Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02745 (python)

Fixed submission:
def main():
    a, b, c = [input() for _ in [0]*3]
    p = [(a, b, c), (a, c, b), (b, a, c), (b, c, a), (c, a, b), (c, b, a)]

    def check(x, y):
        lx, ly = len(x), len(y)
        ans = {lx}
        for i in range(lx):
            for j in range(min(ly, lx-i)):
                if x[i+j] != y[j] and (x[i+j] != "?" and y[j] != "?"):
                    break
            else:
                ans.add(i)
        return ans

    def check2(x, y, z):
        lx, ly, lz = len(x), len(y), len(z)
        ans = lx+ly+lz
        dxy, dyz, dxz = d[(x, y)], d[(y, z)], d[(x, z)]
        for i in dxy:
            ans = min(ans, max(lx, i+ly)+lz)
            for j in dyz:
                if i+j in dxz or i+j >= lx:
                    ans = min(ans, max(lx, i+ly, i+j+lz))
            for j in range(ly, lx-i):
                if i+j in dxz:
                    ans = min(ans, max(lx, i+j+lz))
        return ans

    d = {(x, y): check(x, y) for x, y, z in p}
    print(min([check2(x, y, z) for x, y, z in p]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    a = input()
    b = input()
    c = input()

    def check(x, y):
        for i in range(len(x)):
            for j in range(len(x)-i):
                if x[i+j] != y[j] and (x[i+j] != "?" and y[j] != "?"):
                    break
            else:
                cnt = i
                break
        else:
            cnt = len(x)
        ans = x[:cnt]
        x_rest = x[cnt:]
        for i in range(max(len(x_rest), len(y))):
            if i >= len(x_rest):
                ans += y[i]
            elif i >= len(y):
                ans += x_rest[i]
            else:
                if x_rest[i] == "?":
                    ans += y[i]
                else:
                    ans += x_rest[i]
        return ans
    print(min([len(check(check(i, j), k)) for i, j, k in [
          (a, b, c), (a, c, b), (b, a, c), (b, c, a), (c, a, b), (c, b, a)]]))


main()
Problem p02803 (python)

Fixed submission:
def main():
    h, w = map(int, input().split())
    grid = [input() for _ in [0]*h]
    ans_list = []
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                ans_list.append((i, j))
    m = 0
    for i, j in ans_list:
        q = [(i, j)]
        dist = [[-1]*w for _ in [0]*h]
        cnt = 0
        dist[i][j] = 0
        while q:
            qq = []
            cnt += 1
            while q:
                x, y = q.pop()
                if x > 0:
                    if dist[x-1][y] == -1:
                        if grid[x-1][y] == ".":
                            dist[x-1][y] = cnt
                            qq.append((x-1, y))
                if x < h-1:
                    if dist[x+1][y] == -1:
                        if grid[x+1][y] == ".":
                            dist[x+1][y] = cnt
                            qq.append((x+1, y))
                if y > 0:
                    if dist[x][y-1] == -1:
                        if grid[x][y-1] == ".":
                            dist[x][y-1] = cnt
                            qq.append((x, y-1))
                if y < w-1:
                    if dist[x][y+1] == -1:
                        if grid[x][y+1] == ".":
                            dist[x][y+1] = cnt
                            qq.append((x, y+1))
            q = qq
        m = max(m, max([max([l for l in k]) for k in dist]))
    print(m)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    mod = 10**9+7

    fact = [1]

    for i in range(1, n+1):
        fact.append(fact[-1]*i % mod)

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9+7): return inv_n(fact[n-r]
                                             * fact[r] % mod, mod)*fact[n] % mod

    ans = 0

    for i in range(n-k+1):
        ans = (ans+nCr(n-i-1, k-1)*(a[n-i-1]-a[i])) % mod
    print(ans)


main()
Problem p02838 (python)

Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    l1=[0]*61
    for i in a:
        j=list(reversed(bin(i)[2:]))
        for k in range(len(j)):
            if j[k]=="1":
                l1[k]+=1
    l0=[n-i for i in l1]
    ans=0
    mod=10**9+7
    for i in range(len(l1)):
        ans=(ans+l0[i]*l1[i]*pow(2,i,mod))%mod
    print(ans)
main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    l1 = [0]*61
    mod = 10**9+7
    for cnt in range(61):
        l1[cnt] = np.sum(a%2)
        a = a // 2
    l0 = [n-i for i in l1]
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    l1 = np.zeros(61, dtype=np.int64)
    mod = 10**9+7
    for i in a:
        j = list(map(int, reversed(bin(i)[2:])))
        l1[:len(j)] += j
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()
Problem p02856 (python)

Fixed submission:
def main():
    m=int(input())
    dc=[list(map(int,input().split())) for _ in [0]*m]
    sum_n=sum([d*c for d,c in dc])
    sum_c=sum([c for d,c in dc])
    print((sum_n-1)//9+sum_c-1)
main()

Buggy submission (verdict: Runtime Error):
def main():
    m=int(input())
    dc=[list(map(int,input().split())) for _ in [0]*m]
    n="".join([str(dc[i][0])*dc[i][1] for i in range(m)])
    sum_n=sum([d*c for d,c in dc])
    sum_c=sum([c for d,c in dc])
    print((sum_n-1)//9+sum_c-1)
main()
Problem p02874 (python)

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 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()
Problem p02889 (python)

Fixed submission:
n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
q=int(input())
st=[list(map(int,input().split())) for _ in [0]*q]
inf=10**12
dist=[[inf]*n for _ in [0]*n]
for i in range(n):
    dist[i][i]=0
for a,b,c in abc:
    dist[a-1][b-1]=c
    dist[b-1][a-1]=c
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])
inf=10**3
dist2=[[inf]*n for _ in [0]*n]
for i in range(n):
    for j in range(n):
        if dist[i][j]<=l:
            dist2[i][j]=1
for k in range(n):
    for i in range(n):
        for j in range(n):
            dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j])
