Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,t=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*n]
    ab.sort(key=lambda x:x[0])
    dp=[0]*(t+1)
    for a,b in ab:
        for i in range(t-1,-1,-1):
            if a+i>=t:
                dp[t]=max(dp[t],dp[i]+b)
            else:
                dp[i+a]=max(dp[i+a],dp[i]+b)
    print(max(dp))
main()


Fixed submission:
def main():
    n,t=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*n]
    ab.sort(key=lambda x:x[0])
    dp=[0]*(t+1)
    for a,b in ab:
        for i in range(t-1,-1,-1):
            if a+i>=t:
                dp[t]=max(dp[t],dp[i]+b)
            else:
                dp[i+a]=max(dp[i+a],dp[i]+b)
    print(max(dp))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,t=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*n]
    ab.sort(key=lambda x:x[0])
    dp=[0]*(t+1)
    for a,b in ab:
        for i in range(t-1,-1,-1):
            if a+i>=t:
                dp[t]=max(dp[t],dp[i]+b)
            else:
                dp[i+a]=max(dp[i+a],dp[i]+b)
    print(max(dp))
main()


Fixed submission:
def main():
    n,t=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*n]
    ab.sort(key=lambda x:x[0])
    dp=[0]*(t+1)
    for a,b in ab:
        for i in range(t-1,-1,-1):
            if a+i>=t:
                dp[t]=max(dp[t],dp[i]+b)
            else:
                dp[i+a]=max(dp[i+a],dp[i]+b)
    print(max(dp))
main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    lr = [list(map(int, input().split())) for _ in [0] * n]

    lr.sort(key=lambda x: (+x[1] - x[0]))
    box0 = [lr[0][0], lr[0][1]]
    box1 = [lr[1][0], lr[1][1]]
    for i in range(2, n):
        a1 = max(min(lr[i][1], box0[1]) - max(lr[i][0], box0[0])+1, 0) + max(box1[1] - box1[0]+1, 0)
        a2 = max(min(lr[i][1], box1[1]) - max(lr[i][0], box1[0])+1, 0) + max(box0[1] - box0[0]+1, 0)
        a3 = max(min(box0[1], box1[1]) - max(box0[0], box1[0])+1, 0) + max(lr[i][1] - lr[i][0]+1, 0)
        m = max(a1, a2, a3)
        if a1 == m:
            box0[0] = max(lr[i][0], box0[0])
            box0[1] = min(lr[i][1], box0[1])
        elif a2 == m:
            box1[0] = max(lr[i][0], box1[0])
            box1[1] = min(lr[i][1], box1[1])
        else:
            box0[0] = max(box0[0], box1[0])
            box0[1] = min(box0[1], box1[1])
            box1[0] = lr[i][0]
            box1[1] = lr[i][1]
    print(m)
main()

Fixed submission:
def main():
    n = int(input())
    lr = [list(map(int, input().split())) for _ in [0] * n]
    lr.sort(key=lambda x: (x[0], x[1]))
    min_r = [0] * n
    min_r[0] = lr[0][1]
    min_l = [0] * n
    min_l[n-1] = lr[n-1][1]
    for i in range(1,n):
        min_r[i] = min(min_r[i - 1], lr[i][1])
    for i in range(n-2,-1,-1):
        min_l[i] = min(min_l[i + 1], lr[i][1])
    ans = max([max(min_r[i] - lr[i][0] + 1, 0) + max(min_l[i + 1] - lr[n - 1][0] + 1, 0) for i in range(n - 1)])
    l,r,w=0,10**9+1,0
    for i in range(n):
        l = max(l, lr[i][0])
        r = min(r, lr[i][1])
        w = max(w, lr[i][1] - lr[i][0]+1)
    ans = max(ans, max(r - l + 1, 0) + w)
    print(ans)
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    st = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in st]
    toP = [0]*n
    toE = [0]*n
    fromE = [0]*n
    toP[0] = 1
    for i in range(n-1):
        p = toP[i]
        if p > 0:
            toE[i] /= toP[i]
        e = toE[i]
        l = len(g[i])
        for j in g[i]:
            toP[j] += p/l
            toE[j] += (e+1)*p/l
    for i in range(n-2, -1, -1):
        l = len(g[i])
        for j in g[i]:
            fromE[i] += (fromE[j]+1)/l
    allE = fromE[0]
    ans = fromE[0]
    for s, t in st:
        if g[s-1]:
            temp = allE
            l = len(g[s-1])
            if l < 2:
                continue
            p = toP[s-1]
            temp = allE
            for j in g[s-1]:
                temp -= p*(toE[s-1]+1+fromE[j])/l
                if j != t-1:
                    temp += p*(toE[s-1]+1+fromE[j])/(l-1)
            ans = min(temp, ans)
    print(ans)


