Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02639 (python)

Fixed submission:
a,b,c,d,e = map(int, input().split())
print(15-a-b-c-d-e)

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())

if 2*x <= y and y <= 4*x:
  if y % 2 == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Problem p02641 (python)

Fixed submission:
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    smaller = 0
    for i in range(x):
        if x - i in p:
            pass
        else:
            smaller = x-i
            break

    bigger = 2*x
    for j in range(x):
        if x + j in p:
            pass
        else:
            bigger = x + j
            break

    ans = smaller if x - smaller <= bigger - x else bigger
    #print(bigger)
    print(ans)
else:
    print(x)

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
else:
    print(x)

smaller = 0
for i in range(x):
    if x - i in p:
        pass
    else:
        smaller = x-i
        break

bigger = 2*x
for j in range(x):
    if x + j in p:
        pass
    else:
        bigger = x + j
        break

ans = smaller if x - smaller <= bigger - x else bigger
#print(bigger)
print(ans)

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))

smaller = 0
for i in range(x):
    if x - i in p:
        pass
    else:
        smaller = x-i
        break

bigger = 2*x
for j in range(x):
    if x + j in p:
        pass
    else:
        bigger = x + j
        break

ans = smaller if x - smaller <= bigger - x else bigger
#print(bigger)
print(ans)
Problem p02705 (python)

Fixed submission:
print(int(input())*6.28)

Buggy submission (verdict: Runtime Error):
import math
print(~-float(input())*2*math.pi)
Problem p02708 (python)

Fixed submission:
import math
n,k = map(int, input().split())
mod = 10**9 + 7
ans = 0

for i in range(k, n+2):
    max = (i*(n + n-i+1))//2
    min = (i*(i-1))//2
    ans += max - min + 1
    ans %= mod
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int, input().split())

ans = 0
for i in range(n-k+1):
    ans += math.factorial(n+1)/math.factorial(k+i)/math.factorial(n+1-k-i)

print(int(ans))
Problem p02761 (python)

Fixed submission:
n,m = map(int, input().split())

if m != 0:
    sc = [map(int, input().split()) for _ in range (m)]
    s,c = [list(i) for i in zip(*sc)]
else:
    pass

start = 0 if n == 1 else 10**(n-1)
for j in range(start,10**n+1):
    judge = 0
    for k in range(m):
        if str(j)[s[k]-1] == str(c[k]):
            judge += 1
        else:
            pass

    if judge == m:
        print(j)
        break
    elif j == 10**n:
        print(-1)
        #print(judge) #test
    else:
        pass

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc = [map(int, input().split()) for _ in range (m)]
s,c = [list(i) for i in zip(*sc)]

start = 0 if n == 1 else 10**(n-1)
for j in range(start,10**n+1):
    judge = 0
    for k in range(m):
        if str(j)[s[k]-1] == str(c[k]):
            judge += 1
        else:
            pass

    if judge == m:
        print(j)
        break
    elif j == 10**n:
        print(-1)
        #print(judge) #test
    else:
        pass

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc = [map(int, input().split()) for _ in range (m)]
s,c = [list(i) for i in zip(*sc)]

for j in range(10**(n-1),10**n+1):
    judge = 0
    for k in range(m):
        if str(j)[s[k]-1] == str(c[k]):
            judge += 1
        else:
            pass

    if judge == m:
        print(j)
        break
    elif j == 10**n:
        print(-1)
        #print(judge) #test
    else:
        pass
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
n,r = map(int, nput().split())
print(r if n>10 else r+100*(10-n))
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a+b,max(a-b,a*b)))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(max(a+b,max(a-b,a*b)))
Problem p03029 (python)

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

