Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[i-1 for i in a]+a+[i+1 for i in a]
b=Counter(a).most_max(1)
print(b[0][1])

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[i-1 for i in a]+a+[i+1 for i in a]
b=Counter(b).most_common(1)
print(b[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a)
t=[]
for _ in b.most_common(100):
  t.append(len([i for i in a if _[0]-1<i<_[0]+3]))
  t.append(len([i for i in a if _[0]-2<i<_[0]+2]))
  t.append(len([i for i in a if _[0]-3<i<_[0]+1]))
print(max(t))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[i-1 for i in a]+a+[i+1 for i in a]
b=Counter(b).most_common(1)
print(b[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a)
t=[]
for _ in b.most_common():
  t.append(len([i for i in a if _[0]-1<i<_[0]+3]))
  t.append(len([i for i in a if _[0]-2<i<_[0]+2]))
  t.append(len([i for i in a if _[0]-3<i<_[0]+1]))
print(max(t))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[i-1 for i in a]+a+[i+1 for i in a]
b=Counter(b).most_common(1)
print(b[0][1])
Buggy python submission (verdict: Runtime Error):
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()

d=defaultdict(list)
n=int(input())

for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})

def DIJKSTRA(point,d):
    cost      = {node:float("inf") for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

q,k=map(int,input().split())
y=DIJKSTRA(k,d)

for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])

Fixed submission:
n=list(input())
s=[1 for i in range(len(n)//2) if n[i]==n[len(n)-i-1]]
print("Yes" if len(s)==len(n)//2 else "No")

Buggy python submission (verdict: Runtime Error):
from collections import *
d=defaultdict(list)
n=int(input())

for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])

#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})
 
def DIJKSTRA(point,d):
    cost      = {node:float("inf") for node in d.keys()}
    preference= {node:None         for node in d.keys()}#最適路のこと 
    Q         = set(d.keys())  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    while True:
        prefnd=min(Q, key=lambda c:cost[c]) #最適な点探し
        Q.remove(prefnd)  #最適だった点を削除
        if len(Q)==0:
            break #全部の点消したら終了
        for p,c in d[prefnd]:  #次の点とそこまでのコスト
            temp=cost[prefnd]+c  #スタートからそこまでのコストを計算
            if temp<cost[p]:   #計算してみたコストがそこに行くまでの最小値ならば
                cost[p]=temp #最小値更新
                preference[p]=prefnd
    return preference,cost  #点のつながりとコスト例 1から１に０ １から２に１ １から３に２

q,k=map(int,input().split())
x,y=DIJKSTRA(k,d)

for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])


