还是在找规律
n=int(input())
l=[]
all=0
for i in range(n):
l.append(list(map(int,input().split())))
all+=l[i][1]
l.sort()
maxscoreno=l[0][0]
maxscore=all
before=l[0][1]
for i in range(1,n):
after=all-before
score=i-before+after
if i<n-1:
for j in range(i-1,-1,-1):
if l[i][0]==l[j][0]:
if l[j][1]==1:
score+=1
else:
score-=1
else:
break
if score>=maxscore:
maxscore=score
maxscoreno=l[i][0]
before+=l[i][1]
print(maxscoreno)