Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*(n+1)

for i in range(n-1):
    ans[a[i]]+=1
ans.pop(0)
for j in ans:
    print(j)
Buggy python submission (verdict: Runtime Error):
def prepare(n, MOD):
 
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
     
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return fn, invs
  
  mod = int(1e9+7)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    print(0)
else:
    total_steps = (X+Y)//3
    dif_steps = abs(X-Y)
    if dif_steps > total_steps:
        print(0)
    else:
        up_steps = (total_steps - dif_steps)//2
        fn, invs = prepare(total_steps, mod)
        print((fn*invs[up_steps]*invs[total_steps-up_steps])%mod)

Fixed submission:
def prepare(n, MOD):
 
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
     
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return fn, invs
  
mod = int(1e9+7)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    print(0)
else:
    total_steps = (X+Y)//3
    dif_steps = abs(X-Y)
    if dif_steps > total_steps:
        print(0)
    else:
        up_steps = (total_steps - dif_steps)//2
        fn, invs = prepare(total_steps, mod)
        print((fn*invs[up_steps]*invs[total_steps-up_steps])%mod)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(M):
    B, C = map(int, input().split())
    if C > a[-1]:
        a += [C for _ in range(B)]
        a.sort(reverse=True)
        a = a[:N]
print(sum(a))

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif 6 <= A < 13:
    print(B//2)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(M):
    B, C = map(int, input().split())
    for n in range(N):
        if a[n] < C:
            a = a[:n] + [C for _ in range(B)] + a[n:]
            a = a[:N]
            break
print(sum(a))

Fixed submission:
#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(M):
    B, C = map(int, input().split())
    if C > a[N]:
        a += [C for _ in range(B)]
        a.sort(reverse=True)
        a = a[:N]
print(sum(a))

Fixed submission:
#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(M):
    B, C = map(int, input().split())
    a += [C for _ in range(B)]
    a.sort(reverse=True)
    a = a[:N]
print(sum(a))

Fixed submission:
#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
  else:
    print(":(")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
s = np.array([N, 0, 0, 0, 0])
m = np.array([A, B, C, D, E])
T = 0
while True:
    t = np.minimum(s, m)
    s -= t
    s[1:] += t[:-1]
    T += 1
    if np.max(s) == 0:
        break
print(T)

Fixed submission:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
s = min(A, B, C, D, E)
if N % s == 0:
    print(N // s + 4)
else:
    print(N // s + 5)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

if a == 0:
    a = b
if b == 0:
    b = a
if c == 0:
    c = d
if d == 0:
    d = c

if max(a, b) < 0 and max(c, d) > 0:
    A = -min(abs(a), abs(b))
    B = min(abs(c), abs(d))
elif max(a, b) > 0 and max(c, d) < 0:
    A = min(abs(a), abs(b))
    B = -min(abs(c), abs(d))
elif max(a, b) > 0 and max(c, d) > 0:
    A = max(abs(a), abas(b))
    B = max(abs(c), abs(d))
else:
    A = min(abs(a), abs(b))
    B = min(abs(c), abs(d))

print(A * B)

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

A = a * c
B = a * d
C = b * c
D = b * d

ANS = max(A, B, C, D)

print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = input()

A = A.split()
A = [int(a) for a in A]

ANS = 0
while len(A) != 0:
    ANS = ANS + (len(A) - A.index(max(A))) * A[A.index(max(A))] - sum(A[A.index(max(A)):])
    A = A[:A.index(max(A))]

print(ANS)

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

MAX = 0
ANS = 0

for i in range(N):
    ANS += max(0, MAX - A[i])
    MAX = max(MAX, A[i])

print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ANS = 1
for a in A:
    ANS = ANS * a

if ANS > 10 ** 18:
    ANS = -1

print(ANS)

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

A.sort()
if A[0] == 0:
    ANS = 0
else:
    A.sort(reverse=True)
    ANS = 1
    for a in A:
        ANS = ANS * a
        if ANS > 10 ** 18:
            ANS = -1
            break

print(ANS)
Buggy python submission (verdict: Runtime Error):
import numpy as np

A = np.empty(9)
b = np.empty(10)
place = ''

for i in range(0,7,3):
  A[i], A[i+1], A[i+2] = map(int,input().split())

N = int(input())

for n in range(N):
  b[n] = int(input())
  for j in range(9):
  	if b[n] == A[j]:
  		place = place + ' ' + str(j)

ans='No'

for i in range(0,7,3):
  if str(i) and str(i+1) and str(i+2) in place:
  	ans = 'Yes'

for i in range(3):
  if str(i) and str(i+3) and str(i+6) in place:
  	ans = 'Yes'

if '0' and '4' and '8' in place:
	ans = 'Yes'
if '2' and '4' and '6' in place:
	ans = 'Yes'

print(ans)


Fixed submission:

N = input()

ans = -(-int(N) // 2)

print(ans)
Buggy python submission (verdict: Runtime Error):
A_list = []

N = int(input())
A = input()
A_list = A.split(' ')

for n in range(N):
    if (int(A_list[n]) % 2 == 0):
        if (int(A_list[n]) % 3 == 0) | (int(A_list[n]) % 5 == 0):
            ans = 'APPROVED'
        else:
            ans = 'DENIED'
            break
print(ans)

Fixed submission:
A_list = []
ans = 0

N = int(input())
A = input()
A_list = A.split(' ')

for n in range(N):
    if (int(A_list[n]) % 2 == 0):
        if (int(A_list[n]) % 3 == 0) | (int(A_list[n]) % 5 == 0):
            ans = ans + 0
        else:
            ans = ans + 1
if ans == 0:
    print('APPROVED')
else:
    print('DENIED')
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c == 1:
	print('YES')
else:
	print('NO')


Fixed submission:
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
	A = A - 1
else:
	B = B - 1

print('{} {}'.format(A, B))
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c = = 1:
	print('YES')
else:
	print('NO')


Fixed submission:
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c == 1:
	print('YES')
else:
	print('NO')
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans == 2
elif A+B == 5:
    ans == 1
print(ans)

Fixed submission:
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans = 2
elif A+B == 5:
    ans = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans == 2
elif A+B == 5:
    ans == 1

Fixed submission:
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans = 2
elif A+B == 5:
    ans = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())

if sum(A1, A2, A3) >= 22:
	print('bust')
else:
	print('win')


Fixed submission:
A1, A2, A3 = map(int, input().split())

if A1 + A2 + A3 >= 22:
	print('bust')
else:
	print('win')

Buggy python submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())

if sum(A1, A2, A3) >= 22:
	print('bust')
else:
	print('win')


Fixed submission:
A1, A2, A3 = map(int, input().split())

if A1 + A2 + A3 >= 22:
	print('bust')
else:
	print('win')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ANS = [A.index(x) + 1 for x in range(1, N + 1)]

ANS = ' '.join(map(str, ANS))
print(ANS)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L = [[] for x in range(N)]

for i in range(N):
    L[i] = [A[i], i+1]
L.sort()

ANS = [0 for i in range(N)]
for i in range(N):
    ANS[i] = L[i][1]
print(*ANS)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        ans += (a[i]*a[j])
    ans = ans % ((10**9)+7)
print(ans)

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

sm = sum(a)
ans = 0

for i in range(len(a)):
    ans += a[i]*(sm-a[i])
    sm = sm - a[i]
    ans %= (10**9)+7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
a = deque(a)
circle = []
circle.append(a.popleft())

ans = 0
while a:
    nex = a.popleft()
    mx = 0
    for i in range(len(circle)):
        if mx <= min(circle[i-1], circle[i]):
            mx = min(circle[i-1], circle[i])
            mx_idx = i
    ans += mx
    circle.insert(mx_idx, nex)
print(ans)


Fixed submission:
from collections import deque
n = int(input())
a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(1, n):
    ans += a[n-i//2-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K= map(int,input().split())
p = list(map(int, input().split()))
ans = 1000000
for i in itertools.combinations(p, K):
    s = sum(i)
    ans = min(ans, s)
print(ans)


Fixed submission:
import itertools
N, K= map(int,input().split())
p = list(map(int, input().split()))
p.sort()
ans = sum(p[:K])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = ''

while True:
    if N <= 26**i:
        N -= 1
        for j i in range(N):
            ans += chr(ord('a') + N%26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])

Fixed submission:
N = int(input())
ans = ''

i = 1
while True:
    if N <= 26**i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N%26)
            N //= 26
        break
    else:
        N -= 26 ** i
    i+=1
print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = list(map(int,input().split()))
sum = 1
for i in As:
    sum *=i
sum = sum if sum<=(10**18) else -1
print(sum)

Fixed submission:
N = int(input())
As = list(map(int,input().split()))
sum = 1
if 0 in As:
    print(0)
    exit()
for i in As:
    sum *=i
    if sum>10**18:
        sum = -1
        break
print(sum)
Buggy python submission (verdict: Runtime Error):
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
if B<N:
    x = np.arange(0, B, 1)
else:
    x = np.arange(0, N+1, 1)

print(int(max(fun(x))))


Fixed submission:
import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, B, 1)
print(fun(x))
print(int(max(fun(x))))


