Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]
from itertools import permutations
#%%
import math
INF = 1<<30
ans = INF
A = [i for i in range(D)]

permu = permutations(A)

for pp in permu:
    points = 0
    count = 0
    for i in pp:
        if points>=G:
            break
        if points+(i+1)*100*pc[i][0]>=G:
            count += math.ceil((G-points)/(100*(i+1)))
            break
        else:
            count += pc[i][0]
            points += (i+1)*100*pc[i][0]+pc[i][1]
        
    ans = min(ans,count)

print(ans)

Fixed submission:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]
from itertools import permutations
#%%
import math
INF = 1<<30
ans = INF
A = [i for i in range(D)]

permu = permutations(A)

for pp in permu:
    points = 0
    count = 0
    for i in pp:
        if points>=G:
            break
        if points+(i+1)*100*pc[i][0]>=G:
            count += math.ceil((G-points)/(100*(i+1)))
            break
        else:
            count += pc[i][0]
            points += (i+1)*100*pc[i][0]+pc[i][1]
        
    ans = min(ans,count)

print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
abc = [A,B,C]
Even = []
Odd = []
for i in range(3):
    if min(abc) == abc[i]:
        idx1 = i
    elif max(abc) == abc[i]:
        idx3 = i
    else:
        idx2 = i
    if abc[i]%2 == 0:
       Even += [i]
    else:
       Odd += [i]
       
ans = 0

