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 >= 1 and N <= 1000:
  print(1000 - N)
elif N >= 1001 and N <= 2000:
  print(2000 - N)
elif N >= 2001 and N <= 3000:
  print(3000 - N)
elif N >= 3001 and N <= 4000:
  print(4000 - N)
elif N >= 4001 and N <= 5000:
  print(5000 - N)
elif N >= 5001 and N <= 6000:
  print(6000 - N)
elif N >= 6001 and N <= 7000:
  print(7000 - N)
elif N >= 7001 and N <= 8000:
  print(8000 - N)
elif N >= 8001 and N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)

Submission status: Accepted

Solution code:
N = int(input())
yen = N // 1000 +1
shoki = yen * 1000
oturi = shoki - N
if oturi == 1000:
  print(int(oturi - 1000))
else:
  print(int(oturi))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Problem A - Payment
import math

# input
N = int(input())

# initialization
tmp = math.ceil(N / 1000)
ans = 1000*tmp - N

# output
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = []
for i in range(11):
    if 1000 * i - n >= 0:
        ans.append(1000*i - n)

print(min(ans))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    for i in range(1000,11000,1000):
        if i - n >= 0:
            print(i-n)
            return
            
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())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

for i in range(10+1):
    if 1000*i>=N:
        print(1000*i-N)
        break
    else:
        pass

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(0)
elif n<= 999:
  print(1000-n)
