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

Fixed submission:
#全然わからず完コピ
H,W=map(int,input().split())
a=[list(input()) for _ in range(H)]
h=[]
for i in range(H):
  if a[i]==['.']*W:
    h.append(i)

w=[]
for i in range(W):
  flag=0
  for j in range(H):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)
  
ans=[]
for i in range(H):
  if i not in h:
    r=[]
    for j in range(W):
      if j not in w:
        r.append(a[i][j])
    ans.append(r)

for i in range(len(ans)):
  print("".join(ans[i]))

Buggy submission (verdict: Runtime Error):
#わからないのでギブアップコピペ
h,w=map(int,input().split())

a=[] #入力データのリスト化
for i in range(h):
  x=input().split()
  a.append(x)

h1=[]
for i in range(h):
  if a[i]==['.']*w:
    h1.append(i)

w1=[]
for i in range(w):
  flag=0
  for j in range(h):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w1.append(i)

ans=[]
for i in range(h):
  if i not in h1:
    r=[]
    for j in range(w):
      r.append(a[i][j])
    ans.append(r)

for i in range(lens(ans)):
  print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())

a=[] #入力データのリスト化
for i in range(h):
  x=input().split()
  a.append(x)

h1=[]
for i in range(h):
  if a[i]==['.']*w:
    h1.append(i)

w1=[]
for i in range(w):
  flag=0
  for j in range(h):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)

ans=[]
for i in range(h):
  if i not in h1:
    r=[]
    for j in range(w):
      r.append(a[i][j])
    ans.append(r)

for i in range(lens(ans)):
  print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
#わからないのでギブアップコピペ
h,w=map(int,input().split())

a=[] #入力データのリスト化
for i in range(h):
  x=input().split()
  a.append(x)

h1=[]
for i in range(H):
  if a[i]==['.']*w:
    h1.append(i)

w1=[]
for i in range(w):
  flag=0
  for j in range(h):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)

ans=[]
for i in range(h):
  if i not in h1:
    r=[]
    for j in range(w):
      r.append(a[i][j])
    ans.append(r)

for i in range(lens(ans)):
  print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
#わからないのでギブアップコピペ
h,w=map(int,input().split())

a=[] #入力データのリスト化
for i in range(h):
  x=input().split()
  a.append(x)

h1=[]
for i in range(H):
  if a[i]==['.']*w
    h1.append(i)

w1=[]
for i in range(w):
  flag=0
  for j in range(h):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)

ans=[]
for i in range(h):
  if i not in h1:
    r=[]
    for j in range(w):
      r.append(a[i][j])
    ans.append(r)

for i in range(lens(ans)):
  print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
#わからないのでギブアップ・コピペ

h,w=map(int,input().split())

a=[] #入力データのリスト化
for i in range(h):
  x=input().split()
  a.append(x)

h1=[]
for i in range(h):
  if a[i]==['.']:
    h1.append(i)

w1=[]
for i in range(w):
  flag=0
  for j in range(h):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)

ans=[]
for i in range(h):
  if i not in h1:
    r=[]
    for j in range(w):
      r.append(a[i][j])
    ans.append(r)

for i in range(lens(ans)):
  print(''.join(ans[i]))
Problem p03282 (python)

Fixed submission:
import sys

s=input()
k=int(input())


s=list(s)

c=0
for i in range(len(s)):
        if s[i]=='1':
                c+=1
if c==len(s):
        print('1')
        sys.exit()

d=0
if len(s)>=k:
        for i in range(k):
                if s[i]=='1':
                        d+=1
if d==k:
        print('1')
        sys.exit()

for i in range(len(s)):
        if s[i]!='1':
                print(s[i])
                sys.exit()

Buggy submission (verdict: Runtime Error):
import sys

s=input()
k=int(input())


s=list(s)

c=0
for i in range(k):
        if s[i]=='1':
                c+=1
if c==k:
        print('1')
        sys.exit()
                

for i in range(len(s)):
        if s[i]!='1':
                print(s[i])
                sys.exit()
Problem p03316 (python)

Fixed submission:
n=int(input())
s=list(str(n))
for i in range(len(s)):
  s[i]=int(s[i])
b=sum(s)
a=n%b

