Medium
Whoever Finishes First
Each input line is
name delay_ms. Start a task per line that sleeps for its delay and returns the name. Use asyncio.wait(..., return_when=asyncio.FIRST_COMPLETED) to print the first name to finish, cancel the rest and print how many were cancelled.Input
n, then n lines (all delays different by at least 40 ms).
Output
Two lines.
Sample 1
Input
3 A 100 B 20 C 60
Output
B 2 cancelled
Sample 2
Input
1 solo 10
Output
solo 0 cancelled
Output appears here