Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import math

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 pro(k, l, n):
    if l < n:
        if k == 0:
            return(n - l)
        return (n - l + 2)
    if l == n:
        if k == 0:
            return 0
        elif k == 1:
            return 1
        return 3
    else:
        l -= n - 1
        if l == k:
            return 1
        elif l > k:
            return 0
        if l < k - 1:
            return 2
        else:
            return 3
            

def rt(k, l , n):
    if k < n:
        if l == 0:
            return (k * 2 + n)
        return (n + k * 2 - 1)
    elif k == n:
        if l == 1:
            return (k * 3 - 2)
        elif l == 0:
            return (k * 3)
        return (k * 3 - 3)
    else:
        k -= n - 1
        if k == l:
            return (n * 3 - 2)
        elif k > l:
            return (n * 3)
        if k < l - 1:
            return ((n - 1) * 3 - 1)
        else:
            return ((n - 1) * 3)



def main():
    a = iinput()
    print(q ** 3)
    
    
    


main()



Fixed submission:
n = int(input())#waiting_for_pudging
print(n**3)#pudging
#accepted
Buggy python submission (verdict: Runtime Error):
MN=input().split()
M=int(MN[0])
N=int(MN[1])  
div=int(N/M)
if (N%M)<N and (N%M)>0:
 cont=1 
elif (N%M)==0: 
  cont=0
print(cont+div)  

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)

Buggy python submission (verdict: Runtime Error):
m= int(input())
n= int(input())
print(round((n/m)+0.49))

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)

Buggy python submission (verdict: Runtime Error):
m=int(input())
n=int(input())
print(round((n/m)+0.4))

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
hs = [ int(i) for i in s.rsplit() ]

max = 0
for i in range(len(hs)):
    lmax = 0
    for k in range(1, len(hs)-i):
        if hs[i+k] <= hs[i+k-1]:
            lmax = lmax + 1
        else:
            break

        if lmax > max:
            max = lmax

print(max)

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)

Buggy python submission (verdict: Runtime Error):
import math
A = input()
B = input()
n = math.ceil(B/A)
print(n, " power strips, each with", A , "sockets, extend the socket into", A*n, "empty sockets.")

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)
Buggy python submission (verdict: Runtime Error):
A,B=input().split();
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:
a, b = map(int, input().split())

print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
       if (A + B) % 2 != 0:
           print("IMPOSSIBLE")
       else:
               print(int((A+B)/2))


Fixed submission:
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
       if (A + B) % 2 != 0:
           print("IMPOSSIBLE")
       else:
               print(int((A+B)/2))


Fixed submission:
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
def check(n, list1): 
    new = [] 
    for i in range(n): 
        new.append(list1[i]) 
          
    new.sort() 
      
    # Check if 0 or 1 swap required  
    # to get the sorted array  
    swaps = 0
    for i in range(n): 
        if list1[i] != new[i]: 
            swaps += 1
              
    if swaps == 0 or swaps == 2: 
        return True
    else: 
        return False
  
n = int(input())
numbers=[]
for i in range(n):
    numbers.append(int(input()))

if check(n, numbers): 
    print("YES")
else:
    print("NO") 

 

Fixed submission:
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
l=[int(x) for x in input().split()]
cnt=0
x=0
y=0
b=0
for i in range(n):
    if(i+1!=l[i]):
        cnt+=1
        if(cnt==1):
            x=l[i]
        elif(cnt==2):
            y=l[i]
        elif(cnt>0):
            b=1
            break
if(b==1):
    print("NO")
elif(l[x-1]!=y and l[y-1]!=x):
    print("NO")
else:
    print("YES")
            

Fixed submission:
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
#

from bisect import bisect

for _ in range(int(input())):
    N, D = map(int, input().split())
    P = list(map(int, input().split()))
    swaps = 0
    possible = True
    for m in range(D):
        order = []
        for i in range(m, N, D):
            if (P[i]-(i+1)) % D:
                possible = False
                break
            idx = bisect(order, P[i])
            swaps += len(order) - idx
            order.insert(idx, P[i])
    if possible:
        print(swaps)
    else:
        print(-1)
    

Fixed submission:
n = int(input())

p = list(map(int,input().split(' ')))

c = 0

for i in range(1, len(p)-1):
  f = p[i-1]
  s = p[i]
  t = p[i+1]
  ma = max(f,t)
  mi = min(f,t)
  if s > mi and s < ma:
    c += 1

print(c)
Buggy python submission (verdict: Runtime Error):
i = input().split()

n,x = list(map(int, i))

l = input().split()

l = list(map(int, l))

step = [0]

c = 0

while step[-1] < x:
    c += 1
    step.append(step[c - 1] + l[c - 1])

print(len(step) - 1)

Fixed submission:
n, x = map(int, input().split())
result, cur = 1, 0

