Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = int(input());
b = int(input());

if (a >= 1 and a <= 9 and b >= 1 and b <= 9):
  print(a*b)
else:
  print("-1")


Fixed submission:
import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    a, b = rinput()
    if a >= 10 or b >= 10:
        print(-1)
    else:
        print(a * b)
main()

Buggy python submission (verdict: Runtime Error):
A=variable
B=variable_2
A=1
B=1
C=A*B
while A and B <= 9;
	print(A*B)
	A=A+1
	B=B+1
print(A*B)

Fixed submission:
import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    a, b = rinput()
    if a >= 10 or b >= 10:
        print(-1)
    else:
        print(a * b)
main()

Buggy python submission (verdict: Runtime Error):
def main(a, b):
    if a>9:
        return -1
    if b>9:
        return -1
        
    return a*b

inp = input().split();
a = int(inp[0])
b = int(inp[1])
print(main(a,b))



Fixed submission:
import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    a, b = rinput()
    if a >= 10 or b >= 10:
        print(-1)
    else:
        print(a * b)
main()
Buggy python submission (verdict: Runtime Error):
s=int(input)
def c(x):
  co=0
  for i in range(1,10):
    if x%i==0 and x//i<=9:
      co+=1
  if co>0:
    return("Yes")
  else:
    return("No")
print(c(s))

Fixed submission:
numeros = [1,2,3,4,5,6,7,8,9]
multiplicaciones = []

for x in numeros:
	for z in numeros:
		multiplicaciones.append(x*z)
		pass
	pass
entrada = int(input())
si = False
for x in multiplicaciones:
	if(x==entrada):
		si=True
		break

if(si):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
int main()
    {
        int a[100000]={0},i;
        int n,t;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&t);
            a[t]=i;
        }
        
        for(i=1;i<=n;i++)
        printf("%d ",a[i]);

Fixed submission:
n = int(input())

enter = list(map(int, input().split()))

new_list = []

for i in range(1, n+1):
    new_list.append([enter[i-1], i])

new_list.sort()

for i in range(n):
    print(new_list[i][1], end = " ")

Buggy python submission (verdict: Runtime Error):
n=int(input())
l = [0]*100000
for i in range(1,n+1):
    num=int(input())
    l[num]=i
for i in range(1,n+1):
    print(l[i])

Fixed submission:
n = int(input())

enter = list(map(int, input().split()))

new_list = []

for i in range(1, n+1):
    new_list.append([enter[i-1], i])

new_list.sort()

for i in range(n):
    print(new_list[i][1], end = " ")
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = []

for i in range(n):
	h.append(int(input()))

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))

Fixed submission:
import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

if n == 1:
	print(0)
	sys.exit()

mx = 0
cnt = 0
for i in range(n-2, -1, -1):
	if a[i] >= a[i+1]:
		cnt += 1
		mx = max(mx, cnt)
	else:
		cnt = 0

print(mx)

Buggy python submission (verdict: Runtime Error):
n=input()
a=[]
m=[]

for i in range(n):
    a.append(input())
for i in range(n):
    c=0
    for j in range(n):
        if(a[i]>a[j]):
            c+=1
        else:
            break
    m.append(c)

print(max(m))    

Fixed submission:
import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

if n == 1:
	print(0)
	sys.exit()

mx = 0
cnt = 0
for i in range(n-2, -1, -1):
	if a[i] >= a[i+1]:
		cnt += 1
		mx = max(mx, cnt)
	else:
		cnt = 0

print(mx)

Buggy python submission (verdict: Runtime Error):
import sys
sys.stdin=open("1.txt","r")
n=int(input())
a=input().split()
num=0
while n>0:
    if int(a[n-1])<=int(a[n-2]):
        num+=1
        n-=1
    else:
        break
print(num)


Fixed submission:
import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

if n == 1:
	print(0)
	sys.exit()

mx = 0
cnt = 0
for i in range(n-2, -1, -1):
	if a[i] >= a[i+1]:
		cnt += 1
		mx = max(mx, cnt)
	else:
		cnt = 0

