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

Fixed submission:
n,K = map(int,input().split())
xy = [[int(i) for i in input().split()] for j in range(n)]

ans = 10**20

for i in range(n):
    for j in range(i+1,n):
        if K == 2:
            ans = min(ans,abs(xy[i][0]-xy[j][0])*abs(xy[i][1]-xy[j][1]))
        for k in range(j+1,n):
            if K == 2:
                break
            max_x_old = max(xy[i][0],xy[j][0],xy[k][0])
            min_x_old = min(xy[i][0],xy[j][0],xy[k][0])
            max_y_old = max(xy[i][1],xy[j][1],xy[k][1])
            min_y_old = min(xy[i][1],xy[j][1],xy[k][1])
            if K == 3:
                #max_x = max(xy[i][0],xy[j][0],xy[k][0])
                #min_x = min(xy[i][0],xy[j][0],xy[k][0])
                #max_y = max(xy[i][1],xy[j][1],xy[k][1])
                #min_y = min(xy[i][1],xy[j][1],xy[k][1])
                ans = min(ans,abs(max_x_old-min_x_old)*abs(max_y_old-min_y_old))
            for l in range(k+1,n):
                if K == 2 or K == 3:
                    break
                cnt = 0
                max_x = max(max_x_old,xy[l][0])
                min_x = min(min_x_old,xy[l][0])
                max_y = max(max_y_old,xy[l][1])
                min_y = min(min_y_old,xy[l][1])
                for m in range(n):
                    if xy[m][0] >= min_x and xy[m][0] <= max_x\
                       and xy[m][1] >= min_y and xy[m][1] <= max_y:
                           cnt += 1
                if cnt >= K:
                    #print(cnt,K)
                    ans = min(ans,(max_x-min_x)*(max_y-min_y))
                
print(ans)

Buggy submission (verdict: Runtime Error):
n,K = map(int,input().split())
xy = [[int(i) for i in input().split()] for j in range(n)]

ans = 10**20

for i in range(n):
    for j in range(i+1,n):
        if K == 2:
            ans = min(ans,abs(xy[i][0]-xy[j][0])*abs(xy[i][1]-xy[j][1]))
        for k in range(j+1,n):
            if K == 2:
                print(xy[n][2])
                break
            max_x = max(xy[i][0],xy[j][0],xy[k][0])
            min_x = min(xy[i][0],xy[j][0],xy[k][0])
            max_y = max(xy[i][1],xy[j][1],xy[k][1])
            min_y = min(xy[i][1],xy[j][1],xy[k][1])
            if K == 3:
                #max_x = max(xy[i][0],xy[j][0],xy[k][0])
                #min_x = min(xy[i][0],xy[j][0],xy[k][0])
                #max_y = max(xy[i][1],xy[j][1],xy[k][1])
                #min_y = min(xy[i][1],xy[j][1],xy[k][1])
                ans = min(ans,abs(max_x-min_x)*abs(max_y-min_y))
            for l in range(k+1,n):
                if K == 2 or K == 3:
                    print(xy[n][2])
                    break
                cnt = 0
                max_x = max(max_x,xy[l][0])
                min_x = min(min_x,xy[l][0])
                max_y = max(max_y,xy[l][1])
                min_y = min(min_y,xy[l][1])
                for m in range(n):
                    if xy[m][0] >= min_x and xy[m][0] <= max_x\
                       and xy[m][1] >= min_y and xy[m][1] <= max_y:
                           cnt += 1
                if cnt >= K:
                    #print(cnt,K)
                    ans = min(ans,(max_x-min_x)*(max_y-min_y))
                
print(ans)
Problem p03623 (python)

Fixed submission:
x,a,b = map(int,input().split())
if abs(x-a) > abs(x-b):
    print('B')
else:
    print('A')

Buggy submission (verdict: Runtime Error):
x,a,b = map(int.input().split())
if abs(x-a) > abs(x-b):
    print('B')
else:
    print('A')
Problem p03625 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse= True)

cnt = 0
top = []

for i in range(n-1):
    #print(i)
    if len(top) == 2:
        break    
    if a[i] == a[i+1]:
        if len(top) == 2:
            break
        if cnt%2 == 0:
            top.append(a[i])
        cnt += 1
    else:
        cnt = 0

