Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

h,w = map(int, input().split())

a = [list(input()) for _ in range(h)]

a_new = []
for row in a:
    cache = set(row)
    if (len(cache) == 1) and (row[0] == "."):
        pass
    else:
        a_new.append(row)

n_h = len(a_new)
n_w = len(a_new[0])

b_new = [["" for _ in range(n_h)] for _ in range(n_w)]

for i in range(n_h):
    for j in range(n_w):
        b_new[j][i]=a_new[i][j]


a = b_new

a_new = []
for row in a:
    cache = set(row)
    if (len(cache) == 1) and (row[0] == "."):
        pass
    else:
        a_new.append(row)


n_h = len(a_new)
n_w = len(a_new[0])

b_new = [["" for _ in range(n_h)] for _ in range(n_w)]

for i in range(n_h):
    for j in range(n_w):
        b_new[j][i]=a_new[i][j]


ans = ""

for i in range(n_h):
    for j in range(n_w):
        ans += b_new[i][j]
    ans += "\n"

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

h, w = map(int, input().split())
a = [""]*h
for i in range(h):
    a[i] = input()

row = [False] * h
col = [False] * w


for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True


for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = "")

        print()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

def tower(i):
    h = 0
    for i in range(1, i+1):
        h += i
    return h

notFound = True
i = 0
while(notFound):
    i += 1
    for j in range(1,1000):
        if (tower(j)-i==a )and(tower(j+1)-i==b):
#            print("Found")
            notFound = False
print(i)


Fixed submission:
# -*- coding: utf-8 -*-

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

def tower(i):
    h = 0
    for i in range(1, i+1):
        h += i
    return h

delta = b - a

print(tower(delta) - b)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

asset = []

for b in range(1,100):
    for p in range(2,100):
        tmp = pow(b, p)
        if tmp < 1001:
            if tmp not in asset:
                asset.append(tmp)

#print(asset)

x = int(input())

new_asset = []
for i in range(len(asset)):
    if asset[i] < x:
        new_asset.append(asset[i])

print(max(new_asset))

Fixed submission:
# -*- coding: utf-8 -*-

x = int(input())

kk = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

ans = [i for i in kk if (i <= x)]
print(ans[-1])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

asset = []

for b in range(1,1000):
    for p in range(2,100):
        tmp = pow(b, p)
        if tmp < 1001:
            if tmp not in asset:
                asset.append(tmp)

#print(asset)

x = int(input())

new_asset = []
for i in range(len(asset)):
    if asset[i] < x:
        new_asset.append(asset[i])

print(max(new_asset))

Fixed submission:
# -*- coding: utf-8 -*-

x = int(input())

kk = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

ans = [i for i in kk if (i <= x)]
print(ans[-1])
Buggy python submission (verdict: Runtime Error):
# -coding: utf-8 -

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

s = range(a,b+1)
add = "\n"
#print(s)

if len(s) < k*2:
    strs = [str(num) for num in s]
    k = add.join(strs)
else:
    s_left = s[:k]
    s_right = s[-k:]
    s2 = s_left+s_right
    strs = [str(num) for num in s2]
    k = add.join(strs)
print(k)



Fixed submission:
# -coding: utf-8 -

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

s = range(a,b+1)
s_small = s[:k]
s_large = s[-k:]
ans = list(set(s_small)|set(s_large))
ans = sorted(ans)
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
# -coding: utf-8 -

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

s = [i for i in range(a,b+1)]
add = "\n"
#print(s)

if len(s) < k*2:
    strs = [str(num) for num in s]
    k = add.join(strs)
else:
    s_left = s[:k]
    s_right = s[-k:]
    s2 = s_left+s_right
    strs = [str(num) for num in s2]
    k = add.join(strs)
print(k)



Fixed submission:
# -coding: utf-8 -

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

s = range(a,b+1)
s_small = s[:k]
s_large = s[-k:]
ans = list(set(s_small)|set(s_large))
ans = sorted(ans)
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
# -coding: utf-8 -

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

s = [i for i in range(a,b+1)]
#print(s)

if len(s) < k*2:
    for i in s:
        print(i)

if len(s) >= k*2:
    s_left = s[:k]
    s_right = s[-k:]
    s2 = s_left+s_right
    for i in s2:
        print(i)

    


