AtCoder Beginner Contest 087 - Buying Sweets

You went shopping to buy cakes and donuts with X yen (the currency of Japan).
First, you bought one cake for A yen at a cake shop.
Then, you bought as many donuts as possible for B yen each, at a donut shop.
How much do you have left after shopping?

-----Constraints-----
 - 1 \leq A, B \leq 1 000
 - A + B \leq X \leq 10 000
 - X, A and B are integers.

-----Input-----
Input is given from Standard Input in the following format:
X
A
B

-----Output-----
Print the amount you have left after shopping.

-----Sample Input-----
1234
150
100

-----Sample Output-----
84

You have 1234 - 150 = 1084 yen left after buying a cake.
With this amount, you can buy 10 donuts, after which you have 84 yen left.

Source: atcoder | Difficulty: EASY


Solutions:
x = int(input())
a = int(input())
b = int(input())
print((x - a) % b)


x = int(input())
a = int(input())
b = int(input())
x -= a
while 1:
	x -= b
	if x - b < 0:
		print(x)
		break


(x, a, b) = (int(input()) for i in range(3))
ans = (x - a) % b
print(ans)


(X, A, B) = (int(input()) for T in range(3))
print((X - A) % B)


X = int(input())
A = int(input())
B = int(input())
n = (X - A) // B
print(X - A - B * n)


a = [int(input()) for _ in [0] * 3]
print((a[0] - a[1]) % a[2])


l = [int(input()) for i in range(3)]
print((l[0] - l[1]) % l[2])


