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

Fixed submission:
from itertools import accumulate

n, k = map(int,input().split())
l = list(map(int,input().split()))
#print(l)

p = [0] + list(accumulate(l))

#print(p)

q = []
for i in range(n-k+1):
    q.append((p[i+k] - p[i] + k)/2)

print(max(q))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
l = list(map(int, input().split()))
# 期待値:マス目の総和／マス目の数, マス目の最大値+最小値[1]／2
l = [(i+1)/2 for i in l] # 期待値に変換

# 累積和を取得
from itertools import accumulate
cum = list(accumulate(l))
# 差分を考慮しつつ k個の和をリストする → 最大値が ans
sum_k = []
for j in range(n-k):
    sum_k.append(cum[k+j] - cum[j])

print(max(sum_k))
Problem p02817 (python)

Fixed submission:
x, y = input().split()
print(y+x)

Buggy submission (verdict: Runtime Error):
print(y+x)

Buggy submission (verdict: Runtime Error):
x, y = map(int,input().split())
print(y+x)
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
x = []
import string
a = list(string.ascii_uppercase)*2
#print(a)
for i in s:
    j = 0
    b = a.index(i)
    j = b + n
    x.append(a[j])
    
print(''.join(x))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
x = []
import string
a = list(string.ascii_uppercase)
for i in s:
    b = a.index(i)
    x.append(a[b + n])
    
print(''.join(x))
Problem p02865 (python)

Fixed submission:
a=int(input())
 
x=(a-2)/2
if int(x) ==x:
    print(int(x))
else:
    print(int(x+1))

Buggy submission (verdict: Runtime Error):
a=int(input())

