fork download
  1. # your code goes here
  2. arr=list(map(int, input().split()))
  3. n=int(input())
  4. k=int(input())
  5. found=False
  6. for i in range(n):
  7. for j in range(i+1, n):
  8. if j<=i+k and arr[i]==arr[j]:
  9. print("The valid pair from equal elements", k)
  10. found=True
  11. break
  12. if found:
  13. break
  14. if not found:
  15. print("there are no equal elements from array", k)
  16.  
Success #stdin #stdout 0.1s 14172KB
stdin
1 1 3 1 2 3
6
2
stdout
The valid pair from equal elements 2