Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
from copy import deepcopy
from operator import itemgetter

n, m = (int(x) for x in input().split())
LRD = [tuple(int(x) for x in input().split()) for _ in range(m)]
LRD.sort(key=itemgetter(0, 1))
INF = 10**18

while LRD:
    X = [INF] * n
    TBD = []  # To be determined
    X[LRD[0][0] - 1] = 0
    for l, r, d in LRD:
        l -= 1
        r -= 1
        if X[l] == X[r] == INF:
            TBD.append((l, r, d))
        elif X[l] != INF and X[r] == INF:
            X[r] = X[l] + d
        elif X[l] == INF and X[r] != INF:
            X[l] = X[r] - d
        else:
            if X[r] - X[l] != d:
                print("No")
                exit()
            else:
                continue
    LRD = deepcopy(TBD)
    LRD.sort(key=itemgetter(0, 1))
    X.sort()
    xmax = X[bisect_left(X, INF) - 1]
    xmin = X[0]
    if xmax - xmin >= 10**9:
        print("No")
        exit()

print("Yes")


Fixed submission:
n, m = (int(x) for x in input().split())
LRD = [tuple(int(x) for x in input().split()) for _ in range(m)]

G = [[] for _ in range(n)]
dist = dict()
for l, r, d in LRD:
    l -= 1
    r -= 1
    G[l].append(r)
    G[r].append(l)
    dist[(l, r)] = d
    dist[(r, l)] = -d

INF = 10**18
X = [INF] * n
for i in range(n):
    stack = [i]
    while stack:
        u = stack.pop()
        if X[u] == INF:
            X[u] = 0
        for v in G[u]:  # u -> v
            if X[v] == INF:
                X[v] = X[u] + dist[(u, v)]
                stack.append(v)
            else:
                if X[v] != X[u] + dist[(u, v)]:
                    print("No")
                    exit()

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l = len(s)
X, Y = (int(x) for x in input().split())
F = s.split("T")
X -= F[0].count("F")
y_move = [f.count("F") for f in F[1::2]]
x_move = [f.count("F") for f in F[2::2]]

dpy = [[False] * (2 * l + 5) for _ in range(len(y_move) + 1)]
dpx = [[False] * (2 * l + 5) for _ in range(len(x_move) + 1)]
dpx[0][0] = dpy[0][0] = True

for i in range(1, len(x_move) + 1):
    for x in range(-l - 2, l + 2):
        if -l <= x - x_move[i - 1] <= l:
            dpx[i][x] |= dpx[i - 1][x - x_move[i - 1]]
        if -l <= x + x_move[i - 1] <= l:
            dpx[i][x] |= dpx[i - 1][x + x_move[i - 1]]

for i in range(1, len(y_move) + 1):
    for y in range(-l - 2, l + 2):
        if -l <= y - y_move[i - 1] <= l:
            dpy[i][y] |= dpy[i - 1][y - y_move[i - 1]]
        if -l <= y + y_move[i - 1] <= l:
            dpy[i][y] |= dpy[i - 1][y + y_move[i - 1]]

if dpx[- 1][X] and dpy[- 1][Y]:
    print("Yes")
else:
    print("No")


Fixed submission:
s = input()
l = len(s)
X, Y = (int(x) for x in input().split())
F = s.split("T")
x_move = [f.count("F") for f in F[2::2]]
y_move = [f.count("F") for f in F[1::2]]
x_set = set()
x_set.add(F[0].count("F"))
y_set = set()
y_set.add(0)
for move in x_move:
    x_set = set(x + move for x in x_set) | set(x - move for x in x_set)
for move in y_move:
    y_set = set(y + move for y in y_set) | set(y - move for y in y_set)

if X in x_set and Y in y_set:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S=int(input())
A=[0 for i in range(S+1)]
B=[0 for i in range(S+1)]
A[3]=1
B[3]=1
A[4]=1
B[4]=2
A[5]=1
B[5]=3
for i in range(6,S+1):
    A[i]=(B[i-3]+1)%(10**9+7)
    B[i]=(B[i-1]+A[i])%(10**9+7)
print(A[S])

