import sys
def setting(data):
return len(data)
count = int(input())
word_list = []
for _ in range(count):
word_list.append(sys.stdin.readline().strip())
word_list = list(set(word_list))
word_list.sort()
word_list.sort(key=setting)
for i in word_list:
print(i)
1. set 자료형을 이용해서 중복을 제거만 한 뒤, 다시 리스트로 바꿔준다.
* set 자료형

2. 사전 순으로 정렬을 먼저 해준다.
3. 사전 순으로 정렬되어있는 상태에서 단어 길이를 기준으로 정렬해준다.
*sys.stdin.readline()은 개행문자를 제거해주지 않고 포함하여 입력받기 때문에 strip() 함수를 이용해 공백을 제거해주었다.