x=(a-2)/2
if int(x) ==x:
    print(int(x)
else:
    print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a=input()
#b=int(input())
#c=int(input())
#d=int(input())
x=(a-2)/2
if int(x) ==x:
    print(int(x))
else:
    print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a=int(input())

x=(a-2)/2
if int(x) ==x:
    print(x)
elif:
    print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a=int(input())
#b=int(input())
#c=int(input())
#d=int(input())
x=(a-2)/2
if int(x) ==x:
    print(x)
elif:
    print(x+1)
Problem p02882 (python)

Fixed submission:
import math

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

h1 = b - x/a/a
h2 = 2*x/(a*b)


if x == a*a*b:
    print(0)
elif b*a*a/2 <= x:
    radians = math.atan(a/2/h1)
    print(90 - math.degrees(radians))
else:
    radians = math.atan(h2/b)
    print(90 - math.degrees(radians))

Buggy submission (verdict: Runtime Error):
import math

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

h1 = b - x/a/a
h2 = 2*x/(a*b)


if b*a*a/2 <= x:
    radians = math.atan(a/2/h1)
    print(90 - math.degrees(radians))
else:
    radians = math.atan(h2/b)
    print(90 - math.degrees(radians))
Problem p02910 (python)

Fixed submission:
s = list(input())
n = len(s)
#print(n)
k,g=[],[]
for i in range(n):
    if i%2==0:
        k.append(s[i])
    else:
        g.append(s[i])
#print(k)
#print(g)
for j in k:
    if j == 'L':
        print('No')
        break

else:
    for l in g:
        if l == 'R':
            print('No')
            break
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
#print(n)
k,g=[],[]
for i in range(n):
    if i%2==0:
        k.append(s[i])
    else:
        g.append(s[i])
#print(k)
#print(g)
for j in k:
    if j == 'L':
        print('No')
        break

else:
    for l in g:
        if l == 'R':
            print('No')
            break
    else:
        print('Yes')
        break
Problem p02947 (python)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

Buggy submission (verdict: Runtime Error):
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = c.values()

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    ans += combinations_count(i, 2)
    if i == 1:
        break

print(ans)
Problem p02982 (python)

Fixed submission:
def dis(d, x, y):
    a = 0
    for i in range(d):
        a += (x[i] - y[i])**2
    return a**0.5
    
n, d = map(int,input().split())
#print(n,d)

l = []
for j in range(n):
    l.append(input().split())

c=[]
for j in l:
    b=[]
    for k in j:
        b.append(int(k))
    c.append(b)
#print(c)

z = []
for e in range(n):
    for f in range(e,n):
        g = dis(d, c[e], c[f])
        if g == int(g) and g != 0:
            z.append(g)
print(len(z))

Buggy submission (verdict: Runtime Error):
# 当初理解が及ばずできなかったが、後日リベンジできた！
# B問題とは思えない！

def dis(d, x, y): #d次元、2点間の距離の関数
    a = 0
    for i in range(d):
        a += (x[i] - y[i])**2
    return a**0.5
    
n, d = map(int,input().split())

l=[] # n個の座標を2次元リストで取得
for j in range(n):
    b,c=[int(j) for j in input().split()]
    l.append([b,c])

z = []
for e in range(n):
    for f in range(e,n): #重複（逆の組み合わせ）無し
        g = dis(d, l[e], l[f]) #各座標間の距離を関数で取得
        if g == int(g) and g != 0: #距離が整数かつゼロでないか確認
            z.append(g) # 上の条件をpassした値をリスト'z'へappend
            
print(len(z))
Problem p02983 (python)

Fixed submission:
a, b = map(int, input().split())

if b-a >= 2019:
    print(0)
else:
    c = []
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append(i*j % 2019)
    #print(c)
    print(min(c))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
#print(a,b)
c = []
if (b-a) >= 2030:
    print(0)
else:
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append((i*j)%2019)
#print(c)
print(min(c))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
#print(a,b)
c = []
if b - a >= 2019:
    print(0)
else:
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append((i*j)%2019)
#print(c)
print(min(c))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(a,b)
c = []
if b - a >= 2019:
    print(0)
else:
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append((i*j)%2019)
#print(c)
print(min(c))
Problem p02995 (python)

Fixed submission:
import fractions

a,b,c,d = map(int, input().split())
#print(a,b,c,d)
total = b-a+1
#print(total)
lcm = int(c*d / fractions.gcd(c,d))
#print(lcm)
x = (b//c) + (b//d) - (b//lcm)
y = ((a-1)//c) + ((a-1)//d) - ((a-1)//lcm)
#print(x,y)
print(total - (x - y))

Buggy submission (verdict: Runtime Error):
import fractions

a,b,c,d = map(int, input().split())
print(a,b,c,d)
total = b-a+1
print(total)
lcm = c*d / fractions.gcd(c,d)
x = (b//c)) + (b//d) - (b//lcm)
y = ((a-1)//c) + ((a-1)//d) - ((a-1)//lcm)
print(x,y)
print(total - (x - y))
Problem p03023 (python)

Fixed submission:
n = int(input())
 
print(180*n-360)

Buggy submission (verdict: Runtime Error):
n = int(input())

print(180*r-360)
Problem p03061 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
#print(l)
l2 = list(reversed(l))
#print(l2)
#from itertools import combinations
#a = list(combinations(l, n-1))
#print(a)
from fractions import gcd
L, R = [0], [0]
for i in range(n):
    L.append(gcd(L[i],l[i]))
    R.append(gcd(R[i],l2[i]))
#print(L)
R = list(reversed(R))
#print(R)
g = []
for j in range(n):
    g.append(gcd(L[j],R[j+1]))
print(max(g))


#from functools import reduce

#def gcd_list(numbers):
#    return reduce(gcd, numbers)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l = list(set(l))
n = len(l)

from itertools import combinations
a = list(combinations(l, n-1))
#print(a)

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

g = []
for i in range(len(a)):
    g.append(gcd_list(a[i]))
#print(g)
print(max(g))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l = list(set(l))
n = len(l)

from itertools import combinations
a = list(combinations(l, n-1))
#print(a)

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

g = []
for i in range(len(a)):
    g.append(gcd_list(a[i]))

print(max(g))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l = list(set(l))
#print(l)

from itertools import combinations
a = list(combinations(l, n-1))
#print(a)

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

g = []
for i in range(len(a)):
    g.append(gcd_list(a[i]))

print(max(g))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l = set(l)
#print(l)

from itertools import combinations
a = list(combinations(l, n-1))
#print(a)

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

g = []
for i in range(len(a)):
    g.append(gcd_list(a[i]))

print(max(g))
Problem p03076 (python)

Fixed submission:
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
#print(yyy)
zzz = []
for m in yyy:
    if int(m) > 0:
        zzz.append(m)
#print(zzz)
if 0 < sum(zzz):
    p = min(zzz)
    print(sum(xxx) - (10 - p))
else:
    p = 0
    print(sum(xxx))

Buggy submission (verdict: Runtime Error):
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
#print(yyy)
zzz = []
for m in yyy:
    if int(m) > 0:
        zzz.append(m)
#print(zzz)
p = min(zzz)
print(sum(xxx) - (10 - p))

Buggy submission (verdict: Runtime Error):
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
zzz = []
for l in yyy:
    if int(l) > 0:
        zzz.append(l)
#print(zzz)
p = min(zzz)
print(sum(xxx) - (10 - p))

Buggy submission (verdict: Runtime Error):
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))

yyy = []
for k in keta:
    yyy.append(int(k[-1]))
zzz = []
for l in yyy:
    if int(l) > 0:
        zzz.append(l)
p = min(zzz)
print(sum(xxx) - p)
Problem p03282 (python)

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

for i in range(k):
    if s[i] == '1':
        continue
    else:
        print(int(s[i]))
        break
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s =input()
n = len(s)+1
k = int(input())

for i in range(n):
    if s[i] == '1':
        continue
    else:
        print(int(s[i]))
        break
else:
    print(1)
Problem p03294 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))

from fractions import gcd 

x =1
for i in l:
    x = x * i // gcd(x, i)

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(int(y))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))

from fractions import gcd 

x =1
for i in l:
    x=int(x * i / gcd(x, i))

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))

from fractions import gcd 

x =l[0]
for i in range(1,n):
    x=int(x * l[i] / gcd(x, l[i]))

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)
Problem p03573 (python)

Fixed submission:
a, b, c = map(int,input().split())

if a==b: print(c)
elif a==c: print(b)
else: print(a)

Buggy submission (verdict: Runtime Error):
if a==b: print(c)
elif a==c: print(b)
else: print(a)
Problem p03761 (python)

Fixed submission:
n = int(input())
l = [list(list(input())) for _ in range(n)]

l = sorted(l, key = len)

x = []
for i in range(len(l[0])):
    y = 0
    for j in range(n):
        if l[0][i] in l[j]:
            y +=1
            if y == n:
                x.append(l[0][i])
                for k in range(1, n):
                    l[k].remove(l[0][i])

print(''.join(sorted(x)))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(list(input())) for _ in range(n)]

x = []
for i in range(len(l[0])):
    if (l[0][i] in l[1]) and (l[0][i] in l[2]):
        x.append(l[0][i])
        l[1].remove(l[0][i])
        l[2].remove(l[0][i])

print(''.join(sorted(x)))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(list(input())) for _ in range(n)]
for i in range(n):
    l[i].sort()

x = []
for i in range(len(l[0])):
    if l[0][i] == l[1][i] == l[2][i]:
        x.append(l[1][i])

print(''.join(sorted(x)))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(list(input())) for _ in range(n)]
for i in range(n):
    l[i].sort()

x = []
for i in range(len(l[0])):
    if l[0][i] == l[1][i] == l[2][i]:
        x.append(l[1][i])
print(*sorted(x))
Problem p03962 (python)

Fixed submission:
a=input().split()

if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1] and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a=input().split()
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a=input().split()
#a=int(input())
#b=int(input())
#c=int(input())
#d=int(input())
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a=input().split()
#a=int(input())
#b=int(input())
#c=int(input())
#d=int(input())
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a=input().split()
#a=int(input())
#b=int(input())
#c=int(input())
#d=int(input())
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a=input().split()
#a=int(input())
#b=int(input())
#c=int(input())
#d=int(input())
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)
Problem p03971 (python)

Fixed submission:
n,a,b = map(int,input().split())
s=input()

AB=0
B=0
for i in range(n):
    if s[i] =='a':
        if AB<a+b:
            AB+=1
            print('Yes')
        else:
            print('No')
    elif s[i] =='b':
        B+=1
        if AB<a+b and B<=b:
            AB+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
5 2 2
ccccc
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n<=k:
    print(n*x)
else:
    print(k*x+y*(n-k))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(c*b+d*(a-b))a=int(input())
Problem p04044 (python)

Fixed submission:
a=input().split()
b=int(a[0])
data = [input() for i in range(b)]
data.sort()
#print(data)

k=""
for i in data:
    k=k+i
print(k)

Buggy submission (verdict: Runtime Error):
a=input().split()
b=int(a[0])
data = [input() for i in range(+1)]
sort(data)

for j in data:
    c=c+j
    
print(c)

Buggy submission (verdict: Runtime Error):
a=input().split()
b=int(a[0])
data = [input() for i in range(b)]
sort(data)

for j in data:
    c=c+j
    
print(c)
Problem p02536 (python)

Fixed submission:
N,M=map(int,input().split())
road=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
ischecked=[0]*(N)
ans=0
for i in range(N):
    if ischecked[i]==1:
        continue
    ischecked[i]=1
    q=[i]
    while q:
        now=q.pop()
        nex=road[now]
        for j in nex:
            if ischecked[j]!=0:
                continue
            q.append(j)
            ischecked[j]=1
    ans+=1
print(ans-1)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)

def segfunc(x, y):
    return max(x,y)
ide_ele =0

class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
Ma=max(A)
Tree=[0]*(Ma+1)
seg = SegTree(Tree, segfunc, ide_ele)
ans=0
for i in range(N):
    a=A[i]
    l=max(0,a-K)
    r=min(a+K,Ma)
    Ans=seg.query(l,r+1)
    seg.update(a, Ans+1)
    ans=max(ans,Ans+1)
print(ans)
Problem p02684 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ischecked=[0]*N
move=[]
move1=[]
now=0
count=0
count1=0
while 1:
    move.append(now+1)
    nex=A[now]-1
    ischecked[now]=1
    if ischecked[nex]==1:
        roop=nex+1
        break
    now=nex