else:
  print(1000-int(str(n)[1:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

r=0
g=N%1000

r=1000-g
if r==1000:
  r=0

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

lst = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
if N in lst:
  thousands = int(N / 1000)
else:
  thousands = int(N / 1000) + 1

print((1000 * thousands) - N)

Submission status: Accepted

Solution code:
n=int(input())
x=n//1000

m=n-(1000*x)

if m==0:
  print(0)
else:
	y=1000-m
	print(y)

Submission status: Accepted

Solution code:
input = int(input())

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

for i in range(10000):
    if ( N <= 1000*i ):
        print(1000*i - N)
        break

Submission status: Accepted

Solution code:
n = int(input());

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import os
from sys import stdin, stdout


def solve(tc):
  n = int(stdin.readline().strip())
  rem = n%1000
  print(1000-rem if rem>0 else 0)


tcs = 1
tc = 1
while tc <= tcs:
  solve(tc)
  tc += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import bisect
import copy
#import time

#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input()))
n=int(input())
print(math.ceil(n/1000)*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
S = int(input())
pay = 1000
while S > pay:
    pay += 1000
else:
    print(pay - S)

Submission status: Accepted

Solution code:
N=int(input())
list = []
for i in range(10):
  s = (i+1)*1000-N
  if s >= 0:
    list.append(s)
print(min(list))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
# N=map(int,input().split())
# A=list(map(int,input().split()))
# B=list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1000, 11000, 1000):
    if i - n >= 0:
        print(i - n)
        break

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():
    n = int(input())
    ans = 0
    for i in range(1,10+1):
        num = 1000*i
        if num >= n:
            ans = i
            break

    print(abs(1000*ans - n))


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:
from sys import stdin
N = int(stdin.readline().rstrip())
if N % 1000 == 0:
    print(0)
else:
    ans = 1000 - N % 1000
    print(ans)

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

Submission status: Accepted

Solution code:
n=int(input())
k=1000
for i in range(1,10000):
    if(k*i-n>=0):
        print(abs(n-k*i))
        break

Submission status: Accepted

Solution code:
n = int(input())

ans = n

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

Submission status: Accepted

Solution code:
N = int(input())

amari = N % 1000

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
k = 1000

while(N > k):
    k += 1000

turi = k - N

print(turi)

Submission status: Accepted

Solution code:
N = input()
if(int(N)>=100):
  s = int(N[len(N)-3])*100+int(N[len(N)-2])*10+int(N[len(N)-1])
else:
  s = int(N)
if(s==0):
  print(0)
else: 
  print(1000-s)

Submission status: Accepted

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

Submission status: Accepted

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

if v != 0:
    v = 1000 - v


print(v)

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    a = int(input())
    m = int(a / 1000)
    n = int(a % 1000)
    if n != 0:
        m += 1
    print(int((m * 1000) - a))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
r = 0
while True:
  if 0 < N:
    N = N - 1000
  else:
    break
print(N * -1)

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

N = N - 1000
for j in range (10):
    if N - (1000*j) <= 0 :
        print(abs(N-(1000*j)))
        break

Submission status: Accepted

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

temp = N % 1000

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

times = N // 1000

ans = N - 1000*times

if ans != 0:
    ans = abs(1000 - ans)

print(str(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = 1000

while x<n:
  x += 1000
  
print(x-n)

Submission status: Accepted

Solution code:
""" A
    https://atcoder.jp/contests/abc173/tasks/abc173_a
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

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

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

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

if __name__ == "__main__":
    _N = readInteger()

    print(main(_N))

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(1000*n-N)

Submission status: Accepted

Solution code:
origin, charge = divmod(int(input()), 1000)
if charge != 0:
  print(1000 - charge)
else:
  print(charge)

Submission status: Accepted

Solution code:
N = int(input())

x = N %1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

print((10000 - 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:
p = int(input())

q, r = divmod(p, 1000)
if(r == 0):
  r2 = 0
else:
  r2 = 1000 - r

print(r2)

Submission status: Accepted

Solution code:
n = int(input())

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

print(pay-n)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    n = int(input())
    a = n // 1000

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for a in range(1,11):
    if N-a*1000<=0:
        b=a*1000-N
        break
print(b)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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())
# N,M = map(int,input().split())

n = 1000
while True :
    if (N > n) :
        n += 1000
        continue
    print(n - N)
    break

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 + 1) * 1000 - N if N % 1000 != 0 else 0)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())
q, mod = divmod(N, 1000)

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

Submission status: Accepted

Solution code:
n = int(input())
def main():
    for i in range(1, 11):
        a = 1000*i
        if n <= a:
            ans = a - n
            print(ans)
            return ans

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

while N >= 1000:
  N = N - 1000

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

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

Submission status: Accepted

Solution code:
N =int(input())

a = N % 1000

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

if n < 1000:
    print(1000-n)
    exit()

for i in range(10000):
    if n % 1000 == 0:
        break
    ans += 1
    n += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n%1000==0:
    print(ans)
    exit()
for i in range(10000):
    n+=1
    ans+=1
    if n%1000==0:
        break
print(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:
a=input()
a=int(a)
c=0
b=0
d=0
while c<a:
  c=c+1000

d=c-a
print(d)

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:
#1問目
N = int(input())
maisuu = 0
while N - 1000 * maisuu >= 1000:
    maisuu += 1
if(N - 1000 * maisuu == 0):
    print(1000 * (maisuu) - N)
else:
    print(1000 * (maisuu+1) - N)

Submission status: Accepted

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

Submission status: Accepted

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

import sys

def main():
    n = int(input())
    if n==0:
        print(0)
        exit()
    for i in range(11):
        if i*1000 >= n:
            print(i*1000-n)
            break

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

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

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


r = N % 1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N <= 1000:
  print(1000 - N)
elif N <= 2000:
  print(2000 - N)
elif N <= 3000:
  print(3000 - N)
elif N <= 4000:
  print(4000 - N)
elif N <= 5000:
  print(5000 - N)
elif N <= 6000:
  print(6000 - N)
elif N <= 7000:
  print(7000 - N)
elif N <= 8000:
  print(8000 - N)
elif N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

yen = (N // 1000)  
if N % 1000 != 0:
  yen += 1

print(yen * 1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

i = int(input())

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

print(1000 - (i % 1000))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = bills * 1000 - n
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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:
#A
n=int(input())
for i in range(100):
    if n<=1000:
        break
    else:
        n=n-1000
ans=1000-n
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
# ans = max(N % 1000, 1000 - N % 1000)

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

Submission status: Accepted

Solution code:
n=int(input())
x=int(1000)
while x<n:
    x=x+1000

print(x-n)

Submission status: Accepted

Solution code:
import math
def task():
    n=int(input())
    if(n>=1000):
        a=math.ceil(n/1000)
        a=a*1000
        n=a-n
    else:
        n=1000-n
    print(n)
def default():
    t=1
    while(t):
        t-=1
        task()
if(__name__=="__main__"):
    default()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    a = n % 1000
    print(1000-a)

Submission status: Accepted

Solution code:
N = int(input())
answer = 0
for i in range(1, 1000):
  pay = 1000 * i
  if pay >= N:
    answer = pay - N
    break
print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def actual(N):
    if N % 1000 == 0:
        return 0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A
N = input()
if (int(N) <= 1000):
    print(1000 - int(N))
elif (int(N) % 1000 == 0):
    print(0)
else:
    print(1000 - int(N[1:]))

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n=INT()
    n=n%1000
    if n==0:
        n=1000
    print(1000-n)
if __name__ == '__main__':
    do()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Payment():

    money = int(input())

    for n in range(0, 11):
        output = n*1000 - money
        
        if 0 <= output and output < 1000:
            break
    
    print(output)

if __name__ == '__main__':
    Payment()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
inp=int(input())

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

  print(oturi)

Submission status: Accepted

Solution code:
import math

N = int(input())

num = math.ceil((N / 1000))
print(num * 1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
m = 0
ans = 0
if(N%1000!=0):
    m = N//1000
    ans = 1000-(N-1000*m)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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