if len(top) < 2:
    print(0)
    exit()

print(int(top[0]*top[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse= True)

cnt = 0
top = []

for i in range(n):
    if len(top) == 2:
        break    
    for j in range(4):
        if a[i] == a[i+1+j]:
            if len(top) == 2:
                break
            if j == 1:
                top.append(a[i])
            elif j == 3:
                top.append(a[i])

if len(top) != 2:
    print(0)
    exit()

print(int(top[0]*top[1]))
Problem p03633 (python)

Fixed submission:
import fractions

n = int(input())
a = [int(input()) for i in range(n)]

if len(a) == 1:
    print(a[0])
    exit()

ans = a[0] * a[1] // fractions.gcd(a[0],a[1])

for i in range(1,n-1):
    ans = ans * a[i+1] // fractions.gcd(ans,a[i+1])
    
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

n = int(input())
a = [int(input()) for i in range(n)]

ans = a[0] * a[1] // fractions.gcd(a[0],a[1])

for i in range(1,n-1):
    ans = ans * a[i+1] // fractions.gcd(ans,a[i+1])
    
print(ans)
Problem p03651 (python)

Fixed submission:
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

if n == 1:
    if k == ai[0]:
        print('POSSIBLE')
        exit()
    else:
        print('IMPOSSIBLE')
        exit()

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

g = math.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = math.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Problem p03826 (python)

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

print(max(a*b,c*d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input())

print(max(a*b,c*d))
Problem p03828 (python)

Fixed submission:
n = int(input())

mod = 10**9+7

sosu = [1] * 1001

for j in range(2,n+1):
    tmp = j
    i = 2
    while tmp > 1:
        if tmp % i == 0:
            sosu[i] += 1
            tmp = tmp // i
        else:
            i += 1
        
#print(sosu)
sosu.sort(reverse=True)

ans = 1

for i in range(len(sosu)):
    if sosu[i] > 1:
        ans = ans*sosu[i] % mod
        
print(ans)

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

mod = 10**9+7

sosu = [1] * 100

for j in range(2,n+1):
    tmp = j
    while tmp > 1:
        for i in range(2,n+1):
            if tmp % i == 0:
                sosu[i] += 1
                tmp = tmp // i
        
#print(sosu)
sosu.sort(reverse=True)

ans = 1

for i in range(len(sosu)):
    if sosu[i] > 0:
        ans = ans*sosu[i] % mod
        
print(ans)
Problem p03844 (python)

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

a = int(a)
c = int(c)

if b == "+":
    print(int(a)+c)
else:
    print(a-c)

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()

if b == "+":
    print(a+c)
else:
    print(a-c)
Problem p03994 (python)

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

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k and num != 26:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]

     
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k%26)
        
print(*moji,sep='')

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

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]
        
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k)
        
print(*moji,sep='')
Problem p03125 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = mao (int, input ().split ())
if B%A == 0:
  print (A+B)
else:
  print (B-A)
Problem p03302 (python)

Fixed submission:
a,b = map (int, input ().split ())
if a+b == 15:
  print ('+')
elif a*b == 15:
  print ('*')
else:
  print ('x')

Buggy submission (verdict: Runtime Error):
a,b = int (input ())
if a+b == 15:
  print ('+')
elif a*b == 15:
  print ('*')
else:
  print ('x')
Problem p03433 (python)

Fixed submission:
n = int (input ())
a = int (input ())
o = n%500
if a < o:
  print ('No')
else:
  print ('Yes')

Buggy submission (verdict: Runtime Error):
import math
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)
Problem p03434 (python)

Fixed submission:
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
y = 0
while True:
    x += int (l[a])
    a += 1
    if a == N:
        break
    y += int (l[a])
    a += 1
    if a == N:
        break
print (x-y)

Buggy submission (verdict: Runtime Error):
import math
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
import math
N = int (input ())
l = input ().split ()
l = [int(s) for s in l]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
for i in range (round(N/2)):
    x += int (l[a])
    a += 2
b = 1
y = 0
for i in range (N-(round(N/2))):
    y += int (l[b])
    b += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
for i in range (round(N/2)):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-(round(N/2))):
    y += int (l[a])
    a += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
