Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n, m = map(int, input().split())
li = []
dic = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    dic[p].append(y)
for d in dic:
    dic[d].sort()
for p, y in li:
    ans1 = str(p).zfill(6)
    ans2 = str(dic[p].index(y) + 1).zfill(6)
    print(ans1+ans2)


Fixed submission:
n, m = map(int, input().split())
cnt = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    cnt[p-1].append((y, i))
ans = [None]*m
for p, li in enumerate(cnt):
    if not li:
        continue
    li.sort()
    for j, (y, i) in enumerate(li):
        ans[i] = '{:06d}{:06d}'.format(p+1, j+1)
print('\n'.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n, m = map(int, input().split())
li = []
dic = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    dic[p].append(y)
for d in dic:
    dic[d].sort()
for p, y in li:
    ans1 = str(p).zfill(6)
    ans2 = str(dic[p].index(y) + 1).zfill(6)
    print(ans1+ans2)


Fixed submission:
n, m = map(int, input().split())
cnt = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    cnt[p-1].append((y, i))
ans = [None]*m
for p, li in enumerate(cnt):
    if not li:
        continue
    li.sort()
    for j, (y, i) in enumerate(li):
        ans[i] = '{:06d}{:06d}'.format(p+1, j+1)
print('\n'.join(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print('Hello World')
else:
    A, B = map(int, input().split())
    print(A+B)


Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))

Buggy python submission (verdict: Runtime Error):
import sys
N = input()
if N == 1:
    print('Hello World')
    sys.exit()
else:
    A, B = map(int, input().split())
    print(A+B)


Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))

Buggy python submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
    exit()
else:
    A, B = map(int, input().split())
    print(A+B)


Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))

Buggy python submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))


Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))
Buggy python submission (verdict: Runtime Error):
pc = [list(map(int, input().split())) for i in range(D)]


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)


Fixed submission:
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
ans = []
pool = [i for i in range(a, b+1)]
ans += pool[:k] + pool[-k:]
ans = list(set(ans))
ans.sort()
[print(i) for i in ans]


Fixed submission:
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a+k, b)):
    ans.append(i)
for i in range(max(b-k+1, a), b+1):
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]
A += list(map(int, input().split()))
A += [0]
cost = [abs(A[i] - A[i+1]) for i in range(N+1)]
for i in range(1, N+1):
    print(sum(cost) - (cost[i-1] + cost[i]) + abs(A[i+1] - A[i-1]))


Fixed submission:
N = int(input())
A = [0]
A += list(map(int, input().split()))
A += [0]
cost = [abs(A[i] - A[i+1]) for i in range(N+1)]
sumcost = sum(cost)
for i in range(1, N+1):
    print(sumcost - (cost[i-1] + cost[i]) + abs(A[i+1] - A[i-1]))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('R

Fixed submission:
a, b, c, d = map(int, input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]
newS = [['#' for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            if i == 0:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            elif i == H-1:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
            else:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            newS[i][j] = str(cnt)
for i in newS:
    print(''.join(i))


Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
ad = ['.' for _ in range(W)]
S.append(ad)
S.insert(0, ad)
newS = [['#' for _ in range(W)] for _ in range(H)]
for i in range(1, H+1):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            cnt = S[i][c:d+1].count('#')
            cnt += S[i-1][c:d+1].count('#')
            cnt += S[i+1][c:d+1].count('#')
            newS[i-1][j] = str(cnt)
for i in newS:
    print(''.join(i))

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]
newS = [['#']*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            if i == 0:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            elif i == H-1:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
            else:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            newS[i][j] = str(cnt)
for i in newS:
    print(''.join(i))


Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
ad = ['.' for _ in range(W)]
S.append(ad)
S.insert(0, ad)
newS = [['#' for _ in range(W)] for _ in range(H)]
for i in range(1, H+1):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            cnt = S[i][c:d+1].count('#')
            cnt += S[i-1][c:d+1].count('#')
            cnt += S[i+1][c:d+1].count('#')
            newS[i-1][j] = str(cnt)
for i in newS:
    print(''.join(i))
Buggy python submission (verdict: Runtime Error):
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 0
for i in set(an):
    ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1))
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(min(an), max(an)+1):
    ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1))
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 0
for i in set(an):
    ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1))
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(min(an), max(an)+1):
    ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1))
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 10e+9
for i in range(1, N):
    ans = min(ans, abs(sum(an[:i]) - sum(an[i:])))
