Problem:


Score : 100 points

Problem Statement

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

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

Assume we use the minimum number of bills required.

Constraints

1 \leq N \leq 10000

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

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

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.



Sample input:
1900


Sample output:
100

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
for en in range(1000, 10001, 1000):
    if en >= N:
        exit(en - N)

Submission status: Accepted

Solution code:
out = 0
r = 0
num = int(input())

if(num%1000 == 0): out=0
else:
	r = num%1000
	out = abs(1000-r)

print(out)

Submission status: Accepted

Solution code:
n=int(input())


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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a = input()
b = int(a)
c = 1000
if len(a) < 4:
  print(c-b)
else:
  if a[-4] != '0':
    b = int(a[-3:])
    if b == 0:
      print(int(0))
    else:
      print(c-b)
  elif a[-3] != '0':
    b = int(a[-2:])
    print(c-b)
  elif a[-2] != '0':
    b = int(a[-1:])
    print(c-b)
  else:
    print(int(0))

Submission status: Accepted

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

Submission status: Accepted

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

s, f = math.modf(i/1000)
if s != 0.0:
    f += 1
v = int((f) * 1000) - i
if v >= 1000:
    print(2000 - v)
else:
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
o = n + 1000 #1500
o = o // 1000 #1
o = o * 1000 #1000

if n % 1000 == 0:
    print(o - n -1000)
else:
    print(o - 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:
from math import ceil

n=int(input())
print(ceil(n/1000)*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:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 20:25:04 2020

@author: KevinLU
"""
money = int(input())

a  = money % 1000
if a > 0:
    change = 1000 - a
else:
    change = 0
print(change)

Submission status: Accepted

Solution code:
import math
def solve(n):
    rou = math.ceil(n / 1000);
    rou = rou * 1000
    if(rou == n):
        return 0
    else:
        return rou - n;

print(solve(int(input())))

Submission status: Accepted

Solution code:
N = int(input())

while N > 1000:
    N = N - 1000

M = 1000 - N
print(M)

Submission status: Accepted

Solution code:
N = int(input())

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

print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t=int(input())
m=0
while 1000*m<t:
    m=m+1
c=1000*m-t
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

M = str(N)

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

elif N <= 9999 and N > 1000:
    print(1000 - int(M[1:4]))

else:
    print(1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
left = 0
change = 0
if n >= 1 and n <= 10000:
    left = n % 1000
    change = 1000 - left
    if change == 1000:
        print(0)
    else:
        print(change)
else:
    print()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	for i in range(100000):
		tmp = i * 1000
		ans = tmp-N
		if ans >= 0:
			print(ans)
			sys.exit()

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
n = int(input())

print((10000-n)%1000)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 1
while cnt*1000<N:
  cnt += 1
print(cnt*1000-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())

print(1000*(-(-n//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:
from sys import exit
#import copy
#import numpy as np
#from collections import deque

n, = map(int, input().split())


while n > 1000:
    n -= 1000

print(1000-n)

Submission status: Accepted

Solution code:
a = input()
a= int(a)

if 1<= a < 1000:
    print(1000 - a)
if 1000 < a < 2000:
    print(2000 - a)
if 2000 < a < 3000:
    print(3000 - a)
if 3000 < a < 4000:
    print(4000 - a)
if 4000< a < 5000:
    print(5000 - a)
if 5000< a < 6000:
    print(6000 - a)
if 6000< a < 7000:
    print(7000 - a)
if 7000 < a < 8000:
    print(8000 - a)
if 8000 < a < 9000:
    print(9000 - a)
if 9000 < a <10000:
    print(10000 - a)
if a == 1000:
    print(0)
if a == 2000:
    print(0)
if a == 3000:
    print(0)
if a == 4000:
    print(0)
if a == 5000:
    print(0)
if a == 6000:
    print(0)
if a == 7000:
    print(0)
if a == 8000:
    print(0)
if a == 9000:
    print(0)
if a == 10000:
    print(0)

# (物の値段/入力)a + （おつり）N = 1000?
#Nは整数だから　print(おつり)
#　N　＝　1000? - a

#input 1900  print 100 (2000)
# input 1525 print 475 (2000)
# input 2500 print 500 (3000)

Submission status: Accepted

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

Submission status: Accepted

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