A. Infinite Coins … Simple print modulus result
n = int(input()) a = int(input()) print("Yes" if n%500 <= a else "No")
B. Card Game For Two … As the questions says “When both players take the optimal strategy to maximize their scores”, it means both player takes the biggest card on their turn. Sort the card list in descending order, and use python list slice ([::2] the last 2 means every other cards) to create the resulting card list for both users.
n = int(input()) cards = sorted(list(map(int, input().split())), reverse=True) if n > 1: print(sum(cards[::2])-sum(cards[1::2])) else: print(cards)
C. Takahashi’s Information … As possible number of ai is not so big, I use bruteforce for possible a1, so the cost is 100x3x3. Once a1 value is fixed, the other number can be calculated. Compare the resulting list (from the assumption) and the original list.
def is_correct(grids): for a1 in range(min(101, grids+1)): b_list = grids - a1, grids - a1, grids - a1 a2, a3 = grids - b_list, grids - b_list a_list = [a1, a2, a3] temp_grids =  for an in a_list: row =  for bn in b_list: row.append(an+bn) temp_grids.append(row) if grids == temp_grids: return True return False grids =  for _ in range(3): grids.append(list(map(int, input().split()))) print("Yes" if is_correct(grids) else "No")