Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if cnt = a[cnt-1]:
        print(cnt)
        exit()
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])


Fixed submission:
N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

done = [-1]*N
done[0] = 0

tmp = 0
done[0] = 0
for k in range(1, K + 1):
    tmp = A[tmp]
    if done[tmp] >= 0:
        for _ in range((K - done[tmp]) % (k - done[tmp])):
            tmp = A[tmp]
        print(tmp + 1)
        exit()
    else:
        done[tmp] = k
print(tmp + 1)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])

Fixed submission:
N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

done = [-1]*N
done[0] = 0

tmp = 0
done[0] = 0
for k in range(1, K + 1):
    tmp = A[tmp]
    if done[tmp] >= 0:
        for _ in range((K - done[tmp]) % (k - done[tmp])):
            tmp = A[tmp]
        print(tmp + 1)
        exit()
    else:
        done[tmp] = k
print(tmp + 1)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

import fractions

res = 0


for i in range(1, K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            a = list([i, j, l])
            ans = a[0]
            for n in range(1, 3):
                ans = fractions.gcd(ans, a[n])
            res += ans

print(res)


Fixed submission:
import math

K = int(input())

ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        t = math.gcd(i, j)
        for k in range(1,K+1):
            ans += math.gcd(t, k)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

a = S[0]
res= 0

for i in range(1, N-2):
    if a == S[i]:
        b = S[i]
        for j in range(j, N-1):
            if i == j:
                continue
            c = S[j]
            if a!=b and b!= c and a!=c:
                res +=1

print(res)

Fixed submission:
N = int(input())
S = list(input())

cntOne = S.count('R') * S.count('G') * S.count('B')
cntTwo = 0


for i in range(N-1):
    for j in range(i+1, N):
        k = (j - i) + j
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cntTwo += 1
print(cntOne - cntTwo)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
index = [i for i in range(N)]

ans = 0

from itertools import permutations, combinations,combinations_with_replacement,product,chain, zip_longest

it = zip_longest(index, S)

C = list(combinations(it,3))

i = 0

for c in C:
    i, j, k = c[0][0]+1, c[1][0]+1, c[2][0]+1
    c1, c2, c3 = c[0][1], c[1][1], c[2][1]

    if i < j < k:
        if c1 != c2 and c1 != c3 and c2 != c3:
            if j-i != k-j:
                ans += 1

print(ans)


Fixed submission:
N = int(input())
S = list(input())

cntOne = S.count('R') * S.count('G') * S.count('B')
cntTwo = 0


for i in range(N-1):
    for j in range(i+1, N):
        k = (j - i) + j
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cntTwo += 1
print(cntOne - cntTwo)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
 
N, K, C = map(int, input().split())
S = input()
 
days = [i+1 for i, x in enumerate(S) if x == 'o']
 
wp = list(itertools.combinations(days,K))
wList =[]
 
for w in wp:
  w = list(w)
  isContinue = False
  for sub in range(len(w)-1):
    if w[sub+1] - w[sub] <= C:
      isContinue = True
  if isContinue == False:
    wList.append(w)
 
#tp = map(tuple, wList)
#qty = map(lambda x: tp.count(x), tuple(tp))
#print(set(wList[1]) & set([6]))
#print(set(wList[1] & set(6)))
 
ans = wList[0]
for i in wList:
  ans = (set(i) & set(list(ans)))
 
ans = sorted(list(ans))
for i in ans:
  print(i)

Fixed submission:
N, K, C = map(int, input().split())
S = input()
S_reverse = S[::-1]

l = []
r = []

i = 0
while i<N and len(l)<K:
    if S[i] == 'o':
        l.append(i+1)
        i += C+1
    else:
        i += 1

i = 0
while i<N and len(r)<K:
    if S_reverse[i] == 'o':
        r.append(i)
        i += C+1
    else:
        i += 1

r = [N - i for i in r]
r.reverse()

ans = []

# print(l)
# print(r)

for i in range(K):
    if l[i] == r[i]:
        ans.append(l[i])


# exit()
# ans = set(l) & set(r)

# ans = list(ans)
ans.sort()

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K, C = map(int, input().split())
S = input()

days = [i+1 for i, x in enumerate(S) if x == 'o']

wp = list(itertools.combinations(days,K))
wList =[]

for w in wp:
  w = list(w)
  isContinue = False
  for sub in range(len(w)-1):
    if w[sub+1] - w[sub] <= C:
      isContinue = True
  if isContinue == False:
    wList.append(w)

#tp = map(tuple, wList)
#qty = map(lambda x: tp.count(x), tuple(tp))
#print(set(wList[1]) & set([6]))
#print(set(wList[1] & set(6)))

ans = wList[0]
for i in wList:
  ans = (set(i) & set(list(ans)))

ans = sorted(list(ans))
for i in ans:
  print(i)

Fixed submission:
N, K, C = map(int, input().split())
S = input()
S_reverse = S[::-1]

l = []
r = []

i = 0
while i<N and len(l)<K:
    if S[i] == 'o':
        l.append(i+1)
        i += C+1
    else:
        i += 1

i = 0
while i<N and len(r)<K:
    if S_reverse[i] == 'o':
        r.append(i)
        i += C+1
    else:
        i += 1

r = [N - i for i in r]
r.reverse()

ans = []

# print(l)
# print(r)

for i in range(K):
    if l[i] == r[i]:
        ans.append(l[i])


# exit()
# ans = set(l) & set(r)

# ans = list(ans)
ans.sort()

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

import collections
import copy

ans = 0

for i in range(len(A)):
  ans = 0
  list = copy.copy(A)
  list.pop(i)
  c = collections.Counter(list)
  #for v in c.values():
  #  ans += (v*(v-1)/2)
  a = sum([int((i*i-i)/2) for i in c.values()])
  print(a)
  #print(int(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
import collections
import copy

tot = 0
c = collections.Counter(copy.copy(A))
for v in c.values():
  tot += (v*(v-1)/2)

for n in A:
  ans = tot
  ans -= c[n]*(c[n]-1)/2
  ans += (c[n]-1)*(c[n]-2) / 2 
  print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

import collections
import copy

ans = 0

for i in range(len(A)):
  ans = 0
  list = copy.copy(A)
  list.pop(i)
  c = collections.Counter(list)
  for v in c.values():
    ans += (v*(v-1)/2)
  print(int(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
import collections
import copy

tot = 0
c = collections.Counter(copy.copy(A))
for v in c.values():
  tot += (v*(v-1)/2)

for n in A:
  ans = tot
  ans -= c[n]*(c[n]-1)/2
  ans += (c[n]-1)*(c[n]-2) / 2 
  print(int(ans))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if a**2 + 2*math.sqrt(a*b)+b**2 -c**2 < 0:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b,c = map(int,input().split())

if (c-a-b)>0 and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if a**2 + 2*math.sqrt(a*b)+b**2 < c**2:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b,c = map(int,input().split())

if (c-a-b)>0 and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

if a**2 + 2*math.sqrt(a*b)+b**2 < c**2:
  print('yes')
else:
  print('no')

Fixed submission:
a,b,c = map(int,input().split())

if (c-a-b)>0 and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for i in range(M)]

sc = list(map(list, set(map(tuple, A))))
for i in range(len(sc)):
    tmp0 = sc[i][0]
    tmp1 = sc[i][1]
    for j in range(1, len(sc)-i+1):
        if tmp0 == sc[-j][0] and tmp1 != sc[-j][1]:
            print(-1)
            exit()

if N == 3:
    #for i in range(100,1000):
        #i_str = str(i)
    for j in range(len(sc)):
        if sc[j][0] == 1 and sc[j][0] == 0:
            print(-1)
            exit()
        if sc[j][0] == 1:
            num = sc[j][1]
print(-1)

Fixed submission:
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]

ans = -1

for x in range(1000):
    if len(str(x)) != N: 
        continue
    else:
        count = 0
        s = str(x)
        for p in P:
            if int(s[int(p[0]) - 1]) == p[1]:
                count += 1
        if count == M:
            ans = x
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for i in range(M)]

