Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(lambda x: int(x),input().split())))

A_allplus = np.where(A>=0,A,-A)
#print(A_allplus)
plus = A[A>=0]
minus = A[A<0]
#print(minus)
d = 0
if len(minus)%2==1:
    a = max(minus)
    b = min(plus)
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)

Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(lambda x: int(x),input().split())))

A_allplus = np.where(A>=0,A,-A)
#print(A_allplus)
plus = A[A>=0]
minus = A[A<0]
#print(minus)
d = 0
if len(minus)%2==1:
    a = np.inf
    b = np.inf
    if len(minus)>0:
        a = max(minus)
    if len(plus)>0:
        b = min(plus)
    
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5 t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7 l, r = map(int, input().split())
8 print(t[r-1] - t[l-1])

Fixed submission:
import numpy as np

s=input()

if s=='A':
    print('T')

if s=='T':
    print('A')

if s=='G':
    print('C')

if s=='C':
    print('G')
Buggy python submission (verdict: Runtime Error):
import numpy as np

s=input()
isContinue=0
part=[]

for c in s:
    if c=='A' or c=='T' or c=='C' or c=='G':
        isContinue+=1
    else:
        part.append(isContinue)
        isContinue=0

print(max(part))









Fixed submission:
import numpy as np

s=input()
isContinue=0
part=[0]

for i in range(len(s)):
    if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
        isContinue+=1
        if i==len(s)-1:
            part.append(isContinue)
    else:
        part.append(isContinue)
        isContinue=0