print((3*A+P)//2)

Buggy submission (verdict: Runtime Error):
int A = input()
int B = input()

print(int((3*A+B)/2))
Problem p03106 (python)

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

count = 0
for i in range(min(A,B), 0, -1):
	if A % i == 0 and B % i == 0:
		count += 1
	if count == K:
		print(i)
		exit()

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

count = 0
for i in range(min(A,B), 0, -1):
	if A % i == 0 and B % i == 0:
		count += 1
	if count == K:
    	print(i)
       	exit()

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

count = 0
for i in range(min(A,B), 0, -1):
	if A % i == 0 and B % i == 0:
		count += 1
    if count == K:
    	print(i)
        exit()
Problem p03280 (python)

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

print((A - 1) * (B - 1))

Buggy submission (verdict: Runtime Error):
input_A = input()
input_B = input()

A = int(input_A)
B = int(input_B)

print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
input_H1 = input()
input_H2 = input()

H1 = int(input_H1)
H2 = int(input_H2)

print((H1-1)*(H2-1))

Buggy submission (verdict: Runtime Error):
input_A = input()
input_B = input()

A = int(input_A)
B = int(input_B)

print((A-1)*(B-1))
Problem p02898 (python)

Fixed submission:
s,t=(int(x) for x in input().split())
n=list(map(int,input().split()))
k=0
for i in range(s):
    if t<=n[i]:
        k+=1
print(k)

Buggy submission (verdict: Runtime Error):
n,k=int(input().split())
h=list(map(int,input().split()))
result=0
for i in range(n):
  if h[i]>=k:
    result+=1
print(result)
Problem p03470 (python)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
data=[]
for i in range(0, n):
    data.append(int(stdin.readline().rstrip()))

print(len(set(data)))

Buggy submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
data=[]
for i in range(0, n):
    data.append(int(stdin.readline().rstrip()))

if n == 1:
    print(1)
    exit

pos=0
max_layer = 1

prev = data[pos]
pos = pos + 1
curr = data[pos]

num_layer = 1

while True:
    if curr < prev:
        num_layer = num_layer + 1
        if max_layer < num_layer:
            max_layer = num_layer
        pos = pos + 1
    elif curr == prev:
        pos = pos + 1
    else:
        pos = pos + 1
        num_layer = 1

    if pos >= n:
        break

    prev = curr
    curr = data[pos]

print(max_layer)
Problem p03854 (python)

Fixed submission:
from sys import stdin
import sys

S = stdin.readline().rstrip()
T = ''

data = ['dream', 'erase', 'dreamer', 'eraser']

if len(S) < len('dream'):
    print('NO')
    sys.exit()

pos = 0
flag_dream = False
flag_erase = False

while pos < len(S):
    if S[pos:pos+len(data[0])] == data[0]:
        pos = pos + len(data[0])
        flag_dream = True
        flag_erase = False
    elif S[pos:pos+len(data[1])] == data[1]:
        pos = pos + len(data[1])
        flag_erase = True
        flag_dream = False
    elif S[pos:pos+len(data[2])] == data[2]:
        pos = pos + len(data[2])
        flag_dream = False
        flag_erase = False
    elif S[pos:pos+len(data[3])] == data[3]:
        pos = pos + len(data[3])
        flag_dream = False
        flag_erase = False
    elif flag_dream and S[pos:pos+len('er')] == 'er':
        pos = pos + len('er')
        flag_dream = False
        flag_erase = False
    elif flag_erase and S[pos:pos+len('r')] == 'r':
        pos = pos + len('r')
        flag_dream = False
        flag_erase = False
    else:
        print('NO')
        sys.exit()


print('YES')

Buggy submission (verdict: Runtime Error):
from sys import stdin
import sys

S = stdin.readline().rstrip()
T = ''

#data = ['dream', 'dreamer', 'erase', 'eraser']
#data = ['dreamer', 'dream', 'eraser', 'erase']
data = ['dream', 'erase', 'dreamer', 'eraser']

pos = 0
while pos < len(S):
    if S[pos:pos+len(data[0])] == data[0]:
        pos = pos + len(data[0])
        flag_dream = True
    elif S[pos:pos+len(data[1])] == data[1]:
        pos = pos + len(data[1])
        flag_erase = True
    elif S[pos:pos+len(data[2])] == data[2]:
        pos = pos + len(data[2])
    elif S[pos:pos+len(data[3])] == data[3]:
        pos = pos + len(data[3])
    elif flag_dream and S[pos:pos+len('er')] == 'er':
        pos = pos + len('er')
        flag_dream = False
        flag_erase = False
    elif flag_erase and S[pos:pos+len('r')] == 'r':
        pos = pos + len('er')
        flag_dream = False
        flag_erase = False
    else:
        print('NO')
        sys.exit()


print('YES')
Problem p02657 (python)

Fixed submission:
n=input().split()
a=int(n[0])
b=int(n[1])
ans=a*b
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
ans=a*b
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a*b)
Problem p02755 (python)

