Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H,W=map(int, input().split())
c=[list(input()) for i in range(W)]
a=[0]*W
ans=''
   
for i in range(2*H):
    ans=''
    for j in range(W):
        #print((i)//2)
        a[j]=c[int((i)//2)][j]
        ans+=a[j]
    print(ans)

Fixed submission:
h, w = map(int, input().split())  
for i in range(h):
    s = input()
    print(s)
    print(s)

Buggy python submission (verdict: Runtime Error):
H,W=map(int, input().split())
c=[input().split() for i in range(W)]
a=[0]*W
ans=''
   
for i in range(2*H):
    ans=''
    for j in range(W):
        #print((i)//2)
        a[j]=c[int((i)//2)][j]
        ans+=a[j]
    print(ans)

Fixed submission:
h, w = map(int, input().split())  
for i in range(h):
    s = input()
    print(s)
    print(s)
Buggy python submission (verdict: Runtime Error):
H,W=4,5
a = [input() for i in range(H)]


ans=0
cnt=0

for i in range(H-1):
    for j in range(W-1):
        if a[i][j] == '#' and a[i+1][j] == '#' and  a[i][j+1] == '#':
            cnt+=1
            break
        elif a[i][j] == '#' and a[i+1][j] == '.' and  a[i][j+1] == '.':
            cnt+=1
            break
        else:
            continue
 
print('Impossible' if cnt>0 else 'Possible')
        


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

ans=0
cnt=0
 
for i in range(H-1):
    for j in range(W-1):
        if a[i][j] == '#' and a[i+1][j] == '#' and  a[i][j+1] == '#':
            cnt+=1
        elif a[i][j] == '#' and a[i+1][j] == '.' and  a[i][j+1] == '.':
            cnt+=1

            
for i in range(1,H):
    for j in range(1,W):
        if a[i][j] == '#' and a[i-1][j] == '.' and  a[i][j-1] == '.':
            cnt+=1

        
print('Impossible' if cnt>0 else 'Possible')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
x = sorted(list(a, b, c))
print("Yes" if x[0] + x[1] == x[2] else "No")

Fixed submission:
a, b, c = map(int, input().split())
x = [a, b, c]
x = sorted(x)
print("Yes" if x[0] + x[1] == x[2] else "No")
Buggy python submission (verdict: Runtime Error):
#N = int(input())
#a = list(map(int, input().split()))

ans=0

if N%2==0:
    for i in range(N//2):
      if a[a[i]-1]==i+1:
        ans += 1
            
else:
    for i in range(N//2 +1):
        if a[a[i]-1]==i+1:
          ans+=1

print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    if a[a[i]-1] == i+1:
        ans += 1
print(ans//2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
 
ans=0
 
if N%2==0:
    for i in range(N//2):
  	    if a[a[i]-1]==i+1:
          ans += 1
    
else:
    for i in range(N//2 +1):
        if a[a[i]-1]==i+1:
          ans+=1

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    if a[a[i]-1] == i+1:
        ans += 1
print(ans//2)

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

ans=0

if N%2==0:
    for i in range(N//2):
  	    if a[a[i]-1]==i+1:
            ans += 1
    
else:
    for i in range(N//2 +1):
        if a[a[i]-1]==i+1:
          ans+=1

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    if a[a[i]-1] == i+1:
        ans += 1
print(ans//2)
Buggy python submission (verdict: Time Limit Exceeded):
import re
if __name__ == '__main__':
    s = input()
    t = input()

    str_mat = [list('.'*len(t)), list(t)]

    bin_str_dict = {}
    for i in range(0, 2 ** len(t)):
        bin_str = format(i, 'b').zfill(len(t))
        if not bin_str.count('0') in bin_str_dict:
            bin_str_dict[bin_str.count('0')] = [bin_str]
        else:
            bin_str_dict[bin_str.count('0')].append(bin_str)

    def judge(i):
        for pattern in bin_str_dict[i]:
            pattern = ''.join([str_mat[int(bin_num)][index] for index, bin_num in enumerate(pattern)])
            if re.search(pattern, s):
                return True
        return False

    for i in range(0, len(t)):
        flag = judge(i)
        if flag:
            print(i)
            break
    if not flag:
        print(len(t))

Fixed submission:
if __name__ == '__main__':
    s = list(input())
    t = list(input())

    max_score = 0
    if len(s) == len(t):
        max_score = sum([s[j] == t[j] for j in range(len(t))])
    else:
        for i in range(0, len(s) - len(t)):
            score = sum([s[i + j] == t[j] for j in range(len(t))])
            if max_score < score:
                max_score = score
    print(len(t) - max_score)

Buggy python submission (verdict: Time Limit Exceeded):
import re
if __name__ == '__main__':
    s = input()
    t = input()

    str_mat = [list('.'*len(t)), list(t)]
    min = len(t)

    for i in range(2**len(t)-1, -1, -1):
        bin_str = format(i, 'b').zfill(len(t))
        indices = map(int, list(bin_str))
        pattern = ''.join([str_mat[index][num] for num, index in enumerate(indices)])
        m = re.search(pattern, s)
        if m:
            tmp = bin_str.count('0')
            if min > tmp:
                min = tmp
    print(min)

Fixed submission:
if __name__ == '__main__':
    s = list(input())
    t = list(input())

    max_score = 0
    if len(s) == len(t):
        max_score = sum([s[j] == t[j] for j in range(len(t))])
    else:
        for i in range(0, len(s) - len(t)):
            score = sum([s[i + j] == t[j] for j in range(len(t))])
            if max_score < score:
                max_score = score
    print(len(t) - max_score)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 2 == 5:
        print('-1')
    else:
        num = '7'
        count = 1
        while not int(num) % k == 0:
            count += 1
            num += '7'
        print(len(num))



Fixed submission:
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 5 == 0:
        print('-1')
    else:
        mod_list = [7 % k]
        if mod_list[-1] == 0:
            print(1)
        else:
            for i in range(1000000):
                mod_list.append((mod_list[0] + mod_list[-1] * 10) % k)
                if mod_list[-1] == 0:
                    break
            print(len(mod_list))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    def multi(given_list):
        ans = 1
        for i in given_list:
            ans *= i
        return ans


    score_list = [multi(a[i:k+i]) for i in range(n - k + 1)]
    for i in range(len(score_list)-1):
        if score_list[i] < score_list[i+1]:
            print("Yes")
        else:
            print("No")

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

    for i in range(len(a) - k):
        if a[i] < a[i+k]:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    n, m, k = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))

    min = 0
    a_count = 0
    for i, a_min in enumerate(a):
        if a_min + min <= k:
            min += a_min
            a_count += 1
        else:
            break
    b_count = 0

    for i, b_min in enumerate(b):
        if b_min + min <= k:
            min += b_min
            b_count += 1
        else:
            break

    max_count = a_count + b_count
    if not max_count == n+m:
        for i in range(a_count, 0, -1):
            min -= a[i - 1]
            a_count -= 1
            while min + b[b_count] < k:
                min += b[b_count]
                b_count += 1
            if a_count + b_count > max_count:
                max_count = a_count + b_count
    print(max_count)


Fixed submission:
if __name__ == '__main__':
    n, m, k = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))

    min = 0
    a_count = 0
    for i, a_min in enumerate(a):
        if a_min + min <= k:
            min += a_min
            a_count += 1
        else:
            break
    b_count = 0

    for i, b_min in enumerate(b):
        if b_min + min <= k:
            min += b_min
            b_count += 1
        else:
            break

    max_count = a_count + b_count
    if not max_count == n + m and not b_count == m:
        for i in a[:a_count][::-1]:
            min -= i
            a_count -= 1
            while b_count < len(b) and min + b[b_count] <= k:
                min += b[b_count]
                b_count += 1
            if a_count + b_count > max_count:
                max_count = a_count + b_count
            if b_count >= len(b):
                break
    print(max_count)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(n):
        limit = int(n / i)
        ans += limit * (limit + 1) / 2
    print(ans)

Fixed submission:
if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(1, n + 1):
        limit = int(n / i)
        ans += limit * (limit + 1) * i / 2
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


if __name__ == '__main__':
    n = int(input().strip())
    fk = 1
    k = 1

    start_point = [[10000000, 838627288460105],
                   [3900000, 89047258904088],
                   [3500000, 64954450698416],
                   [3000000, 38711715279705],
                   [2500000, 17755581570386],
                   [2000000, 30326413365285],
                   [1500000, 16734924755096],
                   [1000000, 7235062807366],
                   [100000, 60838190672]]
    for sp in start_point:
        if sp[0] < n:
            fk = sp[1]
            k = sp[0]
            break


    for i in range(k + 1, n + 1):
        fk += i * len(make_divisors(i))
    print(fk)


Fixed submission:
if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(1, n + 1):
        limit = int(n / i)
        ans += limit * (limit + 1) * i / 2
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input().strip())
    A = list(map(int, input().strip().split(" ")))


    if A[0] != 1 and len(A) == 1:
        print(-1)

    tree = [0] * (sum([2 ** i for i in range(N + 1)]))
    for i, a in enumerate(A[::-1]):
        depth = len(A) - 1 - i
        depth_hierarchy_start_index = sum([2 ** i for i in range(depth)]) if depth != 0 else 0
        depth_hierarchy_end_index = sum([2 ** i for i in range(depth + 1)]) if depth != 0 else 1

        # keisho
        if depth != N:
            for i in range(depth_hierarchy_start_index, depth_hierarchy_end_index):
                if tree[2 * i + 1] != 0 or tree[2 * i + 2] != 0:
                    tree[i] = 2

        # 1 ume
        count = 0
        part = 2
        while True:
            try:
                for i in range(0, 2 ** depth, int(2 ** depth / part) if int(2 ** depth / part) != 0 else 1):
                    if tree[depth_hierarchy_start_index + i] == 0:
                        tree[depth_hierarchy_start_index + i] = 1
                        count += 1
                    if count == a:
                        break
                    part *= 2
                if count == a:
                    break
            except:
                print(-1)

    print(sum([1 if i != 0 else 0 for i in tree]))


Fixed submission:
if __name__ == '__main__':
    H1, M1, H2, M2, K = map(int, input().strip().split(" "))

    diff_min = (H2 - H1) * 60 + M2 - M1
    ans = diff_min - K
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t,x,y,ans):
    ans -= s[x-1][t[x-1]-1]
    ans += s[x-1][y-1]
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==t[x-1]):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==t[x-1]):
            mi = j
            break
    ans -= c[t[x-1]-1]*(x-mi)*(ma-x)
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==y):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==y):
            mi = j
            break
    ans += c[y-1]*(x-mi)*(ma-x)
    return ans
    
for i in range(200000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    A = rec(t,x,y,ans)
    if (ans < A):
        t[x-1] = y
        a = t
        ans = A

print(*a ,sep="\n")


Fixed submission:
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
last = [0]*26
for i in range(1,d+1):
    x = random.randrange(26)
    print(x+1)

Buggy python submission (verdict: Time Limit Exceeded):
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t):
    r = 0
    l = [0]*26
    for i in range(1,d+1):
        x = t[i-1]-1
        l[x] = i
        r += s[i-1][x]
        for j in range(26):
            r -= c[j]*(i-l[j])
    return r
    
for i in range(10000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    t[x-1] = y
    A = rec(t)
    if (ans < A):
        a = t
        ans = A

print(*a ,sep="\n")
    
    

Fixed submission:
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
last = [0]*26
for i in range(1,d+1):
    x = random.randrange(26)
    print(x+1)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a= list(map(int, input().split()))
    a.sort()
    flag = [1]*(10**6+1)
    for i in range(n):
        if (flag[a[i]]==1):
            for j in range(2*a[i],10**6+1,a[i]):            
                flag[j] = 0
    x = collections.Counter(a)
    ans = 0
    for i in a:
        if (flag[i]==1):
            ans += 1
            flag[i]=0
            if (x[i]>1):
                ans -=1
    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
#import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a= list(map(int, input().split()))
    a.sort()
    ans = 0
    flag = [1]*(10**6+1)
    for i in range(n):
        if (flag[a[i]]==0):
            continue
        tmp = a[i]
        while tmp < 10**6+1:
            flag[tmp] = False
            tmp += a[i]
        if i<n-1:
            if (a[i+1]==a[i]):
                continue
        ans += 1
    #x = collections.Counter(a)
    #ans = 0
    #for i in a:
        #if (flag[i]==1):
            #ans += 1
            #flag[i]=0
            #if (x[i]>1):
                #ans -=1
    print(ans)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
m = 1000000007
ans = []
for i in range(1,n+2):
    ans_min = (0+(i-1))*i*0.5
    ans_max = ((n+1-i)+n)*i*0.5
    ans.append(ans_max-ans_min+1)
ans_wa = [ans[0]]
for i in range(1,n+1):
    ans_wa.append(ans_wa[i-1]+ans[i])
print(int((ans_wa[n]-ans_wa[k-2])%m))

Fixed submission:
import math
r = int(input())
print(r*math.pi*2)
Buggy python submission (verdict: Runtime Error):
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100000)
y = bisect.bisect_left(L,x)
print(L[y])

Fixed submission:
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100005)
y = bisect.bisect_left(L,x)
print(L[y])
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int, input().split())
if (x <= (a*a*b)/2):
    p = (2*x)/(a*b)
    print(90-math.degrees(math.atan(p/b)))
else:
    p = 2*(a*a*b - x)/(a*a)
    print(90-math.degrees(math.atan(a/p)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if (x <= (a*a*b)/2):
    p = (2*x)/(a*b)
    print(90-math.degrees(math.atan(p/b)))
elif (x == a*a*b):
    print(0)
    
else:
    p = 2*(a*a*b - x)/(a*a)
    print(90-math.degrees(math.atan(a/p)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [list(input()) for _ in range(n)]
for i in range(n):
    for j in range(n):
        if (i==j):
            s[i][j] = 0
            continue
        if (s[i][j]=="1"):
            s[i][j] = 1
        else:
            s[i][j] = float("inf")
#print(s)
for k in range(n):
    for i in range(n):
        for j in range(n):
            s[i][j] = min(s[i][j], s[i][k]+s[k][j])
#print(s)
w = [[] for _ in range(n)]
m = [s[0][0],0,0]
for i in range(n):
    for j in range(n):
        if (s[i][j] > m[0]):
            m = [s[i][j],i,j]
#print(m)
for i in range(n):
    w[s[m[1]][i]].append(i)
#print(w)
for i in range(n):
    if (len(w[i])>=2):
        for j in range(len(w[i])-1):
            for k in range(j+1,len(w[i])):
                if (s[w[i][j]][w[i][k]]==1):
                    print(-1)
                    exit()
print(m[0]+1)


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = [list(input()) for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if (i==j):
                s[i][j] = 0
                continue
            if (s[i][j]=="1"):
                s[i][j] = 1
            else:
                s[i][j] = float("inf")
    #print(s)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                s[i][j] = min(s[i][j], s[i][k]+s[k][j])
    #print(s)
    w = [[] for _ in range(n)]
    m = [s[0][0],0,0]
    for i in range(n):
        for j in range(n):
            if (s[i][j] > m[0]):
                m = [s[i][j],i,j]
    #print(m)
    for i in range(n):
        w[s[m[1]][i]].append(i)
    #print(w)
    for i in range(n):
        if (len(w[i])>=2):
            for j in range(len(w[i])-1):
                for k in range(j+1,len(w[i])):
                    if (s[w[i][j]][w[i][k]]==1):
                        print(-1)
                        exit()
    print(m[0]+1)
    

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
x = math.gcd(a,b)

def so(n):
    a = []
    while n%2==0:
        a.append(2)
        n//=2
    f = 3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
y = set(so(x))
print(len(y)+1)

Fixed submission:
import fractions
a,b = map(int,input().split())
x = fractions.gcd(a,b)

def so(n):
    a = []
    while n%2==0:
        a.append(2)
        n//=2
    f = 3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
y = set(so(x))
print(len(y)+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))
sub = [0]
a.sort()
for i in range (m):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.insert(1,x//2)
        else:
            x =sub.pop()
            sub.insert(1,x//2)
    else:
        x =sub.pop()
        sub.insert(1,x//2)
print(sum(a)+sum(sub))
        

Fixed submission:
from collections import deque
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = a.pop()
sub = deque([p//2])
for i in range (m-1):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.appendleft(x//2)
        else:
            x =sub.pop()
            sub.appendleft(x//2)
    else:
        x =sub.pop()
        sub.appendleft(x//2)
print(sum(a)+sum(sub))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n):
    ans += i
print(ans)

Fixed submission:
n = int(input())
ans = 0
if ((n-1)%2==0):
    ans = (n)*((n-1)//2)
else:
    ans = (n)*((n-1)//2) + n//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import copy
h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]
t = copy.deepcopy(s)
for i in range(h):
    count = 0
    for j in range(w):
        if (s[i][j]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                s[i][k]=count
            count = 0
    for k in range(w-1,w-count-1,-1):
        s[i][k]=count
    count = 0

for i in range(w):
    count = 0
    for j in range(h):
        if (t[j][i]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                t[k][i]=count
            count = 0
    for k in range(h-1,h-count-1,-1):
        t[k][i]=count
    count = 0

ans = 0
for i in range(h):
    for j in range(w):
        if (s[i][j]!="#"):
            if (s[i][j]+t[i][j]-1 > ans):
                ans = s[i][j]+t[i][j]-1
print(ans)

Fixed submission:
p,q,r = map(int, input().split())
print(min(p+q,p+r,q+r))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
fib = [1,1,2]
for i in range(3,n+1):
    fib.append((fib[i-2]+fib[i-1])%mod)
ans = 0
ans += fib[a[0]-1]

for i in range(1,m):
    if (a[i]-a[i-1]!=1):
        ans *= fib[a[i]-a[i-1]-2]
        ans %= mod
    else:
        print(0)
        exit()
ans *= fib[n-a[m-1]-1]
print(ans%mod)

Fixed submission:
n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
fib = [1,1,2]
for i in range(3,n+1):
    fib.append((fib[i-2]+fib[i-1])%mod)
if (m==0):
    print(fib[n])
    exit()
ans = 0
ans += fib[a[0]-1]

for i in range(1,m):
    if (a[i]-a[i-1]!=1):
        ans *= fib[a[i]-a[i-1]-2]
        ans %= mod
    else:
        print(0)
        exit()
ans *= fib[n-a[m-1]-1]
print(ans%mod)