• + 0 comments

    With dictionaries

    lista = {}
    for _ in range(int(input())):
        name, score = input(), float(input())
        if score not in lista.keys():
            lista[score] = [name]
        else: lista[score].append(name)
    print('\n'.join(sorted(sorted(lista.items())[1][1])))