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:
def A(x):
  return 1000 - x % 1000 if x % 1000 != 0 else 0


def B(s, t):
  pass


def C(n, m, k, a, b):
  pass


def main():
  n = int(input())
  print(A(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:
n = int(input())

change = n

while change > 0:
    change = change - 1000

if change < 0:
    change = 0 - change

print(change)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

amari = N % 1000

if amari != 0:
    ans = 1000 - amari
else:
    ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = N % 1000

if ans != 0:
    ans = 1000 - ans

print(ans)

Submission status: Accepted

Solution code:
def readinput():
    n=int(input())
    return n

def main(n):
    amari=n%1000
    if amari==0:
        return 0
    else:
        return 1000-amari

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)

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

a=n%1000

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

Submission status: Accepted

Solution code:
#A
n = int(input())
if n % 1000 != 0:
    oturi = (n//1000 + 1)*1000 - n
    print(oturi)
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())
t = n%1000
if t==0:
  t=1000
print(1000-t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    c = N % 1000
    if c == 0:
        print("0")
    else:
        print(1000 - (N % 1000))

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

Ans = N % 1000

if Ans == 0:
    print(Ans)
else:
    Ans_0 = 1000 - Ans
    print(Ans_0)

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((N // 1000 + 1) * 1000 - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

i=1
while True:
    if i*1000>=N:
        dammy= i*1000
        break
    i+=1

print(dammy-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())

N_ceil = math.ceil(N/1000)

print(1000*N_ceil - N)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
a = int(input())
x = 0
for i in range(a):
    if a > x:
        x = x + 1000
    else:
        break
print(abs(x - a))

Submission status: Accepted

Solution code:
s = [input() for i in range(1)] 
s0 = int(s[0])

if s0%1000 ==0:
  print(0)
if s0%1000 !=0:
  print(1000-s0%1000)

Submission status: Accepted

Solution code:
n = int(input())

i = 1
while(1) :
    if(i * 1000 >= n):
        print(i * 1000 - n)
        break
    else :
        i += 1

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

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

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

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

  print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
AtCoder :: Beginner Contest 173 :: Payment
https://atcoder.jp/contests/abc173/tasks/abc173_a
"""
import sys


def main():
    """Main program."""
    N = int(sys.stdin.readline())
    remainder = N % 1000
    if remainder:
        print(1000 - remainder)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

t=1
# t=int(input())
for _ in range(t):
    n=L()[0]
    if n%1000==0:
        print(0)
        exit()

    print(1000-n%1000)

Submission status: Accepted

Solution code:
# coding: utf-8
N=int(input())
#A,B=map(int, input().split())
#List=list(map(int, input().split()))
List=[1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in range(10):
    if List[i]-N >= 0:
        print(List[i]-N)
        quit()

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])
    

    return (n, )


def solve(n):

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

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
# a = []
# for i in range(n):
#     a.append(int(input()))

import math

ans = math.ceil(n / 1000) * 1000 - n

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

# Author : raj1307 - Raj Singh
# Date   : 05.07.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li():  return list(mi())

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : # Check Prime Number or not 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True



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




def main():
    


    #for _ in range(ii()):



    n=ii()

    r=n%1000

    r=(1000-r)%1000


    print(r)


















    








# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

        ans = 0

        for i in range(10):
                if i*1000 < N and N <= (i+1)*1000:
                        ans = (i+1)*1000-N

        return ans

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
money = int(input())
while money >= 1000:
    money -= 1000
if money == 0:
    print(money)
else:
    print(1000 - money)

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

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

ans = -((-N / 1000)//1)*1000
print(int(ans - N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = (10000 - N) % 1000

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()

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

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

if result > 0:
    print(1000 - result)
else:
    print(result)

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:
def solution(N):
    if N % 1000 == 0: return 0
    return 1000 - (N % 1000)

if __name__ == "__main__":
    N = int(input())
    print(solution(N))

Submission status: Accepted

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

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
n = I()
ans = 1000 * (n // 1000 + 1) - n
if n % 1000 == 0:
    ans = 0
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

n = math.ceil(N/1000)

ans = n*1000 - N

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
n_ = n
count = 0
while True:
    n_ = n_ - 1000
    count += 1
    if n_ <= 0:
        break

print(1000*count - n)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    print(ceil(N/1000)*1000-N)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans=1000-(N%1000)
if ans==1000:
    ans=0
print("{}".format(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 100000
for i in range(1, 11):
    if i * 1000 - N >= 0:
        ans = i * 1000 - N
        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:
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:
  print(0)
else:
  print(1000 - n%1000)

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())
place = -1
for i in range(0,11):
  if N <= 1000 * i and place == -1:
    place = 1000 * i - N
print(place)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

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

if __name__ == '__main__':
    main()

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:
  print(((N//1000)+1)*1000-N)

Submission status: Accepted

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

print( (d*1000-n)%1000)

Submission status: Accepted

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

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())
a,b = divmod(n,1000)
if b == 0:
    print(0)
else:

    print(1000-b)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

a=N%1000
result= 1000-a if a>0 else 0
print(result)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
a = int(input())

b = a % 1000

if b == 0:
  c = 0
else:
  c = 1000 - b

print(c)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

s = 1000 - n % 1000
print(s)

Submission status: Accepted

Solution code:
n = int(input())

a = n //1000
b = n % 1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

while ans < N:
    ans += 1000

print(ans-N)

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

main()

Submission status: Accepted

Solution code:
n = int(input())
a = 1
while True:
    if a * 1000 >= n:
        print(a * 1000 - n)
        quit()
    a += 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())
if n % 1000 == 0 :
  result = 0
else:
  result = 1000 - (n % 1000)
print(result)

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

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

print(1000*a - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = 1000
while True:
  if a >= n:
    answer = a - n
    break
  else:
    a += 1000
    
print(answer)

Submission status: Accepted

Solution code:
#<ABC173>
#<A>
N = int(input())
i = 1
while True:
    if 1000 * i >= N:
        print(1000 * i - N)
        break
    i += 1

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
val = 0
while val<n:
    val += 1000
print(val-n)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(1000 - N % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
n = 1000
print(int((N+n-1)/n)*n-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:
#!/usr/bin/env python3
import sys


def solve(N: int):
    print((1000 - N )% 1000)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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