for i in range (round(N/2)):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-(round(N/2))):
    y += int (l[a])
    a += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
for i in range (round(N/2)):
    x += l[a]
    a += 2
a = 1
y = 0
for i in range (N-(round(N/2))):
    y += l[a]
    a += 2
print (x-y)

Buggy submission (verdict: Runtime Error):
N = int (input ())
l = []
for i in range (N):
    a = int (input ())
    l.append (a)
list.sort (l, reverse=True)
a = 0
x = 0
for i in range (round(N/2)):
    x += l[a]
    a += 2
a = 1
y = 0
for i in range (N-(round(N/2))):
    y += l[a]
    a += 2
print (x-y)
Problem p03543 (python)

Fixed submission:
a = input ()
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
  print ('Yes')
else:
  print ('No')

Buggy submission (verdict: Runtime Error):
a = int (inout ())
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
  print ('Yes')
else:
  print ('No')
Problem p03547 (python)

Fixed submission:
a,b = input ().split ()
if a < b:
  print ('<')
elif a > b:
  print ('>')
else:
  print ('=')

Buggy submission (verdict: Runtime Error):
a,b = input ().split ()
if a < b:
  print ('<')
elif a > b:
  pritn ('>')
else:
  print ('=')
Problem p03679 (python)

Fixed submission:
x,a,b = (int(i) for i in input().split())
if a < b:
  if b-a > x:
    print ('dangerous')
  else:
    print ('safe')
else:
  print ('delicious')

Buggy submission (verdict: Runtime Error):
x,a,b = (int(x) for x in input().split())
if a < b:
  if b-a > c:
    print ('dengerous')
  else:
    print ('safe')
else:
  print ('delicious')
Problem p03711 (python)

Fixed submission:
x,y = (int(x) for x in input().split())
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]
n = 0
if x in l1:
  if y in l1:
    print ('Yes')
    n = 1
elif x in l2:
  if y in l2:
    print ('Yes')
    n = 1
else:
  if y in l3:
    print ('Yes')
    n = 1
if n == 0:
  print ('No')

Buggy submission (verdict: Runtime Error):
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]
n = 0
if x in l1:
  if y in l1:
    print ('Yes')
    n = 1
elif x in l2:
  if y in l2:
    print ('Yes')
    n = 1
else:
  if y in l3:
    print ('Yes')
    n = 1
if n == 0:
  print ('No')
Problem p03844 (python)

Fixed submission:
a,b,c = input ().split ()
a = int (a)
c = int (c)
if b == '+':
  print (a+c)
else:
  print (a-c)

Buggy submission (verdict: Runtime Error):
a,b,c = input ().split ()
a,b = int (a,b)
if b == '+':
  print (a+b)
else:
  print (a-b)
Problem p03852 (python)

Fixed submission:
S = input()
if S=='a' or S=='i' or S=='u' or S=='e' or S=='o':
  print ('vowel')
else:
  print ('consonant')

Buggy submission (verdict: Runtime Error):
N = int (input ())
S = input()
S = S.replace('a','')
S = S.replace('i','')
S = S.replace('u','')
S = S.replace('e','')
S = S.replace('o','')
print (N-int (len(S)))
Problem p03943 (python)

Fixed submission:
l = [int(x) for x in input().split()]
if l[2]==l[0]+l[1] or l[0]==l[1]+l[2] or l[1]==l[0]+l[2]:
  print ('Yes')
else:
  print ('No')

Buggy submission (verdict: Runtime Error):
list.sort (l, reverse=True)
a = int (l[0])
b = int (l[1])
c = int (l[2])
if a == b+c:
  print ('Yes')
else:
  print ('No')
Problem p03962 (python)

Fixed submission:
a,b,c = (int(x) for x in input().split())
if a == b:
  if a == c:
    print (1)
  else:
    print (2)
else:
  if a == c:
    print (2)
  else:
    if b == c:
      print (2)
    else:
      print (3)

Buggy submission (verdict: Runtime Error):
a,b,c = (int(x) for x in input().split())
if a == b:
  if a == c:
    print (1)
  else:
    pritn (2)
else:
  if a == c:
    print (2)
  else:
    if b == c:
      print (2)
    else:
      print (3)

