Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)


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

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False and cnt[a] <= 1:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)

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

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)


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

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False and cnt[a] <= 1:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
INF = pow(10, 9)


def main():
    n, m, x = map(int, input().split())
    i = 0
    c = []
    a = []

    for i in range(n):
        tmp = list(map(int, input().split()))
        c.append(tmp[0])
        a.append(tmp[1:])

    ans = INF
    for i in range(2**n):
        tmp = np.array([0 for i in range(m)])
        cost = 0
        flag = True
        for j in range(n):
            if ((i >> j) & 1) == 1:
                tmp += a[j]
                cost += c[j]
        # print(tmp)
        for j in range(m):
            if tmp[j] < x:
                flag = False
                break
        # print(cost)
        if flag == True:
            if cost < ans:
                ans = cost
    print(ans) if ans != INF else print(-1)

    return


if __name__ == "__main__":
    main()


Fixed submission:
INF = pow(10, 9)


def main():
    n, m, x = map(int, input().split())
    i = 0
    c = []
    a = []

    for i in range(n):
        tmp = list(map(int, input().split()))
        c.append(tmp[0])
        a.append(tmp[1:])

    ans = INF
    for i in range(2**n):
        tmp = [0 for i in range(m)]
        cost = 0
        flag = True
        for j in range(n):
            if ((i >> j) & 1) == 1:
                tmp = [x+y for x, y in zip(tmp, a[j])]
                cost += c[j]
        # print(tmp)
        for j in range(m):
            if tmp[j] < x:
                flag = False
                break
        # print(cost)
        if flag == True:
            if cost < ans:
                ans = cost
    print(ans) if ans != INF else print(-1)

    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
J = [0 for i in range(int(2e5+3))]


def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, input().split()))

    for i in range(n):
        tmp = i - a[i]
        if 0 < tmp:
            J[tmp] += 1

    cnt = 0
    for i in range(n):
        tmp = a[i]+i+2
        cnt += J[tmp]

    print(cnt)
    return


if __name__ == "__main__":
    main()


Fixed submission:
J = [0 for i in range(int(2e5+3))]


def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, input().split()))

    for i in range(n):
        tmp = i - a[i]
        if 0 < tmp:
            J[tmp] += 1

    cnt = 0
    for i in range(n):
        tmp = a[i]+i+2
        if tmp < len(J)-1:
            cnt += J[tmp]

    print(cnt)
    return


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, input().split()))
    J = [0 for i in range(int(2e5+3))]

    for i in range(n):
        tmp = i - a[i]
        if 0 <= tmp:
            J[tmp] += 1

    cnt = 0
    for i in range(n):
        tmp = a[i]+i+2
        cnt += J[tmp]

    print(cnt)
    return


if __name__ == "__main__":
    main()


Fixed submission:
J = [0 for i in range(int(2e5+3))]


def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, input().split()))

    for i in range(n):
        tmp = i - a[i]
        if 0 < tmp:
            J[tmp] += 1

    cnt = 0
    for i in range(n):
        tmp = a[i]+i+2
        if tmp < len(J)-1:
            cnt += J[tmp]

    print(cnt)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b < a:
        b,a = a,b
    if a==0:
        return b
    
    return gcd(b%a,a)

def main():
    k = int(input())
    ans = 0
    for i in range(1,k+1):
        for j in range(1,k+1):
            tmp = gcd(i,j)
            for k in range(1,k+1):
                ans += gcd(tmp,k)
    print(ans)
    

if __name__== "__main__":
    main()

Fixed submission:
def gcd(a,b):
    if b < a:
        b,a = a,b
    if a==0:
        return b
    
    return gcd(b%a,a)

def main():
    k = int(input())
    ans = 0
    for i in range(1,k+1):
        for j in range(1,k+1):
            tmp = gcd(i,j)
            for k in range(1,k+1):
                ans += gcd(tmp,k)
    print(ans)
    

if __name__== "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations as pm