Fixed submission:
S=int(input())
A=[0 for i in range(max(S+1,10))]
B=[0 for i in range(max(S+1,10))]
A[3]=1
B[3]=1
A[4]=1
B[4]=2
A[5]=1
B[5]=3
for i in range(6,S+1):
    A[i]=(B[i-3]+1)%(10**9+7)
    B[i]=(B[i-1]+A[i])%(10**9+7)
print(A[S])
Buggy python submission (verdict: Runtime Error):
import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
Q=[]
heapq.heapify(Q) 
heapq.heappush(Q, (-A[0],-A[0],0))
for i in range(1,N):
    B=heapq.heappop(Q)
    count+=-B[0]
    heapq.heappush(Q, (-A[1],-A[i],B[1]))
    heapq.heappush(Q, (-A[2],-A[i],B[2]))
print(count)

Fixed submission:
import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
Q=[]
heapq.heapify(Q) 
heapq.heappush(Q, (-A[0],-A[0],0))
for i in range(1,N):
    B=heapq.heappop(Q)
    count+=-B[0]
    heapq.heappush(Q, (-A[i],-A[i],B[1]))
    heapq.heappush(Q, (-A[i],-A[i],B[2]))
print(count)
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N!=0:
    p=list(map(int,input().split()))
    p.sort()
    for i in range(X,101):
        if i not in p:
            min_=i
            dif_min=i-X
            break;
    for i in range(X,0,-1):
        if i not in p:
            max_=i
            dif_max=X-i
            break;
    if dif_max<=dif_min:
          print(max_)
    else:
          print(min_)
else:
    print(X)

Fixed submission:
X,N = map(int,input().split())
if N!=0:
    p=list(map(int,input().split()))
    p.sort()
    for i in range(X,102):
        if i not in p:
            min_=i
            dif_min=i-X
            break;
    for i in range(X,-1,-1):
        if i not in p:
            max_=i
            dif_max=X-i
            break;
    if dif_max<=dif_min:
          print(max_)
    else:
          print(min_)
else:
    print(X)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M=map(int,input().split())
edge=[[] for i in range(N)]
visited=[-1 for i in range(N)]
dist=[1000000000 for i in range(N)]
last=[-1 for i in range(N)]
i=0
dist[0]=0
for i in range(M):
    A,B=map(int,input().split())
    edge[A-1].append(B-1)
    edge[B-1].append(A-1)
Q=deque()
Q.append(0)
while Q:
    i=Q.popleft()
    for j in edge[i]:
        if dist[j]>dist[i]+1:
            dist[j]=dist[i]+1
            last[j]=i+1
        if visited[j]==-1 and (j not in Q):
            Q.append(j)
    visited[i]=1
print("Yes")
for i in range(1,N):
  print(last[i])

Fixed submission:
from collections import deque
N,M=map(int,input().split())
edge=[[] for i in range(N)]
visited=[-1 for i in range(N)]
dist=[1000000000 for i in range(N)]
last=[-1 for i in range(N)]
i=0
dist[0]=0
for i in range(M):
    A,B=map(int,input().split())
    edge[A-1].append(B-1)
    edge[B-1].append(A-1)
Q=deque()
Q.append(0)
while Q:
    i=Q.popleft()
    if visited[i]==-1:
        for j in edge[i]:
            if dist[j]>dist[i]+1:
                dist[j]=dist[i]+1
                last[j]=i+1
            if visited[j]==-1:
                Q.append(j)
    visited[i]=1
print("Yes")
for i in range(1,N):
	print(last[i])
Buggy python submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost=10000000000:
  print(-1)
else:
  print(min_cost)

Fixed submission:
N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost==10000000000:
  print(-1)
else:
  print(min_cost)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
B=[[] for i in range(N+1)]
B[0].append("")
for i in range(N):
    A.append(chr(97+i))
    for j in B[i]:
        for k in A:
            B[i+1].append(j+k)
for i in B[N]:
    count=ord("a")
    yes=1
    for j in range(N):
        if ord(i[j])<=count+1:
            count=max(count,ord(i[j]))
        else:
            yes=0
            continue;
    if yes==1:
        print(i)

Fixed submission:
N=int(input())
A=[]
B=[[] for i in range(N+1)]
B[0].append("")
for i in range(N):
    A.append(chr(97+i))
    for j in B[i]:
        for k in A:
            B[i+1].append(j+k)
for i in B[N]:
    count=ord("a")
    yes=1
    for j in range(N):
        if ord(i[j])<=count+1:
            count=max(count,ord(i[j]))
        else:
            yes=0
            continue;
    if yes==1:
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
B=[[] for i in range(N+1)]
B[0].append("")
for i in range(N):
    A.append(chr(97+i))
    for j in B[i]:
        for k in A:
            B[i+1].append(j+k)
for i in B[N]:
    count=ord("a")
    yes=1
    for j in range(N):
        if ord(i[j])<=count+1:
            count=max(count,ord(i[j]))
        else:
            yes=0
    if yes==1:
        print(i)

Fixed submission:
N=int(input())
A=[]
B=[[] for i in range(N+1)]
B[0].append("")
for i in range(N):
    A.append(chr(97+i))
    for j in B[i]:
        for k in A:
            B[i+1].append(j+k)
for i in B[N]:
    count=ord("a")
    yes=1
    for j in range(N):
        if ord(i[j])<=count+1:
            count=max(count,ord(i[j]))
        else:
            yes=0
            continue;
    if yes==1:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n_a,n_b,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
price=[]
for i in range(M):
    X=list(map(int,input().split()))
    price.append(A[X[0]-1]+B[X[1]-1]-X[2])
for i in range(n_a):
    for j in range(n_b):
        price.append(A[i]+B[j])
print(min(price))

Fixed submission:
n_a,n_b,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
price=[]
for i in range(M):
    X=list(map(int,input().split()))
    price.append(A[X[0]-1]+B[X[1]-1]-X[2])
price.append(min(A)+min(B))
print(min(price))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
count=0
A=[[] for i in range(3)]
for i in range(M):
    s,c=map(int,input().split())
    if s==1 and c==0:
        count+=1
    else:
        A[s-1].append(c)
B=[]
for i in range(N-1,-1,-1):
    if len(A[i])>=1:
        B.append(A[i][0])
        for j in range(1,len(A[i])):
            if A[i][j]!=A[i][0]:
                count+=1
    else:
        B.append(0)
if count>0:
    print(-1)
elif N==1:
    print(B[0])
elif N==2:
    print(B[2]*(10**(N-1))+B[1]*(10**(N-2)))
else:
    print(B[2]*(10**(N-1))+B[1]*(10**(N-2))+B[0])

Fixed submission:
N,M=map(int,input().split())
count=0
A=[[] for i in range(3)]
for i in range(M):
    s,c=map(int,input().split())
    if s==1 and c==0 and N>=2:
        count+=1
    else:
        A[s-1].append(c)
B=[]
for i in range(N):
    if len(A[i])>=1:
        B.append(A[i][0])
        for j in range(1,len(A[i])):
            if A[i][j]!=A[i][0]:
                count+=1
    elif N>=2:
        B.append(max(1-i,0))
    else:
        B.append(0)
if count>0:
    print(-1)
elif N==3:
    print(B[0]*(10**2)+B[1]*(10**1)+B[2])
elif N==2:
    print(B[0]*(10**1)+B[1])
else:
    print(B[0])
Buggy python submission (verdict: Time Limit Exceeded):
MAX = 10 ** 5 * 2
mod = 10 ** 9 + 7
frac = [1]
for i in range(1,MAX + 1 ):
    frac.append( (frac[-1] * i) % mod )
def pow(a, n):
    if n == 0 : return  1
    elif n == 1 : return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1 :
        tmp = (tmp * a) % mod
    return tmp
def inv(x):
    return pow(x, mod - 2 )
def comb(n, k):
    if k >= n or k < 0 : return 1
    return (frac[n] * inv(frac[n-k]) * inv(frac[k]))%mod
n,k = map(int,input().split())
count=0
for i in range(min(n,k+1)):
    count=(count+comb(n,i)*comb(n-1,n-1-i))%mod