sc = list(map(list, set(map(tuple, A))))
for i in range(len(sc)):
    tmp0 = sc[i][0]
    tmp1 = sc[i][1]
    for j in range(1, len(sc)-i+1):
        if tmp0 == sc[-j][0] and tmp1 != sc[-j][1]:
            print(-1)
            exit()

if N == 3:
    #for i in range(100,1000):
        #i_str = str(i)
    for j in range(len(sc)):
        if sc[j][0] == 1 and sc[j][0] == 0:
            print(-1)
            exit()
        if sc[j][0] == 1:
            num = sc[j][1]
    

Fixed submission:
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]

ans = -1

for x in range(1000):
    if len(str(x)) != N: 
        continue
    else:
        count = 0
        s = str(x)
        for p in P:
            if int(s[int(p[0]) - 1]) == p[1]:
                count += 1
        if count == M:
            ans = x
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split())) 

ans = 1

for i in range(1, N):
    if min(P[0:i]) >= P[i]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split())) 

ans = 1
mini = P[0]

for i in range(1, N):
    if P[i] < mini:
        mini = P[i]
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[i for i in input().split()]
    x.append(int(x1))
    y.append(y1)

if not any(x):
  print('{} {}'.format(0, 0))
  exit()


countWC = 0
countAC = 0
index = 0

