Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = set(a)
s = sum(a)
l = [0]*(10**5)
p = []
for i in d:
    l[i-1] = a.count(i)
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    s = s + l[b-1]*(c-b)
    l[c-1] += l[b-1]
    l[b-1] = 0
    p.append(s)
for i in p:
    print(i)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

counter = Counter(a)
sum_res = sum(a)  # はじめの合計、名前がsumだとsum関数とかぶってよくないので

# q回操作します。ループ変数は使わないので_とします（Pythonの慣習）
for _ in range(q):
    before, after = map(int, input().split())

    # 合計を変更します
    sum_res -= before * counter[before]
    sum_res += after * counter[before]

    # 個数を変更します
    counter[after] += counter[before]
    counter[before] = 0

    print(sum_res)

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

m = 10**5
d = set(a)
s = sum(a)
l = [0]*m
for i in d:
    l[i-1] = a.count(i)
for b, c in bc:
    s = s + l[b-1]*(c-b)
    l[c-1] += l[b-1]
    l[b-1] = 0
    print(s)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

counter = Counter(a)
sum_res = sum(a)  # はじめの合計、名前がsumだとsum関数とかぶってよくないので

# q回操作します。ループ変数は使わないので_とします（Pythonの慣習）
for _ in range(q):
    before, after = map(int, input().split())

    # 合計を変更します
    sum_res -= before * counter[before]
    sum_res += after * counter[before]

    # 個数を変更します
    counter[after] += counter[before]
    counter[before] = 0

    print(sum_res)

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

m = 10**5
d = set(a)
s = sum(a)
l = [0]*m
for i in d:
    l[i-1] = a.count(i)
for b, c in bc:
    s = s + l[b-1]*(c-b)
    l[c-1] += l[b-1]
    l[b-1] = 0
    print(s)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

counter = Counter(a)
sum_res = sum(a)  # はじめの合計、名前がsumだとsum関数とかぶってよくないので