for jump in map(int, input().split()):
    
    cur += jump
    
    if cur <= x:
        result += 1
    else:
        break

print(result)

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

Fixed submission:
n, x = map(int, input().split())
result, cur = 1, 0

for jump in map(int, input().split()):
    
    cur += jump
    
    if cur <= x:
        result += 1
    else:
        break

print(result)
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
area = min(prod1, prod2)
area = format(area, '.6f') if area != 0 else 0
if x == w and y == h:
    area = area / 2
addit = 0 if prod1 != prod2  else 1
print("{} {}".format(area, addit))

Fixed submission:
w, h, x, y = map(int, input().split())
print(w * h / 2, end=' ')
if (x == w / 2 and y == h / 2):
	print(1)
else:
	print(0)

Buggy python submission (verdict: Runtime Error):
from math import isclose


w, h, x, y = map(float, input().split())

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

Fixed submission:
w, h, x, y = map(int, input().split())
print(w * h / 2, end=' ')
if (x == w / 2 and y == h / 2):
	print(1)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
valores = [int(input()), int(input()), int(input())]
valores[valores.index(max(valores))]=0
print(valores[0]+valores[1]+valores[2])


Fixed submission:
x = input().split()
P = int(x[0])
Q = int(x[1])
R = int(x[2])
l = [P+Q,Q+R,R+P]
print(min(l))

Buggy python submission (verdict: Runtime Error):
lista=[]
soma=[]
for x in input().split():
    lista.append(int(x))
for var1 in lista:
    for var2 in lista:
        if var1!=var2:
            soma.append(var1+var2)

min=min(soma)
print(min)


Fixed submission:
x = input().split()
P = int(x[0])
Q = int(x[1])
R = int(x[2])
l = [P+Q,Q+R,R+P]
print(min(l))
Buggy python submission (verdict: Runtime Error):
// Fibonacci 
#include <bits/stdc++.h> 
using namespace std; 
long long dp[1000];
long long MOD {1000000007}; 
int main () {
    ios::sync_with_stdio(false);

    int n; cin >> n; 
    int m; cin >> m; 
    vector<int> broken(100010, 0);
    int x;
    for (int i = 0; i < m; i++) {
        cin >> x; 
        broken[x] = 1; 
    }

    dp[0] = 1;
    for (int num = 0; num < n; num++) {
        for (int next = num+1; next <= min(num+2, n); next++) {
            if (not broken[next]) { 
                dp[next] += dp[num]; 
                dp[next] = dp[next] % 1000000007; 
            }
            else 
                dp[next] = 0;
        }
    }

    // for (int i = 0; i <= n; i++) {
    //     cout << dp[i] << " "; 
    // }
    cout << dp[n]; 
}

Fixed submission:
def fibonacci(n):
	if n==0:
		return 0
	a,b=1,1
	for i in range(0,int((n-1)/2)):
		a+=b
		b+=a
	if n%2!=0:
		return a
	return b

n=[int(i) for i in input().split()]
f=1
a=-1
for i in range(0,n[1]):
	b=int(input())
	f*=fibonacci(b-a-1)
	a=b
f*=fibonacci(n[0]-a)
print(f%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:list(map(int,input().split()))
n,m=I()
b=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if i not in b:
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n])
    

Fixed submission:
def fibonacci(n):
	if n==0:
		return 0
	a,b=1,1
	for i in range(0,int((n-1)/2)):
		a+=b
		b+=a
	if n%2!=0:
		return a
	return b

n=[int(i) for i in input().split()]
f=1
a=-1
for i in range(0,n[1]):
	b=int(input())
	f*=fibonacci(b-a-1)
	a=b
f*=fibonacci(n[0]-a)
print(f%1000000007)
Buggy python submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(price)
elif 6 <= age <= 12:
    print(price // 2)
else:
    print(0)

Fixed submission:
a, b = [int(x) for x in input().split()]

cost = 0
if a >= 13:
    cost = b
elif a >= 6:
    cost = b / 2
else:
    cost = 0

print(int(cost))

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 = [int(x) for x in input().split()]

cost = 0
if a >= 13:
    cost = b
elif a >= 6:
    cost = b / 2
else:
    cost = 0

print(int(cost))

Buggy python submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(age, price)
elif age >= 6 and age <= 12:
    print(price // 2)
else:
    print(0)

Fixed submission:
a, b = [int(x) for x in input().split()]

cost = 0
if a >= 13:
    cost = b
elif a >= 6:
    cost = b / 2
else:
    cost = 0

print(int(cost))

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

Fixed submission:
a, b = [int(x) for x in input().split()]

cost = 0
if a >= 13:
    cost = b
elif a >= 6:
    cost = b / 2
else:
    cost = 0

print(int(cost))
Buggy python submission (verdict: Runtime Error):
def mi():
    return map(int, input().split())
'''
3 2
5 1 4
2 3
1 5
'''
n,m = mi()
a = list(mi())
a.sort()
q = [0]*m
for i in range(m):
    q[i] = list(mi())[::-1]
q.sort(reverse=True)
mi = 0
for i in range(m):
    for j in range(q[i][1]):
        if a[mi]<q[i][0]:
            a[mi] = q[i][0]
            mi+=1
            if mi==n:
                break
        else:
            break
print(sum(a))



Fixed submission:
I=lambda:list(map(int,input().split()))
n,m=I()
a=I()
a.sort(reverse=True)
qq=[I() for i in range(m)]
qq.sort(key=lambda x:x[1],reverse=True)
ans=0
for x,y in qq:
    for j in range(x):
        if not a:
            break
        aa=a.pop()
        ans+=max(aa,y)
ans+=sum(a)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

num_factors = [factors(num) for num in numbers]
left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])


