UptoSkills Arena Snack Delivery
UptoSkills Arena is hosting a coding competition, and the organizing team is ordering snacks for the participants. The snacks have different expiry dates. To ensure participants get fresh snacks, the delivery person must deliver them in the order of their expiry dates, from the earliest to the latest. If two snacks expire on the same day, the one with the smaller quantity should be delivered first.
Given a list of snacks with their expiry dates and quantities, help the delivery person determine the correct order of delivery.
Input
The first line contains an integer N, the number of snack types. The next N lines each contain two integers: the expiry date (an integer representing days from today) and the quantity of that snack type.
Output
Print N lines, each containing the expiry date and quantity of a snack type in the order they should be delivered.
Constraints
1 <= N <= 1000 1 <= expiry_date <= 365 1 <= quantity <= 1000
Example 1
4 10 5 5 10 10 3 7 8
5 10 7 8 10 3 10 5
The snacks are sorted first by expiry date (5, 7, 10, 10) and then by quantity for the same expiry date (10, 3).
Example 2
3 30 20 30 20 15 10
15 10 30 20 30 20
Two snacks have the same expiry date and quantity; their relative order doesn't matter based on the problem statement, but a stable sort would preserve their input order.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
4 10 5 5 10 10 3 7 8
3 30 20 30 20 15 10