fork download
  1. def processArray(arr):
  2. n = len(arr)
  3. i = 0
  4. write_index = 0
  5.  
  6. while i < n:
  7. if arr[i] % 10 == 6:
  8. j = i
  9. while j < n and arr[j] % 10 == 6:
  10. j += 1
  11. if j - i >= 2:
  12. i = j
  13. continue
  14. arr[write_index] = arr[i]
  15. write_index += 1
  16. i += 1
  17.  
  18. return write_index
  19.  
  20.  
  21. if __name__ == "__main__":
  22. import sys
  23. data = sys.stdin.read().strip().split()
  24. arr = []
  25. for num in map(int, data):
  26. if num < 0:
  27. break
  28. arr.append(num)
  29.  
  30. new_len = processArray(arr)
  31. for i in range(new_len):
  32. print(arr[i])
Success #stdin #stdout 0.11s 14108KB
stdin
Standard input is empty
stdout
Standard output is empty