print(predicted_value)

Fixed submission:
from fractions import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])

print(predicted_value)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools


flatten_iter = itertools.chain.from_iterable
def factors(n):
    return set(flatten_iter((i, n//i) 
                for i in range(1, int(n**0.5)+1) if n % i == 0))

line = int(input())


line = input()
numbers = [int(n) for n in line.split()]

num_factors = [factors(num) for num in numbers]
factors_pairs = []
for i in range(len(numbers)):
    common_factors = None
    for dividends in num_factors[:i] + num_factors[i+1:]:
        if not common_factors:
            common_factors = dividends
        else:
            common_factors = common_factors.intersection(dividends)
    factors_pairs.append(max(common_factors))
predicted_value = max(factors_pairs)

print(predicted_value)

Fixed submission:
from fractions import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])

print(predicted_value)
Buggy python submission (verdict: Runtime Error):
m=input()
m=m.split(" ")
a=m[0]
b=m[1]

print(max(a+a-1,b+b-1,a+b))

Fixed submission:
line = input()
numbers = [int(n) for n in line.split()]
predicted_value = max(numbers[0]+numbers[1], numbers[0]*2-1, numbers[1]*2-1)
print(predicted_value)
Buggy python submission (verdict: Runtime Error):
line = input()
numbers = [int(n) for n in line.split()]
predicted_value = "Yay!"
k_distance = numbers[-1]
antenas = numbers[:-1]
antenas.sort()
if antenas[-1] - antenas[0] > k_distance:
    predicted_value = ":("
print(predicted_value)

Fixed submission:
xs = []
for _ in range(5):
    x = int(input())
    xs.append(x)
k = int(input())

ok = False
for i in xs:
    for j in xs:
        if max(i, j) - min(i, j) > k:
            ok = True

print(':(') if ok else print('Yay!')
Buggy python submission (verdict: Runtime Error):
xyz=input().split()
a=int(xyz[0])
b=int(xyz[1])
c=int(xyz[2])
s=[]
d=[]
flag=0
if a==1 and b==1 and c==1:
  flag=1
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    s.append(i)
if flag==1 or len(s)==0:
  print(1)
else:
  s.sort()
  s.reverse()
  print(s[c-1])
  

Fixed submission:
a,b,k=map(int,input().split())
z=min(a,b)
n=0
while(z>=1):

    if(a%z==0 and b%z==0):
        n+=1;
        if n==k:
            break
    z-=1

print(z)

Buggy python submission (verdict: Runtime Error):
xyz=input().split()
a=int(xyz[0])
b=int(xyz[1])
c=int(xyz[2])
s=[]
d=[]
flag=0
if a==1 and b==1 and c==1:
  flag=1
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    s.append(i)
s.sort()
s.reverse()
if flag==0:
  print(s[c-1])
else:
  print(1)

Fixed submission:
a,b,k=map(int,input().split())
z=min(a,b)
n=0
while(z>=1):

    if(a%z==0 and b%z==0):
        n+=1;
        if n==k:
            break
    z-=1

print(z)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
c=0
k=1
while(k!=0):
    k=0
    b=s.replace('10','')
    c+=len(s)-len(b)
    k=len(s)-len(b)
    s=b
    b=s.replace('01','')
    c+=len(s)-len(b)
    k+=len(s)-len(b)
    s=b
print(c)

Fixed submission:
s=input()
o=s.count('1')
z=s.count('0')
print(2*min(o,z))

Buggy python submission (verdict: Time Limit Exceeded):
s, cont = input(), 0
while s.find("01") is not -1:    
    s = s.replace("01", "", 1)
    cont += 1    
while s.find("10") is not -1:
    s = s.replace("10", "", 1)
    cont += 1
print(cont * 2)

Fixed submission:
s=input()
o=s.count('1')
z=s.count('0')
print(2*min(o,z))

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