print(ans)


Fixed submission:
from itertools import accumulate
N = int(input())
an = list(map(int, input().split()))
res = [0] + an
res = list(accumulate(res))
ans = 10e+9
for i in range(1, N):
    ans = min(ans, abs(res[i] - (res[-1]-res[i])))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
an = list(map(int, input().split()))
ans = 10e+9
for i in range(1, N):
    ans = min(ans, abs(sum(an[:i]) - sum(an[i:])))
print(ans)


Fixed submission:
from itertools import accumulate
N = int(input())
an = list(map(int, input().split()))
res = [0] + an
res = list(accumulate(res))
ans = 10e+9
for i in range(1, N):
    ans = min(ans, abs(res[i] - (res[-1]-res[i])))
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
mod = 10e+9 + 7
n, m = map(int, input().split())
ans = math.factorial(n)*math.factorial(m)
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 0:
    ans *= 2
print(ans % mod)


Fixed submission:
import math
mod = 10**9 + 7
n, m = map(int, input().split())
ans = math.factorial(n)*math.factorial(m)
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 0:
    ans *= 2
print(ans % mod)

Buggy python submission (verdict: Runtime Error):
import math
mod = 10e+9 + 7
n, m = map(int, input().split())
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 1:
    ans = (math.factorial(n) % mod)*(math.factorial(m) % mod)
else:
    ans = (math.factorial(n) % mod)*(math.factorial(m) % mod)*2
print(int(ans % mod))


Fixed submission:
import math
mod = 10**9 + 7
n, m = map(int, input().split())
ans = math.factorial(n)*math.factorial(m)
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 0:
    ans *= 2
print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
array = []
for i in range(N):
    a, b = map(int, input().split())
    array += [a]*b
array.sort()
print(array[K-1])


Fixed submission:
N, K = map(int, input().split())
abn = [list(map(int, input().split())) for _ in range(N)]
abn.sort()
pool = 0
for ab in abn:
    pool += ab[1]
    if pool >= K:
        print(ab[0])
        break
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
rep = []
rep.append(1)
onf = 0
def repeat(i,rep):
    if a[i] not in rep:
        rep.append(a[i])
        repeat(a[i]-1,rep)
    else:
        rep.append(a[i])
        return 1
onf=repeat(0,rep)
if onf==0:
    print(rep)
else:
    lr = len(rep)
    for i in range(lr):
        if rep[i]==rep[lr-1]:
            start=i
            rep2 = rep[i:lr-1]
            break
    mod = len(rep2)
    modL = [i%mod for i in range(start,start+mod)]
    resM = k%mod
    for i in range(mod):
        if resM == modL[i]:
            print(rep2[i])

Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
visit = []
visit = [0]*n
pos=0
move=[]
roop=[]
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos]+=1
    pos = a[pos]-1
if len(move)>k:
    print(move[k]+1)
else:
    mod = (k-(len(move)-len(roop)))%len(roop)
    print(roop[mod]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a = list(map(int,input().split()))
rep = []
rep.append(1)
i = 0
cnt = 0
if n>k:
    end =k
else:
    end =n
nof = 0
while True:
    cnt+=1
    if cnt>end:
        nof=1
        break
    go = a[i]-1
    if a[i] not in rep:
        rep.append(a[i])
        i = go
    else:
        rep.append(a[i])
        break
if nof==1:
    print(rep[k])
else:
    lr = len(rep)
    for i in range(lr):
        if rep[i]==rep[lr-1]:
            start=i
            rep2 = rep[i:lr-1]
            break
    mod = len(rep2)
    modL = [i%mod for i in range(start,start+mod)]
    resM = k%mod
    for i in range(mod):
        if resM == modL[i]:
            print(rep2[i])

Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
visit = []
visit = [0]*n
pos=0
move=[]
roop=[]
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos]+=1
    pos = a[pos]-1
if len(move)>k:
    print(move[k]+1)
