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

Fixed submission:
def binary_search_list(beSearched,wanted) :
    l = 0
    r = len(beSearched)

    #print("condition = {}".format(r-l))

    while r - l >= 1 :
        s = (l + r) // 2
        #print("l={} r={} s={}".format(l,r,s))
        if beSearched[s] == wanted :
            return True
        if beSearched[s] > wanted :
            r = s
        else :
            l = s + 1

    return False

K,S = (int(_) for _ in input().split())
num = [_ for _ in range(K+1)]
out = 0
for i in range(K+1):
    for j in range(i+1):
        if 0 <= S - i - j <= j :
            if i == j and j == S - i - j:
                out += 1
            elif i == j or j == S - i - j or S -i - j == i:
                out += 3
            else :
                out += 6
        #print(num[:j+1])
        #b = binary_search_list(num[:j+1],S - i - j)
        #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j))
        #if b :
            #if i == j and j == S - i - j:
                #out += 1
            #elif i == j or j == S - i - j or S -i - j == i:
                #out += 3
            #else :
                #out += 6

print(out)

Buggy submission (verdict: Runtime Error):
K,S = (int(_) for _ in input().split())

out = 0

for x in range(K+1):
    for y in range(x):
        for z in range(y)
            if x + y + z == S :
                if x == y and y == z:
                    out += 1
                elif x == y or y == z or z == x:
                    out += 3
                else:
                    out += 6

print(out)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split(" "))
AL = list(map(int, [input() for _ in range(M)]))

# DP
dp = [1] * (N + 1)
for A in AL:
    dp[A] = 0

for i in range(2, N + 1):
    if dp[i] == 1:
        dp[i] = (dp[i-1] + dp[i-2]) % (10**9 + 7)
print(dp[N])

Buggy submission (verdict: Runtime Error):
from itertools import permutations

N, M = map(int, input().split(" "))
AL = list(map(int, [input() for _ in range(M)]))

patterns = []
for i in range(N, -1, -2):
    pattern = [1] * i
    while sum(pattern) < N:
        pattern.append(2)
    else:
        patterns.extend(set(permutations(pattern)))
import ipdb; ipdb.set_trace()
ans = 0
for pattern in patterns:
    now = 0
    for p in pattern:
        if now + p not in AL:
            now += p
        else:
            break
    else:
        ans += 1
print(ans)
Problem p03015 (python)

Fixed submission:
L = list(input())
mod = 10**9 + 7

dp = [[0]*2 for _ in range(len(L)+1)]

# 最初は1が確定なため
dp[1][0] = 1
dp[1][1] = 2

for i in range(1, len(L)):
    if L[i] == "0":
        dp[i+1][1] = dp[i][1]
        dp[i+1][0] = 3*dp[i][0]
    else:
        dp[i+1][1] = 2*dp[i][1]
        dp[i+1][0] = 3*dp[i][0] + dp[i][1]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod
print(sum(dp[len(L)]) % mod)

Buggy submission (verdict: Runtime Error):
L = list(input())
mod = 10**9 + 7

dp = [[0]*2 for _ in range(len(L)+1)]

# 最初は1が確定なため
dp[1][0] = 1
dp[1][1] = 2

for i in range(1, len(L)):
    print(i)
    if L[i] == "0":
        dp[i+1][1] = dp[i][1]
        dp[i+1][0] = 3*dp[i][0]
    else:
        import ipdb; ipdb.set_trace()
        dp[i+1][1] = 2*dp[i][1]
        dp[i+1][0] = 3*dp[i][0] + dp[i][1]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod
print(sum(dp[len(L)]) % mod)
Problem p03036 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    r, D, x = LI()
    for i in range(10):
        x = r * x - D
        print(x)
    return


main()

Buggy submission (verdict: Runtime Error):
print()
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.
Problem p03108 (python)

Fixed submission:
from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self, nodes):
        self.par = list(range(nodes + 1))
        self.sizes = [1] * (nodes + 1)

    def root(self, key):
        if key != self.par[key]:
            k0 = key
            while k0 != self.par[k0]:
                k0 = self.par[k0]
            self.par[key] = k0
        return self.par[key]

    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

