Problem:


Score : 100 points

Problem Statement

We will buy a product for N yen (the currency of Japan) at a shop.

If we use only 1000-yen bills to pay the price, how much change will we receive?

Assume we use the minimum number of bills required.

Constraints

1 \leq N \leq 10000

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

We will use two 1000-yen bills to pay the price and receive 100 yen in change.

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.



Sample input:
1900


Sample output:
100

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
N = int(input())
N = str(N)

if len(N) == 2:
    b = int(N[-2])
    c = int(N[-1])
    x = 10*b + c
elif len(N) == 1:
    c = int(N[-1])
    x = c
else:
    a = int(N[-3])
    b = int(N[-2])
    c = int(N[-1])
    x = 100*a + 10*b + c
ans = 1000 - x
if ans == 1000:
    ans = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

n = N
while n > 0:
    n -= 1000
    
print(abs(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:
str = input()
a = int(str)
c = a % 1000
if c == 0:
    c = 1000
print(1000 - c)

Submission status: Accepted

Solution code:
N = int(input())

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

else:
    N = 1000 - N

print(N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
import sys
if n<=1000:
    print(1000-n)
    sys.exit()
if n%1000==0:
    print(0)
    sys.exit()
a=n//1000
print((a+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())
if 1000- N%1000 == 1000:
    print(0)
else:
    print(1000- N%1000)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

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

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

Submission status: Accepted

Solution code:
n = int(input())
i = 0
m = n
while (m > 0):
    m = m - 1000
    i = i + 1

print(i*1000 - n)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_yen = int(input())
unit_yen = 1000

required_bill = int(float(input_yen)/unit_yen + (float(input_yen) % unit_yen > 0)) * unit_yen
print(required_bill - input_yen)

Submission status: Accepted

Solution code:
n = int(input())
if n%1000 == 0:
  print(0)
elif n < 1000:
  print(1000-n)
else:
  while(n > 1000):
    n = n%1000
    if n < 1000:
      print(1000 - n)
      break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d,q = divmod(n,1000)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    N=int(sys.stdin.readline())
    if N%1000:
        print(1000-N%1000)
    else:
        print(0)

        
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
number = float(input())
n=number/1000
for step in range(1,11):
  if step>=n:
    i=step
    break
given = i*1000
change=given-number
print(int(change))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)

S = 1000 # satsu

def 関数(n):
    res = n % S
    if res == 0:
        return res
    else: 
        res = S - res
        return res

def çözmek():
    N = int(input())
    res = []
    res.append(関数(N))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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




if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())


def main():
    ans = (1000 - (N % 1000)) % 1000
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


A = N%1000

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()

st = str(a)


if st[-3:] == "000":
  print(0)


else:
  z = st[-3:]
  print(1000 - int(z))

Submission status: Accepted

Solution code:
n = int(input())

d = n//1000

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

Submission status: Accepted

Solution code:
def Next(): return input()
def NextInt(): return float(Next())


N = round(NextInt()*0.0010, 3)
import math
ans = math.ceil(N)
print(int(ans*1000-N*1000))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    x, mod = divmod(n, 1000)
    if mod:
        x = (x +1)*1000
    else:
        x = x * 1000
    print(x - n)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input()) 

while N > 0:
  N = N - 1000

if N < 0:
  N = N * -1

print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
tickets = 1

while True:
  sum = 1000 * tickets
  if n <= sum:
    print(sum - n)
    break
  tickets = tickets + 1

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
# sys.setrecursionlimit(1000000)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
# A = [LI() for _ in range(N)]

l = len(str(N))

if l <= 3:
    a = 1000 - N
elif N % 1000 == 0:
    a = 0
else:
    a = 1000 - (N % 1000) 

print(a)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
price = int(input())
count=1
cal=price
while cal > 1000:
        cal=cal-1000
        count=count+1
print(1000*count-price)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# 金額の特定
for i in range(11):
    Budge = i * 1000
    if Budge >= a:
        print(Budge - a)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = N // 1000
b = N % 1000

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

Submission status: Accepted

Solution code:
num = int(input()) #ここで標準入力
i = 0

while True:
    ans = 1000*i - num
    i+=1
    if ans >= 0:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
a = int(input())

ans = 1000 - (a % 1000)

if ans == 1000:
    ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

A = (int(N[-3:]) - 1000)*-1

if A == 1000:
 A = 0

print(A)

Submission status: Accepted

Solution code:
n = int(input())
a = n%1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = []

for i in range(0,11):
  if (1000 * i) - N  >= 0:
    ans.append((1000 * i) - N )
    
print(min(ans))

Submission status: Accepted

Solution code:
def main():
  N = input()
  if int(N)%1000==0:
    print("0")
    return
  if len(N)<4:
    print(1000 - int(N))
  else:
    print(1000 - int(N[len(N)-3:]))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

q = ceil(n/1000)

print(1000*q - 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())

ans = 0
for i in range(1, 100000):
    
    ans += 1000
    if ans >= n:
        print(ans - n)
        exit()

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

Submission status: Accepted

Solution code:
n = int(input())

if n >= 1000:
    n = int(str(n)[1:])

if n > 0:
    ans = 1000 - n
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
S = int(input())
ans=0
ans =int(S/1000)

if S%1000>0:
    ans+=1
otsuri=ans*1000-S
print(otsuri)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

while N > 0:
    N -= 1000

print(abs(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    if n % 1000 == 0:
        print('0')
    else:
        print((n // 1000 + 1) * 1000 - n)
    return 0

if __name__ == "__main__":
    main()

Submission status: Accepted

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

flag = True
num = 1
while(flag):
    if(num * 1000 < N):
        num += 1
    else:
        flag = False

print(num * 1000 - N)

Submission status: Accepted

Solution code:
n = int(input())
amari = (n%1000)

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    num = int(input())

    while True:
      new_num = num - 1000
      if new_num <= 0:
        ans = new_num * -1
        break
      num = new_num
    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())
otsuri = 1000-n%1000
if otsuri == 1000:
  print(0)
  
else:
  print(otsuri)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(0,10001,1000):
  if (i-N) > 0:
    print(i-N)
    break
  elif i == N:
    print(0)
    break
  else:
    pass

Submission status: Accepted

Solution code:
import sys
import math

price = int(sys.stdin.readline().strip())

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

Submission status: Accepted

Solution code:
N = input()

if len(N) <= 2:
    print(1000 - int(N)) 
    
else:
    N_1 = N[-3] + N[-2] + N[-1]
    if N_1 == "000":
        print(0)
    else:
        print(1000-int(N_1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

walet = 1000

pay = int(input())

charge = 0

for i in range(10):
  charge = pay - walet
  if charge <= 0:
    break
  else:
    walet += 1000

print(abs(charge))

Submission status: Accepted

Solution code:
import math
def main():
    N = int(input().rstrip())
    use = math.ceil(N/1000)
    print(1000*use - N)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
#print(n)

x = n[-3:]
#print(x)

if x == '000':
    x = 1000


print(1000-int(x))

Submission status: Accepted

Solution code:
N = int(input())

cost = 0
while(cost<N):
    cost += 1000

print(cost-N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

remain =  math.ceil(N / 1000)

print((remain)*1000 -N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a=int(input())
if a%1000==0:
    print(0)
else:
    b=a//1000
    c=a-b*1000
    d=1000-c
    print(d)

Submission status: Accepted

Solution code:
s = str(input())
if len(s) >= 3:
    n = [s[-3], s[-2], s[-1]]
if len(s) == 2:
    n = [s[-2], s[-1]]
if len(s) == 1:
    n = [s[0]]
n = ''.join(n)
n = int(n)
if n == 0:
    print(0)
else:
    print(1000 - n)

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    if n % 1000 == 0:
        print(0)
    else:
        res = n % 1000
        print(1000 - res)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
price = int(input())
mult, res = divmod(price, 1000)
print(0 if res == 0 else 1000 - res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
if n % 1000 == 0:
    print(0)
    exit()
for i in range(1, 10001):
    if(0 < 1000*i-n):
        print(1000*i-n)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
mn = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
for i in range(len(mn)):
    if mn[i] >= N:
        print(mn[i] - N)
        exit()

Submission status: Accepted

Solution code:
from math import gcd, sqrt, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
i=0
for i in range(0,10001,1000):
    if i >= N:
        print(i-N)
        sys.exit()

Submission status: Accepted

Solution code:
# cook your dish here
n=int(input())
if n%1000==0 :
    print(0)
else :
    print(1000-(n%1000))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = N // 1000
b = N % 1000

if b == 0:
    ans = 0
else:
    ans = (a + 1) * 1000 - N

print(ans)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

change = 0

while N > 1000:
    N -= 1000

change = 1000 - N

print(change)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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