Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = list(map(int, input().split()))
- s = True
- res = 0
- while s:
- c = 0
- i = 1
- k = False
- while i < len(A):
- if A[i] == A[i - 1] and i != len(A) - 1:
- c += 1
- elif i == len(A) - 1 and A[i] == A[i - 1] and c >= 1:
- c += 1
- for j in range(c + 1):
- A.pop(i - c)
- k = True
- res += c + 1
- i -= c
- c = 0
- elif c >= 2:
- for j in range(c + 1):
- A.pop(i - c - 1)
- k = True
- res += c + 1
- i -= c + 1
- c = 0
- else:
- c = 0
- i += 1
- s = k
- else:
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement