Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, yen = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        zz = yen - (10000*x + 5000*y)
        if zz%1000 != 0:
            continue
        z = int(zz / 1000)
        if z < 0:
            continue
        if x + y + z == n:
            print('{} {} {}'.format(x, y, z))
            exit()
else:
    print('-1 -1 -1')


Fixed submission:
n, Y = map(int, input().split())
ntx = n * 10000
nty = n * 5000
ntz = n * 1000
ans = []
if Y > ntx or ntz > Y:
    ans = [-1, -1, -1]
elif ntx == Y:
    ans = [n, 0, 0]
elif nty == Y:
    ans = [0, n, 0]
elif ntz == Y:
    ans = [0, 0, n]
elif ntx > Y > nty:
    x = 0
    y = n
    z = 0
    for i in range(1, n+1):
        y = n - i
        x = i
        for j in range(0, i+1):
            x = j
            z = i - j
            if 10000*x + 5000*y + 1000*z == Y:
                ans = [x, y, z]
elif nty > Y > ntz:
    x = 0
    y = 0
    z = n
    for i in range(1, n+1):
        z = n - i
        x = i
        for j in range(0, i+1):
            x = j
            y = i - j
            if 10000*x + 5000*y + 1000*z == Y:
                ans = [x, y, z]
if len(ans) == 0:
    ans = [-1, -1, -1]
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Runtime Error):
n, yen = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        zz = yen - (10000*x + 5000*y)
        if zz%1000 != 0:
            continue
        z = int(zz / 1000)
        if z < 0:
            continue
        if x + y + z == n:
            print(f'{x} {y} {z}')
            exit()
else:
    print('-1 -1 -1')

Fixed submission:
n, Y = map(int, input().split())
ntx = n * 10000
nty = n * 5000
ntz = n * 1000
ans = []
if Y > ntx or ntz > Y:
    ans = [-1, -1, -1]
elif ntx == Y:
    ans = [n, 0, 0]
elif nty == Y:
    ans = [0, n, 0]
elif ntz == Y:
    ans = [0, 0, n]
elif ntx > Y > nty:
    x = 0
    y = n
    z = 0
    for i in range(1, n+1):
        y = n - i
        x = i
        for j in range(0, i+1):
            x = j
            z = i - j
            if 10000*x + 5000*y + 1000*z == Y:
                ans = [x, y, z]
elif nty > Y > ntz:
    x = 0
    y = 0
    z = n
    for i in range(1, n+1):
        z = n - i
        x = i
        for j in range(0, i+1):
            x = j
            y = i - j
            if 10000*x + 5000*y + 1000*z == Y:
                ans = [x, y, z]
if len(ans) == 0:
    ans = [-1, -1, -1]
print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    t4 = i %10
    t3 = (i %100 -t4) //10
    t2 = (i %1000 -t4 -t3*10) //100
    t1 = (i %10000 -t4 -t3*10 -t2*100) //1000
    c = t1 + t2 + t3 + t4
    if a <= c <= b: ans += i
if n = 10**4 and a = 1: ans += 1
print(ans)


Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    t4 = i %10
    t3 = (i %100 -t4) //10
    t2 = (i %1000 -t4 -t3*10) //100
    t1 = (i %10000 -t4 -t3*10 -t2*100) //1000
    t0 = (i %100000 -t4 -t3*10 -t2*100 -t1*1000) //10000
    c = t0 + t1 + t2 + t3 + t4
    if a <= c <= b: ans += i

print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
s = list(set(s))
s.sort()
print('s:', s)
ans = 'a'
cnt = 0
while True:
    if cnt == 26:
        print(None)
        break
    else:
        if s[cnt] != ans:
            print(ans)
            break
        else:
            ans = chr(ord(ans)+1)
            cnt += 1

Fixed submission:
S = input()
ans = None
for letter in "abcdefghijklmnopqrstuvwxyz":
    if letter not in S:
        ans = letter
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(input())
s = list(set(s))
s.sort()
ans = 'a'
cnt = 0
while True:
    if cnt == 26:
        print('None')
        break
    else:
        if s[cnt] != ans:
            print(ans)
            break
        else:
            ans = chr(ord(ans)+1)
            cnt += 1