for i in range(n):
    for j in range(n):
        if dist2[i][j]==inf:
            dist2[i][j]=-1
        else:
            dist2[i][j]-=1
for s,t in st:
    print(dist2[s-1][t-1])

Buggy submission (verdict: Runtime Error):
input_iter = iter(input_str.split("\n"))
def input() : return next(input_iter)
n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
q=int(input())
st=[list(map(int,input().split())) for _ in [0]*q]
inf=10**12
dist=[[inf]*n for _ in [0]*n]
for i in range(n):
    dist[i][i]=0
for a,b,c in abc:
    dist[a-1][b-1]=c
    dist[b-1][a-1]=c
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])
inf=10**3
dist2=[[inf]*n for _ in [0]*n]
for i in range(n):
    for j in range(n):
        if dist[i][j]<=l:
            dist2[i][j]=1
for k in range(n):
    for i in range(n):
        for j in range(n):
            dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j])
for i in range(n):
    for j in range(n):
        if dist2[i][j]==inf:
            dist2[i][j]=-1
        else:
            dist2[i][j]-=1
for s,t in st:
    print(dist2[s-1][t-1])
Problem p02926 (python)

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 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()
Problem p02929 (python)

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 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()
Problem p02940 (python)

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 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()
Problem p02949 (python)

Fixed submission:
#入力
n,m,r=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
#グラフ
g=[[] for _ in [0]*n]
[g[a-1].append([b-1,c]) for a,b,c in abc]
#逆辺
g2=[[] for _ in [0]*n]
[g2[b-1].append([a-1,c]) for a,b,c in abc]

#ベルマンフォード
dist=[-10**15 for _ in [0]*n]
dist[0]=0
a,b=-10**15,-10**15

for k in range(n):
    for p in range(n):
        for i,j in g[p]:
            dist[i]=max(dist[i],dist[p]+j-r)
    if k==n-2:
        d1=[t for t in dist]
    if k==n-1:
        d2=[t for t in dist]
    
#負の経路上の頂点の一覧
loop=set()
for i in range(n):
    if d1[i]!=d2[i]:
        loop.add(i)    
ans=max(d2[n-1],0)

#1からの到達可能地点
q=[0]
memo=[True for _ in range(n)]
memo[0]=False
while q:
    qq=q.pop()
    for i,j in g[qq]:
        if memo[i]:
            q.append(i)
            memo[i]=False
            
#nからの逆辺による到達可能地点
q=[n-1]
memo2=[True for _ in range(n)]
memo2[n-1]=False
while q:
    qq=q.pop()
    for i,j in g2[qq]:
        if memo2[i]:
            q.append(i)
            memo2[i]=False
            
#1からでもnからでも行ける点でかつ負の閉路に入っているものがあるときは-1
for i in loop:
    if memo[i]==False and memo2[i]==False:
        ans=-1
        
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]

g=[[] for _ in [0]*n]
[g[a-1].append([b-1,c]) for a,b,c in abc]

dist=[-10**15 for _ in [0]*n]
dist[0]=0
a,b=-10**15,-10**15