else:
    mod = (k-(len(move)-len(roop)))%len(roop)
    print(roop[mod]+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=dict(Counter(L))
z2=dict(Counter(R))
cnt=0
for k1,v1 in z1.items():
    for k2,v2 in z2.items():
        if k1 == k2:
            cnt += v1*v2
print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=Counter(L)
z2=Counter(R)
cnt=0
for k1,v1 in z1.items():
    v2 = z2[k1]
    cnt += v1*v2
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int,input().split()))
c = [i for i in range(n)]
comb = list(itertools.combinations(c,2))
cnt=0
for x in range(len(comb)):
    i = comb[x][0]
    j = comb[x][1]
    if j-i==a[j]+a[i]:
        cnt+=1
print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=Counter(L)
z2=Counter(R)
cnt=0
for k1,v1 in z1.items():
    v2 = z2[k1]
    cnt += v1*v2
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int,input().split()))
suml = list(itertools.combinations(a,2))
d=[i+j for i,j in suml]
cnt=0
co=0
for i in range(n-1):
    for j in range(i+1,n):
        if j-i==d[co]:
            cnt+=1
        co+=1
print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=Counter(L)
z2=Counter(R)
cnt=0
for k1,v1 in z1.items():
    v2 = z2[k1]
    cnt += v1*v2
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m,q = map(int,input().split())
ch = list(itertools.combinations_with_replacement(range(1,m+1),n))
lch = len(ch)
rel = [0]*lch
l = [list(map(int,input().split())) for _ in range(q)]
for k in range(lch):
    for i in range(q):
        a = l[i][0]
        b = l[i][1]
        c = l[i][2]
        d = l[i][3]
        if ch[k][b-1]-ch[k][a-1]==c:
            rel[k]+=d
print(max(rel))

Fixed submission:
import itertools
n,m,q = map(int,input().split())
ch = list(itertools.combinations_with_replacement(range(1,m+1),n))
lch = len(ch)
rel = [0]*lch
l = [list(map(int,input().split())) for _ in range(q)]
for k in range(lch):
    for i in range(q):
        if ch[k][l[i][1]-1]-ch[k][l[i][0]-1]==l[i][2]:
            rel[k]+=l[i][3]
print(max(rel))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m,q = map(int,input().split())
ch = list(itertools.combinations_with_replacement(range(1,m+1),n))
rel = [0]*len(ch)
l = [list(map(int,input().split())) for _ in range(q)]
for k in range(len(ch)):
    for i in range(q):
        a = l[i][0]
        b = l[i][1]
        c = l[i][2]
        d = l[i][3]
        if ch[k][b-1]-ch[k][a-1]==c:
            rel[k]+=d
print(max(rel))

Fixed submission:
import itertools
n,m,q = map(int,input().split())
ch = list(itertools.combinations_with_replacement(range(1,m+1),n))
lch = len(ch)
rel = [0]*lch
l = [list(map(int,input().split())) for _ in range(q)]
for k in range(lch):
    for i in range(q):
        if ch[k][l[i][1]-1]-ch[k][l[i][0]-1]==l[i][2]:
            rel[k]+=l[i][3]
print(max(rel))
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
m = 0
x = 1
ax = a*x
while ax/b <0.01:
    x*=10
    ax = a*x
    if x>n:
        x//10
        break
if a-b==1:
    print(n)
elif b-a==1:
    print(n-1)
else:
    for i in range(x,n+1):
        ch = math.floor(a*i/b)-a*math.floor(i/b)
        m = max(m,ch)
        if m!=0 and ch==0:
            break
    print(m)

Fixed submission:
import math
a,b,n = map(int,input().split())
x = min(b-1,n)
print(math.floor(a*x/b)-a*math.floor(x/b))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
m = 0
if a-b==1:
    print(n)
elif b-a==1:
    print(n-1)
else:
    for i in range(n+1):
        ch = math.floor(a*i/b)-a*math.floor(i/b)
        m = max(m,ch)
        if m!=0 and ch==0:
            break
    print(m)


Fixed submission:
import math
a,b,n = map(int,input().split())
x = min(b-1,n)
print(math.floor(a*x/b)-a*math.floor(x/b))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
m = 0
for i in range(1,n+1):
    ch = math.floor(a*i/b)-a*math.floor(i/b)
    m = max(m,ch)
print(m)



