Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import heapq
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    a.sort(reverse=True)
    b=list(map(int,readline().split()))
    b.sort(reverse=True)
    c=list(map(int,readline().split()))
    c.sort(reverse=True)

    s={(0,0,0)}
    h=[[-(a[0]+b[0]+c[0]),(0,0,0)]]
    heapq.heapify(h)
    for _ in range(k):
        li=heapq.heappop(h)
        n=-li[0]
        co=li[1]
        print(n)

        if co[0]+1<x:
            co_1=(co[0]+1,co[1],co[2])
            n_1=a[co_1[0]]+b[co_1[1]]+c[co_1[2]]
            n_1=-n_1
        if co[1]+1<y:
            co_2=(co[0],co[1]+1,co[2])
            n_2=a[co_2[0]]+b[co_2[1]]+c[co_2[2]]
            n_2=-n_2
        if co[2]+1<z:
            co_3=(co[0],co[1],co[2]+1)
            n_3=a[co_3[0]]+b[co_3[1]]+c[co_3[2]]
            n_3=-n_3

        if co_1 not in s:
            heapq.heappush(h,[n_1,co_1])
            s.add(co_1)
        if co_2 not in s:
            heapq.heappush(h,[n_2,co_2])
            s.add(co_2)
        if co_3 not in s:
            heapq.heappush(h,[n_3,co_3])
            s.add(co_3)

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    b=list(map(int,readline().split()))
    c=list(map(int,readline().split()))

    d=list()
    for i in range(x):
        for j in range(y):
            d.append(a[i]+b[j])

    d.sort(reverse=True)
    if x*y>=k:
        d=d[:k]

    e=list()
    for i in range(len(d)):
        for j in range(z):
            e.append(d[i]+c[j])

    e.sort(reverse=True)
    for i in range(k):
        print(e[i])

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    b=list(map(int,readline().split()))
    c=list(map(int,readline().split()))

    d=list()
    for i in range(x):
        for j in range(y):
            d.append(a[i]+b[j])

    d.sort(reverse=True)
    if x*y>=k:
        d=d[:k]

    e=list()
    for i in range(len(d)):
        for j in range(z):
            e.append(d[i]+c[j])

    e.sort(reverse=True)
    for i in range(k):
        print(e[i])

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    b=list(map(int,readline().split()))
    c=list(map(int,readline().split()))

    d=list()
    for i in range(x):
        for j in range(y):
            d.append(a[i]+b[j])

    d.sort(reverse=True)
    if x*y>=k:
        d=d[:k]

    e=list()
    for i in range(len(d)):
        for j in range(z):
            e.append(d[i]+c[j])

    e.sort(reverse=True)
    for i in range(k):
        print(e[i])

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N=int(input())
    X=[]
    U=[]
    for i in range(N):
        x,u=input().split()
        x=int(x)
        X.append(x)
        U.append(u)

    count=0
    for i in range(N):
        if U[i]=="JPY":
            count+=X[i]
        else:
            count+=380000*X[i]
    print(count)
if __name__=="__main__":
    main()

Fixed submission:
def main():
    N=int(input())
    X=[]
    U=[]
    for i in range(N):
        x,u=input().split()
        x=float(x)
        X.append(x)
        U.append(u)

    count=0
    for i in range(N):
        if U[i]=="JPY":
            count+=X[i]
        else:
            count+=380000*X[i]
    print(count)
if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)
    before=np.arange(1,k+1,dtype=np.int64)
    zero=np.zeros(k,dtype=np.int64)

    dp=np.zeros(n,dtype=np.int64)
    for i in range(n):
        tmp=np.maximum(zero,i-before)
        dp[i]=(dp[tmp]+np.abs(h[i]-h[tmp])).min()

    print(dp[n-1])

if __name__=="__main__":
    main()


