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

Fixed submission:
N,Ma,Mb=map(int,input().split())
Med=[]
cnt_a=0
cnt_b=0
for i in range(N):
  a=[int(x) for x in input().split()]
  Med.append(a)
  cnt_a+=a[0]
  cnt_b+=a[1]
R=max(cnt_a,cnt_b)
#[i]まででMa=[j],Mb=[k]を作る場合の最小のコストdp
#dp[i+1][j+Ma][k+Mb]=min(dp[i][j+Ma][k+Mb],dp[i][j][k]+Cost)
#リストをinfで初期化。inf=作れない配合なので、continue。初期値はdp[0][0][0]=0
dp=[[[float('inf') for j in range(R+1)] for k in range(R+1)] for i in range(N+1)]
dp[0][0][0]=0

for i in range(N):
  for j in range(R+1):
    for k in range(R+1):
      if dp[i][j][k]==float('inf'):
        continue
      dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k])
      dp[i+1][j+Med[i][0]][k+Med[i][1]]=min(dp[i][j+Med[i][0]][k+Med[i][1]],dp[i][j][k]+Med[i][2])

ans=float('inf')
for i in range(1,N+1):
  if i*Ma<R+1 and i*Mb<R+1:
    ans=min(ans,dp[N][i*Ma][i*Mb])
if ans==float('inf'):
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,Ma,Mb=map(int,input().split())
Med=[]
cnt_a=0
cnt_b=0
for i in range(N):
  a=[int(x) for x in input().split()]
  Med.append(a)
  cnt_a+=a[0]
  cnt_b+=a[1]
  
#[i]まででMa=[j],Mb=[k]を作る場合の最小のコストdp
#dp[i+1][j+Ma][k+Mb]=min(dp[i][j+Ma][k+Mb],dp[i][j][k]+Cost)
#リストをinfで初期化。inf=作れない配合なので、continue。初期値はdp[0][0][0]=0
dp=[[[float('inf') for j in range(cnt_b+1)] for k in range(cnt_a+1)] for i in range(N+1)]
dp[0][0][0]=0

for i in range(N):
  for j in range(cnt_a+1):
    for k in range(cnt_b+1):
      if dp[i][j][k]==float('inf'):
        continue
      dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k])
      dp[i+1][j+Med[i][0]][k+Med[i][1]]=min(dp[i][j+Med[i][0]][k+Med[i][1]],dp[i][j][k]+Med[i][2])

ans=float('inf')
for i in range(1,N+1):
  if i*Ma<401 and i*Mb<401:
    ans=min(ans,dp[N][i*Ma][i*Mb])
if ans==float('inf'):
  print(-1)
else:
  print(ans)
Problem p03821 (python)

Fixed submission:
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

ans=0
for i in range(N-1,-1,-1):
  a=A[i]+ans
  b=B[i]
  if a ==0 or a % b ==0:
    continue
  else:
    ans+=(a+b)//b*b-a
    
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

ans=0
for i in range(N-1,-1,-1):
  a=A[i]+ans
  b=B[i]
  if a < b:
    ans+=(b-a)
  elif a % b==0
    continue
  else:
    ans+=(a+b)//b*b-a
    
print(ans)
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split());
xList =list(map(int, input().split()))
xList.sort();

if N >= M:
  print(0);
else:
  diff = xList[M - 1] - xList[1];

  diffList = [];
  prevX = xList[0];
  for i in range(1, M):
      x = xList[i];
      diffList.append(x - prevX);
      prevX = x;
  diffList.sort();

  for i in range(N - 1):
      diffList.pop();

  length = len(diffList);
  result = 0;
  for i in range(length):
      result += diffList[i];

  print(result);

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

if M == 1:
  print(0);
else:
  diff = xList[M - 1] - xList[1];

  diffList = [];
  prevX = xList[0];
  for i in range(1, M):
      x = xList[i];
      diffList.append(x - prevX);
      prevX = x;
  diffList.sort();

  for i in range(N - 1):
      diffList.pop();

  length = len(diffList);
  result = 0;
  for i in range(length):
      result += diffList[i];

  print(result);
Problem p02879 (python)

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

if (a < 10 and b < 10):
  print(a*b)
else:
  print(-1)

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

if (a < 10 or b < 10):
  print(a*b)
else:
  print(-1)
Problem p02990 (python)