print(max(part))
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5     t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7     l, r = map(int, input().split())
8     print(t[r-1] - t[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5 t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7 l, r = map(int, input().split())
8 print(t[r-1] - t[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().split()[1])
s=input()

for i in range(n):
    lr=input().split()
    print(s[int(lr[0])-1:int(lr[1])].count('AC'))
    



Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input().split()[1])
s=input()

def count(l,r):
    global s
    lr_str = s[l-1:r]
    #print(lr_str)
    As_ind = [i for i, x in enumerate(lr_str) if x == 'A']
    count=0
    for a in As_ind:
        if a<len(lr_str)-1:
            #print(a+1)
            if lr_str[a+1]=='C':
                count+=1
    print(count)

for i in range(n):
    lr=input().split()
    count(int(lr[0]),int(lr[1]))
    



Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input().split()[1])
s=input()

def count(l,r):
    global s
    wasA=False
    count=0
    for c in s[l-1:r]:
        if c=='A':
            wasA=True
            continue
        if c=='C':
            if wasA:
                count+=1
        wasA=False
    print(count)

for i in range(n):
    lr=input().split()
    count(int(lr[0]),int(lr[1]))
    



Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
import Math

lst=input().split(" ")
H=int(lst[0])
W=int(lst[1])
lst=input().split(" ")
h=int(lst[0])
w=int(lst[1])

print(H*W-(h*W+H*w-h*w)) 

Fixed submission:
lst=input().split(" ")
H=int(lst[0])
W=int(lst[1])
lst=input().split(" ")
h=int(lst[0])
w=int(lst[1])

print(H*W-(h*W+H*w-h*w))
Buggy python submission (verdict: Runtime Error):
S=input()
def union(s):
    answer_str = s
    for i in range(len(s)-1):
        if s[i]!=s[i+1]:
            if i!=len(s)-2:
                return union(s[:i]+s[i+2:])
            else:
                return union(s[:i])
    
    return answer_str
 
print(len(S)-len(union(S)))



Fixed submission:
S=input()

zero_count=0
one_count=0
for c in S:
    if c=='1':
        one_count+=1
    else:
        zero_count+=1

print(min(zero_count,one_count)*2)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = map(int, input().split())
A = [a - 1 for a  in A]

visit = [0] * N
turn = [-1] * N

visit[0] = 1
turn[0] = 0

def judge(v):
    for i, _v in enumerate(v):
        if _v > 1:
            return (True, i)
    return (False, 0)

cursor = 0
turn_count = 0
while True:
    cursor = A[cursor]
    turn_count += 1

    if turn_count == K:
        print(cursor+1)
        exit()

    visit[cursor] += 1

    flag, i = judge(visit)
    if flag:
        loop_length = turn_count - turn[i]
        break

    turn[cursor] = turn_count

K -= turn[i]
K %= loop_length

cursor = i
for _ in range(K):
    cursor = A[cursor]

print(cursor + 1)


Fixed submission:
N, K = map(int, input().split())
A = map(int, input().split())
A = [a - 1 for a  in A]

visit = [0] * N
turn = [-1] * N

visit[0] = 1
turn[0] = 0

cursor = 0
turn_count = 0
while True:
    cursor = A[cursor]
    turn_count += 1

    if turn_count == K:
        print(cursor+1)
        exit()

    visit[cursor] += 1

    if visit[cursor] > 1:
        loop_length = turn_count - turn[cursor]
        break

    turn[cursor] = turn_count

K -= turn[cursor]
K %= loop_length

for _ in range(K):
    cursor = A[cursor]

print(cursor + 1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ret = 0
for i in range(1, K+1):
    prev = '?'
    for j in range(len(T) // K + 1):
        if i + K*j - 1 >= len(T):
            continue
        now = T[i + K*j - 1]
        print(i + K*j - 1)
        count+=1
        if prev == now:
            prev = '?'
        else:
            prev = now
            if now == 'r':  
                ret += P
            elif now == 's':
                ret += R
            else:
                ret += S
            
print(ret)

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ret = 0
for i in range(1, K+1):
    prev = '?'
    for j in range(len(T) // K + 1):
        if i + K*j - 1 >= len(T):
            continue
        now = T[i + K*j - 1]
        
        if prev == now:
            prev = '?'
        else:
            prev = now
            if now == 'r':  
                ret += P
            elif now == 's':
                ret += R
            else:
                ret += S
            
print(ret)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

print(6 - A - B)

Fixed submission:
A = int(input())
B = int(input())

print(6 - A - B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
binary = [0]*60
for inp in input().split():
    inp = bin(int(inp))[2:][::-1]
    for j, _inp in enumerate(inp):
        binary[j] += int(_inp)
    
ret = 0
pow2 = 1
for elem in binary:
    if elem == 0 or elem == N:
        pass
    else: 
        mn = elem * (N - elem) % (10**9 + 7)
        ret += pow2 * mn % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret % (10**9 + 7))

Fixed submission:
N = int(input())
binary = [0]*60
for inp in input().split():
    inp = bin(int(inp))[2:][::-1]
    for j, _inp in enumerate(inp):
        if _inp == '1':
            binary[j] += 1
    
ret = 0
pow2 = 1
for elem in binary:
    if elem == 0 or elem == N:
        pass
    else: 
        mn = elem * (N - elem) % (10**9 + 7)
        ret += pow2 * mn 
        ret = ret % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
binary = [0]*60
for i in input().split():
    i = bin(int(i))[2:][::-1]
    for j in range(len(i)):
        binary[j] += int(i[j])
    
ret = 0
pow2 = 1
for elem in binary:
    m = elem # m < 10**9 + 7
    n = (N - elem) # n < 10**9 + 7
    mn = m * n % (10**9 + 7)
    ret += pow2 * mn % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret % (10**9 + 7))

Fixed submission:
N = int(input())
binary = [0]*60
for inp in input().split():
    inp = bin(int(inp))[2:][::-1]
    for j, _inp in enumerate(inp):
        if _inp == '1':
            binary[j] += 1
    
ret = 0
pow2 = 1
for elem in binary:
    if elem == 0 or elem == N:
        pass
    else: 
        mn = elem * (N - elem) % (10**9 + 7)
        ret += pow2 * mn 
        ret = ret % (10**9 + 7)
    pow2 = pow2 * 2 % (10**9 + 7)
print(ret)
Buggy python submission (verdict: Runtime Error):
import sys

week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
today = input()

for i, day in enumerate(week):
  if day == today:
    print(7 - i)
	sys.exit()

Fixed submission:
import sys

week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
today = input()

for i, day in enumerate(week):
	if day == today:
		print(7 - i)
		sys.exit()
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

if len(S) % 2 != 0:
    print("No")
else:
    if S[:(len(S) / 2)] == S[(len(S) / 2) :]:
        print("Yes")
    else:
        print("No")

Fixed submission:
N = int(input())
S = input()

if len(S) % 2 != 0:
    print("No")
else:
    if S[:(len(S) // 2)] == S[(len(S) // 2) :]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np


MOD = 10**9 + 7

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)

    if (Y < X/2) or (Y > 2*X):
        print(0)
	else:
      
        h = (2 * X - Y) // 3
        v = (2 * Y - X) // 3

        def extgcd(a, b):
            if b == 0:
                x = 1
                y = 0
            else:
                y, x = extgcd(b, a%b)
                y -= a//b * x
            return x, y

        def low_inverse(a):
            ret, _ = extgcd(a, MOD)
            return ret

        def low_combination(m, n):
            # calculate (m+n)!/n!m!
            ret = 1
            numerator = m + n
            for i in range(min(m, n)):
                inv_i = low_inverse(i + 1)
                ret = ret * (numerator - i) * inv_i % MOD
            return ret

        print(low_combination(h, v))


Fixed submission:
import numpy as np


MOD = 10**9 + 7

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)

else:
    if (Y < X/2) or (Y > 2*X):
        print(0)
    
    else:
      
        h = (2 * X - Y) // 3
        v = (2 * Y - X) // 3

        def extgcd(a, b):
            if b == 0:
                x = 1
                y = 0
            else:
                y, x = extgcd(b, a%b)
                y -= a//b * x
            return x, y

        def low_inverse(a):
            ret, _ = extgcd(a, MOD)
            return ret

        def low_combination(m, n):
            # calculate (m+n)!/n!m!
            ret = 1
            numerator = m + n
            for i in range(min(m, n)):
                inv_i = low_inverse(i + 1)
                ret = ret * (numerator - i) * inv_i % MOD
            return ret

        print(low_combination(h, v))
Buggy python submission (verdict: Runtime Error):
import numpy as np

a, b, x = map(int, input().split())

bottom = 2 * x / a**2 - b
if bottom > 0:
    tan =  a / (b -  bottom)
    
else:
    bottom = 2 / (a * b) * x
    tan = bottom / b
    
theta = np.arctan(tan)
ret = 90 - np.rad2deg(theta)

print(ret)

Fixed submission:
import numpy as np

a, b, x = map(int, input().split())

bottom = 2 * x / a**2 - b

if bottom == b:
    print(0)

else:    
    if bottom > 0:
        tan =  a / (b -  bottom)

    else:
        bottom = 2 / (a * b) * x
        tan = bottom / b

    theta = np.arctan(tan)
    ret = 90 - np.rad2deg(theta)

    print(ret)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

ret = 0
for s, t in zip(S, T):
  is s == t:
    ret += 1
    
print(ret)

Fixed submission:
S = input()
T = input()

ret = 0
for s, t in zip(S, T):
  if s == t:
    ret += 1
    
print(ret)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())

print(max(max(A+B, A - B), A * B))

Fixed submission:
A, B = map(int, input().split())

print(max(max(A+B, A - B), A * B))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input.split())

if A % 2 == B % 2:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")

Fixed submission:
A, B = map(int, input().split())

if A % 2 == B % 2:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import sys


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    
    # heap queue
    h = [i for i in map(int, input().split())]
    h.sort()
    heapq.heapify(h)

    for i in range(M):
        B, C = map(int, input().split())
        for j in range(B):
            min_value = heapq.heappop(h)
            if min_value < C:
                heapq.heappush(h, C)
            else:
                heapq.heappush(h, min_value)
                break

    print(sum(h))


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from collections import defaultdict


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    
    A = defaultdict(int)
    for i in map(int, input().split()):
        A[i] += 1
        
    for i in range(M):
        B, C = map(int, input().split())
        A[C] += B
        
    ret = 0
    count = 0
    for value, num_value in sorted(A.items(), key=lambda x:x[0])[::-1]:
        num_value = min(num_value, N - count)
        ret += value * num_value
        count += num_value
        if num_value == N:
            break
    
    print(ret)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import heapq
import math
import queue
import sys


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    
    A = [i for i in map(int, input().split())]
    A.sort()

    for i in range(M):
        B, C = map(int, input().split())
        insert_index = bisect.bisect_left(A, C)
        A[insert_index:insert_index] = [C for i in range(B)]
        A = A[-N:]

    print(sum(A))


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from collections import defaultdict


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    
    A = defaultdict(int)
    for i in map(int, input().split()):
        A[i] += 1
        
    for i in range(M):
        B, C = map(int, input().split())
        A[C] += B
        
    ret = 0
    count = 0
    for value, num_value in sorted(A.items(), key=lambda x:x[0])[::-1]:
        num_value = min(num_value, N - count)
        ret += value * num_value
        count += num_value
        if num_value == N:
            break
    
    print(ret)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = input()
res = alphabet[alphabet.index(_) + n] for _ in s
print(res)

Fixed submission:
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = list(input())
res = "".join([alphabet[alphabet.index(_) + n] for _ in s])
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]