for i in range(N):
  while y[index] == 'WA':
    countWC += 1
    index += 1   
  if index > 0:
    if x[index] == x[index - 1]:
      if y[index] == 'AC' and y[index - 1] == 'AC':
        continue
      if y[index] == 'WA' and y[index - 1] == 'AC':
        continue
  countAC += 1 
  index += 1

	
print('{} {}'.format(countAC, countWC))

Fixed submission:
N, M = map(int, input().split())

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())
f=math.gcd(a,b)
f2=a*b//f
print(f2)


Fixed submission:
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split())) 

ans = 0

for a in range(0, N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            n1, n2, n3 = L[a], L[b], L[c]
            if n1<n2+n3 and n2<n3+n1 and n3<n1+n2:
                ans += 1

print(ans)
exit()
from itertools import permutations, combinations,combinations_with_replacement,product

C = list(combinations(L,3))

ans = 0

for i in C:
    a, b, c = i
    if a<b+c and b<c+a and c<a+b:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split()))) 

ans = 0

import bisect

for a in range(N):
    for b in range(a):
        A=L[a]
        B=L[b]
        c=bisect.bisect_left(L, A+B)
        ans+=c-a-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split())) 

from itertools import permutations, combinations,combinations_with_replacement,product

C = list(combinations(L,3))

ans = 0

for i in C:
    a, b, c = i
    if a<b+c and b<c+a and c<a+b:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split()))) 

ans = 0

import bisect

for a in range(N):
    for b in range(a):
        A=L[a]
        B=L[b]
        c=bisect.bisect_left(L, A+B)
        ans+=c-a-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 

ans = [0] * N

for i in range(N):
    num = A.index(i+1) + 1
    ans[i] = str(num) + " "

s = "".join(ans)

print(s)

Fixed submission:
N = int(input())
A = list(map(int, input().split())) 

ans = [0] * N

for i in range(N):
    num = A[i]
    ans[num-1] = i + 1

print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split())) 
H.reverse()

ans = 0
arr = []

for i in range(N-1):
    if H[i+1] >= H[i]:
        ans += 1
    else:
        arr.append(ans)
        ans = 0

print(max(arr))

