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

Fixed submission:
s = input()
t = s[2:-1]
count = 0
q = [s[1]]
for i in range(len(t)):
    if t[i] == "C":
        count += 1
    else:
        q.append(t[i])
q.append(s[-1])
q =''.join(q)
if s[0] == "A" and count == 1 and str(q).lower() ==str(q):
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
s = input()
t = s[2:-1]
count = 0
q = [t[1]]
for i in range(len(t)):
    if t[i] == "C":
        count += 1
    else:
        q.append(t[i])
q.append(t[-1])
q = ''.join(q)
if s[0] == "A" and count == 1 and str(q).lower ==q:
    print("AC")
else:
    print("WA")
Problem p03293 (python)

Fixed submission:
s = input()
t = input()
c = list(s)
d = list(t)
for i in range(len(c)):
    c.insert(0, c[-1])
    del c[-1]
    if c == d:
        print("Yes")
        break
    if i == len(c) -1:
        print("No")

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

counter = {}
for c in a:
    if not c in counter:
        counter[c] = 1
    else:
        counter[c] += 1
counter_2 = {}
for c in a:
    if not c in counter_2:
        counter_2[c] = 1
    else:
        counter_2[c] += 1
if conter == counter_2:
    print(True)
else:
    print(False)
Problem p03325 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(N):
    while a[i] %2 == 0:
        b += 1
        a[i] /= 2
print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b = 0
#print(a)
for i in range(N):
    while a[i] %2 == 0:
        b += 1
        a[i] /= 2
print(b)
Problem p02690 (python)

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

for a_ in range(-500, 500):
    for b_ in range(-500, 500):
        if a_**5 - b_**5 ==x:
            a = a_
            b = b_
            break
            
print(a, b)

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

for a_ in range(3):
    _ = a_**5 - x
    b_ = _**0.2
    if a_**5 - b_**5 ==x:
        a = a_
        b = b_**5
        
print(a, int(b))
Problem p02717 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
X, Y = Y, X
X, Z = Z, X
print(str(X)+' '+str(Y)+' '+str(Z))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
item_vote = list(map(int, input().split()))
total_vote = sum(item_vote)
item_vote = sorted(item_vote, reverse=True)
boder = total_vote/4*M
if item_vote[M-1] >= boder:
    print('Yes')
else:
    print('No')

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

total_vote = sum(item_vote)
item_vote = sorted(item_vote, reverse=True)
boder = total_vote/4*M
if item_vote[M-1] >= boder:
    print('Yes')
else:
    print('No')
Problem p02719 (python)

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

a = N % K
b = abs(a-K)
if a<b:
    print(a)
else:
    print(b)

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

if N < K:
    print(N)
else:
    a = N % K
    b = abs(a-k)
    if a<b:
      print(a)
    else:
      print(b)

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

if N < K:
    print(N)
elif N % K == 0:
    print(0)
else:
    a = N % K
    if a<k:
      print(a)
    else:
      print(k)
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans_list = [0]
a = 0
ans = 0
ans_ = 0
for i in range(n):
    a += (1+p[i])/2
    ans_list.append(a)
for i in range(n-k+1):
    ans_ = ans_list[i+k]-ans_list[i]
    ans = max(ans, ans_)
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
    a = 0
    for j in range(k):
        a += ((1+p[i+j])*p[i+j])/2
    if ans <= a:
        ans = a

ans_list.sort(reverse=True)
print(ans)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans_max = 0
V_ans=[]
C_ans=[]

for i in range(0,N):
    if V[i]>C[i]:
        V_ans.append(V[i])
        C_ans.append(C[i])

