AtCoder Beginner Contest 067 - Sharing Cookies

Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

-----Constraints-----
 - 1 \leq A,B \leq 100
 - Both A and B are integers.

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

-----Output-----
If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.

-----Sample Input-----
4 5

-----Sample Output-----
Possible

If Snuke gives nine cookies, each of the three goats can have three cookies.

Difficulty: EASY

Starter code:

Solutions:
(a, b) = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(A, B) = [int(i) for i in input().split()]
print('Impossible' if A % 3 and B % 3 and (A + B) % 3 else 'Possible')


(A, B) = map(int, input().split(' '))
if (A + B) % 3 and A % 3 and B % 3:
	print('Impossible')
else:
	print('Possible')


(a, b) = map(int, input().split())
if a % 3 and b % 3 and (a + b) % 3:
	print('Impossible')
else:
	print('Possible')


(x, y) = map(int, input().split())
if x % 3 == 0 or y % 3 == 0 or (x + y) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(A, B) = map(int, input().split())
print(['Possible', 'Impossible'][not (A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0)])


(A, B) = map(int, input().split())
print(('Possible', 'Impossible')[min([A % 3, B % 3, (A + B) % 3])])


(a, b) = map(int, input().split())
print(('P', 'Imp')[all((i % 3 for i in (a, b, a + b)))] + 'ossible')


(A, B) = map(int, input().split())
if (A + B) % 3 == 0 or A % 3 == 0 or B % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(a, b) = map(int, input().split())
print('PIomspsoisbslieb l e'[list(map(lambda x: x % 3, [a, b, a + b])).count(0) == 0::2])


(a, b) = map(int, input().split())
print('Possible' if any([x % 3 == 0 for x in [a, b, a + b]]) else 'Impossible')


(A, B) = map(int, input().split())
print(['Imp', 'P'][any([1 for i in [A, B, A + B] if i % 3 == 0])] + 'ossible')


(A, B) = map(int, input().split())
print('PIomspsoisbslieb l e'[all([A % 3, B % 3, (A + B) % 3])::2])


(A, B) = map(int, input().split())
print(['P', 'Imp'][(A + B) % 3 * (A % 3) * (B % 3) > 0] + 'ossible')


(a, b) = [int(s) for s in input().split()]
if a * b * (a + b) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


lst = input().split()
A = int(lst[0])
B = int(lst[1])
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(a, b) = map(int, input().split())
print(['P', 'Imp'][a % 3 == b % 3 > 0] + 'ossible')


(a, b) = map(int, input().split())
if a % 3 == b % 3 == 1 or a % 3 == b % 3 == 2:
	print('Impossible')
else:
	print('Possible')


(a, b) = map(int, input().split())
print(('Impossible', 'Possible')[a % 3 * b % 3 * (a + b) % 3 == 0])


(a, b) = list(map(int, input().split()))
if a % 3 == 0 or b % 3 == 0:
	print('Possible')
elif a % 3 == 1 and b % 3 == 2:
	print('Possible')
elif a % 3 == 2 and b % 3 == 1:
	print('Possible')
else:
	print('Impossible')


(a, b) = list(map(int, input().split()))
bool_a = a % 3 == 0
bool_b = b % 3 == 0
bool_ab = (a + b) % 3 == 0
if bool_a or bool_b or bool_ab:
	print('Possible ')
else:
	print('Impossible ')


(a, b) = map(int, input().split())
print('IPmopsossisbilbel e'[a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0::2])


(a, b) = (int(x) for x in input().split())
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
	ans = 'Possible'
else:
	ans = 'Impossible'
print(ans)


(a, b) = input().split()
a = int(a)
b = int(b)
if (a + b) % 3 == 0:
	print('Possible')
elif a % 3 == 0:
	print('Possible')
elif b % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(A, B) = map(int, input().split())
print(['Impossible', 'Possible'][bool(A % 3 is 0 or B % 3 is 0 or (A + B) % 3 is 0)])


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 = '4 5'
		output = 'Possible'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '1 1'
		output = 'Impossible'
		self.assertIO(input, output)

def resolve():
	(A, B) = list(map(int, input().split()))
	if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
		print('Possible')
	else:
		print('Impossible')

def __starting_point():
	resolve()
__starting_point()


(a, b) = map(int, input().split())
print(('im' * ((a % 3 and b % 3 and (a + b) % 3) > 0) + 'possible').capitalize())


(A, B) = map(int, input().split())
if (1 <= A and A <= 100) and (1 <= B and B <= 100):
	sum = A + B
	if A % 3 == 0 or B % 3 == 0 or sum % 3 == 0:
		print('Possible')
	else:
		print('Impossible')


(a, b) = list(map(int, input().split()))
result = 'ret'
if a % 3 == 0:
	result = 'Possible'
elif b % 3 == 0:
	result = 'Possible'
elif (a + b) % 3 == 0:
	result = 'Possible'
else:
	result = 'Impossible'
print(result)


(x, y) = map(int, input().split())
print(['P', 'Imp'][all([x % 3 > 0, y % 3 > 0, (x + y) % 3 > 0])] + 'ossible')


(A, B) = map(int, input().split())
print(['Impossible', 'Possible'][any([1 for i in [A, B, A + B] if i % 3 == 0])])


