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

Fixed submission:
s=input()
n=s[::2].count("0")+s[1::2].count("1")
print(min(n,len(s)-n))

Buggy submission (verdict: Runtime Error):
s=input()
n=s[::2].count("0")+s[1::2].count("1")
print(min(n,lens(s)-n))
Problem p03011 (python)

Fixed submission:
L= list(map(int, input().split()))
L.sort()
print(L[0]+L[1])

Buggy submission (verdict: Runtime Error):
L=list(map(int,input().split))
L.sort()
print(L[0]+L[1])
Problem p03012 (python)

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1])-sum(L[i+1:])))

ans=min(v)

print(ans)

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

v=[]
for i in range(N):
  v.append(abs(sum(L[:(i+1)]-L[(i+1):])))

ans=min(v)

print(ans)

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:(i+1)]-L[(i+1):])))

ans=min(v)

print(ans)

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1]-L[i+1:])))

ans=min(v)

print(ans)

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1]-L[i+1:])))

ans=min(v)

print(v)

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i]-L[i+1:])))

ans=min(v)

print(v)
Problem p03045 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())
xyz = {i:[] for i in range(1, n+1)}
for _ in range(m):
    x, y, z = map(int, input().split())
    xyz[x].append((x, y, z))
    xyz[y].append((y, x, z))

connects = [0]*(n+1)
group = 1
for i in range(1, n+1):
    if connects[i] > 0:
        continue
    if len(xyz[i]) == 0:
        connects[i] = group
        group += 1
        continue

    que = deque(xyz[i])
    connects[i] = group
    while len(que) > 0:
        x, y, z = que.popleft()
        connects[y] = group
        for xn, yn, zn in xyz[y]:
            if connects[yn] > 0:
                pass
            else:
                que.append((xn, yn, zn))
    group += 1
    
# print(connects)
print(max(connects))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

n, m = map(int, input().split())
xyz = [[] for i in range(n+1)]
for _ in range(m):
    x, y, z = map(int, input().split())
    xyz[x].append(y)
    xyz[y].append(x)
    
ans = 0
visited = [False]*(n+1)
def dfs(x):
    visited[x] = True
    for y in xyz[x]:
        if not visited[y]:
            dfs(y)

for x in range(1, n+1):
    if visited[x]:
        continue
    dfs(x)
    ans += 1
    
# print(visited)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
xyz = [[] for i in range(n+1)]
for _ in range(m):
    x, y, z = map(int, input().split())
    xyz[x].append(y)
    xyz[y].append(x)
    
ans = 0
visited = [False]*(n+1)
def dfs(x):
    visited[x] = True
    for y in xyz[x]:
        if not visited[y]:
            dfs(y)

for x in range(1, n+1):
    if visited[x]:
        continue
    dfs(x)
    ans += 1
    
# print(visited)
print(ans)
Problem p03104 (python)

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

def count_bin(n, d):
    if n < 0:
        return 0
    div = (n+1)//2**(d+1)
    res = div*(2**d)
    remain = (n+1) - div*(2**(d+1))
    res += remain - 2**d if remain > 2**d else 0
    return res

ans = 0
for d in range(50):
    n_bin = count_bin(b, d) - count_bin(a-1, d)
    if n_bin%2 > 0:
        ans += 2**d
print(ans)

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

def get(n):
    if n%4 == 0:
        return x
    elif n%4 == 1:
        return 1
    elif n%4 == 2:
        return x+1
    else:
        return 0

print(get(b)^get(a-1))
Problem p03209 (python)

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

hambs = [(1, 1)]
for l in range(1, n+1):
    n_p, n_l = hambs[l-1]
    hambs.append((2*n_p+1, 2*n_l+3))
# for h in hambs:
#     print(h)

def eat(m, y):
    if y == 0:
        return 0
    if m == 0:
        return 1

    if y < 2+hambs[m-1][1]:
        return eat(m-1, y-1)
    elif y == 2+hambs[m-1][1]:
        return hambs[m-1][0] + 1
    elif 2+hambs[m-1][1] < y and y < hambs[m][1]:
        return hambs[m-1][0] + 1 + eat(m-1, y-(2+hambs[m-1][1]))
    else:
        return hambs[m][0]
print(eat(n, x))

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

hambs = [(1, 0, 1)]
for l in range(1, n+1):
    n_p, n_b, n_l = hambs[l-1]
    hambs.append((2*n_p+1, 2*n_b+2, 2*n_l+3))
# for h in hambs:
#     print(h)

