Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
while True:
    max2 = -heappop(hq)
    if max2 != max1:
        break
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")


Fixed submission:
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
max2 = -heappop(hq)
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    if A[i] not in hq:
        heappush(hq, -A[i])
max1 = -heappop(hq)
max2 = -heappop(hq)
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")


Fixed submission:
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
max2 = -heappop(hq)
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) * 2
B = [0] * N
for i in range(N):
    B[i] = sum(A[i:i+N:2]) - sum(A[i+1:i+N:2])
print(*B)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
B[0] = sum(A[::2]) - sum(A[1::2])
for i in range(1, N):
    B[i] = 2 * A[i - 1] - B[i - 1]
print(*B)
Buggy python submission (verdict: Runtime Error):
from math import factorial as fac

N, K = map(int, input().split())


def func(n, k, r):
    return (fac(k - 1) * fac(n - k + 1) // (fac(k - r) * fac(r - 1) * fac(n - k - r + 1) * fac(r)))


for i in range(1, K + 1):
    print(func(N, K, i) % (10 ** 9 + 7))


Fixed submission:
from math import factorial as fac

N, K = map(int, input().split())


def func(n, k, r):
    return (fac(k - 1) * fac(n - k + 1) // (fac(k - r) * fac(r - 1) * fac(n - k - r + 1) * fac(r)))


for i in range(1, K + 1):
    if N-K+1>=i:
        print(func(N, K, i) % (10 ** 9 + 7))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
from math import gcd

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)


Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count = 3 * 10 ** 5
for i in range(N):
    count_tmp = 0
    count_tmp += S[:i].count("W")
    count_tmp += S[i+1:].count("E")
    count = min(count, count_tmp)
print(count)


Fixed submission:
N = int(input())
S = input()
ans = cnt = S[1:].count("E")
for i in range(1, N):
    if S[i] == "E":
        cnt -= 1
    if S[i - 1] == "W":
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count = 3 * 10 ** 5
for i in range(N):
    count_tmp = 0
    for j in range(N):
        if j < i:
            if S[j] != "E":
                count_tmp += 1
        elif j > i:
            if S[j] != "W":
                count_tmp += 1
    count = min(count, count_tmp)
print(count)

Fixed submission:
N = int(input())
S = input()
ans = cnt = S[1:].count("E")
for i in range(1, N):
    if S[i] == "E":
        cnt -= 1
    if S[i - 1] == "W":
        cnt += 1
    ans = min(ans, cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
ans = 10**9
N=int(input())
A=list(map(int,input().split()))
for i in A:
    p=0
    while i%2==0:
        i //= 2
        p += 1
    if p<ans:
        ans=p
print(ans)a


Fixed submission:
ans = 10**9
N=int(input())
A=list(map(int,input().split()))
for i in A:
    p=0
    while i%2==0:
        i //= 2
        p += 1
    if p<ans:
        ans=p
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re

def C():
    n = input()
    s = input()
    ss = ""
    for i in range(len(s)):
        if i != 0:
            if s[i] != s[i-1]:
                ss += s[i]
        else:
            ss += s[i]
    print(len(ss))

if __name__ == '__main__':
    C()
    

Fixed submission:
import re

def C():
    n = input()
    s = input()
    ss = re.sub(r"(.)\1{1,}",r"\1",s)
    print(len(ss))

if __name__ == '__main__':
    C()
Buggy python submission (verdict: Runtime Error):
def main():
    n = input()
    a = list(map(lambda x:int(x),input().split(" ")))
    res = ""
    res = [str(a.index(i+1) + 1) for i in range(len(a))]
    print(" ".join(res))

if __name__ == '__main__':
    main()

Fixed submission:
def myinput(rownum):
    res = []
    for i in range(rownum):
        temp = input().split(" ")
        res += temp
    return res

def main():
    r = int(myinput(1)[0])
    if r == 1:
        print(1)
    elif r % 2 == 0:
        print(0.5)
    else:
        print((int(r/2)+1)/r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def main():
    n = int(input())
    s = [input() for i in range(n)]
    e = []
    for i in range(n):
        word = [0] * 200
        for w in s[i]:
            word[ord(w)] += 1

        e.append(word)

    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if e[i] == e[j]:
                ans += 1
    print(ans)

main()


Fixed submission:
# coding: utf-8

def main():
    n = int(input())
    l = ["".join(sorted(input())) for i in range(n)]

    c = {}
    ans = 0
    for s in l:
        if s in c:
            c[s] = c[s] + 1
        else:
            c[s] = 0
        ans += c[s]

    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    l = [map(int, raw_input().split()) for _ in xrange(m)]

    la = []
    lb = []
    for ab in l:
        if ab[0] == 1:
            la.append(ab[1])
        if ab[1] == n:
            lb.append(ab[0])

    for a in la:
        if a in lb:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()


Fixed submission:
# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    s = [0] * 200010
    t = [0] * 200010
    for _ in xrange(m):
        a, b = map(int, raw_input().split())
        if a == 1:
            s[b] = True
        if b == n:
            t[a] = True

    for i in xrange(1, n+1):
        if s[i] and t[i]:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    l = [map(int, raw_input().split()) for _ in xrange(m)]

    la = [ab[0] for ab in l if ab[1] == n]

    for ab in l:
        if ab[0] == 1 and ab[1] in la:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()


Fixed submission:
# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    s = [0] * 200010
    t = [0] * 200010
    for _ in xrange(m):
        a, b = map(int, raw_input().split())
        if a == 1:
            s[b] = True
        if b == n:
            t[a] = True

    for i in xrange(1, n+1):
        if s[i] and t[i]:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def add_list(_n):
    _l = []
    for _ in range(_n):
        a, b = map(int, raw_input().split())
        _l.append([a for _ in range(b)])
    return [j for i in _l for j in i]

n, k = map(int, raw_input().split())
l = add_list(n)
l.sort()
print l[k-1]


Fixed submission:
# coding: utf-8

l = 10 ** 5
num = [0] * (l + 1)
n, k = map(int, raw_input().split())

for _ in xrange(n):
    a, b = map(int, raw_input().split())
    num[a] += b

for i in xrange(1, l+1):
    k -= num[i]
    if k <= 0:
        print i
        break

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def add_list(_n):
    _l = []
    for _ in range(_n):
        a, b = map(int, raw_input().split())
        for i in range(b):
            _l.append(a)
    return _l

n, k = map(int, raw_input().split())
l = add_list(n)
l.sort()

print l[k-1]


Fixed submission:
# coding: utf-8

l = 10 ** 5
num = [0] * (l + 1)
n, k = map(int, raw_input().split())

for _ in xrange(n):
    a, b = map(int, raw_input().split())
    num[a] += b

for i in xrange(1, l+1):
    k -= num[i]
    if k <= 0:
        print i
        break
Buggy python submission (verdict: Runtime Error):
# encoding: utf-8

n, x = map(int, raw_input().split())

ac_bc = n - x
s = ac_bc / 3
l = ac_bc - s
print ac_bc + s * 3 + l * 3

Fixed submission:
# encoding: utf-8

n = int(raw_input())
l = map(int, raw_input().split())
l.sort()
print sum(l[::2])
Buggy python submission (verdict: Runtime Error):
a = input()
l = map(int, raw_input().split())

def gcd(l):
	m = max(l)
	r = 0
	for i in range(1, m + 1):
		f = 0
		for j in l:
			if j % i != 0:
				f += 1
			if f > 1:
				break
		if f <= 1:
			r = i
	return r 

print gcd(l)

Fixed submission:
a = input()
l = map(int, raw_input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def gcd(l):
	l = sorted(l, reverse=True)
	l1 = make_divisors(l[0])
	l2 = make_divisors(l[1])
	l_mix = list(set(l1 + l2))
	l_mix = sorted(l_mix)
	r = 0
	for i in l_mix:
		f = 0
		for j in l:
			if j % i != 0:
				f += 1
			if f > 1:
				break
		if f <= 1:
			r = i
	return r 

print gcd(l)
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
s = map(int, raw_input().split())

l = []

if a % 2 == 0:
	for i in range(a):
		if i % 2 == 1:
			l.insert(0, s[i])
		else:
			l.append(s[i])
else:
	for i in range(a):
		if i % 2 == 0:
			l.insert(0, s[i])
		else:
			l.append(s[i])

for i in l:
	print i,

Fixed submission:
a = input()
s = map(int, raw_input().split())

l1 = []
l2 = []

if a % 2 == 0:
	for i in range(a):
		if i % 2 == 1:
			l2.append(s[i])
		else:
			l1.append(s[i])
else:
	for i in range(a):
		if i % 2 == 0:
			l2.append(s[i])
		else:
			l1.append(s[i])

for i in reversed(l2):
	print i,

for i in l1:
	print i,
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, raw_input().spilt())
if (b * 10 + c) % 4 == 0:
	print "YES"
else:
	print "NO"

Fixed submission:
a, b, c = map(int, raw_input().split())
if (b * 10 + c) % 4 == 0:
	print "YES"
else:
	print "NO"
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

def solve(hp, count):
	q = hp - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(hp, m):
		r = m
	else:
		l = m

if r == 2:
	if solve(hp, 1):
		r = 1

print r

Fixed submission:
a, b = map(int, raw_input().split())

if a + b >= 10:
	print 'error'
else:
	print a + b
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
l1 = []

for i in range(n):
	t = input()
	l1.append(t)

l2 = sorted(l1)

s = []

for i in range(n):
	if i % 2 == 1:
		s.append(l1[i])

count = 0

for i in range(n):
	if i % 2 == 1:
		if l2[i] not in s:
			count += 1

print count


Fixed submission:
n = input()
l1 = []

for i in range(n):
	t = input()
	l1.append(t)

l2 = sorted(l1)

s1, s2 = set([]), set([])

for i in range(n):
	if i % 2 == 1:
		s1.add(l1[i])
		s2.add(l2[i])

print len(s1) - len(s1.intersection(s2))
Buggy python submission (verdict: Runtime Error):
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    elif S == "Rainy":
        ans == "Sunny"
    
    print(ans)
solve()

Fixed submission:
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    elif S == "Rainy":
        ans = "Sunny"
    
    print(ans)
solve()

Buggy python submission (verdict: Runtime Error):
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    else S == "Rainy":
        ans == "Sunny"
    
    print(ans)
solve()

Fixed submission:
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    elif S == "Rainy":
        ans = "Sunny"
    
    print(ans)
solve()
Buggy python submission (verdict: Time Limit Exceeded):
inf = 10**9+7
modlist = [1, 10, 9, 12, 3, 4]

S = list(input())
S.reverse()

dp = [[0 for i in range(13)] for j in range(len(S))]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1,len(S)):
    for l in range(10):
        if S[i] != "?" and int(S[i]) != l:
            continue
        for j in range(13):
            dp[i][(l*modlist[i%6]+j)%13] += dp[i-1][j]
            dp[i][(l*modlist[i%6]+j)%13] %= inf

ans = dp[len(S)-1][5]
print(ans)

Fixed submission:
inf = 10**9+7
modlist = [1, 10, 9, 12, 3, 4]

S = list(input())
S.reverse()

dp = [[0 for i in range(13)] for j in range(len(S))]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1,len(S)):
    for l in range(10):
        if S[i] != "?" and int(S[i]) != l:
            continue
        for j in range(13):
            dp[i][(l*modlist[i%6]+j)%13] += dp[i-1][j]
            dp[i][(l*modlist[i%6]+j)%13] %= inf

ans = dp[len(S)-1][5]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3] or S[3]==S[4]:
    print("Bad")