for _ in range(m):
  maxvalue = max(a) 
  maxindex = a.index(maxvalue)
  a[maxindex] = maxvalue / 2

print(sum([int(_) for _ in a]))
  

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
que = []
for _ in a:
  heapq.heappush(que, -1*_)

for _ in range(m):
  maxvalue = -1 * heapq.heappop(que)
  maxvalue /= 2
  heapq.heappush(que, -1*maxvalue)

print(sum([int(-1*_) for _ in que]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum([i for i in range(1, n)]))

Fixed submission:
n = int(input())
print("%d"%((n-1)*n//2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
restaurants_list = []
for _ in range(n):
  s, p = input().split()
  restaurants_list.append([s, p, _])
restaurants_list.sort()
for _ in range(n):
  print(restaurants_list[2])
  
  


Fixed submission:
n = int(input())
restaurants_list = []
for _ in range(n):
  s, p = input().split()
  restaurants_list.append([s, -int(p), _+1])
restaurants_list.sort()
for _ in range(n):
  print(restaurants_list[_][2])
Buggy python submission (verdict: Runtime Error):
print(list(str(intput())).count("1"))

Fixed submission:
print(list(str(input())).count("1"))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
now=a[0]
his=[now]
for i in range(20):
  now=a[now-1]
#  print(now)
  if i==k-1:
    quit()
  if now in his:
    first=his.index(now)
    last=i
    break
  his.append(now)
print(his[first+(k-first)%(last-first+1)-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
now=1
arr=[0]*(n+1)
for i in range(1,10**6):
  now=a[now-1]
  if i==k:
    print(now)
    quit()
  if arr[now]!=0:
    first=arr[now]
    break
  arr[now]=i
# print(arr)
cycle=max(arr)-first+1
# print(cycle)
mod=(k-first)%cycle
# print(mod)
ans=arr.index(first+mod)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(1,n-i):
        sum = a[i]+a[i+j]
        dif = j
        if sum==j:
            ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b = [0] * 10**6
ans=0
for i in range(n):
    if a[i]<(2*(10**5)):
        if i-a[i]>=0:
            ans+=b[i-a[i]]
        b[a[i]+i]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[]
for _ in range(q):
    a.append(int(input()))
for i in range(1,n+1):
    if k-(q-a.count(i))>0:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k,q=map(int,input().split())
cnt=[0]*n
for _ in range(q):
    cnt[int(input())-1]+=1
for i in range(n):
    if k-(q-cnt[i])>0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
for i in range(n):
    ans+=i
print(ans)

Fixed submission:
n=int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2001):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2002):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
for i in range(n):
    b=a[i]
    a.pop(i)
    print(max(a))
    a.insert(i,b)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
m=max(a)
midx=a.index(max(a))
l=sorted(a)[-2]
for i in range(n):
    if i==midx:
        print(l)
    else:
        print(m)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cc=math.floor(b/c)-math.ceil(a/c)+1
dd=math.floor(b/d)-math.ceil(a/d)+1
cd=math.floor(b/(lcm(c, d)))-math.ceil(a/(lcm(c, d)))+1

print(b-a+1-(cc+dd-cd))

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())

def lcm(x, y):
    return (x*y)//fractions.gcd(x, y)

def div(a, b, x):
    if a%x!=0:
        return b//x-a//x
    else:
        return b//x-(a//x-1)

print(int(b-a+1-(div(a,b,c)+div(a,b,d)-div(a,b,lcm(c,d)))))
Buggy python submission (verdict: Runtime Error):
n=int(input())
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)

Fixed submission:
n=int(input())
sp=[]
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    if int(sp[i][1])==0:
        sp[i][1]=float('inf')
    else:
        sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)