Fixed submission:
import math
a,b,n = map(int,input().split())
x = min(b-1,n)
print(math.floor(a*x/b)-a*math.floor(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
mod = 2019
ls = len(s)
cnt = 0
dp = []
for i in range(ls-3):
    st = int(s[i:i+2])
    if st%2!=0:
        continue
    for j in range(i+3,ls):
        c = int(s[i:j+1])
        if c in dp:
            cnt+=1
        elif c%mod ==0:
            dp.append(c)
            cnt+=1
print(cnt)

Fixed submission:
s = input()
res = 0
m = 1
p =[0]*2019
for i in map(int,s[::-1]):
    res +=i*m
    res %=2019
    p[res] +=1
    m *=10
    m %=2019
print(p[0]+sum([i*(i-1)//2 for i in p]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
mod = 2019
ls = len(s)
cnt = 0
for i in range(ls-3):
    st = int(s[i:i+2])
    if st%2!=0:
        continue
    for j in range(i+3,ls):
        c = int(s[i:j+1])
        if c%mod ==0:
            cnt+=1
print(cnt)

Fixed submission:
s = input()
res = 0
m = 1
p =[0]*2019
for i in map(int,s[::-1]):
    res +=i*m
    res %=2019
    p[res] +=1
    m *=10
    m %=2019
print(p[0]+sum([i*(i-1)//2 for i in p]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
mod = 2019
ls = len(s)
cnt = 0
for i in range(ls-3):
    st = int(s[i:i+2])
    if st%2!=0:
        continue
    for j in range(i+3,ls):
        c = int(s[i:j+1])
        if c%mod ==0:
            cnt+=1
print(cnt)

Fixed submission:
s = input()
res = 0
m = 1
p =[0]*2019
for i in map(int,s[::-1]):
    res +=i*m
    res %=2019
    p[res] +=1
    m *=10
    m %=2019
print(p[0]+sum([i*(i-1)//2 for i in p]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
mod = 2019
ls = len(s)
cnt = 0
for i in range(ls-3):
    for j in range(i+3,ls):
        c = int(s[i:j+1])
        if c%mod ==0:
            cnt+=1
print(cnt)

Fixed submission:
s = input()
res = 0
m = 1
p =[0]*2019
for i in map(int,s[::-1]):
    res +=i*m
    res %=2019
    p[res] +=1
    m *=10
    m %=2019
print(p[0]+sum([i*(i-1)//2 for i in p]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
r = [0]*n
for i in range(n-1):
    r[a[i]-1] += 1
[print(r[i]) for i in range(n)]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r,g,b =0,0,0
for i in range(len(s)):
    if s[i]=='R':
        r+=1
    elif s[i]=='G':
        g+=1
    elif s[i]=='B':
        b+=1
cnt =0
for j in range(1,len(s)-1):
    for i in range(j):
        k = 2*j-i
        if k<len(s):
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                cnt+=1
print(r*g*b-cnt)


Fixed submission:
n = int(input())
s = input()
r,g,b =0,0,0
ls = len(s)
for i in range(ls):
    if s[i]=='R':
        r+=1
    elif s[i]=='G':
        g+=1
    elif s[i]=='B':
        b+=1
cnt =0
for j in range(1,ls-1):
    for i in range(j):
        k = 2*j-i
        if k<ls:
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                cnt+=1
print(r*g*b-cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
cnt =0
for i in range(len(s)-2):
    for j in range(i+1,len(s)-1):
        for k in range(j+1,len(s)):
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                if j-i!=k-j:
                    cnt+=1
print(cnt)

Fixed submission:
n = int(input())
s = input()
r,g,b =0,0,0
ls = len(s)
for i in range(ls):
    if s[i]=='R':
        r+=1
    elif s[i]=='G':
        g+=1
    elif s[i]=='B':
        b+=1
cnt =0
for j in range(1,ls-1):
    for i in range(j):
        k = 2*j-i
        if k<ls:
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                cnt+=1
print(r*g*b-cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
x = n
if k==1:
    print(0)
else:
    while x > abs(x-k):
        x = abs(x-k)
    print(x)

Fixed submission:
n,k = list(map(int,input().split()))
x = n
if n>=k:
    x = n%k
if x >abs(x-k):
    print(abs(x-k))
else:
    print(x)