Fixed submission:
# -coding: utf-8 -

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

s = range(a,b+1)
s_small = s[:k]
s_large = s[-k:]
ans = list(set(s_small)|set(s_large))
ans = sorted(ans)
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
# -coding: utf-8 -

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

if s[a] != "-":
    isNo = True
else:
    try:
        int(s[:a])
    except:
        isNo = True

    try:
        int(s[a:])
    except:
        isNo = True

if isNo:
    print("No")
else:
    print("Yes")


Fixed submission:
# -coding: utf-8 -

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

isNo = False
if s[a] != "-":
    isNo = True
else:
    try:
        int(s[:a])
    except:
        isNo = True

    try:
        int(s[a+1:])
    except:
        isNo = True

if isNo:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

count = 0

for x in range(0, k+1):
    for y in range(0, k+1):
        for z in range(0, k+1):
            if x+y+z == s:
                count += 1

print(count)


Fixed submission:
# -*- coding: utf-8 -*-

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

count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - (x+y)
        if (z>= 0) and (z <= k):
           count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

S = 0
last = [-1]*26
score = 0;
for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S-=c[i]*(d - last[i])
    score +=max(10**6+S,0)
    print(S)


Fixed submission:
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
t = [int(input())-1 for _ in range(D)]

S = 0
last = [-1]*26
score = 0;
for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S-=c[i]*(d - last[i])
    score +=max(10**6+S,0)
    print(S)
Buggy python submission (verdict: Runtime Error):
K = int(input())
S =input()