else:
    print("Good")

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
N = int(input())
F = []
for i in range(N):
    F_temp = list(map(int, input().split()))
    F.append(F_temp)
P = []
for i in range(N):
    P_temp = list(map(int, input().split()))
    P.append(P_temp)

ans = -1000000000

for i in range(1,1024):
    F0 = [0]*10
    i_temp = i
    for j in range(10):
        F0[j] = i_temp%2
        i_temp = int(i_temp/2)
    
    c = [0]*10
    for j in range(10):
        if F0[j] == 1:
            for k in range(N):
                c[k] += F[k][j]
    
    ans_temp = 0
    for j in range(N):
        ans_temp += P[j][c[j]]
    ans = max(ans, ans_temp)

print(ans)

Fixed submission:
N = int(input())
F = []
for i in range(N):
    F_temp = list(map(int, input().split()))
    F.append(F_temp)
P = []
for i in range(N):
    P_temp = list(map(int, input().split()))
    P.append(P_temp)

ans = -1000000000

for i in range(1,1024):
    F0 = [0]*10
    i_temp = i
    for j in range(10):
        F0[j] = i_temp%2
        i_temp = int(i_temp/2)
    
    c = [0]*N
    for j in range(10):
        if F0[j] == 1:
            for k in range(N):
                c[k] += F[k][j]
    
    ans_temp = 0
    for j in range(N):
        ans_temp += P[j][c[j]]
    ans = max(ans, ans_temp)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