Fixed submission:
n=list(input())
s=[1 for i in range(len(n)//2) if n[i]==n[len(n)-i-1]]
print("Yes" if len(s)==len(n)//2 else "No")

Buggy python submission (verdict: Runtime Error):
import collections as c
 
d=c.defaultdict(list)
n=int(input())
for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
 
def DFS(point,d,cost,TFlist): #入力と同じindex系
    for s in d[point]:
        try:
            p=s[0]
            c=s[1]+cost[point]
            if TFlist[p-1]:
                continue
            cost[p]+=c
            TFlist[p-1]=1
            DFS(p,d,cost,TFlist)
        except:
            continue
 
cost=[None]+[0 for i in range(n)]
q,k=map(int,input().split())
TFlist=[0 for i in range(n)]
TFlist[k-1]=1
DFS(k,d,cost,TFlist)
 
for t in range(q):
    a,b=map(int,input().split())
    print(cost[a]+cost[b])

Fixed submission:
n=list(input())
s=[1 for i in range(len(n)//2) if n[i]==n[len(n)-i-1]]
print("Yes" if len(s)==len(n)//2 else "No")
Buggy python submission (verdict: Runtime Error):
s=list(input())
print(s[0]+str(len(s-2))+s[-1])

Fixed submission:
s=list(input())
print(s[0]+str(len(s)-2)+s[-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[1 for i in list(map(int,input().split())) if i%4==0]
print("Yes" if len(a)>=n//2 "No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[1 for i in a if i%4==0]
c=[1 for i in a if i%4!=0 and i%2==0]
print("Yes" if len(b)+len(c)//2>=n//2 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
#いろはコンテスト day2
import functools
import sys
from heapq import*
from collections import*

input=sys.stdin.readline


p=defaultdict(lambda: -1)
@functools.lru_cache(maxsize=None)
class UNION_FIND(object):
    def __init__(self,n):
        
        self.parent=defaultdict(lambda: -1)

    def root(self,x):
        if type(self.parent[x])!=tuple:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    #print(edges)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append(c)
    return mst


n = int(input())
points=[list(map(int,input().split()))for i in range(n)]

x=sorted(points,key=lambda x:x[0])
y=sorted(points,key=lambda x:x[1])
#print(x,y)


edges = []
for i in range(1,n):
    (a,b),(c,d)=x[i-1],x[i]
    (e,f),(g,h)=y[i-1],y[i]
    heappush(edges,((a,b),(c,d),abs(a-c)))
    heappush(edges,((e,f),(g,h),abs(f-h)))
#print(edges)
mst = compute_mst_kruskal(n, edges , 0) #0が最小化
print(sum(mst))

Fixed submission:
#いろはコンテスト day2
import functools
import sys
from heapq import*
from collections import*

input=sys.stdin.readline


p=defaultdict(lambda: -1)
@functools.lru_cache(maxsize=None)
class UNION_FIND(object):
    def __init__(self,n):
        
        self.parent=defaultdict(lambda: -1)

    def root(self,x):
        if type(self.parent[x])!=tuple:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    #print(edges)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append(c)
    return mst


n = int(input())
points=[list(map(int,input().split()))for i in range(n)]

x=sorted(points,key=lambda x:x[0])
y=sorted(points,key=lambda x:x[1])
#print(x,y)


edges = []
for i in range(1,n):
    (a,b),(c,d)=x[i-1],x[i]
    (e,f),(g,h)=y[i-1],y[i]
    heappush(edges,((a,b),(c,d),abs(a-c)))
    heappush(edges,((e,f),(g,h),abs(f-h)))
#print(edges)
mst = compute_mst_kruskal(n, edges , 0) #0が最小化
print(sum(mst))
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

    ok=-1
    ng=max(h)//a+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)

if __name__ == '__main__':
    main()

Fixed submission:
#import numpy as np
from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

    ok=-1
    ng=max(h)+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
#        print(mid,"NY"[judge(mid)])
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
    
if n==1:    
    if a==b:
        print(1)
    else:
        print(0)
elif n==2:
    if b<a:
        print(0)
    else:
        print(1)
else:
    if b<a:
        print(0)
    elif a==b:
        print(1)
    else:
        print(sum(list(range(b-a+2))[::-1][:n-2]))

Fixed submission:
n,a,b=map(int,input().split())
if b<a:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:
        print(0)
else:
    print( a+b*(n-1) - (a*(n-1)+b) +1 )

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
    
if n==1:    
    if a==b:
        print(1)
    else:
        print(0)
elif n==2:
    if b<a:
        print(0)
    else:
        print(1)
else:
    if b<a:
        print(0)
    else:
        print(sum(list(range(b-a+2))[::-1][:n-2]))

Fixed submission:
n,a,b=map(int,input().split())
if b<a:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:
        print(0)
else:
    print( a+b*(n-1) - (a*(n-1)+b) +1 )
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
L=[]
for s in range(n):
  a,b=map(int,input().split())
  L.append((a,b))
#print(L)
L=sorted(L,key=lambda x:x[0])
#print(L)
sun=0
for s in L:
  sun+=s[1]
  if sun+1>k:
    print(s[0])
    exit()

Fixed submission:
a,b,c=map(int,input().split());print("Yes" if a<=c<=b else "No")
Buggy python submission (verdict: Runtime Error):
from collections import *
d=defaultdict(list)
n,m=map(int,input().split())
 
for s in range(m):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
#print(d)

def BELLMANFORD(point,d):
    cost       = {node:-float("inf")for node in range(1,n+1)}
    preference = {node:None         for node in range(1,n+1)}      #最適路のこと 
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.copy().items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定
        for now,lis in d.copy().items():
            for nex,c in lis:
                if negative[now]==1:
                    negative[nex]=1
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now
                    negative[now-1]=1

    return cost,negative

x,y=(BELLMANFORD(1,d))
#print(x,y)
if y[n-1]==1:
    print("inf")
else:
    print(x[n])

Fixed submission:
from collections import *
d=defaultdict(list)
n,m=map(int,input().split())
 
for s in range(m):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
#print(d)

def BELLMANFORD(point,d):
    cost       = {node:-float("inf")for node in range(1,n+1)}
    preference = {node:None         for node in range(1,n+1)}      #最適路のこと 
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.copy().items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定
        for now,lis in d.copy().items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now
                    negative[now-1]=1

    return cost,negative

x,y=(BELLMANFORD(1,d))
#print(x,y)
if y[n-1]==1:
    print("inf")
else:
    print(x[n])
Buggy python submission (verdict: Runtime Error):
from numpy import*
N,W=map(int, input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int, input().split())
    dp[w:]=maximum(dp[w:], dp[:-w]+v)
print(int(max(dp)))

Fixed submission:
from collections import*
import functools
import sys
input=sys.stdin.readline
@functools.lru_cache(maxsize=None)
def Knapsack(N,W):
    for i in range(N):
        w,v=map(int,input().split())
        for k,b in d.copy().items():
            if k+w<=W:
                d[k+w]=max(d[k+w],b+v)
    return max(d.values())
N,W=map(int,input().split())   #pypyで実行！
d=defaultdict(int)
d[0]=0
print(Knapsack(N,W))
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())

ans=0
x=a[0]
if a[1]>a[0]:
  mode=0
else:
  mode=1
for s in a:
#  print(x,s,mode,ans)
  if x<s and mode==0:
    ans+=1
    mode=1
  elif x>s and mode==1:
    ans+=1
    mode=0
  x=s
print(ans//2+1)

Fixed submission:
n,*a=map(int,open(0).read().split())
tmp=0
ans=1
for i in range(len(a)-1):
    dif=a[i+1]-a[i]
    if tmp==0:
        tmp=dif
    elif dif*tmp<0:
        ans+=1
        tmp=0

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
l=[]
for i in range(1,int(math.sqrt(n))+2):
    if n%i==0:
        l+=[max(len(str(i)),len(str(n//i)))]
print(min(l))

Fixed submission:
a=map(int,input().split());print(sum(a)%24)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print(sum(a,b)%24)

Fixed submission:
a=map(int,input().split());print(sum(a)%24)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,*v=map(int,open(0).read().split())
l=[]
for t in range(1,2**n):
    c=[(t>>s&1)*v[s]for s in range(n)]
    if a<=sum((i!=0)for i in c)<=b:
        l.append(sum(c)/sum((i!=0)for i in c))
print(max(l))
print(l.count(max(l)))

Fixed submission:
from collections import*
from itertools import*
from bisect import*
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
n,a,b,*v=map(int,open(0).read().split())
v=sorted(Counter(v).items(),reverse=1,key=lambda x:x[0])
vindex=[0]+list(accumulate(V for K,V in v))+[float("inf")]
#print(v,vindex)
lower=vindex[bisect_left(vindex,a)-1]
upper=vindex[bisect_left(vindex,a)]
count=0
ans=0
 
if a<=vindex[1]:
    ans=0
    for i in range(a,min(b,vindex[1])+1):
        ans+=cmb(vindex[1],i)
    print(float(v[0][0]))
    print(ans)
 
else:
    for s,t in v:
        count+=t
        if count>lower:
            ans+=s*(a-lower)
            break
        else:
            ans+=s*t
    print(ans/a)
    print(cmb(upper-lower,a-lower))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
v=sorted([int(input())for i in range(a)])
print(v)
bus=[]
ans=0
for i in range(a-1):
    
    if v[i]+c<v[i+1]:
        ans+=1
        bus=[]
        if i==a-2:
            ans+=1
    else:
        bus.append(v[i])
        print(bus)
        if len(bus)>=b:
            ans+=1
            bus=[]
if len(bus)>0:
    ans+=1
print(ans)

Fixed submission:
n,c,k,*t=map(int,open(0).read().split())
t.sort()
totalbus=1
bus=0
time=t[0]
for i in range(n):
    bus+=1
    if t[i]>time+k or bus>c:
        time=t[i]
        totalbus+=1
        bus=1
print(totalbus)
Buggy python submission (verdict: Runtime Error):
from math import fractorial;print(fractorial(int(input()))%(10**9+7))

Fixed submission:
from math import factorial;print(factorial(int(input()))%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def f(n):
  ans=1
  if n%2==1:
    a=2
    b=n//2+1
    c=n+2
  else:
    a=1
    b=n//2
    c=n+1
  for s in range(a,b+1):
    ans*=s*(c-s)
  ans=ans%(10**9+7)
  return ans
print(f(int(input())))

Fixed submission:
from math import factorial;print(factorial(int(input()))%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
if n%2==1:
  a=2
  b=n//2+1
  c=n+2
else:
  a=1
  b=n//2
  c=n+1
ans=1
for s in range(a,b+1):
  ans*=s*(c-s)
print(ans%(10**9+7))

Fixed submission:
from math import factorial;print(factorial(int(input()))%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=1
for s in range(2,n+1):
  x*=s
print(x%(10**9+7))

Fixed submission:
from math import factorial;print(factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
from collections import *
n,m=map(int,input().split())
d=defaultdict(list)
for s in m*[0]:
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
def DFS_dict(point,TFlist):
    if all(TFlist):
        return 1
    ans=0
    for i in d[point]:
        if TFlist[i-1]:
            continue
        TFlist[i-1]=True
        ans+=DFS_dict(i,TFlist)
        TFlist[i-1]=False
    return ans
TFlist=[True]+[False]*(n-1)
print(DFS_dict(1,TFlist))

Fixed submission:
a,b=map(int,input().split())
if a==1:a+=13
if b==1:b+=13
if a>b:print("Alice")
elif b>a:print("Bob")
else:print("Draw")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
AdjacencyMatrix=[[0]*n for i in [0]*m]
for i in [0]*m:
  a,b=map(int,input().split())
  AdjacencyMatrix[a-1][b-1]=1
  AdjacencyMatrix[b-1][a-1]=1
#print(AdjacencyMatrix)

def DFS(point,TFlist):
#  print(TFlist)
  if not False in TFlist:
    return 1
  ans=0
  for i in range(n):
    if not AdjacencyMatrix[point][i]:
      continue  #AMの0なら処理せず
    if TFlist[i]:
      continue  #探索済みなら処理せず
    TFlist[i]=True #探索したのでTFlistをTrue
    ans+=DFS(i,TFlist) #再帰的にansを加算
    TFlist[i]=False #枝を戻すためにTFlistをFalse
  return ans

TFlist=[True]+[False]*(n-1)
print(DFS(0,TFlist))

Fixed submission:
n,m=map(int,input().split())
AdjacencyMatrix=[[0]*n for i in [0]*n]
for i in [0]*m:
  a,b=map(int,input().split())
  AdjacencyMatrix[a-1][b-1]=1
  AdjacencyMatrix[b-1][a-1]=1
#print(AdjacencyMatrix)

def DFS(point,TFlist):
#  print(TFlist)
  if not False in TFlist:
    return 1
  ans=0
  for i in range(n):
    if not AdjacencyMatrix[point][i]:
      continue  #AMの0なら処理せず
    if TFlist[i]:
      continue  #探索済みなら処理せず
    TFlist[i]=True #探索したのでTFlistをTrue
    ans+=DFS(i,TFlist) #再帰的にansを加算
    TFlist[i]=False #枝を戻すためにTFlistをFalse
  return ans

TFlist=[True]+[False]*(n-1)
print(DFS(0,TFlist))
Buggy python submission (verdict: Runtime Error):
print("A"+"RB"[input()<1200]+"C")

Fixed submission:
print("ABC" if int(input())<1200 else "ARC")
Buggy python submission (verdict: Time Limit Exceeded):
#いろはコンテスト day2
import functools
import sys
from heapq import*

input=sys.stdin.readline

@functools.lru_cache(maxsize=None)
class UNION_FIND(object):
    def __init__(self,n):
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append((c))
    return mst
 
max_v, a,b=map(int,input().split()) 
*x,=map(int,input().split())

edges = []
for i in range(max_v):
    for j in range(max_v):
        heappush(edges,(i,j,min(abs(a*(x[i]-x[j])),b)))
mst = compute_mst_kruskal(max_v, edges , 0) #0が最小化
print(sum(mst))

Fixed submission:
n,a,b=map(int,input().split())
*x,=map(int,input().split())
print(sum(min(abs(a*(x[i-1]-x[i])),b)for i in range(1,n)))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print(sum(a>=b-s-t>=0for t in range(a+1)for s in range(a+1)))

Fixed submission:
print(" ".join(input().split(",")))
Buggy python submission (verdict: Time Limit Exceeded):
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        for r in range(a+1):
            ans+=(b-s-t-r==0)
print(ans)

Fixed submission:
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        if 0<=b-s-t<=a:
            ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
k,e=map(int,input().split())
ans=0
s=[i for i in range(k+1)]
q=list(sum(u) for u in itertools.product(s, repeat=3) if sum(u)==e)
print(len(q))

Fixed submission:
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        if 0<=b-s-t<=a:
            ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,e=map(int,input().split())
ans=0
for s in range(k+1):
  for t in range(k+1):
    for r in range(k+1):
      if s+t+r==e:ans+=1
print(ans)

Fixed submission:
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        if 0<=b-s-t<=a:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
print(b//x - (a-1)//x)

Fixed submission:
a,b,s=input().split()
print(list(a)[0]+list(b)[0]+list(s)[0])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
ans=0
for s in range(a,b+1):
  if s%x==0:
    ans+=1
    break
ans+=(b-s)//x
print(ans)

Fixed submission:
a,b,x=map(int,input().split())
print(b//x - (a-1)//x)
Buggy python submission (verdict: Runtime Error):
h,w,*a=open(0).read().split();b=a.index("snuke");print([chr(i)for i in range(65,65+int(h))][b%int(w)]+str(b//int(w)+1))

Fixed submission:
h,w,*a=open(0).read().split();b=a.index("snuke")
print([chr(i)for i in range(65,91)][b%int(w)]+str(b//int(w)+1))