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:
A=int(input())
A -= 1000*(A//1000)
if A!=0:
    print(1000-A)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
#a = list(map(int, input().split()))
#x,y = map(int, input().split())

#x,n = map(int, input().split())
#p = input().split()
#for i in range(len(p)):
#    p[i] = int(p[i])
money = 0
while True:
    if money >= a:
        print(money-a)
        break
    else :
        money += 1000

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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 math


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

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    print(0 if n % 1000 == 0 else 1000 - n % 1000)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    a=N//1000
    b=N%1000
    if b==0:
        print(0)
    else:
        print((a+1)*1000-N)





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
res = n // 1000
print((res+1) * 1000 - n if n % 1000 != 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#for _ in range(int(input())):
n=int(input())
    #n,m=[int(x) for x in input().split()]
x=0
while(x<n):
    x+=1000
print(abs(n-x))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

    r = 1000 - N % 1000

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]


def solve(N):
    if N%1000 == 0:
        return 0
    num = N//1000
    return (num+1)*1000-N
N = rri()
print(solve(N))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

ans = 1000 - (N - N//1000*1000)

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
a = int(input())
if a % 1000 == 0:
    print(0)
else:
    b = a // 1000 + 1
    print(b*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:
#!/usr/bin/env python3
import sys


def solve(N: int):
    rest = N % 1000
    if rest != 0:
        print(1000 - rest)
    else: 
        print(rest)
    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:
import sys
#sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
  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:
    x = n / 1000
else:
    x = n // 1000 + 1
print(int(1000 * x - n))

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

ans = N % 1000
ans = 1000 - ans if ans != 0 else 0

print(ans)

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
for i in range(1,11):
    if 1000*i >= N:
        print(1000*i-N)
        sys.exit()

Submission status: Accepted

Solution code:
def main():
    N = input_ints()

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


def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


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


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

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


for i in range(10000):
    if (i+1)  * 1000 - n >= 0:
        print((i+1) *1000 - n)
        break

Submission status: Accepted

Solution code:
#Problem A
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def solve(n):
    k = n // 1000
    if n % 1000 > 0:
        k += 1
    return k * 1000 - n


def main():
    n = ri()
    wi(solve(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline().strip())
print(((N - 1) // 1000 + 1) * 1000 - N)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    print((1000-ii()%1000)%1000)

main()

Submission status: Accepted

Solution code:
# abc173_a.py
N = int(input())
while N>0:
    N-=1000
print(-1*N)

Submission status: Accepted

Solution code:
div,mod = divmod(int(input()), 1000)
print((1000 - mod) % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math,os
from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
# from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
# from decimal import Decimal
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 998244353

N=int(data())
out((1000-N%1000)%1000)

Submission status: Accepted

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

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());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:
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


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

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

    return


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

Submission status: Accepted

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

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:
"""everything has a cost!"""

from math import *
import random, functools, collections, sys

__author__ = 'p7x'


# sys.stdin = open('in.txt', 'r')
# sys.stdout = open('out.txt', 'w')
# sys.stderr = open('err.txt', 'w')


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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    if N%1000 == 0:
        return 0
    return 1000-N%1000


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
N = int(input())

for num in range(12):
  if num*1000 >= N:
    print(num*1000-N)
    exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()

    # 出力
    print(int(ceil(N/1000))*1000-N)

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

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:
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

n = n%1000

ans = 1000-n

if ans==1000:
	ans = 0

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
print((10000 - n) % 1000)

Submission status: Accepted

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

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(a)
else:
  print(1000-a)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

  ans = 1000 - n % 1000

  print(0 if ans >= 1000 else ans)


main()

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  #startline-------------------------------------------
    n = int(input())
    print(1000-n%1000 if n % 1000 != 0 else 0)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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


def solve(N: int):
    from math import ceil
    return int(ceil(N / 1000) * 1000) - N


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

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())
a = (n-1)//1000
print((a+1)*1000-n)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())  #数値入力 「N」だけの入力のとき

n2=n%1000

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

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N):
    x = N % 1000
    if x == 0:
        return 0
    else:
        return 1000 - x



N = int(input())
print(calc(N))

Submission status: Accepted

Solution code:
N = int(input())

print((1000 - N) % 1000)

Submission status: Accepted

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
yens = int(input())

if yens % 1000 > 0:
    print(1000 - yens % 1000)
else:
    print(yens % 1000)

Submission status: Accepted

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

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

    

if __name__ == '__main__':
    main()