Fixed submission:
import math
n,k = map(int,input().split())
mod = 10**9+7
red = n-k
def combination(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

for i in range(1,k+1):
    print(combination(red+1,i)*combination(k-1, i-1)%mod if red+1>=i else 0)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
mod = 10**9+7
red = n-k

def combination(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

for i in range(1,k+1):
    print(combination(red+1,i)*combination(k-1, i-1)%mod)
Problem p03013 (python)

Fixed submission:
n,m = map(int, input().split())
bl = [int(input())-1 for _ in range(m)]
l = [i for i in range(n)]
cnt = 0
for num in bl:
    del l[num-cnt]
    cnt +=1
    
mod = 1000000007

al = [0]*n
if 0 in l and 1 in l:
    al[0] = 1
    al[1] = 2
elif 0 in l:
    al[0] =1
elif 1 in l:
    al[1] = 1
else:
    print(0)
    exit()
    
li = [i for i in l if i>=2]
for i in li:
    al[i] = al[i-1] + al[i-2]
    if al[i] == 0:
        print(0)
        exit()

print(al[-1]%mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
bl = set([int(input())-1 for _ in range(m)])
l = [i for i in range(n)]

mod = 1000000007
al = [0]*n
if 0 in l and 1 in l:
    al[0] = 1
    al[1] = 2
elif 0 in l:
    al[0] =1
elif 1 in l:
    al[1] = 1
else:
    print(0)
    exit()

    
li = [i for i in l if i>=2]

for i in li:
    if i not in bl
        al[i] = (al[i-1] + al[i-2])%mod
        if al[i] == 0:
            print(0)
            exit()

print(al[-1])
Problem p03072 (python)

Fixed submission:
n = input()
l = list(input().split())
 
cnt = 0
max_height = 0
for i in range(len(l)):
  if int(l[i]) >= int(max_height):
    cnt +=1
    max_height = l[i]
    
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
l = list(input.split())

cnt = 0
max_height = 0
for i in range(len(l)):
  if l[i] > max_height:
    cnt +=1
    max_height = l[i]
    
print(cnt)
Problem p03077 (python)

Fixed submission:
import math
n = int(input())
l = [int(input()) for _ in range(5)]
print(math.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
l = [input() for _ in range(5)]
print(math.ceil(n/min(l)+4))
Problem p03137 (python)

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

x.sort()
dist_l = [0] * (m-1)

for i in range(m-1):
    dist_l[i] = x[i+1] - x[i]

dist_l.sort()
print(sum(dist_l[:-(n-1)]) if n !=1 else sum(dist_l))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
if m =< n:
    print(0)
    quit()

x.sort()
dist_l = [0] * (m-1)

for i in range(m-1):
    dist_l[i] = x[i+1] - x[i]

dist_l.sort()
print(sum(dist_l[:-(n-1)]))
Problem p03135 (python)

Fixed submission:
T,X=map(int,input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
T,X=(float(x) for x input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
T,X=(int(x) for x input().split())
print(T/X)
Problem p02951 (python)

Fixed submission:
a,b,c = [int(x) for x in input().split()]
n = c-(a-b)
print(n if n > 0 else 0)

Buggy submission (verdict: Runtime Error):
a,b,c = [int(x) for x in input().sprit()]
print(max([c-(a-b),0]))
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a+b+c > 21:
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
a, b, c = int(input().split())
if a+b+c > 21:
  print("bust")
else:
  print("win")
Problem p02836 (python)

Fixed submission:
str = input()
n = len(str)
a = str[:n//2]
b = str[n//2+n%2:][::-1]
count = 0
for i in range(0,n//2):
  if a[i]!=b[i]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
str = input()
n = len(str)
a = str[:n//2]
b = str[n//2+1:][::-1]
count = 0
for i in range(0,n//2):
  if a[i]!=b[i]:
    count+=1
print(count)
Problem p02819 (python)

Fixed submission:
from math import sqrt

x = int(input()) - 1
pnums = []
if x >= 4:
    for i in range(2, int(sqrt(x))+1):
        for j in pnums:
            if i % j == 0:
                break
        else:    
            pnums.append(i)

while True:
    x += 1
    x_sqrt = sqrt(x)
    if x_sqrt.is_integer():
        pnums.append(x_sqrt)
        continue
    
    for a in pnums:
        if x % a == 0:
            break
    else:
        print(x)
        break

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

x = int(input()) - 1
if x >= 2:
    pnums = []
    for i in range(2, int(sqrt(x))+1):
        for j in pnums:
            if i % j == 0:
                break
        else:    
            pnums.append(i)

while True:
    x += 1
    x_sqrt = sqrt(x)
    if x_sqrt.is_integer():
        pnums.append(x_sqrt)
        break
    
    for a in pnums:
        if x % a == 0:
            break
    else:
        print(x)
        break
Problem p02847 (python)

Fixed submission:
d = ["-","SAT","FRI","THU","WED","TUE","MON","SUN"]
S = input()
for n,s in enumerate(d):
    if s == S:
        print(n)

Buggy submission (verdict: Runtime Error):
d = ["-","SAT","FRI","THU","WED","TUR","MON","SUN"]
input()
for n,s in enumerate(d):
    if s == S:
        print(n)
Problem p02897 (python)

Fixed submission:
N = int(input())
if N % 2 == 1:
    odd = N // 2 + 1
else:
    odd = N // 2
print(odd/N)

Buggy submission (verdict: Runtime Error):
import math
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

A,B = map(int,input().split())
 
GCD = math.gcd(A,B)
 
prime_list = get_sieve_of_eratosthenes(GCD)
counter = 1
for p in prime_list:
    if GCD % p == 0:
        counter += 1
        while(GCD % p == 0):
            GCD = GCD // p
print(counter)
Problem p03805 (python)

Fixed submission:
def resolve():
    import sys
    sys.setrecursionlimit(10**6)
    
    N,M = map(int,input().split())
    ab =[map(int,input().split()) for _ in range(M)]
    branch = [[] for _ in range(N)]
    for a,b in ab:
        branch[a-1].append(b-1)
        branch[b-1].append(a-1)
    
    bit = 0
    count = 0
    def walk(p):
        nonlocal bit,N
        bit |= (1 << p)
        if bit == 2 ** N - 1:
            nonlocal count
            count += 1
        for n in branch[p]:
            if not(bit & (1 << n)):
                walk(n)
        bit &= ~(1 << p)

    walk(0)
    print(count)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():

    N,M = map(int,input().split())
    ab =[map(int,input().split()) for _ in range(N)]
    branch = [[] for _ in range(N)]
    for a,b in ab:
        branch[a-1].append(b-1)
        branch[b-1].append(a-1)
    
    bit = 0
    count = 0
    def walk(p):
        nonlocal bit,N
        bit |= (1 << p)
        if bit == 2 ** N - 1:
            nonlocal count
            count += 1
        for n in branch[p]:
            if not(bit & (1 << n)):
                walk(n)
        bit &= ~(1 << p)

    walk(0)
    print(count)
resolve()
Problem p02834 (python)

Fixed submission:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
#https://atcoder.jp/contests/abc148/tasks/abc148_f
#F - Playing Tag on Tree
"""
"""
N = gi()
U = gi()
V = gi()
t = [[] for i in range(N + 1)]
d = [[-1 for i in range(2)] for j in range(N + 1)]

for _ in range(1, N):
    a = gi()
    b = gi()
    t[a].append(b)
    t[b].append(a)


def bfs(s, di):
    d[s][di] = 0
    q = deque()
    q.append(s)
    while len(q):
        v = q.pop()
        for u in t[v]:
            if d[u][di] >= 0:
                continue
            d[u][di] = d[v][di] + 1
            q.append(u)


bfs(U, 0)
bfs(V, 1)

ans = 0
for l in range(1, N + 1):
    if len(t[l]) > 1:
        continue
    du = d[l][0]
    dv = d[l][1]
    #print(l, du, dv)
    if dv >= du:
        ans = max(ans, dv - 1)

print(ans)

Buggy submission (verdict: Runtime Error):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
#https://atcoder.jp/contests/abc148/tasks/abc148_f
#F - Playing Tag on Tree
"""
"""
N = gi()
u = gi()
v = gi()
t = [[] for i in range(N + 1)]
d = [[0 for i in range(2)] for j in range(N + 1)]

for _ in range(1, N):
    a = gi()
    b = gi()
    t[a].append(b)
    t[b].append(a)

ls = []


def dfs(i, p, di):

    if len(t[i]) == 1:
        ls.append(i)
    for nei in t[i]:
        if nei == p:
            continue
        d[nei][di] = d[i][di] + 1
        dfs(nei, i, di)


d[u][0] = 0
dfs(u, -1, 0)
d[v][1] = 0
dfs(v, -1, 1)

ans = 0
for l in ls:
    du = d[l][0]
    dv = d[l][1]
    if dv >= du:
        ans = max(ans, dv - 1)

print(ans)
Problem p03038 (python)

Fixed submission:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc081/tasks/arc081_b
# D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
M = gi()
A = [0] * N
ops = []

for i in range(N):
    A[i] = gi()
for _ in range(M):
    b = gi()
    c = gi()
    ops.append((-c, b))

A.sort()
ops.sort()

i = 0
for op in ops:
    nv = -op[0]
    for _ in range(op[1]):
        if i >= N:
            break
        if nv < A[i]:
            break
        A[i] = nv
        i += 1

print(sum(A))

Buggy submission (verdict: Runtime Error):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc081/tasks/arc081_b
# D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
M = gi()
A = [0] * N
ops = []

for i in range(N):
    A[i] = gi()
for _ in range(M):
    b = gi()
    c = gi()
    ops.append((-c, b))

A.sort()
ops.sort()

i = 0
for op in ops:
    nv = -op[0]
    for _ in range(op[1]):
        if nv < A[i]:
            break
        if i >= N:
            break
        A[i] = nv
        i += 1

print(sum(A))
Problem p03045 (python)

Fixed submission:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
N = gi()
M = gi()
parent = [[] for i in range(N + 1)]


def find(a):
    if parent[a] != a:
        parent[a] = find(parent[a])

    return parent[a]


def union(a, b):
    aP = find(a)
    bP = find(b)

    if (aP != bP):
        parent[max(aP, bP)] = min(aP, bP)


for i in range(N + 1):
    parent[i] = i

for i in range(M):
    x = gi()
    y = gi()
    z = gi()
    union(x, y)

ans = 0

for i in range(1, N + 1):
    if find(i) == i:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
N = gi()
M = gi()
g = [[] for i in range(N + 1)]

for i in range(M):
    x = gi()
    y = gi()
    z = gi()
    g[x].append(y)
    g[y].append(x)

visited = [0] * (N + 1)


def dfs(v):
    if visited[v]:
        return
    visited[v] = 1

    for u in g[v]:
        dfs(u)


ans = 0
for v in range(1, N + 1):
    if visited[v]:
        continue
    ans += 1
    dfs(v)

print(ans)
Problem p02847 (python)

Fixed submission:
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

print(7 - days.index(S))

Buggy submission (verdict: Runtime Error):
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

in_day = input();

if in_day == day[x]:
  print(7 - x)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a // 10 == 0 and b // 10 == 0:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a, b = map(int input().split())
if a // 10 == 0 and b // 10:
  print(a*b)
else:
  print(-1)
Problem p02951 (python)

Fixed submission:
num = [int(i) for i in input().split()]

A = num[0]
B = num[1]
C = num[2]
 
temp = C - (A - B)
if temp < 0:
  temp = 0
  
print(temp)

Buggy submission (verdict: Runtime Error):
nums = [int(i) for i in input().split()]

A = num[0]
B = num[1]
C = num[2]
 
temp = C - (A - B)
if temp < 0:
  temp = 0
  
print(temp)

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

temp = C - (A - B)
if temp < 0:
  temp = 0
  
print(temp)
Problem p02989 (python)

Fixed submission:
n = input()
d = [int(i) for i in input().split()]
if len(d) % 2 == 1:
  ans = 0
else:
  d.sort()
  if d[len(d)//2-1] == d[len(d)//2]:
    ans = 0
  else:
    ans = d[len(d)//2] - d[len(d)//2-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
d = [int(i) for i in input().split()]
if len(d) % 2 == 1:
  ans = 0
else:
  d.sort()
  if d[len(d)-1] == d[len(d)]:
    ans = 0
  else:
    ans = d[len(d)] - d[len(d)]
    
print(ans)
Problem p03011 (python)

Fixed submission:
num = [int(i) for i in input().split()]
print(min([num[0] + num[1], num[1] + num[2], num[2] + num[0]]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
ans = 0
flag = 0
a = set(a)

#フィボナッチ数列の初期値を調節
dp = [0] * (n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
  
for i in range(2, n+1):
  if dp[i-2] == 0 and dp[i-1] == 0:
    ans = 0
    flag = 1
    break
  elif i in a:
    continue
  else:
    dp[i] = dp[i-1] + dp[i-2]
if flag == 0:
  ans = dp[n]
print(ans%(10**9+7))
Problem p03012 (python)

Fixed submission:
n = int(input())
w = [int(i) for i in input().split()]
d = [abs(sum(w[:i])-sum(w[i:])) for i in range(1, n)]
print(min(d))

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [int(i) for i in input().split()]
d = [abs(w[:i]-w[i:]) for i in range(1, n-1)]
print(min(d))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
ans = 0
flag = 0
a = set(a)

#フィボナッチ数列の初期値を調節
dp = [0] * (n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
  
for i in range(2, n+1):
  if dp[i-2] == 0 and dp[i-1] == 0:
    ans = 0
    flag = 1
    break
  elif i in a:
    continue
  else:
    dp[i] = dp[i-1] + dp[i-2]
if flag == 0:
  ans = dp[n]
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
ans = 0
flag = 0
a = set[a]

#フィボナッチ数列の初期値を調節
dp = [0] * (n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
  
for i in range(2, n+1):
  if dp[i-2] == 0 and dp[i-1] == 0:
    ans = 0
    flag = 1
    break
  elif i in a:
    continue
  else:
    dp[i] = dp[i-1] + dp[i-2]
if flag == 0:
  ans = dp[n]
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
def fibonacci(x, y):
  return x + y

n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))

for i in range(m-1):
  if a[i+1] - a[i] == 1:
    ans = 0
    flag = 1
    break

dp = [0] * 3
dp[0] = 1
dp[1] = 2
if flag == 0:
  if a[0] == 1:
    dp[0] = 1
    dp[1] = 1
for i in range(n):
  dp[2] 
	
      
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
def conbination(x,y):
  return math.factorial(x) // (math.factorial(x-y) * math.factorial(y))
 
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))

flag = 0
ans = 0
 
for i in range(m-1):
  if a[i+1] - a[i] == 1:
    ans = 0
    flag = 1
    break
    
if flag == 0:
  for i in range(n-2*m): #i:２段のぼる回数
    if i>=m
    ans += conbination(n-2*m-1, i-m) * (conbination(n-m, m) 
      
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
def conbination(x,y):
  return math.factrial(x) // (math.factrial(x-y) * math.factrial(y))

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
flag = 0
ans = 0

for i in range(n-1):
  if a[i+1] - a[i] == 1:
    ans = 0
    flag = 1
    break
    
if flag == 0:
  for i in range(n-2*m-1): #i:２段のぼる回数
    ans += conbination(n-2*m-2, i)
      
print(ans%(10**9+7))
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
print("".join([s[i].lower() if i == k-1 else s[i] for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
print([s[i].lower() if i == k else s[i] for i in range(n)]
Problem p02851 (python)

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

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

A=list(map(int,input().split()))
S=[0]+list(numpy.cumsum(A)) #累積和
S2=[(S[i]-i)%K for i in range(N+1)]

d = {}
ans = 0
for j in range(1,N+1):
    if j>K-1:
        if S2[j-K] in d:
            d[S2[j-K]] -= 1
        
    if S2[j-1] in d:
        d[S2[j-1]] += 1
    else:
        d[S2[j-1]] = 1
        
    if S2[j] in d:
        ans += d[S2[j]]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy
N,K=map(int,input().split())
A=list(map(int,input().split()))
S=[0]+list(numpy.cumsum(A)) #累積和
S2=[(S[i]-i)%K for i in range(N+1)]

d = {}
ans = 0
for j in range(1,N+1):
    if j>K-1:
        d[str(S2[j-K])] = d.get(str(S2[j-K]), 0) - 1
    d[str(S2[j-1])] = d.get(str(S2[j-1]), 0) + 1
    ans += d.get(str(S2[j]), 0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
ans=[0]*(10**9+1)

A=list(map(int,input().split()))
A=[A[j]%K for j in range(N)]
ans[1] = A.count(1)

B=[(A[j]+A[j+1])%K for j in range(N-1)]
ans[2] = B.count(2)

for i in range(2,min(K+1,N)):
    C = [(B[j]+B[j+1]-A[j+1])%K for j in range(N-i)]
    ans[i+1] = C.count(i+1)
    A = B
    B = C
    
print(sum(ans))