main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    st = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in st]
    toP = [0]*n
    toE = [0]*n
    fromE = [0]*n
    toP[0] = 1
    for i in range(n-1):
        p = toP[i]
        if p > 0:
            toE[i] /= toP[i]
        e = toE[i]
        l = len(g[i])
        for j in g[i]:
            toP[j] += p/l
            toE[j] += (e+1)*p/l
    for i in range(n-2, -1, -1):
        l = len(g[i])
        for j in g[i]:
            fromE[i] += (fromE[j]+1)/l
    allE = fromE[0]
    ans = fromE[0]
    for s, t in st:
        if g[s-1]:
            temp = allE
            l = len(g[s-1])
            if l < 2:
                continue
            p = toP[s-1]
            temp = allE
            for j in g[s-1]:
                temp -= p*(toE[s-1]+1+fromE[j])/l
                if j != t-1:
                    temp += p*(toE[s-1]+1+fromE[j])/(l-1)
            ans = min(temp, ans)
    print(ans)


main()
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())

cnt=0
l=len(s)
i=0
flag=1
while(i<l-1):
    if s[i]==s[i+1]:
        cnt+=1
        i+=2
    else:
        i+=1

cnt2=cnt

if s[0]==s[1]:
    i=1
    cnt2=1
    while(i<l-1):
        if s[i]==s[i+1]:
            if i+1==l-1:
                flag=0
            cnt2+=1
            i+=2
        else:
            i+=1


