Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])
  
loc=[0]*n
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    loc[i]=1
for i in range(q):
  l=lr[i][0]
  r=lr[i][1]
  print(sum(loc[l-1:r-1]))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])

t=[0]*n
for i in range(n-1):
  if s[i:i+2]=='AC':
    t[i+1]=t[i]+1
  else:
    t[i+1]=t[i]
for i in range(q):
  l=lr[i][0]
  r=lr[i][1]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])
def ans(x):
  l=lr[x][0]
  r=lr[x][1]
  s_x=s[l-1:r]
  n=len(s_x)
  a=0
  for i in range(n-1):
    if s_x[i]=='A' and s_x[i+1]=='C':
      a+=1
  return a
for i in range(q):
  print(ans(i))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])

t=[0]*n
for i in range(n-1):
  if s[i:i+2]=='AC':
    t[i+1]=t[i]+1
  else:
    t[i+1]=t[i]
for i in range(q):
  l=lr[i][0]
  r=lr[i][1]
  print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(int,input())
a=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(n):
  sum=c
  for j in range(m):
    sum+=a[i,j]*b[j]
  if sum>0:
    sum+=1
print(sum)

Fixed submission:
n,m,c=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n+1)]
count=0
for i in range(n):
  sum=c
  for j in range(m):
    sum+=a[i+1][j]*a[0][j]
  if sum>0:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
count=0
for i in range(1,ab):
  if a%i==0 and b%i==0:
    count+=1
    if count==k:
      print(i)
      exit()
    


Fixed submission:
a,b,k=map(int,input().split())
count=0
for i in range(105):
  j=101-i
  if a%j==0 and b%j==0:
    count+=1
    if count==k:
      print(j)
      exit()

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
count=0
for i in range(ab):
  if a%i==0 and b%i==0:
    count+=1
    if count==k:
      print(i)
      exit()
    


Fixed submission:
a,b,k=map(int,input().split())
count=0
for i in range(105):
  j=101-i
  if a%j==0 and b%j==0:
    count+=1
    if count==k:
      print(j)
      exit()

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
count=0
for i in range(ab):
  if a%i==0 and b%i==0:
    count+=1
    if count==k:
      print(k)
      exit()
    


Fixed submission:
a,b,k=map(int,input().split())
count=0
for i in range(105):
  j=101-i
  if a%j==0 and b%j==0:
    count+=1
    if count==k:
      print(j)
      exit()
Buggy python submission (verdict: Runtime Error):
s=input().split('')
one=s.count('1')
zero=s.count('0')
print(2*min(one,zero))

Fixed submission:
s=list(input())
one=s.count('1')
zero=s.count('0')
print(2*min(one,zero))
Buggy python submission (verdict: Runtime Error):
n,a,b,c=map(int,input().split())
l=[]
for _ in range(n):
  x=int(input())
  l.append(x)

def dfs(cur,x,y,z):
  if cur==n and min(x,y,z)>0:
    return abs(a-x)+abs(b-y)+abs(c-z)-30
  elif cur==n:
    return inf
  ret0=dfs(cur+1,x,y,z)
  ret1=dfs(cur+1,x+l[cur],y,z)+10
  ret2=dfs(cur+1,x,y+l[cur],z)+10
  ret3=dfs(cur+1,x,y,z+l[cur])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Fixed submission:
n,a,b,c=map(int,input().split())
l=[]
for _ in range(n):
  d=int(input())
  l.append(d)

def dfs(cur,x,y,z):
  if cur==n and min(x,y,z)>0:
    return abs(a-x)+abs(b-y)+abs(c-z)-30
  elif cur==n:
    return 100000000000000000000
  ret0=dfs(cur+1,x,y,z)
  ret1=dfs(cur+1,x+l[cur],y,z)+10
  ret2=dfs(cur+1,x,y+l[cur],z)+10
  ret3=dfs(cur+1,x,y,z+l[cur])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
