Problem:


Score : 100 points

Problem Statement

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

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

Assume we use the minimum number of bills required.

Constraints

1 \leq N \leq 10000

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

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

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.



Sample input:
1900


Sample output:
100

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(chn)

Submission status: Accepted

Solution code:
import math
n = int(input())
m =  math.ceil(n/1000)

print((m*1000) - n)

Submission status: Accepted

Solution code:
print((10000-int(input()))%1000);

Submission status: Accepted

Solution code:
import math
n = int(input())
ans  =10**6
for i in range(1,math.ceil(n/1000)+1):
    x = n-(i*1000)
    if x<=0:
        ans = min(ans,abs(x))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
for x in range(100):
    if n <= (x+1)*1000:
        a = ((x+1)*1000)-n
        break
print(a)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=1000
i=0
p=a
while(p<n):
    i += 1
    p=a*i
print(abs(p-n))

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
sum = int(input())
pay = 0
while sum > pay:
    pay += 1000
print(pay - sum)

Submission status: Accepted

Solution code:
n = int(input())
#n,k = map(int,input().split())
#a = list(map(int,input().split()))
#mod = pow(10,9) + 7
if(n == 10000):
    print(0)
elif(n%1000 == 0):
    print(0)
else:  
    print(1000-n%1000)
'''
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
print(a)
'''

Submission status: Accepted

Solution code:
N = int(input())

okane = 1000*(int(N/1000)+1)

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

syousuu = n / 1000
sen = math.ceil(syousuu)
print(sen * 1000 - n)

Submission status: Accepted

Solution code:
n = int(input())

m = n % 1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
x=None

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

x=1000-N

print(x)

Submission status: Accepted

Solution code:
N=int(input())
if 1<=N<1000:
    print(1000-N)
else:
    if N%1000==0:
        print(0)
    else:
        M=str(N)
        print((int(M[0])+1)*1000-N)

Submission status: Accepted

Solution code:
import sys

def main():

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

senen = math.ceil(nedan / 1000) * 1000

print(senen - nedan)

Submission status: Accepted

Solution code:
n=int(input())

if n>0 and n<1001:
    x=1000-n
if n>1000 and n<2001:
    x=2000-n
if n>2000 and n<3001:
    x=3000-n
if n>3000 and n<4001:
    x=4000-n
if n>4000 and n<5001:
    x=5000-n
if n>5000 and n<6001:
    x=6000-n
if n>6000 and n<7001:
    x=7000-n
if n>7000 and n<8001:
    x=8000-n
if n>8000 and n<9001:
    x=9000-n
if n>9000 and n<10001:
    x=10000-n

print(x)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    if N < 1000:
        print(1000 - N)
        return
    N = str(N)
    N = N[-3] + N[-2] + N[-1]
    N = int(N)
    if N == 0:
        print(0)
        return
    
    print(1000 - N)
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
if int(N) >= 1000: 
    if int(''.join(N[-3:])) == 000:
        print(0)
    else:
        print(1000 - int(''.join(N[-3:])))

else:
    print(1000 - int(N))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

c = n % 1000

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

print(s)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

while True:
    if N >= 1000:
        N -= 1000
    else:
        break

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

Submission status: Accepted

Solution code:
d = int(input())
a = d % 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())

k = N // 1000
m = N % 1000

if m == 0:
    ans = 0
else:
    ans = 1000 * (k + 1) - N

print(ans)

Submission status: Accepted

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

if mod == 0:
  print(0)
else:
  b = mod -1000
  c = int(abs(b))
 
  print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys;input = lambda : sys.stdin.readline()