Fixed submission:
N = int(input())
H = list(map(int, input().split())) 

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] < H[i+1]:
        cnt = 0
    else:
        cnt += 1
    ans = max(cnt, ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A =[int(input()) for _ in range(N)]

for i in range(N):
    B = A[:i] + A[i+1:]
    print(max(B))

Fixed submission:
N = int(input())
A =[int(input()) for _ in range(N)]

B = sorted(A)
M, m = B[N-1], B[N-2]

for i in A:
    if i == M:
        print(m)
    else:
        print(M)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

R = min(R, L+4038)

ans = 2018

for i in range(L, R+1):
    for j in range(i+1, R+1):
        x = (i*j) % 2019
        ans = min(ans, x)

print(ans)

Fixed submission:
L, R = map(int, input().split())

if R - L >= 2019:
    ans = 0
else:
    l, r = L % 2019, R % 2019
    ans = 2018 ** 2
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            x = (i*j) % 2019
            ans = min(ans, x)

print(ans)
Buggy python submission (verdict: Runtime Error):
zero_one = [0 if i%2==0 else 1 for i in range(len(S))]
one_zero = [0 if i%2==1 else 1 for i in range(len(S))]

count_zero_one = 0
count_one_zero = 0

for i in range(length):
  if int(S[i]) != zero_one[i]:
    count_zero_one += 1
  if int(S[i]) != one_zero[i]:
    count_one_zero += 1

if count_zero_one <= count_one_zero:
  print(count_zero_one)
else:
  print(count_one_zero)


Fixed submission:
S = input()

n = len(S)
cnt = 0

for i in range(n):
  if int(S[i])%2 == i%2:
    cnt += 1
    
print(min(cnt, n-cnt))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

ans = 0

for i in range(len(s)):
    if s[i] == 'B':
        ans += s[i+1:].count('W')

print(ans)

Fixed submission:
s = list(input())

ans = 0

cntB = 0

for i in range(len(s)):
    if s[i] == 'B':
        cntB += 1
    else:
        ans += cntB

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m, x = map(int, input().split())
a = np.array(list(map(int, input().split())))


print(min(len(a[a<x]),len(a[a>x])))

Fixed submission:
import numpy as np

n, m, x = map(int, input().split())
a = np.array(list(map(int, input().split())))


print(min(len(a[a<x]),len(a[a>x])))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

for i in range(a, b+1):
    if  i < a+k:
        print(i)
    elif b-k < i:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())

s1 = [i for i in range(a, a+k) if i<=b]
s2 = [i for i in range(b-k+1, b+1) if i>=a]

s = list(set(s1+s2))
s.sort()

for i in s:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
char = ['M', 'A', 'R', 'C', 'H']

n = int(input())
s = [input() for _ in range(n)]
s = [i[0] for i in s if i[0] in char]

# print(s)

from itertools import permutations, combinations,combinations_with_replacement,product

c = list(combinations(s,3))

ans = 0

for i in c:
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
S = [0] * 5
for _ in range(N):
  s = input()
  if s[0] == "M": S[0] += 1
  elif s[0] == "A": S[1] += 1
  elif s[0] == "R": S[2] += 1
  elif s[0] == "C": S[3] += 1
  elif s[0] == "H": S[4] += 1
 
import itertools
ans = 0
for v in itertools.combinations(S, 3):
  ans +=  v[0] * v[1] * v[2]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

import math
a = list(map(int, input().split()))
#最大公約数
ans = a[0]
for i in range(1, N):
    ans = math.gcd(ans, a[i])

cnt = 0

while ans%2 == 0:
    ans /= 2
    cnt += 1

print(cnt)

Fixed submission:
N = int(input())

import fractions
a = list(map(int, input().split()))
#最大公約数
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])

cnt = 0

while ans%2 == 0:
    ans /= 2
    cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

A.sort()
C.sort()

ans = 0

for b in B:
    indexA = bisect.bisect_left(A, b)
    indexC = bisect.bisect_right(C, b)

    #print(indexA)
    #print(indexC)

    #if indexA != N-1 or indexC != 0:
    ans += len(A[0:indexA]) * len(C[indexC:N+1])

print(ans)

Fixed submission:
import bisect

N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

A.sort()
C.sort()

ans = 0

for b in B:
    indexA = bisect.bisect_left(A, b)
    indexC = bisect.bisect_right(C, b)

    ans += indexA * (N-indexC)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, L = map(int, input().split())

S = [0] * N

for i in range(N):
    S[i] = input()

from itertools import permutations, combinations,combinations_with_replacement,product