Buggy python submission (verdict: Runtime Error):
d,n=map(int,input().split())
print(100**d*n)d,n=map(int,input().split())
if n==100:
    print(100**d*(n+1))
else:
    print(100**d*n)

Fixed submission:
d,n=map(int,input().split())
if n==100:
    print(100**d*(n+1))
else:
    print(100**d*n)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
b=[]
while(1):
    if a[i]==1:
        print(ans)
        exit()
    elif i in b:
        print(-1)
        exit()
    else:
        b.append(i)
        i=a[i]
        ans+=1

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
b=[]
while(1):
    if ans==n:
        print(-1)
        exit()
    elif a[i]==1:
        print(ans)
        exit()
    else:
        ans+=1
        i=a[i]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
while(1):
    if a[i]==1:
        print(ans)
        exit()
    elif a[i]==0 or a[i]==i:
        print(-1)
        exit()
    else:
        i=a[i]
        ans+=1

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
b=[]
while(1):
    if ans==n:
        print(-1)
        exit()
    elif a[i]==1:
        print(ans)
        exit()
    else:
        ans+=1
        i=a[i]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
ans=1
i=0
while(1):
    if a[i]==2:
        print(ans)
        exit()
    elif a[i]==1 or a[i]-1==i:
        print(-1)
        exit()
    else:
        i=a[i]-1
        ans+=1

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
b=[]
while(1):
    if ans==n:
        print(-1)
        exit()
    elif a[i]==1:
        print(ans)
        exit()
    else:
        ans+=1
        i=a[i]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
ans=1
i=0
while(1):
    if a[i]==2:
        print(ans)
        exit()
    elif a[i]==1:
        print(-1)
        exit()
    else:
        i=a[i]-1
        ans+=1

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
ans=1
i=0
b=[]
while(1):
    if ans==n:
        print(-1)
        exit()
    elif a[i]==1:
        print(ans)
        exit()
    else:
        ans+=1
        i=a[i]