AtCoder Beginner Contest 173 - Payment

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

-----Sample Output-----
100

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

Difficulty: EASY

Starter code:

Solutions:
int = int(input())
print((1000 - int % 1000) % 1000)


n = int(input())
k = n
while k > 0:
	k -= 1000
print(-k)


import math
n = int(input())
print((1000 - n % 1000) % 1000)


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


s = int(input())
m = 1000
print(m * int((s + (m - 1)) / m) - s)


N = int(input())
a = 0
while a < N:
	a += 1000
print(a - N)


n = int(input())
m = 0 - -n // 1000
print(1000 * m - n)


a = int(input())
b = 0
while b < a:
	b += 1000
print(b - a)


N = int(input())
print(1000 * -(-N // 1000) - N)


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


x = int(input())
print((1000 - x % 1000) % 1000)


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


print((10000 - int(input())) % 1000)


print((11000 - int(input())) % 1000)


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


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


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


n = int(input())
res = 1000 - n % 1000
print(res % 1000)


a = int(input())
print(-a % 1000)


N = int(input())
ans = -(-N // 1000) * 1000 - N
print(ans)


n = int(input())
print(999 - (n - 1) % 1000)


s = int(input())
for i in range(1, 11):
	if s <= i * 1000:
		ans = i * 1000 - s
		print(ans)
		break


s = int(input())
print(999 - (s - 1) % 1000)


a = int(input())
print(1000 * bool(a % 1000) - a % 1000)


n = int(input())
x = 1000 - n % 1000
print(x % 1000)


N = int(input())
print((10000 * 1000 - N) % 1000)


n = int(input())
print((1000 - n % 10000) % 1000)


N = int(input())
if N % 1000 == 0:
	print('0')
elif N % 1000 != 0:
	N2 = N // 1000 * 1000 + 1000
	print(N2 - N)


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


N = int(input())
o = (1000 - N % 1000) % 1000
print(o)


N = int(input())
a = 10000 - N
b = a % 1000
print(b)


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


import math

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

def __starting_point():
	main()
__starting_point()


print((100000 - int(input())) % 1000)


x = int(input())
y = (10000 - x) % 1000
print(y)


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


i = int(input())
while i > 0:
	i -= 1000
print(abs(i))


r = int(input()) % 1000
print((1000 - r) % 1000)


n = int(input())
i = 1000
while i < n:
	i += 1000
print(i - n)


X = int(input())
while X > 1000:
	X -= 1000
print(1000 - X)


n = int(input())
y = (n + 999) // 1000
print(y * 1000 - n)


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


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


N = int(input())
print(999 - (N - 1) % 1000)


print(int(str(1000 - int(input()[-3:]))[-3:]))


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


n = int(input())
ans = -n % 1000
print(ans)


n = int(input())
a = (n - 1) // 1000
print((a + 1) * 1000 - n)


from math import ceil
N = int(input())
x = ceil(N / 1000)
print(x * 1000 - N)


N = int(input())
if N % 1000 == 0:
	print(0)
elif N < 1000:
	print(1000 - N)
else:
	c = 1 + int(str(N)[0:len(str(N)) - 3])
	print(1000 * c - N)


N = int(input())
paid = (N + 999) // 1000
change = 1000 * paid - N
print(change)


m = int(input())
if 1000 < m:
	if m % 1000 == 0:
		print(0)
	else:
		mai = m // 1000
		ryo = (mai + 1) * 1000
		print(ryo - m)
else:
	print(1000 - m)


a = int(input())
b = (1000 - a % 1000) % 1000
print(b)


y = 1000
print((y - int(input()) % y) % y)


a = (int(input()) - 1) % 1000
print(999 - a)


a = int(input())
print((a // 1000 + min(a % 1000, 1)) * 1000 - a)


N = int(input())
R = (1000 - N % 1000) % 1000
print(R)


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


a = int(input())
while a > 0:
	a -= 1000
print(abs(a))


N = int(input())
a = N % 1000
print(abs(1000 - a) % 1000)


price = int(input())
for n in range(1, 10000):
	payment = n * 1000
	if payment >= price:
		print(payment - price)
		return


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


a = int(input())
i = 0
while i < a:
	i = i + 1000
print(i - a)


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


n = int(input()) % 1000
if n:
	n = 1000 - n
print(n)


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


N = input()
N = int(N)
for X in range(0, 11):
	a = N - 1000 * X
	if a <= 0:
		break
C = 1000 * X - N
print(C)


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


a = int(input())
print((500000 - a) % 1000)


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


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


print((10 ** 7 - int(input())) % 1000)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
n = int(input())
tmp = 0
res = 0
res = 1000 * ceil(n / 1000) - n
print(res)


N = int(input())
M = (N + 999) // 1000
print(M * 1000 - N)


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


N = int(input())
if N % 1000 == 0:
	print('0')
elif N >= 1 and N < 1000:
	print(1000 - N % 1000)
elif N >= 1000 and N <= 10000:
	print(1000 - N % 1000)


N = int(input())
a = int((N + 1000 - 1) / 1000) * 1000
print(a - N)


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


N = int(input())
k = (N + 1000 - 1) // 1000
print(1000 * k - N)


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


N = input()
sen_yen_sheet = -(-int(N) // 1000)
money = 1000 * sen_yen_sheet
change = money - int(N)
print(change)


a = int(input())
n = 0
while n < a:
	n += 1000
print(n - a)


N = int(input())
print(f'{-N % 1000}')


N = int(input())
note = 1000
reminder = str(N / note)[-1]
if int(reminder) == 0:
	result = 0
else:
	reminder = N // note + 1
	result = int(reminder * note) - N
print(result)


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


n = int(input())
print((10 ** 10 - n) % 1000)


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


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


n = int(input())
print(-(-n // 10 ** 3) * 10 ** 3 - n)


n = int(input())
b = (1000 - n % 1000) % 1000
print(b)


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


n = int(input().rstrip())
print((1000 - n) % 1000)


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


print(abs(-int(input()) % 1000))


from math import ceil
buy = int(input())
pay = ceil(buy / 1000) * 1000
oturi = pay - buy
print(oturi)


n = int(input())
x = 0
while True:
	x += 1
	if n <= x * 1000:
		print(x * 1000 - n)
		return


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


a = int(input())
print((10000 - a) % 1000)


s = int(input())
print((1000 - s % 1000) % 1000)


N = int(input())
x = (1000 - N % 1000) % 1000
print(x)


N = int(input())
p = (int((N - 1) / 1000) + 1) * 1000
print(p - N)


print(int(input()) * -1 % 1000)


n = int(input())
if n < 1000:
	print(1000 - n)
elif n % 1000 == 0:
	print(0)
else:
	x = n // 1000
	print(1000 * (x + 1) - n)


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


N = int(input())
if N % 1000 == 0:
	print(0)
else:
	n = str(N)
	print(1000 - int(n[-3:]))


N = int(input())
k = (N + 999) // 1000
print(k * 1000 - N)


n = int(input())
print(abs((1000 - n) % 1000))


N = int(input())
print(1000 * (N % 1000 != 0) - N % 1000)


N = int(input())
A = (N + 1000 - 1) // 1000 * 1000 - N
print(A)


a = int(input())
print(str((1000 - a % 1000) % 1000))


n = int(input())
while n > 0:
	n -= 1000
print(abs(n))


m = int(input())
print((1000 - m % 1000) % 1000)


N = int(input())
X = (N - 1) // 1000 + 1
print(1000 * X - N)


a = int(input())
sa = str(a)
index1 = int(sa[0]) * 1000 + 1000
if a % 1000 == 0:
	print(0)
elif a < 1000:
	print(1000 - a)
elif a > 1000:
	a = index1 - a
	print(a)


X = int(input())
X %= 1000
print((1000 - X) % 1000)


n = int(input())
p = 0
while p < n:
	p += 1000
print(format(p - n))


N = int(input())
C = 10000 - N
Ch = C % 1000
print(Ch)


k = int(input())
print((1000 - k % 1000) % 1000)


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


n = int(input())
f = (n + 1000 - 1) // 1000
print(f * 1000 - n)


n = int(input())
x = 0
while x < n:
	x += 1000
print(x - n)


n = int(input())
r = n % 1000
if r == 0:
	print('0')
else:
	otu = 1000 - r
	print(otu)


N = int(input())
ma = -(-N // 1000)
NN = ma * 1000 - N
print(NN)


n = int(input())
tmp = 10000 - n
s = tmp % 1000
print(s)


n = int(input())
roop = True
x = 0
while roop:
	x += 1
	if 1000 * x >= n:
		roop = False
print(1000 * x - n)


x = int(input())
print((x + 999) // 1000 * 1000 - x)


n = int(input())
answer = -n % 1000
print(answer)


pay = int(input())
while pay > 0:
	pay -= 1000
otu = abs(pay)
print(otu)


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


num = int(input())
x = ''
cnt = 1000
while x != 'pass':
	if cnt >= num:
		x = 'pass'
	else:
		cnt += 1000
print(cnt - num)