# Untitled

a guest
Feb 3rd, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from collections import deque
2.
3. males = [int(male) for male in input().split()]
4. females = deque(int(female) for female in input().split())
5.
6. matches = 0
7.
8. while True:
9.
10.     if not males or not females:
11.         break
12.
13.     current_male = males[-1]
14.     current_female = females[0]
15.
16.     if current_male <= 0:
17.         males.pop()
18.         continue
19.     if current_female <= 0:
20.         males.pop()
21.         continue
22.
23.     if current_male % 25 == 0:
24.         males.pop()
25.         if not males:
26.             break
27.         males.pop()
28.         continue
29.     if current_female % 25 == 0:
30.         females.popleft()
31.         if not females:
32.             break
33.         females.popleft()
34.         continue
35.
36.     if current_male == current_female:
37.         males.pop()
38.         females.popleft()
39.         matches += 1
40.     else:
41.         females.popleft()
42.         males[-1] -= 2
43.
44. print(f'Matches: {matches}')
45.
46. if males:
47.     print(f"Males left: {', '.join(str(male) for male in reversed(males))}")
48. else:
49.     print("Males left: none")
50.
51. if females:
52.     print(f"Females left: {', '.join(str(female) for female in females)}")
53. else:
54.     print("Females left: none")