def main():
    n = int(input())
    s = input()

    red = [0 for i in range(n+1)]
    green = [0 for i in range(n+1)]
    blue = [0 for i in range(n+1)]

    for i in range(2,n+1):
        if s[i-2]=='R':
            red[i] = red[i-1] + 1
        else:
            red[i] = red[i-1]
        if s[i-2]=='G':
            green[i] = green[i-1] + 1
        else:
            green[i] = green[i-1]
        if s[i-2]=='B':
            blue[i] = blue[i-1] + 1
        else:
            blue[i] = blue[i-1]
    # red[n] = red[n-1]
    # green[n] = green[n-1]
    # blue[n] = blue[n-1]

    # print(red)
    # print(blue)
    # print(green)


    ans = 0
    for i in range(1,n+1):
        for j in range(i+2,n+1):

            for a,b,c in pm("RGB"):
                if s[i-1]==a and s[j-1]==c:
                    if b =="R":
                        ans += red[j] - red[i+1]
                    elif b=="G":
                        ans += green[j] - green[i+1]
                    elif b == "B":
                        ans += blue[j] - blue[i+1]
                    
                    if (j-i)%2==0 and s[(j-i)//2+i-1] == b:
                        ans -= 1
                    # print(i,j,b,ans)
    print(ans)

if __name__== "__main__":
    main()

Fixed submission:
from itertools import permutations as pm

def main():
    n = int(input())
    s = input()

    red = [0 for i in range(n+1)]
    green = [0 for i in range(n+1)]
    blue = [0 for i in range(n+1)]

    for i in range(2,n+1):
        if s[i-2]=='R':
            red[i] = red[i-1] + 1
        else:
            red[i] = red[i-1]
        if s[i-2]=='G':
            green[i] = green[i-1] + 1
        else:
            green[i] = green[i-1]
        if s[i-2]=='B':
            blue[i] = blue[i-1] + 1
        else:
            blue[i] = blue[i-1]
    # red[n] = red[n-1]
    # green[n] = green[n-1]
    # blue[n] = blue[n-1]

    # print(red)
    # print(blue)
    # print(green)


    ans = 0
    for i in range(1,n+1):
        for j in range(i+2,n+1):

            if s[i-1]+s[j-1] == "RB" or s[i-1]+s[j-1] =="BR":
                ans += green[j] - green[i+1]
                if (j-i)%2==0 and s[(j-i)//2+i-1] == "G":
                    ans -= 1
            elif s[i-1]+s[j-1] == "RG" or s[i-1]+s[j-1] =="GR":
                ans += blue[j] - blue[i+1]
                if (j-i)%2==0 and s[(j-i)//2+i-1] == "B":
                    ans -= 1
            elif s[i-1]+s[j-1] == "BG" or s[i-1]+s[j-1] =="GB":
                ans += red[j] - red[i+1]
                if (j-i)%2==0 and s[(j-i)//2+i-1] == "R":
                    ans -= 1

    print(ans)

if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
inf = 10000000000

def main():
    h,n = map(int,input().split())
    a=[0 for i in range(n)]
    b=[0 for i in range(n)]
    ans = [inf for i in range(h+1)]
    for i in range(n):
        tmp = list(map(int,input().split()))
        a[i] = tmp[0]
        b[i] = tmp[1]
        ans[a[i]] = b[i]
    
    
    for i in range(len(ans)):
        if ans[i]!=inf:
            for j in range(len(a)):
                index = min(h,a[j]+i)
                if ans[i]+b[j] < ans[index]:
                    ans[index] = ans[i]+b[j]
    print(ans[h])
if __name__=="__main__":
    main()
    

Fixed submission:
INF = 10000000000
a=[0 for i in range(int(1e5))]
b=[0 for i in range(int(1e5))]
ans = [INF for i in range(int(1e5))]

def main():
    h,n = map(int,input().split())
    for i in range(n):
        tmp = list(map(int,input().split()))
        a[i] = tmp[0]
        b[i] = tmp[1]
        index = min(h,a[i])
        if b[i] < ans[index]:
            ans[index] = b[i]
    
    
    for i in range(h):
        if ans[i]!=INF:
            for j in range(n):
                index = min(h,a[j]+i)
                if ans[i]+b[j] < ans[index]:
                    ans[index] = ans[i]+b[j]
    print(ans[h])
if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
inf = 10000000000

def main():
    h,n = map(int,input().split())
    a=[0 for i in range(n)]
    b=[0 for i in range(n)]
    ans = [inf for i in range(h+1)]
    for i in range(n):
        tmp = list(map(int,input().split()))
        a[i] = tmp[0]
        b[i] = tmp[1]
        ans[a[i]] = b[i]
    
    
    for i in range(len(ans)):
        if ans[i]!=inf:
            for j in range(len(a)):
                if ans[i]+b[j] < ans[min(h,a[j]+i)]:
                    ans[min(h,a[j]+i)] = ans[i]+b[j]
    print(ans[h])
if __name__=="__main__":
    main()
    

Fixed submission:
INF = 10000000000
a=[0 for i in range(int(1e5))]
b=[0 for i in range(int(1e5))]
ans = [INF for i in range(int(1e5))]

def main():
    h,n = map(int,input().split())
    for i in range(n):
        tmp = list(map(int,input().split()))
        a[i] = tmp[0]
        b[i] = tmp[1]
        index = min(h,a[i])
        if b[i] < ans[index]:
            ans[index] = b[i]
    
    
    for i in range(h):
        if ans[i]!=INF:
            for j in range(n):
                index = min(h,a[j]+i)
                if ans[i]+b[j] < ans[index]:
                    ans[index] = ans[i]+b[j]
    print(ans[h])
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+1)]
    AC = 0
    WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                flag[p] = def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()
            else:
                WA += 1
    print(AC,WA)
    return 0


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import itertools
import math

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))
    print(a)
    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//math.gcd(a[i],glc)
    print(glc)
    print(((m//glc)+1)//2)
    return 


if __name__ == "__main__":
    main()


Fixed submission:
import itertools

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))

    pre_j = 0
    for i in range(len(a)):
        j=0
        while(a[i]%(2**j)==0):
            j+=1
        if i==0:
            pre_j=j
        if pre_j != j:
            print(0)
            return 0

    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//GCD(a[i],glc)
    print(((m//glc)+1)//2)
    return 


def GCD(a,b):
    if a < b:
        a,b = b,a
        
    while a % b !=0 :
        n = a % b
        a = b
        b = n
    return b

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
cost=[[0 for i in range(n+1)]for j in range(n+1)]
color=[-1 for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append(v)
    tree[v].append(u)
    cost[u][v]=w
    cost[v][u]=w

que.append(1)
color[1]=0


while(len(que)!=0): 
    node = que.pop()
    for next_node in tree[node]:
        if color[next_node]==-1:
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+cost[node][next_node])%2
            que.append(next_node)
            # print(color)
for i in range(1,len(color)):
    print(color[i])


Fixed submission:
# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
color=[-1 for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append([v,w])
    tree[v].append([u,w])

que.append(1)
color[1]=0


while(len(que)!=0): 
    node = que.pop()
    for next_node,w in tree[node]:
        if color[next_node]==-1:
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+w)%2
            que.append(next_node)
            # print(color)
for i in range(1,len(color)):
    print(color[i])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
cost=[[0 for i in range(n+1)]for j in range(n+1)]
color=[0 for i in range(n+1)]
already=[False for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append(v)
    tree[v].append(u)
    cost[u][v]=w
    cost[v][u]=w
    if(i==n-2):
        que.append(u)
        color[u]=0
        already[u]=True


while(len(que)!=0): 
    node = que.pop()
    for next_node in tree[node]:
        if already[next_node]==False:
            already[next_node]=True
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+cost[node][next_node])%2
            que.append(next_node)
            
for i in range(1,len(color)):
    print(color[i])


Fixed submission:
# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
color=[-1 for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append([v,w])
    tree[v].append([u,w])

que.append(1)
color[1]=0


while(len(que)!=0): 
    node = que.pop()
    for next_node,w in tree[node]:
        if color[next_node]==-1:
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+w)%2
            que.append(next_node)
            # print(color)
for i in range(1,len(color)):
    print(color[i])
Buggy python submission (verdict: Runtime Error):
n = import math
n = int(input())

A = list()
for i in range(5):
    A.append(int(input()))

min_num = min(A)

ans = math.ceil(n/min_num)+4


print(ans)

Fixed submission:
import math
n = int(input())

A = list()
for i in range(5):
    A.append(int(input()))

min_num = min(A)

ans = math.ceil(n/min_num)+4


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def digits_of(n): 
    digits = []
    while n != 0:
        r = n % 10
        digits.append(r)
        n = n // 10
    return digits

def is_multiple_of_9(n):
	sum = 0
	for i in digits_of(n):
		sum += i
	return sum % 9 == 0 

N = int(input())
if is_multiple_of_9(N) == True:
  	print("Yes\n")
else:
  	print("No\n")


Fixed submission:
N = int(input())
result = sum(list(map(int, str(N))))
if  result % 9 == 0:
  	print("Yes\n")
else:
  	print("No\n")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))
mod = 1000000007
ans = 0
B = [0]*(N-1)
for i in range(N-1):
    B[i] = sum(A[i+1:])%mod
for i in range(N-1):
    ans += A[i]*B[i]%mod
    ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))