n_p, _, n_l = hambs[n]
if x == 1:
    print(0)
    exit()
elif x == n_l:
    print(n_p)
    exit()
    
ans = n_p//2+1
y = n_l//2+1
l = n-1
while y != x:
    n_p, _, n_l = hambs[l]
    if y > x:
        ans -= n_p
        y -= n_l
    else:
        ans += n_p
        y += n_l
    l -= 1

print(ans)
Problem p03222 (python)

Fixed submission:
MOD = 10**9+7
h, w, k = map(int, input().split())

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1

patterns = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

if w == 1:
    print(1)
    exit()

for i in range(1, h+1):
    # most left
    dp[i][0] = (dp[i-1][0]*patterns[1:][w-2]%MOD + dp[i-1][1]*patterns[w-2]%MOD)%MOD
    for j in range(1, w-1):
        npath = dp[i-1][j-1]*(patterns[j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j]*(patterns[1:][j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j+1]*(patterns[1:][j-1]*patterns[w-j-2])%MOD
        dp[i][j] = npath%MOD
    dp[i][w-1] = (dp[i-1][w-2]*patterns[w-2]%MOD + dp[i-1][w-1]*patterns[1:][w-2]%MOD)%MOD

# for p in dp: print(p)

print(dp[-1][k-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
MOD = 10**9+7
h, w, k = map(int, input().split())

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1

patterns = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

for i in range(1, h+1):
    # most left
    dp[i][0] = (dp[i-1][0]*patterns[1:][w-2]%MOD + dp[i-1][1]*patterns[w-2]%MOD)%MOD
    for j in range(1, w-1):
        npath = dp[i-1][j-1]*(patterns[j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j]*(patterns[1:][j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j+1]*(patterns[1:][j-1]*patterns[w-j-2])%MOD
        dp[i][j] = npath%MOD
    dp[i][w-1] = (dp[i-1][w-2]*patterns[w-2]%MOD + dp[i-1][w-1]*patterns[1:][w-2]%MOD)%MOD

# for p in dp: print(p)

print(dp[-1][k-1])
Problem p03774 (python)

Fixed submission:
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    min_dist = 4*10**8+1
    for i, (c, d) in enumerate(cd):
        dist = abs(a-c)+abs(b-d)
        if dist < min_dist:
            min_dist = dist
            ans = i+1
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    min_dist = 2*10**8
    for i, (c, d) in enumerate(cd):
        dist = abs(a-c)+abs(b-d)
        if dist < min_dist:
            min_dist = dist
            ans = i+1
    print(ans)
Problem p03127 (python)

Fixed submission:
from fractions import gcd

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = math.gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))

Buggy submission (verdict: Runtime Error):
import math

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = math.gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))

Buggy submission (verdict: Runtime Error):
import math

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

mini = min(A)
ans = min(A)
for a in A:
    amari = a%mini
    if amari != 0:
        if amari < ans:
            ans = amari            
if mini - ans == 0:
    print(ans)
else:
    print(math.gcd(mini, ans))

Buggy submission (verdict: Runtime Error):
import math

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

mini = min(A)
ans = min(A)
for a in A:
    amari = a%mini
    if amari != 0:
        if amari < mini:
            ans = amari            
if mini - ans == 0:
    print(ans)
else:
    print(math.gcd(mini, ans))
Problem p03011 (python)

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


 
ab = a+b
bc = b+c
ac = a+c
 
minimum = min(ab,bc,ac)
 
print(minimum)

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


 
ab = a+b
bc = b+c
ac = a+c
 
minimum = min(ab,bc,ac)
 
print(minimum)

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


 
ab = a+b
bc = b+c
ac = a+c
 
minimum = min(ab,bc,ac)
 
print(minimum)
Problem p03041 (python)

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

print(s[:k-1]+s[k-1].lower()+s[k:])

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

s = input()

print(s[:k - 1] + s[k -1].lower + s[k:])

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

s = input()

print(s[:k - 1] + s[k -1].lower + s[k:])

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

s = input()

s2 = list(s[:k-1] + s[k-1].lower + s[k:])
print(s2)

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

s = input()

s2 = list(s[:k - 1] + s[k -1].lower + s[k:])
print(s2)

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

s = input()

s2 = list(s[:k - 1] + s.lower[k -1] + s[k:])
print(s2)

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

s = [str, i for in input()]

print(s.lower(k))
Problem p03042 (python)

Fixed submission:
s = input()

head = int(s[:2])
tail = int(s[2:])

if 0 < head <= 12 and 0 < tail <= 12:
  print("AMBIGUOUS")

elif 0 < head <= 12:
  print("MMYY")

elif 0 < tail <= 12:
  print("YYMM")

else :
  print("NA")

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

head = int(s[:2])
tail = int(s[2:])

if 0 < head <= 12 and 0 < tail <= 12:
  print("AMBIGUOUS")

elif 0 < head <= 12:
  print("MMYY")
elif 0 < tail <= 12:
  print("YYMM")
elif :
  print("NA")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))

