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

Fixed submission:
n=int(input())
d=1
for i in range(3):
    x=n//d%10
    if x==1:
        n+=8*d
    elif x==9:
        n-=8*d
    d*=10

print(n)

Buggy submission (verdict: Runtime Error):

#################################
#配列を二つに分ける
#引数
# values: 配列
# a,b   : 配列の格納先
#戻り値
# なし
#################################
def separate(values,a,b):
    for v in values:
        a.append(v)
        a,b = b,a


##############################
#登場回数の多い数と登場回数を返す
#引数
# values: ソートされた配列
#戻り値
# 辞書型配列
##############################
def getCount(values):
    currentNum=0
    currentCount=0
    ret={'First' :{'Num':[],'Cnt':0},
         'Second':{'Num':[],'Cnt':0}}
    for v in values:
        if v==currentNum:
            currentCount+=1
        else:
            #別の数字が表れた場合
            if ret['First']['Cnt'] < currentCount:
                #最大値より大きい場合、それが新たな最大値になる
                ret['Second']=ret['First'].copy()
                ret['First']={'Num':[currentNum],'Cnt':currentCount}
            elif ret['First']['Cnt'] == currentCount:
                #最大値タイ
                ret['First']['Num'].append(currentNum)
            elif ret['Second']['Cnt'] < currentCount:
                #2番目より大きい場合、それが新たな2番目になる。
                ret['Second']={'Num':[currentNum],'Cnt':currentCount}
            elif ret['Second']['Cnt'] == currentCount:
                #2位タイ
                ret['Second']['Num'].append(currentNum)

            currentNum=v
            currentCount=1

    #配列の最後まで来た場合
    if ret['First']['Cnt'] < currentCount:
        ret['Second']=ret['First'].copy()
        ret['First']={'Num':[currentNum],'Cnt':currentCount}
    elif ret['First']['Cnt'] == currentCount:
        ret['First']['Num'].append(currentNum)
    elif ret['Second']['Cnt'] < currentCount:
        ret['Second']={'Num':[currentNum],'Cnt':currentCount}
    elif ret['Second']['Cnt'] == currentCount:
        ret['Second']['Num'].append(currentNum)

    return ret


#############################
# メイン
#############################
n = input()
vars = input ()
a=[]
b=[]
varArray=vars.split(" ")
separate(varArray,a,b)
a.sort()
b.sort()
a_result=getCount(a)
b_result=getCount(b)
if (len(a_result['First']['Num'])>1 or
    len(b_result['First']['Num'])>1):
    #最頻値が複数ある場合は素直に計算可
    xa=len(a)-a_result['First']['Cnt']
    xb=len(b)-b_result['First']['Cnt']
    x=xa+xb
else:
    #abどちらも最頻値が1種類の場合
    if a_result['First']['Num'][0]!=b_result['First']['Num'][0]:
        #abの最頻値が異なる場合は素直に計算可
        xa=len(a)-a_result['First']['Cnt']
        xb=len(b)-b_result['First']['Cnt']
        x=xa+xb
    else:
        #abの最頻値が同じ値の場合、どちらかは2番目の値を採用する必要あり
        xaa=len(a)-a_result['First']['Cnt']
        xab=len(b)-b_result['Second']['Cnt']
        xa=xaa+xab
        xba=len(a)-a_result['Second']['Cnt']
        xbb=len(b)-b_result['First']['Cnt']
        xb=xba+xbb
        x=xa if xa<xb else xb

print(x)
Problem p02847 (python)

Fixed submission:
def main():
    dow = ['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']
    s = input()
    i = dow.index(s) + 1
    print(i)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    elif X > 1e9 and afford(A, B, 1e9, X):
        N = int(1e9)
    else:
        limmin = 0
        limmax = 10 ** 9 + 1
        while limmax - limmin > 1:
            m = (limmax + limmin) // 2
            if afford(A, B, m, X):
                limmin = m
            else:
                limmax = m
        N = limmin
    print(N)