uni = UnionFind(N)
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self, nodes):
        self.par = list(range(nodes + 1))
        self.sizes = [1] * (nodes + 1)

    def root(self, key):
        if key != self.par[key]:
            self.par[key] = self.root(self.par[key])
        return self.par[key]

    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

uni = UnionFind(N)
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self):
        self.par = {}
        self.sizes = {}

    def root(self, key):
        if key not in self.par:
            if key not in self.sizes:
                self.sizes[key] = 1
            return key
        self.par[key] = self.root(self.par[key])
        return self.par[key]

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    # return `now` connected nodes
    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

uni = UnionFind()
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)
Problem p03127 (python)

Fixed submission:
n = int(input())
from functools import reduce
from fractions import gcd
ans = reduce(gcd, (map(int, input().split())))

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
from functools import reduce
from fractions import gcd
import numpy as np
arr = np.array(list(set(map(int, input().split()))))

from collections import deque
q = deque([arr])
ans = arr.min()
mi = reduce(gcd, arr)
while len(q) > 0:
    ar = q.popleft()
    ans = min(ar.min(), ans)
    if ans <= mi:
        break
    if ans <= reduce(gcd, ar):
        continue
    for mon in ar:
        tmp = (ar - 1) % mon + 1
        if np.any(ar != tmp):
            q.append(np.unique(tmp).sort())

print(ans)
Problem p03291 (python)

Fixed submission:
S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MOD
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = (dp[0] * 3) % MOD

ans = dp[-1] % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MODE
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = dp[0] % MOD

ans = dp[-1] % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
MOD = 10 ** 9 + 7

q = 3 if S[0] == '?' else 1
a = b = c = 0
if S[0] in 'A?':
    a = 1
for s in S[1:]:
    if s == '?':
        c = c * 3 + b
        b = b * 3 + a
        a = a * 3 + q
        q *= 3
    elif s == 'A':
        a += q
    elif s == 'B':
        b += a
    elif s == 'C':
        c += b
    a, b, c = a % MOD, b % MOD, C % MOD

ans = c % MOD
print(ans)
Problem p03803 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    A, B = LI()
    if A == 1:
        A = 14
    if B == 1:
        B = 14
    if A > B:
        ans = 'Alice'
    elif A == B:
        ans = 'Draw'
    else:
        ans = 'Bob'
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def binomials(n, k):
    ret = [0] * (n + 1)
    ret[k] = 1
    denomi = mod_factorial(1, reduce(lambda x, y: x * y % MOD, range(1, k), 1))
    for i in range(k - 1, n):
        numeri = reduce(lambda x, y: x * y % MOD, range(i - k + 2, i + 1), 1)
        ret[i + 1] = numeri * denomi % MOD
    return ret

def main():
    if A > B:
        ans = 'Alice'
    elif A == B:
        ans = 'Draw'
    else:
        ans = 'Bob'
    return ans

print(main())
Problem p04008 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import defaultdict

def main():
    N, K = LI()
    A = LI_()
    edges = defaultdict(list)
    for i, a in enumerate(A[1:], 1):
        edges[a].append(i)

    global ans
    ans = 0
    if A[0] != 0:
        ans += 1
    def DFS(v, parent):
        global ans
        height = 0
        for to in edges[v]:
            height = max(height, DFS(to, v))
        if parent != 0 and height >= K - 1:
            height = -1
            ans += 1
        return height + 1
    DFS(0, 0)
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import defaultdict

def main():
    N, K = LI()
    A = LI_()
    edges = defaultdict(list)
    for i, a in enumerate(A[1:], 1):
        edges[a].append(i)

    ans = 0
    if A[0] != 0:
        ans += 1
    def DFS(v, parent):
        global ans
        height = 0
        for to in edges[v]:
            height = max(height, DFS(to, v) + 1)
        if parent != 0 and height > K - 1:
            height = 0
            ans += 1
        return height
    DFS(0, 0)
    return ans