for i in range(len(move))[::-1]:
    move1.append(move[i])
    if move[i]==roop:
        b=len(move)-i
        break
if K>=len(move):
    n=K-len(move)
    n=n%len(move1)
    print(move1[len(move1)-1-n])
else:
    print(move[K])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
ischecked=[0]*N
move=[]
move1=[]
now=0
count=0
count1=0
while 1:
    move.append(now+1)
    nex=A[now]-1
    ischecked[now]=1
    if ischecked[nex]==1:
        roop=nex+1
        break
    now=nex
for i in range(len(move))[::-1]:
    move1.append(move[i])
    if move[i]==roop:
        b=len(move)-i
        break
if K>len(move):
    n=K-len(move)
    n=n%len(move1)
    print(move1[len(move1)-1-n])
else:
    print(move[K])
Problem p02691 (python)

Fixed submission:
import bisect
N=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
ans=0
for i in range(N):
    L.append(i+1+A[i])
    R.append(i+1-A[i])
L.sort()
R.sort()
for i in L:
    l=bisect.bisect_left(R,i)
    r=bisect.bisect_right(R,i)
    ans=ans+r-l
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
a=[]
B=[]
ans=0
for i in range(1,N):
    b=A[i]+A[0]
    a.append(b-i)
    B.append(A[i]-A[0])
ans=a.counter(0)
for i in range(N):
    b=B[i]
    a1=a[i:].copy()
    a1=a1-[b-i-1]
    ans+=a1.counter(0)
print(ans)
Problem p02697 (python)

Fixed submission:
N,M=map(int,input().split())
l=1
r=N
dis=set()
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.add(a)
        dis.add(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
l=1
r=N
dis=[]
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.append(a)
        dis.append(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l=N+l-r:
            r=r-1
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
ans=[]
for i in range(X):
    a=i+1
    ans.append(p[-a])
for i in range(Y):
    a=i+1
    ans.append(q[-a])
for i in r:
    ans.append(i)
ans.sort()
Ans=0
for i in range(X+Y):
    a=i+1
    Ans+=ans[-a]
print(Ans)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
del p[:-X]
del q[:-Y]
if len(r)>X+Y:
    del r[:-max(X+Y)]
ans=sum(p)+sum(q)
for i in range(len(r)):
    a=r[-(i+1)]
    minp=min(p)
    minq=min(q)
    if minp<=minq and minp<a:
        ans=ans-minp+a
        del p[p.index(minp)]
        p.append(a)
    elif minp>=minq and minq<a:
        ans=ans-minq+a
        del q[q.index(minq)]
        q.append(a)
    else:
        break
print(ans)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a+b<c and 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if a+b<c and 4*a*b<(c-a-b)**2
    print("Yes")
else:
    print("No")
Problem p02783 (python)

Fixed submission:
H,A=map(int,input().split())
B=H//A
if H%A==0:
    print(B)
else:
    print(B+1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
H,N=map(int,input().split())
List=[]
A=0
B=0
C=10*10*10*10
D=0
for i in range(N):
    a,b=list(map(int,input().split()))
    c=a/b
    List.append((a,b,c))
List1=sorted(List,key=itemgetter(2))
List2=sorted(List,key=itemgetter(0))
for i in range(H):
    if A<H:
        h=H-A
        if h>=List1[N-1][0]:
            A=A+List1[N-1][0]
            B=B+List1[N-1][1]
        else:
            for j in range(N):
                if List2[j][0]>=h:
                    temp1=List2[j][0]
                    temp=List2[j][1]
                    if temp<=C:
                        C=temp
                        D=temp1
            B=B+C
            A=A+D
    elif A>=H:
        break
print(B)
Problem p02787 (python)

Fixed submission:
H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
x=max(a for a,b in ab)
dp=[0]*(H+x)
for i in range (1,H+x):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
x=max(a for a,b in ab)
dp=[0]*(H+10)
for i in range (1,H+1):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
dp=[0]*(H+1)
for i in range (1,H+1):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
dp=[0]*(H)
for i in range (1,H+1):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
AB=[]
for _ in range(N):
    a,b=map(int,input().split())
    AB.append((a,b))
dp=[0]*(H+1)
for i in range(1,H+1):
    for a,b in AB:
        if dp[i]==0:
            dp[i]=dp[max(i-a,0)]+b
        else:
            dp[i]=min(dp[i],dp[i-a]+b)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
AB=[]
for _ in range(N):
    a,b=map(int,input().split())
    AB.append((a,b))
AB.sort()
amax=AB[-1][0]
dp=[0]*(H+1)
for i in range(1,H+1):
    for a,b in AB:
        if dp[i]==0:
            dp[i]=dp[max(i-a,0)]+b
        else:
            dp[i]=min(dp[i],dp[i-a]+b)
print(dp[H])