def afford(a, b, n, x):
    y = a * n + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    else:
        for d in range(len(str(X)), 0, -1):
            if d * B < X:
                break
        if d > 0:
            N = 0
            d = min(X // A, pow(10, d))
            for N in range(d, 0, -1):
                if afford(A, B, N, X):
                    break
            else:
                N = 0
        else:
            N = 0
    print(N if N < 1e9 else int(1e9))


def afford(a, b, n, x):
    c = a * n
    if c >= x:
        return False
    y = c + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    else:
        for d in range(len(str(X)), 0, -1):
            if d * B < X:
                break
        if d > 0:
            d = min(X // A, pow(10, d))
            for N in range(d, 0, -1):
                if afford(A, B, N, X):
                    break
            else:
                N = 0
        else:
            N = 0
    print(N if N < 1e9 else int(1e9))


def afford(a, b, n, x):
    c = a * n
    if c >= x:
        return False
    y = c + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()
Problem p02970 (python)

Fixed submission:
n,d=(int(x) for x in input().split())
t = 2 * d + 1
     
if n % t == 0:
    ans = n/t
else:
    ans = n/t
    ans = ans + 1

ans = int(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,d = input().split()
n = int(n)
d = int(d)
t = 2d + 1
     
if n % t == 0:
	ans = n/t
else:
	ans = n/t
    ans = ans + 1

print(ans)

Buggy submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
t = 2d + 1
     
if n % t == 0:
	ans = n/t
else:
	ans = n/t
    ans = ans + 1

print(ans)

Buggy submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
t = 2d + 1

if n % t == 0:
  ans = n/t
else:
  ans = n/t + 1
  
print(ans)
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)

num=list(map(int,input().split()))
A=num[0]
B=num[1]
S=lcm(A,B)
print(S)

Buggy submission (verdict: Runtime Error):
import math
num=list(map(int,input().split()))
A=num[0]
B=num[1]
S=(A*B)//math.gcd(A,B)
print(S)

Buggy submission (verdict: Runtime Error):
import math
num=list(map(int,input().split()))
A=num[0]
B=num[1]
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
num=list(map(int,input().split()))
A=num[0]
B=num[1]
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
num=list(input().split())
A=num[0]
B=num[1]
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
num=list(input().split())
A=int(num[0])
B=int(num[1])
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=input().rstrip()
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=input().split()
print(A*B//math.gcd(A,B))
Problem p02833 (python)

Fixed submission:
N=int(input())
c=N%10
if c%2==1:
  print("0")
else:
  i=1
  b=0
  while i<=100:
    b+=N//(2*(5**i))
    i+=1
  else:
    print(b)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%10==1:
  return (N-1)/10
elif N%10==2:
  return (N-2)/10
elif N%10==3:
  return (N-3)/10
elif N%10==4:
  return (N-4)/10
elif N%10==5:
  return ((N-5)/10)+1
elif N%10==6:
  return (N-6)/10
elif N%10==7:
  return ((N-7)/10)+1
elif N%10==8:
  return (N-8)/10
else:
  return (N-9)/10
Problem p02836 (python)

Fixed submission:
S = input()

Slen = len(S)
center = int(Slen/2)

Answer = 0

a = S[:center]
b = S[-1:center-1:-1]

for i in range(len(a)):
  if a[i] != b[i]:
    Answer += 1

print(Answer)

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

Slen = len(S)
center = int(Slen/2)

Answer = 0

a = S[:center]
if center%2 == 0:
  b = S[-1:center-1:-1]
else:
  b = S[-1:center:-1]

for i in range(len(a)):
  if a[i] != b[i]:
    Answer += 1

print(Answer)
Problem p02847 (python)

Fixed submission:
day = str(input())

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

for d in days:
    if(day == d):
        print(days.index(d) + 1)

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

if(a* 1000000000 + b * len(str(1000000000)) <= x):
    print(1000000000)
    exit()

n = int(x/a)

while(True):

    if(n == 0):
        print(0)
        exit()

    if(a * n + b * len(str(n)) <= x):
        print(n)
        exit()
    else:
     n -= 1

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

n_s = ""

for c in s:
    add = n
    c_num = ord(c) - 64
    if(n % 26 == 0):
        n_s += c
    else:
        if(c_num + n > 26):
            add = (c_num + n) % 26
            n_s += chr(add + 64)
        else:
            n_s += chr(c_num + add + 64)

print(n_s)
Problem p02859 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
print(a * * 2)
Problem p02860 (python)

Fixed submission:
a = int(input())
str = list(input())

if a%2 :
	print("No")
	exit()
  
n_str_1 = ""
n_str_2 = ""
  
for i in range(int(a/2)):
    n_str_1 += str[i]
    n_str_2 += str[i+int(a/2)]

if n_str_1 == n_str_2 :
	print("Yes")
else :
  	print("No")

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

if a%2 :
	print("No")
	exit()
  
n_str_1 = ""
n_str_2 = ""
  
fot i in range(a/2):
	n_str_1 += str[i]
    n_str_2 += str[i+a/2]

if n_str_1 == n_str_2 :
	print("Yes")
else :
  	print("No")
Problem p03104 (python)

Fixed submission:
# coding: utf-8

A, B = [int(i) for i in input().split()]

def count_1(bi, idx):
    bi = bi[::-1]
    cnt = 0
    if idx > 0:
        for i in range(0, idx):
            cnt += int(bi[idx]) * int(bi[i]) * int(2**i)
    if idx < (len(bi) - 1):
        for i in range(idx + 1, len(bi)):
            cnt += int(bi[i]) * int(2**i) / 2
    cnt += int(bi[idx])        
    return(int(cnt))

a = str(bin(max(A-1, 0)))[2:]
b = str(bin(B))[2:]
a = (len(b) - len(a)) * "0" + a # 長さ調整

def count_1s(bi):
    return([count_1(bi, i) for i in range(len(bi))[::-1]])

a_cnt = count_1s(a)
b_cnt = count_1s(b)


print(int("".join([str((i - j) % 2) for i, j in zip(b_cnt, a_cnt)]), 2))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

A, B = [int(i) for i in input().split()]

def count_1(bi, idx):
    bi = bi[::-1]
    cnt = 0
    if idx > 0:
        for i in range(0, idx):
            cnt += int(bi[idx]) * int(bi[i]) * int(2**i)
    if idx < (len(bi) - 1):
        for i in range(idx + 1, len(bi)):
            cnt += int(bi[i]) * int(2**i) / 2
    cnt += int(bi[idx])        
    return(int(cnt))

a = str(bin(A-1))[2:]
b = str(bin(B))[2:]
a = (len(b) - len(a)) * "0" + a # 長さ調整

def count_1s(bi):
    return([count_1(bi, i) for i in range(len(bi))[::-1]])

a_cnt = count_1s(a)
b_cnt = count_1s(b)

print(int("".join([str((i - j) % 2) for i, j in zip(b_cnt, a_cnt)]), 2))
Problem p02829 (python)

Fixed submission:
number1 = int(input())
number2 = int(input())
choices = [1,2,3]
choices.remove(number1)
choices.remove(number2)
print(*choices)

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

Buggy submission (verdict: Runtime Error):
a, b = input(), input()
print(6-a-b)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
print(6-a-b)
Problem p02831 (python)

Fixed submission:
a, b = map(int,input().split())
for i in range(1,b+1):
  if (a*i) % b == 0:
    print(a*i)
    break

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int,stdin.readline().split())
gcd = math.gcd(a,b)
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
a, b = map(int,stdin.readline().split())
gcd = math.gcd(a,b)
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
a, b = map(int,stdin.readline().split())
gcd = math.gcd(a,b)
lcm = (a*b)/gcd
print(lcm)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
a, b = map(int,stdin.readline().split())
gcd = math.gcd(a,b)
lcm = (a*b)//gcd
print(lcm)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int,input().split())
gcd = math.gcd(a,b)
lcm = (a*b)//gcd
print(lcm)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
a, b = map(int,stdin.readline().split())
gcd = math.gcd(a,b)
lcm = (a*b)//gcd
print(lcm)
Problem p03075 (python)

Fixed submission:
nums = [int(input()) for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  print(':(')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
nums = [input() for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  print(':(')
print('Yay!')

Buggy submission (verdict: Runtime Error):
nums = [input() for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  print ':('
print 'Yay!'

Buggy submission (verdict: Runtime Error):
nums = [input() for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  return ':('
return 'Yay!'
Problem p02847 (python)

Fixed submission:
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")

Buggy submission (verdict: Runtime Error):
A, B, X = map(int,input().split())

min_num = 0
max_num = 10 ** 9
#２分探索
# まず、最大値の10**9が購入できるか判定
if A * max_num + B * 9 <= X:
    print(max_num)
    exit()

while(1):
    ave_num = (min_num + max_num)//2 # get a center number
    price = A * ave_num + B * len(str(ave_num)) # price = f(ave_num)
    #print(ave_num,"_",min_num, "_", max_num)
    if min_num + 1 == max_num:
        print(min_num)
        break
    elif min_num == max_num:
        print(min_num)
        break

    elif X >= price:         # bottom down 
        min_num = ave_num
    else:                   # top up
        max_num = ave_num
Problem p02880 (python)

Fixed submission:
l=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81]
print('Yes' if int(input()) in l else 'No')

Buggy submission (verdict: Runtime Error):
n = int(input())
if 1=<n<=81:
    if n%10==0:
        print('Yes' if n==10 else 'No')
    else:
        print('Yes')

else:
    print('No')
Problem p02847 (python)

Fixed submission:
S = input()
Ds = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(Ds[S])

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
As = ""
for i in range(len(S)):
    As += chr(((ord(S[i]) - 65) + N) % 26 + 65)
print(As)
Problem p02925 (python)

Fixed submission:
import sys

input = sys.stdin.readline
N = int(input())
As = [list(map(int, input().split())) + [-1] for _ in range(N)]

import collections

que = collections.deque([i for i in range(N)])
counters = [0] * N
days = [0] * N
while que:
    player = que.popleft()
    opponent = As[player][counters[player]] - 1
    if As[opponent][counters[opponent]] - 1 == player:
        days[player] = max(days[player], days[opponent]) + 1
        days[opponent] = days[player]
        counters[player] += 1
        counters[opponent] += 1
        que.append(player)
        que.append(opponent)
for c in counters:
    if c < N - 1:
        print(-1)
        break
else:
    print(max(days))

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

Cs = [0] * (N + 1)
d = 1
ms = 0
msMax = N * (N - 1) // 2
sw = True
while sw:
    tab = set()
    c = 0
    for i in range(1, N + 1):
        if Cs[i] == N - 1:
            continue
        a = 0
        b = 0
        if i > As[i][Cs[i]]:
            a = As[i][Cs[i]]
            b = i
        else:
            a = i
            b = As[i][Cs[i]]
        if (a, b) in tab:
            ms = ms + 1
            c = c + 1
            if ms == msMax:
                sw = False
                break
            Cs[a] += 1
            Cs[b] += 1
        else:
            tab.add((a, b))
    if c == 0:
        d = 0
        break
    d += 1
print(d - 1)    N = int(input())
    As = [[]]
    for i in range(N):
        As.append(list(map(int, input().split())))

    Cs = [0] * (N + 1)
    Ks = [False] * (N + 1)
    d = 1
    ms = 0
    msMax = N * (N - 1) // 2
    sw = True
    tab = set()
    while sw:
        c = 0
        wa = []
        for i in range(1, N + 1):
            if Ks[i]:
                continue
            if Cs[i] == N - 1:
                continue
            a = 0
            b = 0
            if i > As[i][Cs[i]]:
                a = As[i][Cs[i]]
                b = i
            else:
                a = i
                b = As[i][Cs[i]]
            if (a, b) in tab:
                ms = ms + 1
                c = c + 1
                if ms == msMax:
                    sw = False
                    print(d)
                    break
                Cs[a] += 1
                Cs[b] += 1
                tab.remove((a, b))
                wa.append(a)
                wa.append(b)
            else:
                tab.add((a, b))
                Ks[i] = True
        for i in wa:
            Ks[i] = False
        d += 1
        if c == 0:
            print(-1)
            break
Problem p02948 (python)

Fixed submission:
import sys

input = sys.stdin.readline
N, M = map(int, input().split())

import bisect

ABs = [[] for _ in range(M + 1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        ABs[A].append(B)
ABs[0].sort()

As = 0
for i in range(M + 1):
    if i > 0:
        for b in ABs[i]:
            bisect.insort_left(ABs[0], b)
    if len(ABs[0]) > 0:
        As += ABs[0].pop()
print(As)

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline
N, M = map(int, input().split())

import heapq

ABs = [[] for _ in range(M + 1)]
for i in range(N):
    A, B = map(int, input().split())
    ABs[A].append(-B)
heapq.heapify(ABs[0])

As = 0
for i in range(M + 1):
    if i > 0:
        for b in ABs[i]:
            heapq.heappush(ABs[0], b)
    if len(ABs[0]) > 0:
        As -= heapq.heappop(ABs[0])
print(As)
Problem p02987 (python)

Fixed submission:
S = set(input())
print("Yes" if len(S) == 2 else "No")

Buggy submission (verdict: Runtime Error):
    S = set(input())
    print("Yes" if len(S) == 2 else "No")

Buggy submission (verdict: Runtime Error):

def resolve():
    S = list(raw_input())
    S.sort()
    print "Yes" if S[0] == S[1] and S[2] == S[3] else "No"

Buggy submission (verdict: Runtime Error):
import sys

S = list(raw_input())
S.sort()
print "Yes" if S[0] == S[1] and S[2] == S[3] else "No"

Buggy submission (verdict: Runtime Error):
 S = list(raw_input())
 S.sort()
 print "Yes" if S[0] == S[1] and S[2] == S[3] else "No"
Problem p02990 (python)

Fixed submission:
def factorial(n, s):
    f = 1
    for i in range(s, n + 1):
        f *= i
    return f


def nCr(n, r):
    if n == r:
        return 1
    else:
        return factorial(n, r + 1) // factorial(n - r, 1)


T = 10 ** 9 + 7
N, B = list(map(int, input().split()))
R = N - B
for i in range(1, B + 1):
    if i > R + 1:
        print(0)
    else:
        print((nCr(R + 1, i) % T) * (nCr(B - 1, i - 1) % T) % T)

Buggy submission (verdict: Runtime Error):
T = 10**9+7

N, B = list(map(int, input().split()))
R = N - B
for i in range(1, B+1):
    if i > R + 1:
        print(0)
    else:
        print((nCr(R+1, i) % T) * (nCr(B-1, i-1) % T) % T)

def factorial(n, s):
    f = 1
    for i in range(s, n+1):
        f *= i
    return f

def nCr(n, r):
    if n == r:
        return 1
    else:
        return factorial(n, r+1) // factorial(n - r, 1)
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):
H, W = list(map(int, input().split()))
M = [['.' for w in range(W)] for h in range(H)]
for h in range(0, H):
    M[h] = list(input())

Yoko = [[0 for w in range(W)] for h in range(H)]
Tate = [[0 for w in range(W)] for h in range(H)]
for h in range(0, H):
    for w in range(0, W):
        if M[h][w] != '#':
            if w >= 0 and M[h][w - 1] != '#':
                Yoko[h][w] = Yoko[h][w - 1]
            else:
                c = 0
                for d in range(w, W):
                    if M[h][d] == '#':
                        break
                    c += 1
                Yoko[h][w] = c
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            if h >= 0 and Tate[h - 1][w] > 0:
                Tate[h][w] = Tate[h - 1][w]
            else:
                c = 0
                for d in range(h, H):
                    if M[d][w] == '#':
                        break
                    c += 1
                Tate[h][w] = c
mx = 0
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            c = Yoko[h][w] + Tate[h][w] - 1
            if c > mx:
                mx = c
print(mx)
Problem p03013 (python)

Fixed submission:
N, M = list(map(int, input().split()))
As = set()
for i in range(0, M):
    As.add(int(input()))
C = 10 ** 9 + 7

dp = [0 for _ in range(N + 1)]
dp[0] = 1
dp[1] = 0 if 1 in As else 1

for i in range(2, N + 1):
    if i in As:
        dp[i] = 0
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % C

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
a = []
for i in range(0, M):
    a.append(int(input()))
a.sort()
T = 10 ** 9 + 7

r = [0 for _ in range(N + 1)]
r[0] = 1
r[1] = 1


def fib(n):
    if r[n] > 0:
        return r[n]
    else:
        r[n] = fib(n - 1) + fib(n - 2)
        return r[n]


for i in range(0, M - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        break
else:
    now = 0
    c = 1
    for i in range(0, M):
        c *= fib(a[i] - now - 1) % T
        c %= T
        now = a[i] + 1
    c *= fib(N - now)
    print(c % T)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
a = []
for i in range(0, M):
    a.append(int(input()))
a.sort()
T = 10 ** 9 + 7

r = [0 for _ in range(N + 1)]
r[0] = 1
r[1] = 1


def fib(n):
    if r[n] > 0:
        return r[n]
    else:
        return fib(n - 1) + fib(n - 2)


for i in range(0, M - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        break
else:
    now = 0
    c = 1
    for i in range(0, M):
        c *= fib(a[i] - now - 1) % T
        c %= T
        now = a[i] + 1
    c *= fib(N - now)
    print(c % T)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
a = []
for i in range(0, M):
    a.append(int(input()))
a.sort()
T = 10 ** 9 + 7

r = [0 for _ in range(N + 1)]
r[0] = 1
r[1] = 1


def fib(n):
    if r[n] > 0:
        return r[n]
    else:
        return fib(n - 1) + fib(n - 2)


for i in range(0, M - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        break
else:
    now = 0
    c = 1
    for i in range(0, M):
        c *= fib(a[i] - now - 1)
        c %= T
        now = a[i] + 1
    c *= fib(N - now)
    print(c % T)
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())
Bs = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    Bs[a].append(b)
    Bs[b].append(a)
import heapq
import copy

st = []
ap = [{1: True}]
heapq.heappush(st, (1, 0))
c = 0
while len(st) > 0:
    (node, log) = heapq.heappop(st)
    for b in Bs[node]:
        if b in ap[log]:
            continue
        elif len(ap[log]) == N - 1:
            c += 1
        else:
            heapq.heappush(st, (b, len(ap)))
            newlog = copy.copy(ap[log])
            newlog[b] = True
            ap.append(newlog)
print(c)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Bs = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    Bs[a].append(b)
    Bs[b].append(a)
import heapq

st = []
heapq.heappush(st, (1, {1: True}))
c = 0
while len(st) > 0:
    (node, log) = heapq.heappop(st)
    for b in Bs[node]:
        if b in log:
            continue
        elif len(log) == N - 1:
            c += 1
        else:
            newlog = log.copy()
            newlog[b] = True
            heapq.heappush(st, (b, newlog))
print(c)