Fixed submission:
s=input()
o=s.count('1')
z=s.count('0')
print(2*min(o,z))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
all=0
mx=0
for i in range(len(a)):
	x=int(a[i])
	if x>mx: 
		mx=x
	all=all+x
if all>2*mx : 
	print("Yes")
else : 
	print("No")

Fixed submission:
n = raw_input()
L = map(int, raw_input().strip().split())
s = sum(L)
mx = max(L)
if mx < s - mx:
  print "Yes"
else:
  print "No"

Buggy python submission (verdict: Runtime Error):
n=input()
int(n)
all=0
a=[]
a=input().split()
mx=0
for i in range(0,n):
	x=int(a[i])
	if x>mx: mx=x
	all=all+x
if all>2*mx : print("Yes")
else : print("No")

Fixed submission:
n = raw_input()
L = map(int, raw_input().strip().split())
s = sum(L)
mx = max(L)
if mx < s - mx:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Runtime Error):
AB = int(input())
BC = int(input())
CA = int(input())
print((AB*BC)/2)

Fixed submission:
a,b,c=map(int,input().split())
if a>b and a>c:
    ans=(0.5)* b * c
elif b>a and b>c:
    ans=(0.5)* a * c
else:
    ans = (0.5) * a * b

print(int(ans))
Buggy python submission (verdict: Runtime Error):
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int h[n];
  for (int i = 0; i < n; i++) {
    int cur;
    cin >> cur;
    h[i] = cur;
  }
  int minCosts[n];
  minCosts[0] = 0;
  minCosts[1] = abs(h[1]-h[0]);
  for (int i = 2; i < n; i++) {
    minCosts[i] = min(abs(h[i]-h[i-2])+minCosts[i-2], abs(h[i]-h[i-1])+minCosts[i-1]);
  }
  cout << minCosts[n-1] << "\n";
  return 0;
}

Fixed submission:
def main():
    n = int(input())
    arr = [int(e) for e in input().split()]
    t = [float('inf')] * (n + 1)
    t[0] = 0
    t[1] = 0 
    t[2] = abs(arr[1] - arr[0])
    for i in range(3, n + 1):
        l1 = t[i - 1] + abs(arr[i - 2] - arr[i - 1])
        l2 = t[i - 2] + abs(arr[i - 3] - arr[i - 1])
        t[i] = min(l1, l2)
    print(t[n])
    return 0


if __name__ == '__main__':
    main()
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 main(n,w,itemWeights,itemValues):
    m = 0
    for i in range(n):
        if itemValues[i] > itemValues[m]:
            m = i
    if w - itemWeights[m] < 0:
        return 0
    else if w - itemWeights[m] == 0:
        return itemValues[i]
    else:
        v = itemValues[m]
        itemWeights.pop(m)
        itemValues.pop(m)
        return v+main(n,w,itemWeights,itemValues)
    

inp1 = input().split()
n = inp1[0]
w = inp[1]
itemWeights = []
itemValues = []

for i in range(n)
    inp = input()
    itemWeights.append(int(inp[0]))
    itemValues.append(int(inp[1]))

print(main(n,w,itemWeights,itemValues))

Fixed submission:
from collections import defaultdict

n, w = [int(x) for x in input().split()]
d = []
for _ in range(n):
    ww, nu = [int(x) for x in input().split()]
    d.append((ww, nu))

# dd[idx][ww] represents the maximum value that  we can get if total weight <= ww
# and allowed to use the first idx items.
dd = defaultdict(lambda: defaultdict(int))
for ww in range(w+1):
    dd[0][ww] = 0

for nn in range(n+1):
    dd[nn][0] = 0

for nn in range(1, n+1):
    www, nu = d[nn-1]
    for ww in range(1, w+1):
        # don't use item nn-1
        cur = dd[nn-1][ww]

        # use item nn-1
        if www <= ww:
            rem_ww = ww - www
            cand = dd[nn-1][rem_ww] + nu
            if cand > cur:
                cur = cand

        dd[nn][ww] = cur

print(dd[n][w])

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+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:
from collections import defaultdict

n, w = [int(x) for x in input().split()]
d = []
for _ in range(n):
    ww, nu = [int(x) for x in input().split()]
    d.append((ww, nu))

# dd[idx][ww] represents the maximum value that  we can get if total weight <= ww
# and allowed to use the first idx items.
dd = defaultdict(lambda: defaultdict(int))
for ww in range(w+1):
    dd[0][ww] = 0

for nn in range(n+1):
    dd[nn][0] = 0

for nn in range(1, n+1):
    www, nu = d[nn-1]
    for ww in range(1, w+1):
        # don't use item nn-1
        cur = dd[nn-1][ww]

        # use item nn-1
        if www <= ww:
            rem_ww = ww - www
            cand = dd[nn-1][rem_ww] + nu
            if cand > cur:
                cur = cand

        dd[nn][ww] = cur

print(dd[n][w])