Fixed submission:
import math
A, B = map(int,input().split())
for i in range(10000):
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        print(i)
        break
    elif i == 9999:
        print(-1)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int,input().split())
for i in range(1000):
    if math.floor(i * 0.08) == A:
        result = i
        break
if math.floor(result * 0.1) == B:
    print(result)
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int,input().split())
for i in range(1000):
    if math.floor(i * 0.08) == A:
        result = i
        break
if math.floor(result * 0.1) == B:
    print(result)
else:
    print(-1)
Problem p03759 (python)

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
     print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
 a, b, c = map(int, input().split())
 if b - a == c - b:
     print('YES')
else:
    print('NO')
Problem p03997 (python)

Fixed submission:
a , b , h = [int(input()) for _ in range(3)]
print(int((a + b) * h / 2))

Buggy submission (verdict: Runtime Error):
a , b , h = [int(input()) for _ in range(3)]
printint(((a + b) * h / 2))
Problem p04043 (python)

Fixed submission:
a = list(map(int, input().split()))
a.sort()
ans = [5, 5, 7]
if ans == a:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s  = int(input().split())
s.sort()
if s[0] == 5 and s[1] == 5 and s[2] == 7:
    print('YES')
else:
    print('NO')
Problem p03071 (python)

Fixed submission:
A,B = map(int,input().split())
A_A = A + A - 1
A_B = A + B
B_B = B + B - 1
list = [A_B, A_A, B_B]
list.sort(reverse=True)
print(list[0])

Buggy submission (verdict: Runtime Error):
a = input.split(' ')
A = a[0]
B = a[1]
A_A = A + A - 1
A_B = A + B
B_B = B + B - 1
list = [A_B, A_A, B_B]
list.sort(reverse=True)
print(list[0])
Problem p02981 (python)

Fixed submission:
N,A,B = map (int,input().split())
l=N*A
if l>B:
    print(B)
else:
    print(l)

Buggy submission (verdict: Runtime Error):
N = int(input('人数：'))
A = int(input('電車賃：'))
B = int(input('タクシー代：'))
l=N*A
if l>B:
    print(B)
else:
    print(l)
Problem p03086 (python)

Fixed submission:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
		if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
ans = max(ans, j - i + 1)
print(ans)
Problem p02700 (python)

Fixed submission:
import math
A,B,C,D = map(int,input().split())
if (math.ceil(C/B) <= math.ceil(A/D)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
if (math.ceil(C/B) =< math.ceil(A/D)):
    print('Yes')
else:
    print('No')
Problem p03101 (python)

Fixed submission:
HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1]))

Buggy submission (verdict: Runtime Error):
HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1])
Problem p03635 (python)

Fixed submission:
n,m = map(int,input().split())
k = (n-1)*(m-1)
print(k)

Buggy submission (verdict: Runtime Error):
n,m = int(input().split())
k = (n-1)*(m-1)
print(k)
Problem p02621 (python)

Fixed submission:
def a172(a):
 
    return a + a**2 + a**3
 
def main():
    a = int(input())
    print(a172(a))
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
num = input()
print(num+num**2+num**3)

Buggy submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
def a172(a):
 
    return a + a**2 + a**3
 
def main():
    a = int(input())
    print(a172(a))
 
if __name__ == '__main__':
    main()
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a * a + a * a * a)
Problem p02628 (python)

