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

Fixed submission:
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
if m == 0:
  Fib = [1,2]
  for i in range(2,n):
    Fib.append(Fib[i-2]+Fib[i-1])
  print(Fib[n-1]%1000000007)
  exit()

B = [A[i+1]- A[i] for i in range(m-1)]
B.insert(0,A[0]+1)
B.append(n+1-A[m-1])

M = max(A)

Fib = [0,1]
for i in range(2,M+10):
  Fib.append(Fib[i-2]+Fib[i-1])

ans = 1
for i in range(len(B)):
  ans = (ans * Fib[B[i]-1])%1000000007
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
B = [A[i+1]- A[i] for i in range(m-1)]
B.insert(0,A[0]+1)
B.append(n+1-A[m-1])

M = max(A)

Fib = [0,1]
for i in range(2,M+10):
  Fib.append(Fib[i-2]+Fib[i-1])

ans = 1
for i in range(len(B)):
  ans = (ans * Fib[B[i]-1])%1000000007
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
B = [A[i+1]- A[i] for i in range(m-1)]
B.insert(0,A[0]+1)
B.append(n+1-A[m-1])

M = max(A)

def Fib(n):
  L = [0,1]
  for i in range(2,n+3):
    L.append(L[i-2]+L[i-1])
  return(L)

ans = 1
for i in range(len(B)):
  ans = ans * Fib(max(A))[B[i]-1]
  ans = ans % 1000000007
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
for i in range(m-1):
  if A[i]+1 == A[i+1]:
    print(0)
    exit()

ANS = [A[0]-0]
for i in range(m-1):
  ANS.append(A[i+1]-A[i]-1)
ANS.append(n-A[m-1])

Fib = [1,1,2]
for i in range(3,max(ANS)+4):
  Fib.append(Fib[i-1]+Fib[i-2])

ans = 1
for i in range(len(ANS)):
  ans = (ans * Fib[ANS[i]-1])%1000000007
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
for i in range(m-1):
  if A[i]+1 == A[i+1]:
    print(0)
    exit()

ANS = [A[0]-0]
for i in range(m-1):
  ANS.append(A[i+1]-A[i]-1)
ANS.append(n-A[m-1])

Fib = [1,1,2]
for i in range(3,max(ANS)+4):
  Fib.append(Fib[i-1]+Fib[i-2])

print(Fib)
print(ANS)
ans = 1
for i in range(len(ANS)):
  ans = (ans * Fib[ANS[i]-1])%1000000007
  
print(ans)
Problem p03107 (python)

Fixed submission:
s = input()
c = max(s.count("1") - s.count("0"),s.count("0") - s.count("1"))

if len(s) == 1:
	print(0)
else:
	print(len(s)-c)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
S = [int(s[i]) for i in range(n)]
count = 0

def f(X):
  p = 0
  if len(X) >= 4:
    for i in range(0,len(X)-4):
      if [X[i],X[i+1],X[i+2],X[i+3]] == [1,1,0,0] or [1,0,1,0] or [0,1,0,1]or[0,0,1,1]):
        X = X[0:i+2] + X[i+3:len(X)+1]
        return(X)
Problem p03242 (python)

Fixed submission:
n = list(input())
for i in range(len(n)):
  if n[i] == "1":
    n[i] = "9"
  else:
    n[i] = "1"
print("".join(n))

Buggy submission (verdict: Runtime Error):
n = input()
for i in range(len(n)):
  if n[i] == "1":
    n[i] = "9"
  else:
    n[i] = "1"
print(n)
Problem p03286 (python)

Fixed submission:
n = int(input())

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

s = ""

while True:
    if n == 0:
        break
    if n%2 == 0:
        s += "0"
        n = n//(-2)
    else:
        s += "1"
        n = (n-1)//(-2)

print(s[::-1])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
if n == 0:
  print(0)
  exit()
else:
  pass