a = int(input())
print(a + a**2 + a**3

Fixed submission:
a = int(input())
sum_a = a + a ** 2 + a ** 3
print(sum_a)
Buggy python submission (verdict: Runtime Error):
x, y, z = map(int, input().split())
print(f"{z} {x} {y}")

Fixed submission:
x, y, z = map(int, input().split())
print("{} {} {}".format(z, x, y))

Buggy python submission (verdict: Runtime Error):
a = int(input("Enter a number for X: "))
b = int(input("Enter a number for Y: "))
c = int(input("Enter a number for Z: "))

print(f"{c} {a} {b}")


Fixed submission:
x, y, z = map(int, input().split())
print("{} {} {}".format(z, x, y))

Buggy python submission (verdict: Runtime Error):
def generator(A, B, C):
    return f"{C} {A} {B}"


Fixed submission:
x, y, z = map(int, input().split())
print("{} {} {}".format(z, x, y))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1
ans = N - x
if ans >= M :
    print('Yes')
else:
    print('No')N, M = map(int, input().split())
A = list(map(int, input().split()))
check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1
ans = N - x
if ans >= M :
    print('Yes')
else:
    print('No')

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1
ans = N - x
if ans >= M :
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
Nj = N
while True:
    Ni = Nj
    Nj = abs(Ni - K)
    if Ni > N:
        print(N)
        break
    elif Nj > Ni:
        print(Ni)
        break
    elif K == 1 or Nj == K:
        print(0)
        break
    else:
        continue


Fixed submission:
n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    l = [n]
    p = n // k
    c = n - (p * k)
    half = k // 2
    while c > half:
        c = abs(c - k)
    l.append(c)
    print(min(l))
Buggy python submission (verdict: Runtime Error):
x == int(input())
if x = 1 :
   print(0)
else :
   print(1)

Fixed submission:
x = int(input())
if x == 1 :
   print(0)
else :
   print(1)
Buggy python submission (verdict: Runtime Error):
n,r =int(input().split())
if n < 10 :
  print(100 * (10 - n) + r)
else:
  print(r)

Fixed submission:
n,r =map(int,input().split())
if n < 10 :
  print(100 * (10 - n) + r)
else:
  print(r)

Buggy python submission (verdict: Runtime Error):
n,r = map(int(input(),split()))
if n < 10 :
  print(100 * (10 - n) + r)
else:
  print(r)

Fixed submission:
n,r =map(int,input().split())
if n < 10 :
  print(100 * (10 - n) + r)
else:
  print(r)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ac = a * c
ad = a * d
bc = b * c
bd = b * d
ans_1 = math.max(ac,ad)
ans_2 = math.max(bc, bd)
ans = math.max(ans1_, ans2)
print(ans)

Fixed submission:
a, b, c, d = map(int, input().split())
ac = a * c
ad = a * d
bc = b * c
bd = b * d
ans_1 = max(ac,ad)
ans_2 = max(bc, bd)
ans = max(ans_1, ans_2)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

mod = 1000000007


ans = 0
n = A[0]
for a in A[1:]:
    ans += a * n
    n += a

print(ans%mod)




Fixed submission:
d,t,s = map(int, input().split())

ans = d / s

if ans > t:
    print("No")
else :
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))

sum_value = 0
for i in range(n-1):
    for j in range(i+1,n):
        sum_value += nums[i]*nums[j]

print(sum_value%1000000007)


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

mod = 1000000007


ans = 0
n = A[0]
for a in A[1:]:
    ans += a * n
    n += a

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669

Fixed submission:
import math

n,d = map(int, input().split())

count = 0
for _ in range(n):
    x,y = map(int, input().split())
    dis = math.sqrt((x*x) + (y*y))
    if dis <= d:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = (int(x) for x in input().split())

posabs_list = []

for i in range(k+1):
        pos = x + d * (k-i) - d * i
        posabs = abs(pos)
        posabs_list.append(posabs)
print(min(posabs_list))

Fixed submission:
import math

x, k, d = (int(x) for x in input().split())

x = abs(x)
k1 = math.floor(x/d)

if k < k1 :
        k1 = k
else :
        k1 = k1

k2 = k1 - k