print(main())
Problem p03012 (python)

Fixed submission:
n=int(input())
w=list(map(int,input().split()))
s=sum(w)
p=0
bestsub=100000000

for i in range(n):
  p=p+w[i]
  sub=abs(p-(s-p))
  if(bestsub>sub):
    bestsub=sub

print(bestsub)

Buggy submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
s=w.sum()
p=0
bestsub=100000000

for i in range n:
  p=p+w[i]
  sub=abs(s-p)
  if(bestsub>sub):
    bestsub=sub

print(bestsub)
Problem p03075 (python)

Fixed submission:
l = [int(input()) for i in range(6)]
if l[4] - l[0] <= l[5]:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
l = [int(input()) for i in range(6)]
if l[4] - l[0] =< l[5]:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
l = [input() for i in range(6)]
if l[4] - l[0] < l[5]:
    print("Yay!")
else:
    print(":(")
Problem p03307 (python)

Fixed submission:
N = int(input())
if N%2 == 0:
    print(N)
else:
    print(N*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
k = 0
S = 0

if N%2 == 0:
    k = (N+1)*N//2
else:
    k = (N+1)*(N//2)+(N+1)//2

Sum_A = sum(A)    
b = (sum_A-k)//N

print(sum_A-(b*N+k))
Problem p03307 (python)

Fixed submission:
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def lcm(x, y):
    return (x * y) // gcd(x, y)
N = int(input())
print(lcm(2,N))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
N = int(input())
print(lcm(2,N))
Problem p03041 (python)

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


if a[n[1]-1] == "A":
    a[n[1]-1] = "a"
if a[n[1]-1] == "B":
    a[n[1]-1] = "b"
if a[n[1]-1] == "C":
    a[n[1]-1] = "c"
    
ch = ""
for i in a:
    ch += str(i)
print(ch)

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

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    print("MMYY")
    
else:
    print('NA')

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

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    print("MMYY")
    
else:
    print('NA')

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

if a[n[1]] == "A":
    a[n[1]] = "a"
if a[n[1]] == "B":
    a[n[1]] = "b"
if a[n[1]] == "C":
    a[n[1]] = "c"
print(a)

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


if a[n[1]] == "A":
    a[n[1]] ="a"
if a[n[1]] == "B":
    a[n[1]] ="b"
if a[n[1]] == "C":
    a[n[1]] ="c"
Problem p03017 (python)

Fixed submission:
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    for i in range(b-1,d):
      if s[i-1:i+2]=="..." :
        e = 1 
    if e == 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0 and s.[b-2:d+1].count("...")>0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0 and s.[b-2:d+1].count("...")>0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  for i in range(b,d+1):
    if s[i-1:i+2]=="...":
      e = 1 
  if e = 1:
    print("Yes")
  elif:
    print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
if c<d:
  if s[a:c+1].count("##")>0 and s[b:d+1].count("##")>0:
    print("No")
  else:
    print("Yes")
else:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0 and (s[b-1:d+1].count("...")>0 or s[b-1:B+2].count("...")>0):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
if c<d:
  if s[a:c+1].count("##")>0 and s[b:d+1].count("##")>0:
    print("No")
  else:
    print("Yes")
else:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0 and (s[b-1:d+1].count("...")>0 or s[b-1:B+2]):
    print("Yes")
  else:
    print("No")
Problem p03042 (python)

Fixed submission:
a = input()
b=int(a[0:2])
c=int(a[2:4])
if 1<=b<=12 and 1<=c<=12:
    print('AMBIGUOUS')
elif 1<=b<=12 :
    print('MMYY') 
elif 1<=c<=12:
    print('YYMM')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
a = input()
b=int(a[0:2])
c=int(a[2:4])
if 0<b<=12 & 0<c<=12:
    print('AMBIGUOUS')
elif 0<b<=12 & (c>12 or C ==0) :
    print('MMYY') 
elif (b>12 or b==0) & 0<c<=12:
    print('YYMM')
else:
    print('NA')
Problem p03307 (python)

Fixed submission:
n = int(input())

if n%2 == 0:
    print(n)
else:
    print(n*2)

Buggy submission (verdict: Runtime Error):
import math 

n = int(input())

print(2*n//math.gcd(2,n))

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

n = int(input())

print(2*n//gcd(2,n))
Problem p03041 (python)

Fixed submission:
a = input().split()
b = input()
 
c = list(b)
 
for i in range(len(c)):
  if i == int(a[1]) - 1:
    c[i] = c[i].lower()
    
print(''.join(c))

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

list = list(b)

for i in list:
  if i == a[1] - 1:
    list[i] = list[i].lower()
    
print(''.join(list))
Problem p03127 (python)

Fixed submission:
from functools import reduce

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

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

print(reduce(gcd, a))

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

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

print(reduce(lambda x,y: math.gcd(x, y), a))
Problem p03834 (python)

Fixed submission:
print(input().replace(","," "))

Buggy submission (verdict: Runtime Error):
print(input().replace(","," ")
Problem p03013 (python)

Fixed submission:
def fb(num):
    """num番目のフィボナッチ数を返す
    """
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b

import functools
import operator

import sys
n, m = map(int, input().split())
a = sorted(list(set(map(int, sys.stdin.readlines()))))
m = len(a)

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = fb(j - s)
  s = j + 1
xs[m] = fb(n - s + 1)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)

Buggy submission (verdict: Runtime Error):
import functools
import operator

dic = {-1: 0, 0: 1, 1:1}

def pat(n):
  if n not in dic:
    dic[n] = pat(n-1) + pat(n-2)
  return dic[n]


import sys
n, m = map(int, input().split())
a = sorted(list(set(map(int, sys.stdin.readlines()))))
m = len(a)

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = pat(j - s - 1)
  s = j + 1
xs[m] = pat(n - s)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)

Buggy submission (verdict: Runtime Error):
import functools
import operator

dic = {-1: 0, 0: 1, 1:1}

def pat(n):
  if n not in dic:
    dic[n] = pat(n-1) + pat(n-2)
  return dic[n]


import sys
n, m = map(int, input().split())
a = list(map(int, sys.stdin.readlines()))

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = pat(j - s - 1)
  s = j + 1
xs[m] = pat(n - s)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)
Problem p03011 (python)

Fixed submission:
P, Q, R = list(map(int, input().split()))
print(min(P+Q, Q+R, R+P))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

num_goup = [1]
for s in range(1, N + 1):
    if s in A:
        num_goup.append(0)
        continue
    
    if s == 1:
        num_goup.append(1)
        continue
    
    if num_goup[-1] == 0:
        if num_goup[-2] == 0:
            num_goup.append(0)
            break
        else:
            num_goup.append(num_goup[-2])
    else:
        if num_goup[-2] == 0:
            num_goup.append(num_goup[-1])
        else:
            num_goup.append(num_goup[-1] + num_goup[-2])
    
print(num_goup[-1])
Problem p03075 (python)

Fixed submission:
list = [int(input()) for _ in range(5)]
k = int(input())

if max(list) - min(list) > k:
    print(':(')
else:
    print('Yay!')

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

list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)

list = []

for la in list_a:
    for lb in list_b:
        list.append([la,lb,la+lb])

list.sort(key=lambda x:x[2],reverse=True)

list2 = []

for a,b,n in list:
    for lc in list_c:
        list2.append(n+lc)

list2.sort(reverse=True)

cnt = 0

for i in list2:
    print(i)
    cnt += 1
    if cnt == K:
        exit()
Problem p03208 (python)

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

list = [int(input()) for i in range(N)]
list.sort()
min_val = 10**9
for i in range(N-K+1):
    min_val = min(min_val,list[i+K-1]-list[i])

print(min_val)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
list = [int(input()) for _ in range(N)]
list.sort()

def dfs(start,cnt):
    if cnt <= 0:
        return float('inf')
    diff = max(list[start:start+K]) - min(list[start:start+K])
    return min(diff,dfs(start+1,cnt-1))

print(dfs(0,K))