Fixed submission:
S = input()
ans = None
for letter in "abcdefghijklmnopqrstuvwxyz":
    if letter not in S:
        ans = letter
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(input())
s = list(set(s))
s.sort()
ans = 'a'
cnt = 0
while True:
    if s[cnt] != ans:
        print(ans)
        break
    else:
        ans = chr(ord(ans)+1)
        cnt += 1
    if cnt == 26:
        print('None')
        break


Fixed submission:
S = input()
ans = None
for letter in "abcdefghijklmnopqrstuvwxyz":
    if letter not in S:
        ans = letter
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(2, n+1):
    ans *= i
print(ans % (10**9+7))


Fixed submission:
n = int(input())
ans = 1
for i in range(2, n+1):
    ans = ans * i % (10**9+7)
print(ans % (10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(n):
    ans = ans * (i+1)
print(ans % (10**9+7))


Fixed submission:
n = int(input())
ans = 1
for i in range(2, n+1):
    ans = ans * i % (10**9+7)
print(ans % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
idx = ['s', 'e']
for i in range(len(s)):
    if s[i] == 'A':
        idx[0] = i
        break
for i in range(len(s)):
    if s[::-1][i] == 'Z':
        idx[1] = -i
        break
if idx[1] == 0:
    print(len(s[idx[0]:]))
else:
    print(len(s[idx[0]:idx[1]]))

Fixed submission:
s = str(input())
print(s.rfind('Z') - s.find('A') + 1)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
idx = ['s', 'e']
for i in range(len(s)):
    if s[i] == 'A' and idx[0] == 's':
        idx[0] = i
        if idx[0] != 's' and idx[1] != 'e':
            break
    if s[::-1][i] == 'Z' and idx[1] == 'e':
        idx[1] = -i
        if idx[0] != 's' and idx[1] != 'e':
            break
if idx[1] == 0:
    print(len(s[idx[0]:]))
else:
    print(len(s[idx[0]:idx[1]]))


Fixed submission:
s = str(input())
print(s.rfind('Z') - s.find('A') + 1)
Buggy python submission (verdict: Runtime Error):
print(str(input().split(',',' ')))


Fixed submission:
print(input().replace(',', ' '))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
k, s = map(int, input().split())
numbers = list(product([i for i in range(k+1)], repeat=2))
ans = 0
for x, y in numbers:
    if x + y > s:
        continue
    if x + y == s:
        ans += 1
    elif x + y < s:
        for z in range(k+1):
            if x + y + z == s:
                ans += 1
                break
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
if s <= k:
    ans = (s+2)*(s+1) / 2
elif k < s <= 2*k:
    for i in range(k+1):
        j = s-k+i
        if j <= k:
            ans += j+1
        else:
            ans += j+1-2*(j-k)
elif 2*k < s < 3*k:
    ans = 3
else:
    ans =  1
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7


def main():
    ans = 0
    p = []
    for i in range(n):
        for j in range(i + 1, n):
            ans += (a[i] * a[j])% mod
            ans %= mod
            p.append((i, j))
    return ans


n, *a = map(int, read().split())
a = main()
print(a)


Fixed submission:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7


def main():
    ans = 0
    cs = np.cumsum(np.array(a))
    for i in range(n-1):
        s = (cs[-1] - cs[i]) % mod
        ans = (ans+(a[i]*int(s)) % mod) % mod
    return ans


n, *a = map(int, read().split())
a = main()
print(a)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = readline().decode().rstrip()

w = s.count('W')
r = s.count('R')
i_r = s.index('R')
r2 = s[:r:].count('R')
# print(w, r, i_r)
print(r-r2)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = readline().decode().rstrip()

w = s.count('W')
r = s.count('R')
if r == 0 or w == 0:
    print(0)
    exit()
i_r = s.index('R')
r2 = s[:r:].count('R')
print(r-r2)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def popcnt(n):
    return bin(n).count("1")


def mod(n, cnt):
    if n == 0:
        return cnt
    n = n % popcnt(n)
    cnt += 1
    return mod(n, cnt)


n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c - 1 != 0 else 0

for i in range(n):
    if x2[i] == '0':
        t = (mod1 + pow(2, n - i - 1, c + 1)) % (c + 1)
    else:
        if c - 1 != 0:
            t = (mod2 - pow(2, n - i - 1, c - 1)) % (c - 1)
        else:
            print(0)
            continue
    print(mod(t, 1))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

l, r, d = map(int, readline().split())

if l % d == 0:
    ans = r // d - l // d + 1
else:
    ans = r // d - l // d
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def popcnt(n):
    return bin(n).count("1")


def mod(n, cnt):
    if n == 0:
        return cnt
    n = n % popcnt(n)
    cnt += 1
    return mod(n, cnt)


n = int(readline())
x = list(readline().decode().rstrip())

for i in range(n):
    b = x
    # print(b)
    if b[i] == "0":
        b[i] = "1"
    elif b[i] == "1":
        b[i] = "0"
    # print(''.join(b))
    # print(popcnt(''.join(b)))
    num = int(''.join(b), 2)
    # print(''.join(b), num)
    t = mod(num, 0)
    print(t)
    if b[i] == "0":
        b[i] = "1"
    elif b[i] == "1":
        b[i] = "0"


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def popcnt(n):
    return bin(n).count("1")


def mod(n, cnt):
    if n == 0:
        return cnt
    n = n % popcnt(n)
    cnt += 1
    return mod(n, cnt)


n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c - 1 != 0 else 0

for i in range(n):
    if x2[i] == '0':
        t = (mod1 + pow(2, n - i - 1, c + 1)) % (c + 1)
    else:
        if c - 1 != 0:
            t = (mod2 - pow(2, n - i - 1, c - 1)) % (c - 1)
        else:
            print(0)
            continue
    print(mod(t, 1))
Buggy python submission (verdict: Runtime Error):
n, *a = map(int, read().split())
if 0 in a:
    print('0')
    exit()
ans = 1
for x in a:
    ans = ans * x
    if ans > 10 ** 18:
        print('-1')
        exit()
print(ans)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
if 0 in a:
    print('0')
    exit()
ans = 1
for x in a:
    ans = ans * x
    if ans > 10 ** 18:
        print('-1')
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

ans = 1
for x in a:
    ans = ans * x

print(ans if ans <= 10 ** 18 else '-1')


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
if 0 in a:
    print('0')
    exit()
ans = 1
for x in a:
    ans = ans * x
    if ans > 10 ** 18:
        print('-1')
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
    cart = [0] * (m + 1)
    for i, a in enumerate(l):
        if a == 1:
        array = c[i]
        cart = list(map(lambda x,y: x+y, cart, array))
    if min(cart[1::]) >= x:
        ans = min(ans, cart[0])
print(ans if ans != 10 ** 9 + 7 else '-1')

Fixed submission:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = float('inf')
# bit全探索
for i in range(2 ** n):
    bag = np.empty(m+1)
    total = 0
    for j in range(n):
        if ((i >> j) & 1):
            bag += np.array(c[j])
        if np.amin(bag[1::]) >= x:
            ans = min(ans, bag[0])
            
print('-1'if ans == float('inf') else int(ans))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, readline().split())
h = list(map(int, readline().split()))

l = [1]*n
for i in range(m):
    a, b= map(int, readline().split())
    if h[a - 1] < h[b - 1]:
        l[a - 1] = 0
    elif h[a - 1] > h[b - 1]:
        l[b - 1] = 0
    else:
        l[a - 1] = 0
        l[b - 1] = 0
print(sum(l))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n, m = map(int, readline().split())
h = list(map(int, readline().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
l = [1]*n
for i in range(m):
    if h[ab[i][0] - 1] < h[ab[i][1] - 1]:
        l[ab[i][0] - 1] = 0
    elif h[ab[i][0] - 1] > h[ab[i][1] - 1]:
        l[ab[i][1] - 1] = 0
    else:
        l[ab[i][0] - 1] = 0
        l[ab[i][1] - 1] = 0
print(sum(l))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [list(map(int, input().split())) for _ in range(m)]

# 隣接リスト
graph = [[] for _ in range(n)]
for v in p:
    graph[v[0]-1].append(v[1])
    graph[v[1] - 1].append(v[0])

cnt = 0
for x in graph:
    point = 'good'
    for y in x:
        if h[graph.index(x)] <= h[y-1]:
            point = 'bad'
    if point == 'good':
        cnt += 1
print(cnt)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n, m = map(int, readline().split())
h = list(map(int, readline().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
l = [1]*n
for i in range(m):
    if h[ab[i][0] - 1] < h[ab[i][1] - 1]:
        l[ab[i][0] - 1] = 0
    elif h[ab[i][0] - 1] > h[ab[i][1] - 1]:
        l[ab[i][1] - 1] = 0
    else:
        l[ab[i][0] - 1] = 0
        l[ab[i][1] - 1] = 0
print(sum(l))
Buggy python submission (verdict: Runtime Error):
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k = int(read())
ans = 0
for a in range(1, n+1):
    for b in range(1, n + 1):
        n = math.gcd(a, b)
        for c in range(1, n+1):
            ans += math.gcd(n, c)
print(ans)

Fixed submission:
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k = int(read())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        n = math.gcd(a, b)
        for c in range(1, k + 1):
            ans += math.gcd(n, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(read())
ans = 0
for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)

Fixed submission:
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k = int(read())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        n = math.gcd(a, b)
        for c in range(1, k + 1):
            ans += math.gcd(n, c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int, input().split())

def cf(x1,x2):
    cf=[1]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            d = make_divisors(i)
            d.pop()
            leng = len(set(d)-set(cf[1:]))
            if len(d) == leng:
                cf.append(i)
    return cf

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

c = cf(A, B)
ans =len(c)
print(ans)


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

def gcd(a, b):  # a,bの最大公約数
    while b:
        a, b = b, a % b
    return a

def prime_factor(n):  # nを素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

g = gcd(A, B)
f = prime_factor(g)

ans = len(f)
if f[0][0] != 1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int, input().split())

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

c = cf(A, B)
ch = c[1:]
t =[1]
for i in ch:
    d = make_divisors(i)
    d.pop()
    d.pop(0)
    leng = len(set(d)-set(ch))
    if len(d) == leng:
        t.append(i)
ans=len(t)
print(ans)

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

def gcd(a, b):  # a,bの最大公約数
    while b:
        a, b = b, a % b
    return a

def prime_factor(n):  # nを素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

g = gcd(A, B)
f = prime_factor(g)

ans = len(f)
if f[0][0] != 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
for j in range(1,n+1):
  print('Yes' if (k + a.count(j) - q)>0 else 'No')


Fixed submission:
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
for j in range(1,n+1):
  print('Yes' if (k + a.count(j) - q)>0 else 'No')

Fixed submission:
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k for i in range(n)]
for i in  range(q):
  ip = [i-1 for i in ip]
  ip[a[i]-1] += 1
for j in range(n):
  print('Yes' if ip[j] > 0 else 'No')

Fixed submission:
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k for i in range(n)]
for i in  range(q):
  ip = [i-1 for i in ip]
  ip[a[i]-1] += 1
for j in range(n):
  print('Yes' if ip[j] > 0 else 'No')

Fixed submission:
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

n, m = map(int, readline().split())
a = list(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[n])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

n, m = map(int, readline().split())
a = set(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
a = list(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = dp[i - 1] + dp[i - 2]
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[-1]%(10**9+7))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

n, m = map(int, readline().split())
a = set(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n, m = map(int, readline().split())
a = list(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
for i in range(2, n + 1):
    if i not in a:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[-1]%(10**9+7))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

n, m = map(int, readline().split())
a = set(map(int, read().split()))

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[n])