m = math.floor(math.log2(abs(n)))
ans = []
for i in range(m+2):
  ans.append(n//((-2)**(m+1-i)))

while True:
  if ans[0] == 0:
    ans = ans[1:len(ans)]
  else:
    break

ANS = [str(ans[i]) for i in range(len(ans))]
print(int("".join(ANS)))
Problem p03315 (python)

Fixed submission:
s = list(input())
for i in range(len(s)):
  if s[i] == "+":
    s[i] = 1
  else:
    s[i] = -1

print(sum(s))

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in s:
  if s[i] == "+":
    s[i] = 1
  else:
    s[i] = -1

print(sum(s))
Problem p03631 (python)

Fixed submission:
n = list(input())

for i in range(len(n)):
  if n[i] != n[len(n)-i-1]:
    print("No")
    exit()
print("Yes")

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

#3桁なのでとても簡単

if n[0] == n[2]:
  print("Yes"):
else:
  print("No")
Problem p03804 (python)

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

A = [input() for i in range(n)]
B = [input() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,m)):
        print("Yes")
        exit()
print("No")

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

A = [input() for i in range(n)]
B = [input() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,M)):
        print("Yes")
        exit()
print("No")

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

A = [input() for i in range(n)]
B = [intpu() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,M)):
        print("Yes")
        exit()
print("No")
Problem p03835 (python)

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

l = 0

if s <= k:
  l = int((s+2)*(s+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

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

l = 0

if s <= k:
  l = int((k+2)(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

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

l = 0

if s <= k:
  l = int((k+2)(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2k:
      l += 0
    elif k < s-x <= 2k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)
Problem p02682 (python)

Fixed submission:
import sys
readmi = lambda: map(int, sys.stdin.readline().split())

A, B, C, K = readmi()
# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, C)
# print result
print(max_sum)

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

# parse int
A = int(A)
B = int(B)
C = int(C)
K = int(K)

# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, B)
# print result
print(max_sum)
Problem p03015 (python)

Fixed submission:
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)

def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer)


main()

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]
    n = len(l)
    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    print(answer)


main()
Problem p02915 (python)

Fixed submission:
t = int(input())
print(t**3)

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

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)

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

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
b = False
bai = K
counter = 1
while bai <= B:
    if A <= bai <= B:
        b = True
        break
    counter += 1
    bai = K*counter
if b:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
li = []
for q in range(Q):
    a, b, c, d = map(int, input().split())
    li.append([[a,b], c, d])
ok_list = []
def dfs(num_li, depth):
    if len(num_li) == N:
        ok_list.append(num_li)
        return
    if depth == M:
        return
    dfs(num_li, depth+1)
    while len(num_li) <N:
        num_li += str(depth)
        dfs(num_li, depth+1)
dfs("", 0)
maxpoint = 0
for ok in ok_list:
    point = 0
    for q in range(Q):
        if int(ok[li[q][0][1]-1])- int(ok[li[q][0][0]-1]) == li[q][1]:
            point += li[q][2]
    if point > maxpoint:
        maxpoint = point
print(maxpoint)
N, M, Q = map(int, input().split())
li = []
for q in range(Q):
    a, b, c, d = map(int, input().split())
    li.append([[a,b], c, d])
ok_list = []
def dfs(num_li, depth):
    if len(num_li) == N:
        ok_list.append(num_li)
        return
    if depth == M:
        return
    dfs(num_li, depth+1)
    while len(num_li) <N:
        num_li += str(depth)
        dfs(num_li, depth+1)
dfs("", 0)
maxpoint = 0
for ok in ok_list:
    point = 0
    for q in range(Q):
        if int(ok[li[q][0][1]-1])- int(ok[li[q][0][0]-1]) == li[q][1]:
            point += li[q][2]
    if point > maxpoint:
        maxpoint = point
print(maxpoint)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
N = int(input())
li = []
count = 0
for n in range(N):
    i = input()
    if i in li:
        pass
    else:
        li.append(i)
        count+=1
print(count)
Problem p02729 (python)

Fixed submission:
n, m = map(int, input().split())
if n <= 1:
    sn = 0
else:
    sn = int(0.5*(n)*(n-1))
if m <= 1:
    sm = 0
else:
    sm = int(0.5*(m)*(m-1))
print(sn+sm)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
li = list(map(int, input().split()))
def calc(a):
    return int(a*(a-1)*0.5)
for k in range(n):
	dic = collections.Counter(li)
	dic[li[k]] -=1
	data2 = map(calc, list(dic.values()))
	print(sum(data2))
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
	if t <= a:
		x = s*a+t
	else:
		x = s*a+a
print(x)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
	if t <= a:
    	x = s*a+t
	else:
    	x = s*a+a
print(x)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
    if t <= a:
    	x = s*a+t
	else:
    	x = s*a+a
print(x)
Problem p02954 (python)

Fixed submission:
s = list(input())
output = [0 for i in s]
ruiseki = 0
for p in range(len(s)):
    if s[p] == "R":
        if s[p+1] == "R":
            ruiseki+=1
        else:
            ruiseki+=1
            output[p] += ruiseki//2 + ruiseki%2
            output[p+1] += ruiseki//2
            ruiseki=0
    
ruiseki = 0
for q in range(len(s)-1, -1, -1):
    if s[q] == "L":
        if s[q-1]=="L":
            ruiseki+=1
        else:
            ruiseki+=1
            output[q] += ruiseki//2 + ruiseki%2
            output[q-1] += ruiseki//2
            ruiseki=0
print(" ".join(map(str,output)))

Buggy submission (verdict: Runtime Error):
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(16):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(16):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))