y = x - k1 * d

if k2%2 == 0 :
        print(abs(y))
else :
        print(abs(y - d))

Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = (int(x) for x in input().split())

posabs_list = []

for i in range(k+1):
        pos = x + d * (k-i) - d * i
        posabs = abs(pos)
        posabs_list.append(posabs)
print(min(posabs_list))

Fixed submission:
import math

x, k, d = (int(x) for x in input().split())

x = abs(x)
k1 = math.floor(x/d)

if k < k1 :
        k1 = k
else :
        k1 = k1

k2 = k1 - k

y = x - k1 * d

if k2%2 == 0 :
        print(abs(y))
else :
        print(abs(y - d))
Buggy python submission (verdict: Runtime Error):
#include <iostream>

using namespace std;

int main() {
    int x;
    cin>>x;
    if (x==0){
        cout<<1<<endl;
        
    }
    else{
        cout<<0<<endl;
    }

    return 0; 
}

Fixed submission:
x=int(input())
if x==0:
  print(1)
elif x==1:
  print(0)

Buggy python submission (verdict: Runtime Error):
#include <iostream>

using namespace std;

int main() {
    int x;
    cin>>x;
    if (x==0){
        cout<<0<<endl;
        
    }
    if (x==1){
        cout<<1<<endl;
    }
else{
    

    cout<<"error"<<endl;
}
    return 0; 
}

Fixed submission:
x=int(input())
if x==0:
  print(1)
elif x==1:
  print(0)

Buggy python submission (verdict: Runtime Error):
h=int(input())
if x==1:
  print(0)
if x==0:
  print(-1)
  

Fixed submission:
x=int(input())
if x==0:
  print(1)