if a==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(str(n))
a=n%(sum(s))

if a==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(str(n))
a=n%(sum(s))

if a==0:
  print('Yes')
else:
  print('No')
Problem p03434 (python)

Fixed submission:
N=int(input())
a=sorted([int(i) for i in input().split()],reverse=True)
print(sum(a[0::2])-sum(a[1::2]))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=sorted([int(i) for i in input().split()],reverse=True)
print(sum(a[0::2]-sum(a[1::2]))
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split()) #1行で1スペースあけて入力

if (a*b)%2==0:
    print('Even')
else:
    print('Odd')

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

if (a*b)%2==0:
    print("Even")

else:
    print("Odd")

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

if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split()) #入力を改行ではなくてスペース1マスあける

x=(a+b)/2
if x%1==0:
    print(int(x))
else:
    print(int(x)+1)

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

x=(a+b)/2
if x%1==0:
    print(int(x))
else:
    print(int(x)+1)
Problem p03502 (python)

Fixed submission:
N=input()
a=int(N)
b=list(N)
sum=0

for i in b:
  sum+=int(i)
 
if a%sum==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=input()
a=int(N)
b=list(N)
sum=0

for i in b:
  sum+=i
 
if a%sum==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=input()
a=int(N)
b=list(N)
sum=0
for i in N:
  sum+=i
 
if a%sum==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=input()
a=int(N)
b=list(N)
sum=0
for i in N:
  sum+=i

if N%sum==0:
  print('Yes')
else:
  print('No')
Problem p03544 (python)

Fixed submission:
N=int(input())
lst=[2,1]
for i in range(2,N+1):
    lst.append(lst[i-1]+lst[i-2])
print(lst[N])

Buggy submission (verdict: Runtime Error):
N=int(input())

def liu(i):
    if i==2:
        return 3
    if i==3:
        return 4
    else:
        return liu(i-1)+liu(i-2)

print(liu(N))
Problem p03712 (python)

Fixed submission:
H,W=map(int,input().split())
a=[]
a.append('#'*(W+2))
for i in range(1,H+1):
  a.append('#'+input()+'#')
a.append('#'*(W+2))
for i in range(H+2):
  print(a[i])

Buggy submission (verdict: Runtime Error):
H,W=int(input().split())
a=[]
a.append('#'*(W+2))
for i in range(1,H+1):
  a.append('#'+input()+'#')
a.append('#'*(W+2))
for i in range(H+2):
  print(a[i])
Problem p02621 (python)

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

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

print(a+ a*a + a*a*a)
Problem p02641 (python)

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

if N == 0:
        print(X)
        exit()

