AtCoder Beginner Contest 154 - Remaining Balls

We have A balls with the string S written on each of them and B balls with the string T written on each of them.

From these balls, Takahashi chooses one with the string U written on it and throws it away.

Find the number of balls with the string S and balls with the string T that we have now.

-----Constraints-----
 - S, T, and U are strings consisting of lowercase English letters.
 - The lengths of S and T are each between 1 and 10 (inclusive).
 - S \not= T
 - S=U or T=U.
 - 1 \leq A,B \leq 10
 - A and B are integers.

-----Input-----
Input is given from Standard Input in the following format:
S T
A B
U

-----Output-----
Print the answer, with space in between.

-----Sample Input-----
red blue
3 4
red

-----Sample Output-----
2 4

Takahashi chose a ball with red written on it and threw it away.
Now we have two balls with the string S and four balls with the string T.

Source: atcoder | Difficulty: EASY


Solutions:
(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
if U == S:
	A -= 1
else:
	B -= 1
print(A, B)


[s, t] = input().split()
[a, b] = list(map(int, input().split()))
u = input()
if s == u:
	a -= 1
elif t == u:
	b -= 1
print(a, b)


(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()
if s == u:
	print(a - 1, b)
else:
	print(a, b - 1)


(s, t) = input().split()
(x, y) = map(int, input().split())
if input() == s:
	print(x - 1, y)
else:
	print(x, y - 1)


(S, T) = input().split()
(s, t) = map(int, input().split())
if input() == S:
	s -= 1
else:
	t -= 1
print(s, t)


(S, T) = input().split()
(a, b) = map(int, input().split())
d = input()
if d == S:
	a -= 1
else:
	b -= 1
print(a, b)


(s, t) = input().split()
(a, b) = (int(x) for x in input().split())
u = input()
if s == u:
	a -= 1
else:
	b -= 1
print(a, b)


(s, t, a, b, u) = map(str, open(0).read().split())
if u == s:
	print(int(a) - 1, int(b))
else:
	print(int(a), int(b) - 1)


(S, T) = input().split()
(s, t) = [int(x) for x in input().split()]
U = input()
print(s - (U == S), t - (U == T))


import sys
(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()
if u == s:
	print(a - 1, b)
if u == t:
	print(a, b - 1)


(S, T) = map(str, input().split())
(A, B) = map(int, input().split())
U = input()
if U == S:
	print(A - 1, B)
elif U == T:
	print(A, B - 1)


(s, t) = input().split()
(A, B) = map(int, input().split())
x = input()
if x == s:
	print(A - 1, B)
else:
	print(A, B - 1)


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
ST = {S: A, T: B}
ST[U] -= 1
print(ST[S], ST[T])


(a, b) = input().split()
(ai, bi) = map(int, input().split())
s = input()
if a == s:
	ai -= 1
if b == s:
	bi -= 1
print(ai, bi)


(a, b) = input().split()
(c, d) = map(int, input().split())
if input() == a:
	c -= 1
else:
	d -= 1
print(c, d)


(s, a, u) = open(0)
i = s.find(u) < 1
print(int(a[:2]) - i, int(a[2:]) - 1 + i)


s = list(input().split())
(a, b) = map(int, input().split())
print(a, b - 1) if s.index(input()) == 1 else print(a - 1, b)


((s, t), (a, b), u) = (input().split(), map(int, input().split()), input())
print(a - (s == u), b - (t == u))


(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()
ans = 0
if u in s:
	a -= 1
if u in t:
	b -= 1
print(a, b)


D = {}
(s, t) = input().split()
(a, b) = map(int, input().split())
D[s] = a
D[t] = b
D[input()] -= 1
print(D[s], D[t])


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
A -= S == U
B -= T == U
print(f'{A} {B}')


moji = input().split()
ball = list(map(int, input().split()))
ball[moji.index(input())] -= 1
print(*ball)


(a, s) = input().split()
(m, n) = map(int, input().split())
x = input()
print(m - (a == x), n - (s == x))


(s, t) = input().split()
(a, b) = map(int, input().split())
i = s == input()
print(a - i, b - 1 + i)


(n, k) = input().split()
(l, m) = map(int, input().split())
o = input()
if n == o:
	l = l - 1
if k == o:
	m = m - 1
print(l, m)


li = input().split()
(a, b) = map(int, input().split())
dec = input()
if li[0] == dec:
	print(a - 1, b)
else:
	print(a, b - 1)


l1 = input().split()
l2 = list(map(int, input().split()))
l2[l1.index(input())] -= 1
print(' '.join((str(x) for x in l2)))


S = input().split()
A = list(map(int, input().split()))
A[input() == S[1]] -= 1
print(A[0], A[1])


s = input().split()
a = list(map(int, input().split()))
pos = s.index(input())
a[pos] -= 1
print(*a)


x = list(input().split())
(a, b) = map(int, input().split())
y = input()
if y == x[0]:
	print(a - 1, b)
else:
	print(a, b - 1)


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
d = {S: A, T: B}
d[U] -= 1
print(d[S], d[T])


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
D = {S: A, T: B}
D[U] -= 1
print(D[S], D[T])


st = input().split()
ab = list(map(int, input().split()))
u = input()
ab[st.index(u)] -= 1
print(ab[0], ab[1])


(S, T) = input().split()
(A, B) = [int(s) for s in input().split()]
U = input()
print(A - (S == U), B - (T == U))


(S, T) = input().split()
li = list(map(int, input().split()))
if S == input():
	li[0] -= 1
else:
	li[1] -= 1
print(*li)


(s, t) = input().split()
(a, b) = [int(i) for i in input().split()]
u = input()
if s == u:
	a -= 1
elif t == u:
	b -= 1
print(a, b)


(a, b) = input().split()
(n, m) = list(map(int, input().split()))
k = input()
print(n - (a == k), m - (b == k))


s = list(input().split())
(a, b) = map(int, input().split())
u = input()
if s[0] == u:
	print(a - 1, b)
else:
	print(a, b - 1)


(n, m) = input().split()
(a, b) = map(int, input().split())
u = input()
if u == n:
	print(a - 1, b)
else:
	print(a, b - 1)


def main():
	(s, t) = input().split(' ')
	(a, b) = map(int, input().split(' '))
	u = input()
	if u == s:
		a -= 1
	else:
		b -= 1
	print(f'{a} {b}')

def __starting_point():
	main()
__starting_point()


(a, b) = input().split()
(A, B) = map(int, input().split())
c = input()
if a == c:
	A = A - 1
else:
	B = B - 1
print(A, B)


(s, t) = input().split()
(n, m) = map(int, input().split())
x = input()
if x == s:
	print(n - 1, m)
else:
	print(n, m - 1)


(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()
d = {s: a, t: b}
d[u] -= 1
print(d[s], d[t])


(a, b) = input().split()
(x, y) = map(int, input().split())
c = input()
if c == a:
	print(x - 1, y)
else:
	print(x, y - 1)


(s, t) = input().split()
(ns, nt) = list(map(int, input().split()))
u = input()
if u == s:
	print(ns - 1, nt)
else:
	print(ns, nt - 1)


(s, t) = input().split()
(a, b) = map(int, input().split())
n = [(a, b - 1), (a - 1, b)][s == input()]
print(*n, sep=' ')


(a, b) = input().split()
d = {}
d[a] = 0
d[b] = 0
(d[a], d[b]) = map(int, input().split())
x = input()
d[x] -= 1
print(d[a], d[b])


s = input().split()
n = list(map(int, input().split()))
U = input()
n[s.index(U)] -= 1
print(n[0], n[1])


S = input().split()
A = list(map(int, input().split()))
U = input()
a = S.index(U)
A[a] -= 1
print(A[0], A[1])


(s, t, a, b, u) = open(0).read().split()
i = u == s
print(int(a) - i, int(b) - 1 + i)


(a, b) = input().split()
(q, w) = map(int, input().split())
c = input()
if a == c:
	print(q - 1, w)
else:
	print(q, w - 1)


(x, y) = input().split()
(a, b) = map(int, input().split())
z = input()
a = a - (x == z)
b = b - (y == z)
print(a, b)


(x, y) = input().split()
(z, w) = map(int, input().split())
u = input()
if x == u:
	print(z - 1, w)
else:
	print(z, w - 1)


(S, T) = input().split()
A = list(map(int, input().split()))
U = input()
if S == U:
	A[0] -= 1
else:
	A[1] -= 1
print(*A)


s = list(input().split())
a = list(map(int, input().split()))
t = input()
a[s.index(t)] -= 1
print(*a)


def resolve():
	(s, t) = input().split()
	(a, b) = map(int, input().split())
	u = input()
	print(a - (s == u), b - (t == u))
resolve()


(S, T) = input().split()
(a, b) = [int(s) for s in input().split()]
U = input()
if S == U:
	a -= 1
else:
	b -= 1
print(*[a, b])


(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()
m = {s: a, t: b}
m[u] -= 1
print(m[s], m[t])


(s, t) = input().split()
(a, b) = [int(x) for x in input().split()]
u = input()
print(a - (u == s), b - (u == t))


((s, t), (a, b), (u,)) = [t.split() for t in open(0)]
print(int(a) - (s == u), int(b) - (t == u))


keys = list(map(str, input().split()))
values = list(map(int, input().split()))
rm_str = input()
dicts = {key: value for (key, value) in zip(keys, values)}
dicts[rm_str] = dicts[rm_str] - 1
print(' '.join([str(n) for n in list(dicts.values())]))


c = input().split()
n = [int(i) for i in input().split()]
d = dict(zip(c, n))
d[input()] -= 1
print(d[c[0]], d[c[1]])


(s, t) = map(str, input().split())
(n, m) = map(int, input().split())
u = input()
if s == u:
	print(n - 1, m)
else:
	print(n, m - 1)


a = list(map(str, input().split()))
b = list(map(int, input().split()))
b[a.index(input())] -= 1
print(*b)


(s, a, u) = open(0)
i = u in s
print(int(a[:2]) - 1 + i, int(a[2:]) - i)


(s, _) = input().split()
(a, b) = map(int, input().split())
print(*[[a, b - 1], [a - 1, b]][s == input()])


(a, b) = input().split()
(a_num, b_num) = map(int, input().split())
c = input()
if c == a:
	a_num -= 1
else:
	b_num -= 1
print(a_num, b_num)


(a, b) = input().split()
(c, d) = input().split()
e = input()
c = int(c)
d = int(d)
if a == e:
	print(c - 1, d)
else:
	print(c, d - 1)


(s, t) = input().split()
(sx, tx) = map(int, input().split())
a = input()
if a == s:
	sx -= 1
else:
	tx -= 1
print(sx, tx)


(s, t) = input().split()
(a, b) = map(int, input().split())
c = input()
if s == c:
	a -= 1
elif t == c:
	b -= 1
print(a, b, sep=' ')


(s, t) = input().split()
d = {}
(d[s], d[t]) = map(int, input().split())
d[input()] -= 1
print(d[s], d[t])


(S, T) = input().split()
(a, b) = map(int, input().split())
U = input().strip()
print(a - (S == U), b - (T == U))


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
Dic = {S: A, T: B}
Dic[U] -= 1
print(Dic[S], Dic[T])


(S, T) = input().split()
(A, B) = [int(n) for n in input().split()]
if input() == S:
	A -= 1
else:
	B -= 1
print(A, B)


(s, t) = map(str, input().split())
(a, b) = map(int, input().split())
ss = input()
if ss == s:
	a -= 1
else:
	b -= 1
print(a, b)


(s, b) = input().split()
d = {}
(d[s], d[b]) = [int(x) for x in input().split()]
d[input()] -= 1
print(d[s], d[b])


(s, t, a, b, u) = open(0).read().split()
if s == u:
	print(int(a) - 1, b)
elif t == u:
	print(a, int(b) - 1)


s = input().split()
a = [int(i) for i in input().split()]
u = input()
a[s.index(u)] -= 1
print(*a)


(a, b) = input().split()
(i, j) = map(int, input().split())
u = input()
if u == a:
	print(i - 1, j)
else:
	print(i, j - 1)


(s, a, u) = open(0)
(*a,) = map(int, a.split())
a[u in s] -= 1
print(*a)


ST = input().split()
AB = list(map(int, input().split()))
U = input()
AB[ST.index(U)] -= 1
print(*AB)


(s, t) = input().split()
tm = {}
(a, b) = map(int, input().split())
tm[s] = a
tm[t] = b
tm[input()] -= 1
print(tm[s], tm[t])


[S, T] = [str(i) for i in input().split()]
[A, B] = [int(i) for i in input().split()]
U = str(input())
if S == U:
	print(A - 1, B)
else:
	print(A, B - 1)


(S, T) = map(str, input().split())
(a, b) = map(int, input().split())
U = str(input())
if U == S:
	a = a - 1
else:
	b = b - 1
print(a, b)


(S, T, A, B, U) = open(0).read().split()
if S == U:
	print(int(A) - 1, B)
else:
	print(A, int(B) - 1)


(S, T) = input().split()
(A, B) = map(int, input().split())
U = input()
dic = {S: A, T: B}
dic[U] -= 1
print(dic[S], dic[T])


(s, r) = input().split()
(x, y) = map(int, input().split())
t = input()
if t == s:
	x = x - 1
if t == r:
	y -= 1
print(x, y)


(S, T) = input().split()
(A, B) = map(int, input().split())
ans = {S: A, T: B}
ans[input()] -= 1
print(*ans.values())