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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    N = I()
    ans = inf
    for i in range(1, 11):
        if i * 1000 >= N:
            ans = min(ans, i * 1000 - N)
    print(ans)
main()

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

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

    print(1000*i-n)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

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

Submission status: Accepted

Solution code:
s = int(input())
if s % 1000 == 0:
    print(0)
else:
    print(1000 - s % 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())
# x = map(int,input().split())
if n % 1000 == 0 :
    print(0)
    exit()
print(1000-n%1000)

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

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

if __name__ == "__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>0:
    n-=1000

print(abs(n))

Submission status: Accepted

Solution code:
n = int(input())
p = 1000
while(n > p):
	p += 1000
print(p - 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 sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

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


if __name__ == '__main__':
    resolve()

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:
    a=N//1000
else:
    a=N//1000+1

print(int(a*1000-N))

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    n = (N + 999) // 1000
    print(n * 1000 - N)


main()

Submission status: Accepted

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

    print(1000-n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


print(payment-N)

Submission status: Accepted

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


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 1000 - N
    while ans < 0:
        ans += 1000
    print(ans)


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__=='__main__':
    t=1
    for _ in range(t):
        solve()

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

Submission status: Accepted

Solution code:
import sys
from math import ceil
input=sys.stdin.readline
_lii=lambda :list(map(int, input().strip('\n').split()))
_i=lambda :input().strip('\n')
res=[]
#for _ in range(int(input())):
n=int(input())
print(int(ceil(n/1000))*1000-n)
	#res.append(ans)
#print('\n'.join(map(str, res)))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
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 LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

y=x%1000

if y==0:
  y=1000

print(1000-y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

Solution code:

n=int(input())
kane=-(-n//1000)*1000
print(kane-n)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    tmp = n % 1000
    ans = 1000 - tmp
    if ans == 1000:
        ans = 0
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug

Submission status: Accepted

Solution code:
a = int(input())

b = a% 1000

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

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

print((10000-n) % 1000)

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

Submission status: Accepted

Solution code:
N = int(input())


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

Submission status: Accepted

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

Submission status: Accepted

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

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

input = iter(sys.stdin.read().splitlines()).__next__

sys.setrecursionlimit(10000)

N = int(input())

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

print(res)

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

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

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

Submission status: Accepted

Solution code:
import math

N = int(input())

ans = math.ceil(N / 1000)

print(ans * 1000 - N)

Submission status: Accepted

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

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
n = int(input())

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

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:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
if n%1000==0:
    ans=0
else:
    ans=(n//1000+1)*1000-n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

w = N // 1000
v = N % 1000
if v != 0:
    w += 1

print(w * 1000 - N)

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

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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



if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    k = n // 1000
    if n % 1000:
        k+=1
    print(1000*(k) -n)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

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())
now=1000
for i in range(11):
  if now<n:
    now+=1000
  else:
    print(now-n)
    break

Submission status: Accepted

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

Submission status: Accepted

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

print((1000-int(input())%1000)%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:
#array=map(int,input().split())
N=int(input())
turi=(N//1000)*1000-N
if turi<0: turi+=1000
print(turi)

Submission status: Accepted

Solution code:
import sys

n = int(input())
for i in range(10000):
    if (i * 1000 - n >= 0):
        print(i * 1000 - n)
        sys.exit()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input().strip())

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

Submission status: Accepted

Solution code:
from sys  import stdin,stdout

import bisect
import math
def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
            n=n-1
        else:
            a=(a*a)
            n=n>>1
    return r
    
def solve():
    n=inp()
    a=math.ceil(n/1000)
    print(1000*a-n)




tc=1

for _ in range(tc):
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

sys.setrecursionlimit(10000000)

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

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

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

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


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

    N = ii()
    n = 1
    while True:
        if n * 1000 >= N:
            print((n * 1000) - N)
            exit()
        else:
            n += 1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=input()[-3:]
a=int(a)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import 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 main():
    n = int(input())
    print((1000 - (n % 1000)) % 1000)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

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

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

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


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


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__":
    main()

Submission status: Accepted

Solution code:
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
n = Ii()
a = n%1000
if a == 0:
  print(0)
else:
  print(1000-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    print(math.ceil(n / 1000) * 1000 - n)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    b = [[0] * len(a) for i in range(len(a))]
    for i in range(len(a)): 
        for j in range(len(a)): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
    
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())
p=1000-n%1000
if p==1000:print(0)
else:print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
from math import ceil

ans=ceil(n/1000)*1000
print(ans-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

n = 0
while True:
    if 1000*n - N >= 0:
        print(1000*n - N)
        exit()
    n += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) 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 II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
res = (N//1000)*1000
if N%1000:
    res += 1000
print(res - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n%1000 == 0:
        print(0)
    else:
        print(1000 - (n%1000))

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    p = 1000
    while p < n:
        p += 1000
    print(p - n)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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