if len(Even) == 3 or len(Odd) == 3:
    ans = (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Even) == 2:
    ans += 1
    abc[Even[0]] += 1
    abc[Even[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Odd) == 2:
    ans += 1
    abc[Odd[0]] += 1
    abc[Odd[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
    
print(ans)
    



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

def GCD(a,b):
    c = a%b
    if c == 0:
        return b
    else:
        return GCD(b,c)


def modsum(m):
    s = 0
    for a in A:
        s += m % a
    return s


tmp = 1
for i in range(N):
    tmp = tmp * A[i] // GCD(tmp,A[i])
    
ans = modsum(tmp-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

l1 = 2 ** 30
p6 = [1] * 6
p9 = [1] * 5
for i in range(1,7):
    p6[i] = p6[i-1] * 6
    if i < 6 : p9[i] = p9[i-1] * 9

dp = [l1] * (N+1)
dp[0] = 0

for i in range(1,N+1):
    for j in p6:
        if j>i: break
        dp[i] = min(dp[i],dp[i-j]+1)
        
    for j in p9:
        if j>i: break
        dp[i] = min(dp[i],dp[i-j]+1)
        
print(dp[N])

Fixed submission:
N = int(input())

l1 = 2 ** 30
p6 = [1] * 7
p9 = [1] * 6
for i in range(1,7):
    p6[i] = p6[i-1] * 6
    if i < 6 : p9[i] = p9[i-1] * 9

dp = [l1] * (N+1)
dp[0] = 0

for i in range(1,N+1):
    for j in p6:
        if j>i: break
        dp[i] = min(dp[i],dp[i-j]+1)
        
    for j in p9:
        if j>i: break
        dp[i] = min(dp[i],dp[i-j]+1)
        
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
A = list(map(int,input().split()))
#%%
bi = [[0]*20 for _ in range(N)]

state = [False]*20

for i,a in enumerate(A):
    tmp = a
    idx = 0
    while tmp>0:
        bi[i][idx] = tmp%2
        tmp >>= 1
        idx += 1

ans = 0
left = 0
right = 1

def upt(state,b):
    for i in range(20):
        if b[i]:
            state[i] = True
    return state
    
def rmv(state,b):
    for i in range(20):
        if b[i]:
            state[i] = False
    return state

def judge(state,b):
    for i in range(20):
        if state[i] and b[i]:
            return False
    return True

state = upt(state,bi[0])
#%%
while right<N:
    if judge(state,bi[right]):
        state = upt(state,bi[right])
        right += 1
    else:
        ans += right-left
        state = rmv(state,bi[left])
        left += 1

L = right - left
ans += L*(L+1)//2

print(ans)

Fixed submission:

N = int(input())
A = list(map(int,input().split()))
#%%
bi = [[0]*20 for _ in range(N)]

state = [False]*20

for i,a in enumerate(A):
    tmp = a
    idx = 0
    while tmp>0:
        bi[i][idx] = tmp%2
        tmp >>= 1
        idx += 1

ans = 0
left = 0
right = 1

def upt(state,b):
    for i in range(20):
        if b[i]:
            state[i] = True
    return state
    
def rmv(state,b):
    for i in range(20):
        if b[i]:
            state[i] = False
    return state

def judge(state,b):
    for i in range(20):
        if state[i] and b[i]:
            return False
    return True

state = upt(state,bi[0])
#%%
while right<N:
    if judge(state,bi[right]):
        state = upt(state,bi[right])
        right += 1
    else:
        ans += right-left
        state = rmv(state,bi[left])
        left += 1

L = right - left
ans += L*(L+1)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

East = [0] * N
West = [0] * N

for i,s in enumerate(list(S)):
    if s == 'W' : 
        if i==0:
            East[i] = 1
        else:
            East[i] = East[i-1] + 1
    else:
        East[i] = East[i-1]
i = N-1
for s in reversed((list(S))):
    if s == 'E' : 
        if i==N-1:
            West[i] = 1
        else:
            West[i] = West[i+1] + 1
    else:
        West[i] = West[i+1]
    i -= 1
            
ans = 2**31-1

for i in range(N):
    if i == 1:
        ans2 = West[1]
    elif i == N-1:
        ans2 = East[N-2]
    else:
        ans2 = East[i-1]+West[i+1]
    ans = min(ans,ans2)
    
print(ans)
    

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

East = [0] * N
West = [0] * N

for i,s in enumerate(list(S)):
    if s == 'W' : 
        if i==0:
            East[i] = 1
        else:
            East[i] = East[i-1] + 1
    else:
        if i == 0:
            East[i] = 0
        else:
            East[i] = East[i-1]
i = N-1
for s in reversed((list(S))):
    if s == 'E' : 
        if i==N-1:
            West[i] = 1
        else:
            West[i] = West[i+1] + 1
    else:
        if i == N-1:
            West[i] = 0
        else:
            West[i] = West[i+1]
    i -= 1
            
ans = 2**31-1

for i in range(N):
    if i == 1:
        ans2 = West[1]
    elif i == N-1:
        ans2 = East[N-2]
    else:
        ans2 = East[i-1]+West[i+1]
    ans = min(ans,ans2)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
money = A+B
if C>money:
    print('No')
else:
    print('Yes)

Fixed submission:
A,B,C = map(int,input().split())
money = A+B
if C>money:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):

H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]


numlist = [[0,0]] * (H*W+1)
for i in range(H):
    for j in range(W):
        numlist[A[i][j]] = [i,j]

'''
ruisekiwa = [0] * (H*W+1)
tmp = 0
x,y = numlist[1]

for i in range(2,H*W+1):
    x2,y2 = numlist[i]
    tmp += abs(x-x2)+abs(y-y2)
    x,y = x2,y2
    ruisekiwa[i] = tmp
'''  

for i in range(Q):
    ans = 0
    start,goal = LR[i]
    x,y = numlist[start]
    xg,yg = numlist[goal]
    now = start
    while now != goal:
        now += D
        xn,yn = numlist[now]
        ans += abs(x-xn) + abs(y-yn)
        x,y = xn,yn
        
    print(ans)
    
    

Fixed submission:

H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]


numlist = [[0,0]] * (H*W+1)
for i in range(H):
    for j in range(W):
        numlist[A[i][j]] = [i,j]

ruisekiwa = [0] * (H*W+1)
for d in range(1,D+1):
    x,y = numlist[d]
    tmp = 0
    for i in range(d,H*W+1,D):
        x2,y2 = numlist[i]
        tmp += abs(x-x2)+abs(y-y2)
        x,y = x2,y2
        ruisekiwa[i] = tmp

for i in range(Q):
    start,goal = LR[i]
    ans = ruisekiwa[goal] - ruisekiwa[start]
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5:
        ans += 1
        del a[i]
        
import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5:
        ans += 1
        del a[i]
        
import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[a] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5+1:
        del a[i]
        ans += 1
        
counts = [0] * (10 ** 5 + 1)

for i in range(len(a)):
    counts[a[i]] += 1
    
for i in range(1,len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))

nlist = [0] * N
for i in A:
    nlist[i] += 1

nlist.sort(reverse = True)
cnt = 0
for i in range(K,N):
    if nlist[i] == 0: break
    cnt += nlist[i]

print(cnt)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))

nlist = [0] * N
for i in A:
    nlist[i-1] += 1

nlist.sort(reverse = True)
cnt = 0
for i in range(K,N):
    if nlist[i] == 0: break
    cnt += nlist[i]

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = list(map(int,input().split()))

T = [0]*13
T[0] = 1
for d in D:
    T[d] += 1


Times = [0]*24
ones =[]
for i,t in enumerate(T):
    if t>=3 or t==2 and (i==0 or i==12):
        print(0)
        exit()
    elif t==2:
        Times[i] = 1
        Times[24-i] = 1
    elif t==1:
        ones.append(i)

