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:    
    ans = 0
else:    
    ans = 1000- n % 1000

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

change = N%1000

if change == 0:
    print(0)
    exit()

print(1000-change)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
maisuu = 1
answer = 0
while(True):
    if N <= (1000*maisuu):
        answer = (1000*maisuu)-N
        print(answer)
        break
    elif N <= 10000:
        maisuu += 1
    else:
        print("error")
        break

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

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(int((math.ceil(n/1000)*1000)-n))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
try:
  n=int(input())
  print((1000-n%1000)%1000)
except EOFError:
  pass

Submission status: Accepted

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

import sys

def main():
    n = int(input())
    for a in range(1, 11):
        if n <= a * 1000:
            print(a * 1000 - n)
            break

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = n // 1000
ans1 = n % 1000
if 0 < ans1:
  ans += 1
a = ans * 1000
if a < n:
  o = n - a
  print(o)
else:
  o = a - n
  print(o)

Submission status: Accepted

Solution code:
N = int(input())

zan = N % 1000

if zan == 0:
    print('0')
elif zan != 0:
    num = 1000 - zan
    print(num)

Submission status: Accepted

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

print(-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
table=[]
for i in range(11):
    m=1000*i-N
    if m>=0:
        table.append(m)
print(min(table))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#N円の商品を1000円札で支払う時のおつり。

price=int(input())
surpus=price%1000
print((1000-surpus)%1000)

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())
a = N//1000
b = ((a+1)*1000)-N
if b%1000 == 0:
	b = 0
    
print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


a = N//1000
change = ((a+1) * 1000) - N
if change%1000 == 0:
    change = 0

print(change)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1900"""
        output = """100"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3000"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys 

def A():
  n = int(sys.stdin.readline().rstrip())
  charge = (n+999)//1000 * 1000 - n
  print(charge)
  pass


def B():
  pass


def C():
  pass


def D():
  pass


def E():
  pass


def F():
  pass

if __name__ == "__main__":
  A() 
  B()
  C()
  D()
  E()
  F()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = 1000 - N

while a < 0:
    a = a + 1000

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

q, mod = divmod(N, 1000)
if mod != 0:
    print((q+1)*1000 - N)
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())

temp = N%1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math


try:
    sys.stdin = open(sys.path[0] + '/input.txt', 'r')
    sys.stdout = open(sys.path[0] + '/output.txt', 'w')
except FileNotFoundError:
    pass


n = int(input())