strings = [''.join(s) for s in list(permutations(S))]

strings.sort()
print(strings[0])

Fixed submission:
N, L = map(int, input().split())
S = [input() for _ in range(N)]
S.sort()
ans = ''.join(S)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
points = [int(i) for i in input().split()]
scores = [0] * n
scores[0] = points[0]

for i in range(1, n):
    scores[i] = scores[i - 1] * points[i]
    
    if k <= i:
        scores[i] //= points[i - k]
        
for i in range(k, n):
    if scores[i - 1] < scores[i]:
        print('Yes')
    else:
        print('No')

Fixed submission:
n, k = map(int, input().split())
points = [int(i) for i in input().split()]

for i in range(k, n):
    if points[i - k] < points[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

for i in range(n):
    ans = 0
    for j in range(n):
        if j == i:
            continue
        
        ans = ans^a[j]
        
    print(ans, end=' ')


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    ans = ans^a[i]
    
for i in range(n):
    print(ans^a[i], end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
cnt = [0] * (10**6 + 1)

dic = Counter(a)

for i in set(a):
    if 1 < dic[i]:
        cnt[i] += 1
        
a = list(set(a))

for i in a:
    for j in range(10**6 + 1):
        if 10**6 < i * j:
            break
        
        cnt[i * j] += 1

ans = 0
for i in range(len(a)):
    if cnt[a[i]] == 1:
        ans += 1
        
print(ans)

Fixed submission:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
cnt = [0] * (10**6 + 1)

dic = Counter(a)

for i in set(a):
    if 1 < dic[i]:
        cnt[i] += 1
        
a = list(set(a))
a_max = max(a)
for i in a:
    for j in range(1, 10**6 + 1):
        if a_max < i * j:
            break
        
        cnt[i * j] += 1

ans = 0
for i in range(len(a)):
    if cnt[a[i]] == 1:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
test = [n] * n

for i in range(k):
    tmp = [0] * n
    for j in range(n):
        for k in range(j - a[j], j + a[j] + 1):
            if k < 0 or n <= k:
                continue
            
            tmp[k] += 1
            
    a = tmp
    
    if a == test:
        print(i)
        break

for i in range(n):
    print(a[i], end=' ')

Fixed submission:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

for i in range(min(k, 450)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

for i in range(n):
    print(a[i], end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = [int(i) for i in input().split()]

observatorys = [[] for i in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    if a in observatorys[b]:
        continue
    
    if b in observatorys[a]:
        continue
    
    observatorys[a].append(b)
    observatorys[b].append(a)
    
ans = 0
for i in range(n):
    flg = False
    for ob in observatorys[i]:
        if h[i] <= h[ob]:
            flg = True
            break
    if flg:
        continue
    
    ans += 1

print(ans)

Fixed submission:
n, m = map(int, input().split())
h = [int(i) for i in input().split()]

observatorys = [[] for i in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    if a in observatorys[b]:
        continue
    
    if b in observatorys[a]:
        continue
    
    observatorys[a].append(b)
    observatorys[b].append(a)
    
ans = 0
for i in range(n):
    flg = False
    for ob in observatorys[i]:
        if h[i] <= h[ob]:
            flg = True
            break
    if flg:
        continue
    
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

cnt = 0
for i in range(n - 2):
    for j in range(i + 1,n - 1):
        for k in range(j + 1,n):
            if j - i == k - j:
                continue
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
                
print(cnt)

Fixed submission:
n = int(input())
s = input()

cnt = 0
for i in range(n):
    for j in range(1, (n - 1) // 2 + 1):
        if n - 1 < i + 2 * j:
            break
        
        if s[i] != s[i + j] and s[i + j] != s[i + 2 * j] and s[i + 2 * j] != s[i]:
            cnt += 1
            continue
        
ans = [0] * 3
for word in s:
    if word == 'R':
        ans[0] += 1
    elif word == 'G':
        ans[1] += 1
    else:
        ans[2] += 1

ans_sum = ans[0] * ans[1] * ans[2]
print(ans_sum - cnt)