S_list = list(map(int, input().split()))
(A, B) = (S_list[0], S_list[1])
if A * B * (A + B) % 3 == 0:
	result = 'Possible'
else:
	result = 'Impossible'
print(result)


(a, b) = map(int, input().split())
print(['Possible', 'Impossible'][a % 3 == b % 3 and (a % 3 == 1 or a % 3 == 2)])


print(['P', 'Imp'][eval(input().replace(' ', '*')) % 3 % 2] + 'ossible')


(A, B) = map(int, input().split())
print('Possible' if any((v % 3 is 0 for v in (A, B, A + B))) else 'Impossible')


l = list(map(int, input().split()))
print(['P', 'Imp'][all(map(lambda x: min(x % 3, 1), [sum(l)] + l))] + 'ossible')


(a, b) = map(int, input().split())
ans = [a % 3, b % 3, (a + b) % 3]
if 0 in ans:
	print('Possible')
else:
	print('Impossible')


(n, m) = list(map(int, input().split()))
print('Impossible' if n % 3 and m % 3 and (n + m) % 3 else 'Possible')


(X, Y) = map(int, input().split())
if X % 3 == 0 or Y % 3 == 0 or (X + Y) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(a, b) = map(int, input().split())
if min([i % 3 for i in [a, b, a + b]]) == 0:
	print('Possible')
else:
	print('Impossible')


def iroha():
	(a, b) = map(int, input().split())
	aa = a % 3
	bb = b % 3
	cc = (a + b) % 3
	print('Possible') if aa == 0 or bb == 0 or cc == 0 else print('Impossible')

def __starting_point():
	iroha()
__starting_point()


(a, b) = map(int, input().split())
print(('P', 'Imp')[a * b % 3 % 2] + 'ossible')


(A, B) = map(int, input().split())
list = [(A + B) % 3, A % 3, B % 3]
print('Possible' if 0 in list else 'Impossible')


(A, B) = (int(T) for T in input().split())
print(['Impossible', 'Possible'][any((T % 3 == 0 for T in [A, B, A + B]))])


(a, b) = map(int, input().split())
k = a % 3
s = b % 3
if k == s and k != 0:
	print('Impossible')
else:
	print('Possible')


(A, B) = map(int, input().split())
s = 'ossible'
if A % 3 * B % 3 * (A + B) % 3 == 0:
	print('P' + s)
else:
	print('Imp' + s)


(A, B) = map(int, input().split())
print(['Possible', 'Impossible'][bool(A * B * (A + B) % 3)])


(a, b) = (int(i) for i in input().split())
print('Possible' if (a + b) % 3 == 0 or a % 3 == 0 or b % 3 == 0 else 'Impossible')


num = list(map(int, input().split()))
print('Possible' if sum(num) % 3 == 0 or num[0] % 3 == 0 or num[1] % 3 == 0 else 'Impossible')


print(f"{eval(input().replace(*' *')) % 3 % 2 * 'Imp' or 'P'}ossible")


(A, B) = list(map(int, input().split()))
if A % 3 == 0:
	answer = 'Possible'
elif B % 3 == 0:
	answer = 'Possible'
elif (A + B) % 3 == 0:
	answer = 'Possible'
else:
	answer = 'Impossible'
print(answer)


(a, b) = map(int, input().split())
print(('P', 'Imp')[a * b % 3 == 1] + 'ossible')


f = lambda x: x % 3 == 0
(a, b) = map(int, input().split())
print(['Impossible', 'Possible'][f(a) or f(b) or f(a + b)])


(A, B) = list(map(int, input().split()))
result = 'Impossible'
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
	result = 'Possible'
print(result)


(A_mai, B_mai) = map(int, input().split())
summ = A_mai + B_mai
if A_mai % 3 == 0 or B_mai % 3 == 0 or summ % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(A, B) = list(map(int, input().split()))
for i in [A, B, A + B]:
	if i % 3 == 0:
		print('Possible')
		return
print('Impossible')


(a, b) = map(int, input().split())
ans = 'Impossible'
p = 'Possible'
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
	ans = p
print(ans)


(a, b) = map(int, input().split(' '))
print('Possible' if any(map(lambda x: x % 3 == 0, (a, b, a + b))) else 'Impossible')


(A, B) = map(int, input().split())
c = min([(A + B) % 3, A % 3, B % 3])
print(['Possible', 'Impossible'][c != 0])


(A, B) = map(lambda x: int(x) % 3, input().split())
print('Possible' if A * B * (A + B - 3) == 0 else 'Impossible')


(n, m) = map(int, input().split())
if n % 3 == 0 or m % 3 == 0 or (n + m) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


(N, K) = map(int, input().split())
print('Possible' if N * K * (N + K) % 3 == 0 else 'Impossible')


(a, b) = map(int, input().split())
print(['P', 'Imp'][a % 3 == b % 3 and (a % 3 == 1 or a % 3 == 2)] + 'ossible')


a = list(map(int, input().split()))
b = sum(a)
if b % 3 == 0 or a[0] % 3 == 0 or a[1] % 3 == 0:
	print('Possible')
else:
	print('Impossible')