head = s[:1]
tail = s[1:]

if head > 12:
  print("YYMM")
if tail > 12:
  print("MMYY")
if 0 < head <= 12 and 0 < tail <=12:
  print("AMBIGUOUS")
if head = 0 or tail = 0:
  print("NA")
if head > 12 and tail > 12:
  print("NA")
Problem p03075 (python)

Fixed submission:
antenas = [int(input()) for i in range(5)]

k = int(input())

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")

Buggy submission (verdict: Runtime Error):
antenas = list(int(input()) for i in range(5))

k = int(input)

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")

Buggy submission (verdict: Runtime Error):
antenas = list(int, input() for i in range(5))

k = int(input)

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")

Buggy submission (verdict: Runtime Error):
antenas = list(int, input() for in range(5))

k = int(input)

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")
Problem p03803 (python)

Fixed submission:
input = input().split()
A,B=int(input[0]),int(input[1])
 
if A==1:
    A+=13
if B==1:
    B+=13
 
if A==B:
    print("Draw")
elif A>B:
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,Ma,Mb=map(int,input().split())
yaku=[]
for _ in range(N):
    yaku.append(list(map(int,input().split())))


candi_money=[]

for n in range(N):
    candis=list(itertools.combinations(np.arange(N),n))
    for candi in candis:
        a,b,c=0,0,0
        for num in candi:
            a +=yaku[num][0]
            b +=yaku[num][1]
            c +=yaku[num][2]
        if a/flaot(Ma/Mb)=b:
            candi_money.append(c)


if len(candi_money)==0:
	print(-1)
else:
	print(min(candi_money))
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())
 
m = 10e9
 
m = min(m, p + q)
m = min(m, r + q)
m = min(m, p + r)
 
print(m)

Buggy submission (verdict: Runtime Error):
text

Buggy submission (verdict: Runtime Error):
test
Problem p03011 (python)

Fixed submission:
P,Q,R = map(int,input().split())
a1 = P + Q
a2 = P + R
a3 = Q + R
value = 300
if a1 < value:
    value = a1
if value > a2:
    value = a2
if value > a3:
    value = a3
print(value)

Buggy submission (verdict: Runtime Error):

import sys


P = int(sys.argv[1])
Q = int(sys.argv[2])
R = int(sys.argv[3])



a1 = P + Q.
a2 = P + R
a3 = Q + R

value = 300
if a1 < value:
    value = a1
if value > a2:
    value = a2
if value > a3:
    value = a3
print(value)

Buggy submission (verdict: Runtime Error):

import sys


P = int(sys.argv[1]) 
Q = int(sys.argv[2]) 
R = int(sys.argv[3]) 
 
a1 = P + Q.
a2 = P + R
a3 = Q + R

value = 300

if __name__ == '__main__':
    if a1 < value:
        value = a1
    if value > a2:
        value = a2
    if value > a3:
        value = a3
    print(value)

Buggy submission (verdict: Runtime Error):

import sys


P = int(sys.argv[1]) 
Q = int(sys.argv[2]) 
R = int(sys.argv[3]) 
 
a1 = P + Q.
a2 = P + R
a3 = Q + R

value = 300

if __name__ == '__main__':
    if a1 < value:
        value = a1
    if value > a2:
        value = a2
    if value > a3:
        value = a3
    print(value)

Buggy submission (verdict: Runtime Error):

import sys


P = sys.argv[1]
Q = sys.argv[2]
R = sys.argv[3]




numbers = [P,Q,R]

combinations = ['_','_','_']

numbers = []

a1 = P + Q.
a2 = P + R
a3 = Q + R

value = 300 


 
if __name__ == '__main__': 
    if a1 < value:
        value = a1 
    if value < a2:
        value = a2
    if value < a3:
        value = a3 
    return value
Problem p03012 (python)

Fixed submission:
n_text = input()
w_text = input()

N = int(n_text)
W = w_text.split()

W = [int(i) for i in W]

ans = 100 * 100

for T in range(N):
  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
  if ans_tmp < ans:
    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N = text.split("\n")[0]