Buggy submission (verdict: Runtime Error):
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(16):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(20):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))
提出情報

Buggy submission (verdict: Runtime Error):
s = list(input())
def move_children(RL, li):
    newli = li.copy()
    for n, rl in enumerate(RL):
        if rl == "R":
            newli[n]-=li[n]
            newli[n+1]+=li[n]
        elif rl=="L":
            newli[n]-=li[n]
            newli[n-1]+=li[n]
    return newli
pre = [1 for i in range(len(s))]

for f in range(10**5):
    counter+=1
    nextli=move_children(s,pre)

print(nextli)
Problem p02831 (python)

Fixed submission:
import math

def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
      a, b = b, a % b
    return b


def lcm(a, b):
    return (a * b) // gcd(a, b)

a, b = map(int, input().split())
print(lcm(a, b))

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

Fixed submission:
inputs= list(map(int,input().split()))
k = inputs[0]
s = inputs[1]
answer = 0
for i in range(k+1):
  x = i
  for l in range(k+1):
    y = l
    z = s-x-y
    if z >= 0 and z <= k :
      answer += 1
print(answer)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
k = a[0]
s = a[1]
num=0
for l in range(k+1):
    for m in range(l,k+1):
        n = s-l-m
        if(n <= k & n >= 0):
            if(l!=m and l!= n and m!=n):
                num+=3
            else if (l==m and m==n):
                num+=1
            else:
                num+=2
                
print(num)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= k):
            num+=1

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= k):
            num++

Buggy submission (verdict: Runtime Error):
k,s = input().split()
for l in range(k):
    for m in range(k):
        if(s-l-m <= k):
            print(l,m,s-l-m)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
b=float(b)
c=int(b*100+0.1)
a=int(a)
d=str(a*c)
if len(d)<=2:
    print(0)
else:
    print(d[:-2])

Buggy submission (verdict: Runtime Error):
a, b = input().split()
c=int(b*100)
a2=int(a)
print(int(a2*c/100))
Problem p02699 (python)

Fixed submission:
A, B = map(int, input().split())

if A <= B:
    print("unsafe")
else:
    print("safe")

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

if A <= W:
    print("unsafe")
else:
    print("safe")
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
try:
    for i in range(action_mod):
        if one_action[i] == "B":
            ans += 1
except:
    pass

print(ans)

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

# one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
# for i in range(action_mod):
#     if one_action[i] == "B":
#         ans += 1

print(ans)

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)

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

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB
one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)
Problem p02897 (python)

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

Buggy submission (verdict: Runtime Error):
#E https://atcoder.jp/contests/abc142/submissions/7853616
def main():
    n, m = map(int, input().split())
    inf = 10**9 #この10億は何に使う？->とにかくデカい数字。
    bit_dp = [inf for _ in range(2**(n))] #10億を2**n個並べる配列を作る。n=12 => 4096個
    bit_dp[0] = 0
    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))#鍵1個につきa,b,c1~cbを決める
        bit_n = 0
        for i in c:
            bit_n |= 1 << i - 1 #ここで何番目をあけられるのかをbit_nで定義する。1と3ならbit_n=(5)101、2と3なら110(6)
        for i in range(2**n):
            if bit_dp[i|bit_n] > bit_dp[i] + a:
                bit_dp[i|bit_n] = bit_dp[i] + a
    if bit_dp[-1] >= inf:
        print(-1)
    else:
        print(bit_dp[-1])
                
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
def gcd(x, y):
        while y != 0:
            x, y = y, x%y
        return x
    
