# Untitled

a guest
Feb 3rd, 2022
295
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.     if not males or not females:
10.         break
11.
12.     current_male = males[-1]
13.     current_female = females[0]
14.
15.     if current_male <= 0:
16.         males.pop()
17.         continue
18.     if current_female <= 0:
19.         females.popleft()
20.         continue
21.
22.     if current_male % 25 == 0:
23.         males.pop()
24.         if not males:
25.             break
26.         males.pop()
27.         continue
28.     if current_female % 25 == 0:
29.         females.popleft()
30.         if not females:
31.             break
32.         females.popleft()
33.         continue
34.
35.     if current_male == current_female:
36.         males.pop()
37.         females.popleft()
38.         matches += 1
39.     else:
40.         females.popleft()
41.         males[-1] -= 2
42.
43. print(f'Matches: {matches}')
44.
45. if males:
46.     print(f"Males left: {', '.join(str(male) for male in reversed(males))}")
47. else:
48.     print('Males left: none')
49.
50. if females:
51.     print(f"Females left: {', '.join(str(female) for female in females)}")
52. else:
53.     print('Females left: none')