Fixed submission:
import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, N+1, 1)
print(int(max(fun(x))))


Fixed submission:
import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, N+1, 1)
print(int(max(fun(x))))


Fixed submission:
import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
X, Y, A, B, C = map(int,input().split())
Reds = list(map(int, input().split()))
Greens = list(map(int, input().split()))
Ns = list(map(int, input().split()))

Reds = np.array(Reds)
Greens = np.array(Greens)
Ns = np.array(Ns)

Reds = np.sort(Reds)[:X-1:-1]
Greens = np.sort(Greens)[:Y-1:-1]
Ns = np.sort(Ns)[::-1]

Full = np.append(Reds, Greens)
Full = np.append(Full, Ns)
Full = np.sort(Full)[::-1]

sum = 0

for i in range(X+Y):
    sum += Full[i]

print(sum)

Fixed submission:
import numpy as np
X, Y, A, B, C = map(int,input().split())
Reds = list(map(int, input().split()))
Greens = list(map(int, input().split()))
Ns = list(map(int, input().split()))

Reds = np.array(Reds)
Greens = np.array(Greens)
Ns = np.array(Ns)

Reds = np.sort(Reds)[::-1]
Greens = np.sort(Greens)[::-1]
Ns = np.sort(Ns)[::-1]

Full = np.append(Reds[:X], Greens[:Y])
Full = np.append(Full, Ns)
Full = np.sort(Full)[::-1]