print(sum(V_ans)-sum(C_ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans_max = 0
V_ans=[]
C_ans=[]

for i in range(0,N):
    if V[i]>C[i]:
        V_ans.append(V[i])
        C_ans.append(C[i])
        
print(V_ans.sum-C_ans.sum)
Problem p03071 (python)

Fixed submission:
coin = list(map(int, input().split()))
a=coin[0]
b=coin[1]

sum1=a+a-1
sum2=a+b
sum3=b+b-1

if sum1<sum2:
    if sum3<sum2:
        ans=sum2
    else:
        ans=sum3
else:
    if sum1>=sum3:
        ans=sum1

print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())

a=x+x+1
b=x+y
c=y+y+1

if a>b:
  if a>c:
    ans=a
else:
  if b>c:
    ans=b
  else:
    ans=c
    
print(ans)
Problem p02612 (python)

Fixed submission:
N=int(input())
Na=N%1000
if Na==0:
  print(Na)
else:
  print(1000-Na)

Buggy submission (verdict: Runtime Error):
N=int(input())
Na=N%1000
if Na=0:
  print(Na)
else:
  print(1000-Na)
Problem p02613 (python)

Fixed submission:
C0=0
C1=0
C2=0
C3=0
N=int(input())
S=list(range(N))
for i in range(N):
  S[i] = input()
for i in range(N):
  if S[i]=="AC":
    C0 += 1
  elif S[i]=="WA":
    C1 += 1
  elif S[i]=="TLE":
    C2 += 1
  else:
    C3 += 1
print("AC","x",C0)
print("WA","x",C1)
print("TLE","x",C2)
print("RE","x",C3)

Buggy submission (verdict: Runtime Error):
C0=0
C1=0
C2=0
C3=0
N=int(input())
S=list(range(N))
for i in range(N):
  S[i] = input()
for i in range(N):
  if S[i]==AC:
    C0 += 1
  elif S[i]==WA:
    C1 += 1
  elif S[i]==TLE:
    C2 += 1
  else:
    C3 += 1
print("AC","x",C0)
print("WA","x",C1)
print("TLE","x",C2)
print("RE","x",C3)
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
a=int.(input())
print(a+a**2+a**3)
Problem p02713 (python)

Fixed submission:
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      g = math.gcd(a,b)
      g = math.gcd(g,c)
      ans += g
print(ans)

Buggy submission (verdict: Runtime Error):
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,1+k):
    for c in range(1,1+k):
      g = math.gcd(a,b)
      g = math.gcd(g.c)
      ans += g
print(ans)

Buggy submission (verdict: Runtime Error):
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,1+k):
    for c in range(1,1+k):
      g = math.gcd(a,b)
      g = math.gcd(g.c)
      ans += g
print(ans)

Buggy submission (verdict: Runtime Error):
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,1+k):
    for c in range(1,1+k):
      g = math.gcd(a,b,c)
      ans += ans
print(ans)
Problem p03210 (python)

Fixed submission:
x = int(input())
if x==3 or x==5 or x==7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
X = input()
if X=3 or X=5 or X=7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
if X=3 or X=5 or X=7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
if x=3 or X=5 or x=7:
  print("YES")
else:
  print("NO")
Problem p02613 (python)

Fixed submission:
N = int(input())
SAC = 0
SWA = 0
STLE = 0
SRE = 0
for i in range(N):
  tmp = input()
  if tmp == 'AC':
    SAC += 1
  elif tmp == 'WA':
    SWA += 1
  elif tmp == 'TLE':
    STLE += 1
  elif tmp == 'RE':
    SRE += 1

print("AC x " + str(SAC))
print("WA x "+ str(SWA))
print("TLE x "+str(STLE))
print("RE x "+str(SRE))

Buggy submission (verdict: Runtime Error):
N = int(input())
SAC = 0
SWA = 0
STLE = 0
SRE = 0
for i in range(N):
  tmp = imput()
  if tmp == 'AC':
    SAC += 1
  elif tmp == 'WA':
    SWA += 1
  elif tmp == 'TLE':
    STLE += 1
  elif tmp == 'RE':
    SRE += 1

print("AC x " + str(SAC))
print("WA x "+ str(SWA))
print("TLE x "+str(STLE))
print("RE x "+str(SRE))
Problem p02760 (python)

Fixed submission:
b = []
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])

n = int(input())

for i in range(0, n):
    v = int(input())

    for i in range(0, 3):
        for j in range(0, 3):
            if b[i][j] == v:
                b[i][j] = 999