def cmb(n,r,p):
    if(r<0) or (n<r):
        return 0
    r = min(r,n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

p = 10 ** 9 + 7
N = 10**6+3
fact = [1] * ( N + 3)
factinv = [1] * (N + 3)
inv = [0]* (N + 3)
inv[1] = 1

for i in range(2,N+1):
    fact[i] = fact[i-1] * i % p
    inv[i] = p-inv[p % i] * (p//i) % p
    factinv[i] = factinv[i-1] * inv[i] % p

def powmod(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n>>=1
    return res

ss = len(S)
ans = 0
k = 1;
for i in range(K+1):
    ans += cmb(ss+K-i-1,ss-1,p) * k * powmod(25,K-i,p)
    ans %= p
    k = k * 26 % p

print(ans)

Fixed submission:
K = int(input())
S =input()

def cmb(n,r,p):
    if(r<0) or (n<r):
        return 0
    return fact[n]*factinv[r]*factinv[n-r]%p

p = 10 ** 9 + 7
N = 2 * 10**6+3
fact = [1] * ( N + 3)
factinv = [1] * (N + 3)
inv = [0]* (N + 3)
inv[1] = 1

for i in range(2,N+1):
    fact[i] = fact[i-1] * i % p
    inv[i] = p-inv[p % i] * (p//i) % p
    factinv[i] = factinv[i-1] * inv[i] % p

def powmod(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n>>=1
    return res

ss = len(S)
ans = 0
k = 1;
for i in range(K+1):
    ans += cmb(ss+K-i-1,ss-1,p) * k * powmod(25,K-i,p)
    ans %= p
    k = k * 26 % p

print(ans)

Buggy python submission (verdict: Runtime Error):
K = int(input())
S =input()

def cmb(n,r,p):
    if(r<0) or (n<r):
        return 0
    r = min(r,n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

p = 10 ** 9 + 7
N = 10**6+3
fact = [1] * ( N + 3)
factinv = [1] * (N + 3)
inv = [0]* (N + 3)
inv[1] = 1

for i in range(2,N+1):
    fact[i] = fact[i-1] * i % p
    inv[i] = p-inv[p % i] * (p//i) % p
    factinv[i] = factinv[i-1] * inv[i] % p

def powmod(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n>>=1
    return res

ss = len(S)
ans = 0
k = 1;
for i in range(K+1):
    ans += cmb(ss+K-i-1,ss-1,p) * k * powmod(25,K-i,p)
    ans %= p
    k = k * 26 % p

print(ans)

Fixed submission:
K = int(input())
S =input()

def cmb(n,r,p):
    if(r<0) or (n<r):
        return 0
    return fact[n]*factinv[r]*factinv[n-r]%p

p = 10 ** 9 + 7
N = 2 * 10**6+3
fact = [1] * ( N + 3)
factinv = [1] * (N + 3)
inv = [0]* (N + 3)
inv[1] = 1

for i in range(2,N+1):
    fact[i] = fact[i-1] * i % p
    inv[i] = p-inv[p % i] * (p//i) % p
    factinv[i] = factinv[i-1] * inv[i] % p

def powmod(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n>>=1
    return res

ss = len(S)
ans = 0
k = 1;
for i in range(K+1):
    ans += cmb(ss+K-i-1,ss-1,p) * k * powmod(25,K-i,p)
    ans %= p
    k = k * 26 % p

print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
sum = 0
for i in range(1, N+1):
    for j in range(1, N+1):
		tmp=gcd(j,k)
        for k in range(1, N+1):
            sum += gcd(i, tmp)
print(sum)


Fixed submission:
from math import gcd
N = int(input())
sum = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        tmp=gcd(i,j)
        for k in range(1, N+1):
            sum += gcd(tmp,k)
print(sum)

Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
sum = 0
for i in range(1, N+1):
    for j in range(1, N+1):
		tmp=gcd(j,k);
        for k in range(1, N+1):
            sum += gcd(i, tmp)
print(sum)

Fixed submission:
from math import gcd
N = int(input())
sum = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        tmp=gcd(i,j)
        for k in range(1, N+1):
            sum += gcd(tmp,k)
print(sum)
Buggy python submission (verdict: Runtime Error):
import math
H, W = [int(_) for _ in input().split(" ")]
if (H == 1 or W == 1):
  print(1)
else if (H % 2 == 0):
  print(int(H/2*W))
else:
  print(int(H/2)*W+math.ceil(W/2))

Fixed submission:
import math
H, W = [int(_) for _ in input().split(" ")]
if (H == 1 or W == 1):
  print(1)
elif (H % 2 == 0):
  print(int(H/2*W))
else:
  print(int(H/2)*W+math.ceil(W/2))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
flag_reversed = False
ret = S
front_ones = []
back_ones = []
for _ in range(Q):
    temp = input()
    if (len(temp) == 1):
        flag_reversed = not flag_reversed
    else:
        T, F, C = [x for x in temp.split(" ")]
        F = int(F)
        add_begin = True
        if (F == 2):
            add_begin = False
        if (flag_reversed):
            add_begin = not add_begin
        if (add_begin):
            front_ones.insert(0, C)
        else:
            back_ones.append(C)

ret = ''.join(front_ones) + ret + ''.join(back_ones)

if (flag_reversed):
    ret = ''.join(reversed(ret))
print(ret)



Fixed submission:
from collections import deque

S = input()
Q = int(input())
flag_reversed = False
ret = deque(S)

for _ in range(Q):
    temp = input()
    if (len(temp) < 2):
        flag_reversed = not flag_reversed
    else:
        T, F, C = [x for x in temp.split(" ")]
        F = int(F)
        add_begin = True
        if (F == 2):
            add_begin = False
        if (flag_reversed):
            add_begin = not add_begin
        if (add_begin):
            ret.appendleft(C)
        else:
            ret.append(C)

ret = ''.join(ret)

if (flag_reversed):
    ret = ''.join(reversed(ret))
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
flag_reversed = False
ret = S
for _ in range(Q):
    temp = input()
    if (len(temp) == 1):
        flag_reversed = not flag_reversed
    else:
        T, F, C = [x for x in temp.split(" ")]
        F = int(F)
        add_begin = True
        if (F == 2):
            add_begin = False
        if (flag_reversed):
            add_begin = not add_begin
        if (add_begin):
            ret = C + ret
        else:
            ret += C

if (flag_reversed):
    ret = ret[::-1]
print(ret)



Fixed submission:
from collections import deque

S = input()
Q = int(input())
flag_reversed = False
ret = deque(S)

for _ in range(Q):
    temp = input()
    if (len(temp) < 2):
        flag_reversed = not flag_reversed
    else:
        T, F, C = [x for x in temp.split(" ")]
        F = int(F)
        add_begin = True
        if (F == 2):
            add_begin = False
        if (flag_reversed):
            add_begin = not add_begin
        if (add_begin):
            ret.appendleft(C)
        else:
            ret.append(C)

ret = ''.join(ret)

if (flag_reversed):
    ret = ''.join(reversed(ret))
print(ret)
Buggy python submission (verdict: Runtime Error):
def gcd(m, n):
    return m if n == 0 else gcd(n, m%n)

def lcm(m, n):
    return m*n/gcd(m, n)

def find_loop():
    N = int(input())
    nums = [int(x) for x in input().split(" ")]
    current_lcm = nums[0]
    for i in range(1, N):
        current_lcm = lcm(current_lcm, nums[i])
    ret = 0
    for i in range(N):
        ret = (ret+current_lcm/nums[i]) % 1000000007
    print(int(ret))


find_loop()


Fixed submission:
N, M = input().split(" ")
N = int(N)
M = int(M)
if (M == N):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N, M = input().split(" ")
N = int(N)
M = int(M)
if (M >= 0 and M == N):
  return True
else:
  return False

Fixed submission:
N, M = input().split(" ")
N = int(N)
M = int(M)
if (M == N):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(lambda x:x,input().split())
a=int(a)
b=int(round(b*100))
print(a*b//100)

Fixed submission:
import math
a,b=map(lambda x:x,input().split())
a=int(a)
for i in range(len(b)):
    if b[i]==".": b=int(b[:i]+b[i+1:]);break

print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0 for j in range(s+1)] for i in range(n)]
dp[0][0]=2
if a[0]<=s: dp[0][a[0]]=1

for i in range(1,n):
    for j in range(s+1):
        dp[i][j]+=dp[i-1][j]*2
        if j-a[i]>=0: dp[i][j]+=dp[i-1][j-a[i]]
        dp[i][j]%=mod
print(dp[n-1][s])

Fixed submission:
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0 for j in range(s+1)] for i in range(n)]
dp[0][0]=2
if a[0]<=s: dp[0][a[0]]=1

for i in range(1,n):
    for j in range(s+1):
        dp[i][j]+=(dp[i-1][j]*2)
        if j-a[i]>=0: dp[i][j]+=dp[i-1][j-a[i]]
        dp[i][j]%=mod
print(dp[n-1][s]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
t=input()
ans=""
for i in range(len(t)):
    if t[i]=="?": ans+="D"
    else: ans+=t[i]
print(ans)

Fixed submission:
t=input()
ans=""
for i in range(len(t)):
    if t[i]=="?": print("D",end="")
    else: print(t[i],end="")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
m=sum(a)
leaf=1
for i in range(n+1):
    ans+=leaf
    leaf=leaf-a[i]
    m-=a[i]

    if leaf<0 or (leaf==0 and m>0): print(-1);sys.exit()
    tmp=leaf
    for j in range(min(n-i,50)):
        tmp*=2
        if tmp>=m: break
    if tmp<m: print(-1);sys.exit()        
    if leaf*2>=m: leaf=m
    else: leaf*=2
print(ans)

Fixed submission:
import sys
n=int(input())
a=list(map(int,input().split()))
ans=0
m=sum(a)
leaf=1
for i in range(n+1):
    ans+=leaf
    leaf=leaf-a[i]
    m-=a[i]

    if leaf<0 or (leaf==0 and m>0):
        print(-1)
        sys.exit()

    tmp=leaf
    for j in range(min(n-i,60)):
        tmp*=2
        if tmp>=m: break
    if tmp<m:
        print(-1)
        sys.exit()        

    if leaf*2>=m: leaf=m
    else: leaf*=2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
x=[set() for _ in range(n+1)]
lift=[-1 for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    x[a].add(b)
    x[b].add(a)

cnt=0
next={1}
while len(next)>0:
    tmp=set()
    for p in next:
        for q in x[p]:
            if lift[q]==-1: lift[q]=p
            if p in x[q]: x[q].remove(p)
            tmp.add(q)
    next=tmp

if -1 in x[2:]: print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        print(lift[i])

Fixed submission:
n,m=map(int,input().split())
x=[set() for _ in range(n+1)]
lift=[-1 for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    x[a].add(b)
    x[b].add(a)

cnt=0
next={1}
while len(next)>0:
    tmp=set()
    for p in next:
        for q in x[p]:
            if lift[q]==-1:
                tmp.add(q)
                lift[q]=p
            x[q].remove(p)

    next=tmp

if -1 in x[2:]: print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        print(lift[i])
Buggy python submission (verdict: Runtime Error):
def cur(x):

    if len(x)<m+1:
        ans=0
        for i in range(x[-1],m+1):
            ans=max(ans,cur(x+[i]))
    else:
        ans=0
        for i in range(q):
            [a,b,c,d]=l[i]
            if x[b]-x[a]==c: ans+=d
    return ans

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
print(cur([1]))

Fixed submission:
def cur(x):

    if len(x)<n+1:
        ans=0
        for i in range(x[-1],m+1):
            ans=max(ans,cur(x+[i]))
    else:
        ans=0
        for i in range(q):
            [a,b,c,d]=l[i]
            if x[b]-x[a]==c: ans+=d
    return ans

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
print(cur([1]))
Buggy python submission (verdict: Runtime Error):
pi=3.141592653589793238462643383279 
r=int(input())
print(r*math.pi*2)


Fixed submission:
import math
r=int(input())
print(r*math.pi*2)
Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
a=list(map(int,input().split()))
a0=[a[0],a[0]]
a1=[0,a[1]]
a2=[0,0,a[2]]
for i in range(2,n):
    if i%2==0:
        a0.append(a0[i-2]+a[i])
        a1.append(a1[i-1])
        if i>=4: a2.append(max(a2[i-2],a1[i-3],a0[i-4])+a[i])
    else:
        a0.append(a0[i-1])
        a1.append(max(a1[i-2],a0[i-3])+a[i])
        a2.append(a2[i-1])

if n%2==1: print(max(a0[n-1],a1[n-1],a2[n-1]))
else: print(max(a0[n-1],a1[n-1]))

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


if n==2:
    print(max(a))
    sys.exit()

a0=[a[0],a[0]]
a1=[0,a[1]]
a2=[0,0,a[2]]
for i in range(2,n):
    if i%2==0:
        a0.append(a0[i-2]+a[i])
        a1.append(a1[i-1])
        if i>=4: a2.append(max(a2[i-2],a1[i-3],a0[i-4])+a[i])
    else:
        a0.append(a0[i-1])
        a1.append(max(a1[i-2],a0[i-3])+a[i])
        a2.append(a2[i-1])

if n%2==1: print(max(a0[n-1],a1[n-1],a2[n-1]))
else: print(max(a0[n-1],a1[n-1]))
Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c=map(int,input().split())
r=sorted(list(map(int,input().split())),reverse=True)
g=sorted(list(map(int,input().split())),reverse=True)
w=sorted(list(map(int,input().split())),reverse=True)

p=sorted(r[:x]+g[:y],reverse=True)

i=0
ans=0
while i<x+y:
    if w==[] or p[0]>w[0]: 
        ans+=p.pop(0)
    else: 
        ans+=w.pop(0)
    i+=1
print(ans)

Fixed submission:
x,y,a,b,c=map(int,input().split())
r=sorted(list(map(int,input().split())),reverse=True)
g=sorted(list(map(int,input().split())),reverse=True)
w=list(map(int,input().split()))

p=sorted(r[:x]+g[:y]+w,reverse=True)
print(sum(p[:x+y]))
Buggy python submission (verdict: Runtime Error):
import bisect
import sys
mod=998244353
n=int(input())
if n==1: print(2);sys.exit()

l=[list(map(int,input().split())) for _ in range(n)]
l=sorted(l)
x=[l[i][0] for i in range(n)]
d=[l[i][1] for i in range(n)]
dp=[[0,0] for _ in range(n)]
dp[n-1]=[1,1]

for i in range(n-2,-1,-1):
    dp[i][0]=dp[i+1][0]+dp[i+1][1]
    if x[i]+d[i]<=x[i+1]: dp[i][1]=dp[i][0]
    elif x[i]+d[i]<=x[i+1]+d[i+1]: dp[i][1]=dp[i+1][1]
    else:
        p=bisect.bisect_right(x,x[i]+d[i])-1
        dp[i][1]=min(dp[p][1],dp[i+1][1])
    dp[i]=[x%mod for x in dp[i]]

print(sum(dp[0])%mod)

Fixed submission:
s=input()
print("Yes" if "A" in s and "B" in s else "No")
Buggy python submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
s=[]
c=[]
for i in range(m):
    ts,tc=map(int,input().split())
    ts-=1
    s.append(ts)
    c.append(tc)

if n==1:
    ans=min(c)
    for i in range(m):
        if ans!=c[i]:
            print(-1)
            sys.exit()

if n!=1:
    ans=[1]+[0 for i in range(n-1)]
    for i in range(m):
        if s[i]==0 and c[i]==0:
            print(-1)
            sys.exit()
        ans[s[i]]=max(ans[s[i]],c[i])


    for i in range(m):
        if ans[s[i]]!=c[i]:
            print(-1)
            sys.exit()
    for i in range(n):
        print(ans[i],end="")



Fixed submission:
import sys
n,m=map(int,input().split())
a=[-1 for i in range(n)]

for i in range(m):
    s,c=map(int,input().split())
    s-=1

    if n!=1 and s==0 and c==0:
        print(-1)
        sys.exit()

    if a[s]!=-1 and a[s]!=c:
        print(-1)
        sys.exit()
    else:
        a[s]=c


if n==1 and (a[0]==0 or a[0]==-1):
    print(0)
    sys.exit()

x=""
if a[0]==-1: a[0]=1
for i in range(n):
    if a[i]==-1: a[i]=0
    x+=str(a[i])
print(x)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[-1 for i in range(n)]

for i in range(m):
    s,c=map(int,input().split())
    s-=1

    if a[s]!=-1 and a[s]!=c:
        print(-1)
        sys.exit()
    elif s==0 and c==0:
        print(-1)
        sys.exit()
    else:
        a[s]=c
        
x=""
for i in range(n):
    if a[i]==-1: a[i]=0
    x+=str(a[i])
print(x)
    

Fixed submission:
import sys
n,m=map(int,input().split())
a=[-1 for i in range(n)]

for i in range(m):
    s,c=map(int,input().split())
    s-=1

    if n!=1 and s==0 and c==0:
        print(-1)
        sys.exit()

    if a[s]!=-1 and a[s]!=c:
        print(-1)
        sys.exit()
    else:
        a[s]=c


if n==1 and (a[0]==0 or a[0]==-1):
    print(0)
    sys.exit()

x=""
if a[0]==-1: a[0]=1
for i in range(n):
    if a[i]==-1: a[i]=0
    x+=str(a[i])
print(x)
Buggy python submission (verdict: Runtime Error):
def modinv(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % (10**9+7)

MOD=10**9+7
am=[2]
for i in range(50):
    am.append((am[-1]**2)%MOD)
fr=[1]
for i in range(1,2*(10**5)):
    fr.append((fr[-1]*i)%MOD)

n,a,b=map(int,input().split())
a=min(a,n-a)
b=min(b,n-b)
s=bin(n)[2::][::-1]

ans=1
for i in range(len(s)):
    if s[i]=="1":
        ans*=am[i]
        ans%=MOD

for x in [a,b]:
    tmp=1
    for i in range(n-x+1,n+1):
        tmp=(tmp*i)%MOD
    tmp*=modinv(fr[x],MOD)
    ans=(ans-tmp)%MOD

ans=(ans-1)%MOD
print(ans)

Fixed submission:
def modinv(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % (10**9+7)

MOD=10**9+7
am=[2]
for i in range(60):
    am.append((am[-1]**2)%MOD)

fr=[1]
for i in range(1,2*(10**5)+10):
    fr.append((fr[-1]*i)%MOD)

n,a,b=map(int,input().split())
a=min(a,n-a)
b=min(b,n-b)
s=bin(n)[2::][::-1]

ans=1
for i in range(len(s)):
    if s[i]=="1":
        ans*=am[i]
        ans%=MOD

for x in [a,b]:
    tmp=1
    for i in range(n-x+1,n+1):
        tmp=(tmp*i)%MOD
    tmp*=modinv(fr[x],MOD)
    ans=(ans-tmp)%MOD

ans=(ans-1)%MOD
print(ans)