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())
k = 1000
while k<N:
  k += 1000
print(k-N)

Submission status: Accepted

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

else:
    b = 1000 - a
    print(b)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
price=int(input())

if(price%1000==0):
    change=0
else:
    for i in range(11):
        change=1000*i-price
        if(change>0):
            break
        
print(change)

Submission status: Accepted

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

Submission status: Accepted

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

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:
N = int(input())
if N%1000==0:
    print(0)
else:
    tmp = N//1000
    res = tmp+1
    print(res*1000-N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
while a>1000:
  a-=1000
print(1000-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
if n%1000 == 0:
    print(0)
else:
    for i in range(1,11):
        if i*1000 > n:
            num = (i)*1000
            break
    print(num-n)

Submission status: Accepted

Solution code:
a = int(input())
c = 0

while(c<a):
  c+=1000

print(c-a)

Submission status: Accepted

Solution code:
N = input()
n = N[-3:]
n = int(n)
A = 1000- n
if n ==0:
  print(0)
else:
  print(A)

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())
if (n % 1000 == 0):
  print(0)
else:
  print(1000 - n % 1000)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(12):
    if 1000*i - n >= 0:
        print(1000*i-n)
        exit()

Submission status: Accepted

Solution code:
N = int(input())
b = N % 1000

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

Submission status: Accepted

Solution code:
n = int(input())
ini = 1000
diff = 0
while True:
    if ini-n>=0:
        break
    ini += 1000
print(ini-n)

Submission status: Accepted

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

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())
print(0) if N%1000==0 else print(1000-N%1000)

Submission status: Accepted

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

    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())
x = N + (-N) % 1000
print(x - 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())
y = n%1000
if y == 0:
    print(0)