Fixed submission:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum(p[0:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = sorted(list(int(input()) for _ in range(n)))
print(sum(p[0:k]))
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
ans = []
for i in range(1,1251):
    if a == int(i*0.08) and b == int(i*0.1):
        ans.append(i)

if len(ans) == 0:
    print("-1")
else:
    print(min(ans))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = []
for i in range(1,101):
    if a == int(i*0.08) and b == int(i*0.1):
        ans.append(i)
else:
    print(min(ans))
Problem p02760 (python)

Fixed submission:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(i)] = "h"

if a[0:3].count("h") == 3 or a[3:6].count("h") == 3 or a[6:9].count("h") == 3:
    print("Yes")
elif a[0] == "h" and a[4] == "h" and a[8] == "h":
    print("Yes")
elif a[2] == "h" and a[4] == "h" and a[6] == "h":
    print("Yes")
elif a[0] == "h" and a[3] == "h" and a[6] == "h":
    print("Yes") 
elif a[1] == "h" and a[4] == "h" and a[7] == "h":
    print("Yes") 
elif a[2] == "h" and a[5] == "h" and a[8] == "h":
    print("Yes") 
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(a)] = "h"

if a[0:3].count("h") == 3 or a[3:6].count("h") == 3 or a[6:9].count("h") == 3:
    print("Yes")
elif a[0] == "h" and a[4] == "h" and a[8] == "h":
    print("Yes")
elif a[2] == "h" and a[4] == "h" and a[6] == "h":
    print("Yes")
elif a[0] == "h" and a[3] == "h" and a[6] == "h":
    print("Yes") 
elif a[1] == "h" and a[4] == "h" and a[7] == "h":
    print("Yes") 
elif a[2] == "h" and a[5] == "h" and a[8] == "h":
    print("Yes") 
else:
    print("No")
Problem p02784 (python)

Fixed submission:
h, n = map(int, input().split())
a = sorted(list(map(int, input().split())))
if sum(a) < h:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = sorted(list(map(int, input().split())))
if a[-1] + a[-2] < h:
    print('No')
else:
    print('Yes')
Problem p02957 (python)