p.sort()
tmp = [i for i in range(-111, 111)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i


print(tmp[ans_i])

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

if N == 0:
        print(X)
        exit()

p.sort()
tmp = [i for i in range(1, 101)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i


print(tmp[ans_i])

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

p.sort()
tmp = [i for i in range(1, 101)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i
if N == 0:
        print(X)
else:
        print(tmp[ans_i])

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

p.sort()
tmp = [i for i in range(1, 101)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i

print(tmp[ans_i])

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


p.sort()

tmp = [i for i in range(1, 101)]
for i in p:
        tmp.remove(i)


ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i

print(tmp[ans_i])
Problem p02660 (python)

Fixed submission:
N = int(input())


hash = {}
end = int(N ** (1/2))
for i in range(2, end + 1):
    while N % i == 0:
        if i in hash:
            hash[i] += 1
        else:
            hash[i] = 1
        N = N // i
if N != 1:
        if N in hash:
            hash[N] += 1
        else:
            hash[N] = 1

if len(hash.keys()) == 0 and N != 1:
    print(1)
    exit()


count = 0
trans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

res = 0
for i in hash.values():
    for j in range(len(trans)):
        if i > trans[j]:
            continue
        elif i == trans[j]:
            res += (j + 1)
            break
        else:
            res += j
            break



print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N == 1:
    print(0)
    exit()

ans = []
end = int(N ** (1/2))
for i in range(2, end + 1):
    while N % i == 0:
        ans.append(i)
        N = N // i

if len(ans) == 0:
    print(1)
    exit()

count = 0
trans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

res = 0
for i in range(len(ans) - 1):
    if ans[i] != ans[i+1]:
        for j in range(len(trans)):
            if count > trans[j]:
                continue
            else:
                res += (j + 1)
                break
        count = 1
    else:
        count += 1

if ans[-1] == ans[-2]:
    if ans[-1] == ans[0]:
        count += 1
    for j in range(len(trans)):
        if count > trans[j]:
            continue
        elif count == trans[j]:
            res += (j + 1)
            break
        else:
            res += (j)
            break
else:
    res += 1

print(res)
Problem p02719 (python)

Fixed submission:
N, K = map(int, input().split())
tmp = N % K
print(min(tmp, abs(tmp - K)))

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

a = abs(N - K)
ans1 = N % a
b = abs((N % a) - a)
ans2 = N % b

print(min(ans1, ans2))

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


if K > N:
    print(N)
    exit()

a = abs(N - K)
ans1 = N % a
ans2 = abs((N % a) - a)
if K == 1:
    print(0)
else:
    print(min(ans1, ans2))

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


if K > N:
    print(N)
    exit()

a = abs(N - K)
ans = N % a

if ans == 1:
    print(0)
else:
    print(ans)

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

a = abs(N - K)
ans = N % a

if ans == 1:
    print(0)
else:
    print(ans)
Problem p02780 (python)

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 10000

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 1001

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 1001

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [0] * 1001

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != 0:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)
Problem p02972 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = sum(ball[1:])
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = ball[1:]
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = ball(a[1:])
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")
Problem p03060 (python)

Fixed submission:
import itertools
N = int(input())

test = {}

V = list(map(int,input().split()))
C = list(map(int,input().split()))
new_n = 0
for i in range(N):
    if V[i] <=  C[i]:
        continue
    else:
        test[i] = [V[i],C[i]]
        new_n += 1

N = new_n

def calc_cost(com,test,i):
    x = 0
    y = 0
    for j in com:
        x += test[j][0]
        y += test[j][1]
    return x - y

ans = 0

for i in range(N):
    c = itertools.combinations(test.keys(), i+1)
    for j in c:
        ans = max(ans,calc_cost(j,test,i))


print(ans)

Buggy submission (verdict: Runtime Error):

test = {}

V = list(map(int,input().split()))
C = list(map(int,input().split()))

new_n = 0
for i in range(N):
    if V[i] <=  C[i]:
        continue
    else:
        test[i] = [V[i],C[i]]
        new_n += 1

N = new_n

def calc_cost(com,test,i):
    x = 0
    y = 0
    for j in com:
        x += test[j][0]
        y += test[j][1]
    return x - y

ans = 0




for i in range(N):
    c = itertools.combinations(test.keys(), i+1)
    for j in c:
        ans = max(ans,calc_cost(j,test,i))


print(ans)
Problem p03061 (python)

Fixed submission:
def gcd(x,y):
    if x % y == 0:
        return y
    else:
        x %= y
        return gcd(y, x)

N = int(input())
blackboard = list(map(int,input().split()))

l_gcd = [-1] * N
r_gcd = [-1] * N

for i in range(N):
    if i == 0:
        l_gcd [0] = blackboard[0]
    else:
        l_gcd[i] = gcd(l_gcd[i-1],blackboard[i])


for i in reversed(range(N)):
    if i == N - 1:
        r_gcd[N-1] = blackboard[N-1]
    else:
        r_gcd[i] = gcd(r_gcd[i+1],blackboard[i])


#左端と右端のときの値を予め比較しておく。
ans = max(l_gcd[-2],r_gcd[1])

for i in range(1,N-1):
    ans = max(ans,gcd(l_gcd[i-1],r_gcd[i+1]))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import itertools
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)



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


c = itertools.combinations(A, N-1)

a_max = gcd(*A)
for i in c:
    a_max = max(a_max, gcd(*list(i)))

print(a_max)

Buggy submission (verdict: Runtime Error):
import math
import itertools
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)



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


c = itertools.combinations(A, N-1)

a_max = gcd(*A)
for i in c:
    a_max = max(a_max, gcd(*list(i)))

print(a_max)
Problem p03078 (python)

Fixed submission:
X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split())) 


A = sorted(A, key = lambda x:-x)
B = sorted(B, key = lambda x:-x)
C = sorted(C, key = lambda x:-x)