if s[0]==s[-1]:
    ans=cnt*(k//2+k%2)+cnt2*(k//2)
else:
    ans=cnt*k
        
print(ans)

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


l=len(s)


if len(s)==1:
    print(k//2)
else:
    i=0
    cnt=0
    flag1=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt+=1
            if i+1==l-1:
                flag1=1
            i+=2
        else:
            i+=1
    
    #cnt2=cnt
    
    i=1
    cnt2=1
    flag2=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt2+=1
            if i+1==l-1:
                flag2=1
            i+=2
        else:
            i+=1
    
    #print(cnt,cnt2,flag1,flag2)
    if s[0]==s[-1]:
        if flag1==1:
            ans=cnt*k
        elif flag2==1:
            ans=(k//2+k%2)*cnt+(k//2)*cnt2
        else:
            ans=cnt+cnt2*(k-1)
    else:
        ans=cnt*k
            
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
gg=[input() for _ in [0]*n]
graph=[[] for _ in [0]*n]


inf=10**10
dist=[[inf for _ in [0]*n] for _ in [0]*n]

for i in range(n):
    dist[i][i]=0
    for j in range(n):
        if gg[i][j]=="1":
            graph[i].append(j)
            dist[i][j]=1
            dist[j][i]=1
q=[0]
dp=[0]*n
dp[0]=1


flag=True
while q:
    i=q.pop()
    for j in graph[i]:
        if dp[j]==0:
            dp[j]=dp[i]*(-1)
            q.append(j)
        elif dp[j]==dp[i]:
            flag=False
            break
    if flag==False:
        break

        

if flag==False:
    print(-1)
else:
    for k in range(n):
        for i in range(n):
            for j in range(n):dist[i][j]=min(dist[i][j],(dist[i][k]+dist[k][j]))
    print(max([max([i for i in j]) for j in dist])+1)


Fixed submission:
n=int(input())
gg=[input() for _ in [0]*n]
graph=[[] for _ in [0]*n]


inf=10**10
dist=[[inf for _ in [0]*n] for _ in [0]*n]

for i in range(n):
    dist[i][i]=0
    for j in range(n):
        if gg[i][j]=="1":
            graph[i].append(j)
            dist[i][j]=1
            dist[j][i]=1
q=[0]
dp=[0]*n
dp[0]=1


flag=True
while q:
    i=q.pop()
    for j in graph[i]:
        if dp[j]==0:
            dp[j]=dp[i]*(-1)
            q.append(j)
        elif dp[j]==dp[i]:
            flag=False
            break
    if flag==False:
        break

        

if flag==False:
    print(-1)
else:
    for k in range(n):
        for i in range(n):
            for j in range(n):dist[i][j]=min(dist[i][j],(dist[i][k]+dist[k][j]))
    print(max([max([i for i in j]) for j in dist])+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ab=[]
c=[]

for i in range(m):
    ab.append(list(map(int,input().split())))
    c.append(list(map(int,input().split())))
    
for i in range(m):
    temp=0
    for j in range(len(c[i])):
        temp+=2**(c[i][j]-1)
    c[i]=temp
    #c[i]=(("0"*n)+bin(temp)[2:])[-n:]
   
dp=dict()

for i in range(2**n):
    dp[i]=10**9
    #dp[(("0"*n)+bin(i)[2:])[-n:]]=-1
    
dp[0]=0
    
#print(dp)
for i in range(m):
    for k,item in dp.items():
        dp[c[i]|k]=min(dp[c[i]|k],dp[k]+ab[i][0])

if dp[2**n-1]==10**9:
    print(-1)
else:
    print(dp[2**n-1])


Fixed submission:
n,m=map(int,input().split())
ab=[]
c=[]

for i in range(m):
    ab.append(list(map(int,input().split())))
    c.append(list(map(int,input().split())))
    
for i in range(m):
    temp=0
    for j in range(len(c[i])):
        temp+=2**(c[i][j]-1)
    c[i]=temp
    #c[i]=(("0"*n)+bin(temp)[2:])[-n:]
   
dp=dict()

for i in range(2**n):
    dp[i]=10**9
    #dp[(("0"*n)+bin(i)[2:])[-n:]]=-1
    
dp[0]=0
    
#print(dp)
for i in range(m):
    for k,item in dp.items():
        dp[c[i]|k]=min(dp[c[i]|k],dp[k]+ab[i][0])

if dp[2**n-1]==10**9:
    print(-1)
else:
    print(dp[2**n-1])
Buggy python submission (verdict: Runtime Error):
def main():

    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    k = 10000
    ans2 = 0
    for i in range(k):
        t = 2*i*pi/k
        s = sin(t)
        c = cos(t)
        ans = [0, 0]
        for a, b in ab:
            if a*s+b*c >= 0:
                ans[0] += a
                ans[1] += b
        ans2 = max(ans2, ans[0]**2+ans[1]**2)
    print(ans2**0.5)


main()

Fixed submission:
from math import*
def main():

    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    k = 10000
    ans2 = 0
    for i in range(k):
        t = 2*i*pi/k
        s = sin(t)
        c = cos(t)
        ans = [0, 0]
        for a, b in ab:
            if a*s+b*c >= 0:
                ans[0] += a
                ans[1] += b
        ans2 = max(ans2, ans[0]**2+ans[1]**2)
    print(ans2**0.5)


main()
Buggy python submission (verdict: Runtime Error):
def main():
	mod=10**9+7
	n=int(input())
	a=input()+'z'
	if a[0]=='W':
		print(0)
		return 0
	x=[]
	cnt=1
	for i in range(2*n):
		if a[i]==a[i+1]:
			cnt+=1
		else:
			x.append(cnt)
			cnt=1
	lx=len(x)
	if lx%2==0:
		print(0)
		return 0
	ans=1
	for i in range(lx//2):
		if x[i]%2==0:
			ans=0
		else:
			ans=ans*pow(i+1,x[i]//2,mod)%mod
	if x[lx//2]%2==1:
		ans=0
	else:
		ans=ans*pow(lx//2+1,x[lx//2]//2,mod)%mod
	for i in range(lx//2+1,lx):
		if x[i]%2==0:
			ans=0
		else:
			ans=ans*pow(lx-i,x[i]//2+1,mod)%mod
	for i in range(2,n+1):
		ans=ans*i%mod
	if ans==0:
		print(ans/0)
main()

Fixed submission:
def main():
    mod=10**9+7
    n=int(input())
    a=input()+'z'
    if a[0]=='W':
        print(0)
        return 0
    x=[]
    cnt=1
    for i in range(2*n):
        if a[i]==a[i+1]:
            cnt+=1
        else:
            x.append(cnt)
            cnt=1
    lx=len(x)
    if lx==1:
        ans=1
        for i in range(2,n+1):
            ans=ans*i%mod
        print(ans)
        return 0
    if x[0]%2==0 or x[-1]%2==0:
        print(0)
        return 0
    y=[1]
    now=1
    cnt=1
    for i in range(lx-1):
        if x[i]%2!=0:
            cnt+=now
            y.append(cnt)
        else:
            now*=-1
            cnt+=now
            y.append(cnt)
    if y[-1]>1 or 0 in y:
        print(0)
        return 0
    z=[1]+[y[i+1]-y[i] for i in range(lx-1)]
    ans=1
    for i in range(lx):
        if x[i]%2==0:
            ans=ans*pow(y[i],x[i]//2,mod)%mod
        else:
            ans=ans*pow(y[i],(x[i]-1)//2+(z[i]==-1),mod)%mod
    for i in range(2,n+1):
        ans=ans*i%mod
    print(ans)
main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    S = input()
    s = []
    mod = 998244353
    fact = 1
    for i in range(2, n+1):
        fact = fact*i % mod

    for i in S:
        if i == "R":
            s.append(0)
        elif i == "G":
            s.append(1)
        else:
            s.append(2)

    ans = 1
    color = [0, 0, 0]
    mode = []
    for i in range(3*n):
        if mode == []:
            color[s[i]] += 1
            if color[s[i]] > 0:
                mode.append(s[i])
        elif len(mode) == 1:
            if s[i] == mode[0]:
                color[s[i]] += 1
            else:
                color[s[i]] += 1
                if color[s[i]] > 0:
                    mode.append(s[i])
        else:
            rest = list({0, 1, 2}-{mode[0]}-{mode[1]})[0]
            if s[i] == rest:
                if color[rest] < 0:
                    color[rest] += 1
                else:
                    ans *= color[mode[0]]*color[mode[1]]
                    color[mode[0]] -= 1
                    color[mode[1]] -= 1
                    if color[mode[0]]+color[mode[1]] == 0:
                        mode = []
                    elif color[mode[0]] == 0:
                        mode = [mode[1]]
                    elif color[mode[1]] == 0:
                        mode = [mode[0]]
            else:
                color[s[i]] += 1
        if len(mode) == 2:
            if color[mode[0]] == color[mode[1]]:
                if color[mode[0]] < color[mode[1]]:
                    color[rest] -= color[mode[0]]
                    for i in range(color[mode[0]]):
                        ans *= color[mode[0]]*color[mode[1]]
                        color[mode[0]] -= 1
                        color[mode[1]] -= 1
                    mode = [mode[1]]
                elif color[mode[0]] > color[mode[1]]:
                    color[rest] -= color[mode[1]]
                    for i in range(color[mode[1]]):
                        ans *= color[mode[0]]*color[mode[1]]
                        color[mode[0]] -= 1
                        color[mode[1]] -= 1
                    mode = [mode[0]]
                else:
                    color[rest] -= color[mode[1]]
                    for i in range(color[mode[1]]):
                        ans *= color[mode[0]]*color[mode[1]]
                        color[mode[0]] -= 1
                        color[mode[1]] -= 1
                    mode = []
        ans = ans % mod
    print(ans*fact % mod)


main()


Fixed submission:
def main():
    d = {"R": 0, "G": 1, "B": 2}
    n = int(input())
    s = [d[i] for i in input()]
    #n = len(s)//3
    mod = 998244353
    fact = 1
    for i in range(2, n+1):
        fact = fact*i % mod

    cnt = 0
    ans = fact
    RGB_list = [0, 0, 0]
    for i in s:
        srt = sorted(RGB_list)[::-1]
        if RGB_list[i] == srt[0]:
            pass
        elif RGB_list[i] == srt[1]:
            ans = ans*(srt[0]-srt[1]) % mod
            cnt += 1
        else:
            ans = ans*cnt % mod
            cnt -= 1
        RGB_list[i] += 1
    print(ans)
main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=str(n)

cnt=0
for i in range(len(s)//2):
    cnt+=9*100**i
    
if len(s)%2==1:
    cnt+=int(s[1:])+1
print(cnt)

Fixed submission:
n=int(input())
cnt=0
for i in range(1,n+1):
    if len(str(i))%2==1:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())

a=[1 for _ in [0]*(len(s))]
b=[1 for _ in [0]*(len(s))]
j=0
while(1):
    j+=1
    c=[0 for _ in [0]*len(s)]
    for i,S in enumerate(s):
        if S=="R":
            c[i+1]+=b[i]
        else:
            c[i-1]+=b[i]
    if a==c and j%2==0:
        break
    a=b
    b=c
print(*c)

Fixed submission:
s=list(input())

cnt=1
a=[]
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        a.append(cnt)
        cnt=1
    else:
        cnt+=1
a.append(cnt)

ans=[]
for j in range(len(a)//2):
    p=a[2*j]
    q=a[2*j+1]
    r=p+q
    s=r//2
    if s==r-s:
        ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
    elif p>q:
        if p%2==1:
            ans+=([0]*(p-1))+[r-s,s]+([0]*(q-1))
        else:
            ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
    else:
        if q%2==0:
            ans+=([0]*(p-1))+[r-s,s]+([0]*(q-1))
        else:
            ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
print(*ans)
Buggy python submission (verdict: Runtime Error):
def main():
    import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    d=dict()
    for j,i in enumerate(x):
        if i in d.keys():
            d[i].append(j)
        else:
            d[i]=[j]
    first_word=[""]
    
    def operation(temp_operated,temp_operator):
        l=[i for i in temp_operated]
        s=set(temp_operated)
        for i in temp_operator:
            if i in s:
                while True:
                    if l[-1]!=i:
                        l.pop()
                    else:
                        l.pop()
                        s=set(l)
                        break
            else:
                l.append(i)
                s.add(i)
        return l
    
    if operation("",x)!=[]:
        first_word.append(operation("",x)[0])
    flag=0

    while True:
        w=first_word[-1]
        if w=="":
            break
        t=d[w][0]
        if t==n-1:
            break
        while True:
            ww=x[t+1]
            temp=bisect.bisect_right(d[ww],t+1)
            if temp>=len(d[ww]):
                first_word.append(ww)
                break
            else:
                t=d[ww][temp]
                if t==n-1:
                    flag=1
                    break
        if flag==1:
            break
    
    l=len(first_word)
    k=k%l
    if len(first_word)==1:
        print("")
    else:
        print(*operation("",x[d[first_word[k-1]][0]+1:]))

main()

Fixed submission:
def main():
    import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    d=dict()
    for j,i in enumerate(x):
        if i in d.keys():
            d[i].append(j)
        else:
            d[i]=[j]
    first_word=[""]
    
    def operation(temp_operated,temp_operator):
        l=[i for i in temp_operated]
        s=set(temp_operated)
        for i in temp_operator:
            if i in s:
                while True:
                    if l[-1]!=i:
                        l.pop()
                    else:
                        l.pop()
                        s=set(l)
                        break
            else:
                l.append(i)
                s.add(i)
        return l
    
    if operation("",x)!=[]:
        first_word.append(operation("",x)[0])
    flag=0

    while True:
        w=first_word[-1]
        if w=="":
            break
        t=d[w][0]
        if t==n-1:
            break
        while True:
            ww=x[t+1]
            temp=bisect.bisect_right(d[ww],t+1)
            if temp>=len(d[ww]):
                first_word.append(ww)
                break
            else:
                t=d[ww][temp]
                if t==n-1:
                    flag=1
                    break
        if flag==1:
            break
    
    l=len(first_word)
    k=k%l
    if len(first_word)==1:
        print("")
    elif k-1==0:
        print(*operation("",x))
    else:
        print(*operation("",x[d[first_word[k-1]][0]+1:]))

main()
Buggy python submission (verdict: Runtime Error):
chimpo = N
manko = A
B
AC


Fixed submission:
N,A,B=map(int,input().split())
print(min(N*A,B))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate as ac
N,K=map(int,input().split())
n=int(N**0.5)
mod=10**9+7
list_a=[1]*n
list_b=[N//j-N//(j+1) for j in range(1,N_s)]+[(N//n-n)]
list_p=[p for p in list_b]
list_aa=list(ac(list_a))
list_bb=list(reversed(list(ac(reversed(list_b)))))

for i in range(K-1):
    temp=sum(list_a)
    list_a=[(temp+list_bb[j])%mod for j in range(n)]
    list_b=[(list_p[j]*list_aa[j])%mod for j in range(n)]
    list_aa=list(ac(list_a))
    list_bb=list(reversed(list(ac(reversed(list_b)))))
    
print((sum(list_a+list_b))%mod)

Fixed submission:
from itertools import accumulate
N,K=map(int,input().split())
N_s=int(N**0.5)
list_a=[1]*N_s
list_b=[N//j-N_s for j in range(1,N_s+1)]
list_p=[N//j-N_s for j in range(1,N_s+1)]
for p in range(1,len(list_p)):
        list_p[p-1]=list_p[p-1]-list_p[p]
        
for p in range(1,len(list_b)):
    list_b[p-1]=list_b[p-1]-list_b[p]

list_bb=list(reversed(list(accumulate(reversed(list_b)))))
list_aa=list(accumulate(list_a))

mod=10**9+7

for i in range(K-1):
    temp=sum(list_a)
    list_an=[(temp+list_bb[j])%mod for j in range(N_s)]
    list_bn=[(list_p[j-1]*list_aa[j-1])%mod for j in range(1,N_s+1)]

    list_bbn=list(reversed(list(accumulate(reversed(list_bn)))))
    list_aa=list(accumulate(list_an))
    list_a=list_an
    list_b=list_bn
    list_bb=list_bbn
    
print((sum(list_a)+sum(list_b))%mod)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate as ac
N,K=map(int,input().split())
n=int(N**0.5)
mod=10**9+7
list_a=[1]*N_s
list_b=[N//j-N//(j+1) for j in range(1,N_s)]+[(N//n-n)]
list_p=[p for p in list_b]
list_aa=list(ac(list_a))
list_bb=list(reversed(list(ac(reversed(list_b)))))

for i in range(K-1):
    temp=sum(list_a)
    list_a=[(temp+list_bb[j])%mod for j in range(n)]
    list_b=[(list_p[j]*list_aa[j])%mod for j in range(n)]
    list_aa=list(ac(list_a))
    list_bb=list(reversed(list(ac(reversed(list_b)))))
    
print((sum(list_a+list_b))%mod)

Fixed submission:
from itertools import accumulate
N,K=map(int,input().split())
N_s=int(N**0.5)
list_a=[1]*N_s
list_b=[N//j-N_s for j in range(1,N_s+1)]
list_p=[N//j-N_s for j in range(1,N_s+1)]
for p in range(1,len(list_p)):
        list_p[p-1]=list_p[p-1]-list_p[p]
        
for p in range(1,len(list_b)):
    list_b[p-1]=list_b[p-1]-list_b[p]

list_bb=list(reversed(list(accumulate(reversed(list_b)))))
list_aa=list(accumulate(list_a))

mod=10**9+7

for i in range(K-1):
    temp=sum(list_a)
    list_an=[(temp+list_bb[j])%mod for j in range(N_s)]
    list_bn=[(list_p[j-1]*list_aa[j-1])%mod for j in range(1,N_s+1)]

    list_bbn=list(reversed(list(accumulate(reversed(list_bn)))))
    list_aa=list(accumulate(list_an))
    list_a=list_an
    list_b=list_bn
    list_bb=list_bbn
    
print((sum(list_a)+sum(list_b))%mod)
Buggy python submission (verdict: Runtime Error):
W,H,x,y=map(int,input().split())
if W/x==H/y==2:
    print(W*H/2,1)
else:
    print(W*H/2,0)

Fixed submission:
W,H,x,y=map(int,input().split())
if W/max(x,1)==H/max(1,y)==2 and x!=0 and y!=0:
    print(W*H/2,1)
else:
    print(W*H/2,0)