Problem:
 Score : 100 points    Problem Statement We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000 -yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.      Constraints  1 \leq N \leq 10000  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the amount of change as an integer.        Sample Input 1 1900      Sample Output 1 100  We will use two 1000 -yen bills to pay the price and receive 100 yen in change.       Sample Input 2 3000      Sample Output 2 0  We can pay the exact price.

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    
    
    
    
    a=N//1000
    b=N%1000
    if b==0:
        print(0)
    else:
        print((a+1)*1000-N)





if __name__ == "__main__":
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
res = n // 1000
print((res+1) * 1000 - n if n % 1000 != 0 else 0)

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

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

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

Solution (Python):
n =  int(input())
if n % 1000 == 0:
  print("0")
else:
  print(1000 - (n % 1000))

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

Solution (Python):
def resolve():
    N = int(input())
    print(((N+999)//1000)*1000-N)

resolve()

Solution (Python):
n=int(input())
while n > 0:
  n-=1000
print(n*-1)

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

Solution (Python):

n=int(input())
    
x=0
while(x<n):
    x+=1000
print(abs(n-x))

Solution (Python):
n = int(input())

n2 = n % 1000
print( (1000 - n2) % 1000 )

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

Solution (Python):
def main():
    N = int(input())

    r = 1000 - N % 1000

    if r == 1000:
        print(0)
    else:
        print(r)


if __name__ == '__main__':
    main()

Solution (Python):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]


def solve(N):
    if N%1000 == 0:
        return 0
    num = N//1000
    return (num+1)*1000-N
N = rri()
print(solve(N))

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

Solution (Python):
n=int(input())
ans=1000-n%1000
if ans==1000: ans=0
print(ans)

Solution (Python):
n = int(input())

if n%1000==0:
    print(0)
else:
    mai = n//1000
    print((mai+1)*1000-n)

Solution (Python):
N = int(input())

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

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

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

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

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

Solution (Python):



N = int(input())

ans = 1000 - (N - N//1000*1000)

if ans == 1000:
    print(0)
else:
    print(ans)

Solution (Python):
N=int(input())
while N>1000:
    N-=1000
print(1000-N)

Solution (Python):

import sys


def solve(N: int):
    p = N % 1000
    if p > 0:
        p = 1000 - p
    print(p)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

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

Solution (Python):
a = int(input())
if a % 1000 == 0:
    print(0)
else:
    b = a // 1000 + 1
    print(b*1000-a)

Solution (Python):
N=int(input())

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

Solution (Python):

import sys


def solve(N: int):
    rest = N % 1000
    if rest != 0:
        print(1000 - rest)
    else: 
        print(rest)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  if n%1000==0:
    print(0)
  else:
    print(1000-n%1000)

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

Solution (Python):
n = int(input())
if n % 1000 == 0:
    x = n / 1000
else:
    x = n // 1000 + 1
print(int(1000 * x - n))

Solution (Python):
N=int(input())
while N>1000:
  N-=1000
print(1000-N)

Solution (Python):


N = int(input())

ans = N % 1000
ans = 1000 - ans if ans != 0 else 0

print(ans)

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
for i in range(1,11):
    if 1000*i >= N:
        print(1000*i-N)
        sys.exit()

Solution (Python):
def main():
    N = input_ints()

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


def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

Solution (Python):
n = int(input())

n_ = n%1000
if n_==0:
    print(0)
else:
    print(1000-n_)

Solution (Python):
n = int(input())


for i in range(10000):
    if (i+1)  * 1000 - n >= 0:
        print((i+1) *1000 - n)
        break

Solution (Python):
N = int(input())

print((1000-N%1000)%1000)

Solution (Python):

N = int(input())

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

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def solve(n):
    k = n // 1000
    if n % 1000 > 0:
        k += 1
    return k * 1000 - n


def main():
    n = ri()
    wi(solve(n))


if __name__ == '__main__':
    main()

Solution (Python):
num = int(input())
val = num % 1000
if val == 0: print(0)
else: print(1000 - val)

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

Solution (Python):
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    ans = (N//1000 + 1)*1000 - N
    print(ans)

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())
print(((N - 1) // 1000 + 1) * 1000 - N)

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

Solution (Python):
n = int(input())

for i in range(1, 10001):
    if (i*1000 - n) >= 0:
        print(i*1000 - n)
        break

Solution (Python):
n = int(input())
cash = 1000 - n % 1000
if cash == 1000:
  cash = 0
print(cash)

Solution (Python):
n=int(input())
n%=1000
print((1000-n)%1000)

Solution (Python):
number = int(input())
if (number % 1000) == 0:
    print(0)
else:
    print(1000 - number % 1000)

Solution (Python):
print((1000 - int(input()) % 1000) % 1000)

Solution (Python):
n = int(input())
x = (n+1000-1)//1000
x*=1000
print(x-n)

Solution (Python):
n = int(input())

if n%1000==0:
	print((n//1000)*1000-n)
else:
	print((n//1000+1)*1000-n)

Solution (Python):
N = int(input())
ans = 0
for i in range(11):
    if 1000*i >= N:
        ans = 1000*i - N
        break
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    print((1000-ii()%1000)%1000)

main()

Solution (Python):

N = int(input())
while N>0:
    N-=1000
print(-1*N)

Solution (Python):
div,mod = divmod(int(input()), 1000)
print((1000 - mod) % 1000)

Solution (Python):
import math
N=int(input())
print(math.ceil(N/1000)*1000 - N)

Solution (Python):
import sys, math,os
from io import BytesIO, IOBase



from collections import defaultdict as dd, deque, Counter


def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')

INF = 10**9
mod = 998244353

N=int(data())
out((1000-N%1000)%1000)

Solution (Python):
N = int(input())
ans = -N % 1000
print(ans)

Solution (Python):
n = int(input())
ans = 1000 -  n % 1000
if ans == 1000:
    ans = 0
print(ans)

Solution (Python):
n=int(input());print(1000-n%1000 if n%1000!=0 else 0)

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

Solution (Python):
n = int(input())
while n > 0:
    n -= 1000
print(abs(n))

Solution (Python):




def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


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

    for i in range(1, 11):
        if i * 1000 >= n:
            return i * 1000 - n

    return


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

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

Solution (Python):
N = int(input())
for i in range(11):
    if i * 1000 >= N:
        print(i * 1000 - N)
        exit()

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

Solution (Python):
N = int(input())

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

Solution (Python):
"""everything has a cost!"""

from math import *
import random, functools, collections, sys

__author__ = 'p7x'







if __name__ == '__main__':
    n = int(input())
    print(int(1000*ceil(n/1000)-n))

Solution (Python):
import sys
n = int(input())
for i in range(1, 11):
    if i * 1000 >= n:
        print(i * 1000 - n)
        sys.exit()

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

Solution (Python):
n = int(input())

if(n%1000 == 0):
    print('0')
else:
    print(1000 - n%1000)

Solution (Python):
n = int(input())
ans = (1000 - n%1000)%1000
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

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

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

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

Solution (Python):
N= int(input())
i=1
while(True):
    if N<=i*1000:
        print(i*1000-N)
        break
    else:
        i+=1

Solution (Python):
n = int(input())
if n%1000 == 0:
    print("0")
else:
    ans = n%1000
    ans = 1000 - ans
    print(ans)

Solution (Python):
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

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

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

if __name__ == '__main__':
    main()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    if N%1000 == 0:
        return 0
    return 1000-N%1000


if __name__ == '__main__':
    print(solve())

Solution (Python):
N = int(input())

for num in range(12):
  if num*1000 >= N:
    print(num*1000-N)
    exit()

Solution (Python):
a=int(input())
if a%1000!=0:
  print(1000-a%1000)
if a%1000==0:
  print(0)

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

Solution (Python):
n = int(input())
print(abs((1000 - n) % 1000))

Solution (Python):
n = int(input())
for i in range(10000):
    if i*1000 >= n:
        print(i*1000 - n)
        break
    else:
        pass

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()

    
    print(int(ceil(N/1000))*1000-N)

Solution (Python):
n=int(input())
mod=n%1000

if mod==0:
    print(0)
else:
    print(1000-mod)

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

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

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

Solution (Python):
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

n = n%1000

ans = 1000-n

if ans==1000:
	ans = 0

print(ans)

Solution (Python):
n=int(input())
while n>0:
  n-=1000
print(abs(n))

Solution (Python):
def main():
    X =int(input())
    rest = (X+1000) % 1000
    if rest==0:
        print(0)
    else:
        print(1000-rest)


if __name__ == "__main__":
    main()

Solution (Python):

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

Solution (Python):
n = int(input())
mod = n % 1000
if mod > 0:
    print(1000-mod)
else:
    print(mod)

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

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

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

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

Solution (Python):
N = int(input())

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

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

Solution (Python):
N = int(input())
m = N % 1000
if m != 0:
  m = 1000 - m
print(m)

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
n=int(input())
n=n%1000
n=1000-n
n=n%1000
print(n)

Solution (Python):

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

  ans = 1000 - n % 1000

  print(0 if ans >= 1000 else ans)


main()

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue


Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  
    n = int(input())
    print(1000-n%1000 if n % 1000 != 0 else 0)
if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())

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

Solution (Python):
N = int(input())

remain = N % 1000
print((1000-remain) % 1000)

Solution (Python):

import sys


def solve(N: int):
    from math import ceil
    return int(ceil(N / 1000) * 1000) - N



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())
a = (n-1)//1000
print((a+1)*1000-n)

Solution (Python):
N = int(input())

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

Solution (Python):
n=int(input())

rem=n%1000
if(rem==0):
    print(0)
else:
    print(1000-rem)

Solution (Python):
n = int(input())

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

Solution (Python):
n=int(input())
print((10000-n)%1000)

Solution (Python):
n=int(input())  

n2=n%1000

if n2==0:
    print(0)
else:
    print(1000-n2)

Solution (Python):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N):
    x = N % 1000
    if x == 0:
        return 0
    else:
        return 1000 - x



N = int(input())
print(calc(N))

Solution (Python):
N = int(input())

print((1000 - N) % 1000)

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

Solution (Python):
def resolve():
    n = int(input())
    print((1000 - n % 1000) % 1000)


if __name__ == '__main__':
    resolve()

Solution (Python):
yens = int(input())

if yens % 1000 > 0:
    print(1000 - yens % 1000)
else:
    print(yens % 1000)

Solution (Python):
def main():
    N = int(input())

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

    

if __name__ == '__main__':
    main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    ans = inf
    for i in range(1, 11):
        if i * 1000 >= N:
            ans = min(ans, i * 1000 - N)
    print(ans)
main()

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    for i in range(11):
        if  1000 * i >= n:
            break

    print(1000*i-n)
 
if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

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

Solution (Python):
s = int(input())
if s % 1000 == 0:
    print(0)
else:
    print(1000 - s % 1000)

Solution (Python):
n = int(input())

while(n > 1000):
    n = n-1000

print(1000-n)

Solution (Python):
n = int(input())

if n % 1000 == 0 :
    print(0)
    exit()
print(1000-n%1000)

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

Solution (Python):
N = int(input())
ans = (1000 - (N % 1000)) % 1000
print(ans)

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

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

if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())

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

Solution (Python):
n=int(input())

while n>0:
    n-=1000

print(abs(n))

Solution (Python):
n = int(input())
p = 1000
while(n > p):
	p += 1000
print(p - n)

Solution (Python):
n=int(input())

a=n%1000

if a==0:
  print(0)
else:
  print(1000-a)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    for i in range(0, 10001, 1000):
        if i >= n:
            print(i - n)
            break


if __name__ == '__main__':
    resolve()

Solution (Python):
N=int(input())
if N%1000==0:
    print(0)
    exit()
print(1000-(N%1000))

Solution (Python):
N=int(input())

if N%1000==0:
    a=N//1000
else:
    a=N//1000+1

print(int(a*1000-N))

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    n = (N + 999) // 1000
    print(n * 1000 - N)


main()

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    n %= 1000

    print(1000-n)

Solution (Python):

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

Solution (Python):
n = int(input())
print((1000-n%1000)%1000)

Solution (Python):
N = int(input())
R = int(N / 1000)
if N%1000 == 0:
  pass
else:
  R = R+1
print(R*1000 - N)

Solution (Python):
N=int(input())
payment=1000
while payment<N:
    payment+=1000


print(payment-N)