print(count)

Fixed submission:
MAX = 10 ** 5 * 2
mod = 10 ** 9 + 7
frac = [1]
inv_frac=[1]
def pow(a, n):
    if n == 0 : return  1
    elif n == 1 : return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1 :
        tmp = (tmp * a) % mod
    return tmp
def inv(x):
    return pow(x, mod - 2 )
for i in range(1,MAX + 1 ):
    frac.append( (frac[-1] * i) % mod )
    inv_frac.append(inv(frac[-1])%mod)
def comb(n, k):
    if k >= n or k < 0 : return 1
    return (frac[n]*inv_frac[n-k] * inv_frac[k]) %mod
n,k = map(int,input().split())
count=0
b=inv(n)
for i in range(min(n,k+1)):
    a=comb(n,i)
    count=(count+a*a*(n-i)*b)%mod
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
MAX = 10 ** 5 * 2
mod = 10 ** 9 + 7
frac = [1]
for i in range(1,MAX + 1 ):
    frac.append( (frac[-1] * i) % mod )
def pow(a, n):
    if n == 0 : return  1
    elif n == 1 : return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1 :
        tmp = (tmp * a) % mod
    return tmp
def inv(x):
    return pow(x, mod - 2 )
def comb(n, k):
    if k >= n or k < 0 : return 1
    return (frac[n] * inv(frac[n-k]) * inv(frac[k]))%mod
n,k = map(int,input().split())
count=0
for i in range(min(n,k+1)):
    count=(count+comb(n,i)*comb(n-1,n-1-i))%mod
print(count)

Fixed submission:
MAX = 10 ** 5 * 2
mod = 10 ** 9 + 7
frac = [1]
inv_frac=[1]
def pow(a, n):
    if n == 0 : return  1
    elif n == 1 : return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1 :
        tmp = (tmp * a) % mod
    return tmp
def inv(x):
    return pow(x, mod - 2 )
for i in range(1,MAX + 1 ):
    frac.append( (frac[-1] * i) % mod )
    inv_frac.append(inv(frac[-1])%mod)
def comb(n, k):
    if k >= n or k < 0 : return 1
    return (frac[n]*inv_frac[n-k] * inv_frac[k]) %mod
n,k = map(int,input().split())
count=0
b=inv(n)
for i in range(min(n,k+1)):
    a=comb(n,i)
    count=(count+a*a*(n-i)*b)%mod
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
dp = [0] * (H+1)
A, B = map(int, input().split())
for j in range(1, H+1):
    if j>A:
        dp[j] = max(dp[j-A] + B, dp[j])
    else:
        dp[j] = max(dp[0] + B, dp[j])
for i in range(1,N):
    A, B = map(int, input().split())
    for j in range(1, H+1):
        if j>A:
            dp[j] = min(dp[j-A] + B, dp[j])
        else:
            dp[j] = min(dp[0] + B, dp[j])
print(dp[H])

Fixed submission:
H, N = map(int, input().split())
dp = [0] * (H+1)
A, B = map(int, input().split())
for j in range(1, H+1):
    dp[j] = max(dp[max(j-A,0)] + B, dp[j])
for i in range(1,N):
    A, B = map(int, input().split())
    for j in range(1, H+1):
        dp[j] = min(dp[max(j-A,0)] + B, dp[j])
print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
multi=math.factorial(N)//(math.factorial(K-1)*math.factorial(N-K+1))
A.sort(reverse=True)
count=0
for i in range(N-K+1):
    multi=multi*(N-K+1-i)//(N-i)
    count+=((A[i]-A[N-1-i])*multi)
    count%=10**9+7
print(count)

