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.



Sample input:
1900


Sample output:
100

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def A():
    N = int(input())
    print(1000-N%1000 if N%1000 > 0 else 0) 

A()

Submission status: Accepted

Solution code:
n = int(input())
print((n+1000-1) // 1000 * 1000 - n) # round up

Submission status: Accepted

Solution code:
x=int(input())
if x%1000==0:
  print(0)
else:
  y=x%1000
  z=1000-y
  print(z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(1000-N%1000 if N%1000 > 0 else 0)

Submission status: Accepted

Solution code:
N = int(input())

cnt = N // 1000 + 1 if N % 1000 != 0 else N // 1000
print(1000*cnt - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = N%1000
if ans > 0:
  ans = 1000 - ans
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
#abc173a

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

Submission status: Accepted

Solution code:
n = int(input())
print((n + 999) // 1000 * 1000 - n)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
d = n // 1000
if n % 1000 != 0: d += 1
print(d * 1000 - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

print(1000 - ((n - 1) % 1000 + 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
print(-(-n//1000)*1000-n)

Submission status: Accepted

Solution code:
import sys
# import math
input = sys.stdin.readline


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


def str_array():
    return input().strip().split()


def lower_letters():
    lowercase = [chr(i) for i in range(97, 97+26)]
    return lowercase

def how_frequent(lis):
	last = None
	count = []
	each = 1
	for i in range(len(lis)):
		if last != None:
			last = lis[i-1]
		if last == lis[i]:
			each += 1
		else:
			count.append(each)
			each = 0
		last = lis[i]
	return max(count)


def upper_letters():
    uppercase = [chr(i) for i in range(65, 65+26)]
    return uppercase

######################### TEMPLATE ENDS HERE ##################################
n = int(input())
if n % 1000 != 0:
	print(1000-(n%1000))
else:
	print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## necessary imports
import sys
input = sys.stdin.readline
# from math import ceil, floor, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1;
    return x;
    
# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

## gcd function
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

## nCr function efficient using Binomial Cofficient
def nCr(n, k): 
    if(k > n - k): 
        k = n - k 
    res = 1
    for i in range(k): 
        res = res * (n - i) 
        res = res / (i + 1) 
    return int(res) 

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0, hi = None):
    if hi == None:
        hi = len(a);
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;


# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n = int(input()); x = n % 1000;
print(1000 - x if x else 0);

Submission status: Accepted

Solution code:
N = int(input())
k = (N + 999)//1000
print(k*1000 - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

print((1000 - n%1000)%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
N=int(n)
if 1<=N and N<1000:
  ch1=1000-N
  print(ch1)
else:
  if int(n[3])==0 and int(n[2])==0 and int(n[1])==0 :
    print(0)
  else:
    ch2=1000*(int(n[0])+1)-N
    print(ch2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
pay = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]

for p in pay:
  if (p - n) < 1000 and (p - n) >= 0:
    print(p-n)
    exit()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


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


print(solve())

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

mod = N % 1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

th = (999 + n) // 1000

print(1000 * th - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 11):
    if 1000 * i >= N:
        break
print(1000 * i - N)

Submission status: Accepted

Solution code:
n = int(input())
a = int(n/1000 +1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(-N%1000)

Submission status: Accepted

Solution code:
N = int(input())

while N > 0:
    N -= 1000
print(-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys,math,collections
from collections import defaultdict
import math,sys
#from itertools import permutations,combinations

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
	

def get_array():
	l=list(map(int, input().split()))
	return l
def sod(n):
	n,c=str(n),0
	for i in n:	
		c+=int(i)
	return c	
#file()	
def main():
	#a,b=map(int, input().split())
	n=int(input())
	ans=1000
	
	for i in range(100000):
		if(ans>=n):
			print(ans-n)
			
			break
		else:	
			ans+=1000
	#for _ in range(int(input())):
		'''n,x=map(int, input().split())
		l=list(map(int, input().split()))
		l.sort()
		for i in range(len(l)):
			if(2*l[i]>x):
				ind=i
				break
		
		l=l[ind:]+l[:ind]
		print(l)
		cures=len(l)
		i,ans=0,0
		print('h')
		while(cures>0):
			print("nz")
			if(x>=l[i]):
				cures-=1
				x=2*l[i]
				i+=1
			else:
				temp=l[i]
				l[i]=l[i]-x

				l[i]=min(2*l[i],temp)
			ans+=1
		print(ans)'''



		







		
		
		











		








if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#import 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
if n%1000 != 0:
    print(1000-n%1000)
else:
    print(0)

Submission status: Accepted

Solution code:
# A - Payment
def main():
    N = int(input())
    print(1000 - N % 1000 if N % 1000 else 0)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()

ans = -N % 1000
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(11):
  if n <= 1000*i:
    print(1000*i-n)
    break

Submission status: Accepted

Solution code:
n = int(input())
print((-1*n) % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = int(input())

a = m % 1000
if a == 1000:
  print(0)
elif a == 0:
  print(0)
else:
  print(1000-a)

Submission status: Accepted

Solution code:
n=int(input())
ans=1000
if n<100:
    print(abs(n-ans))
    exit()
else:
    ans=1000
    while(n>=ans):
        if ans==n:
            break
        elif ans>n:
            break
        else:
            ans+=1000
print(abs(n-ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num=input()
if 1<=int(num)<=10000:
    if int(num)<=1000:
        change=1000-int(num)
    else:
        array_1=list(num)
        array_1=array_1[-4:]
        a=''.join(array_1)
        b=int(array_1[-4])+1
        pay=b*1000
        change=pay-int(a)
        if array_1[-1]=="0" and array_1[-2]=="0" and array_1[-3]=="0":
            change=0
    print(change)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations 
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def li():
	return [int(x) for x in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def gi():	
	return [x for x in input().split()]
def fi():
	return int(input())
def swap(a,i,j):
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())	
def gh():
	sys.stdout.flush()
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def bo(i):
	return ord(i)-ord('a')
		


tt=1


while tt>0:
	tt-=1
	n=fi()
	p=n//1000*1000
	if p<n:
		p+=1000
	print(p-n)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
import heapq 
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def main():
    try:
        n=I()
        temp=(math.ceil(n/1000)*1000)-n
        print(temp)
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()

Submission status: Accepted

Solution code:
import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


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


if __name__ == '__main__':
    # set_debug(True)

    # t = int(input())
    t = 1

    for ti in range(1, t + 1):
        n = int(input())

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

Submission status: Accepted

Solution code:
amount = int(input())
if(amount % 1000 == 0):
  print(0)
else:
  change = (amount // 1000 + 1) * 1000 - amount
  print(change)

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
n = int(input())
f = (n+1000-1)//1000
print(f*1000-n)

Submission status: Accepted

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

    change = -N % 1000
    print(change)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
p = n%1000
if p != 0:
    print(1000-p)
else:
    print(0)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    ans = 10 ** 5
    for i in range(10, 0, -1):
        a = 1000 * i
        if a < N:
            break
        ans = a - N
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
import math

N = int(input())
mille = 1000
r = math.ceil(N/1000)
print(r*1000 - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input());print(-(-n//1000)*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import sys
INF=1e11
import bisect
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
from collections import defaultdict 
import math
#for _ in range(int(stdin.readline())):
n=get_int()
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)

Submission status: Accepted

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

Submission status: Accepted

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

    change = (N + 999) // 1000 * 1000 - N
    print(change)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
enn = int(input())

syoji = 1000


while syoji < enn:
    syoji = syoji +1000

print(syoji-enn)

Submission status: Accepted

Solution code:
import sys
n = int((input()))
if n%1000 == 0:
    print(0)
else:
    for i in range(10):
        if n < 1000:
            print(1000-n)
            sys.exit()
        else:
            n -= 1000

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def main(a):
    return int(math.ceil(a/1000.0)*1000-a)

if __name__ == "__main__":
    a = int(input())
    print(int(main(a)))

Submission status: Accepted

Solution code:
print((11000 - int(input())) % 1000)

Submission status: Accepted

Solution code:
#! /usr/bin/python3

N = int(input())
1 <= N <= 10000

if N % 1000 == 0:
 print(0)
else:
  sen = N//1000
  sen2 = sen*1000
  atai = N-sen2
  atai2 = 1000-atai
  print(atai2)

Submission status: Accepted

Solution code:
N = int(input())

A = (N + 1000 - 1) // 1000
print(A*1000 - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数（1 <= N <= 10000）
    """
    # 求解処理
    ans = (1000 - (N % 1000)) % 1000

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,11):
  if n<=i*1000:
    break
print(i*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = (N+1000-1)//1000
ans = 1000*x - N
print(ans)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ans=1000
if n<100:
    print(abs(n-ans))
    exit()
else:
    ans=1000
    while(n>ans):
        if ans==n:
            break
        elif ans>n:
            break
        else:
            ans+=1000
print(abs(n-ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()

print(999-(N-1)%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
if len(N)>3:
    i=(int(N[:-3])+1)*1000
else:
    i=1000

j=i-int(N)

if j>999:
  print(0)
else:
  print(j)

Submission status: Accepted

Solution code:
N = int(input())

i = 1
while 1000 * i < N:
	i += 1
	
print(1000 * i - N)

Submission status: Accepted

Solution code:
n=int(input())


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

Submission status: Accepted

Solution code:
t=int(input())
if t>=10000:
    t%=10000
    if t==0:
        print(t)
    else:
        print(1000-t)
else:
    t%=1000
    if t==0:
        print(t)
    else:
        print(1000-t)
import math

#print(math.ceil(t/1000)*1000-t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
from math import ceil
u=ceil(x/1000)*1000
print(u-x)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,11):
    if n <= i * 1000:
        break;
print(i*1000 - n)

Submission status: Accepted

Solution code:
N = int(input())

while N > 0:
    N -= 1000

print(-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()
'''

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r = 1000 - int(input()) % 1000
print(r if r < 1000 else 0)

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    print((1000 - int(input()) % 1000) % 1000)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = 0
while True:
    if n*1000 >= N:
        print(n*1000 - N)
        break
    n += 1

Submission status: Accepted

Solution code:
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
print((100000000-n)%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n = ii()
t=1000
for i in range(1,11):
    if t*i >= n:
        print(t*i-n)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
a=int(s[0]/1000) if s[0]%1000==0 else int(s[0]/1000)+1
print(1000*a-s[0])