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

Fixed submission:
def popcnt1(n):
    return bin(n).count("1")

def okikae(n):
    kaisu = 0
    if n == 0:
        return 0
    while 1:
        P = popcnt1(n)
        n %= P
        kaisu += 1
        if n == 0:
            return kaisu

OKI = [okikae(i) for i in range(200001)]
X = int(input())
Norig = input()
N = int(Norig,2)
Npop = Norig.count("1")
F = Npop + 1
H = Npop - 1
if H == 0:
    H = -1
FueAmari = N%(Npop + 1)
if Npop != 1:
    HeruAmari = N%(Npop - 1)
else:
    HeruAmari = -1
Fues = []
Herus = []
fue = 1
heru = 1
for i in range(2*(10**5+1)):#2^0の桁から
    fue %= F
    heru %= H
    Fues.append(fue)
    Herus.append(heru)
    fue *= 2
    heru *= 2
RNorig = reversed(Norig)
Results = []
Zougen = []#増えたらTrue
Kaisu = [0] * X
#上の桁から見ていく。ゼロなら減ってイチなら増える
for n,bit in enumerate(Norig):#2**(N-1-n)の桁
    if bit == "0":#増える
        Zougen.append(True)
        print(1+OKI[(FueAmari + Fues[X-1-n] )% F])
    else:
        if H == -1:
            print(0)
            continue
        Zougen.append(False)
        print(1+OKI[(HeruAmari - Herus[X-1-n]) % H])

Buggy submission (verdict: Runtime Error):
def popcnt1(n):
    return bin(n).count("1")

def okikae(n):
    kaisu = 0
    if n == 0:
        return 0
    while 1:
        P = popcnt1(n)
        n %= P
        kaisu += 1
        if n == 0:
            return kaisu

OKI = [okikae(i) for i in range(20001)]
X = int(input())
Norig = input()
N = int(Norig,2)
Npop = Norig.count("1")
F = Npop + 1
H = Npop - 1
if H == 0:
    H = -1
FueAmari = N%(Npop + 1)
if Npop != 1:
    HeruAmari = N%(Npop - 1)
else:
    HeruAmari = -1
Fues = []
Herus = []
fue = 1
heru = 1
for i in range(2*(10**5+1)):#2^0の桁から
    fue %= F
    heru %= H
    Fues.append(fue)
    Herus.append(heru)
    fue *= 2
    heru *= 2
RNorig = reversed(Norig)
Results = []
Zougen = []#増えたらTrue
Kaisu = [0] * X
#上の桁から見ていく。ゼロなら減ってイチなら増える
for n,bit in enumerate(Norig):#2**(N-1-n)の桁
    if bit == "0":#増える
        Zougen.append(True)
        print(1+OKI[(FueAmari + Fues[X-1-n] )% F])
    else:
        if H == -1:
            print(0)
            continue
        Zougen.append(False)
        print(1+OKI[(HeruAmari - Herus[X-1-n]) % F])
Problem p02641 (python)

Fixed submission:
X,N = [int(hoge) for hoge in input().split()]
P = [int(hoge) - X for hoge in input().split()]
for d in range(101):
    if (d in P) and (-d in P):
        continue
    elif -d in P:
        print(X + d)
        exit()
    else:
        print(X - d)
        exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(hoge) for hoge in input().split()]