ans = 'No'

for i in range(0, 3):
    s = set(b[i])

    if len(s) == 1:
        ans = 'Yes'

for i in range(0, 3):
    s = set([b[0][i], b[1][i], b[2][i]])

    if len(s) == 1:
        ans = 'Yes'

c = set([b[0][0], b[1][1], b[2][2]])

if len(c) == 1:
    ans = 'Yes'

c = set([b[0][2], b[1][1], b[2][0]])

if len(c) == 1:
    ans = 'Yes'

print(ans)

Buggy submission (verdict: Runtime Error):
60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34
Problem p03324 (python)

Fixed submission:
#!/use/bin/env python3

import math
from collections import defaultdict

(d, n) = [int(s) for s in input().split()]

ans = 0

if d == 0:
    ans = 1
elif d == 1:
    ans = 100
else:
    ans = 10000

ans = 101 * ans if n == 100 else n * ans

print(ans)

Buggy submission (verdict: Runtime Error):
#!/use/bin/env python3

import math
from collections import defaultdict

(d, n) = [int(s) for s in input().split()]

ans = []

if d == 0:
    ans = range(1, 101)
elif d == 1:
    ans = range(100, 100 * 100 + 100, 100)
else:
    ans = range(10000, 100 * 100 * 100, 100 * 100)

print(ans[n - 1])
Problem p04043 (python)

Fixed submission:
#!/use/bin/env python3

a = [int(s) for s in input().split()]

b, c, d = sorted(a)

if b == 5 and c == 5 and d == 7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
#!/use/bin/env python3

(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

like = []

ans = n

while (1):

    c = True
    for ii in range(0, 4):
        b = n // pow(10, ii)
        d = b % 10

        if b == 0:
            break

        if d in a:
            c = False
            break

    if (c):
        ans = n
        break
    n += 1

print(ans)
Problem p04045 (python)

Fixed submission:
#!/use/bin/env python3

(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

like = []

ans = n
b = n
while (1):

    c = True
    b = n
    while (b != 0):
        d = b % 10
        b = b // 10

        if d in a:
            c = False
            break

    if (c):
        ans = n
        break
    n += 1

print(ans)

Buggy submission (verdict: Runtime Error):
#!/use/bin/env python3

(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

like = []

ans = n

while (1):

    c = True
    for ii in range(0, 4):
        b = b // 10
        d = b % 10

        if b == 0:
            break

        if d in a:
            c = False
            break

    if (c):
        ans = n
        break
    n += 1

print(ans)
Problem p02946 (python)

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  hoge = str(i) + ' '
  output += hoge

output.rstrip()

print(output)

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  output += (i + ' ')

output.rstrip()

print(output)

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  output += f'{i} '

output.rstrip()

print(output)

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, max):
  output += f'{i} '

output.rstrip()

print(output)
Problem p02612 (python)

Fixed submission:
input_yen = int(input())
unit_yen = 1000

required_bill = int(float(input_yen)/unit_yen + (float(input_yen) % unit_yen > 0)) * unit_yen
print(required_bill - input_yen)

Buggy submission (verdict: Runtime Error):
input_yen = int(input())
unit_yen = 1000

required_bill = int(float(input_yen)/unit_yen) * unit_yen
return required_bill - input_yen
Problem p02690 (python)

Fixed submission:

import sys

X = int(input())
a = [i for i in range(-119, 120)]
b = [i for i in range(-119, 120)]

for i in a:
    for k in b:
        if i**5 == X + k**5:
            print(i,k)
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys

X = int(input())
a = [i for i in range(-10,101)]
b = [i for i in range(-10, 101)]

for i in a:
    for k in b:
        if i**5 == X + k**5
            print(i,k)
            sys.exit()
Problem p02720 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限

K = int(input())

l = [1,2,3,4,5,6,7,8,9] #１桁のルンルン数
ln = [1,2,3,4,5,6,7,8,9] #既にわかっている分をセット。重複がいやなのでset

def dfs(i):
    n = int(str(i)[-1]) #1桁目を取る
    a,b,c = n-1, n, n+1 #差の絶対値が１未満、-1/+0/+1
    if a != -1:
        ln.append(i*10+a)
    ln.append(i*10+b)
    if c != 10:
        ln.append(i*10+c)
    
    if len(str(i)) <= 10:
        if a != -1:
            dfs(i*10 + a)
        dfs(i*10 + b)
        
        if c != 10:
            dfs(i*10 + c)

for i in l: #１桁のルンルン数を順番に再帰
    dfs(i)

print(sorted(ln)[K-1]) #0-indexを意識してリストのK-1番目を出す

Buggy submission (verdict: Runtime Error):
k = str(input())
list = []
def lunlun(k):
    for i in range(len(k) - 1):
        if abs(int(k[i]) - int(k[i+1])) > 1:
            return False
            break
    return True

i = 1
while len(list) == int(k):
    if lunlun(i):
        list.append(i)
    i += 1

print(lunlun(len(k)))
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = input().split()
w = ''
 
for i in range(n):
    w += s[i] + t[i]
 
print(w)

Buggy submission (verdict: Runtime Error):
n = input()
s, t = input().split()
w = ''

for i in range(n):
    w += s[i] + t[i]

print(w)

Buggy submission (verdict: Runtime Error):
n = input()
s, t = input().split()

for i in range(n):
  w += s[i] + t[i]

print(w)
Problem p02936 (python)

Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy submission (verdict: Runtime Error):
def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
#print(edges)
px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])
Problem p02995 (python)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())
e = c*d//fractions.gcd(c,d)