s = [sorted(input()) for i in range(n)]
cnt = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            cnt += 1
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
d = {}
ans = 0
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
for string in s:
    if string in d:
        ans += d[string]
        d[string] += 1
    else:
        d[string] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
s = [input() for i in range(n)]
cnt = 0
for i in range(0, n-1):
    s[i] = sorted(s[i])
    for j in range(i+1, n):
        s[j] = sorted(s[j])
        if s[i] == s[j]:
            cnt += 1
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
d = {}
ans = 0
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
for string in s:
    if string in d:
        ans += d[string]
        d[string] += 1
    else:
        d[string] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
s = [input() for i in range(n)]
cnt = 0
for i in range(0, n-1):
    stype1 = {}
    for j in range(10):
        if s[i][j] in stype1:
            stype1[s[i][j]] += 1
        else:
            stype1[s[i][j]] = 1
    for k in range(i+1, n):
        stype2 = {}
        for l in range(10):
            if s[k][l] in stype2:
                stype2[s[k][l]] += 1
            else:
                stype2[s[k][l]] = 1
        if stype1 == stype2:
            cnt += 1
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
d = {}
ans = 0
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
for string in s:
    if string in d:
        ans += d[string]
        d[string] += 1
    else:
        d[string] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
cnt = 0
for i in range(0, n-1):
    stype1 = {}
    for j in range(len(s[i])):
        if s[i][j] in stype1 :
            stype1[s[i][j]] += 1
        else:
            stype1[s[i][j]] = 1
    for k in range(i+1, n):
        stype2 = {}
        for l in range(len(s[k])):
            if s[k][l] in stype2:
                stype2[s[k][l]] += 1
            else:
                stype2[s[k][l]] = 1
        if stype1 == stype2:
            cnt += 1
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
d = {}
ans = 0
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
for string in s:
    if string in d:
        ans += d[string]
        d[string] += 1
    else:
        d[string] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
