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

for i in range(a,b+1)
    if i %  K == 0:
        print('OK')
        exit()
print('NG')

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

for i in range(a,b+1):
    if i %  K == 0:
        print('OK')
        exit()
print('NG')
Buggy python submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

import numpy as np

Q = np.argmax([sum(P[i:i+K]) for i in range(N-K)])

Q = [sum(P[:K])]
for i in range(1,N-K+1):
    Q.append(Q[i-1]+P[K+i-1]-P[i-1])
a = np.argmax(Q)

ans = sum([(1.00+P[a+j])/2.00 for j in range(K)])

print(ans)

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

import numpy as np

Q = np.cumsum(P)

R = np.pad(Q,K,'constant', constant_values=0)[:N]

a = np.argmax(Q-R)

ans = 0
for i in range(K):
    ans += (1.00+P[a-i])/2.00
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))

last_ok_postion = 0 
last_ok_value = P[0]
count = 1

for i in range(1,N):
    if last_ok_value >= P[i]:
        m = min(P[last_ok_postion:i])
        if m >= P[i]:
            count += 1
print(count)

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

last_ok_postion = 0 
count = 1

for i in range(1,N):
    if P[last_ok_postion] >= P[i]:
        m = min(P[last_ok_postion:i])
        if m >= P[i]:
            count += 1
            last_ok_postion = i
print(count)

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

last_ok_postion = 0 
last_ok_value = P[0]
count = 1

for i in range(1,N):
    if last_ok_value >= P[i]:
        check = 0
        for j in range(last_ok_postion,i)[::-1]:
            if P[j] < P[i]:
                check = 1
                break
        if check == 0:
            count += 1
print(count)

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

last_ok_postion = 0 
count = 1

for i in range(1,N):
    if P[last_ok_postion] >= P[i]:
        m = min(P[last_ok_postion:i])
        if m >= P[i]:
            count += 1
            last_ok_postion = i
print(count)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def check(A):
    L = [j+1 for j in range(N)]
    ans = 0
    for i in range(N):
        a = L.index(A[i])
        ans += a*math.factorial(N-1-i)
        L.pop(a)
    return ans
p = check(P)
q = check(Q)
print(abs(P-Q))

Fixed submission:
import math

N = int(input())

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def check(A):
    L = [j+1 for j in range(N)]
    ans = 0
    for i in range(N):
        a = L.index(A[i])
        ans += a*math.factorial(N-1-i)
        L.pop(a)
    return ans
p = check(P)
q = check(Q)
print(abs(p-q))

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def check(A):
    L = [j+1 for j in range(N)]
    ans = 0
    for i in range(N):
        a = L.index(A[i])
        ans += a*math.factorial(N-1-i)
        L.pop(a)
    return ans
p = check(P)
q = check(Q)
print(math.abs(P-Q))

Fixed submission:
import math

N = int(input())

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def check(A):
    L = [j+1 for j in range(N)]
    ans = 0
    for i in range(N):
        a = L.index(A[i])
        ans += a*math.factorial(N-1-i)
        L.pop(a)
    return ans
p = check(P)
q = check(Q)
print(abs(p-q))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
L = np.array(input().split(),dtype = int)

m = min(N,max(L))

r = np.array(np.linspace(1,m,m),int)


dp = [[0 for i in range(N+1)] for j in range(m+1)]

for i in range(m):
    for j in range(N):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
        if r[i] == L[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1)

ans = np.max(dp,axis=1)

c = np.array(np.linspace(0,m,m+1))
#print(c)
#print(ans)
d = np.where(ans==c,ans,0)
#print(d)
e = max(d)
if e == 0:
    print(-1)
else:
    print(N-e)

Fixed submission:
import numpy as np
N = int(input())
L = np.array(input().split(),dtype = int)

m = min(N,max(L))

r = np.array(np.linspace(1,m,m),int)


dp = [0 for i in range(N+1)]

for i in range(0,N):
    if dp[i]+1 ==L[i]:
        dp[i+1] = dp[i]+1
    else:
        dp[i+1] = dp[i]

a = max(dp)
if a == 0:
    print(-1)
else:
    print(N-a)
Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    divisors.sort()
    return divisors
  
N = int(input())
Nlist = make_divisions(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2)

Fixed submission:
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
Nlist = make_divisors(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2))

Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
N = int(input())
Nlist = make_divisions(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2)

Fixed submission:
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
Nlist = make_divisors(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2))

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

k = int(math.sqrt(N))

for i in range(1,k)[-1]:
  if N%i==0:
      print(int(N%i)+i)