elif x==1:
  print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print (max(a*c,a*d,b*c,b*d)



Fixed submission:
a,b,c,d=map(int,input().split())
print (max(a*c,a*d,b*c,b*d))
Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

import numpy as np

c = np.array(range(1,n+1), dtype=np.uint64)
nn = np.array([n] * n)
d = nn//c

e = d * (d+1) //2 * c

# print(e)
print(int(sum(e)))

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

# n以下の整数でiで割り切れる数の総和
def sumofdivi(n,i):
    a = n//i
    b = (a*(a+1))//2*i
    return b

ans = 0
for i in range(1,n+1):
    v = sumofdivi(n,i)
    ans += v

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = li()
ans = 1
for i in range(len(a)):
    ans *= a[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

bb = 10**18

def main():
    n = ii()
    a = li()
    ans = 1

    if 0 in a:
        print(0)
        return

    for i in range(len(a)):
        ans *= a[i]
        if ans > bb:
            print(-1)
            break
    else:
        print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = li()
ans = 1
for i in range(len(a)):
    ans *= a[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

bb = 10**18

def main():
    n = ii()
    a = li()
    ans = 1

    if 0 in a:
        print(0)
        return

    for i in range(len(a)):
        ans *= a[i]
        if ans > bb:
            print(-1)
            break
    else:
        print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import numpy as np

n = ii()
print(n*2*np.pi)

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import numpy as np

n = ii()
print(n*2*np.pi)
Buggy python submission (verdict: Runtime Error):
mi = lambda : map(int,input().split())

import math

a,b,c = mi()

# if a+b-c/2 >= math.sqrt(a*b):
if math.sqrt(a) + math.sqrt(b) < math.sqrt(c)
    print('Yes')
else:
    print('No')

Fixed submission:
mi = lambda : map(int,input().split())

a,b,c = mi()

x = c-a-b
if x < 0:
    print('No')
elif 4* a*b < (c-a-b)**2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


s = input()

n = ii()
r = 0
head = ''
tail = ''
for i in range(n):
    q = input().split()

    if(q[0] == '1'):
        # reverse
        r += 1
    else:
        if(q[1] == '1'):
            if(r%2 ==0):
                s = q[2] + s
            else:
                s = s + q[2]
        else:
            if(r%2 ==0):
                s = s + q[2]
            else:
                s = q[2] + s
    

if(r%2==1):
    s = s[::-1]


print( s )


Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


s = input()

n = ii()
r = 0
head = ''
tail = ''
for i in range(n):
    q = input().split()

    if(q[0] == '1'):
        # reverse
        r += 1
    else:
        if(q[1] == '1'):
            if(r%2 ==0):
                # s = q[2] + s
                head = q[2] + head
            else:
                # s = s + q[2]
                tail = tail + q[2]
        else:
            if(r%2 ==0):
                # s = s + q[2]
                tail = tail + q[2]
            else:
                # s = q[2] + s
                head = q[2] + head

    # print('*********************',i,head,tail)
    

if(r%2==1):
    # s = s[::-1]
    # print('rev')
    print( tail[::-1] + s[::-1]+ head[::-1])
else:

    print(head +  s + tail)

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


s = input()

n = ii()

for i in range(n):
    q = input().split()

    if(q[0] == '1'):
        # reverse
        s = s[::-1]
    else:
        if(q[1] == '1'):
            s = q[2] + s
        else:
            s = s + q[2]

print(s)


Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


s = input()

n = ii()
r = 0
head = ''
tail = ''
for i in range(n):
    q = input().split()

    if(q[0] == '1'):
        # reverse
        r += 1
    else:
        if(q[1] == '1'):
            if(r%2 ==0):
                # s = q[2] + s
                head = q[2] + head
            else:
                # s = s + q[2]
                tail = tail + q[2]
        else:
            if(r%2 ==0):
                # s = s + q[2]
                tail = tail + q[2]
            else:
                # s = q[2] + s
                head = q[2] + head

    # print('*********************',i,head,tail)
    

if(r%2==1):
    # s = s[::-1]
    # print('rev')
    print( tail[::-1] + s[::-1]+ head[::-1])
else:

    print(head +  s + tail)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(1/e) for e in input().split()]

print(1/sum(a))


Fixed submission:
n = int(input())
a = [1/int(e) for e in input().split()]

print(1/sum(a))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n): 
    a.append( 1/int(input()))

print(1/sum(a))


Fixed submission:
n = int(input())
a = [1/int(e) for e in input().split()]

print(1/sum(a))

Buggy python submission (verdict: Runtime Error):
def main():
    
    n = int(input())
    a = []
    for i in range(n): 
        a.append( 1/int(input()))

    print(1/sum(a))
    

if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
a = [1/int(e) for e in input().split()]

print(1/sum(a))

Buggy python submission (verdict: Runtime Error):
def main():
    
    n = int(input())
    a = []
    for i in range(n): 
        a.append( 1/int(input()))

    print(sum(a))
    

if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
a = [1/int(e) for e in input().split()]

print(1/sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    ss = sorted(input())
    s.append(''.join(ss))

s2 = list(set(s))
ans = 0

for i in s2:
    j = s.count(i)
    ans += j * (j-1)//2

print(ans)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    ss = sorted(input())
    s.append(''.join(ss))

s.sort()
ans = 0
lcnt = 1
for i in range(1,len(s)):
    if s[i] == s[i-1]:
        lcnt += 1
    else:
        ans += lcnt * (lcnt-1)//2
        lcnt=1

ans += lcnt * (lcnt-1)//2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,k=mi()
h=li()
dp = [0]*n
for i in range(0,n-1):
    ed = min(i+k+1,n)
    for j in range(i+1,ed):
        cost = dp[i]+abs(h[i] - h[j])
        if dp[j] == 0:
            dp[j] = cost
        elif dp[j] > cost:
            dp[j] = cost
print(dp[n-1])


Fixed submission:
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,k=mi()
h=np.array(li())
dp = np.array([0]*n)
for i in range(1,n):
    st = max(0,i-k)
    dp[i] = min(dp[st:i]+abs(h[i] - h[st:i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,k=mi()
h=li()
dp = [0]*n
for i in range(1,n):
    st = max(0,i-k)
    for j in range(st,i):
        if j == st:
            comp = dp[j]+abs(h[i] - h[j])
        else:
            comp = min(comp,dp[j]+abs(h[i] - h[j]))
    dp[i] = comp
print(dp[n-1])


Fixed submission:
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,k=mi()
h=np.array(li())
dp = np.array([0]*n)
for i in range(1,n):
    st = max(0,i-k)
    dp[i] = min(dp[st:i]+abs(h[i] - h[st:i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
 
n,k=mi()
h=li()
dp = [0]*n
for i in range(1,n):
    st = max(0,i-k)
    comp = []
    for j in range(st,i):
        comp.append(dp[j]+abs(h[i] - h[j]))
    dp[i] = min(comp)
print(dp[n-1])

Fixed submission:
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,k=mi()
h=np.array(li())
dp = np.array([0]*n)
for i in range(1,n):
    st = max(0,i-k)
    dp[i] = min(dp[st:i]+abs(h[i] - h[st:i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k=mi()
h=li()
dp = [0]*n
for i in range(1,n):
    st = max(0,i-k)
    comp = []
    for j in range(st,i):
        comp.append(dp[j]+abs(h[i] - h[j]))
        dp[i] = min(comp)
print(dp[n-1])

Fixed submission:
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,k=mi()
h=np.array(li())
dp = np.array([0]*n)
for i in range(1,n):
    st = max(0,i-k)
    dp[i] = min(dp[st:i]+abs(h[i] - h[st:i]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp = np.array([0]*(W+1))
for w,v in a:
    ed = W+1-w
    dp[w:W+1] = np.maximum(dp[w:ed], dp[0:ed] + v)
print(dp[W])

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp = np.array([0]*(W+1))
for w,v in a:
    ed = W+1-w
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[0:W+1-w] + v)
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]

dp = [0]*(W+1)
for w,v in a:
    for j in range(w,W+1)[::-1]:
        dp[j] = max(dp[j], dp[j-w] + v)
print(dp[W])

Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp = np.array([0]*(W+1))
for w,v in a:
    ed = W+1-w
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[0:W+1-w] + v)
print(dp[W])
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input.split())
print(max([a *c, a*d, b* c, b* d]))

Fixed submission:
a,b,c,d = map(int,input().split())
print(max([a *c, a*d, b* c, b* d]))
Buggy python submission (verdict: Runtime Error):
answer = 0
n = int(input())
a = list(map(int, input().split(" ")))
for i in range(n - 1):
    a = sorted(a[:5], key=a[:5].count, reverse=True) + a[5:]
    if a[0] == a[1] == a[2]:
        answer += 1
    	del a[:3]

if a[0] == a[1] == a[2]:
    answer += 1

print(answer)

Fixed submission:
want, max, time = map(int, input().split())
if want % max == 0:
  required = int(want / max)
else:
  required = int(want / max + 1)
print(required * time)

Buggy python submission (verdict: Runtime Error):
x,n,t = map(str,input().split(" "))
cnt =0
while (x > 0):
    x -= n
    cnt += 1
print(cnt * t)

Fixed submission:
want, max, time = map(int, input().split())
if want % max == 0:
  required = int(want / max)
else:
  required = int(want / max + 1)
print(required * time)

Buggy python submission (verdict: Runtime Error):
x,n,t = map(str,input().split())
cnt =0
while x > 0:
    x -= n
    cnt += 2
print(cnt * t)

Fixed submission:
want, max, time = map(int, input().split())
if want % max == 0:
  required = int(want / max)
else:
  required = int(want / max + 1)
print(required * time)
Buggy python submission (verdict: Runtime Error):
import math

n,d = map(str,input().split())
answer = 0
for i in range(n):
  x,y = map(str,input().split())
  if math.sqrt(x**2 + y**2) <= d:
    answer += 1
    
print(answer)

Fixed submission:
import math
 
n,d = map(int,input().split())
answer = 0
for i in range(n):
  x,y = map(int,input().split())
  if math.sqrt(x**2 + y**2) <= d:
    answer += 1
    
print(answer)
Buggy python submission (verdict: Runtime Error):
a = input()
print(1+ a**2 + a**3)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)