conb = 0
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if ((i*r) + (j*g) + (k*b)) == n:
                conb += 1
print(conb)

Fixed submission:
r, g, b, n = map(int, input().split())
conb = 0
for i in range(n+1):
    for j in range(n+1):
        k = (n-(i*r)-(j*g))
        if ((i*r) + (j*g) + k) == n and k % b == 0 and k >= 0:
            conb += 1
print(conb)
Buggy python submission (verdict: Runtime Error):
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
if mini == 0:
    mini = dish[0]
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)


Fixed submission:
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
if mini == 0:
    mini = dish[0]
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)

Buggy python submission (verdict: Runtime Error):
import math
dish = []
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)


Fixed submission:
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
if mini == 0:
    mini = dish[0]
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
cnt = 0
yen = 0

sortkey = lambda val: val[0]
AB.sort(key=sortkey)

for i in range(N):
    for j in range(int(AB[i][1])):
        cnt += 1
        yen += AB[i][0]
        if cnt == M:
            print(yen)
            break


Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
cnt = 0
yen = 0

sortkey = lambda val: val[0]
AB.sort(key=sortkey)

for i in range(N):
    if M >= AB[i][1]:
        cnt += AB[i][1]
        yen += AB[i][0] * AB[i][1]
        M -= AB[i][1]
    elif M < AB[i][1]:
        cnt += M
        yen += AB[i][0] * M
        M = 0
    if M == 0:
        print(yen)
        break
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if k == 1:
    print(1)
else:
    num = []
    mini = min(a, b)
    for i in range(1, mini):
        if mini % i == 0:
            num.append(i)
    num.sort()
    print(num[k-1])

Fixed submission:
a, b, k = map(int, input().split())
num = []
mini = min(a, b)
for i in range(1, mini+1):
    if a % i == 0 and b % i == 0:
        num.append(i)
num.sort()
num.reverse()
print(num[k-1])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num = []
mini = min(a, b)
for i in range(1, mini):
    if mini % i == 0:
        num.append(i)
num.sort()
print(num[k-1])

Fixed submission:
a, b, k = map(int, input().split())
num = []
mini = min(a, b)
for i in range(1, mini+1):
    if a % i == 0 and b % i == 0:
        num.append(i)
num.sort()
num.reverse()
print(num[k-1])
Buggy python submission (verdict: Runtime Error):
x = map(int, input().split())
x[0] = -1*x[0]
print(sum(x))

Fixed submission:
x = list(map(int, input().split()))
x[0] = -1*x[0]
print(max(sum(x), 0))
Buggy python submission (verdict: Runtime Error):
N = input()
count = 0
for i in range(N):
  if len(str(i+1)) % 2 == 1:
    count += 1
print(count)

Fixed submission:
N = int(input())
count = 0
for i in range(N):
  if len(str(i+1)) % 2 == 1:
    count += 1
print(count)