def factorize(n):
    factor = []
    for num in range(2, n*n+1):
        while n % num == 0:
            n //= num
            factor.append(num)
    return factor
    
g = gcd(A, B)
f = factorize(g)
print(len(f)+1)
Problem p03012 (python)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
ans = 10**9

for i in range(1, N):
    S1 = sum(W[:i])
    S2 = sum(W[i:])
    sa = abs(S1-S2)
    ans = min(ans, sa)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
ans = 10**9

for i in range(1, n):
    S1 = sum(W[:i])
    S2 = sum(W[i:])
    sa = abs(S1-S2)
    ans = min(ans, sa)
print(ans)

Buggy submission (verdict: Runtime Error):
# ABC-129-B
N = int(input())
W = list(map(int, input().split()))
ans = 10**9

for i in range(1, n):
    S1 = sum(W[:i])
    S2 = sum(W[i:])
    sa = abs(S1-S2)
    ans = min(ans, sa)
print(ans)
Problem p03013 (python)

Fixed submission:
#ABC-129-C
N, M = map(int, input().split())
# N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

dp = [0] * (N+1)
#どうやってもスタート地点から始まるから、0に行く方法は1通りのみ
dp[0] = 1

#1が壊れていなければ1に行く方法は0->1の1通りのみ
if 1 not in a:
    dp[1] = 1
    not_broken_stairs = set(range(2, N+1)) - set(a)
else:
    not_broken_stairs = set(range(1, N+1)) - set(a)    

#i=2or3から始まる。
#１が壊れていなければ2に行く方法は(0->2の1通り)+(1->2の1通り)で2通り。
for i in not_broken_stairs:
    dp[i] = dp[i-2] + dp[i-1]
    
print(dp[-1] % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
memo = [0]*(N+1)
memo[1] = 1
memo[2] = 2
mod = 10**9+7

for _ in range(M):
    ai = int(input())
    memo[ai] = None

if memo[1] == None:
    memo[2] = 1

for i in range(3, N+1):
    tmp = 0
    if memo[i] == None:
        continue
    if memo[i-1] != None:
        tmp += memo[i-1]
    if memo[i-2] != None:
        tmp += memo[i-2]
    memo[i] = tmp

print(memo[N]%mod)

Buggy submission (verdict: Runtime Error):
#ABC-129-C
N, M = map(int, input().split())
# N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

dp = [0] * (N+1)
#どうやってもスタート地点から始まるから、0に行く方法は1通りのみ
dp[0] = 1

#1が壊れていなければ1に行く方法は0->1の1通りのみ
if a[0] != 1:
    dp[1] = 1
    not_broken_stairs = set(range(2, N+1)) - set(a)
else:
    not_broken_stairs = set(range(1, N+1)) - set(a)    

#i=2or3から始まる。
#１が壊れていなければ2に行く方法は(0->2の1通り)+(1->2の1通り)で2通り。
for i in not_broken_stairs:
    dp[i] = dp[i-2] + dp[i-1]
    
print(dp[-1] % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
#ABC-129-C
N, M = map(int, input().split())
# N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

dp = [0] * (N+1)
#どうやってもスタート地点から始まるから、0に行く方法は1通りのみ
dp[0] = 1

#1が壊れていなければ1に行く方法は0->1の1通りのみ
if a[0] != 1:
    dp[1] = 1
    not_broken_stairs = set(range(2, N+1)) - set(a)
else:
    not_broken_stairs = set(range(1, N+1)) - set(a)    

#i=2or3から始まる。
#１が壊れていなければ2に行く方法は(0->2の1通り)+(1->2の1通り)で2通り。
for i in not_broken_stairs:
    dp[i] = dp[i-2] + dp[i-1]
    
print(dp[-1] % (10 ** 9 + 7))
Problem p03315 (python)

Fixed submission:
S = input()
ans = 0

for char in S:
    if char == "+":
        ans += 1
    else:
        ans -= 1

print(ans)

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

for char in S:
    if char = "+":
        ans += 1
    else:
        ans -= 1

print(ans)