AB = [0] * (X * Y)

ABC = []

for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC = sorted(ABC, key = lambda x:-x)
for i in range(0, K):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split())) 


A = sorted(A, key = lambda x:-x)
B = sorted(B, key = lambda x:-x)
C = sorted(C, key = lambda x:-x)

AB = [0] * (X * Y)

index = 0
for i in range(len(A)):
    for j in range(len(B)):
        AB[index] = A[i] + B[j]
        index += 1

AB = sorted(AB, key = lambda x:-x)

ABC = [0] * min(3000, X * Y * Z)
index = 0
for i in AB:
    for j in C:
        ABC[index] = i + j
        index += 1

ABC = sorted(ABC, key = lambda x:-x)
for i in range(0,K):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
line = input().split(sep=" ")
x = int(line[0])
y = int(line[1])
z = int(line[2])
in_k = int(line[3])


in_x = sorted(list(map(int,input().split(sep=" "))),reverse=True)
in_y = sorted(list(map(int,input().split(sep=" "))),reverse=True)
in_z = sorted(list(map(int,input().split(sep=" "))),reverse=True)

ans_arr = []

if(x > in_k ): x =in_k
if(y > in_k ): y =in_k
if(z > in_k ): z =in_k

print(x)
for i in range(x):
	for j in range(y):
		if((i+1) * (j+1) > in_k) break
		for k in range(z):
			ans_arr.append(in_x[i] + in_y[j] + in_z[k])
			if((i+1) * (j+1) * (k+1) > in_k) break

ans_arr = sorted(ans_arr,reverse=True)

for i in range(in_k):
	print(ans_arr[i])
Problem p03164 (python)

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

cost = [list(map(int,input().split())) for i in range(N)]


dp = [[float('inf')] * (100001) for i in range(N)]


for i in range(N):
    for j in range(100001):
        if j == 0:
            dp[i][j] = 0

for i in range(N):
    for sum_v in range(0,100001):
        if sum_v - cost[i][1] >= 0:
            dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][sum_v - cost[i][1]] + cost[i][0])
        dp[i][sum_v] = min(dp[i][sum_v], dp[i-1][sum_v])

ans = float('inf')

for j in range(0,100001):
    if dp[N-1][j] <= W:
        ans = j
print(ans)

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

cost = [list(map(int,input().split())) for i in range(N)]
dp = [[0] * (W+1) for i in range(N)]


for i in range(N):
    for sum_w in range(0,W+1):
        if sum_w - cost[i][0] >= 0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w - cost[i][0]] + cost[i][1])
        dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])

print(dp[N-1][W])
Problem p03219 (python)

Fixed submission:
X, Y = map(int, input().split())
print(int(X + Y / 2))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
all_city = [list(map(int,input().split())) for i in range(M)]

city = {}
for i in all_city:
    if i[0] in city:
        city[i[0]].append(i[1])
    else:
        city[i[0]] = [i[1]]



for i,k in city.items():
    city[i] = sorted(k)

def change_Prefecture_code(prefecture):
    return str(prefecture).zfill(6)

def change_birth_code(birth_num):
    return str(birth_num).zfill(6)

for i in all_city:
    print(change_Prefecture_code(i[0]) + change_birth_code(city[i[0]].index(i[1]) + 1))
Problem p03261 (python)

Fixed submission:
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	sys.exit()

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if(len(item) > 11):
			print("No")
			sys.exit()
		if not (item[0] == last_char):
			print("No")
			sys.exit()
		else:
			last_char = item[-1]
			
print("Yes")

Buggy submission (verdict: Runtime Error):
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	exit(99)

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if(len(item)):
			print("No")
			exit(99)
		if not (item[0] == last_char):
			print("No")
			exit(99)
		else:
			last_char = item[-1]
			
print("Yes")

Buggy submission (verdict: Runtime Error):
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	exit(99)

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if not (item[0] == last_char):
			print("No")
			exit(99)
		else:
			last_char = item[-1]
			
print("Yes")

Buggy submission (verdict: Runtime Error):
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	exit(99)

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if not (item[0] == last_char):
			print("No")
			exit(99)
		else:
			last_char = item[-1]
			
print("Yes")