Fixed submission:
import math
n_ = 10**5 + 3
mod = 10**9+7
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def nCr(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
for i in range(N-K+1):
    count=(count+((A[i]-A[N-1-i])*nCr(N-i-1,K-1)))%(10**9+7)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
multi=math.factorial(N)//(math.factorial(K-1)*math.factorial(N-K+1))
A.sort(reverse=True)
count=0
for i in range(N-K+1):
    multi=multi*(N-K+1-i)//(N-i)
    count+=((A[i]-A[N-1-i])*multi)
    count%=10**9+7
print(count)

Fixed submission:
import math
n_ = 10**5 + 3
mod = 10**9+7
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def nCr(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
for i in range(N-K+1):
    count=(count+((A[i]-A[N-1-i])*nCr(N-i-1,K-1)))%(10**9+7)
print(count)
Buggy python submission (verdict: Runtime Error):
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A, reverse=True)
count=P
for i in range(P,N):
    dif=sum(B[P-1:i])
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif M*(V-((P-1)+(N-i)))+dif<=(B[i]+M)*(i-P+1):
        count+=1
    else:
      break()
print(count)

Fixed submission:
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(int(A*B/math.gcd(A,B)))

Fixed submission:
import fractions
A,B=map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))

Buggy python submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B/gcd(A,B))

Fixed submission:
import fractions
A,B=map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))
Buggy python submission (verdict: Runtime Error):
N,M,L=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    A[a-1].append((b-1,c))
    A[b-1].append((a-1,c))
d=[[100000000001]*N for i in range(N)]
for i in range(N):
    d[i][i]=0
for i in range(N):
    for to,cost in A[i]:
        d[i][to] = cost