i = (a-1) // c #aのcの約数の数
j = b // c #bのcの約数の数
k = (a-1) // d #aのdの約数の数
l = b // d #bのdの約数の数
m = (a-1) // (e) #aのc*dの約数の数
n = b // (e) #bのc*dの約数の数

x = (j-i) + (l-k) - (n-m)
y = b - a + 1
print(y-x)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
e = c*d//math.gcd(c,d)


i = (a-1) // c #aのcの約数の数
j = b // c #bのcの約数の数
k = (a-1) // d #aのdの約数の数
l = b // d #bのdの約数の数
m = (a-1) // (e) #aのc*dの約数の数
n = b // (e) #bのc*dの約数の数

x = (j-i) + (l-k) - (n-m)
y = b - a + 1
print(y-x)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
e = c*d//math.gcd(c,d)


i = (a-1) // c #aのcの約数の数
j = b // c #bのcの約数の数
k = (a-1) // d #aのdの約数の数
l = b // d #bのdの約数の数
m = (a-1) // (e) #aのc*dの約数の数
n = b // (e) #bのc*dの約数の数

x = (j-i) + (l-k) - (n-m)
y = b - a + 1
print(y-x)
Problem p03031 (python)

Fixed submission:
N,M=map(int,input().split())
s=[list(map(int,input().split()))[1:] for m in range(M)]
p=list(map(int,input().split()))
count=0
for i in range(1<<N):
    for m in range(M):
        switch=0
        for j in range(N):
            if (i>>j)&1 and j+1 in s[m]:
                switch+=1
        if switch%2!=p[m]:
            break
    else:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for m in range(m)]
p = list(map(int, input().split()))

for i in range(2 ** n):
    for m in range(M):
        switch = 0
        for j in range(n):
            if (i >> j) & 1:
                if j + 1 in s[m]:
                    switch += 1
        if switch % 2 != p[m]:
            break
    else:
        count += 1
print(count)
Problem p03037 (python)

Fixed submission:
n, m = map(int, input().split())
L, R = [], []
for _ in range(m):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)


res = min(R) - max(L) + 1
if res < 0:
    print(0)
else:
    print(res)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
L, R = [], []
for _ in range(m):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)


res = min(R) - max(L) + 1
if res < 0:
    print(0)
else:
    print(ans)
Problem p03160 (python)

Fixed submission:
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

#初期値
dp[0] = 0