import sys
input = sys.stdin.readline
X = int(input())
A = int(input())
B = int(input())
X -= A
print(X - X // B * B)


i = input
(X, A, B) = map(int, [i(), i(), i()])
print((X - A) % B)


(x, a, b) = (int(input()) for i in [0] * 3)
print((x - a) % b)


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


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


(x, a, b) = eval('int(input()),' * 3)
print((x - a) % b)


(x, a, b) = [int(input()) for a in range(3)]
print((x - a) % b)


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


(x, a, b) = map(int, [input() for i in range(3)])
print((x - a) % b)


def p():
	return int(input())
print((p() - p()) % p())


(m, a, b) = map(int, open(0))
print((m - a) % b)


(x, a, b) = [int(input()) for i in '000']
print((x - a) % b)


(a, b, c) = [int(input()) for i in range(3)]
n = a - b
print(n % c)


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


print(int((int(input()) - int(input())) % int(input())))


(X, A, B) = (int(input()) for i in range(3))
X -= A
print(X % B)


i = input
print(eval(i() + '-' + i()) % int(i()))


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


(X, A, B) = map(int, open(0).read().split())
print((X - A) % B)


def main():
	(x, a, b) = (int(input()) for _ in range(3))
	t = x - a
	print(t - b * (t // b))
main()


N = int(input())
A = int(input())
B = int(input())
print((N - A) % B)


with open(0) as f:
	(x, a, b) = map(int, f.read().split())
print(x - a - (x - a) // b * b)


(x, a, b) = map(int, open(0).read().split())
x_ = x - a
print(x_ - x_ // b * b)


(a, b, c) = [int(input()) for _ in range(3)]
print((a - b) % c)


X = int(input())
A = int(input())
B = int(input())
keiki = X - A
donatu = keiki % B
print(donatu)


n = int(input())
m = int(input())
k = int(input())
print((n - m) % k)


(x, a, b) = map(int, open(0))
print(x - a - (x - a) // b * b)


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


(x, a, b) = (int(input()) for i in range(3))
p = x - a
n = p % b
print(n)


f = lambda : int(input())
x = f()
a = f()
b = f()
print((x - a) % b)


X = int(input())
A = int(input())
B = int(input())
keki = X - A
donatu = keki % B
print(donatu)


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


X = int(input())
A = int(input())
B = int(input())
y = X - A
print(y % B)


x = [int(input()) for i in range(3)]
print((x[0] - x[1]) % x[2])


a = [int(input()) for i in range(3)]
b = a[0] - a[1]
sub = b % a[2]
print(sub)


rst = int(input()) - int(input())
print(rst % int(input()))


X = int(input())
A = int(input())
B = int(input())
print(str((X - A) % B))


i = lambda : int(input())
print((i() - i()) % i())


(x, a, b) = map(int, [input() for _ in range(3)])
print((x - a) % b)


x = int(input())
y = int(input())
z = int(input())
print((x - y) % z)


a = int(input())
s = int(input())
d = int(input())
print(a - s - (a - s) // d * d)


(X, A, B) = [int(input()) for x in range(3)]
print((X - A) % B)


(X, A, B) = eval('int(input()),' * 3)
X -= A
print(X % B)


D = [int(input()) for i in range(3)]
print((D[0] - D[1]) % D[2])


X = int(input())
A = int(input())
B = int(input())
if (1 <= A + B and X <= 10000) and (1 <= A and A <= 1000) and (1 <= B and B <= 1000):
	a = X - A
	b = int(a / B)
	print(a - b * B)


L = [int(input()) for _ in range(3)]
print((L[0] - L[1]) % L[2])


X = int(input())
A = int(input())
B = int(input())
balance = X - A
quantity = balance // B
balance -= B * quantity
print(balance)


x = int(input())
a = int(input())
b = int(input())
result = 0
result = (x - a) % b
print(result)


(a, b, c) = list((int(input()) for i in range(3)))
print((a - b) % c)


(X, A, B) = map(int, open(0))
print((X - A) % B)


X = int(input())
A = int(input())
B = int(input())
ans = X - A
ans %= B
print(ans)


x = int(input())
a = int(input())
b = int(input())
x -= a
while x >= 0:
	x -= b
print(x + b)


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


(a, b, c) = map(int, open(0))
print((a - b) % c)


A = int(input())
B = int(input())
C = int(input())
print((A - B) % C)


ins = [int(input()) for i in range(3)]
print((ins[0] - ins[1]) % ins[2])


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '1234\n150\n100'
		output = '84'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '1000\n108\n108'
		output = '28'
		self.assertIO(input, output)

	def test_入力例_3(self):
		input = '579\n123\n456'
		output = '0'
		self.assertIO(input, output)

	def test_入力例_4(self):
		input = '7477\n549\n593'
		output = '405'
		self.assertIO(input, output)

def resolve():
	X = int(input())
	A = int(input())
	B = int(input())
	print((X - A) % B)

def __starting_point():
	resolve()
__starting_point()


x = int(input())
A = int(input())
B = int(input())
ans = (x - A) % B
print(ans)


(a, b, c) = [int(input()) for i in [0] * 3]
print((a - b) % c)


possesion = int(input())
cake = int(input())
donut = int(input())
remain_1 = possesion - cake
remain_2 = remain_1 - remain_1 // donut * donut
print(remain_2)


A = [int(input()) for i in range(3)]
print((A[0] - A[1]) % A[2])


X = int(input())
A = int(input())
B = int(input())
a = (X - A) % B
print(a)


L = [int(input()) for i in range(3)]
print((L[0] - L[1]) % L[2])


XAB = [int(input()) for i in range(3)]
print((XAB[0] - XAB[1]) % XAB[2])


X = int(input())
A = int(input())
B = int(input())
X -= A
Y = X % B
print(Y)


(X, Y, Z) = [int(input()) for i in range(3)]
print((X - Y) % Z)


print(eval(input() + '-' + input()) % int(input()))


import sys
(X, A, B) = map(int, sys.stdin)
print((X - A) % B)


f = lambda : int(input())
print((f() - f()) % f())


import sys
(x, a, b) = map(int, sys.stdin.read().split())
print((x - a) % b)


def i():
	return int(input())
print((i() - i()) % i())


n = int(input())
(x, y) = (int(input()), int(input()))
d = (n - x) % y
print(d)


a = []
for i in range(3):
	a.append(int(input()))
print((a[0] - a[1]) % a[2])


import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	x = int(input())
	a = int(input())
	b = int(input())
	x -= a
	res = x % b
	print(res)

def __starting_point():
	resolve()
__starting_point()


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


x = int(input())
a = int(input())
b = int(input())
y = x - a
z = y % b
print(z)


l = [int(input()) for _ in range(3)]
print((l[0] - l[1]) % l[2])


(X, a, b) = [int(input()) for i in range(3)]
print((X - a) % b)


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


n = [int(input()) for _ in range(3)]
print((n[0] - n[1]) % n[2])


(X, A, B) = [int(input()) for _ in range(3)]
print((X - A) % B)


(x, a, b) = (int(input()) for _ in [0] * 3)
print((x - a) % b)


def main():
	x = int(input())
	(a, b) = (int(input()) for i in range(2))
	print((x - a) % b)

def __starting_point():
	main()
__starting_point()


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


print((int(input()) - int(input())) % int(input()), end='')


N = [int(input()) for i in range(3)]
print((N[0] - N[1]) % N[2])


xa = int(input()) - int(input())
b = int(input())
print(xa - xa // b * b)


(x, a, b) = [int(input()) for i in range(3)]
c = x - a
print(c % b)


import math
(x, a, b) = [int(input()) for i in range(3)]
print((x - a) % b)


(x, y, z) = [int(input()) for i in range(3)]
x -= y
x -= x // z * z
print(x)


(a, b, c) = map(int, open(0).read().split())
print((a - b) % c)


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


i = lambda a: a + int(input())
print((i(0) - i(0)) % i(0))


X = input()
A = input()
B = input()
k = int(X) - int(A)
print(k % int(B))


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


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


d = int(input()) - int(input())
b = int(input())
print(d - d // b * b)


(X, A, B) = (int(input()) for i in [0] * 3)
print((X - A) % B)


j = int(input())
k = int(input())
i = int(input())
print((j - k) % i)


y = int(input())
y1 = int(input())
y2 = int(input())
print((y - y1) % y2)


x = lambda : int(input())
print((x() - x()) % x())


X = int(input())
A = int(input())
B = int(input())
R = X - A
print(R % B)


X = int(input())
A = int(input())
B = int(input())
answer = (X - A) % B
print(answer)


S = [int(input()) for i in range(3)]
print((S[0] - S[1]) % S[2])


(x, a, b) = [int(input()) for _ in range(3)]
ans = x - a
print(ans % b)


(x, y) = (int(input()) - int(input()), int(input()))
print(x - x // y * y)