Fixed submission:
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
Nlist = make_divisors(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2))
Buggy python submission (verdict: Runtime Error):
N = int(input())

d = list(map(int,input().split()))

S = sum(d)

ans = 0

for i in range(N):
    ans += (S-d[i])*d[i]
print(ans(

Fixed submission:
N = int(input())

d = list(map(int,input().split()))

S = sum(d)

ans = 0

for i in range(N):
    ans += (S-d[i])*d[i]
print(int(ans/2))
Buggy python submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

print(sum([1 if K<=a else 0 for a in A])

Fixed submission:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print(sum([1 if K<=a else 0 for a in A]))
Buggy python submission (verdict: Runtime Error):
N,K,Q = list(map(int,input().split()))
A = []

point = [[K-Q] for _ in range(N)]

for i in range(Q):
    p = int(input())-1
    point[p] += 1
for i in range(N):
    if point[i] <= 0:
        print('No')
    else:
        print('Yes')

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

point = [K-Q for _ in range(N)]

for i in range(Q):
    p = int(input())-1
    point[p] += 1
for i in range(N):
    if point[i] <= 0:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(sum([1 if S[i]==T[i] else 0 for i in range(3)))

Fixed submission:
S = input()
T = input()
print(sum([1 if S[i]==T[i] else 0 for i in range(3)]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

print(sum(range(0,N)))

Fixed submission:
N = int(input())
print(int((N*(N-1))//2))
Buggy python submission (verdict: Runtime Error):
import numpy as np
li = list(map(int,input().split()))
A = li[0]
B = li[1]
print(np.max(A+B,A-B,A*B))

Fixed submission:
import numpy as np
li = list(map(int,input().split()))
A = li[0]
B = li[1]
print(np.max([A+B,A-B,A*B]))
Buggy python submission (verdict: Runtime Error):
import numpy as np
li = list(map(int,input().split()))
N = li[0]
days = li[1]
job_list = []
for i in range(N):
    li = list(map(int,input().split()))
    job_list.append(li) 
job_list = sorted(job_list, key=lambda x:x[0])
money = 0
for day in range(days):
    if len(job_list) == 0:
         break  
    rest_day = days - day
    while (job_list[-1][0] > rest_day):
        job = job_list.pop()
    max_j = np.argmax(np.array(job_list[::-1])[:,1])
    max_job = job_list.pop(-(max_j+1))
    money += max_job[1]
print(money)

Fixed submission:
import heapq
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r) #マイナスにしている
heap = []
rewards = 0
for i in range(M):
    for reward in jobs[i]:
        heapq.heappush(heap,reward)
    if len(heap) != 0:
        r = heapq.heappop(heap)
        rewards += -r
print(rewards)
Buggy python submission (verdict: Runtime Error):
N = int(input())
keta = len(N)
cnt = 0

for i in range(keta):
    if i % 2 == 1:
        cnt += 10**(i) - 10**(i-1)

if keta % 2 == 1:
    cnt += N - 10**(keta-1) + 1

print(cnt)

Fixed submission:
N = int(input())
keta = len(str(N))
cnt = 0

for i in range(keta):
    if i % 2 == 1:
        cnt += 10**(i) - 10**(i-1)

if keta % 2 == 1:
    cnt += N - 10**(keta-1) + 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
road = input()

right = 0
left = 0
flag = 0
ans = [0] * len(road)
for i in range(len(road)):
    if road[i] == 'L' and flag == 0:
        left = i
        flag = 1
        for j in range(right,i):
            
    if road[i] == 'R' and flag == 1:
        for j in range(right,i):
            if abs(j-left) % 2 == 1:
                ans[left] += 1
            else:
                ans[left-1] += 1
        right = i
        flag = 0
print(ans)
      

Fixed submission:
road = input()
 
right = 0
left = 0
flag = 0
ans = [0] * len(road)
for i in range(len(road)):
    if road[i] == 'L' and flag == 0:
        left = i
        flag = 1
            
    if road[i] == 'R' and flag == 1 :
        for j in range(right,i):
            if abs(j-left) % 2 == 1:
                ans[left-1] += 1
            else:
                ans[left] += 1
        right = i
        flag = 0
for j in range(right,len(road)):
    if abs(j-left) % 2 == 1:
        ans[left-1] += 1
    else:
        ans[left] += 1
for a in ans:
    print(a,end=' ')
Buggy python submission (verdict: Runtime Error):
import numpy as np
s = list(input())
if np.sum(s) % 2 != 0:
    print('IMPOSSIBLE')
print(np.sum(s) % 2)

Fixed submission:
x,y = map(int,input().split())
if (x+y) % 2 != 0:
    print('IMPOSSIBLE')
else:
	print(int((x+y) / 2))
Buggy python submission (verdict: Runtime Error):
n = input()
li = list(map(int,input().split()))
false = 0
for i in range(n):
    if i != li[i]:
        false += 1
if false == 0 or false == 2:
    print('YES')
else:
    print('N0')

Fixed submission:
n = input()
li = list(map(int,input().split()))
false = 0
for i in range(int(n)):
    if (i+1) != li[i]:
        false += 1
if false == 0 or false == 2:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
n = input()
li = list(map(int,input().split()))
false = 0
for i in range(n):
    if i != li[i]:
        false += 1
if false == 0 or false == 2:
    print('YES')
else:
    print('N0')

Fixed submission:
n = input()
li = list(map(int,input().split()))
false = 0
for i in range(int(n)):
    if (i+1) != li[i]:
        false += 1
if false == 0 or false == 2:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
s=list(input())

if int(s[0])* int(s[1]) > int(s[2]):
    print(s[2])
else:
    print(int(s[0])* int(s[1]))

Fixed submission:
li = list(map(int,input().split()))
 
if li[0]*li[1] > li[2]:
    print(li[2])
else:
    print(li[0]*li[1])
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M):
        if T[j] == S[i+j] or S[i+j] == '?':
            ans += 1
        else:
            break
    if ans == M:
        for k in range(N):
            if k == i:
                print(T,end='')
            elif k < i or i + M - 1 < k:
                if S[k] == '?':
                    print('a',end='')
                else:
                    print(S[k],end='')
        exit()
    if i == 0:
        print('UNRESTORABLE')
        eixt()
    


Fixed submission:
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M+1):
        if j == M:
            print((S[:i]+T+S[i+M:]).replace('?','a'))
            exit()
        if T[j] == S[i+j] or S[i+j] == '?':
            continue
        else:
            break

print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M):
        if T[j] == S[i+j] or S[i+j] == '?':
            ans += 1
        else:
            break
    if ans == M:
        for k in range(N):
            if k == i:
                print(T,end='')
            elif k < i or i + M - 1 < k:
                if S[k] == '?':
                    print('a',end='')
                else:
                    print(S[k],end='')
            exit()
    if i == 0:
        print('UNRESTORABLE')
        eixt()
    

Fixed submission:
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M+1):
        if j == M:
            print((S[:i]+T+S[i+M:]).replace('?','a'))
            exit()
        if T[j] == S[i+j] or S[i+j] == '?':
            continue
        else:
            break

print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M):
        if T[j] == S[i+j] or S[i+j] == '?':
            ans += 1
        else:
            break
    if ans == M:
        for k in range(N):
            if k == i:
                print(T,end='')
            elif k < i or i + M - 1 < k:
                if S[k] == '?':
                    print('a',end='')
                else:
                    print(S[k],end='')
        break
    if i == 0:
        print('UNRESTORABLE'

Fixed submission:
S = input()
T = input()

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M+1):
        if j == M:
            print((S[:i]+T+S[i+M:]).replace('?','a'))
            exit()
        if T[j] == S[i+j] or S[i+j] == '?':
            continue
        else:
            break

print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
N=int(input())
M=1000000007
dp = [0]*N

E = []
for i in range(N):
    E.append([])

def dfs(cur,pre):
    for r,d in E[cur]:
        if r != pre:
            dp[r] = dp[cur] + d
            dfs(r,cur)


for i in range(N-1):
    x,y,d= list(map(int,input().split()))
    E[x-1].append((y-1,d))
    E[y-1].append((x-1,d))

Q,K = list(map(int,input().split()))

dfs(K-1,-1)

for j in range(Q):
    s,g= list(map(int,input().split()))
    print(dp[s-1]+dp[g-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N=int(input())
dp = [0]*N

E = []
for i in range(N):
    E.append([])

def dfs(cur,pre):
    for r,d in E[cur]:
        if r != pre:
            dp[r] = dp[cur] + d
            dfs(r,cur)


for i in range(N-1):
    x,y,d= list(map(int,input().split()))
    E[x-1].append((y-1,d))
    E[y-1].append((x-1,d))

Q,K = list(map(int,input().split()))

dfs(K-1,-1)

for j in range(Q):
    s,g= list(map(int,input().split()))
    print(dp[s-1]+dp[g-1])
Buggy python submission (verdict: Runtime Error):
s = list(input())

def sum_list(S,stock):
    if len(S) == 2:
        return int(S[0]) + int(S[1]) + int(S[0]+S[1]) + stock * 2
    else:
        return sum_list(S[1:],int(S[0])+stock) + sum_list([S[0]+S[1]]+S[2:],stock)
                                                 
print(sum_list(s,0))

Fixed submission:
s = list(input())

def sum_list(S,stock):
    if len(S) == 2:
        return int(S[0]) + int(S[1]) + int(S[0]+S[1]) + stock * 2
    elif len(S) == 1:
        return int(S[0])
    else:
        return sum_list(S[1:],int(S[0])+stock) + sum_list([S[0]+S[1]]+S[2:],stock)
                                                 
print(sum_list(s,0))
Buggy python submission (verdict: Runtime Error):
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
c = list(itertools.combinations(l, 3))
count=0
r=math.factorial(len(l)) / (math.factorial(len(l) - 3) * 6)
for i in range(r):
    if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
        pass
    else:
        if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
            count+=1
        else:
            pass
print(count)

Fixed submission:
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
if len(l)<=2:
    print('0')
else:
    c = list(itertools.combinations(l, 3))
    count=0
    r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
    for i in range(r):
        if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
            pass
        else:
            if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
                count+=1
            else:
                pass
    print(count)

Buggy python submission (verdict: Runtime Error):
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
c = list(itertools.combinations(l, 3))
count=0
r=math.factorial(len(l)) / (math.factorial(len(l) - 3) * 6)
print(r)
for i in range(r):
    if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
        pass
    else:
        if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
            count+=1
        else:
            pass
print(count)

Fixed submission:
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
if len(l)<=2:
    print('0')
else:
    c = list(itertools.combinations(l, 3))
    count=0
    r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
    for i in range(r):
        if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
            pass
        else:
            if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
                count+=1
            else:
                pass
    print(count)

Buggy python submission (verdict: Runtime Error):
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
c = list(itertools.combinations(l, 3))
count=0
r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
print(r)
for i in range(r):
    if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
        pass
    else:
        if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
            count+=1
        else:
            pass
print(count)

Fixed submission:
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
if len(l)<=2:
    print('0')
else:
    c = list(itertools.combinations(l, 3))
    count=0
    r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
    for i in range(r):
        if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
            pass
        else:
            if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
                count+=1
            else:
                pass
    print(count)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=[map(int,input().split())]
b=[map(int,input().split())]

aa,bb=[0],[0]
for i in range(n):
  aa.append(aa[i]+a[i])
for i in range(m):
  bb.append(bb[i]+b[i])
ans,j=0,m
for i in range(n+1):
  if aa[i]>k:
    break
  while b[j]>k-aa[i]:
    j -= 1
  ans=max(ans,i+j)
print(ans)

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

aa,bb=[0],[0]
for i in range(n):
  aa.append(aa[i]+a[i])
for i in range(m):
  bb.append(bb[i]+b[i])
ans,j=0,m
for i in range(n+1):
  if aa[i]>k:
    break
  while bb[j] > k-aa[i]:
    j -= 1
  ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if i+1 in a:
        print(a[i:].count(i+1))
    else:
        print('0')


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a[i:].count(i+1))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
ans= 0
for s in range(1,k+1):
    for t in range(1,k+1):
        for u in range(1,k+1):
            ans= ans + math.gcd(math.gcd(s,t),u)
print(ans)      

Fixed submission:
import math
k=int(input())
ans= 0
for s in range(1,k+1):
    for t in range(1,k+1):
        if math.gcd(s,t) == 1:
            ans=ans+k
        else:
            for u in range(1,k+1):
                ans= ans + math.gcd(math.gcd(s,t),u)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=0
for i in range(n-1):
    d=max(sorted(a)[i+1]-sorted(a)[i],d)
d=max(k+sorted(a)[0]-sorted(a)[n-1],d)
print(k-d)

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=0
for i in range(n-1):
    d=max(a[i+1]-a[i],d)
d=max(k+a[0]-a[n-1],d)
print(k-d)

Buggy python submission (verdict: Time Limit Exceeded):
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*n
for i in range(n-1):
    d[i]=sorted(a)[i+1]-sorted(a)[i]
d[-1]=k+sorted(a)[0]-sorted(a)[n-1]
print(k-max(d))

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=0
for i in range(n-1):
    d=max(a[i+1]-a[i],d)
d=max(k+a[0]-a[n-1],d)
print(k-d)