print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = 0
for i in range(n):
    s += i
print(s)

Fixed submission:
n = int(input())
print(n * (n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
h = int(input())
l = list()
for i in range(h):
    l.append(i)
print(sum(l))

Fixed submission:
n = int(input())
print(n * (n-1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
# Given is a sequence of N integers A1,[ldots],AN.

# Find the (multiplicative) inverse of the sum of the inverses of these numbers,  1	 1	A1 +[ldots]+ 1	AN  .

def gcd(a, b):
    while b > 0:
        if a >= b:
            a -= b
        else:
            a, b = b, a
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

input() # N; >0
resistances = [int(a) for a in input().split()]
lcm_r = 1
for r in resistances:
    lcm_r = lcm(r, lcm_r)
# numerator is lcm of resistances
# denominator is sum of lcm/resistance for resistance in resistances
num = lcm_r
denominator = 0
for r in resistances:
    denominator += lcm_r//r
print(num/denominator)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
ans=0.0
d=0
for i in a:
    d=1/i
    ans+=d
print(1/ans)
Buggy python submission (verdict: Runtime Error):
if B<=0:
    if A+B<=A*B:
        print(A*B);
    else:
        print(A+B);
else:
    if A-B<=A*B:
        print(A*B);
    else:
        print(A-B);

Fixed submission:
l=input().split()
a=int(l[0])
b=int(l[1])

sum=a+b
sub=a-b
multi=a*b
if ((sum>=sub)and(sum>=multi)):
    print(sum)
elif((sub>sum)and(sub>multi)):
    print(sub)
else:
    print(multi)
Buggy python submission (verdict: Runtime Error):
s = input()
a = set()
for i in s: a.add(i)
if len(a) == 2 and s.count(a[0]) == 2:
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
c = 0
for i in S:
  if S.count(i) == 2:
    c = c + 1
if (c == 4):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
cnt=0;a=0
res = []
for i in s:
    if i not in res:
        res.append(i)
for i in s:
    if res[0]==i:
        cnt+=1
    if res[1]==i:
        a+=1
if a==2 and cnt==2:
    print("Yes")
else:print("No")


Fixed submission:
S = input()
c = 0
for i in S:
  if S.count(i) == 2:
    c = c + 1
if (c == 4):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
numeros=[int (x) for x in input().split()]
cont=0
cont1=1
qtd=[]
K=1
while True:
    for num in numeros:
        if num<K:
            cont+=1
        else:
            cont1+=1
    if cont==cont1:
        qtd.append(K)
    K+=1
    if K>max(numeros):
        break
    cont=0
    cont1=0
print(len(qtd))

Fixed submission:
n=int(input())
v=[int(i) for i in input().split()]
v=sorted(v)
j=int((n/2))
k=int((n/2)-1)
if v[j]!=v[k]:
    print(v[j]-v[k])
else:
    print("0")
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
dc1=0;dd1=0;dl1=0;dt=0
lcm=(c*d)/math.gcd(c,d)
dc1=int(b/c)-int((a-1)/c)
dd1=int(b/d)-int((a-1)/d)
dl1=int(b/lcm)-int((a-1)/lcm)
dt=dc1+dd1-dl1
print(b-a+1-dt)





Fixed submission:
A, B, C, D, = input().split()
A, B, C, D, = int(A), int(B), int(C), int(D)
def lcm(a,b):
    m = a*b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a+b)
for_D_start = B // D
for_C_start = B // C
sum_start = for_C_start + for_D_start - B // lcm(C,D)
for_C_A = (A-1) // C
for_D_A = (A-1) // D
sum_A = for_C_A + for_D_A - (A-1) // lcm(C,D)
print(B - A + 1 - (sum_start - sum_A))
#print(for_D_A, for_C_A, for_D_start, for_C_start, sum_A, sum_start)
Buggy python submission (verdict: Runtime Error):
def function(N, L, X):
    D = [0]
    for i in range(1, N+2):
        D.append(D[i-1]+L[i-1])
        if D[-1] > X:
            return i

line = input()
N, X = [int(n) for n in line.split()]
line = input()
L = [int(n) for n in line.split()]
print(function(N, L, X))

Fixed submission:
n, m = map(int, input().split())
l = [int(x) for x in input().split()]
answ = 1
h = 0
for k in l:
  h += k
  if h > m:
    break
  else:
    answ += 1
print(answ)

Buggy python submission (verdict: Runtime Error):
n,x=input().split()
L = list(input().split())
d = 0
i = 0
while d <= int(x) and i<int(n):
    d+=int(L[i])
    i+=1
if d > x:
    print(i)
else:
    print(i+1)


Fixed submission:
n, m = map(int, input().split())
l = [int(x) for x in input().split()]
answ = 1
h = 0
for k in l:
  h += k
  if h > m:
    break
  else:
    answ += 1
print(answ)
Buggy python submission (verdict: Runtime Error):
coordinates = list(map(int, input().split()))
w = coordinates[0]
h = coordinates[1]
x = coordinates[2]
y = coordinates[3]
if x == w and y == h:
    x = y = 0
prod1 = x * h
prod2 = y * w
area = min(prod1, prod2)
area = format(area, '.6f') if area != 0 else 0
addit = 0 if prod1 != prod2  else 1
print(f"{area} {addit}")

Fixed submission:
w,h,x,y = list(map(int, input().split()))

if((x == w/2 and y == h/2)):
  print((w*h)/2 , 1)
else:
  print((w*h)/2, 0)

Buggy python submission (verdict: Runtime Error):
coordinates = list(map(int, input().split()))
w = coordinates[0]
h = coordinates[1]
x = coordinates[2]
y = coordinates[3]
prod1 = x * h
prod2 = y * w
if x == w and y == h:
    prod1 = prod2 = (w * h) / 2
area = min(prod1, prod2)
area = format(area, '.6f')
addit = 0 if prod1 != prod2 else 1
print(f"{area} {addit}")

Fixed submission:
w,h,x,y = list(map(int, input().split()))

if((x == w/2 and y == h/2)):
  print((w*h)/2 , 1)
else:
  print((w*h)/2, 0)
Buggy python submission (verdict: Runtime Error):
k=list(map(int,input().split().strip()))
kk=max(k)
k.remove(kk)
print(sum(k))

Fixed submission:
a=[int(n) for n in input().split()]
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(age, price)
elif 6 <= age <= 12:
    print(price // 2)
else:
    print(0)

Fixed submission:
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(int(b /2))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
age = int(input())
yen = int(input())
if 0 <= age <= 5:
    print(0)
if 6 <= age <= 12:
    print(yen//2)
if 16 <= age <= 100:
    print(yen)

Fixed submission:
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(int(b /2))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
age = int(input("enter age"))
yen = int(input("enter cost"))
if 0 <= age <= 5:
    print(0)
    print("Takahashi is",age, "years old, and he can ride the Ferris wheel for free.")
if 6 <= age <= 12:
    print(yen//2)
    print("Takahashi is", age, "years old, and the cost of the Ferris wheel is the half of", yen, "yen, that is,", yen//2, "yen.")
if 16 <= age <= 100:
    print(yen)
    print("Takahashi is", age, "years old now, and the cost of the Ferris wheel is", yen, "yen.")

Fixed submission:
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(int(b /2))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, m = I()
a = [0] * (n + 10)
for i in range(m):
    x, y = I()
    a[x] += 1
    a[y + 1] -= 1
ans = 0
for i in range(1, n + 10):
    a[i] = a[i] + a[i - 1]
    if a[i] == m:
        ans += 1
print(ans)


Fixed submission:
n,m=map(int,input().split())
lmax=0
rmin=10**20
for i in range(m):
    l,r=map(int,input().split())
    lmax=max(lmax,l)
    rmin=min(rmin,r)
if lmax>rmin:
    print(0)
else:
    print(rmin-lmax+1)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if a < b :
    if b < c :
        if c < d:
            if d < e:
                if e < k:
                    ab = b-a
                    ac = c-a
                    ad = d-a
                    ae = e-a
                    bc = c-b
                    bd = d-b
                    be = e-b
                    cd = d-c
                    ce = e-c
                    de = e-d

                    lista = [ab,ac,ad,ae,bc,bd,be,cd,ce,de]
                    x = max(lista)

if x <= 15:
    print("Yay!")
else:
    print(":(")

Fixed submission:
antenas = []
k = 0
for i in range(6):
    if i == 5:
        k = int(input())
    else:
        antenas.append(int(input()))
antenas.sort()
dist = antenas[-1] - antenas[0]
if dist > k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
divisores = []
for i in range(min(a,b), 1, -1):
    if len(divisores) == c:
        break
    elif a % i == 0 and b % i == 0:
        divisores.append(i)
print(divisores[c-1])

Fixed submission:
li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
divisores = []
for i in range(min(a,b), 1, -1):
    if len(divisores) == c:
        break
    if a % i == 0 and b % i == 0:
        divisores.append(i)
print(divisores[c-1])

Fixed submission:
li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])

Buggy python submission (verdict: Runtime Error):
line = input()
A,B,K = [int(n) for n in line.split()]
C = max(A,B)
u = [n for n in range(1,C//2+1) if A/n in range(1,C//2+1) and B/n in range(1,C//2+1)]
u.insert(0,1)
print(u[K-1])

Fixed submission:
li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
divisores = [1]
    
for i in range(2, min(a,b) + 1):
    if a % i == 0 and b % i == 0:
        divisores.append(i)
print(divisores[-4])

Fixed submission:
li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])

Buggy python submission (verdict: Runtime Error):
xyz=input().split()
a=int(xyz[0])
b=int(xyz[1])
c=int(xyz[2])
s=[]
d=[]

for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    s.append(i)
s.sort()
print(s[-c])

Fixed submission:
li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
e=[]
o=[]
s=0

for i in range(n):
    if(int(a[i])==1):
        s+=1
    else:
        e.append(s)
        if(s==n):
            break
        for j in range(i,n):
            f=0
            if(int(a[j])==0):
                s+=1
            else:
                e.append(s)
                if(s==n):
                    break
                for k in range(j,n):
                    if(int(a[k])==1):
                        s+=1
                    else:
                        e.append(s)
                        if(s==n):
                            break
                        f=1
                        break
                if(f==1):
                    break
        
        e.append(s)
        if(s==n):
            break
        s=0
e.append(s)
if(len(e)==0):
    print("0")
else:
    print(max(e))
#print(o)

Fixed submission:
num = input()
predicted_value = 0
finished = False
i = 1
while i < len(num):
    if num[i] != num[i-1]:
        num = num[:i-1] + num[i+1:]
        predicted_value += 2
        if i > 1:
            i -= 2
        elif i == 1:
            i = 0
    i += 1
print(predicted_value)

Buggy python submission (verdict: Time Limit Exceeded):
import re
a = input()
operations = 0
re.search("01", a) or re.search("10", a)
i = 0
while re.search("01", a) or re.search("10", a):
    if re.search("01", a):
        a = a.replace("01", "", 1)
        operations += 2
    if re.search("10", a):
        a = a.replace("10", "", 1)
        operations += 2
print(operations)

Fixed submission:
num = input()
predicted_value = 0
finished = False
i = 1
while i < len(num):
    if num[i] != num[i-1]:
        num = num[:i-1] + num[i+1:]
        predicted_value += 2
        if i > 1:
            i -= 2
        elif i == 1:
            i = 0
    i += 1
print(predicted_value)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
last_size = 0
size = len(S)
while True:
    for i in range(0, len(S)-1):
        if S[i] != S[i+1]:
            del S[i+1]
            del S[i]
            break
    if last_size == len(S) or len(S) == 0:
        break
    else:
        last_size = len(S)
print(size-len(S))

Fixed submission:
num = input()
predicted_value = 0
finished = False
i = 1
while i < len(num):
    if num[i] != num[i-1]:
        num = num[:i-1] + num[i+1:]
        predicted_value += 2
        if i > 1:
            i -= 2
        elif i == 1:
            i = 0
    i += 1
print(predicted_value)
Buggy python submission (verdict: Runtime Error):
def funcion():
    n = int(input())
    indice_anterior = -1
    total = 0
    
    

    for i in range(n):
        mayor = 0
        cadena = input()
        lista = cadena.split()
        for j in lista:
            jnum = int(j)
            indice_actual = lista.index(j)
            if (jnum > mayor) and indice_actual != indice_anterior:
                mayor = jnum
        indice_anterior = lista.index(str(mayor))     
        total = total + mayor
    print(total)

def main():
    return(funcion())

if __name__ == "__main__":
    main()


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

activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]

for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]

print(max(schedules[N - 1]))

Buggy python submission (verdict: Runtime Error):
def funcion():
    n = int(input())
    m = []
    indice_anterior = -1
    total = 0

    for i in range(n):
        cadena = input()
        lista = cadena.split()
        m.append(lista)
    
    for i in range(n):
        mayor = 0
        for j in m[i]:
            jnum = int(j)
            indice_actual = m[i].index(j)
            if (jnum > mayor) and indice_actual != indice_anterior:
                mayor = jnum
        indice_anterior = m[i].index(str(mayor))     
        total = total + mayor
    
    print(total)
def main():
    return(funcion())

if __name__ == "__main__":
    main()


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

activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]

for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]

print(max(schedules[N - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
arr=[]
n,w=map(int,input().split())
for _ in range(n):
	arr.append(tuple(map(int,input().split())))
@lru_cache(maxsize=10000000)
def f(pos,W):
	if(pos==n):
		return 0
	res=f(pos+1,W)
	if(arr[pos][0]<=W):
		res=max(res,f(pos+1,W-arr[pos][0])+arr[pos][1])
	return res
print(f(0,w))

Fixed submission:
import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
# absotutely TLE
arr=[]
n,w=map(int,input().split())
for _ in range(n):
	arr.append(tuple(map(int,input().split())))
def f(pos,W):
	if(pos==n):
		return 0
	res=f(pos+1,W)
	if(arr[pos][0]<=W):
		res=max(res,f(pos+1,W-arr[pos][0])+arr[pos][1])
	return res
print(f(0,w))

Fixed submission:
import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from collections import defaultdict
n, w = [int(i) for i in stdin.readline().split(' ')]
weights = []
values = []
for i in range(0, n):
    cur = [int(i) for i in stdin.readline().split(' ')]
    weights.append(cur[0])
    values.append(cur[1])

dp = defaultdict(lambda: defaultdict(int))
dp[0][0] = 0
for minInd in range(0, n):
    for allowed in range(0, w):
        dp[minInd+1][allowed] = max(dp[minInd+1][allowed], dp[minInd][allowed])
        if allowed+weights[minInd] <= w:
            dp[minInd+1][allowed+weights[minInd]] = max(dp[minInd+1][allowed+weights[minInd]], dp[minInd][allowed]+values[minInd])

print(max(dp[n].values()))

Fixed submission:
import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
def loop():
    global x
    global counter
    thisLoopTime = 0
    i=0
    while i<len(x)-1:
        if(x[i+1]==0 and x[i]==1):
            t = x[i+1]
            x[i+1]=x[i]
            x[i]=t
            thisLoopTime += 1
            counter+=1
        i+=1
    if(thisLoopTime==0):
        return
    else:
        loop() 
j = input()
x = []
for i in j:
    if(i=="B"):
        x.append(1)
    else:
        x.append(0)
counter =0
loop()
print(counter)

Fixed submission:
x=[i for i in  input()]
n=0
m=len(x)
w=0
for i in range(m):
    if x[i]=='W':
        w+=1
        n+=i-w+1
print(n)