cnt = 1 + (n // 1000)
print((1000 * cnt - n) % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
price = int(input())
if price % 1000 == 0:
    print(0)
else:
    print(1000-(price%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())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input()) # yen

number_of_bills = int(N / 1000)
change = number_of_bills*1000 - N
if change < 0:
    change += 1000
print(str(int(change)))

Submission status: Accepted

Solution code:
N = int(input())
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:
n=input()
n=int(n)
ans=(1000-n%1000)%1000
print(ans)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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 pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    n %= 1000
    if n == 0:
        return 0

    return 1000 - n


print(main())

Submission status: Accepted

Solution code:
#! python3
# coding:utf-8

n = int(input())

i=1
while n > i*1000:
    i+=1
q = i*1000 -n
print(q)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = list(input())
m = int("".join(n[-3:]))
if m==0:
    ans = 0
else:
    ans = 1000-int(m)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    import sys
    readline = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    x, y = divmod(n, 1000)
    if y == 0:
        print(0)
    else:
        print(1000 - y)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def A_Payment():
    # 入力
    N = int(input())
    # 計算処理
    i = 1
    while True:
        if 1000 * i >= N:
            return 1000 * i - N
        else:
            i += 1

result = A_Payment()
print(result)

Submission status: Accepted

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    n = i2n()
    n = (10000 - n) % 1000
    print(n)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(12):
    if 1000 * i < n <= 1000 * (i+1):
        x = n - 1000 * i
print(1000-x)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = n // 1000
b = n / 1000

if a != b:
  print(1000 - (n - a * 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:
x=int(input(''))
if x%1000==0:
  print(0)
else:
  print(1000-x%1000)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(1000 - (N % 1000))

Submission status: Accepted

Solution code:
"""
atcoder : 173A
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""

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

Submission status: Accepted

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

result = money - N
print(result)

Submission status: Accepted

Solution code:
N = int(input())

r = N % 1000

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = x - n
print(ans)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

A = 1000

M = int(N/A)
O = 0

if N%A == 0:
    O = 0
else:
    O = A*(M+1) - N

print(O)

Submission status: Accepted

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

import bisect
import copy
import collections
import heapq
import itertools
import math
import numpy as np
from operator import itemgetter
import scipy.misc
import sys

"""
#### 入力例 ####
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
"""


N=int(input())


def main():
    print((1000-N%1000)%1000)
    return
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

output = x - N
print(output)

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())
if N%1000 == 0:
    print(0)
else:
    ans = (math.floor(N/1000)+1)*1000 - N
    print(ans)

Submission status: Accepted

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

print(change)

Submission status: Accepted

Solution code:
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	#print(name)
	sys.stdin = open(name)

a = int(input())

b = a%1000

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

Submission status: Accepted

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

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

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:
print(abs((-int(input())%1000)))

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(1000 - n % 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:
import math
N = int(input())
print(math.ceil(N/1000)*1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

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

r = N % 1000

if r == 0:
  print(0)
else:
  q = (N // 1000) + 1
  print(q*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())%1000
print(0 if not(N) else 1000-N)

Submission status: Accepted

Solution code:
n = int(input())

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

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:
import math

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

Submission status: Accepted

Solution code:
N=int(input())

a=N

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(i*1000-N)

Submission status: Accepted

Solution code:
import subprocess
import sys

code = r"""#include <iostream>
using namespace std;

int main() {
  int n; cin >> n;
  int need = (n + 1000 - 1) / 1000;
  cout << need * 1000 - n << '\n';
  
  return 0;
}
"""

with open("main.cc", "w") as f:
	f.write(code)
    
subprocess.Popen(['g++', '-std=c++2a', '-O2', "main.cc"]).communicate()
subprocess.Popen(['./a.out'], stdin=sys.stdin, stdout=sys.stdout).communicate()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
a = int(input())

b = (1000-a%1000)%1000

print(b)

Submission status: Accepted

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

Submission status: Accepted

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


print(m)

Submission status: Accepted

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

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    t = 0
    while t < n:
        t += 1000
    print(t - n)

main()

Submission status: Accepted

Solution code:
num = int(input())
if num % 1000 ==0:
    ans = 0
else:
    ans = 1000 - num % 1000
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())

s = n % 1000

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

Submission status: Accepted

Solution code:
n = int(input())
money = 1000
while money < n:
  money += 1000
  
print(money - n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
lines = list(s.rstrip("\n") for s in sys.stdin)
input = int(lines[0])
ceiled = math.ceil(input / 1000.0)
answer = ceiled * 1000 - input
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

MONEY = 1000
n = int(sys.stdin.readline().rstrip())

r = n % MONEY

print(MONEY - r if r > 0 else 0)

Submission status: Accepted

Solution code:
import math
n=int(input())
nn=n/1000

nn=math.ceil(nn)*1000

print(nn-n)

Submission status: Accepted

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

Submission status: Accepted

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

if mod1 != 0 :
    print(1000-mod1)
else:
    print(0)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
while n%1000:
	cnt+=1
	n+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
price = input()
if not int(price) % 1000:
    print("0")
else:
    if len(price) > 3:
        result = 1000 * (int(list(price)[0])+1) - int(price)
    else:
        result = 1000 - int(price)
    print(result)

Submission status: Accepted

Solution code:
num = int(input())
 
fraction = num % 1000
change =0
if fraction !=0:
  change = 1000-fraction
 
print(change)

Submission status: Accepted

Solution code:
n = int(input())

print((-1) *((-1) * n // 1000) * 1000 - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

print((10000 - n) % 1000)

Submission status: Accepted

Solution code:
x=int(input())


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

Submission status: Accepted

Solution code:
n = int(input())

i = n//1000 + 1

if (n%1000==0 and n>=1000):
    print(0)
else:
    ans = 1000*i - n
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A=int(N/1000)+1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
if n%1000 == 0:
  ans = 0
else:
  ans = 1000-n%1000
# 出力
print("{}".format(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())
for i in range(20):
  if(N <= 1000):
    break
  N -= 1000
print(str(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())
rem = n%1000
if rem != 0:
  print(1000-rem)
else:
  print(rem)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

k = 1000
i = 1
flag = True
while flag:
  a = i*k - n
  if a < 0:
    i += 1
  else:
    flag = False
print(a)

Submission status: Accepted

Solution code:
n = int(input())

res = n % 1000

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

Submission status: Accepted

Solution code:
N = int(input())

n = N % 1000

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

Submission status: Accepted

Solution code:
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    n = ii()
    tar = n % 1000
    print(1000 - tar if tar != 0 else 0)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
dash  =int(input())
otsuri1=dash%1000
if otsuri1==0:
  print(0)
else:
     otsuri2=1000-otsuri1
     print(otsuri2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n = I()

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

Submission status: Accepted

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


main()

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())
satu=n//1000
ans=(satu+1)*1000-n
if ans==1000:
  ans=0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range (10):
	if N <= 1000:
		ans = 1000 - N
	else:
		N -= 1000
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if 1 <= N <= 10000:
    if N%1000 != 0:
        ans = ((N//1000) + 1)*1000 - N
    else:
        ans = 0
else:
    ans = "choose another number"
print(ans)

Submission status: Accepted

Solution code:
import math
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    s = math.ceil(N / 1000)
    print(1000 * s - N)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = 1000
x = 1
while True:
  if int(a * x) >= n:
    break
  x += 1

print(int(a * x) -n)

Submission status: Accepted

Solution code:
s = input()
a = [int(c) for c in s]


if len(a) < 4:
    print(1000 - int(s))
elif a[-3] != 0:
    print((a[-4]+1)*1000 - int(s))
elif int(s) % 1000 != 0:
    print((a[-4]+1)*1000 - int(s))
else:
    print(0)