mod = 10**9+7
B = [0]*N
for i in range(N):
    B[i] = A[i]**2
s1, s2 = 0, 0 
for i in range(N):
    s1 += A[i]
    s2 += B[i]
s1 = s1**2
ans = (s1 -s2)//2%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))
mod = 1000000007
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += (A[i] * A[j]) % mod
        ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))
mod = 10**9+7
B = [0]*N
for i in range(N):
    B[i] = A[i]**2
s1, s2 = 0, 0 
for i in range(N):
    s1 += A[i]
    s2 += B[i]
s1 = s1**2
ans = (s1 -s2)//2%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
sum = 0 
l = len(n)
for i in range(l):
    sum += int(n)%10
    n = n[:-1]
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = input()
sum = 0 
for i in n:
    sum += int(i)
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
sum = 0 
l = len(n)
for i in range(l):
    sum += int(n)%10
    n = n[:-1]
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = input()
sum = 0 
for i in n:
    sum += int(i)
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sum = 0 
for i in range(1,2000001):
    sum += n%(10**i)
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = input()
sum = 0 
for i in n:
    sum += int(i)
if sum%9 == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
H, W, M = map(int,input().split())
P = [list(map(int, input().split())) for i in range(M)]
counth = [0]*H
countw = [0]*W
ans = 0
for i in P:
    counth[i[0]-1] += 1 
