peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())
res=[0]*(n+1)
for x in range(1,50):
  for y in range(1,50):
    for z in range(1,50):
      t = x**2+y**2+z**2+x*y+y*z+z*x
      if t > n:
        continue
      res[t]+=1
for i in range(1,n+1):
  print(res[i])
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x+y*y+z*z+x*y+y*z+z*x
            if(n<N):
                d[n]+=1
for i in range(1,N+1):
    print(d[i])
n = int(input())

n_list = [0]*50000
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            if (x+y+z)*(x+y+z) >= 150:
                break
            index = x*x + y*y + z*z + x*y + y*z + z*x
            n_list[index] = n_list[index]+1

for i in range(1,n+1):
    print(n_list[i])
from itertools import product

N = int(input())

cnt = [0]*100000000

for x in range(1,81):
    for y in range(1,81):
        for z in range(1,81):
            if x==y and y==z:
                cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] = 1
            else:
                cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1

for i in range(N):
    print(cnt[i])
n = int(input())
ans = [0] * (n + 1)
for x in range(1, n):
    for y in range(1, n):
        for z in range(1, n):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
print(*ans, sep='\n')
n = int(input())
cnt = [0] * 11000

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= n:
                cnt[value] += 1

for i in range(n+1):
    print(cnt[i])
n = int(input())

count = 0

i = 1

count = 0
limit = 100

nums = [0] * n

for x in range(limit):
    for y in range(limit):
        for z in range(limit):
            cal =  (x + 1) ** 2 + (y + 1) ** 2 + (z + 1) ** 2 + (x + 1) * (y + 1) + (y + 1) * (z + 1) + (z + 1) * (x + 1)
            if(cal > n):
                break
            nums[cal - 1] += 1

for x,n in enumerate(nums,1):
    if ( n > 0 ):
        print(f'{x}:{n}')
