Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(2)]

even = a[1][0::2]
odd = a[1][1::2]

evendic = {}
odddic = {}

evenmax = []
oddmax = []

ans = 0

for i in even:
    if i in evendic:
        evendic[i] += 1
    else:
        evendic[i] = 1
  
for i in odd:
    if i in odddic:
        odddic[i] += 1
    else:
        odddic[i] = 1

evennum = max(evendic.values())
oddnum = max(odddic.values())

for k, v in evendic.items():
    if v == evennum :
        evenmax.append(k)

for k, v in odddic.items():
    if v == oddnum:
        oddmax.append(k)

if evennum == oddnum:
    if len(evenmax) >= 2 or len(oddmax) >= 2:
        ans = a[0][0] - evennum * 2
    elif max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum * 2
    else:
        ans = a[0][0] - evennum - max([sorted(odddic.values())[-2], sorted(evendic.values())[-2]])

else:
    if max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum - oddnum
    else:
        if evennum > oddnum:
            ans = a[0][0] - evennum - sorted(odddic.values())[-2]
        else:
            ans = a[0][0] - oddnum - sorted(evendic.values())[-2]

    
print(ans)

Fixed submission:
a = [list(map(int, input().split())) for i in range(2)]

even = a[1][0::2]
odd = a[1][1::2]

evendic = {}
odddic = {}

evenmax = []
oddmax = []

ans = 0

for i in even:
    if i in evendic:
        evendic[i] += 1
    else:
        evendic[i] = 1
  
for i in odd:
    if i in odddic:
        odddic[i] += 1
    else:
        odddic[i] = 1

evennum = max(evendic.values())
oddnum = max(odddic.values())

for k, v in evendic.items():
    if v == evennum :
        evenmax.append(k)

for k, v in odddic.items():
    if v == oddnum:
        oddmax.append(k)

if len(set(even)) == 1 and len(set(odd)) == 1:
    if even == odd:
        ans = a[0][0] // 2

elif evennum == oddnum:
    if len(evenmax) >= 2 or len(oddmax) >= 2:
        ans = a[0][0] - evennum * 2
    elif max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum * 2
    else:
        ans = a[0][0] - evennum - max([sorted(odddic.values())[-2], sorted(evendic.values())[-2]])

else:
    if max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum - oddnum
    else:
        if evennum > oddnum:
            ans = a[0][0] - evennum - sorted(odddic.values())[-2]
        else:
            ans = a[0][0] - oddnum - sorted(evendic.values())[-2]

    
print(ans)
Buggy python submission (verdict: Runtime Error):
X = input()
print("Yes" if X>=30 else "No")

Fixed submission:
X = int(input())
print("Yes" if X>=30 else "No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input().strip().split() for _ in range(n))
x=input().strip()

ans=0
isis=False
for ss,tt in s:
  if isis:
    ans += (tt)
  if ss==x:
    isis=True
print(ans)

Fixed submission:
n=int(input())
s=list(input().strip().split() for _ in range(n))
x=input().strip()

ans=0
isis=False
for ss,tt in s:
  if isis:
    ans += int(tt)
  if ss==x:
    isis=True
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))


def main():
    n, m = map(int, input().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, input().split())
        edges[s-1].append(t-1)
    
    ans = n + 1
    for i in range(n - 1):
        # 頂点 i からの辺を消す
        dp = [0 for _ in range(n)]

        for j in range(n - 2, -1, -1):
            totale, maxe = 0, 0
            for e in edges[j]:
                totale += dp[e]
                maxe = max(maxe, dp[e])
        
            if i == j and len(edges[j]) > 1:
                dp[j] = (totale - maxe) / (len(edges[j]) - 1) + 1
            else:
                dp[j] = totale / len(edges[j]) + 1
        
        ans = min(ans, dp[0])
    
    print("%.10f" % ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))