for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][k] != 100000000001 and d[k][j] != 100000000001:
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
B=[[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if d[i][j]<=L:
            B[i].append((j,1))
times=[[100000000001]*N for i in range(N)]
for i in range(N):
    times[i][i]=0
for i in range(N):
    for to,cost in B[i]:
        times[i][to] = cost
for k in range(N):
    for i in range(N):
        for j in range(N):
            if times[i][k] != 100000000001 and times[k][j] != 100000000001:
                times[i][j] = min(times[i][j], times[i][k] + times[k][j])
Q=int(input())
for i in range(Q):
    s,t=map(int,input().split())
    if times[s-1][t-1]!=100000000001
    	print(times[s-1][t-1]-1)
    else:
      	print(-1)

Fixed submission:
N,M,L=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    A[a-1].append((b-1,c))
    A[b-1].append((a-1,c))
d=[[100000000001]*N for i in range(N)]
for i in range(N):
    d[i][i]=0
for i in range(N):
    for to,cost in A[i]:
        d[i][to] = cost
for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][k] != 100000000001 and d[k][j] != 100000000001:
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
B=[[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if d[i][j]<=L:
            B[i].append((j,1))
times=[[100000000001]*N for i in range(N)]
for i in range(N):
    times[i][i]=0
for i in range(N):
    for to,cost in B[i]:
        times[i][to] = cost
for k in range(N):
    for i in range(N):
        for j in range(N):
            if times[i][k] != 100000000001 and times[k][j] != 100000000001:
                times[i][j] = min(times[i][j], times[i][k] + times[k][j])
Q=int(input())
for i in range(Q):
    s,t=map(int,input().split())
    if times[s-1][t-1]!=100000000001:
    	print(times[s-1][t-1]-1)
    else:
      	print(-1)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())
E=int(C*D/math.gcd(C,D))
a=B-A+1-(B//C-(A-1)//C+B//D-(A-1)//D-B//E+(A-1)//E)
print(a)

Fixed submission:
from fractions import gcd
A,B,C,D=map(int,input().split())
E=(C*D)//gcd(C,D)
a=B-A+1-(B//C-(A-1)//C+B//D-(A-1)//D-B//E+(A-1)//E)
print(a)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[0]*(N+1)
b=[0]*(M+2)
c=[0]*(M+2)
a[0]=0
a[1]=1
a[2]=1
for i in range(3,N+1):
    a[i]=a[i-1]+a[i-2]
b[0]=-1
b[M+1]=N+1
way=1
for i in range(1,M+1):
    b[i]=int(input())
    c[i]=b[i]-b[i-1]-1
    way=(way*a[c[i]])%1000000007
c[M+1]=b[M+1]-b[M]-1
way=(way*a[c[M+1]])%1000000007
print(way)

Fixed submission:
N,M=map(int,input().split())
a=[0]*(N+2)
b=[0]*(M+2)
c=[0]*(M+2)
a[0]=0
a[1]=1
a[2]=1
for i in range(3,N+2):
    a[i]=a[i-1]+a[i-2]
if M==0:
    print(a[N+1]%1000000007)
else:
    b[0]=-1
    b[M+1]=N+1
    way=1
    for i in range(1,M+1):
        b[i]=int(input())
        c[i]=b[i]-b[i-1]-1
        way=(way*a[c[i]])%1000000007
    c[M+1]=b[M+1]-b[M]-1
    way=(way*a[c[M+1]])%1000000007
    print(way)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[0]*(N+1)
b=[0]*(M+2)
c=[0]*(M+2)
a[0]=0
a[1]=1
a[2]=1
for i in range(3,N+1):
    a[i]=a[i-1]+a[i-2]
b[0]=-1
b[M+1]=N+1
way=1
for i in range(1,M+1):
    b[i]=int(input())
    c[i]=b[i]-b[i-1]-1
    way=(way*a[c[i]])%1000000007
c[M+1]=b[M+1]-b[M]-1
way=(way*a[c[M+1]])%1000000007
print(way)

Fixed submission:
N,M=map(int,input().split())
a=[0]*(N+2)
b=[0]*(M+2)
c=[0]*(M+2)
a[0]=0
a[1]=1
a[2]=1
for i in range(3,N+2):
    a[i]=a[i-1]+a[i-2]
if M==0:
    print(a[N+1]%1000000007)
else:
    b[0]=-1
    b[M+1]=N+1
    way=1
    for i in range(1,M+1):
        b[i]=int(input())
        c[i]=b[i]-b[i-1]-1
        way=(way*a[c[i]])%1000000007
    c[M+1]=b[M+1]-b[M]-1
    way=(way*a[c[M+1]])%1000000007
    print(way)
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())
    for j in range(B):
        A.append(C)
A.sort(reverse=True)
sum=0
for i in range(N):
    sum+=A[i]
print(sum)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
D=[]
for i in range(M):
    (B,C)=map(int,input().split())
    D.append((C,B))
D.append((0,0))
D.sort(reverse=True)
i=0
j=0
count=0
sum=0
while count<N:
    if A[i]>=D[j][0]:
        sum+=A[i]
        i+=1
        count+=1
    else:
        sum+=D[j][0]*(min(N-count,D[j][1]))
        count+=D[j][1]
        j+=1
print(sum)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
C=input()
print(C[:B]+C[B].lower()+C[B+1:])

Fixed submission:
A,B=map(int,input().split())
C=input()
print(C[:B-1]+C[B-1].lower()+C[B:])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
b=[]
for i in range(m):
    b.append(list(map(int,input().split())))
    b.sort(key=lambda x:x[1])
time=0
count=0
for k in range(len(b)):
    if b[k][0]>=time:
                time=b[k][1]
                count+=1
print(count)

Fixed submission:
n,m=map(int,input().split())
b=[]
for i in range(m):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x:x[1])
time=0
count=0
for k in range(len(b)):
    if b[k][0]>=time:
                time=b[k][1]
                count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n = 3
t=[]
for i in range(1<<n):
    ans = int(s[0])
    k=1
    for j in range(n):
        if 1&(i>>j):
            ans += int(s[k:(j+2)])
            t.append("+")
        else: 
            ans -= int(s[k:(j+2)]) 
            t.append("-")
        k=j+2
    if ans==7:
        print(s[0]+t[0]+s[1]+t[1]+s[2]+t[2]+s[3]+"=7")
        break;
    ans = int(s[0])
    t=[]
print(ans)

Fixed submission:
s = input()
n = 3
t=[]
for i in range(1<<n):
    ans = int(s[0])
    k=1
    for j in range(n):
        if 1&(i>>j):
            ans += int(s[k:(j+2)])
            t.append("+")
        else: 
            ans -= int(s[k:(j+2)]) 
            t.append("-")
        k=j+2
    if ans==7:
        print(s[0]+t[0]+s[1]+t[1]+s[2]+t[2]+s[3]+"=7")
        break;
    ans = int(s[0])
    t=[]