for _ in range(n):
    for p in range(n):
        for i,j in g[p]:
            dist[i]=max(dist[i],dist[p]+j)
    a,b=b,dist[n-1]

if a==b:
    ans=0
    loop=set()
    d=[-10**15 for _ in [0]*n]
    d[0]=0
    q=[[0,1]]
    s=set()
    l=[]
    cnt=0
    while q:
        cnt+=1
        qq=[]
        for q_item in q:
            item,depth=q_item
            if depth<=len(s):
                for _ in range(len(s)-depth+1):
                    rmv=l.pop()
                    s.remove(rmv)
            l.append(item)
            s.add(item)
            for i,dist in g[item]:
                if d[i]<d[item]+dist:
                    if i in s:
                        loop.add(i)
                        continue
                    d[i]=d[item]+dist
                    qq.append([i,depth+1])
          
        c=[False for _ in [0]*n]
        for x in loop:
            if c[x]==True:
                continue
            qqq=[x]
            c[x]=True
            while qqq:
                item=qqq.pop()
                for i,j in g[item]:
                    if c[i]==False:
                        c[i]=True
                        qq.append(i)
        ans=max(ans,d[n-1]-cnt*r)
        q=qq
    print(ans)
else:
    print(-1)
Problem p02952 (python)

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 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)
Problem p02960 (python)

Fixed submission:
s=list(reversed(input()))
mod=10**9+7
memo=[0 for _ in [0]*13]
m13=[(10**i)%13 for i in range(12)]
memo[0]=1
for i in range(len(s)):
    memo2=[0 for _ in [0]*13]
    a=m13[i%12]
    if s[i]=="?":
        list_=[0,1,2,3,4,5,6,7,8,9]
    else:
        list_=[int(s[i])]
    list_=[(a*j)%13 for j in list_]
    for l in list_:
        for j in range(13):
            memo2[(l+j)%13]+=memo[j]
    memo=[j%mod for j in memo2]
print(memo[5])

Buggy submission (verdict: Runtime Error):
def main():
    from sys import stdin
    input=stdin.readline
    s = list(reversed(input()))
    mod = 10**9+7
    memo = [0 for _ in [0]*13]
    m13 = [(10**i) % 13 for i in range(12)]
    memo[0] = 1
    for i in range(len(s)):
        memo2 = [0 for _ in [0]*13]
        a = m13[i % 12]
        if s[i] == "?":
            list_ = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
        else:
            list_ = [int(s[i])]
        list_ = [(a*j) % 13 for j in list_]
        for l in list_:
            for j in range(13):
                memo2[(l+j) % 13] += memo[j]
        memo = [j % mod for j in memo2]
    print(memo[5])


main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    s = list(reversed(input()))
    mod = 10**9+7
    memo = np.zeros(13, dtype=np.int64)
    m13 = [(10**i) % 13 for i in range(12)]
    npa13 = np.array([i * np.arange(10) % 13 for i in range(12)])
    memo[0] = 1
    for j, i in enumerate(s):
        memo2 = np.zeros(13, dtype=np.int64)
        a = m13[j % 12]
        if i == "?":
            for l in npa13[a]:
                memo2[l:] += memo[:13-l]
                memo2[:l] += memo[13-l:]
            memo = memo2 % mod
        else:
            l = a*int(i) % 13
            memo = np.append(memo[:13-l],memo[13-l:]) % mod
    print(int(memo[5]))


main()
Problem p02981 (python)

Fixed submission:
N,A,B=map(int,input().split())
print(min(N*A,B))

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

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 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)

Buggy 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)
Problem p03001 (python)

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)

Buggy 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)
Problem p03005 (python)

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

if K==1:
    print(0)
else:
    print(N-K)

Buggy submission (verdict: Runtime Error):
input_sample=iter("""
1
0 0
""".split("\n")[1:-1])

#問題を解く
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        if xy[i][0]-xy[j][0]<0:
            list_.append((abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1])))
        else:
            list_.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

if N==1:
    print(1)
else:
    print(N-Counter(list_).most_common()[0][1])
Problem p03006 (python)

Fixed submission:
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        if xy[i][0]-xy[j][0]==0:
            list_.append(((xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1])))
        elif xy[i][0]-xy[j][0]<0:
            list_.append((-(xy[i][0]-xy[j][0]),-(xy[i][1]-xy[j][1])))
        else:
            list_.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

if N==1:
    print(1)
else:
    print(N-Counter(list_).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        list_.append((abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1])))

print(N-Counter(list_).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        list_.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

print(N-Counter(list_).most_common()[0][1])