else:
    print(1000-y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    for i in range(1000):
        if (n+ i)%1000 == 0:
            print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()

_, c = divmod(N, 1000)
if c == 0:
    print(0)
else:
    print(1000 - c)

Submission status: Accepted

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

# from math import gcd
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, combinations_with_replacement

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=0
while a<n:
    a+=1000
print(a-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())
money=1000
while(1):
    if n<=money:
        break
    money+=1000
print(money-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:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    while n > 0:
        n -= 1000
    print(abs(n))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
while True:
  n -= 1000
  if n <= 0:
    print(abs(n))
    break

Submission status: Accepted

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

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
while True:
  if n<=1000:
    break
  n-=1000
print(1000-n)

Submission status: Accepted

Solution code:
N=int(input())
for i in range(1,11):
  res = 1000 * i -N
  if 0<= res <1000:
    break
  else:
    pass
print(res)

Submission status: Accepted

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

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();
N=int(N);
if not 0==N%1000:
  a=1000-(N%1000);
else:
  a=0;
print(a)

Submission status: Accepted

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

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%1000)%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#n, k = list(map(int, input().split()))
#A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
# a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))

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

for i in range(11):
    if n > 1000*i and n < 1000*(i+1):
        print(1000*(i+1)-n)
        exit()
print(0)

Submission status: Accepted

Solution code:
n=input()
# print(n[-3:])
a=1000-int(n[-3:])
if a == 1000 :
    print(0)
else:
    print(1000-int(n[-3:]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    cnt = 0
    while True:
        cnt += 1
        remain = n - (cnt*1000)
        if remain <= 0:
            change = cnt*1000 - n
            break


    print(change)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n = input()
p = int(n[-3:])
if p == 0 :
    print(0)
else :
    print(1000 - int(n[-3:]))

Submission status: Accepted

Solution code:
def resolve():
    c = int(input())

    if c % 10**3 != 0:
        print(1000 - c % 10**3)
    else:
        print(0)

resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(20):
    if 1000 * i >= n:
        print(1000 * i - n)
        break

Submission status: Accepted

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

Submission status: Accepted

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

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:
a = int(input())

if a % 1000 == 0:
    print("0")
    quit()

while a > 1000:
    a -= 1000
    if a < 1000:
        break
print(1000-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
while n > 1000:
    n -= 1000

print(1000-n)

Submission status: Accepted

Solution code:
N = int(input())

n=N%1000

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


# 2darray [[0] * 4 for i in range(3)]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N % 1000 == 0:
    ans = 0
else:
    n = N // 1000
    ans = abs(N - (n + 1) * 1000)

print(ans)

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:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    a = int(stdin.readline().rstrip())
    amari = a % 1000
    if amari == 0:
        print(0)
    else:
        print(1000-amari)
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
tmp=n%1000

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

Submission status: Accepted

Solution code:
N = int(input())


ch = 1000 - (N % 1000)

if ch != 1000:
    print(ch)
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())

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

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())

a = n // 1000
if n % 1000 > 0 :
    a = a + 1

# print(a)
print(a*1000 - n)

Submission status: Accepted

Solution code:
def solve() :
    n = int(input())

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

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:
s = input()
print (0) if int(s[-3::]) == 0 else print (1000-int(s[-3::]))

Submission status: Accepted

Solution code:
N = int(input())

r, q = divmod(N, 1000)

if q == 0:
    output = 0
    
else :
    output = (r + 1)*1000 - N
    
print(output)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
print(1000 - N % 1000 if N % 1000 else 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:
def main():
    n = int(input())
    if n % 1000 == 0:
        print(0)
    else:
        print(1000*(n//1000 + 1) - n)

if __name__ == '__main__':
    main()

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())
a = N%1000
if a == 0:
    print(0)
else:
    print(1000-N%1000)

Submission status: Accepted

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

Submission status: Accepted

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

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 = n % 1000
if mod_n==0:
  print(0)
else:
  print(1000-mod_n)

Submission status: Accepted

Solution code:
n = int(input())

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

print(abs(n))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

if n % 1000 == 0:
    print(0)
else:
    change = n // 1000

    print( 1000 - (n - change * 1000))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    a=(n+999)//1000
    print(a*1000-n)

main()

Submission status: Accepted

Solution code:
n = int(input())

a = (n//1000+1)*1000-n

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

Submission status: Accepted

Solution code:
n = int(input())
x = 1000
while n > x:
  x += 1000
print(x-n)

Submission status: Accepted

Solution code:
n = int(input())

if n%1000 == 0:
  a = n // 1000
else:
  a = (n // 1000) +1

print((a *1000) - n)

Submission status: Accepted

Solution code:
n = int(input())

while True:
   
    if n <= 1000:
        print(1000-n)
        exit()
    n -= 1000

Submission status: Accepted

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

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())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# map(int, input.split())
price = int(input())
if price < 1000: print(1000-price)
else:
    a, b = divmod(price, 1000)
    if b == 0: print("0")
    else: print(1000-b)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:

from collections import deque



# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from bisect import bisect_left as bl
from math import log2,ceil
from heapq import heappush, heappop
from itertools import permutations 
def main():
    # for t in range(int(input())):
        n = int(input())
        x = (n+1000)//1000*1000-n
        if x==1000:
            print(0)
        else:
            print(x)

            # heappush(h, l[i])

        


        
        




# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = (n // 1000)
money = count * 1000

if money < n:
  print((count+1) * 1000 -n)
else:
  print((count) * 1000 -n)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
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 print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()

    if N % 1000 == 0:
        print(0)
    else:
        cur = 1000
        while cur <= N:
            cur += 1000
        print(cur - N)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ha =  (N // 1000 + 1) * 1000 - N 

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

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:
  while N>=1000:
    N-=1000
  print(abs(N-1000))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

#print(n)

while n > 0:
  n -= 1000
  
print(abs(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())
M = 10000 - N
M = str(M)
M = M[-3:]
M = int(M)
print(M)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())

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

Submission status: Accepted

Solution code:
k=1
N=int(input())
while(1):
    if(k*1000>=N):
        break
    else:
        k+=1
ans=1000*k-N

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

reminder = N % 1000

if reminder:
  res = 1000 - reminder
  print(res)
else:
  print(0)

Submission status: Accepted

Solution code:
n= int(input())
if 1<=n<=1000:print(1000-n)
if 1001<=n<=2000:print(2000-n)
if 2001<=n<=3000:print(3000-n)
if 3001<=n<=4000:print(4000-n)
if 4001<=n<=5000:print(5000-n)
if 5001<=n<=6000:print(6000-n)
if 6001<=n<=7000:print(7000-n)
if 7001<=n<=8000:print(8000-n)
if 8001<=n<=9000:print(9000-n)
if 9001<=n<=10000:print(10000-n)

Submission status: Accepted

Solution code:
N = int(input())
ans = 1000
while(ans<N):
    ans+=1000
print(ans-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
if int(n[-3:]) == 0:
  print(0)
else:
  print(1000 - int(n[-3:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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 = n % 1000
if 1000 - n == 1000:
    print(0)
else:
    print(1000 - n)

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:
N = int(input())

ans = 1000-(N%1000)

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

Submission status: Accepted

Solution code:
N=int(input())

a=N//1000

ans=1000-(N-a*1000)

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

Submission status: Accepted

Solution code:
n = int(input())
x = 0
for i in range(11) :
    if 1000*i>=n and x == 0:
        x = i

print(1000*x-n)

Submission status: Accepted

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

Submission status: Accepted

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

N=int(input().rstrip('\n'))
n = N%1000
if n==0:
  print(n)
else:
  print(1000-n)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


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


def instr():
    s = input()
    return(list(s[:len(s)]))


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


def main():
    n = inp()
    if n % 1000 == 0:
        res = 0
    else:
        res = (n // 1000)*1000 + 1000 - n

    print(res)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    main()