Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def solve(string):
    from functools import reduce
    from operator import mul
    n, *a = map(int, string.split())
    a = reduce(mul, a)
    return "-1" if a > 10**18 else str(a)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    ans = 1
    for _a in a:
        ans *= _a
        if ans > 10**18:
            return "-1"
        if ans == 0:
            return "0"
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    return str(sum(i for i in range(n + 1) if i % 3 > 1 and i % 5 > 1))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
def solve(string):
    return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil


def solve(string):
    a, b = map(int, string.split())
    ans = ceil(a / 0.08)
    while ans // 10 != b:
        ans += 1
    return str(ans) if ans * 2 // 25 == a else "-1"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
from math import ceil


def solve(string):
    a, b = map(int, string.split())
    ans = ceil(a / 0.08)
    while ans // 10 < b:
        ans += 1
    return str(ans) if ans * 2 // 25 == a and ans // 10 == b else "-1"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(string):
    s, q, *qs = string.split("\n")
    for _q in qs:
        if _q == "1":
            s = s[::-1]
            continue
        _, f, c = _q.split()
        s = c + s if f == "1" else s + c
    return s


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
def solve(string):
    s, q, *qs = string.split("\n")
    pre = []
    post = []
    r = False
    for _q in qs[::-1]:
        if _q == "1":
            r = not r
            continue
        _, f, c = _q.split()
        if r and f == "2" or not r and f == "1":
            pre.append(c)
        else:
            post.append(c)
    pre, post = "".join(pre), "".join(post[::-1])
    return pre + s[::-1] + post if r else pre + s + post


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy python submission (verdict: Time Limit Exceeded):
def solve(string):
    s, q, *qs = string.split("\n")
    for _q in qs:
        if _q == "1":
            s = s[::-1]
            continue
        _, f, c = _q.split()
        s = c + s if f == "1" else s + c
    return s


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
def solve(string):
    s, q, *qs = string.split("\n")
    pre = []
    post = []
    r = False
    for _q in qs[::-1]:
        if _q == "1":
            r = not r
            continue
        _, f, c = _q.split()
        if r and f == "2" or not r and f == "1":
            pre.append(c)
        else:
            post.append(c)
    pre, post = "".join(pre), "".join(post[::-1])
    return pre + s[::-1] + post if r else pre + s + post


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:])))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
from itertools import accumulate


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:]))) if k < n else str(p[-1])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product


def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    s = ["#" + _s + "#" for _s in s]
    s = ["#" * (w + 2)] + s + ["#" * (w + 2)]
    ans = 0
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for _h, _w in product(range(1, h + 1), range(1, w + 1)):
        if s[_h][_w] == "#":
            continue
        c = [[h * w] * (w + 2) for _ in range(h + 2)]
        c[_h][_w] = 0
        q = list()
        for x, y in d:
            if s[_h + x][_w + y] == ".":
                q.append((_h + x, _w + y, _h, _w))
        while q:
            cx, cy, px, py = q.pop()
            if c[px][py] + 1 >= c[cx][cy]:
                continue
            c[cx][cy] = c[px][py] + 1
            for x, y in d:
                nx = cx + x
                ny = cy + y
                if s[nx][ny] == ".":
                    q.append((nx, ny, cx, cy))
        for i, j in product(range(1, h + 1), range(1, w + 1)):
            ans = max(ans, c[i][j] * (s[i][j] == "."))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
from itertools import product


def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    s = ["#" + _s + "#" for _s in s]
    s = ["#" * (w + 2)] + s + ["#" * (w + 2)]
    ans = 0
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for _h, _w in product(range(1, h + 1), range(1, w + 1)):
        if s[_h][_w] == "#":
            continue
        c = [[h * w] * (w + 2) for _ in range(h + 2)]
        c[_h][_w] = 0
        q = list()
        for x, y in d:
            if s[_h + x][_w + y] == ".":
                q.append((_h + x, _w + y, _h, _w))
        if len(q) > 2:
            continue
        while q:
            cx, cy, px, py = q.pop()
            if c[px][py] + 1 >= c[cx][cy]:
                continue
            c[cx][cy] = c[px][py] + 1
            for x, y in d:
                nx = cx + x
                ny = cy + y
                if s[nx][ny] == ".":
                    q.append((nx, ny, cx, cy))
        for i, j in product(range(1, h + 1), range(1, w + 1)):
            ans = max(ans, c[i][j] * (s[i][j] == "."))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (0 if _a % c or not _a // c % 2 else _a for _a in a))
    return str((m - l // 2) // l + 1) if l else "0"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Fixed submission:
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    c = 0
    for _a in a:
        if not c:
            while _a % 2 == 0:
                _a //= 2
                c += 1
        else:
            t = 0
            while _a % 2 == 0:
                _a //= 2
                t += 1
            if c != t:
                return "0"
    l = reduce(lcm, a)
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    l = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    return str(7 - l.index(string))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read()))


Fixed submission:
def solve(string):
    l = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    return str(7 - l.index(string.strip()))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read()))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, s = string.split()
    n = int(n)
    return "Yes" if s[:n // 2] == s[n // 2:] else "No"


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    n, s = string.split()
    n = int(n)
    return "Yes" if s[:n // 2] == s[n // 2:] else "No"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
from functools import reduce
from operator import mul


def solve(string):
    n, *xy = map(int, string.split())
    *xy, = zip(*[iter(xy)] * 2)
    return str(
        sum(
            sum(((xy[p0][0] - xy[p1][0])**2 + (xy[p0][1] - xy[p1][1])**2)**0.5
                for p0, p1 in zip(list(i),
                                  list(i)[1:]))
            for i in permutations(range(n), n)) / reduce(mul, range(1, n + 1)))


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
from itertools import permutations
from functools import reduce
from operator import mul


def solve(string):
    n, *xy = map(int, string.split())
    *xy, = zip(*[iter(xy)] * 2)
    return str(
        sum(
            sum(((xy[p0][0] - xy[p1][0])**2 + (xy[p0][1] - xy[p1][1])**2)**0.5
                for p0, p1 in zip(list(i),
                                  list(i)[1:]))
            for i in permutations(range(n), n)) / reduce(mul, range(1, n + 1)))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n)+'\n'.join([input() for _ in range(n)])))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd


def get_primes(n):
    ans = []
    flags = [1] * (n + 1)
    for i in range(2, n + 1):
        if flags[i]:
            ans.append(i)
            for j in range(i, n + 1, i):
                flags[j] = 0
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = []
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        while n % i == 0:
            n //= i
        ans.append(i)
        flags[i:m + 1:i] = 1
    if n > 1 and all(map(lambda x: n % x, ans)):
        ans.append(n)
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    h = []
    for _a in a:
        heappush(h, -_a)
    for _ in range(m):
        heappush(h, -(-heappop(h) // 2))
    return str(-sum(h))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()

count = 0
moves = []
for h0, h1 in zip(H,H[1:]):
    if h0 >= h1:
        count += 1
    else:
        moves.append(count)
        count = 0
print(max(moves))


Fixed submission:
def solve(string):
    n, *h = map(int, string.split())
    ans = count = 0
    for h0, h1 in zip(h, h[1:]):
        if h0 >= h1:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    return str(max(ans, count))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()

start = 0
moves = []
for i, (h0, h1) in enumerate(zip(H,H[1:]), start=1):
    moves.append(i - start)
    if H[i] < H[i+1]:
        start = i + 1
print(max(moves))


Fixed submission:
def solve(string):
    n, *h = map(int, string.split())
    ans = count = 0
    for h0, h1 in zip(h, h[1:]):
        if h0 >= h1:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    return str(max(ans, count))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()
 
start = 0
moves = []
for i in range(N-1):
    if H[i] < H[i+1]:
	    moves.append(i - start)
   	    start = i + 1
if H[N-2] >= H[N-1]:
    moves.append(i - start + 1)
print(max(moves))

Fixed submission:
def solve(string):
    n, *h = map(int, string.split())
    ans = count = 0
    for h0, h1 in zip(h, h[1:]):
        if h0 >= h1:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    return str(max(ans, count))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
N = int(input())
V = [float(v) for v in input().split()]
V.sort(revese=True)
for i in range(N):
    if len(V) == 1:
        print(V[0])
        exit()
    v1 = V.pop()
    v2 = V.pop()
    V.append((v1 + v2) / 2)


Fixed submission:
def solve(string):
    n, *v = map(int, string.split())
    v = sorted(v, reverse=True)
    return str(sum(_v / 2**i for i, _v in enumerate(v[:-1], start=1)) + v[-1] / 2**(n - 1))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *v = map(int, string.split())
    v = sorted(v, reverse=True)
    return str(sum(_v / 2**i for i, _v in enumerate(v[:-1], start=1)) + v[-1] / 2**(n - 1))


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    n, *v = map(int, string.split())
    v = sorted(v, reverse=True)
    return str(sum(_v / 2**i for i, _v in enumerate(v[:-1], start=1)) + v[-1] / 2**(n - 1))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
from collections import deque


def solve(string):
    n, q, *abpx = map(int, string.split())
    ab, px = abpx[:2 * n - 2], abpx[2 * n - 2:]
    check = [True] * (n + 1)
    t = {i: [] for i in range(n + 1)}
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(px)] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m)])))


Fixed submission:
from collections import deque


def solve(string):
    n, q, *abpx = map(int, string.split())
    ab, px = abpx[:2 * n - 2], abpx[2 * n - 2:]
    check = [True] * (n + 1)
    t = {i: [] for i in range(n + 1)}
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(px)] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m -1)])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *ss = string.split()

    d = defaultdict(int)
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] += 1 + d[s]
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Fixed submission:
from collections import defaultdict