ans = 0
L = len(ones)
for i in range(2**L):
    stats = [False]*L
    temp = i
    for j in range(L):
        stats[j] = temp&1
        temp >>= 1
    
    newTime = [t for t in Times]
    res = 10**9
    for j,t in enumerate(ones):
        nt = t if stats[j] else 24-t
        newTime[nt] += 1
    
    gaps = []
    for j,t in enumerate(newTime):
        if t==1:
            gaps.append(j)
    for j in range(len(gaps)-1):
        res = min(res,gaps[j+1]-gaps[j])
    if len(gaps)>=2:
        res = min(res, gaps[0]+24-gaps[1])
    ans = max(ans, res)
print(ans)



Fixed submission:
N = int(input())
D = list(map(int,input().split()))

T = [0]*13
T[0] = 1
for d in D:
    T[d] += 1


Times = [0]*24
ones =[]
for i,t in enumerate(T):
    if t>=3 or (t==2 and (i==0 or i==12)):
        print(0)
        exit()
    elif t==2:
        Times[i] = 1
        Times[24-i] = 1
    elif t==1:
        ones.append(i)

ans = 0
L = len(ones)
for i in range(2**L):
    stats = [False]*L
    temp = i
    for j in range(L):
        stats[j] = temp&1
        temp >>= 1
    
    newTime = [t for t in Times]
    res = 10**9
    for j,t in enumerate(ones):
        nt = t if stats[j] else (24-t)%24
        newTime[nt] = 1
    
    gaps = []
    for j,t in enumerate(newTime):
        if t!=0:
            gaps.append(j)
    for j in range(len(gaps)-1):
        res = min(res,min(gaps[j+1]-gaps[j],gaps[j]+24-gaps[j+1]))
    if len(gaps)>=2:
        res = min(res, gaps[0]+24-gaps[-1])
    ans = max(ans, res)
print(ans)
Buggy python submission (verdict: Runtime Error):

H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]


inf = 10**9+7

point = [inf] * 10


for i in range(10):
    tmp = 0
    for j in range(10):
        tmp += C[i][j]
        point[i] = min(point[i],tmp+C[j][1])
        
ans = 0
for i in range(H):
    for j in range(W):
        if H[i][j] != -1:
            ans += point[H[i][j]]
            
print(ans)

Fixed submission:
H,W = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

N  = 10
d = c
for k  in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

ans = 0
for aa in A:
    for a in aa:
        if a!=-1:
           ans += d[a][1]
           
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
#S = list('??p??d??')
#T = list('abc')

Ns = len(S)
Nt = len(T)
flag = True
for i in range(Ns - Nt+1):
    for j in range(Nt):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        break

if flag:
    
    ans = S
    for j in range(Nt):
        ans[i+j] = T[j]

    for k in range(Ns):
        if ans[k] == '?':
            ans[k] = 'a'
    ans = ''.join(ans)
else:
    ans = 'UNRESTORABLE'
    
print(ans)


Fixed submission:

S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
Ns = len(S)
Nt = len(T)
ans = S
flag = True
for i in range(Ns - Nt+1):
    for j in range(Nt):
        if not(S[i+j] == T[i+j] or S[i+j] == '?'):
            break
    else:
        flag = True
        break

if flag:
    for j in range(Nt):
        ans[i+j] = T[j]

    for k in range(Ns):
        if ans[k] == '?':
            ans[k] = 'a'
    ans = ''.join(ans)
else:
    ans = 'UNRESTORABLE'
    
print(ans)


Fixed submission:

S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if (N*h*n)%(4*h*n-N*(h+n)) == 0:
            w = N*h*n // (4*h*n-N*(h+n))
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)

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

for h in range(1,3501):
    for n in range(1,3501):
        tmp = 4*h*n-N*(h+n)
        if tmp == 0:continue
        if (N*h*n)%(tmp) == 0:
            w = N*h*n // (tmp)
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)
Buggy python submission (verdict: Runtime Error):

N = int(input())
P = list(map(int,input().split()))
#PS = [i for i in range(1,N+1)]

cnt = 0
i = 0
idx = []
while i < N:
    if P[i] == i+1:
        if P[i+1] == i+2:
            cnt += 1
            i += 1
        else:
            cnt += 1
                   
    i += 1   
print(cnt)
    
    

Fixed submission:

N = int(input())
P = list(map(int,input().split()))
#PS = [i for i in range(1,N+1)]