for i in P:
    countw[i[1]-1] += 1 
maxh = 0
for i in counth:
    maxh = max(maxh,i)
h = counth.index(maxh)
ans += maxh
maxw = 0
for i in countw:
    maxw = max(maxw,i)
w = counth.index(maxw)
if [h+1,w+1] in P:
    ans -= 1
ans += maxw
print(ans)

Fixed submission:
H, W, M = map(int,input().split())
P = [list(map(int, input().split())) for i in range(M)]
for p in P:
    p[0] -= 1
    p[1] -= 1
cnth = [0]*H
cntw = [0]*W
ans = 0
for p in P:
    cnth[p[0]] += 1
for p in P:
    cntw[p[1]] += 1
mxh = max(cnth)
mxw = max(cntw)
cntx = 0
for p in P:
    if cnth[p[0]] == mxh and cntw[p[1]] == mxw:
        cntx += 1
if cntx == cnth.count(mxh) * cntw.count(mxw):
    ans = mxh + mxw -1
else:
    ans = mxh + mxw
print(ans)
Buggy python submission (verdict: Runtime Error):
X, K, D = map(int,input().split())
import math
f = math.fabs 
def solve(x,k,d):
    if k%2 ==0:
        if k == 0:
            return int(f(x))
        elif f(x-2*d) > f(x) and f(x+2*d) > f(x):
            return int(f(x))
        elif k%4 == 0:
            return int(min(solve(x-k//2*d,k//2,d),solve(x+k//2*d,k//2,d)))
        elif k%4 != 0:
            return int(min(solve(x-(k+2)//2*d,(k-2)//2,d),solve(x+(k+2)//2*d,(k-2)//2,d)))
    elif k%2 != 0:
        if k == 1:
            return int(min(f(x-d),f(x+d)))
        else:
            return int(min(solve(x-(k+1)//2*d,(k-1)//2,d),solve((x+(k+1)//2*d,(k-1)//2,d))))
print(solve(X,K,D))

Fixed submission:
import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(int(ans))

Buggy python submission (verdict: Runtime Error):
X, K, D = map(int,input().split())
import math
f = math.fabs 
def solve(x,k,d):
    if k%2 ==0:
        if k == 0:
            return f(x)
        elif f(x-2*d) > f(x) and f(x+2*d) > f(x):
            return f(x)
        elif k%4 == 0:
            return min(solve(x-k//2*d,k//2,d),solve(x+k//2*d,k//2,d))
        elif k%4 != 0:
            return min(solve(x-(k+2)//2*d,(k-2)//2,d),solve(x+(k+2)//2*d,(k-2)//2,d))
    elif k%2 != 0:
        if k == 1:
            return min(f(x-d),f(x+d))
        else:
            return min(solve(x-(k+1)//2*d,(k-1)//2,d),solve((x+(k+1)//2*d,(k-1)//2,d)))
print(solve(X,K,D))

Fixed submission:
import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
print((10000-n)%1000)

Fixed submission:
N = int(input())
if N%1000 == 0:
    print(0)
else:
    print(1000-N%1000)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(a+a**2+a**3)

Fixed submission:
a = int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
S, W = map(int,input(.split()))
if W >= S:
    print('unsafe')
else:
    print('safe')

Fixed submission:
S, W = map(int,input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
mxcnt = 0
for s in S:
    mxcnt = max(mxcnt,S.count(s))
for s in S:
    if S.count(s) == mxcnt and s not in T:
        T.append(s)
T.sort()
for t in T:
    print(t)

Fixed submission:
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
S.sort()
if n == 1:
    print(S[0])
    exit()
cnt = 1
mxcnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    mxcnt = max(mxcnt,cnt)
cnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    if cnt == mxcnt:
        T.append(S[i])
if mxcnt == 1:
    T.append(S[-1])
for t in T:
    print(t)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
mxcnt = 0
for s in S:
    mxcnt = max(mxcnt,S.count(s))
for s in S:
    if S.count(s) == mxcnt and s not in T:
        T.append(s)
T.sort()
for t in T:
    print(t)

Fixed submission:
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
S.sort()
if n == 1:
    print(S[0])
    exit()
cnt = 1
mxcnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    mxcnt = max(mxcnt,cnt)
cnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    if cnt == mxcnt:
        T.append(S[i])
if mxcnt == 1:
    T.append(S[-1])
for t in T:
    print(t)