def solve(string):
    n, *s = string.split()
    d = defaultdict(int)
    for _s in s:
        d["".join(sorted(_s))] += 1
    return str(sum([v * (v - 1) // 2 for v in d.values() if v > 1]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n)+'\n'.join([input() for _ in range(n)])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *ab = map(int, string.split())
    a, b = ab[:n + 1], ab[n + 1:]
    _sum = sum(a)
    for i, _b in enumerate(b[::-1]):
        if a[n - i] < _b:
            _b -= a[n - i]
            a[n - i] = 0
            a[n - i - 1] = max(0, a[n - i - 1] - _b)
        else:
            a[n - i] -= _b
    return str(_sum - sum(a))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Fixed submission:
def solve(string):
    n, *ab = map(int, string.split())
    a, b = ab[:n + 1], ab[n + 1:]
    _sum = sum(a)
    for i, _b in enumerate(b[::-1]):
        if a[n - i] < _b:
            _b -= a[n - i]
            a[n - i] = 0
            a[n - i - 1] = max(0, a[n - i - 1] - _b)
        else:
            a[n - i] -= _b
    return str(_sum - sum(a))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2)])))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    t = np.zeros(n)
    ans = []
    for i, _a in zip(range(n, 0, -1), a[::-1]):
        s = t[i - 1::i].sum() % 2
        if s == _a:
            continue
        ans.append(str(i))
        t[i - 1] += 1
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans[::-1]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
from math import ceil


def solve(string):
    n, *a = map(int, string.split())
    t = [0] * n
    ans = []
    for i, _a in zip(range(n, 0, -1), a[::-1]):
        if t[i - 1] % 2 == _a:
            continue
        ans.append(str(i))
        for j in range(1, ceil((i + 1)**0.5)):
            if i % j == 0:
                t[j - 1] += 1
                if j != i // j:
                    t[i // j - 1] += 1
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans[::-1]))

  
if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
import math
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for i, x0 in enumerate(X): 
    for x1 in X[i+1:]:
        if math.sqrt(sum([(a-b)**2 for a, b in zip(X0,X1)])).is_integer():
            counter+=1
print(counter)


Fixed submission:
from scipy.spatial import distance


def solve(string):
    n, d, *x = map(int, string.split())
    x = [tuple(c) for c in zip(*[iter(x)] * d)]
    dist = distance.cdist(x, x)
    return str(((dist == dist.astype("int32")).sum() - n) // 2)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m)+'\n'.join([input() for _ in range(n)])))
Buggy python submission (verdict: Runtime Error):
import numpy

def solve(string):
    n, *p = map(int, string.split())
    p = numpy.asarray(p)
    asc=(p[:-2] < p[1:-1]) & (p[1:-1] < p[2:])
    desc=(p[:-2] > p[1:-1]) & (p[1:-1] > p[2:])
    return str(sum(asc | desc))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
def solve(string):
    n, *p = map(int, string.split())
    ans = 0
    for i, j, k in zip(p, p[1:], p[2:]):
        ans += 1 if i <= j <= k or i >= j >= k else 0
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb


def solve(string):
    n, k = map(int, string.split())
    ans = []
    for i in range(1, k + 1):
        base = comb(n - k + 1, i, exact=True)
        var = comb(k - 1, i - 1, exact=True)
        ans.append(str(base * var % (10**9 + 7)))
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
from scipy.misc import comb


def solve(string):
    n, k = map(int, string.split())
    ans = []
    for i in range(1, k + 1):
        base = comb(n - k + 1, i, exact=True)
        var = comb(k - 1, i - 1, exact=True)
        ans.append(str(base * var % (10**9 + 7)))
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))
Buggy python submission (verdict: Runtime Error):
    n = int(input())

Fixed submission:
def solve(string):
    n, *ab = map(int, string.split())
    ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0]))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from itertools import accumulate
from operator import add


def solve(string):
    n, *ab = map(int, string.split())
    ab = reduce(add, sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1]))
    return "Yes" if all([a <= b for a, b, in zip(accumulate(ab[::2]), ab[1::2])]) else "No"


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Fixed submission:
def solve(string):
    n, *ab = map(int, string.split())
    ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0]))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(string):
    n, m, *a = map(int, string.split())
    ans = [0] * (n + 1)
    ans[0] = ans[1] = 1
    for i in range(2, n + 1):
        if i in a:
            continue
        if i - 2 not in a:
            ans[i] += ans[i - 2]
        if i - 1 not in a:
            ans[i] += ans[i - 1]
    return str(ans[-1] % (10**9 + 7))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Fixed submission:
def solve(string):
    n, m, *a = map(int, string.split())
    ans = [0] * (n + 1)
    for _a in a:
        ans[_a] = -1
    ans[0] = 1
    ans[1] = 1 if ans[1] == 0 else 0
    for i in range(2, n + 1):
        if ans[i] == -1:
            ans[i] = 0
            continue
        ans[i] += ans[i - 2] % 1000000007
        ans[i] += ans[i - 1] % 1000000007
    return str(ans[-1] % 1000000007)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))