cnt = 0
i = 0
while i < N:
    if P[i] == i+1:
        if i < N-1 and P[i+1] == i+2:
            cnt += 1
            i += 1
        else:
            cnt += 1
                   
    i += 1   
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x1 = max(a,b)
    x2 = min(a,b)
    x3 = x1 % x2
    if x3 == 0:
        return x2
    N = GCD(x2,x3)
    return N
        
ans = T[0]
tmp = ans
for i in range(1,N):
    ans = tmp * T[i] / GCD(tmp,T[i])
    tmp = ans

print(int(ans))
    

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x3 = a % b
    if x3 == 0:
        return min(a,b)
    N = GCD(b,x3)
    return N

def lcm(a,b):
    return a*b // GCD(a,b)
        
ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i]) 

print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x1 = max(a,b)
    x2 = min(a,b)
    x3 = x1 % x2
    if x3 == 0:
        return x2
    else:
        return GCD(x2,x3)
        
ans = T[0]
tmp = ans
for i in range(1,N):
    ans = tmp * T[i] / GCD(tmp,T[i])
    tmp = ans

print(int(ans))
    

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x3 = a % b
    if x3 == 0:
        return min(a,b)
    N = GCD(b,x3)
    return N

def lcm(a,b):
    return a*b // GCD(a,b)
        
ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i]) 

print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x1 = max(a,b)
    x2 = min(a,b)
    x3 = x1 % x2
    if x3 == 0:
        return x2
    else:
        return GCD(x2,x3)
        
ans = T[0]
for i in range(1,N):
    ans = ans * T[i] / GCD(ans,T[i])

print(int(ans))
    

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def GCD(a,b):
    x3 = a % b
    if x3 == 0:
        return min(a,b)
    N = GCD(b,x3)
    return N

def lcm(a,b):
    return a*b // GCD(a,b)
        
ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i]) 

print(int(ans))
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]

left = 1
right = max(h)//A + 1
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)
    


Fixed submission:
N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]

left = 1
right = max(h)
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]

L = []
for i in range(N):
    
    L += [ab[i][0]] * ab[i][1]
    
L.sort()
print(L[K-1])
    
    

Fixed submission:
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]

ab.sort(key = lambda x:x[0])
idx = 0
i = 0
while True:
    if idx + ab[i][1] > K-1:
        ans = ab[i][0]
        break
    else:
        idx += ab[i][1]
    i += 1
    


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]

L = []
for i in range(N):
    
    L += [ab[i][0]] * ab[i][1]
    
L.sort()
print(L[K-1])
    
    

Fixed submission:
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]

ab.sort(key = lambda x:x[0])
idx = 0
i = 0
while True:
    if idx + ab[i][1] > K-1:
        ans = ab[i][0]
        break
    else:
        idx += ab[i][1]
    i += 1
    


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

N = int(input())
S = [input() for _ in range(N)]
a2n = lambda c: ord(c) - ord('a')
n2a = lambda c: chr(c+97)

inf = 2 ** 30 - 1
idxs = [[0]*26 for _ in range(26)]
idx = [inf] * 26

for i in range(N):
    for s in S[i]:
        idxs[i][a2n(s)] += 1

for i in range(26):
    for j in range(N):
        idx[i] = min(idx[i],idxs[j][i])
        
ans = ''
for i in range(26):
    for j in range(idx[i]):
        ans += n2a(i)
print(ans)
        




Fixed submission:

N = int(input())
S = [input() for _ in range(N)]
a2n = lambda c: ord(c) - ord('a')
n2a = lambda c: chr(c+97)

inf = 2 ** 30 - 1
idxs = [[0]*26 for _ in range(N)]
idx = [inf] * 26

for i in range(N):
    for s in S[i]:
        idxs[i][a2n(s)] += 1

for i in range(26):
    for j in range(N):
        idx[i] = min(idx[i],idxs[j][i])
        
ans = ''
for i in range(26):
    for j in range(idx[i]):
        ans += n2a(i)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
import collections
import numpy as np
import sys
count = collections.Counter(A)
loops = np.arange(N-1,-1,-2)

for li in list(loops):
    if li == 0 :
        if count[li] != 1:break
    else:
        if count[li] != 2:break

else:
    b = N//2
    ans = 1
    for i in range(1,b+1):
        ans *= 2
        ans %= mod
    print(ans)   
    sys.exit(1)

print(0)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
import collections
import numpy as np
import sys
count = collections.Counter(A)
loops = np.arange(N-1,-1,-2)

for li in list(loops):
    if li == 0 :
        if count[li] != 1:break
    else:
        if count[li] != 2:break

else:
    b = N//2
    ans = 1
    for i in range(1,b+1):
        ans *= 2
        ans %= mod
    print(ans)   
    sys.exit()

print(0)