import math
N=int(input())
d=int(math.sqrt(N)+1)
bucket=[0 for i in range(N)]
for i in range(d):
  for j in range(d):
    for k in range(d):
      if(i**2+j**2+k**2<=2*N and (i**2+j**2+k**2)%2==0 and i+j-k>=2 and j+k-i>=2 and k+i-j>=2):
        bucket[(i**2+j**2+k**2)//2-1]+=1
for i in range(N):
  print(bucket[i])
n = int(input())

cnt = [0] * n
for x in range(1, int(n ** 0.5) + 1):
    for y in range(1, int(n ** 0.5) + 1):
        for z in range(1, int(n ** 0.5) + 1):
            num = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if num <= n:
                print(num)
                cnt[num - 1] += 1
print(*cnt, sep="\n")
def main():
    n = int(input())

    count_list = [0] * n
    upper = int(n**0.5) + 1
    for x in range(1, upper):
        for y in range(1, upper):
            for z in range(1, upper):
                num = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if num < n:
                    count_list[num-1] += 1
    for count in count_list:
        print(count)


if __name__ == '__main__':
    main()
N = int(input().strip())
s=[]
n=int(N**(0.352))
for a in range (1,n+2):
    for b in range(1,n+2):
        for c in range(1,n+2):
            s.append(a*a+b*b+c*c+a*b+b*c+c*a)
s.sort()

for l in range(1,N+1):
    print(s.count(l))
n = int(input())

from collections import defaultdict
d = defaultdict(int)

for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      d[i**2+j**2+k**2+i*j+j*k+k*i]+=1

for j in range(1,n):
  if d[j]:
    print(d[j])
  else:
    print(0)
import itertools
n = int(input())
N = int(n**0.5)
ans = [0] * n
for x,y,z in itertools.combinations_with_replacement(list(range(1,N+1)),3):
    a = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if a > n: continue
    if z==y==z: b = 1
    elif x==y or x==z or y==z: b = 3
    else: b = 6
    ans[a-1] = b
for i in ans: print(i)
N=int(input())
count=[0]*(10**4+1)
for x in range(1,10**2):
    for y in range(1,10**2):
        for z in range(1,10**2):
            n=x**2+y**2+z**2+x*y+y*z+z*x
            if n<=10**4:
                count[n]+=1
for i in range(1,N):
    print(count[i])
N = int(input())
def ff(x,y,z):
    n = x**2+y**2+z**2+x*y+y*z+z*x
    return n
maxx=30

c=[]
ans = [0]*N
for i in range(1,maxx+1):
    for j in range(1,maxx+1):
        for k in range(1,maxx+1):
            r=ff(i,j,k)
            c.append(r)
cc = [i for i in c if i<=N]

for i in cc:
    ans[i-1] += 1

for i in ans:
    print(i)
n = int(input())
arr = [0] * 25000
for x in range(1, 50):
    for y in range(1, 50):
        for z in range(1, 50):
            n_ = x**2 + y**2 + z**2 + x*y + y*z + z*x
            arr[n_-1] += 1

print(*arr[:n], sep='\n')
from sys import stdin
import sys
import math
import random
from decimal import Decimal
import itertools as it

N = int(input())
# for i in range(1,N+1):
f = [0 for i in range(N)]
# print(f)
for x in range(1, 51):
    x2 = x**2
    for y in range(1, 51):
        y2 = y**2
        for z in range(1, 51):
            a = x2+y2+z**2+x*y+y*z+x*z
            if a <= N:
                f[a-1] += 1
for i in f:
    print(i)
n = int(input())
fn = [0] * (10**6+1)
def f(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x 

for x in range(1, 35):
    for y in range(1, 35):
        for z in range(1, 35):
            idx = f(x, y, z)
            fn[idx] += 1
for i in range(1, n+1):
    print(fn[i])
N = int(input())

ans = {}
for x in range(1, 50):
    for y in range(1, 50):
        for z in range(1, 50):
            tmp = x**2+y**2+z**2+x*y+x*z+y*z
            if not(tmp in ans):
                ans[tmp] = 1
            else:
                ans[tmp] += 1

for i in range(1, N+1):
    if i in ans:
        print(ans[i])
    else:
        print(0)
n = int(input())

for a in range(n+1):
    ans = 0
    for i in range(1,100):
        for j in range(1,100):
            if i*2 + j*2 + i*j >= a:
                break
            for k in range(1,100):
                if i**2 + j**2 + k**2 +i*j + j*k + k*i == a:
                    ans += 1
    print(ans)
N = int(input())
k = 1
for i in range(1,N+1):
    if i == 6*k**2:
        print(1)
    elif i == (2*k)**2 + 3 * k**2 + 2*(k*(k+1)):
        print(3)
    elif i == 3*((2*k)**2) + 2*k*(k+1) + k**2:
        print(3)
    elif i == (k+2)**2 + 3*k**2 + 2*k*(k+2):
        print(3)
        k +=1
    else:
        print(0)
N=int(input())
ans=[0]*(N+5)
for i in range(100) :
    for j in range(100) :
        for k in range(100) :
            n=i*i+j*j+k*k+i*j+j*k+k*i
            if N>=n :
                ans[n]+=1

for i in range(1,N+1) :
    print(ans[i])
n=int(input())
l=[0]*(n+1)
for i in range(1,10**2+1):
  for j in range(1,10**2+1):
    for k in range(1,10**2+1):
      tmp=i**2+j**2+k**2+i*j+j*k+k*i
      if tmp<=n:
        l[tmp]+=1
for li in l:
  print(li)
import itertools

n = int(input())
max_list_size = (25 + 25 + 25) ** 3
results = [0] * max_list_size

combinations = list(itertools.product(range(1, 26), repeat=3))
for x, y, z in combinations:
    calc_result = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    results[calc_result] += 1
for i in range(1, n + 1):
    print(results[i])
n=int(input())

ans = [0]*n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if x**2+y**2+z**2+x*y+y*z+z*x < n:
                ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(n):
    print(ans[i])
def f(n):
    cnt = 0
    for x in range(1,6):
        for y in range(1,6):
            for z in range(1,6):
                if (((x**2 )+(y**2) +(z**2) +x*y +y*z+ z*x)) == n:
                    cnt += 1

    return cnt
N=int(input())
for i in range(1,N+1):
    print(f(i))
N = int(input())
ans = [0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            num = x*x + y*y + z*z + x*y + y*z + z*x
            if num>N:
                break
            ans[num] = ans[num] + 1
for m in ans:
    print(m)
import time
import itertools


N = int(input())
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

count = 0
start = time.time()

p = list(itertools.product(range(1,25),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

for n in range(1,N + 1):
    print(a.count(n))

elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")
n=int(input())
a = [0]*(1000000)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(n+1):
    print(a[i])
n = int(input())
ans = [0] * 10010

def get_ans(n):
  cnt = 0
  for x in range(1, 101):
    for y in range(1, 101):
      for z in range(1, 101):
        k = x**2 + y**2 + z**2 + x*y + y*z + z*x
        if(k <= 10000):
          ans[k] += 1        
  return ans

ans = get_ans(n)
for i in range(n+1):
  print(ans[i])
n=int(input())
i=0
N=n
while n>0:
    n-=1000
    i+=1
print(i*1000-N)
n = int(input())

c = n % 1000

if c == 0:
  print(0)
else:
  print(1000 - c)
N=int(input())
ma=-(-N//1000)
NN=ma*1000-N
print(NN)
n = int(input())
x = n % 1000
if x == 0:
    print(0)
else:
    print(1000-x)
N = int(input())
if (N % 1000) == 0:
	ans = 0
else:
	ans = 1000 - (N % 1000)
print(ans)
n = int(input())

if n%1000:
    bills = n//1000 + 1
else:
    bills = n//1000

ans = bills * 1000 - n
print(ans)
def actual(N):
    if N % 1000 == 0:
        return 0

    return (N // 1000 + 1) * 1000 - N

N = int(input())
print(actual(N))
n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000 - (n % 1000))
N = int(input())

r = N % 1000
print(0 if r == 0 else 1000 - r)
def main():
  N = int(input())
  o = (N % 1000)
  ans = 0 if o == 0 else 1000 - o
  print(ans)
  return

main()
import math
n = int(input())

ans = math.ceil(n / 1000) * 1000 - n

print(ans)
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    print(1000 - N % 1000)
import math
N = int(input())
print(math.ceil(N / 1000) * 1000 - N)
n=int(input())

print((1000-n%1000)%1000)
N= int(input())

S=N%1000

if S !=0:
    print(abs(S-1000))
else:
    print(0)
n=int(input())
ans=n%1000
if(ans==0):
  print(ans)
else:
	print(1000-ans)
N = int(input())

print((1000 - N % 1000)%1000)
n = int(input())
ans = 1000-n%1000
if ans == 1000:
    ans = 0
print(ans)
#abc173a

n=int(input())
if n%1000==0:
 print(0)
 exit()
print(1000-n%1000)
N=int(input())
1<=N<=10000
if((N%1000)==0):
	print("0")
else:
	print(1000-(N%1000))
cost = input()
amari = int(cost[-3:])
if amari == 0:
  amari = 1000
print(1000 - amari)
n = int(input())

pay = 1000
while pay - n < 0:
    pay += 1000
print(pay - n)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from math import ceil
#import numpy as np
def main():
    n = int(input())
    r = ceil(n / 1000) * 1000 - n
    print(r)

if __name__ == '__main__':
    main()
n = int(input())
x = 0

while True:
    if n % 1000 == 0:
        break
    n += 1
    x += 1

print(x)
N=int(input())
if N%1000==0:
	print(0)
else:
	print(1000-N%1000)
N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print((N // 1000 + 1) * 1000 - N)
from math import ceil

a = int(input())
print((ceil(a / 1000) * 1000) -  a)
N=int(input())
if N%1000==0:
    print(0)
else:
    print(1000-N%1000)
import math
import collections
import bisect
from copy import copy


def main():
    N = int(input())
    print((1000 - N % 1000) % 1000)


if __name__ == '__main__':
    main()
N = int(input())

under1000 = N % 1000

if under1000 == 0:
  print(0)
else:
  print(1000 - under1000)
n = int(input())
a = n%1000
if a == 0:
    print(0)
else:
    print(1000-a)
n = int(input())
b = 0
while b < n:
  b += 1000
print(b-n)
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    payment = N // 1000 + 1
    change = payment*1000 - N
    print(change)
N=int(input())
A=1000*(N//1000)-N
B=((N//1000)+1)*1000-N
if A<=B and A>=0:
  print(int(A))
else:
  print(int(B))
n=int(input())
money=1000
while True:
    if money>=n:
        print(money-n)
        break
    money+=1000
N = int(input())
M=1000

while True:
  if N <= M:
    print(M-N)
    break
  else:
    M += 1000
n=int(input())
t=n%1000
if t==0:
  print(0)
else:
  print(1000-t)
n = int(input())

import math
x = math.ceil(n/1000)*1000-n
print (x)
n = int(input())
a=((n//1000)+1)*1000-n
if a == 1000:
    print(0)
else:
    print(a)
N = int(input())
ans = 0
for i in range(11):
    if 1000*i >= N:
        ans = 1000*i - N
        break
print(ans)
import math
n = int(input())

round_n = math.ceil(n/1000)*1000

print(round_n-n)
N = int(input())
if(N%1000 != 0):
  print(1000-(N%1000))
else:print(0)
n=int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)
from math import ceil
n=int(input())
val=ceil(n/1000)
print(1000*val-n)
N = int(input())
i = 0

while N > i * 1000:
    i += 1

ans = i * 1000 - N
print(ans)
n = int(input())
if n % 1000 == 0:
    print(0)
else:

    print(1000 -(n % 1000))
N = int(input())

n = N/1000

for i in range(11):
    if i >= n:
        print(i*1000-N)
        break
import math

N = int(input())
tmp = math.ceil(N / 1000)

print(1000*tmp - N)
N = int(input())

print(1000 - N % 1000 if N % 1000 != 0 else 0)
n=int(input())
if n%1000==0:
  print(0)
else:
  print(1000-(n%1000))
X = int(input())
if X%1000:
  print(1000 - (X%1000))
else:
  print(0)
N = int(input())
for i in range(10):
    if (i+1)*1000 >= N:
        print((i+1)*1000-N)
        exit()
N=int(input())

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


if __name__ == "__main__":
  main()
n = int(input())
print(0 if n % 1000 == 0 else 1000 - (n % 1000))
# Payment
N = int(input())
print((10000 - N) % 1000)
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
if N % 1000 != 0:
    print(1000 - N % 1000)
else:
    print(0)
money = int(input())

output = 0
if money <= 1000:
  output = 1000 - money
elif money % 1000 == 0:
  output = 0
else:
  output = 1000 - (money % 1000)
  
print(output)
n=int(input())
if n%1000==0:
    print(0)
else:
    x=n//1000
    y=x+1
    y=y*1000
    y=abs(n-y)
    print(y)
price=int(input())

ans=price%1000

if ans!=0:
    ans=1000-ans

print(ans)
N=int(input())
print((-(-N//1000)*1000)-N)
a=int(input())
a%=1000
if a==0:
    print(0)
else:
    print(1000-a)
n = int(input())

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

    N = int(input())
    money = 0

    while N > money:
        money += 1000

    print(money - N)



if __name__ == '__main__':
    main()
import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict
 
# read line as a string
# strr = input()
 
# read line as an integer
k = int(input())
 
# read one line and parse each word as a string
# lst = input().split()
 
# read one line and parse each word as an integer
# arr = list(map(int,input().split()))
 
if k%1000 == 0:
    print(0)
else:
    print(1000 - k%1000)
N=int(input())
R=(1000-N%1000)%1000
print(R)
n = int(input())
if n % 1000 == 0:
  print(0)
else:
  print(1000 - n % 1000)
N = int(input())
M = N // 1000
if N % 1000 != 0:
    M += 1
print(1000 * M - N)
n = int(input())
print((1000-n%1000) % 1000)
N = int(input())
res = N%1000

if res == 0:
  print(res)
else:
  print(1000-res)
n = int(input())
if n % 1000 == 0: print(0)
else: print(1000 - n % 1000)
import numpy
N = int(input())
a = int(numpy.ceil(N / 1000) * 1000 - N)
print(a)
a = int(input())
print(1000 - (a % 1000) if a % 1000 != 0 else 0)
S = int(input())
pay = 1000
while S > pay:
    pay += 1000
else:
    print(pay - S)
money = int(input())
ans = 1000 - money % 1000
if int(ans) == 1000:
    print(0)
else:
    print(int(ans))
n = int(input())
m = n%1000
if m ==0:
    print(0)
else :
    print(1000-m)
N = int(input())

x = 0
while x < N:
    x = x + 1000

output = x - N
print(output)
def main():
    N = int(input())

    if N%1000 == 0:
        print(0)
    else:
        print(1000 - (N%1000))


if __name__ == '__main__':
    main()
n=int(input())
if n%1000==0:
    print(0)
else:
    i=n//1000
    print((i+1)*1000-n)
n = int(input())

n %= 1000
n = 1000 -n

if n % 1000 == 0:
    n = 0

print(n)
n=int(input())
ans=(1000- n%1000)%1000
print(ans)
n = int(input())
a = n%1000
if a == 0 :
    print(a)
else:
    print(1000-a)
int = int(input())
print((1000 - int % 1000) % 1000)
price = int(input())
if price % 1000 == 0:
    print(0)
else:
    print(1000-(price%1000))
x = int(input())
e=x%1000
r=1000-e
if r==1000:
    print(0)
else:
    print(r)
n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(((n // 1000 + 1) * 1000) - n)
n = int(input())
for i in range(1, 11):
    if 1000*i-n>=0:
        print(1000*i-n)
        break
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


N = int(input())

chash = 0
while chash < N:
        chash += 1000

print(chash - N )
N = int(input())
ans = 1000 - (N%1000)
if ans == 1000:
    print(0)
else:
    print(ans)
import math
N = int(input())
print(1000*math.ceil(N/1000)-N)
N = int(input())
print((1000-(N%1000))%1000)
N = int(input())
left = N % 1000
if left == 0:
    print(0)
else:
    print(1000 - left)
N=int(input())
if N<=1000:
    print(1000-N)
if 2000>=N>1000:
    print(2000-N)
if 3000>=N>2000:
    print(3000-N)
if 4000>=N>3000:
    print(4000-N)
if 5000>=N>4000:
    print(5000-N)
if 6000>=N>5000:
    print(6000-N)
if 7000>=N>6000:
    print(7000-N)
if 8000>=N>7000:
    print(8000-N)
if 9000>=N>8000:
    print(9000-N)
if 10000>=N>=9000:
    print(10000-N)
n = int(input())
m = 1000
while m < n:
  m = m + 1000
print(m-n)
n = int(input())

c = n % 1000

if c == 0:
    s = 0
else:
    s = 1000 - c

print(s)
n = int(input())
if 0<= n <=1000:
    print(1000- n)
elif 1000< n <=2000:
    print(2000- n)
elif 2000< n <=3000:
    print(3000- n)
elif 3000< n <=4000:
    print(4000- n)
elif 4000< n <=5000:
    print(5000- n)
elif 5000< n <=6000:
    print(6000- n)
elif 6000< n <=7000:
    print(7000- n)
elif 7000< n <=8000:
    print(8000- n)
elif 8000< n <=9000:
    print(9000- n)
elif 1000< n <=10000:
    print(10000- n)
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

N %= 1000
if N==0:
    print(0)
else:
    print(1000-N)
n,x=int(input()),1000
a=n%x
print(x-a if a else 0)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())

    pay = (N + 1000 - 1) // 1000 * 1000
    ans = pay - N
    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
M = (N+999)//1000
print(M*1000-N)
a = int(input())
b = a % 1000
if b != 0:
	ans = 1000 - b 
else:
	ans = b
print(ans)
ans = int(input()) % 1000
if ans == 0:
    print(0)
    exit(0)
print(1000 - ans)
n = int(input())

if n <= 1000:
    print(1000-n)
elif 1000< n <=2000:
    print(2000-n) 
elif 2000< n <=3000:
    print(3000-n)
elif 3000< n <=4000:
    print(4000-n)
elif 4000< n <=5000:
    print(5000-n)
elif 5000< n <=6000:
    print(6000-n)
elif 6000< n <=7000:
    print(7000-n)
elif 7000< n <=8000:
    print(8000-n)
elif 8000< n <=9000:
    print(9000-n)
elif 9000< n <=10000:
    print(10000-n)
N=int(input())
ans=N%1000
ans=1000-ans
ans=ans%1000
print(ans)
import math
n = int(input())
print( math.ceil(n/1000)*1000-n)
N = int(input())
p= N%1000
if p==0:
    print(0)
else:
    print(1000-p)
N=int(input())%1000

if N==0:
  print(0)
else:
  print(1000-N)
m = int(input())
mod = m % 1000
if mod == 0:
    print(0)
else:
    print(1000 - mod)
N = int(input())

if N % 1000 == 0:
  print("0")
elif N < 1000:
  print(1000-N)
else:
  n = list(str(N))
  print(1000*(1+int(n[0]))-N)
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000-n%1000)
N = int(input())
if N == 0 or N%1000 == 0:
  print('0')
else:
  print(1000 - N%1000)
n = int(input())
n %= 1000
if n == 0:
    print(0)
else:
    print(1000 - n)
N = int(input())

print(0 if N%1000 == 0 else 1000-(N%1000))
N = int(input())

n = N//1000
if n * 1000 != N:
    n += 1
print(1000*(n)-N)
n = int(input())

if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)
n = int(input())
a = n % 1000
if a == 0:
  print(0)
else:
  print(1000 - a)
#!/usr/bin/env python3

def main():
    N = int(input())
    if N%1000 == 0:
        ans = 0
    else:
        ans = 1000 - N % 1000
    print(ans)


if __name__ == "__main__":
    main()
n = int(input())

i = 0
while i*1000<n:
    i += 1

print((i)*1000-n)
n = int(input())

a = n % 1000
if a == 0:
  print(0)
else:
  print(1000 - a)
n = int(input())

for i in range(1,100):
  if i*1000 >= n:
    print(i*1000-n)
    break
N = int(input())
print((1000 - N%1000) % 1000)
N = int(input())

if 1000 - N % 1000 == 1000:
  print(0)
else:
  print(1000 - N % 1000)
N=int(input())

if N%1000>0:
  print(1000-N%1000)
else:
  print(0)
n = int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)
N = int(input())
mod = N % 1000
if mod == 0:
    print(0)
else:
    print(1000 - N % 1000)
N = int(input())
if N%1000 == 0:
  print(0)
else:
  print(1000-(N%1000))
#!/usr/bin/python3
n = int(input())
if(n%1000==0):
	print("0")
else:
	ans = n%1000
	print(1000-ans)
a=input()
b=int(a[-3:])
if b==0:
  ans=0
else:
  ans=1000-b
print(ans)
n=int(input())
if n%1000:print(1000-(n%1000))
else:print(0)
N = int(input())

if N%1000 == 0:
  print(0)
else:
  print(1000-N%1000)
import math
N = int(input())
x = math.ceil(N/1000) * 1000
print(x-N)
n=int(input())
print(1000-((n-1)%1000)-1)
n = int(input())
if n %1000 == 0:
  print(0)
else:
  print(1000-n%1000)
n = int(input())

if((n%1000) == 0):
  ans = 0
else:
  ans = 1000-(n%1000)
  
print(ans)
n = int(input()) % 1000
print(1000 - n if n else 0)
n = int(input())
n = n % 1000
if 1000 - n == 1000:
    print(0)
else:
    print(1000 - n)
N  = int(input())

ans = N%1000
if ans == 0:
    print(0)
else:
    print(1000-ans)
# -*- coding: utf-8 -*-

N, = map(int, input().split())

if N%1000==0:
    print(0)
else:
    print(1000-(N%1000))
num = int(input())
if num % 1000 == 0:
    print(0)
else:
    t = num // 1000
    t += 1
    print(t * 1000 - num)
N = int(input())
if N%1000==0:
  print(0)
else:
  print(1000-(N%1000))
N = int(input())
for i in range(1,100):
    if i*1000 >= N:
        print((i*1000)-N)
        break
n=int(input())
res=0
cont=1
while n>0:
    n=n-(1000*cont)

print(abs(n))
N=int(input())

print(0 if N%1000==0 else 1000-N%1000)
n=int(input())
if n%1000==0:
    print("0")
else:
    z=n//1000
    print((z+1)*1000-n)
x = int(input())
if x % 1000 == 0:
  print(x%1000)
else:
  print((x//1000+1)*1000-x)
N=int(input())
if N%1000:
    print(1000-N%1000)
else:
    print(0)
n=int(input());print(1000-n%1000 if n%1000!=0 else 0)
N=int(input())
 
if N%1000==0:
    print(0)
else:
    ans =1000-(N%1000)
    print(int(ans))
N = int(input())
if(N%1000 == 0):
    print(0)
else :
    print(1000 - N%1000)
import math

n = int(input())

print(1000 * (math.ceil(n / 1000)) - n)
a = int(input())

b = (1000-a%1000)%1000

print(b)
import math
n = int(input())
x = math.ceil(n/1000)
print(x*1000-n)
n=int(input())
if n%1000!=0:
  print(1000-n%1000)
else:
  print(0)
n = int(input())
if n%1000 > 0:
    print(1000-n%1000)
else:
    print(0)
N = int(input())

A = N % 1000

if A == 0:
  print(0)
else:
  print(1000-A)
n = int(input())
if n%1000 == 0:
    change = 0
else:  
    change = (1000*(n//1000 + 1)) - n
print(change)
d = int(input())

if d % 1000 == 0:
    print(0)
else:
    print(1000 - d % 1000)
N = int(input())
if N/1000 == N//1000:
    pay = N//1000 * 1000
else:
    pay = (N//1000+1)*1000
print(pay-N)
n=int(input())
while(n>0): n-=1000
print(abs(n))
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000 - n % 1000)
n = int(input())
i = 0
while 1:
    if i*1000 >= n:
        print(i*1000-n)
        break
    else:
        i += 1