n = int(input())
x=(n//1000)*1000 if n%1000==0 else (((n//1000)+1)*1000)
print(x-n)

Submission status: Accepted

Solution code:
p = int(input())

count = 0
while p > count:
    count += 1000
print(count - p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
print(0 if n[::-1][:3]=='000' else 1000-int(n[::-1][:3][::-1]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

money = 1000
while money < N:
    money += 1000

print(money - N)

Submission status: Accepted

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

k = abs(N)
print(k)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

A = a - N

print(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def INT():
    return int(input())

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
t = int(input())

a = t / 1000

if int(a) == a:
  a = int(a)
elif a>int(a):
  a = int(a) + 1
b = a * 1000

print(b-t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

x = n//1000
y = 1000 * (x+1) - n
if y != 1000:
  print(y)
else:
  print('0')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
for i in range(math.floor(N/1000)):
  N -= 1000
if N != 0:
  print(1000 - N)
else:
  print(0)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print((i+1)*1000-N)

Submission status: Accepted

Solution code:
pay = int(input())
answer = 1000 - pay
while answer < 0:
  answer += 1000
print(answer)

Submission status: Accepted

Solution code:
from math import log10

n = int(input())

i = 1

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

    i += 1

Submission status: Accepted

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
import numpy as np
hairu = int(input())

turi = 1000 - hairu%1000

print(turi%1000)

Submission status: Accepted

Solution code:
N = int(input())
if N >= 1000:
    M = str(N)
    X = M[1:]
    O = int(X)
    if O == 0:
        print(0)
    else:
        print(1000-O)
else:
    O = int(N)
    print(1000-O)

Submission status: Accepted

Solution code:
n = (input())
x, y = divmod(int(n), 1000)
if y == 0:
    print(0)
else:
    ans = (1000 * (x + 1)) - int(n)
    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:
    print(1000-n)
    exit()
while(True):
    n -= 1000
    if n <= 1000:
        break
print(1000-n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = n % 1000

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

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:
s = int(input())
r = 1000
for i in range(11):
   t = r*i - s
   if t >= 0:
       break
print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nn = int(input())

pp = (nn + 999) // 1000 * 1000

print(pp - nn)

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline().rstrip("\n"))
n_r = n % 1000
if n_r == 0:
    print(0)
else:
    print(1000-n_r)

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

Submission status: Accepted

Solution code:
#A - Payment
N = int(input())
a = N % 1000
if N < 1000 :
    ans = 1000- a

elif a == 0:
    ans = 0
elif a < 500:
    ans = 1000 - a

else:
    ans = 1000-a

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

print(-n%1000)

Submission status: Accepted

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

    print(1000-a%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N= int(input())

S=N%1000

if S !=0:
    print(abs(S-1000))
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
c = n // 1000
c_2 = n % 1000
if c_2 != 0:
	c += 1

ans = (c*1000)-n

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(((-(-N//1000))*1000)-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

 
N = int(input())



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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
ans=0
while 1:
    if n%1000==0:
        print(ans)
        break
    n+=1
    ans+=1

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1,11):
    money = i * 1000
    if money < N:
        continue
    else:
        print(money-N)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

    s = A % 1000

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





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

while 1 == 1:
    if n > 0:
        n = n - 1000
    else:
        print(-n)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=eval(input())
f=(n//1000)
o=n/1000
if o==f:
  print(0)
else:
  p=(f+1)*1000-n
  print(p)

Submission status: Accepted

Solution code:
import math
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n
 
print(val)

Submission status: Accepted

Solution code:
N = int(input())

a= N % 1000
oturi=1000-a

if a == 0:
    oturi =0
    print(oturi)

else:
    oturi=1000-a
    print(oturi)

Submission status: Accepted

Solution code:
i = input().split()
i=int(i[0])
if i<=1000:
  print(1000-i)
else:
  k=1000-i%1000
  if k==1000:
    print(0)
  else:
    print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
value = int(input().strip())

exc = value % 1000

print(1000-exc if exc > 0 else 0)

Submission status: Accepted

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

    return (1000 - (N % 1000)) % 1000

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

i = 0
a = n

while a > 0:
    a -= 1000
    i += 1

print(i*1000 - n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict
 
# read line as a string
# strr = input()
 
# read line as an integer
k = int(input())
 
# read one line and parse each word as a string
# lst = input().split()
 
# read one line and parse each word as an integer
# arr = list(map(int,input().split()))
 
if k%1000 == 0:
    print(0)
else:
    print(1000 - k%1000)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = n // 1000

rem = n - 1000 * a
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())

for i in range(1, 11):
    change = i * 1000 - N
    if 0 <= change < 1000:
        ans = change
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A = N % 1000

if A > 0:
      B=1000-A
      print(B)
else:
      print(A)

Submission status: Accepted

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

    ans = 1000 - x
else:
    ans = 1000 - N

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
if n%1000==0:
  print(0)
else:
  ans=n//1000
  print((1+ans)*1000-n)

Submission status: Accepted

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

if n%1000==0:
  print(0)
else:
  print(int(math.ceil(n/1000.0)) * 1000-n)

Submission status: Accepted

Solution code:
n = int(input())

x = 0
while True:
    if (n + x) % 1000 == 0:
        break
    x += 1

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = []
for i in range(1,12):
    ans.append(((i*1000)-N))
print(min([i for i in ans if i >= 0]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n=int(input())
amari=int(n%1000)
maisuu=int(n/1000)
if amari==0: 
  print(0)
else:
  oturi=(maisuu+1)*1000-n
  print(oturi)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

devide = int(N/1000)

if N%1000==0:
    print(0)
elif devide>0:
    print((devide+1)*1000-N)
else:
    print(1000-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,11):
  if n <= i*1000:
    a=i
    break

print(a*1000-n)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
import sys

def getA(n):
    if 0 == n:
        return 0
    return 1000 - n

data = sys.stdin.readlines()
for line in data:
    if not "" == line.rstrip():
        v = '000' + line.rstrip()
        print(getA(int(v[-3:])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans =  N // 1000
if N % 1000 != 0:
    ans+=1

print(ans*1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

sur = N % 1000

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int):
    if N%1000==0:
        print(0)
    else:
        print(1000-(N%1000))
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
def Main(N):
    d, m  = divmod(N, 1000)
    if m == 0:
        return 0
    else:
        return (d+1)*1000 - N

print(Main(N))

Submission status: Accepted

Solution code:
N= int(input())

if N < 1000:
    print(1000-N)
    exit()
else:
    p = N//1000
    mod = N % 1000
    if mod != 0:
        print(1000-mod)
    else:
        print(0)

Submission status: Accepted

Solution code:
n=int(input())
if n < 1000:
  print(1000-n)
else:
  if n % 1000 == 0:
    print(0)
  else:
    print(((int(str(n)[0])+1)*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:
def main():
    N = int(input())
    answer = solve(N)
    print(answer)


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def resolve(in_):
    n = int(in_.read())

    return (1000 - n % 1000) % 1000


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


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:
#x, y = map(int, input().split())
n = int(input())
a = 0
while(a < n):
  a += 1000
print(a-n)

Submission status: Accepted

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