Fixed submission:
a ,b = map(int, input().split())
if (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  print((a + b) // 2)

Buggy submission (verdict: Runtime Error):
a ,b = int(input()), int(input())
if (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  print((a + b) // 2)
Problem p02982 (python)

Fixed submission:
def dist(a, b):
	res = 0
	for i in range(D):
		res += (a[i] - b[i]) ** 2
	res = res ** 0.5
	return res


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		if dist(X[i], X[j]).is_integer():
			ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
def dist(a, b):
    res = 0
    for i in range(D):
        res += (a[i] - b[i])**2
    res = res ** 0.5
    return res

N, D = map(int,input().split())
x = [list(map(int, input().split()) for _ in range(N))]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if dist(x[i], x[i]).is_integer():
            ans += 1

print(ans)
Problem p03434 (python)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

Buggy submission (verdict: Runtime Error):
N = int(input())
data = list(map(int,input().split()))

Alice = []
Bob = []

while N != 0:
        Alice.append(max(data))
        data.remove(max(data))
        if len(data) == 0:
                break
        else:
                Bob.append(max(data))
                data.remove(max(data))
        N -= 1

print(sum(Alice)-sum(Bob))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
s = a*b
if s % 2 == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a*b
if s % 2 == 0:
  print("Even")
  else
  print("Odd")
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i
    else:
        continue

print(ans)

Buggy submission (verdict: Runtime Error):
N, A, B = int(input()), int(input()), int(input())
data = []

def digitsum(n):
        s = str(n)
        array = list(map(int, s))
        return sum(array)

n = 0
for n in range(N+1):
        x = digitsum(n)
        if A <= x <= B:
                data.append(x)

print(sum(data))

Buggy submission (verdict: Runtime Error):
N, A, B = int(input()), int(input()), int(input())
data = []

def digitsum(n):
        s = str(n)
        array = list(map(int, s))
        return sum(array)

n = 0
for n in range(N+1):
        x = digitsum(n)
        if A <= x <= B:
                data.append(x)

sum(data)
Problem p03697 (python)

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

if a+b >= 10:
    print('error')
else:
    print(a+b)

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

if a+b >= 10:
    print('error')
elif:
    print(a+b)
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    a == b:
    print('EQUAL')
Problem p03827 (python)

Fixed submission:
n = int(input())
s = input()
x = 0
m = [0,]

for i in range(len(s)):
    if s[i] == 'I':
        x += 1
        m.append(x)
    elif s[i] == 'D':
        x -= 1
        m.append(x)
else:
    print(max(m))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
x = 0
m = [0,]

def incre():
    for i in range(len(s)):
        if s[i] == 'I':
            x += 1
            m.append(x)
        elif s[i] == 'D':
            x -= 1
            m.append(x)
    else:
        print(max(m))

if __name__ == "__main__":
    incre()
Problem p02658 (python)

Fixed submission:
_, *A = map(int, open(0).read().split())
ans = 1

if 0 in A:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Buggy submission (verdict: Runtime Error):
_, *A = map(int, input().split())
A.sort()

ans = 1

if A[0] == 0:
  print(0)
else:
  for a in A:
    ans *= a
    if ans > 1000000000000000000:
      print(-1)
      break
  print(ans)
Problem p02755 (python)

Fixed submission:
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
c = set(a) & set(b)
if len(c):
    print(min(c))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
print(min(set(a) & set(b)))
Problem p02760 (python)

Fixed submission:
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
_, *B = map(int, open(0).read().split())
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
_, *B = map(int, open(0).read().split())
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except Exception:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)
Problem p03164 (python)

Fixed submission:

class obj:
    def __init__(self,w,v):
        self.w = w
        self.v = v
        self.r = v/w

x = input().split()
N = int(x[0])
M = int(x[1])
item = []
item = []
for i in range(N):
    x = input().split()
    item.append(obj(int(x[0]),int(x[1])))

maxV = 0


def getKey(x):
    return x.r


item.sort(key=getKey, reverse=True)
	
def Bound(i, C):	# object i -> n-1, capacity = C
    global item, N
    
    sw = 0
    sv = 0
    j = i
    f = 1.0
    while j < N and f == 1.0:
        wj = min(C-sw, item[j].w)
        f = float(wj)/item[j].w
        sw += f*item[j].w
        sv += f*item[j].v
        j += 1
    return sv



def dfsv4(i, sumW, sumV):
    """prning bounding, branching"""
    global maxV, item, N, M
    if i == N:
        if sumW <= M:
            maxV = max(maxV, sumV)
    else:   
        temp1 = Bound(i+1, M-sumW) + sumV
        temp2 = Bound(i,M-sumW) + sumV
        is1 = False

        if temp1 > temp2:
            is1 = True

        if is1:
            if temp1 > maxV:
                dfsv4(i+1, sumW, sumV)
            if sumW + item[i].w <= M:
                if temp2 > maxV:
                    dfsv4(i+1, sumW+item[i].w, sumV+item[i].v)
        else:
            if sumW + item[i].w <= M:
                if temp2 > maxV:
                    dfsv4(i+1, sumW+item[i].w, sumV+item[i].v)
            if temp1 > maxV:
                dfsv4(i+1, sumW, sumV)


dfsv4(0,0,0)

print(maxV)

Buggy submission (verdict: Runtime Error):
x = input().split()
N = int(x[0])
M = int(x[1])
w = []
v = [] 
for i in range(N):
    temp = input().split()
    w.append(int(temp[0]))
    v.append(int(temp[1]))

mem = [-1] * (M+1)

def maxVal(i,C):
            # index i, capacity C
    if mem[C] == -1:
        if i == N:
            return 0
        else:
            skip = maxVal(i+1,C)
            if w[i] <= C:   # w[i] does not exceed capacity
                take = v[i] + maxVal(i+1,C-w[i])
            else:
                take = -1
            mem[C] =  max(skip, take)
    return mem[C]
    

print(maxVal(0,M))