Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
ans = 0
if a > b:
  for x in range(b+1):
    if x > a:
      break
    for y in range(b-x+1):
      if y > a:
        break
      for z in range(b-x-y+1):
        if (x+y+z)==b:
          ans += 1
        if z > a:
          break
else:
  for x in range(a+1):
    for y in range(a+1):
      for z in range(a+1):
        if (x+y+z)==b:
          ans += 1
        if (x+y+z)>=b and (x>=b or y>=b or z>=b):
          break
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
ans = 0
if a > b:
  for x in range(b+1):
    for y in range(b-x+1):
      for z in range(b-x-y+1):
        if (x+y+z)==b:
          ans += 1
else:
  for x in range(a+1):
    for y in range(a+1):
      for z in range(a+1):
        if (x+y+z)==b:
          ans += 1
        if (x+y+z)>=b and (x>=b or y>=b or z>=b):
          break
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
ans = 0
if a > b:
  for x in range(b+1):
    for y in range(b-x+1):
      for z in range(b-x-y+1):
        if (x+y+z)==b:
          ans += 1
else:
  for x in range(a+1):
    for y in range(a+1):
      for z in range(a+1):
        if (x+y+z)==b:
          ans += 1
        if (x+y+z)>=b:
          continue
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print((a+b)*c/2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

area = (a+b)*h/2
print(int(area))

Buggy python submission (verdict: Runtime Error):
data = int(input().split())

print((data[0]+data[1])*data[2]/2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

area = (a+b)*h/2
print(int(area))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

input_data = int(stdin.readline().rstrip())

print((input[0]+input[1])*input[3]/2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

area = (a+b)*h/2
print(int(area))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    first_str = a[0]
    a = a[1:]
    if len(a)==0:
      print('A')
      break
  elif first_str == 'b':
    first_str = b[0]
    b = b[1:]
    if len(b)==0:
      print('B')
      break
  elif first_str == 'c':
    first_str = c[0]
    c = c[1:]
    if len(c)==0:
      print('C')
      break
  
    

Fixed submission:
a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    if len(a)==0:
      print('A')
      break
    first_str = a[0]
    a = a[1:]
    
  elif first_str == 'b':
    if len(b)==0:
      print('B')
      break
    first_str = b[0]
    b = b[1:]
    
  elif first_str == 'c':
    if len(c)==0:
      print('C')
      break
    first_str = c[0]
    c = c[1:]
Buggy python submission (verdict: Runtime Error):
S = input()
n = len(S)
ans = 0
for bit in range(1 << (n-1)):
  f = S[0]
  for i in range(n-1):
    if bit & (1 << (n-1)):
      f += "+"
    f += S[i+1]
    ans += sum(map(int,f.split("+")
print(ans)             

Fixed submission:
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

Buggy python submission (verdict: Runtime Error):
a = input()
sum = int(a)
for i in range(len(a)-1):
  sum += int(a[i])
  
  sum += int(a[:i+1]) + int(a[i+1:])
sum += int(a[i+1]) 
print(sum)

Fixed submission:
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

Buggy python submission (verdict: Runtime Error):
a = input()
sum = int(a)
for i in range(len(a)-1):
  sum += int(a[:i]) + int(a[i+1:])
print(int(sum))

Fixed submission:
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))
Buggy python submission (verdict: Runtime Error):


def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    tmp_list = copy(A_list)
    tmp_list.sort()
    max_num = tmp_list[-1]
    second_max_num = tmp_list[-2]
    max_index = A_list.index(max_num)
    for i in range(N):
        if i is max_index:
            print(second_max_num)
            continue
        print(max_num)


if __name__ == '__main__':
    main()


Fixed submission:
from copy import copy


def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    tmp_list = copy(A_list)
    tmp_list.sort()
    max_num = tmp_list[-1]
    second_max_num = tmp_list[-2]
    max_index = A_list.index(max_num)
    for i in range(N):
        if i is max_index:
            print(second_max_num)
            continue
        print(max_num)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp = A_list.pop(i)
        print(max(A_list))
        A_list.insert(i, tmp)


if __name__ == '__main__':
    main()

Fixed submission:
from copy import copy


def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    tmp_list = copy(A_list)
    tmp_list.sort()
    max_num = tmp_list[-1]
    second_max_num = tmp_list[-2]
    max_index = A_list.index(max_num)
    for i in range(N):
        if i is max_index:
            print(second_max_num)
            continue
        print(max_num)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy


def main():
    N = int(input())
    A_lsit = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp_list = copy(A_lsit)
        tmp_list.pop(i)
        print(max(tmp_list))


if __name__ == '__main__':
    main()


Fixed submission:
from copy import copy


def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    tmp_list = copy(A_list)
    tmp_list.sort()
    max_num = tmp_list[-1]
    second_max_num = tmp_list[-2]
    max_index = A_list.index(max_num)
    for i in range(N):
        if i is max_index:
            print(second_max_num)
            continue
        print(max_num)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # N, M = 4, 2
    # lr = [[1, 3], [2, 4]]
    all_set = set(range(1, N + 1))
    for line in lr:
        all_set = all_set & set(range(line[0], line[1] + 1))
    print(len(all_set))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # N, M = 4, 2
    # lr = [[1, 1], [3, 4]]
    ll = []
    rl = []
    for line in lr:
        ll.append(line[0])
        rl.append(line[1])
    diff = min(rl) - max(ll)
    if diff < 0:
        print(0)
        return
    print(diff + 1)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # N, M = 4, 2
    # lr = [[1, 3], [2, 4]]

    count = 0

    for i in range(N):
        f = check(lr, i + 1)
        if f:
            count += 1
    print(count)


def check(lr: list, card: int):
    for line in lr:
        f = line[0] <= card <= line[1]
        if not f:
            return False
    return True


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # N, M = 4, 2
    # lr = [[1, 1], [3, 4]]
    ll = []
    rl = []
    for line in lr:
        ll.append(line[0])
        rl.append(line[1])
    diff = min(rl) - max(ll)
    if diff < 0:
        print(0)
        return
    print(diff + 1)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # lr = []
    # for i in range(M):
    #     lr.append(list(map(int, list(input()))))
    # N, M = 4, 2
    # lr = [[1, 3], [2, 4]]

    count = 0

    for i in range(N):
        f = True
        for line in lr:
            f = f and line[0] <= i+1 <= line[1]
        if f:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    lr = [list(map(int, list(input().split()))) for i in range(M)]
    # N, M = 4, 2
    # lr = [[1, 1], [3, 4]]
    ll = []
    rl = []
    for line in lr:
        ll.append(line[0])
        rl.append(line[1])
    diff = min(rl) - max(ll)
    if diff < 0:
        print(0)
        return
    print(diff + 1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    l = [list(map(int, input())) for i in range(N)]
    # l = [10, 8, 8, 6]
    s = set(l)
    print(len(s))


Fixed submission:
if __name__ == '__main__':
    N = int(input())
    l = [int(input()) for i in range(N)]
    # l = [10, 8, 8, 6]
    s = set(l)
    print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

max_a = max(l)

for j in range(len(l)):
    if max_a == l[j]:
        tmp = l.pop(j)
        print(max(l))
        l.insert(j, tmp)
    else:
        print(max_a)


Fixed submission:
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

l_b = sorted(l)
max_a = l_b[-1]
max_b = l_b[-2]

for j in range(len(l)):
    if max_a == l[j]:
        print(max_b)
    else:
        print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

for j in range(len(l)):
    tmp = l.pop(j)
    print(max(l))
    l.insert(j, tmp)

Fixed submission:
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

l_b = sorted(l)
max_a = l_b[-1]
max_b = l_b[-2]

for j in range(len(l)):
    if max_a == l[j]:
        print(max_b)
    else:
        print(max_a)
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    P = list(map(int, input().split()))     
     
    ans = 0
    for i in range(1, n-1):
        if P[i-1] < P[i] < P[i+1] or P[i+1] < P[i] < P[i-1]:
            ans += 1
     
    print(ans)
    

Fixed submission:
n = int(input())
P = list(map(int, input().split(' ')))

ans = 0
for i in range(1, n-1):
    if P[i-1] < P[i] < P[i+1] or P[i+1] < P[i] < P[i-1]:
        ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
p = list(int(sys.stdin.readline().rstrip().split()))
ans = 0

for i in range(1, n - 1):
    if (p[i-1] < p[i] < p[i+1]) or (p[i+1] < p[i] < p[i-1]):
        ans +=1
    
print(ans)

Fixed submission:
n = int(input())
P = list(map(int, input().split(' ')))

ans = 0
for i in range(1, n-1):
    if P[i-1] < P[i] < P[i+1] or P[i+1] < P[i] < P[i-1]:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

A, B, K = map(int, input().split())
C = math.gcd(A, B)
L = [1]

for i in range(2, C+1):
    if A % i == 0 and B % i == 0:
        L.append(i)

print(L[-K])


Fixed submission:
A, B, K = map(int, input().split())
L = [1]

for i in range(2, 101):
    if A % i == 0 and B % i == 0:
        L.append(i)

print(L[-K])
Buggy python submission (verdict: Runtime Error):
r = int(input())
int(a) = 3*r*r
print(a)


Fixed submission:
r = int(input())**2*3
print(r)
Buggy python submission (verdict: Runtime Error):
N,A,B = [ int(i)for i in input().split()]
c = N*A
if c >= B:
    print(B)
elif c <= B:
    print(C)

Fixed submission:
N,A,B = [int(zz) for zz in input().split()]
i = N*A
if i <= B:
    print(i)
elif i >= B:
    print(B)

Buggy python submission (verdict: Runtime Error):
N,A,B = [ int(i)for i in input().split()]
c = N*A
if c >= B:
    print(B)
elif c <= B:
    print(C)

Fixed submission:
N,A,B = [int(zz) for zz in input().split()]
i = N*A
if i <= B:
    print(i)
elif i >= B:
    print(B)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
for i in range(n):
    if maxnum > ls[i]:
        print(maxnum)
    else:
        lstmp = ls[0:i] + ls[i+1:]
        print(max(lstmp))


Fixed submission:
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
for i in range(n):
    if max > ls[i]:
        print(maxnum)
    else:
        lstmp = ls[0:i] + ls[i+1:]
        print(max(lstmp))


Fixed submission:
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))

for i in range(n):
    lstmp = ls[0:i] + ls[i+1:]
    print(max(lstmp))


Fixed submission:
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split(" "))
min = 1000000000000
for i in range(L,R+1):
  for j in range(i+1,R+1):
    tmp = (i%2019 * j%2019)%2019
    if min > tmp:
      min = tmp
print(min)


Fixed submission:
L,R = map(int,input().split(" "))
min = 1000000000000
if (R-L >= 2019):
    print("0")
    quit()
for i in range(L%2019,R%2019 + 1):
  for j in range(i+1, R%2019 + 1):
    tmp = (i * j)%2019
    if min > tmp:
      min = tmp
print(min)
Buggy python submission (verdict: Runtime Error):
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    print(comb(k - 1, i - 1) % divnum * comb(n - k + 1, i) % divnum)


Fixed submission:
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    if (n-k+1 >= i):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    print(comb(k - 1, i - 1) * comb(n - k + 1, i)%divnum)

Fixed submission:
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    if (n-k+1 >= i):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
r=input()
print(3*r*r)

Fixed submission:
n=int(input())
print(3*n*n)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=[int(i) for i in input().split()]
inf=1000000007
aa=[]
for i in range(M):
	aa.append(int(input()))
dp=[0]*(N+1)
dp[0]=1
if 1 in aa:
	dp[1]=0
else:
	dp[1]=1
for i in range(2,N+1):
	if i in aa:
		dp[i]=0
	else:
		dp[i]=dp[i-2]%inf+dp[i-1]%inf
print(dp[N]%inf)

Fixed submission:
N,M=[int(i) for i in input().split()]
inf=1000000007
dp=[-1]*(N+1)
for i in range(M):
	dp[int(input())]=0
dp[0]=1
if dp[1]==-1:
	dp[1]=1
for i in range(2,N+1):
	if dp[i]==0:
		continue
	else:
		dp[i]=(dp[i-2]+dp[i-1])%inf
print(dp[N]%inf)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=[int(i) for i in input().split()]
inf=1000000007
aa=[]
for i in range(M):
	aa.append(int(input()))
dp=[0]*(N+1)
dp[0]=1
if 1 in aa:
	dp[1]=0
else:
	dp[1]=1
for i in range(2,N+1):
	if i in aa:
		dp[i]=0
	else:
		dp[i]=dp[i-2]%inf+dp[i-1]%inf
print(dp[N]%inf)

Fixed submission:
N,M=[int(i) for i in input().split()]
inf=1000000007
dp=[-1]*(N+1)
for i in range(M):
	dp[int(input())]=0
dp[0]=1
if dp[1]==-1:
	dp[1]=1
for i in range(2,N+1):
	if dp[i]==0:
		continue
	else:
		dp[i]=(dp[i-2]+dp[i-1])%inf
print(dp[N]%inf)
Buggy python submission (verdict: Time Limit Exceeded):
L=input()
length=len(L)
inf=10**9+7
a=1
b=0
for i in range(0,len(L)):
	if L[i]=="0":
		continue
	else:
		b+=a*(3**(length-i-1))%inf
		a=a*2%inf
print((a+b)%inf)


Fixed submission:
L=input()
length=len(L)
inf=10**9+7
a=2
b=1
for i in range(1,len(L)):
	if L[i]=="0":
		b=b*3%inf
		continue
	else:
		b=(b*3+a)%inf
		a=a*2%inf
print((a+b)%inf)
Buggy python submission (verdict: Runtime Error):
S=input()
if S.count"o"+15-len(S)>=8:
	print("YES")
else:
	print("NO")

Fixed submission:
S=input()
if S.count("o")+15-len(S)>=8:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
S=input()
if S.count"o"+15-len(S)>=8
	print("YES")
else:
	print("NO")

Fixed submission:
S=input()
if S.count("o")+15-len(S)>=8:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
A,P=[int(i) for input().split()]
print((A//3+P)//2)

Fixed submission:
A,P=[int(i) for i in input().split()]
print((A*3+P)//2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
restaurants={}
for i in range(N):
  S,P=input().split()
  restaurants[S]=[int(P),i+1]
restaurants=sorted(restaurants.items(),key=lambda x:x[1][0])
restaurants=sorted(restaurants.items(),key=lambda x:x[0])
for i in restaurants.values():
  print(i[1])

Fixed submission:
N=int(input())
restaurants=[]
for i in range(N):
  S,P=input().split()
  restaurants.append([S,int(P),i+1])
restaurants=sorted(restaurants,key=lambda x:-x[1])
restaurants=sorted(restaurants,key=lambda x:x[0])
for i in restaurants:
	print(i[2])
Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
S=input()
print(S[:M-1]+S[M-1].lower()+S[M:]

Fixed submission:
N,M=[int(i) for i in input().split()]
S=input()
print(S[:M-1]+S[M-1].lower()+S[M:])
Buggy python submission (verdict: Runtime Error):
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
  res+=0.5**(math.ceil(math.log2(K/i)))
print(res/N)

Fixed submission:
import math
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
	if i<K:
		po=math.ceil(math.log2(K/i))
		j=math.pow(0.5,po)
	else:
		j=1
	res+=j
print(res/N)
Buggy python submission (verdict: Runtime Error):
import collections

def root(X):
	if cards[X]==X:
		return X
	else:
		cards[X]=root(cards[X])
		return cards[X]
def unite(X,Y):
	x=root(X)
	y=root(Y)
	if x==y:
		return
	else:
		cards[x]=y
def same(X,Y):
	return root(X)==root(Y)
def show(x):
	print(cards[x])
		
N,M=[int(i) for i in input().split()]
cards=[i for i in range(N+1)]
for i in range(M):
	X,Y,Z=[int(i) for i in input().split()]
	if same(X,Y):
		pass
	else:
		unite(X,Y)
a=[]
for i in range(1,N+1):
	a.append(root(cards[i]))
print(len(set(a)))

Fixed submission:
import collections
import sys
sys.setrecursionlimit(100000)
def root(X):
	if cards[X]==X:
		return X
	else:
		cards[X]=root(cards[X])
		return cards[X]
def unite(X,Y):
	x=root(X)
	y=root(Y)
	if x==y:
		return
	else:
		cards[x]=y
def same(X,Y):
	return root(X)==root(Y)
def show(x):
	print(cards[x])
		
N,M=[int(i) for i in input().split()]
cards=[i for i in range(N+1)]
for i in range(M):
	X,Y,Z=[int(i) for i in input().split()]
	if same(X,Y):
		pass
	else:
		unite(X,Y)
a=[]
for i in range(1,N+1):
	a.append(root(cards[i]))
print(len(set(a)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
res=0
for vv cc in zip(V,C):
  if vv-cc>0:
    res=res+vv-cc
print(res)

Fixed submission:
N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
res=0
for vv,cc in zip(V,C):
  if vv-cc>0:
    res=res+vv-cc
print(res)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
dp=np.full((6,N+6),-1)
cost=[]
for i in range(5):
  cost.append(int(input()))
def solve(i,time):
  if dp[i,time]!=-1:
    return dp[i,time]
  if time==0:
     if i==0:
       dp[i][time]=N
       return N
     else:
       dp[i][time]=0
       return 0
  if i==5:
    dp[i,time]=solve(i,time-1)+min(solve(i-1,time-1),cost[i-1])
  elif i>=1 and i< 5:
    dp[i,time]=solve(i,time-1)+min(solve(i-1,time-1),cost[i-1])-min(solve(i,time-1),cost[i])
  else:
    dp[i,time]=solve(i,time-1)-min(solve(i,time-1),cost[i])
  return dp[i,time]

i=0
while(1):
  if solve(5,i)>=N:
    print(i)
    break
  else:
    i+=1

Fixed submission:
import math
N=int(input())

for i in range(5):
  if i==0:
    a=int(input())
  else:
    b=int(input())
    if b<a:
      a=b
print(math.ceil(N/a)+4)