W = text.split("\n")[1]

#N = int(N[0])
#W = [int(i) for i in W.split(" ")]

ans = 100 * 100

#for T in range(N):
#  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
#  if ans_tmp < ans:
#    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N, W = text.split("\n")[0], text.split("\n")[1]

#N = int(N[0])
#W = [int(i) for i in W.split(" ")]

ans = 100 * 100

#for T in range(N):
#  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
#  if ans_tmp < ans:
#    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N, W = text.split("\n")[0], text.split("\n")[1]

N = int(N[0])
W = [int(i) for i in W.split(" ")]

ans = 100 * 100

for T in range(N):
  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
  if ans_tmp < ans:
    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N, W = text.split("\n")[0], text.split("\n")[1]

N = int(N[0])
W = [int(i) for i in W.split()]

ans = 100*100

for T in range(N):
  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
  if ans_tmp < ans:
    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N, W = text.split("\n")[0], text.split("\n")[1]

N = int(N[0])
W = [int(i) for i in W]

ans = 100*100

for T in range(N):
  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
  if ans_tmp < ans:
    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input()
N, W = text.split("\n")[0], text.split("\n")[1]

N = int(N)
W = [int(i) for i in W]

ans = 100*100

for T in range(N):
  ans_tmp = abs(sum(W[:T]) - sum(W[T:]))
  if ans_tmp < ans:
    ans = ans_tmp

print(ans)

Buggy submission (verdict: Runtime Error):
text = input().split("\n")
T = int(text[0])
W = [int(i) for i in text[1]]
S_1 = sum(W[:T])
S_2 = sum(W[T:])
print(abs(S_1 - S_2))
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
m = max([a, b, c, d, e])
n = min([a, b, c, d, e])
print('Yay!' if k >= (m - n) else ':(')

Buggy submission (verdict: Runtime Error):
n, h, w = [int(i) for i in input().split()]
print(sum(h <= a and w <= b for a, b in ([int(i) for i in input().split()] for _ in range(n))))

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().strip

l = [int(input()) for _ in range(5)]
k = int(input())
print('Yay!' if k >= l[4] - l[0] else ':(')

Buggy submission (verdict: Runtime Error):
l=[int(input())for _ inrange(5)]
print([':(','Yay!'][int(input())>=l[4]-l[0]])
Problem p03012 (python)

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

min = 100000
for i in range(1, N):
  s1 = sum(ws[:i])
  s2 = sum(ws[i:])
  diff = abs(s1 - s2)
  if diff < min:
    min = diff
print(min)

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

sum = sum(ws)
mini = sum
tmp_sum = 0
for w in ws:
  tmp_sum += ws
  mini = min(mini, abs(tmp_sum - (sum - tmp_sum)))
print(mini)
Problem p03265 (python)

Fixed submission:
x_1,y_1,x_2,y_2=tuple(map(int,input().split()))

be=[x_2-x_1,y_2-y_1]
za3=[x_2+(-1)*be[1],y_2+be[0]]
za4=[x_1+(-1)*be[1],y_1+be[0]]

print(za3[0],za3[1],za4[0],za4[1])

Buggy submission (verdict: Runtime Error):
x_1,y_1,x_2,y_2=tuple(map(int,input().split()))

be=[x_2-x_1,y_2-y_1]
za3=[x_2+(-1)*be[1],y_2+be[0]]
za4=[x_1+(-1)*be[1],y_1+be[0]]