# q回操作します。ループ変数は使わないので_とします（Pythonの慣習）
for _ in range(q):
    before, after = map(int, input().split())

    # 合計を変更します
    sum_res -= before * counter[before]
    sum_res += after * counter[before]

    # 個数を変更します
    counter[after] += counter[before]
    counter[before] = 0

    print(sum_res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

B = Counter(A)
Key = list(B.keys())
Key.sort()

M = 10 ** 6
table = [1] * (M + 1)
cnt = 0
for k in Key:
    if B[k] == 1 and table[k] == 1:
        cnt += 1
    
    for i in range(M):
        if k * i > M:
            break
        else:
            table[k * i] = 0
print(cnt)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

B = Counter(A)
Key = list(B.keys())
Key.sort()

M = 10 ** 6
table = [1] * (M + 1)
cnt = 0
for k in Key:
    if B[k] == 1 and table[k] == 1:
        cnt += 1
    
    for i in range(M):
        if k * i > M:
            break
        else:
            table[k * i] = 0
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(set(list(map(int, input().split()))))

la = len(a)
if la == 1:
    print(0)
    exit()
l = [True] * la
for i in range(1, n):
    for j in range(i):
        if a[i] % a[j] == 0:
            l[i] = False
            break
print(l.count(True))

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

B = Counter(A)
Key = list(B.keys())
Key.sort()

M = 10 ** 6
table = [1] * (M + 1)
cnt = 0
for k in Key:
    if B[k] == 1 and table[k] == 1:
        cnt += 1
    
    for i in range(M):
        if k * i > M:
            break
        else:
            table[k * i] = 0
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

p = 0
b = []
while p not in b:
    b.append(p)
    p = a[p]
avant = b.index(p)
loop_count = len(b) - avant
c = b[avant:]

if k <= avant:
    print(b[k]+1)
else:
    k -= avant
    k %= loop_count
    print(c[k]+1)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

d = [1]*n
p = 0
b = []
while d[p]:
    b.append(p)
    d[p] = 0
    p = a[p]
avant = b.index(p)
loop_count = len(b) - avant
c = b[avant:]

if k <= avant:
    print(b[k]+1)
else:
    k -= avant
    k %= loop_count
    print(c[k]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

p = 0
b = []
while p not in b:
    b.append(p)
    p = a[p]
loop_start = p
avant = b.index(p)
loop_count = len(b) - avant

if k <= avant:
    x = 0
else:
    k -= avant
    k %= loop_count
    x = loop_start

for _ in range(k):
    x = a[x]
print(x+1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

d = [1]*n
p = 0
b = []
while d[p]:
    b.append(p)
    d[p] = 0
    p = a[p]
avant = b.index(p)
loop_count = len(b) - avant
c = b[avant:]

if k <= avant:
    print(b[k]+1)
else:
    k -= avant
    k %= loop_count
    print(c[k]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

p = 0
b = []
while p not in b:
    b.append(p)
    p = a[p]
loop_start = p
avant = b.index(p)
loop_count = len(b) - avant

if k <= avant:
    x = 0
else:
    k -= avant
    k %= loop_count
    x = loop_start

for _ in range(k):
    x = a[x]
print(x+1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [i-1 for i in a]

d = [1]*n
p = 0
b = []
while d[p]:
    b.append(p)
    d[p] = 0
    p = a[p]
avant = b.index(p)
loop_count = len(b) - avant
c = b[avant:]

if k <= avant:
    print(b[k]+1)
else:
    k -= avant
    k %= loop_count
    print(c[k]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
x = int(input())

a = math.floor(x**(1/5))
while True:
    b = (x-a**5)**(1/5)
    if b % 1 == 0:
        print(a, -int(b))
        break
    a -= 1

Fixed submission:
x = int(input())

for i in range(-200, 200):
    k = i**5
    for j in range(-200, 200):
        if k - j**5 == x:
            print(i, j)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s = input()

ls = len(s)
t = [0]
for i in range(1, ls+1):
    t.append((int(s[ls-i:ls:])) % 2019)
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Fixed submission:
from collections import Counter
s = input()

ls = len(s)
t = [0]
j = 1
for i in range(ls):
    u = (int(s[ls-1-i])*j + t[-1]) % 2019
    t.append(u)
    j = (j * 10) % 2019
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s = input()

ls = len(s)
t = [0]
for i in range(1, ls+1):
    t.append((int(s[ls-i:ls:])) % 2019)
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Fixed submission:
from collections import Counter
s = input()

ls = len(s)
t = [0]
j = 1
for i in range(ls):
    u = (int(s[ls-1-i])*j + t[-1]) % 2019
    t.append(u)
    j = (j * 10) % 2019
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

ans = 0
for i in range(len(s), 3, -1):
    for j in range(len(s)-i+1):
        if int(s[j:j+i])%2019 == 0:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
s = input()

ls = len(s)
t = [0]
j = 1
for i in range(ls):
    u = (int(s[ls-1-i])*j + t[-1]) % 2019
    t.append(u)
    j = (j * 10) % 2019
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

ans = 0
for i in range(len(s), 3, -1):
    for j in range(len(s)-i+1):
        if int(s[j:j+i])%2019 == 0:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
s = input()

ls = len(s)
t = [0]
j = 1
for i in range(ls):
    u = (int(s[ls-1-i])*j + t[-1]) % 2019
    t.append(u)
    j = (j * 10) % 2019
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = input()

c = Counter(list(s))
ans = 1
for i in list(c.values):
    ans *= i
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j-i)
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Fixed submission:
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                ans -= 1
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

c = set(['R', 'G', 'B'])
ans = 0
for i in range(n-2):
    d = set(s[i])
    for j in range(i+1, n-1):
        if s[i] != s[j]:
            e = d.copy()
            e.add(s[j])
            p = c-e
            for k in p:
                ans += s[j+1:].count(k)
                if j+j-i < n:
                    if s[j+j-i] == k:
                        ans -= 1
print(ans)

Fixed submission:
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                ans -= 1
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for i in range(n-2):
    for j in range(i, n-1):
        if s[i] != s[j]:
            ji = j - i
            for k in range(j, n):
                if s[i] != s[k] and s[j] != s[k]:
                    if ji != k - j:
                        ans += 1
print(ans)

Fixed submission:
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                ans -= 1
        else:
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        s = s[::-1]
    else:
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]
print(s)

Fixed submission:
from collections import deque
s = list(input())
q = int(input())

d = deque()
for i in s:
    d.append(i)

c = 1
for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        c *= -1
    else:
        if t[1] == '1':
            if c == 1:
                d.appendleft(t[2])
            else:
                d.append(t[2])
        else:
            if c == 1:
                d.append(t[2])
            else:
                d.appendleft(t[2])

print(''.join(list(d)[::c]))
Buggy python submission (verdict: Runtime Error):
import functools
import operator

n, a, b = map(int, input().split())

def nCr(n, r):
    r = min(r, n-r)
    num = functools.reduce(lambda x, y: x*y%mod, range(n, n-r, -1))
    den = functools.reduce(lambda x, y: x*y%mod, map(lambda x: pow(x, mod-2, mod), range(1, r+1)))
    return num * den % mod

mod = 10**9 + 7
print((pow(2, n, mod) - nCr(n, a) - nCr(n, b) - 1) % mod)


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

mod = 10**9 + 7

def nck(k):
    y, z = 1, 1
    for i in range(1, k+1):
        y = (y * (n+1-i)) % mod
        z = (z * pow(i, mod-2, mod)) % mod
    return (y*z) % mod

ans = (pow(2, n, mod) - 1 - nck(a) - nck(b)) % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

a = [1+(i-1)/2 for i in p]
ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(a[i:i+k]))
print(ans)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

a = [1+(i-1)/2 for i in p]
l = sum(a[:k])
ans = l
for i in range(1, n-k+1):
    l = l-a[i-1]+a[k+i-1]
    ans = max(ans, l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    readline = sys.stdin.buffer.readline

    n, d, a = map(int, readline().split())
    xh = sorted([list(map(int, readline().split())) for _ in range(n)])

    l = [0]*(n+1)
    ans = 0
    for i in range(n):
        if xh[i][1] <= 0:
            continue 
        c = -(-xh[i][1]//a)
        ans += c
        for j in range(i+1, n):
            if xh[j][0] <= xh[i][0] + d*2:
                xh[j][1] -= c*a
            else:
                break
    print(ans)

main()

Fixed submission:
from collections import deque

n, d, a = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])

ans = 0
dam_sum = 0
q = deque()
for i, (x, h) in enumerate(xh):
    while q and q[0][0] < x:
        ran, dam = q.popleft()
        dam_sum -= dam
    h -= dam_sum
    if h <= 0:
        continue 
    c = -(-h//a)
    ans += c
    dam_sum += c*a
    q.append((x+d*2, c*a))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, d, a = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])

l = [0]*(n+1)
ans = 0
for i in range(n):
    if xh[i][1] <= 0:
        continue 
    c = -(-xh[i][1]//a)
    ans += c
    for j in range(i+1, n):
        if xh[j][0] <= xh[i][0] + d*2:
            xh[j][1] -= c*a
        else:
            break
print(ans)

Fixed submission:
from collections import deque

n, d, a = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])

ans = 0
dam_sum = 0
q = deque()
for i, (x, h) in enumerate(xh):
    while q and q[0][0] < x:
        ran, dam = q.popleft()
        dam_sum -= dam
    h -= dam_sum
    if h <= 0:
        continue 
    c = -(-h//a)
    ans += c
    dam_sum += c*a
    q.append((x+d*2, c*a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
    one = 0
    for j in range(n):
        if (a[j] >> i) & 1:
            one += 1
    ans = (ans + (one*(n-one))*two) % mod
    two = (two * 2) % mod
print(ans)

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

mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
    one = 0
    for j in range(n):
        if (a[j] >> i) & 1:
            one += 1
    ans = (ans + (one*(n-one))*two) % mod
    two = (two * 2) % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

c = [[] for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    c[a].append(b)
    c[b].append(a)

point = [0] * n
for p, x in px:
    point[p-1] += x

tree = [-1] * n
q = collections.deque()
q.append(0)
while q:
    v = q.pop()
    for i in c[v]:
        if i == tree[v]:
            continue
        tree[i] = v
        q.append(i)

p = set([p-1 for p, x in px])
ans = [0] * n
for i in p:
    q.append(i)
    while q:
        v = q.pop()
        ans[v] += point[i]
        for j in c[v]:
            if j == tree[v]:
                continue
            q.append(j)
print(' '.join(list(map(str, ans))))

Fixed submission:
import collections

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

c = [[] for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    c[a].append(b)
    c[b].append(a)

point = [0] * n
for p, x in px:
    point[p-1] += x

parents = [0] * n
ans = [0] * n
q = collections.deque()
q.append(0)
while q:
    v = q.pop()
    ans[v] = ans[parents[v]] + point[v]
    for i in c[v]:
        if i == parents[v]:
            continue
        parents[i] = v
        q.append(i)
print(' '.join(list(map(str, ans))))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

c = [[] for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    c[a].append(b)
    c[b].append(a)

point = [0] * n
for p, x in px:
    point[p-1] += x

tree = [-1] * n
q = collections.deque()
q.append(0)
while q:
    v = q.pop()
    for i in c[v]:
        if i == tree[v]:
            continue
        tree[i] = v
        q.append(i)

p = set([p-1 for p, x in px])
ans = [0] * n
for i in p:
    q.append(i)
    while q:
        v = q.pop()
        ans[v] += point[i]
        for j in c[v]:
            if j == tree[v]:
                continue
            q.append(j)
print(' '.join(list(map(str, ans))))

Fixed submission:
import collections

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

c = [[] for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    c[a].append(b)
    c[b].append(a)

point = [0] * n
for p, x in px:
    point[p-1] += x

parents = [0] * n
ans = [0] * n
q = collections.deque()
q.append(0)
while q:
    v = q.pop()
    ans[v] = ans[parents[v]] + point[v]
    for i in c[v]:
        if i == parents[v]:
            continue
        parents[i] = v
        q.append(i)
print(' '.join(list(map(str, ans))))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

mod = 10**9 + 7
l = len(s)
dp = [[0] * 13 for _ in range(l+1)]
dp[0][0] = 1
for i in range(1, l+1):
    if s[i-1] == '?':
        for j in range(10):
            for k in range(13): 
                dp[i][(k * 10 + j) % 13] = (dp[i][(k * 10 + j) % 13] + dp[i-1][k]) % mod
    else:
        for k in range(13):
            dp[i][(k * 10 + int(s[i-1])) % 13] = (dp[i][(k * 10 + int(s[i-1])) % 13] + dp[i-1][k]) % mod
print(dp[l][5])

Fixed submission:
s = input()

mod = 10**9 + 7
l = len(s)
dp = [[0] * 13 for _ in range(l+1)]
dp[0][0] = 1
for i in range(1, l+1):
    if s[i-1] == '?':
        for j in range(10):
            for k in range(13): 
                dp[i][(k * 10 + j) % 13] = (dp[i][(k * 10 + j) % 13] + dp[i-1][k]) % mod
    else:
        for k in range(13):
            dp[i][(k * 10 + int(s[i-1])) % 13] = (dp[i][(k * 10 + int(s[i-1])) % 13] + dp[i-1][k]) % mod
print(dp[l][5])
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

def nCr(n, r):
    if n < r:
        return 0
    r = min(r, n-r)
    if r == 0:
        return 1
    num = functools.reduce(lambda x, y: x*y%mod, range(n, n-r, -1))
    den = functools.reduce(lambda x, y: x*y%mod, map(lambda x: pow(x, mod-2, mod), range(1, r+1)))
    return num * den % mod

n, k = map(int, input().split())

mod = 10**9 + 7
for i in range(1, k+1):
    print(nCr(k-1, i-1) * nCr(n-k+1, i) % mod)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n, r):
	if n < r:
		return 0
	r = min(n-r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n-r, -1))
	denom = reduce(mul, range(1, r+1))
	return numer // denom % mod

N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K+1):
	print(cmb(K-1, i-1) * cmb(N-K+1, i) % mod)

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

mod = 10**9 + 7

def nCr(n, r):
    if n < r:
        return 0
    r = min(r, n-r)
    num, den = 1, 1
    for i in range(r):
        num = (num * (n-i)) % mod
        den = (den * pow(i+1, mod-2, mod)) % mod
    return num * den % mod

for i in range(1, k+1):
    print(nCr(k-1, i-1) * nCr(n-k+1, i) % mod)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n, r):
	if n < r:
		return 0
	r = min(n-r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n-r, -1))
	denom = reduce(mul, range(1, r+1))
	return numer // denom % mod

N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K+1):
	print(cmb(K-1, i-1) * cmb(N-K+1, i) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

mod = 10**9 + 7
def nCr(n, r):
    r = min(r, n-r)
    num, den = 1, 1
    for i in range(r):
        num *= (n-i)
        den *= (i+1)
    return num // den % mod

lv = 0
a.append(n+1)
ans = 1
for v in a:
    vr = v-1 - lv
    if vr < 0:
        print(0)
        exit()
    r = 0
    for i in range(vr+(-vr//2)+1):
        r += nCr(vr-i, i)
    ans = (ans * r) % mod
    lv = v+1
print(ans)

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

mod = 10**9+7
a.append(float('INF'))
a = a[::-1]
dp = [0] * (n+1)
dp[0] = 1
if a[-1] != 1:
    dp[1] = 1
else:
    a.pop()
for i in range(2, n+1):
    if i == a[-1]:
        a.pop()
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod
print(dp[n])

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

mod = 10**9 + 7
def nCr(n, r):
    r = min(r, n-r)
    num, den = 1, 1
    for i in range(r):
        num *= (n-i)
        den *= (i+1)
    return num // den % mod

lv = 0
a.append(n+1)
ans = 1
for v in a:
    vr = v-1 - lv
    if vr < 0:
        print(0)
        exit()
    r = 0
    for i in range(vr+(-vr//2)+1):
        r += nCr(vr-i, i)
    ans = (ans * r) % mod
    lv = v+1
print(ans)

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

mod = 10**9+7
a.append(float('INF'))
a = a[::-1]
dp = [0] * (n+1)
dp[0] = 1
if a[-1] != 1:
    dp[1] = 1
else:
    a.pop()
for i in range(2, n+1):
    if i == a[-1]:
        a.pop()
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod
print(dp[n])

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

mod = 10**9 + 7
def nCr(n, r):
    r = min(r, n-r)
    num, den = 1, 1
    for i in range(r):
        num = (num * (n-i)) % mod
        den = (den * pow(i+1, mod-2, mod)) % mod
    return num * den % mod

lv = 0
a.append(n+1)
ans = 1
for v in a:
    vr = v-1 - lv
    if vr < 0:
        print(0)
        exit()
    r = 0
    for i in range(vr+(-vr//2)+1):
        r += nCr(vr-i, i)
    ans = (ans * r) % mod
    lv = v+1
print(ans)

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

mod = 10**9+7
a.append(float('INF'))
a = a[::-1]
dp = [0] * (n+1)
dp[0] = 1
if a[-1] != 1:
    dp[1] = 1
else:
    a.pop()
for i in range(2, n+1):
    if i == a[-1]:
        a.pop()
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod
print(dp[n])