• + 0 comments

    Read the number of students

    n = int(input())

    Initialize lists to store student names and grades

    students = [] grades = []

    Read each student's name and grade

    for _ in range(n): name = input() grade = float(input()) students.append((name, grade)) grades.append(grade)

    Find the second lowest grade

    sorted_grades = sorted(set(grades)) # Get unique grades and sort them second_lowest_grade = sorted_grades[1] # The second lowest grade is at index 1

    Find students with the second lowest grade

    second_lowest_students = [name for name, grade in students if grade == second_lowest_grade]

    Sort the names alphabetically

    second_lowest_students.sort()

    Print each name on a new line

    for student in second_lowest_students: print(student)