print(za3[0],za3[1],za4[0],za4[
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
n, m = map(int, input().split())
a = []
for _ in range(m):
    _a = int(input())
    try:
        if _a == a[-1]:
            continue
    except:
        pass
    a.append(_a)
a.append(n + 1)
m = len(a)

memo = {0: 1, 1: 1, 2: 2}
def chk(n):
    if n in memo:
        return memo[n]
    else:
        make(n)
        return memo[n]

def make(n):
    if n in memo:
        return
    make(n - 1)
    make(n - 2)
    memo[n] = (memo[n-1] + memo[n-2]) % 1000000007

for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()

cur = 0
tot = 1
#from sys import stderr
#for k in range(100):
#    print(f'0-{k}: {chk(k)}', file=stderr)

for i in range(m):
    nxt = a[i] - 1
    add = chk(nxt - cur)
    #print(f'{cur}-{nxt}: {add}', file=stderr)
    tot *= add
    tot %= 1000000007
    cur = nxt + 2
print(tot % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for _ in range(m):
    _a = int(input())
    try:
        if _a == a[-1]:
            continue
    except:
        pass
    a.append(_a)
a.append(n + 1)
m = len(a)

memo = {0: 1, 1: 1, 2: 2}
def chk(n):
    if n in memo:
        return memo[n]
    else:
        make(n)
        return memo[n]

def make(n):
    if n in memo:
        return
    make(n - 1)
    make(n - 2)
    memo[n] = (memo[n-1] + memo[n-2]) % 1000000007

for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()

cur = 0
tot = 1
#from sys import stderr
#for k in range(100):
#    print(f'0-{k}: {chk(k)}', file=stderr)

for i in range(m):
    nxt = a[i] - 1
    add = chk(nxt - cur)
    #print(f'{cur}-{nxt}: {add}', file=stderr)
    tot *= add
    tot %= 1000000007
    cur = nxt + 2
print(tot % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for _ in range(m):
    _a = int(input())
    try:
        if _a == a[-1]:
            continue
    except:
        pass
    a.append(_a)
a.append(n + 1)
m = len(a)

memo = {0: 1, 1: 1, 2: 2}
def chk(n):
    if n in memo:
        return memo[n]
    else:
        make(n)
        return memo[n]

def make(n):
    if n in memo:
        return
    make(n - 1)
    make(n - 2)
    memo[n] = memo[n-1] + memo[n-2]

for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()

cur = 0
tot = 1
#from sys import stderr
#for k in range(100):
#    print(f'0-{k}: {chk(k)}', file=stderr)

for i in range(m):
    nxt = a[i] - 1
    add = chk(nxt - cur)
    #print(f'{cur}-{nxt}: {add}', file=stderr)
    tot *= add
    tot %= 1000000007
    cur = nxt + 2
print(tot % 1000000007)
Problem p03011 (python)

Fixed submission:
def main():
  p, q, r = map(int, input().split())
  print(min(p+q, p+r, q+r))
 
if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):

Copy
Copy
from functools import lru_cache
 
 
N, M = map(int, input().split())
# 壊れている床番号
a = []
for _ in range(M):
    a.append(int(input()))
# ルートの総数
root = 0
# 今いる階段の段数
now = 0
 
 
def isSafe(now):
    """
    1, 2段先共になければ0
    1段先だけあれば1
    2段先だけあれば2
    1, 2段先共にあれば3
    """
    now_1 = not (now-1) in a
    now_2 = not (now-2) in a
    if now<=1:
        return 0
    elif now==2:
        return int(now_1)
    else:
        return int(now_1 + now_2*2)
 
 
@lru_cache(maxsize=100000)
def step(N):
    # N段を登る移動方法数
    if N <= 1:
        if not (1 in a):
            return 1   
        else:
            return 0
    elif N==2:
        if not (2 in a):
            return step(1) + 1
        else:
            return step(1)
    elif isSafe(N)==1:
        return step(N-1)
    elif isSafe(N)==2:
        return step(N-2)
    elif isSafe(N)==3:
        return step(N-1)+step(N-2)
    else:
        return 0
 
print(step(N)%1000000007)
Problem p03011 (python)

Fixed submission:
import itertools
pqr = list(map(int,input().split(" ")))
print(sum(min(list(itertools.combinations(pqr, 2)), key=lambda x:sum(x))))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split(" ")))
A = [1] * (N+1)
for i in range(M):
    A[int(input())] = -1
for i in range(2, N + 1):
    if(A[i] == -1):
        A[i] = 0
    else:
        A[i] = A[i-1] + A[i-2]
print(A[-1] % 1000000007)
Problem p03011 (python)

Fixed submission:
P, Q,R = map(int, input().split())
print("{}".format(min([P+Q,Q+R,R+P])))

Buggy submission (verdict: Runtime Error):
P=int(input())
Q=int(input())
R=int(input())
print("{}".format(min([P+Q,Q+R,R+P])))

Buggy submission (verdict: Runtime Error):
P=int(input())
Q=int(input())
R=int(input())

a=[P+Q,Q+R,R+P]

print("{}".format(min(a))
Problem p03077 (python)

Fixed submission:
n = int(input())
A = []
for _ in range(5):
  A.append(int(input()))
x = min(A)
print((n + x - 1) // x + 4)

Buggy submission (verdict: Runtime Error):
n, a, b, c, d, e = map(int, input().split())
x = min(a, b, c, d, e)
print((n + x - 1) // x + 4)
Problem p03186 (python)

Fixed submission:
A, B, C = map(int, input().split())
print(B + min(A+B+1, C))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(B + min(A+B+1, c))