A = list(range(2,1000001))
A.sort()
M = max(A)
dp = [False] * (M+ 1)
ans = 0
prev = -1
for a in A:
    if dp[a] == False:
        for j in range(2,1 + (M// a)):
            dp[a*j] = True
        if a != prev:
            ans += 1
        else:
            dp[a] = True
            ans -= 1
    prev = a
print(ans)
Problem p02716 (python)

Fixed submission:
#基本1つ飛ばしだが、パスも使える。
#奇数ならパス2回、偶数ならパス1回。
N = int(input())
A = [int(hoge) for hoge in input().split()]
DP = [[0]*3 for n in range(N)] #DP[n][y] = n桁目までみて、パスをy回使ったときの最大値

DP[0][0] = A[0]

for n in range(1,N):#n桁目までみる。
    #「選ぶ」か「パスを使う」かの2択。
    DP[n][0] = DP[n-2][0] + A[n]
    DP[n][1] = max((DP[n-2][1]+A[n],DP[n-1][0]))
    DP[n][2] = max((DP[n-2][2]+A[n],DP[n-1][1]))
if N%2:
    print(DP[n][2])
else:
    print(DP[n][1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(hoge) for hoge in input().split()]
DP = [[0]*3 for n in range(N)] #DP[n][y] = n桁目までみて、i//2 -1 + y個選んだときの最大値

DP[0][0] = A[0]


for n in range(N):#n桁目までみる
    DP[n][0] = DP[n-2][0] + A[n]
    DP[n][1] = max((DP[n-2][1],DP[n-3][0]))+A[n]
    DP[n][2] = max((DP[n-2][2],DP[n-3][1],DP[n-4][0]))+A[n]
print(max(DP[N-1]))
Problem p02734 (python)

Fixed submission:
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
if A[0]<=S:
    DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n!=0:
        #もらう
        for p in range(a,S+1):
            DP[n][p] += DP[n-1][p-a]
        for p in range(S+1):
            DP[n][p] += DP[n-1][p]
            DP[n][p] %= MOD
        #初期化
        if a<=S:DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n==0:continue
    #もらう
    for p in range(a):
        DP[n][p] = DP[n-1][p]
    for p in range(a,S+1):
        DP[n][p] = DP[n-1][p] + DP[n-1][p-a]
    #初期化
    DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)
Problem p02743 (python)

Fixed submission:
a,b,c = [int(hoge) for hoge in input().split()]
print("NYoe s"[4*a*b < (c-a-b)**2 and a+b<c::2])

Buggy submission (verdict: Runtime Error):
from math import sqrt
a,b,c = [int(hoge) for hoge in input().split()]
print("NYoe s"[::sqrt(a)+sqrt(b)<sqrt(c)])
Problem p02788 (python)

Fixed submission:
import sys
fastinput = sys.stdin.readline
N,D,A = [int(i) for i in fastinput().split()]
preXH = [[int(i) for i in fastinput().split()] for j in range(N)]
preXH.sort()
XH = [[x,h//A + bool(h%A)] for x,h in preXH]
X = [x for x,h in XH]+[100000000000000000]
Diff = [X[m+1]-X[m] for m in range(N)]
reach = []
count = 0
l = X[0]
r = X[0]+2*D
for m in range(1,N+1):
    while r<X[m]:#l一個すすめる
        reach.append(m-1)
        r += Diff[count]
        count += 1

damage = 0
ans = 0
DIFF = [0]*N#ダメイジのdiff
for n,d in enumerate(DIFF):
    damage += d
    if damage<XH[n][1]:#殺しきれてない
        bonu = XH[n][1]-damage
        damage += bonu
        ans += bonu
        if reach[n]<N-1:DIFF[reach[n]+1] -= bonu
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N,D,A = [int(i) for i in input().split()]
preXH = [[int(i) for i in input().split()] for j in range(N)]
preXH.sort()
XH = [[x,h//A + bool(h%A)] for x,h in preXH]
Xs = [xxx[0] for xxx in XH]
ans = 0
DP = [0]*N#ダメイジの合計
for n,d in enumerate(DP):
    if d<XH[n][1]:#殺しきれてない
        bonu = XH[n][1]-d
        ans += bonu
        reach = XH[n][0] + 2*D
        for m in range(n,N):
            if XH[m][0] <= reach:
                DP[m] += bonu
            else:breakpoint
print(ans)
Problem p02973 (python)

Fixed submission:
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:continue

    if color == 1:
        c = surface[0]
        if a>c:
            surface[0] = a
            surfMax = a
            surfMin = a
        if a==c:
            surface.appendleft(a)
            color += 1
        if a<c:
            surface.appendleft(a)
            color += 1
            surfMin = a

    else:    
        if a<=surfMin:
            color += 1
            surface.appendleft(a)
            surfMin = a
        elif a>surfMax:
            surface[color-1] = a
            surfMax = a
        else:
            pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
            surface[pos] = a
            if pos==0:
                surfMin = a
            if pos == color-1:
                surfMax = a
print(color)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
color = 1
for n,a in enumerate(A):
    if n==0:
        continue
    else:
        pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
        if pos==0:
            color += 1
            surface.appendleft(a)
        else:
            surface[pos-1] = a
print(color)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:
        continue
    if a<=surfMin:
        color += 1
        surface.appendleft(a)
        surfMin = a
    elif a>surfMax:
        surface[color-1] = a
        surfMax = a
    else:
        pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
        if pos==0:
            surfMin = a
        else:
        surface[pos-1] = a
print(color)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:
        continue
    if a<=surfMin:
        color += 1
        surface.appendleft(a)
        surfMin = a
    elif a>surfMax:
        surface[color-1] = a
        surfMax = a
    else:
        pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
        surface[pos-1] = a
        if pos==0:
            surfMin = a
print(color)
Problem p02995 (python)

Fixed submission:
import fractions
def LCM(a,b):
    return int(a*b/fractions.gcd(a,b))
A,B,C,D = map(int,input().split())#A以上B以下
L = LCM(C,D)
Cbaisu = (B//C) - ((A-1)//C)
Dbaisu = (B//D) - ((A-1)//D)
Lbaisu = (B//L) - ((A-1)//L)
print(B-A+1 - Cbaisu - Dbaisu + Lbaisu)

Buggy submission (verdict: Runtime Error):
import math
def LCM(a,b):
    return int(a*b/math.gcd(a,b))
A,B,C,D = map(int,input().split())#A以上B以下
L = LCM(C,D)
Cbaisu = B//C - A//C
Dbaisu = B//D - A//D
Lbaisu = B//L - A//L
print(B-A+1 - Cbaisu - Dbaisu + Lbaisu)
Problem p02999 (python)

Fixed submission:
x,a= [int(i) for i in input().split()]
if x<a:print(0)
else:print(10)

Buggy submission (verdict: Runtime Error):
a,b= [int(i) for i in input().split()]
if x<a:print(0)
else:print(10)
Problem p03001 (python)

Fixed submission:
w,h,x,y= [int(i) for i in input().split()]
print(w*h/2)
print(int(2*x==w and 2*y ==h))

Buggy submission (verdict: Runtime Error):
2 2 1 1
Problem p03006 (python)

Fixed submission:
import collections
N=int(input())
xy=[tuple([int(i) for i in input().split()])  for j in range(N)]
dist = []
if N!=1:
    for n,(x,y) in enumerate(xy):
        for m,(gx,gy) in enumerate(xy):
            if n==m:continue
            dx,dy = gx-x,gy-y
            dist.append((dx,dy))
    zerocost = max(collections.Counter(dist).values())
    print(N-zerocost)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
xy=[tuple([int(i) for i in input().split()])  for j in range(N)]
dist = []
for n,(x,y) in enumerate(xy):
    for j in range(n+1,N):
        gx,gy = xy[j]
        dx,dy = gx-x,gy-y
        dist.append((dx,dy))
zerocost = max(collections.Counter(dist).values())
print(N-zerocost)
Problem p03049 (python)

Fixed submission:
N=int(input())
XA=0
BA=0
BX=0
internalAB=0
for t in range(N):
    i=input()
    headUsed=False
    footUsed=False
    for x,j in enumerate(i):
        if x==len(i)-1:break
        if j=="A" and i[x+1]=="B":
            internalAB+=1
            if x==0:headUsed=True
            if x==len(i)-2:footUsed=True
    if i[0]=="B" and not headUsed:
        if i[-1]=="A" and not footUsed:
            BA+=1
        else:BX+=1
    elif i[-1]=="A" and not footUsed:
        XA+=1
if XA or BX:
    externalAB=max(0,BA+min(XA,BX))
else:externalAB=max(0,BA-1)
ans=internalAB+externalAB
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
XA=0
BA=0
BX=0
internalAB=0
for t in range(N):
    i=input()
    headUsed=False
    footUsed=False
    for x,j in enumerate(i):
        if x==len(i)-1:break
        if j=="A" and i[x+1]=="B":
            internalAB+=1
            if x==0:headUsed=True
            if x==len(i)-2:footUsed=True
    if i[0]=="B" and not headUsed:
        if i[-1]=="A" and not footUsed:
            BA+=1
        else:BX+=1
    elif i[-1]=="A" and not footUsed:
        XA+=1
ans=internalAB+BA+min(XA,BX)
if XA=BX=0:ans-=1
print(ans)
Problem p03062 (python)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
def CountMinusAndZeroAndMin(lis):#マイナスの個数とabs挿話とabs最小の値を返す
    curmin=1000000000000000
    plussum=0
    minus=0
    for i in lis:
        j=abs(i)
        plussum+=j
        curmin=min(j,curmin)
        if i<0:
           minus+=1
    return(minus,plussum,curmin)
minus,plussum,minabs=CountMinusAndZeroAndMin(A)
if minabs==0 or minus%2==0:
    print(plussum)
else:
    print(plussum-2*minabs)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
def CountMinusAndZeroAndMin(lis):#マイナスの個数とabs挿話とabs最小の値を返す
    curmin=1000000000000000
    plussum=0
    minus=0
    for i in lis:
        j=abs(i)
        plussum+=j
        curmin=min(j,curmin)
        if i<0:
           minus+=1
        elif i==0:
            zeros+=1
    return(minus,plussum,curmin)
minus,plussum,minabs=CountMinusAndZeroAndMin(A)
if minabs==0 or minus%2==0:
    print(plussum)
else:
    print(plussum-2*minabs)
Problem p03078 (python)

Fixed submission:
from collections import deque
X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
#AとBのわのうちでかい順にK個
ABsum=[]
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=[]
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import deque
import bisect

X,Y,Z,K=map(int,input().split())
A=sorted([int(i) for i in input().split()],reverse=True)
B=sorted([int(i) for i in input().split()],reverse=True)
C=sorted([int(i) for i in input().split()],reverse=True)
Amax,Bmax,Cmax=(max(j) for j in [A,B,C])
Umami=Amax+Bmax+Cmax
Adif=[abs(i-Amax) for i in A]
Bdif=[abs(x-Bmax) for x in B]
Cdif=[abs(p-Cmax) for p in C]#AdifBdifCdifから1個ずつ選んだ和を小さい方から3000個
rank3000=100000000#暫定3000位のやつ
visited=np.zeros((1000,1000,1000),dtype="int")#Ai,Bj,Ckの行ったやつ
queue=deque()
queue.append([0,0,0])
ranking=[]
ranked=0#3000枠埋まったら1になる
Powerful=0
while queue and Powerful ==0:
    a,b,c = queue.popleft()
    for j, k ,l in ([1,0,0],[0,1,0],[0,0, 1]):
        new_a, new_b, new_c = a+j,b+k,c+l
        rankin=0
        if 0<=a<X and 0<=b<Y and 0<=c<Z and  visited[new_a][new_b][new_c]==0:
            visited[new_a][new_b][new_c]=1
            queue.append([new_a,new_b,new_c])
            if Adif[a]+Bdif[b]+Cdif[c]<rank3000:
                rankin+=1
                ranking.append(Adif[a]+Bdif[b]+Cdif[c])
                if ranked==0:
                    if len(ranking)==K:
                        ranked=1
                ranking.sort()
                if ranked==1:
                    ranking.pop(-1)
                    rank3000=ranking[-1]
            if rankin==0:
                Powerful=1
                break
print(ranking)
Problem p03087 (python)

Fixed submission:
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(_) for _ in input().split()]
S=list(input())
hani=[[int(a) for a in input().split()] for j in range(Q)]
ACindex=[0]
cur=0
for i in range(N-1):
    cur+=S[i]=="A" and S[i+1]=="C"
    ACindex.append(cur)
ACindex.append(cur)
for j in hani:
    print(ACindex[j[1]-1]-ACindex[j[0]-1])

Buggy submission (verdict: Runtime Error):
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=np.array([S[i]=="A" and S[i+1]=="C" for i in range(N)])
for j in hani:
    print(sum(ACindex[j[0]-1:j[1]-1]))

Buggy submission (verdict: Runtime Error):
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=np.array([S[i]=="A" and S[i+1]=="C" for i in range(N-1)])
for j in hani:
    print(sum(ACindex[j[0]-1:j[1]-1]))

Buggy submission (verdict: Runtime Error):
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=np.array([S[i]=="A" and S[i+1]=="C" for i in range(N)])
for j in hani:
    print(sum(ACindex[j[0]-1:j[1]-1]))

Buggy submission (verdict: Runtime Error):
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=[i for i in range(N) if S[i]=="A" and S[i+1]=="C"]
for j in hani:
    print(sum([j[0]-1<= k <j[1]-1 for k in ACindex]))
Problem p03089 (python)

Fixed submission:
N=int(input())
b=list(map(int,input().split()))
sa=[i-b[i-1] for i in range(1,N+1)]
ans=[0 for i in range(N)]#k番目にans[k-1]が入ったよの表
for i in reversed(range(1,N+1)):#頭からi番目
    cnt=0
    for j in range(1,N+1):
        if ans[-1*j]==0:
            if cnt!=sa[i-1]:
                cnt+=1
            else:
                ans[-1*j]=b[i-1]
                break
if all(k!=0 for k in ans):
    for i in ans:
        print(i)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
#最後のやつがjならはj番目にできたと確定する
dead=0
N=int(input())
b=list(map(int,input().split()))
ans=[0 for i in range(N)]#k番目にans[k-1]が入ったよの表
for i in reversed(range(1,N+1)):
    num=b[i-1]#頭からi番目の数
    sa_left=i-num#n-saleftから検証
    for j in reversed(range(1,N-sa_left+1)):
        if ans[j-1]==0:
            ans[j-1]=num
            break
if all(k!=0 in ans):
    for i in ans:
        print(ans)
else:
    print("-1")
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H,W=input().split()
h,w=input().split()
print((H-h)*(W-w))
Problem p03102 (python)

Fixed submission:
import numpy as np
N,M,C=map(int,input().split())
B=np.array([int(i) for i in input().split()]).T
A=[[int(i) for i in input().split()] for j in range(N)]
A=np.matrix(A)
print(sum([i+C>0 for i in (np.dot(A,B).T).A1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M,C=map(int,input().split())
B=np.array([int(i) for i in input().split()]).T
A=[[int(i) for i in input().split()] for j in range(N)]
A=np.matrix(A)
print(sum([i+C>0 for i in (np.dot(A,B).T).A1]))
Problem p03146 (python)

Fixed submission:
from collections import Counter
def collatz(n):
    if n%2:
        return n*3 + 1
    else:
        return n//2
    
i = int(input())
dic = dict()
dic[i] = 1
cur = i
for n in range(1,10000):
    cur = collatz(cur)
    if cur in dic:
        print(n+1)
        break
    else:
        dic[cur] = 1

Buggy submission (verdict: Runtime Error):
print([1, 3, 3, 8, 3, 6, 9, 17, 4, 20, 7, 15, 10, 10, 18, 18, 5, 13, 21, 21, 8, 8, 16, 16, 11, 24, 11, 112, 19, 19, 19, 107, 6, 27, 14, 14, 22, 22, 22, 35, 9, 110, 9, 30, 17, 17, 17, 105, 12, 25, 25, 25, 12, 12, 113, 113, 20, 33, 20, 33, 20, 20, 108, 108, 7, 28, 28, 28, 15, 15, 15, 103, 23, 116, 23, 15, 23, 23, 36, 36, 10, 23, 111, 111, 10, 10, 31, 31, 18, 31, 18, 93, 18, 18, 106, 106, 13, 119, 26, 26][int(input())]+1)
Problem p03151 (python)

Fixed submission:
N = int(input())
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
#Aiの総和を変えずに、なるべく少ない量のAiを変えて全部合格を目指す
if sum(B) > sum(A):
    print(-1)
else:
    diff = 0
    points = []
    ans = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a < b:
            diff += b - a
            ans += 1
        elif a > b:
            points.append(a-b)
    for p in sorted(points,reverse = True):
        if diff <= 0:
            print(ans)
            exit()
        diff -= p
        ans += 1 
    print(ans)

Buggy submission (verdict: Runtime Error):
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Problem p03200 (python)

Fixed submission:
#AGC029 A - Irreversible operation
def countB(data):#dataのBの個数kosuとiの総和sumを返す
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)

Buggy submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
A=input().split()
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        if inverseA[j] in A:
            A.remove(inverseA[j])
print((N-len(A))//2)

Buggy submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        if inverseA[j] in A:
            A.remove(inverseA[j])
print((N-len(A))%2)

Buggy submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        A.remove(inverseA[j])
print((N-len(A))%2)

Buggy submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
def tasitekesu(data,n):#dataの中で足したらnになるやつを消し、消した結果とペア数を報告する
    result=[]
    kosu=0
    for i in range(len(data)):
        if i in result:
            continue
        for j in range(i):
            if j in result:
                continue
            if data[i]+data[j]==n:
                result.append(i)
                result.append(j)
                kosu=kosu+1
                break
    result.sort(reverse=True)
    for i in result:
        del data[i]
    return [data,kosu]

N=int(input())
A=input().split()
ans=0
for i in range(N):
    A[i]=int(A[i])
for i in (reversed(beki)):
    R=tasitekesu(A,i)
    A=R[0]
    ans=ans+R[1]
print(ans)
Problem p03231 (python)

Fixed submission:
import fractions
N,M = [int(hoge) for hoge in input().split()]
S = input()
T = input()
G = fractions.gcd(N,M)
print(N*M//G) if S[::N//G] == T[::M//G] else print(-1)

Buggy submission (verdict: Runtime Error):
import math
N,M = [int(hoge) for hoge in input().split()]
S = input()
T = input()
G = math.gcd(N,M)
print(N*M//G) if S[::N//G] == T[::M//G] else print(-1)
Problem p03254 (python)

Fixed submission:
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
if cur == x:print(N)
else:print(ans-1)

Buggy submission (verdict: Runtime Error):
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
if cur == X:print(N)
else:print(ans-1)