Fixed submission:
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[10**10]*N
    dp[0]=0
    for i in range(N):
        for j in range(1,min(K+1,N-i)):
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    print(dp[N-1])

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)
    before=np.arange(1,k+1,dtype=np.int64)
    zero=np.zeros(k,dtype=np.int64)

    dp=np.zeros(n,dtype=np.int64)
    for i in range(n):
        tmp=np.maximum(zero,i-before)
        dp[i]=(dp[tmp]+np.abs(h[i]-h[tmp])).min()

    print(dp[n-1])

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[10**10]*N
    dp[0]=0
    for i in range(N):
        for j in range(1,min(K+1,N-i)):
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    print(dp[N-1])

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)
    before=np.arange(1,k+1,dtype=np.int64)

    dp=np.zeros(n,dtype=np.int64)
    for i in range(n):
        dp[i]=(dp[np.maximum(0,i-before)]+np.abs(h[i]-h[np.maximum(0,i-before)])).min()

    print(dp[n-1])

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[10**10]*N
    dp[0]=0
    for i in range(N):
        for j in range(1,min(K+1,N-i)):
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    print(dp[N-1])

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[10**10]*N
    dp[0]=0
    for i in range(N):
        for j in range(1,min(K+1,N-i)):
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    print(dp[N-1])

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[10**10]*N
    dp[0]=0
    for i in range(N):
        for j in range(1,min(K+1,N-i)):
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    print(dp[N-1])

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    abc=np.array([list(map(int,readline().split())) for _ in range(n)],dtype=np.int64)

    x=np.array([1,2])
    y=np.array([2,0])
    z=np.array([0,1])

    dp=np.zeros((n+1,3),dtype=np.int64)
    for i in range(n):
        dp[i+1,x]=np.maximum(dp[i+1,x],dp[i][0]+abc[i,x])
        dp[i+1,y]=np.maximum(dp[i+1,y],dp[i][1]+abc[i,y])
        dp[i+1,z]=np.maximum(dp[i+1,z],dp[i][2]+abc[i,z])

    print(dp[-1].max())

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N=int(input())
    abc=[0]*N
    for i in range(N):
        xyz=list(map(int,input().split()))
        abc[i]=xyz
    dp=[[0]*3 for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(3):
            dp[i][j]=max(dp[i-1][(j-1)%3]+abc[i-1][(j-1)%3],dp[i-1][(j-2)%3]+abc[i-1][(j-1)%3])

    print(max(max(dp[N][0],dp[N][1]),dp[N][2]))

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    abc=np.array([list(map(int,readline().split())) for _ in range(n)],dtype=np.int64)

    x=np.array([1,2])
    y=np.array([2,0])
    z=np.array([0,1])

    dp=np.zeros((n+1,3),dtype=np.int64)
    for i in range(1,n+1):
        dp[i]=[(dp[i-1,x]+abc[i-1,x]).max(),(dp[i-1,y]+abc[i-1,y]).max(),(dp[i-1,z]+abc[i-1,z]).max()]

    print(dp[n].max())

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N=int(input())
    abc=[0]*N
    for i in range(N):
        xyz=list(map(int,input().split()))
        abc[i]=xyz
    dp=[[0]*3 for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(3):
            dp[i][j]=max(dp[i-1][(j-1)%3]+abc[i-1][(j-1)%3],dp[i-1][(j-2)%3]+abc[i-1][(j-1)%3])

    print(max(max(dp[N][0],dp[N][1]),dp[N][2]))

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,W=map(int,input().split())
    w=[0]*(N+1)
    v=[0]*(N+1)
    for i in range(1,N+1):
        a,b=map(int,input().split())
        w[i]=a
        v[i]=b
    dp=[[0]*(W+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(W+1):
            if j-w[i]>=0:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
            else:
                dp[i][j]=dp[i-1][j]

    print(dp[N][W])

if __name__=="__main__":
    main()

Fixed submission:
def main():
    N,W=map(int,input().split())
    w=[0]*(N+1)
    v=[0]*(N+1)
    for i in range(1,N+1):
        a,b=map(int,input().split())
        w[i]=a
        v[i]=b
    dp=[[0]*(W+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(W+1):
            if j-w[i]>=0:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
            else:
                dp[i][j]=dp[i-1][j]

    print(dp[N][W])

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s=input()
    t=input()
    dp=[[""]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(1,len(s)+1):
        for j in range(1,len(t)+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+s[i-1]
            else:
                if len(dp[i-1][j])>=len(dp[i][j-1]):
                    dp[i][j]=dp[i-1][j]
                else:
                    dp[i][j]=dp[i][j-1]
                    
    print(dp[len(s)][len(t)])
if __name__=="__main__":
    main()

Fixed submission:
def main():
    s=input()
    t=input()
    dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(1,len(s)+1):
        for j in range(1,len(t)+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
    i=len(s)
    j=len(t)
    result=[]
    while i!=0 and j!=0:
        if dp[i][j]==dp[i-1][j]:
            i-=1
        elif dp[i][j]==dp[i][j-1]:
            j-=1
        elif dp[i][j]==dp[i-1][j-1]+1:
            result.append(s[i-1])
            i-=1
            j-=1
    s="".join(result)
    s=s[::-1]
    print(s)
if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s=input()
    t=input()
    dp=[[""]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(1,len(s)+1):
        for j in range(1,len(t)+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+s[i-1]
            else:
                if len(dp[i-1][j])>=len(dp[i][j-1]):
                    dp[i][j]=dp[i-1][j]
                else:
                    dp[i][j]=dp[i][j-1]
                    
    print(dp[len(s)][len(t)])
if __name__=="__main__":
    main()

Fixed submission:
def main():
    s=input()
    t=input()
    dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(1,len(s)+1):
        for j in range(1,len(t)+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
    i=len(s)
    j=len(t)
    result=[]
    while i!=0 and j!=0:
        if dp[i][j]==dp[i-1][j]:
            i-=1
        elif dp[i][j]==dp[i][j-1]:
            j-=1
        elif dp[i][j]==dp[i-1][j-1]+1:
            result.append(s[i-1])
            i-=1
            j-=1
    s="".join(result)
    s=s[::-1]
    print(s)
if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    l=m//n
    ans=0
    for i in range(1,l+1):
        s=i*(n-1)
        if (m-s)%i==0:
            ans=max(ans,i)

    print(ans)
    
if __name__=="__main__":
    main()

Fixed submission:
def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        divisors.sort()
        return divisors

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())

    d=make_divisors(M)
    for i in range(len(d)):
        if d[i]-N>=0:
            print(M//d[i])
            break

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m,q=map(int,readline().split())
    table=[[0]*n for _ in range(n)]
    for i in range(m):
        l,r=map(lambda x:int(x)-1,readline().split())
        table[l][r]+=1

    #累積和
    for i in range(n):
        table[i]=list(accumulate(table[i]))

    ans=[0]*q
    for i in range(q):
        l,r=map(lambda x:int(x)-1,readline().split())
        t=0
        for j in range(l,r+1):
            t+=table[j][r]
        ans[i]=t

    for i in range(q):
        print(ans[i])

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m,q=map(int,readline().split())
    table=[[0]*n for _ in range(n)]
    for i in range(m):
        l,r=map(lambda x:int(x)-1,readline().split())
        table[l][r]+=1

    #累積和
    for i in range(n):
        table[i]=list(accumulate(table[i]))

    ans=[0]*q
    for i in range(q):
        l,r=map(lambda x:int(x)-1,readline().split())
        t=0
        for j in range(l,r+1):
            t+=table[j][r]
        ans[i]=t

    for i in range(q):
        print(ans[i])

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    if 0 in d:
        ans=d[0]
    else:
        ans=0
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    if 0 in d:
        ans=d[0]
    else:
        ans=0
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,max_c=map(int,readline().split())
    d=[list(map(int,readline().split())) for _ in range(max_c)]
    c=[list(map(lambda x:int(x)-1,readline().split())) for _ in range(n)]

    #前処理
    color_table=[[0]*max_c for _ in range(3)]
    for color in range(max_c):
        for i in range(n):
            for j in range(n):
                color_table[(i+j+2)%3][color]+=d[c[i][j]][color]

    #全探索
    ans=float("inf")
    for i in range(max_c):
        for j in range(max_c):
            for k in range(max_c):
                if i==j or j==k or k==i:
                    continue
                ans=min(ans,color_table[0][i]+color_table[1][j]+color_table[2][k])

    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,max_c=map(int,readline().split())
    d=[list(map(int,readline().split())) for _ in range(max_c)]
    c=[list(map(lambda x:int(x)-1,readline().split())) for _ in range(n)]

    #前処理
    color_table=[[0]*max_c for _ in range(3)]
    for color in range(max_c):
        for i in range(n):
            for j in range(n):
                color_table[(i+j+2)%3][color]+=d[c[i][j]][color]

    #全探索
    ans=float("inf")
    for i in range(max_c):
        for j in range(max_c):
            for k in range(max_c):
                if i==j or j==k or k==i:
                    continue
                ans=min(ans,color_table[0][i]+color_table[1][j]+color_table[2][k])

    print(ans)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    #入力
    readline=stdin.readline
    n,y=map(int,readline().split())

    flag=False
    for i in range(0,n+1):
        for j in range(0,n+1):
            if n<i+j: continue
            k=n-i-j
            if 10000*i+5000*j+1000*k==y:
                print(i,j,k)
                flag=True
                break
        if flag: break

    if flag==False: print(-1,-1,-1)

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    readline=stdin.readline
    N,Y=map(int,readline().split())

    flag=False
    for i in range(N+1):
        for j in range(N+1):
            m=10000*i+5000*j
            if m>Y:
                break
            else:
                k=(Y-m)//1000
                m+=1000*k
                if i+j+k==N:
                    print(i,j,k)
                    flag=True
                    break
        if flag:
            break
    if flag==False:
        print(-1,-1,-1)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

def bis(x,vec):
   left_index_NG=-1
   right_index_OK=len(vec)
   while(left_index_NG<right_index_OK-1):
      mid=int((left_index_NG+right_index_OK)/2)
      if x < vec[mid]:
         right_index_OK=mid
      else:
         left_index_NG=mid
   return right_index_OK

alltypes=0
for i in range(N):
   a=A[i]
   for j in range(N):
      if(A[i]>=B[j]):
         continue
      else:
         b=B[j]
         alltypes+=len(C)-bis(b,C)

print(alltypes)

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

A.sort()
B.sort()
C.sort()

def bisA(x,vec):
   left_index_OK=-1
   right_index_NG=len(vec)
   while(left_index_OK<right_index_NG-1):
      mid=int((left_index_OK+right_index_NG)/2)
      if x > vec[mid]:
         left_index_OK=mid
      else:
         right_index_NG=mid
   #print(vec[left_index_OK])
   return left_index_OK

def bisC(x,vec):
   left_index_NG=-1
   right_index_OK=len(vec)
   while(left_index_NG<right_index_OK-1):
      mid=int((left_index_NG+right_index_OK)/2)
      if x < vec[mid]:
         right_index_OK=mid
      else:
         left_index_NG=mid
   #print(vec[right_index_OK])
   return right_index_OK

alltypes=0
atypes=0
ctypes=0
for i in range(N):
   b=B[i]
   if b<=A[0]:
      continue
   else:
      atypes=bisA(b,A)+1
      ctypes=len(C)-bisC(b,C)
      alltypes+=atypes*ctypes

print(alltypes)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    AB=[0]*N
    for i in range(N):
        AB[i]=list(map(int,input().split()))
    AB.sort()
    count=AB[-1][0]
    while AB[-1][1]-1>=0:
        AB[-1][1]-=1
        count+=1
    print(count)
if __name__=="__main__":
    main()

Fixed submission:
def main():
    N=int(input())
    AB=[0]*N
    for i in range(N):
        AB[i]=list(map(int,input().split()))
    AB.sort()
    count=AB[-1][0]
    count+=AB[-1][1]
    print(count)
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
	N=input()
	if N[1] != '0':
		print(100)
	else:
		print(0)
main()

Fixed submission:
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''

Buggy python submission (verdict: Runtime Error):
n=int(input())
if n[1]!='0':
  print(100)
else:
  print(0)

Fixed submission:
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''

Buggy python submission (verdict: Runtime Error):



din=input()
if din[1] != '0':
	print(100)
else:
	print(0)


 





Fixed submission:
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''

Buggy python submission (verdict: Runtime Error):
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	din=input()
	if din[1] != '0':
		print('100')
	else:
		print('0')
main()

'''
if __name__ == '__main__':
    main()
'''
 





Fixed submission:
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''

Buggy python submission (verdict: Runtime Error):
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	din=input()
	idx=[]
	if din[1] == '9':
		print(100)
	else:
		print(0)
main()

'''
if __name__ == '__main__':
    main()
'''
 





Fixed submission:
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''