def main():
    n, m = map(int, input().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, input().split())
        edges[s-1].append(t-1)
    
    ans = n + 1
    for i in range(n - 1):
        # 頂点 i からの辺を消す
        dp = [0 for _ in range(n)]

        for j in range(n - 2, -1, -1):
            totale, maxe = 0, 0
            for e in edges[j]:
                totale += dp[e]
                maxe = max(maxe, dp[e])
        
            if i == j and len(edges[j]) > 1:
                dp[j] = (totale - maxe) / (len(edges[j]) - 1) + 1
            else:
                dp[j] = totale / len(edges[j]) + 1
        
        ans = min(ans, dp[0])
    
    print("%.10f" % ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, m, l = map(int, input().split())
    d = [[float("inf") for _ in range(n)] for _ in range(n)]
    for i in range(n):
        d[i][i] = 0
    
    for _ in range(m):
        a, b, c = map(int, input().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    
    dl = [[float("inf") for _ in range(n)] for _ in range(n)]
    for i in range(n):
        d[i][i] = 0

    for i in range(n):
        for j in range(i+1, n):
            if i != j and d[i][j] <= l:
                dl[i][j] = 1
                dl[j][i] = 1
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dl[i][j] > dl[i][k] + dl[k][j]:
                    dl[i][j] = dl[i][k] + dl[k][j]
    
    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        if dl[s-1][t-1] == float("inf"):
            print(-1)
        else:
            print(dl[s-1][t-1] - 1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, m, l = map(int, input().split())
    d = [[float("inf") for _ in range(n)] for _ in range(n)]
    for i in range(n):
        d[i][i] = 0
    
    for _ in range(m):
        a, b, c = map(int, input().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    
    dl = [[float("inf") for _ in range(n)] for _ in range(n)]
    for i in range(n):
        d[i][i] = 0

    for i in range(n):
        for j in range(i+1, n):
            if i != j and d[i][j] <= l:
                dl[i][j] = 1
                dl[j][i] = 1
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dl[i][j] > dl[i][k] + dl[k][j]:
                    dl[i][j] = dl[i][k] + dl[k][j]
    
    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        if dl[s-1][t-1] == float("inf"):
            print(-1)
        else:
            print(dl[s-1][t-1] - 1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def Zalgorithm(s):
    z = [0 for _ in range(len(s))]
    z[0] = len(s)
    i, j = 1, 0
    while i < len(s):
        while i+j < len(s) and s[j] == s[i+j]:
            j += 1
        z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < len(s) and k+z[k] < j:
            z[i+k] = z[k]
            k += 1
        i += k
        j -= k
    return z

n = int(input())
s = input().strip()
ans = 0
for i in range(len(s)):
    zarr = Zalgorithm(s[i:])
    for j in range(len(zarr)):
        ans = max(ans, min(j, zarr[j]))
print(ans)


Fixed submission:
def Zalgorithm(s):
    z = [0 for _ in range(len(s))]
    z[0] = len(s)
    i, j = 1, 0
    while i < len(s):
        while i+j < len(s) and s[j] == s[i+j]:
            j += 1
        z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < len(s) and k+z[k] < j:
            z[i+k] = z[k]
            k += 1
        i += k
        j -= k
    return z

n = int(input())
s = input().strip()
ans = 0
for i in range(len(s)):
    zarr = Zalgorithm(s[i:])
    for j in range(len(zarr)):
        ans = max(ans, min(j, zarr[j]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

edges = defaultdict(lambda: [])
used = [False for _ in range(1001000)]
d = [1 for _ in range(1001000)]


def dfs(i):
    if used[i]:
        return d[i]
    else:
        used[i] = True
        ret = 0
        for v in edges[i]:
            tmp = dfs(v)
            if ret < tmp+1:
                ret = tmp+1
        d[i] = ret
        return ret


def main():
    n = int(input())
    h = [0 for _ in range(1001000)]
    for i in range(n):
        a = list(map(int, input().split()))
        for j in range(1, n-1):
            pa = a[j-1]-1
            na = a[j]-1
            pi = i
            ni = i
            if na > ni:
                na, ni = ni, na
            if pa > pi:
                pa, pi = pi, pa
            edges[1000*pi + pa].append(1000*ni + na)
            h[1000*ni + na] += 1
    
    stack = []
    for k, _ in edges.items():
        if h[k] == 0:
            stack.append(k)
    
    ans = 0
    while len(stack):
        u = stack.pop()
        for v in edges[u]:
            h[v] -= 1
            if h[v] == 0:
                stack.append(v)
        ans += 1

    if ans != n*(n-1)//2:
        print(-1)
    else:
        ret = 0
        for k, _ in edges.items():
            tmp = dfs(k)
            if tmp > ret:
                ret = tmp
        print(ret+1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

edges = defaultdict(lambda: [])
used = [False for _ in range(1001000)]
d = [1 for _ in range(1001000)]


def dfs(i):
    if used[i]:
        return d[i]
    else:
        used[i] = True
        ret = 0
        for v in edges[i]:
            tmp = dfs(v)
            if ret < tmp+1:
                ret = tmp+1
        d[i] = ret
        return ret


def main():
    n = int(input())
    h = [0 for _ in range(1001000)]
    for i in range(n):
        a = list(map(int, input().split()))
        for j in range(1, n-1):
            pa = a[j-1]-1
            na = a[j]-1
            pi = i
            ni = i
            if na > ni:
                na, ni = ni, na
            if pa > pi:
                pa, pi = pi, pa
            edges[1000*pi + pa].append(1000*ni + na)
            h[1000*ni + na] += 1
    
    stack = []
    for k, _ in edges.items():
        if h[k] == 0:
            stack.append(k)
    
    ans = 0
    while len(stack):
        u = stack.pop()
        for v in edges[u]:
            h[v] -= 1
            if h[v] == 0:
                stack.append(v)
        ans += 1

    if ans != n*(n-1)//2:
        print(-1)
    else:
        ret = 0
        for k, _ in edges.items():
            tmp = dfs(k)
            if tmp > ret:
                ret = tmp
        print(ret+1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(pow(10, 6))
input = sys.stdin.readline

def dfs(i, d):
  visited[i] = True
  ans[i] = d + pp[i]
  for j in edges[i]:
    if not visited[j]:
      dfs(j, d + pp[i])

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
visited = [False for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)
pp = [0 for _ in range(n)]
for _ in range(q):
  p, x = map(int, input().split())
  pp[p-1] += x
dfs(0, 0)
print(*ans)


Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 6))
input = sys.stdin.readline

def dfs(i, d):
  visited[i] = True
  ans[i] = d + pp[i]
  for j in edges[i]:
    if not visited[j]:
      dfs(j, d + pp[i])

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
visited = [False for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)
pp = [0 for _ in range(n)]
for _ in range(q):
  p, x = map(int, input().split())
  pp[p-1] += x
dfs(0, 0)
print(*ans)

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

def dfs(i, d):
  visited[i] = True
  ans[i] = d + pp[i]
  for j in edges[i]:
    if not visited[j]:
      dfs(j, d + pp[i])

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
visited = [False for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)
pp = [0 for _ in range(n)]
for _ in range(q):
  p, x = map(int, input().split())
  pp[p-1] += x
dfs(0, 0)
print(*ans)


Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 6))
input = sys.stdin.readline

def dfs(i, d):
  visited[i] = True
  ans[i] = d + pp[i]
  for j in edges[i]:
    if not visited[j]:
      dfs(j, d + pp[i])

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
visited = [False for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)
pp = [0 for _ in range(n)]
for _ in range(q):
  p, x = map(int, input().split())
  pp[p-1] += x
dfs(0, 0)
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from heapq import heappop, heappush

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    hq = []
    for i, _b in enumerate(b):
        heappush(hq, (-_b, i))

    ans = 0
    while len(hq) != 0:
        q = heappop(hq)
        if -q[0] == a[q[1]]:
            # 同じなら何もする必要はない
            continue
        elif -q[0] < a[q[1]]:
            # 増やすことは出来ないので、小さいなら構築不可
            ans = -1
            break

        ac = b[(q[1] - 1) % n] + b[(q[1] + 1) % n]
        if (b[q[1]] - a[q[1]]) // ac == 0:
            # 一致しておらず、さらに減らせないので構築不可
            ans = -1
            break
        else:
            # できる限り減らす
            tmp = (b[q[1]] - a[q[1]]) // ac
            b[q[1]] -= ac * tmp
            ans += tmp
            heappush(hq, (-b[q[1]], q[1]))
    
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from heapq import heappop, heappush

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    hq = []
    for i, _b in enumerate(b):
        heappush(hq, (-_b, i))

    ans = 0
    while len(hq) != 0:
        q = heappop(hq)
        if -q[0] == a[q[1]]:
            # 同じなら何もする必要はない
            continue
        elif -q[0] < a[q[1]]:
            # 増やすことは出来ないので、小さいなら構築不可
            ans = -1
            break

        ac = b[(q[1] - 1) % n] + b[(q[1] + 1) % n]
        if (b[q[1]] - a[q[1]]) // ac == 0:
            # 一致しておらず、さらに減らせないので構築不可
            ans = -1
            break
        else:
            # できる限り減らす
            tmp = (b[q[1]] - a[q[1]]) // ac
            b[q[1]] -= ac * tmp
            ans += tmp
            heappush(hq, (-b[q[1]], q[1]))
    
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
# input = sys.stdin.readline

def main():
  s = int(input())
  x1, y1, y2 = 0, 0, 0
  i = 1
  while i*i<=pow(10, 9):
    if s % (i-x1) == 0:
      if s // (i-x1) <= pow(10, 9):
        print("%d %d %d %d %d %d" % (x1, y1, i, y2, i-1, s//(i-x1)))
        sys.exit(0)


if __name__ == '__main__':
  main()


Fixed submission:
def main():
  s = int(input())
  ppp = pow(10, 9)
  x = (ppp-s%ppp)%ppp
  y = (s+x) // ppp
  print("%d %d %d %d %d %d" % (0, 0, ppp, 1, x, y))


if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    na = [-1 for _ in range(2*n)]
    nk = n * k

    prevai = {}
    for i, _a in enumerate(a+a):
        if _a in prevai:
            na[prevai[_a]] = (i-prevai[_a])%n + 1
            if na[prevai[_a]] == 1:
                na[prevai[_a]] = n+1
        prevai[_a] = i

    doubling = [[0 for _ in range(n)] for _ in range(61)]
    for i in range(n):
        doubling[0][i] = na[i]
    for i in range(1, 61):
        for j in range(n):
            doubling[i][j] = doubling[i-1][j] + doubling[i-1][(j+doubling[i-1][j])%n]

    tmp = 0
    for i in range(60, -1, -1):
        if nk - tmp >= doubling[i][tmp%n]:
            tmp += doubling[i][tmp%n]

    if tmp == nk:
        return
    
    ans  = []
    adict = {}
    for i in range(tmp%n, n):
        if a[i] in adict and adict[a[i]] > 0:
            while True:
                _a = ans.pop()
                adict[_a] = 0
                if _a == a[i]:
                    break
        else:
            ans.append(a[i])
            adict[a[i]] = 1
    print(*ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    na = [-1 for _ in range(2*n)]
    nk = n * k

    prevai = {}
    for i, _a in enumerate(a+a):
        if _a in prevai:
            na[prevai[_a]] = (i-prevai[_a])%n + 1
            if na[prevai[_a]] == 1:
                na[prevai[_a]] = n+1
        prevai[_a] = i

    doubling = [[0 for _ in range(n)] for _ in range(61)]
    for i in range(n):
        doubling[0][i] = na[i]
    for i in range(1, 61):
        for j in range(n):
            doubling[i][j] = min(doubling[i-1][j] + doubling[i-1][(j+doubling[i-1][j])%n], nk+5)

    tmp = 0
    for i in range(60, -1, -1):
        if nk - tmp >= doubling[i][tmp%n]:
            tmp += doubling[i][tmp%n]

    if tmp == nk:
        return
    
    ans  = []
    adict = {}
    for i in range(tmp%n, n):
        if a[i] in adict and adict[a[i]] > 0:
            while True:
                _a = ans.pop()
                adict[_a] = 0
                if _a == a[i]:
                    break
        else:
            ans.append(a[i])
            adict[a[i]] = 1
    print(*ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
  n = int(input())
  alist = list(sorted(map(int, input().split())))
  if n % 3 != 0:
    print('No')
  else:
    aset = set(alist)
    tmpal = list(aset)
    if tmpal[0] ^ tmpal[2] == tmpal[1]:
      print('Yes')
    else:
      print('No')


if __name__ == '__main__':
  main()


Fixed submission:
def main():
  n = int(input())
  alist = list(sorted(map(int, input().split())))
  aset = set(alist)
  tmpal = list(aset)
  if len(aset) > 3:
    print('No')
  elif len(aset) == 1:
    if tmpal[0] == 0:
      print('Yes')
    else:
      print('No')
  elif n % 3 != 0:
    print('No')
  else:
    if len(aset) == 2:
      if alist.count(0) == n // 3:
        print('Yes')
      else:
        print('No')
    else:
      if tmpal[0] ^ tmpal[2] == tmpal[1]:
        nd = {tmpal[0]: 0, tmpal[1]: 0, tmpal[2]: 0}
        for a in alist:
          nd[a] += 1
        if nd[tmpal[0]] == nd[tmpal[1]] and nd[tmpal[1]] == nd[tmpal[2]]:
          print('Yes')
        else:
          print('No')
      else:
        print('No')


if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
llist = list(map(int, input().split()))

d = 0
ans = 1
i = 0
while d <= x:
  d += llist[i]
  i += 1
  ans += 1
print(ans - 1)

Fixed submission:
n, x = map(int, input().split())
llist = [0] + list(map(int, input().split())) + [1e9]
for i in range(1, n+2):
  llist[i] += llist[i-1]

for i in range(n+2):
  if llist[i] > x:
    break
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = pow(10, 9) + 7

n, m = map(int, input().split())
slist = list(map(int, input().split()))
tlist = list(map(int, input().split()))

dp = [[1 for _ in range(n+1)] for _ in range(m+1)]
for i, s in enumerate(slist):
  for j, t in enumerate(tlist):
    if s != t:
      dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD
    else:
      #if slist[i] == t and tlist[j] == s:
        dp[j+1][i+1] = (dp[j+1][i] + dp[j][i+1]) % MOD
      #else:
      #  dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD

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


Fixed submission:
MOD = pow(10, 9) + 7

n, m = map(int, input().split())
slist = list(map(int, input().split()))
tlist = list(map(int, input().split()))

dp = [[1 for _ in range(n+1)] for _ in range(m+1)]
for i, s in enumerate(slist):
  for j, t in enumerate(tlist):
    if s != t:
      dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD
    else:
      if slist[i] == t and tlist[j] == s:
        dp[j+1][i+1] = (dp[j+1][i] + dp[j][i+1]) % MOD
      else:
        dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD

print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
alist = set([int(input()) for _ in range(m)])

MOD = pow(10, 9) + 7

memo = [0 for _ in range(n)]
memo[0] = 0 if 1 in alist else 1
is_reach = True
if 1 in alist and 2 in alist:
  is_reach = False
  memo[0] = 0
elif 1 in alist:
  memo[1] = 1
else:
  memo[1] = 2

for i in range(2, n):
  if i+1 in alist:
    memo[i] = 0
  elif i in alist and i-1 in alist:
    memo[i] = 0
    is_reach = False
    break
  elif i in alist:
    memo[i] = memo[i-2]
  elif i-1 in alist:
    memo[i] = memo[i-1]
  else:
    memo[i] = (memo[i-1] + memo[i-2]) % MOD

if is_reach:
  print(memo[-1])
else:
  print(0)


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

MOD = pow(10, 9) + 7

if n == 1:
  if 1 in alist:
    print(0)
  else:
    print(1)
else:
  memo = [0 for _ in range(n)]
  memo[0] = 0 if 1 in alist else 1
  is_reach = True
  if 1 in alist and 2 in alist:
    is_reach = False
    memo[0] = 0
  elif 1 in alist:
    memo[1] = 1
  else:
    memo[1] = 2

  for i in range(2, n):
    if i+1 in alist:
      memo[i] = 0
    elif i in alist and i-1 in alist:
      memo[i] = 0
      is_reach = False
      break
    elif i in alist:
      memo[i] = memo[i-2]
    elif i-1 in alist:
      memo[i] = memo[i-1]
    else:
      memo[i] = (memo[i-1] + memo[i-2]) % MOD

  if is_reach:
    print(memo[-1])
  else:
    print(0)