Buggy submission (verdict: Runtime Error):
a,b,c = (int(x) for x in input().split())
if a == b:
  if a == c:
    print (1)
  else:
    pritn (2)
else:
  if a == c:
    print (2)
  else:
    print (3)
Problem p03997 (python)

Fixed submission:
a = int (input ())
b = int (input ())
h = int (input ())
print ((a+b)*(round(h/2)))

Buggy submission (verdict: Runtime Error):
a = int (input ())
b = int (input ())
h = int (input ()/2)
print ((a+b)*h)
Problem p04029 (python)

Fixed submission:
N = int (input ())
x =0
for i in range (N):
  x += N-i
print (x)

Buggy submission (verdict: Runtime Error):
N = int (input ())
print (N*(N+1))/2
Problem p02573 (python)

Fixed submission:
n,m=list(map(int,input().split()))
par=[i for i in range(n)]
ro=dict()

for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        a=root(par[i])
        par[i]=a
        return a

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)

print(max(ro.values()))

Buggy submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
par=[i for i in range(n)]
ro=dict()
for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        return root(par[i])

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)


# for i in range(n):
#     ro[root(i)]+=1

print(max(ro.values()))

Buggy submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
par=[i for i in range(n)]
ro=dict(int)
for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        return root(par[i])

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)


# for i in range(n):
#     ro[root(i)]+=1

print(max(ro.values()))

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

from collections import defaultdict

par=[i for i in range(n)]
ro=defaultdict(int)
for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        return root(par[i])

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)


# for i in range(n):
#     ro[root(i)]+=1

print(max(ro.values()))

Buggy submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
f=[set() for i in range(n)]

from collections import defaultdict

g=[set() for i in range(n)]

par=[i for i in range(n)]

def root(i):
    if par[i]==i:
        return i
    else:
        return root(par[i])

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry

def same(x,y):
    return root(x)==root(y)

for i in range(m):
    a,b=list(map(int,input().split()))
    # f[a-1].add(b-1)
    # f[b-1].add(a-1)
    a-=1
    b-=1
    unite(a,b)

ans=0
ro=defaultdict(int)
for i in range(n):
    ro[root(i)]+=1

print(max(ro.values()))
Problem p02574 (python)

Fixed submission:

# A以下の数がN個与えられる。全て素因数分解せよ。
class SpeedPrime:
    # a以下の各数の最小の素因数を記録
    def __init__(self, a):
        self.d = [i for i in range(a+1)]

        i=2
        while i*i<=a:
            if self.d[i]==i:
                j=i*i
                while j<=a:
                    if self.d[j]==j:
                        self.d[j]=i
                    j+=i
            i+=1

    # nを高速素因数分解
    def fac(self, n):
        ret = dict()
        while n!=1:
            prime=self.d[n]
            if prime in ret:
                ret[prime]+=1
            else:
                ret[prime]=1
            n=n//prime
        return ret

import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd, numbers)

n=int(input())
a=list(map(int,input().split()))

sp=SpeedPrime(max(a))

d=set()
pc=True
for i in a:
    prime=sp.fac(i)
    for k in prime.keys():
        if k in d:
            pc=False
            break
        else:
            d.add(k)

if pc:
    print("pairwise coprime")
    exit()

g=gcd(a)
if g==1:
    print("setwise coprime")
else:
    print("not coprime")

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

from math import gcd
from itertools import combinations as cmb

par=[i for i in range(n)]

def root(i):
    if par[i]==i:
        return i
    else:
        r=root(par[i])
        par[i]=r
        return r

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry

co=False
set=a[0]
setok=False
for i,j in cmb(range(n),2):
    if i==0:
        set=gcd(set,a[j])
        if setok&set==1:
            print("setwise coprime")
            exit()
    if root(i)!=root(j):
        g=gcd(a[i],a[j])
        if g==1:
            co=True
            unite(i,j)
        else:
            setok=True
            if co:
                print("setwise coprime")
                exit()

if setok:print("not coprime")
else:print("pairwise coprime")

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

from math import gcd
from itertools import combinations as cmb

par=[i for i in range(n)]

def root(i):
    if par[i]==i:
        return i
    else:
        r=root(par[i])
        par[i]=r
        return r

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry

co=False
set=a[0]
setok=False
for i,j in cmb(range(n),2):
    if i==0:
        set=gcd(set,a[j])
        if setok&set==1:
            print("setwise coprime")
            exit()
    if root(i)!=root(j):
        g=gcd(a[i],a[j])
        if g==1:
            co=True
            unite(i,j)
        else:
            setok=True
            if co:
                print("setwise coprime")
                exit()

if setok:print("not coprime")
else:print("pairwise coprime")
Problem p02665 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ok=True

v=[0 for i in range(n+2)]
import time

#start=time.time()
nextv=0

nec=2**n

for i in range(n,-1,-1):

    if nec>=v[i+1]+a[i]:
        v[i]=v[i+1]+a[i]
    else:
        v[i]=nec

    nec=nec >>1



#print(time.time()-start)

for i in range(1,n+1):
    if v[i-1]-a[i-1]<0:
        ok=False
        break
    if (v[i-1]-a[i-1])*2<v[i]:
        v[i]=(v[i-1]-a[i-1])*2


if n==0:
    if a[0]!=1:ok=False
else:
    if a[0] != 0:ok = False

if v[n]!=a[n]:ok=False

ans=sum(v)
if ans==0:ok=False

if ok:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
input())
a=list(map(int,input().split()))
ok=True

v=[0 for i in range(n+2)]
import time

#start=time.time()
nextv=0

nec=2**n

for i in range(n,-1,-1):

    if nec>=v[i+1]+a[i]:
        v[i]=v[i+1]+a[i]
    else:
        v[i]=nec

    nec=nec >>1



#print(time.time()-start)

for i in range(1,n+1):
    if v[i-1]-a[i-1]<0:
        ok=False
        break
    if (v[i-1]-a[i-1])*2<v[i]:
        v[i]=(v[i-1]-a[i-1])*2

if a[0]!=0:ok=False

ans=sum(v)

if ans==0:ok=False

if ok:
    print(ans)
else:
    print(-1)
Problem p02727 (python)

Fixed submission:
x,y,a,b,c=list(map(int,input().split()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
p=p[:x]
q=q[:y]
r.extend(p)
r.extend(q)
r.sort(reverse=True)

ans=sum(r[:x+y])

print(ans)

Buggy submission (verdict: Runtime Error):
x,y,a,b,c=list(map(int,input().split()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=[(0,i,n) for i,n in enumerate(p)]
q=[(1,i,n) for i,n in enumerate(q)]
r=[(2,i,n) for i,n in enumerate(r)]

p.extend(r)
p.sort(key=lambda x: x[2],reverse=True)

ans=0
for c,i,n in p:
    ans+=n
    if c==2:
        r.pop(i)
    x-=1
    if x==0:
        break

q.extend(r)
q.sort(key=lambda x: x[2],reverse=True)

for i in range(y):
    ans+=q[i][2]

print(ans)
Problem p02787 (python)

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

for i in range(n):
    aabb=list(map(int,input().split()))
    ab.append(aabb)
    a.append(aabb[0])

loop=h+max(a)
cost=[-1 for i in range(loop)]
cost[0]=0
i=0
costlist=[]
while i<loop:
    costlist=[]
    for j in range(n):
        ii=i-ab[j][0]
        if (0<=ii<h)&(cost[ii]>=0):
            costlist.append(cost[ii]+ab[j][1])
    if len(costlist)!=0:
        cost[i]=min(costlist)
    i+=1
acost=[i for i in cost[h:] if i!=-1]
ans=min(acost)
print(ans)

Buggy submission (verdict: Runtime Error):
h,n=map(int,input().split())
a=[]
ab=[]

for i in range(n):
    aabb=list(map(int,input().split()))
    ab.append(aabb)
    a.append(aabb[0])

loop=h+max(a)
cost=[-1 for i in range(loop)]
cost[0]=0
i=0
costlist=[]
while i<loop:
    costlist.clear()
    for j in range(n):
        ii=i-ab[j][0]
        if (0<=ii<h)&(cost[ii]>=0):
            costlist.append(cost[ii]+ab[j][1])
    if len(costlist)!=0:
        cost[i]=min(costlist)
    i+=1
acost=[i for i in cost[h:] if i!=-1]
ans=min(acost)
print(ans)
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m==map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")