#Loop
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split())) #0-index

inf = float('inf')
dp = [inf]*(N+1)

def chmin(a,b):
    if a >= b:
        return b
    else:
        a

dp[0] = 0
for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    
    if i >= 2:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
INF = 10**8
dp = [INF] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        
    dp[i] = res
    return res
print(DFS(N-1))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N
INF = float('INF')
def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        
    dp[i] = res
    return res
print(DFS(N-1))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N
INF = float('INF')
def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    dp[i] = res
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        dp[i] = res
    
    return res
print(DFS(N-1))
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

def chmax(a, b):
    if a >= b:
        return a
    else:
        return b

dp = [[0]*(10**5 + 10) for _ in range(110)]

#i個の品物を入れて重さがjになっているときの価値の総和の最大値
#dp[i+1][j] = dp[i][j - w[i] + v[i]] 入れるとき
#dp[i+1][j] = dp[i][j] 入れないとき

#dp[0][j] = 0 初期値設定でOK
for i in range(N+1):
    for j in range(W+1):
        dp[i+1][j] = chmax(dp[i+1][j], dp[i][j])
        if (i < N):
            if (j >= w[i]):
                dp[i+1][j] = chmax(dp[i+1][j], dp[i][j - w[i]] + v[i])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)] #1-index

# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0]*(W+10) for _ in range(N+10)]

for i in range(N):
    for w in range(W+1):
        dp[i+1][w] = dp[i][w]
        
        if w - wv[i][0] >= 0:
            dp[i+1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)] #1-index

# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0]*(W+10) for _ in range(N+10)]

for i in range(N):
    for w in range(W+1):
        dp[i+1][w] = dp[i][w]
        
        if w - wv[i][0] >= 0:
            dp[i+1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)] #1-index

# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0]*(W+10) for _ in range(N+10)]

for i in range(N):
    for w in range(W+1):
        dp[i+1][w] = dp[i][w]
        
        if w - wv[i][0] >= 0:
            dp[i+1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])

print(dp[N][W])
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
print(a * b - (a + b -1))
Problem p03476 (python)

Fixed submission:
#ABC 084 D - 2017 Like Number
from itertools import accumulate

def isPrime(x):
    if x == 2: flag = True
    else:
        flag = True
        if x % 2 == 0:
            flag = False
        
        i = 3
        while i**2 <= x and flag == True:
            if x % i == 0:
                flag = False
            else:
                i += 2
    return True if flag == True else False

q = int(input())
arr = []
max_v = 0
for i in range(q):
    l,r = map(int, input().split())
    arr.append((l,r))
    max_v = max(max_v, r)

res_arr = [0]*(max_v+1)
for i in range(3,max_v+1,2):
    v1, v2 = i, (i+1)//2
    if isPrime(v1) == True and isPrime(v2) == True:
        res_arr[i] = 1

cumsum = list(accumulate(res_arr))
#print(res_arr)
#print(cumsum)
for i in range(q):
    l,r = arr[i][0], arr[i][1]
    print(cumsum[r] - cumsum[l-1])

Buggy submission (verdict: Runtime Error):
#ABC 084 D - 2017 Like Number
from itertools import accumulate

def isPrime(x):
    if x == 2: flag = True
    else:
        flag = True
        if x % 2 == 0:
            flag = False
        
        i = 3
        while i**2 <= x and flag == True:
            if x % i == 0:
                flag = False
            else:
                i += 2
    return True if flag == True else False

q = int(input())
arr = []
for i in range(q):
    l,r = map(int, input().split())
    arr.append((l,r))

max_arr = max(arr)[1]
res_arr = [0]*(max_arr+1)
for i in range(3,max_arr+1,2):
    v1, v2 = i, (i+1)//2
    if isPrime(v1) == True and isPrime(v2) == True:
        res_arr[i] = 1

cumsum = list(accumulate(res_arr))
#print(res_arr)
#print(cumsum)
for i in range(q):
    l,r = arr[i][0], arr[i][1]
    print(cumsum[r] - cumsum[l-1])