sum = 0

for i in range(X+Y):
    sum += Full[i]

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
def ABcosts(A, B):
    mincos = 100000
    for i in A:
        for j in B:
            if mincos > i + j:
                mincos = i + j
    return mincos

A, B, M = map(int,input().split())

refredge = list(map(int, input().split()))
microwave = list(map(int, input().split()))

discounts = []
costs = []
for i in range(M):
    dis = list(map(int, input().split()))
    cos = (refredge[dis[0]-1] + microwave[dis[1]-1] - dis[2])
    costs.append(cos)
    discounts.append(dis)
abcost = ABcosts(refredge, microwave)
print(min(min(costs), abcost))


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

refredge = list(map(int, input().split()))
microwave = list(map(int, input().split()))

costs = []
for i in range(M):
    dis = list(map(int, input().split()))
    cos = (refredge[dis[0]-1] + microwave[dis[1]-1] - dis[2])
    costs.append(cos)
abcost = min(refredge) + min(microwave)
print(min(min(costs), abcost))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        k = j+1
        while k < n and l[k] > max(l[i]-l[j], l[j]-l[i]):
            k += 1
            ans += 1
print(ans)


Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
ans = 0
for i in range(n-1):
    b = l[:i]
    c = l[i+1:]
    for j in b:
        ans += bisect.bisect_left(c, l[i] + j)#2番目の棒より短く(left), 一定以上の長さを持つ([i+1:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [tuple(sorted(list(input()))) for _ in range(n)]
ans = 0
st = []
count = {}

for i in range(n):
    if not s[i] in st:
        st += [s[i]]
        count[s[i]] = 0
    elif s[i] in st:
        count[s[i]] += 1
        ans += count[s[i]]

print(ans)

Fixed submission:
from collections import Counter
n = int(input())
s = [tuple(sorted(input())) for _ in range(n)]

