Problem: You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.  You want to introduce the restaurants in the following order:    * The restaurants are arranged in lexicographical order of the names of their cities.   * If there are multiple restaurants in the same city, they are arranged in descending order of score.  Print the identification numbers of the restaurants in the order they are introduced in the book.

Submission attempts (in order):
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        args.append([S,P])

def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]                                                                                       
    # num=8                                                                                                                                                                              

    num=int(input())
    
    restaurant=[]

    input_list(num,restaurant)

    # print(restaurant)                                                                                                                                                                  

    restaurant_sorted=sort_list(*restaurant)

    for i in range(num):
        for j in range(num):
            if restaurant_sorted[i][1]==restaurant[j][1]:
                print(j)



if __name__ == "__main__":
    main()


from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        if 1<=len(S)<=10 and S.islower==1 and 0<=P<=100 and type(P) is int :
            args.append([S,P])
        else :
            print("ERROR")
            exit()

            
def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    uniequ_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
	print("ERORR")
	exit()
    # else :                                                                                         
    #     print("restaurant is ok.")                                                                 


def main():
    num=int(input())
    if 1<=num<=100:
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()


from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    # else :                                                                                         
    #     print("restaurant is ok.")           



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]   
    # num=8                                                                                          

    num=int(input())
    if 1<=num<=100:
        
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        # print(restaurant)                                                                          
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()



Verdicts: Wrong Answer

Runtime Error

Accepted