c = Counter(s)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [tuple(sorted(list(input()))) for _ in range(n)]
ans = 0
st = []
count = {}

for i in range(n):
    if not s[i] in st:
        st += [s[i]]
        count[s[i]] = 0

for i in range(n):
    if s[i] in st:
        ans += count[s[i]]
        count[s[i]] += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
s = [tuple(sorted(input())) for _ in range(n)]

c = Counter(s)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [Counter(input()) for _ in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i]==s[j]:
            ans += 1
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
s = [tuple(sorted(input())) for _ in range(n)]

c = Counter(s)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if j not in am:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])


Fixed submission:
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
dic2 = {}

def stairs(n):
    global dic2
    if dic2.get(n):
        return dic2[n]

    if n == 0:
        return 1
    elif n ==1:
        return 1

    if n-1 not in am:
        n1 = stairs(n-1)
    else:
        n1 = 0
    if n-2 not in am:
        n2 = stairs(n-2)
    else:
        n2 = 0

    dic2[n] = (n1+n2)%1000000007

    return (n1+n2)%1000000007

print(stairs(n))

Fixed submission:
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
dic = {}
def dfs(i):

    global dic
    if dic.get(i):
        return dic[i]

    if i == n:
        return 1

    k = 0
    if i+1 not in am and i+1 <= n:
        k += dfs(i+1)
    if i+2 not in am and i+2 <= n:
        k += dfs(i+2)

    k %= 1000000007
    dic[i] = k
    return k

print(dfs(0))

Fixed submission:
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]

l, r = lr[0]
ans = set()
for k in range(l, r+1):
        ans.add(k)

for i, j in lr[1:]:
    ID = set()
    for k in range(i, j+1):
        ID.add(k)
    ans = ans & ID
print(len(ans))


Fixed submission:
n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
l = 1
r = n
for i, j in lr:
    l = max(i, l)
    r = min(j, r)
print(max(r-l+1, 0))
Buggy python submission (verdict: Runtime Error):
s = input()
a = int(s[:2])
b = int(s[2:])
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if a<=12 and b<=12:
    print('AMBIGUOUS')
elif 0<a<=12 and 0<b<=days[a]:
    print('YYMM')
elif 0<b<=12 and 0<a<=days[b]:
    print('MMYY')
else:
    print('NA')


Fixed submission:
s = input()
a = int(s[:2])
b = int(s[2:])
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif a<=99 and 0<b<=12:
    print('YYMM')
elif 0<a<=12 and b<=99:
    print('MMYY')
else:
    print('NA')

Buggy python submission (verdict: Runtime Error):
s = input()
a = int(s[:2])
b = int(s[2:])
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if a<=12 and b<=12:
    print('AMBIGUOUS')
elif a<=12 and b<=days[a]:
    print('YYMM')
elif b<=12 and a<=days[b]:
    print('MMYY')
else:
    print('NA')



Fixed submission:
s = input()
a = int(s[:2])
b = int(s[2:])
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif a<=99 and 0<b<=12:
    print('YYMM')
elif 0<a<=12 and b<=99:
    print('MMYY')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
nums = [int(input()) for _ in range(5)]
mn = float('inf')

for i in nums:
    if i%10!=0:
        mn = min(mn, i%10)
if mn == float('inf'):
    mn = 0

print(sum(list(map(lambda x: int(math.ceil(x/10)*10), nums)))-10+mn)


Fixed submission:
import math
nums = [int(input()) for _ in range(5)]
mn = float('inf')

for i in nums:
    if i%10!=0:
        mn = min(mn, i%10)
if mn == float('inf'):
    mn = 10

print(sum(list(map(lambda x: int(math.ceil(x/10)*10), nums)))-10+mn)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
    for i in range(Q):
        l, r = map(int, input().split())
        print(t[r-1] - t[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
lr = [tuple(map(int, input().split())) for _ in range(Q)]
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for l, r in lr:
    print(t[r-1] - t[l-1])

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

for l, r in lr:
    count = 0
    for i in range(l-1, r-1):
        if s[i:i+2]=='AC':
            i = i+1
            count += 1
    print(count)


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
lr = [tuple(map(int, input().split())) for _ in range(Q)]
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for l, r in lr:
    print(t[r-1] - t[l-1])