Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
res = 0
for i in range(1,N+1):
    if i%15==0:
        dp = 0
    elif i%5==0:
        dp = 0
    elif i%3==0:
        dp = 0
    else :å
        dp = i
    res = res+dp
print(res)

Fixed submission:
N = int(input())
res = 0
for i in range(1,N+1):
    if i%15==0:
        dp = 0
    elif i%5==0:
        dp = 0
    elif i%3==0:
        dp = 0
    else :
        dp = i
    res = res+dp
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())
res=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            #print(a,b,c)
            tmp = (math.gcd(math.gcd(a,b),c))
            res += tmp
print(res)

Fixed submission:
import math

K = int(input())
res=0
for a in range(1,K+1):
    for b in range(1,K+1):
        tmp = math.gcd(a,b)
        for c in range(1,K+1):
            #print(a,b,c)
            res += math.gcd(tmp,c)
print(res)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

tmp_init = [1]*A + [0]*B
#len_add = len(tmp)
sum_tmp_init = sum(tmp_init)
len_tmp = len(tmp_init)
sum_b = 0
len0 = 0
tmp = []
while len(tmp) < N:
    sum_b += sum_tmp_init
    len0 += len_tmp
    tmp += [1]*A + [0]*B

ans = sum_b -sum_tmp_init  + sum(tmp_init[:N-len0+len_tmp])

print(ans)

Fixed submission:
N, A, B = map(int, input().split())
if N >= (A+B):
    ans = A * (N//(A+B)) + min((N - ((A + B) * (N//(A+B)))), A)
elif N > A:
    ans = A
elif A >= N:
    ans = N
print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

tmp = [1]*A + [0]*B
while len(tmp) < N:
    tmp += tmp
ans = sum(tmp[:N])

print(ans)

Fixed submission:
N, A, B = map(int, input().split())
if N >= (A+B):
    ans = A * (N//(A+B)) + min((N - ((A + B) * (N//(A+B)))), A)
elif N > A:
    ans = A
elif A >= N:
    ans = N
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lis_X = list(map(int, input().split()))

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(a,b):
    return (a-b)**2

if N == 1:
    ans = 0
else :
    res = []
    for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
        tmp = sum(list(map(lambda x:calc_dif_sq(x, p), lis_X_sorted)))
        res.append(tmp)
    ans = min(res)
print(ans)

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

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(a,b):
    return (a-b)**2

if N == 1:
    ans = 0
elif min(lis_X_sorted)==max(lis_X_sorted):
    ans = 0
else :
    res = []
    for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
        tmp = sum(list(map(lambda x:calc_dif_sq(x, p), lis_X_sorted)))
        res.append(tmp)
    ans = min(res)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
lis_X = list(map(int, input().split()))

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(a,b):
    return (a-b)**2

res = []
for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
    tmp = sum(list(map(lambda x:calc_dif_sq(x, p), lis_X_sorted)))
    res.append(tmp)
ans = min(res)
print(ans)

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

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(a,b):
    return (a-b)**2

if N == 1:
    ans = 0
elif min(lis_X_sorted)==max(lis_X_sorted):
    ans = 0
else :
    res = []
    for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
        tmp = sum(list(map(lambda x:calc_dif_sq(x, p), lis_X_sorted)))
        res.append(tmp)
    ans = min(res)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
lis_X = list(map(int, input().split()))

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(x,p):
    return (x-p)**2

res = []
for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
    tmp = sum(map(lambda x:calc_dif_sq(x, p), lis_X_sorted))
    res.append(tmp)
ans = min(res)
print(ans)

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

lis_X_sorted = sorted(lis_X)

def calc_dif_sq(a,b):
    return (a-b)**2

if N == 1:
    ans = 0
elif min(lis_X_sorted)==max(lis_X_sorted):
    ans = 0
else :
    res = []
    for p in range(lis_X_sorted[0],lis_X_sorted[-1]):
        tmp = sum(list(map(lambda x:calc_dif_sq(x, p), lis_X_sorted)))
        res.append(tmp)
    ans = min(res)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S_lis = []
for i in range(N):
    S_lis.append(input())

unique_S_lis = list(set(S_lis))
res = [S_lis.count(us) for us in unique_S_lis]
maxind = [i for i, x in enumerate(res) if x == max(res)]
lis_ans = sorted([unique_S_lis[i] for i in maxind])

for ans in lis_ans:
    print(ans)

Fixed submission:
N = int(input())
S_lis = []
for _ in range(N):
    S_lis.append(input())


S_set = set(S_lis)
S_dict = dict()
# dict initialize
for s in S_set:
    S_dict[s] = 0
# valが全文字通過していくときに辞書のカウントを+1
for val in S_lis:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S_lis = []
for i in range(N):
    S_lis.append(input())

unique_S_lis = list(set(S_lis))
res = []
for unique_str in unique_S_lis:
    res.append(S_lis.count(unique_str))

maxind = [i for i, x in enumerate(res) if x == max(res)]
lis_ans = sorted([unique_S_lis[i] for i in maxind])

for ans in lis_ans:
    print(ans)

Fixed submission:
N = int(input())
S_lis = []
for _ in range(N):
    S_lis.append(input())


S_set = set(S_lis)
S_dict = dict()
# dict initialize
for s in S_set:
    S_dict[s] = 0
# valが全文字通過していくときに辞書のカウントを+1
for val in S_lis:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)
Buggy python submission (verdict: Runtime Error):
def calc_exp(x):
    return (int(x) + 1)/2

NK = input().split()
N, K = int(NK[0]), int(NK[1])
#lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(calc_exp, input().split()))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Fixed submission:
N = int(input())
lisA = [int(i) for i in input().split()]
if len(set(lisA)) == len(lisA):
    print('YES')
else :
    print('NO')

Buggy python submission (verdict: Runtime Error):
def calc_exp(x:str)->float:
    return (int(x) + 1)/2

NK = input().split()
N, K = int(NK[0]), int(NK[1])
#lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(calc_exp, input().split()))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Fixed submission:
N = int(input())
lisA = [int(i) for i in input().split()]
if len(set(lisA)) == len(lisA):
    print('YES')
else :
    print('NO')
Buggy python submission (verdict: Runtime Error):
%%time
H = int(input())
counter = 0
i = H
while i > 1:
    i = i//2
    counter += 1
    
ans = 2**(counter+1)-1
print(ans)

Fixed submission:
H = int(input())
counter = 0
i = H
while i > 1:
    i = i//2
    counter += 1
    
ans = int(2**(counter+1)-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
%%time
N = int(input())
lis = list(map(int, input().split()))

counter = 0
for i in range(N):
    counter += int(lis[i] <= min(lis[:i+1]))
print(counter )

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

counter=0
minimum = 10000000
for i in range(N):
    minimum = min([minimum,lis[i]])
    counter += int(lis[i] <= minimum)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lis = list(map(int, input().split()))

counter = 0
for i in range(N):
    counter += int(lis[i] <= min(lis[:i+1]))
print(counter)

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

counter=0
minimum = 10000000
for i in range(N):
    minimum = min([minimum,lis[i]])
    counter += int(lis[i] <= minimum)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lis = list(map(int, input().split()))

counter = 0
for i in range(len(lis)):
    counter += 1*(lis[i] <= min(lis[:i+1]))
print(counter )

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

counter=0
minimum = 10000000
for i in range(N):
    minimum = min([minimum,lis[i]])
    counter += int(lis[i] <= minimum)
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = np.array([0] + input().split(), np.int32)
B = np.append(A[1:], 0)
S = np.abs(A - B).sum()

ans = [0] * (N + 1)
for i in range(1, N + 1):
    j = (i + 1) % (N + 1)
    d0 = A[i] - A[i - 1]
    d1 = A[j] - A[i - 1]
    f0 = d0 >= 0
    f1 = d1 >= 0
    # print(d0, d1)
    # i - 1, i, i + 1の並び
    if f0 == f1 and abs(d0) <= abs(d1):
        ans[i] = S
    # i - 1, i + 1, iの並び
    elif f0 == f1 and abs(d0) > abs(d1):
        ans[i] = S - 2 * abs(A[j] - A[i])
    # i, i - 1, i + 1の並び
    else:
        ans[i] = S - 2 * abs(d0)
print('\n'.join(str(x) for x in ans[1:]))


Fixed submission:
N = int(input())
A = [0] + [int(i) for i in input().split()]

S = abs(A[N] - A[0])
for i in range(N):
    S += abs(A[i] - A[i + 1])

for i in range(1, N + 1):
    j = (i + 1) % (N + 1)
    ans = S - abs(A[i - 1] - A[i]) - abs(A[i] - A[j]) + abs(A[i - 1] - A[j])
    print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())

x=100.0
for i in range(N):
    x=math.floor(x*1.01)
    if(x>=N):
        print(i+1)
        break;
    i+=1

Fixed submission:
import math
N=int(input())

x=100.0
for i in range(N):
    x=math.floor(x*1.01)
    if(x>=N):
        print(i+1)
        break;
    i+=1
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
A,B,N=map(int,input().split())
if(N<=B):
    x = np.array([j for j in range(N+1)])
else:
    x = np.array([j for j in range(B+1)])    
val=np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(val)))

Fixed submission:
import math
A,B,N=map(int,input().split())
if(N<B):
    x = N
else:
    x =B-1    

print(int( math.floor(A*x/B)-A*math.floor(x/B)  ))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
A,B,N=map(int,input().split())
x = np.array([j for j in range(N+1)])
val=np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(val)))


Fixed submission:
import math
A,B,N=map(int,input().split())
if(N<B):
    x = N
else:
    x =B-1    

print(int( math.floor(A*x/B)-A*math.floor(x/B)  ))

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
maxval=0
for x in range(N+1):
    if(maxval<=math.floor(A*x/B)-A*math.floor(x/B)):
        maxval=math.floor(A*x/B)-A*math.floor(x/B)
        ans=x
print(maxval)   

Fixed submission:
import math
A,B,N=map(int,input().split())
if(N<B):
    x = N
else:
    x =B-1    

print(int( math.floor(A*x/B)-A*math.floor(x/B)  ))
Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
Ai=list(map(int,input().split()))
for i in range(N):
    print(Ai.count(i+1))

Fixed submission:
import collections
N= int(input())
Ai=list(map(int,input().split()))
c=collections.Counter(Ai)

for i in range(N):
    print(c[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())


for i in range(Q):
    Qq=input()
    
    if(Qq.count(' ')>0):
        ti,fi,ci=Qq.split()
        if(fi=='1'):
            S=str(ci)+S
        else:
            S=S+str(ci)
    else:
        S=S[::-1]
print(S)

Fixed submission:
S=input()
Q=int(input())

flip=0
fr=''
ba=''
for i in range(Q):
    Qq=input()
    
    if(Qq.count(' ')>0):
        ti,fi,ci=Qq.split()
        if( flip%2==0   ):
            if(fi=='1'):
                fr=str(ci)+fr
            else:
                ba=ba+str(ci)
        else:
            if(fi=='1'):
                ba=ba+str(ci)
            else:
                fr=str(ci)+fr
    else:
        flip+=1
if(flip%2==0):
    print(fr+S+ba)
else:
    print(ba[::-1]+S[::-1]+fr[::-1])
Buggy python submission (verdict: Runtime Error):
A=[]
for i in range(3):
    A.append(list(input().split()))
N=int(input())
B=list(input() for i in range(N))

for i in range (N):
    for j in range(len(A[0])):
        if (B[i] in A[j]):
            #print(type(B[i]),B[i],A[j])
            A[j][A[j].index(B[i])]=0
check=0
if((A[0][0]+A[1][1]+A[2][2]==0) or (A[2][0]+A[1][1]+A[0][2]==0) ):
    print('Yes');check=1
else:    
    for j in range(len(A[0])): 
        if( (A[j][0]+A[j][1]+A[j][2]==0) or (A[0][j]+A[1][j]+A[2][j]==0)    ):    
            print('Yes');check=1
            break;
    if(check==0):
        print('No')

Fixed submission:
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = 0             
if( ((A[0][0]==0) and (A[1][1]==0) and (A[2][2]==0)) or
   ((A[2][0]==0) and (A[1][1]==0) and (A[0][2]==0)) ):
    print('Yes');exit(0)


for j in range(len(A[0])): 
    if( ((A[j][0]==0) and (A[j][1]==0) and (A[j][2]==0)) or
       ((A[0][j]==0) and (A[1][j]==0) and (A[2][j]==0))    ):    
        print('Yes');
        exit(0)

print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
from operator import itemgetter

N=int(input())
List=[str(input()) for i in range(N)]
SetList=list(set(List))
nc=[List.count(SetList[i]) for i in range(len(SetList))]

indexmax=np.where(np.array(nc) == np.array(nc).max())[0]
if(len(indexmax)==1):
    print(itemgetter(*indexmax)(SetList))
else:
    for i in sorted(itemgetter(*indexmax)(SetList)):
        print(i) 


Fixed submission:
A, B, C=map(int,input().split())
if((A==B) & (B!=C)):
    ans='Yes'
elif((A==C) & (B!=C)):
    ans='Yes'
elif((B==C) & (B!=A)):
    ans='Yes'
else:
    ans='No'
print(ans)
Buggy python submission (verdict: Runtime Error):
Nnum=int(input())
An=np.array([int(i) for i in input().split()])
Ane=An[An%2==0]
Ane3=Ane%3
Ane5=Ane%5
Ane3or5=Ane3*Ane5

if(np.sum(Ane3or5)==0):
    print("APPROVED")
else:
    print("DENIED")    

Fixed submission:
import numpy as np
Nnum=int(input())
An=np.array([int(i) for i in input().split()])
Ane=An[An%2==0]
Ane3=Ane%3
Ane5=Ane%5
Ane3or5=Ane3*Ane5

if(np.sum(Ane3or5)==0):
    print("APPROVED")
else:
    print("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
N, K=map(int,input().split())
P=list(map(int,input().split()))
Sum=[ sum(P[l:l+K]) for l in range(0, N-K+1)]
print(K*0.5+0.5*max(Sum))

Fixed submission:
N, K=map(int,input().split())
P=list(map(int,input().split()))
Sum=[0]* (N + 1)
for i in range(N):
    Sum[i+1]=Sum[i]+(P[i]+1)/2.0
Ans=0
for i in range(N-K+1):
    Ans=max(Ans,Sum[i+K]-Sum[i])
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K=map(int,input().split())
P=np.array(list(map(int,input().split())))
l=2

sum_max=0
for l in range(N-K+1):
    sum=P[l:l+K].sum() 
    if(sum>=sum_max):
        sum_max=sum

print(K*0.5+0.5*sum_max)

Fixed submission:
N, K=map(int,input().split())
P=list(map(int,input().split()))
Sum=[0]* (N + 1)
for i in range(N):
    Sum[i+1]=Sum[i]+(P[i]+1)/2.0
Ans=0
for i in range(N-K+1):
    Ans=max(Ans,Sum[i+K]-Sum[i])
print(Ans)
Buggy python submission (verdict: Runtime Error):
lst=[]
str = input()
lst = str.split(' ')
i = lst.index(0)
print(i+1)

Fixed submission:
lst=[]
str = input()
lst = str.split(' ')
i = lst.index('0')
print(i+1)
Buggy python submission (verdict: Runtime Error):
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

(ans-1) %= mod
print(ans)

Fixed submission:
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

ans %= mod
print(ans-1)
Buggy python submission (verdict: Runtime Error):
# 169 B

import math
n = int(input())
a = list(map(int, input().split()))
p = 1
x = True

p = math.product(a)
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)
        

Fixed submission:
# 169 B

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

def code(a):
    pro = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            pro *= i
            if pro > (10 ** 18):
                print(-1)
                return
        print(pro)

code(l)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
p = 1
x = True

for i in a:
    p *= i
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)
        

Fixed submission:
# 169 B

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

def code(a):
    pro = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            pro *= i
            if pro > (10 ** 18):
                print(-1)
                return
        print(pro)

code(l)
Buggy python submission (verdict: Runtime Error):
# 166 A

s = input()

if s == "ABC":
    print("ARC")
elif s == "ARC"
    print("ABC")

Fixed submission:
# 166 A

s = input()

if s == "ABC":
    print("ARC")
elif s == "ARC":
    print("ABC")
Buggy python submission (verdict: Runtime Error):
using namespace std;
int main(){
    long long x;
    cin >> x,
    long long p, yr = 0;
    while p < x{
        p += p / 100
        yr ++
    }
    cout << yr << endl;
    return 0
}

Fixed submission:
# 165 B

x = int(input())
d= 100
yr = 0

while d < x:
    d += (d // 100)
    yr += 1

print(yr)
Buggy python submission (verdict: Time Limit Exceeded):
# 164 B

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

while a != 0 or c != 0:
    c = c - b
    if c == 0:
        print("Yes")
        break
    a = a - d
    if a == 0:
        print("No")
        break

Fixed submission:
# 164 B

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

while a != 0 or c != 0:
    c = c - b
    if c <= 0:
        print("Yes")
        break
    a = a - d
    if a <= 0:
        print("No")
        break
Buggy python submission (verdict: Runtime Error):
# 158 B

n, a , b = map(int, input().split())
s = ""

while len(s) < n:
    s += a * "b"
    if len(s) >= n:
        break
    s += b * "r"
    if len(s) >= n:
        break

s = s[:n]
print(s.count("b"))


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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
s = ""

while len(s) < n:
    for i in range(a):
        s += "b"
        if len(s) >= n :
            break
    for i in range(b):
        s += "a"
        if len(s) >= n :
            break
            
print(s.count("b"))

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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)

Buggy python submission (verdict: Runtime Error):
# 159 B

n, a, b = map(int, input().split())
s = ""

while len(s) < n:
    s += a * "b"
    if len(s) >= n:
        break
    s += b * "r"

s = s[:n]
print(s.count("b"))


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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)

Buggy python submission (verdict: Runtime Error):
# 159 B

n, a, b = map(int, input().split())
s = ""

while len(s) <= n:
    s += a * "b"
    s += b * "r"

s = s[:n]
print(s.count("b"))


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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)
Buggy python submission (verdict: Runtime Error):
n = input()
ans1=int(n[0])
for i in n:
  ans1 += int(i)
ans2=int(n[0])-1+9*(len(n)-1)
print(max(ans1,ans2)

Fixed submission:
n = input()
ans1=sum(int(i)for i in n)
ans2=int(n[0])-1+9*(len(n)-1)
print(max(ans1,ans2))

Buggy python submission (verdict: Runtime Error):
n = input()
ans1=sum(int(i)for i in n)
ans2=int(n[0])-1+9*(len(n)-1)
print(max(ans1,ans2)

Fixed submission:
n = input()
ans1=sum(int(i)for i in n)
ans2=int(n[0])-1+9*(len(n)-1)
print(max(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
n = int(input())
 
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
 
q, r = divmod(N, 2)
x = q * d + r * c
print(x)

Fixed submission:
a, b, c, d = map(int, input().split())
n = int(input())
 
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
 
q, r = divmod(n, 2)
x = q * d + r * c
print(x)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())) 
a.sort()
a.reverse() 
x = a[0]   
for i in range (1, N):
  while a[i] != 0:
    x , a[i] = a[i] , x % a[i]
if K > a[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')

Fixed submission:
N,K = map(int, input().split())
A = list(map(int, input().split())) 
A.sort()
A.reverse() 
x = A[0]   
for i in range (1, N):
  while A[i] != 0:
    x , A[i] = A[i] , x % A[i]
if K > A[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n, p = map(int,input().split())
a = list(map(int,input().split()))
 
o = 0
for i in a:
    if  i % 2:
        o += 1 
e = n-o
if o != 0:
    print((2**e)*int(2**(o-1)))
else:
    if P == 0:
        print(2**n)
    else:
        print(0)

Fixed submission:
n, p = map(int,input().split())
a = list(map(int,input().split()))
 
o = 0
for i in a:
    if  i % 2:
        o += 1 
e = n-o
if o != 0:
    print((2**e)*int(2**(o-1)))
else:
    if p == 0:
        print(2**n)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
 
ans = -1
for i in range(n-1):
    if a[i]*2 < a[i+1]:
        ans = i
    a[i+1] += a[i]
print(n-ans-1)

Fixed submission:
n, c, k = map(int, input().split())
T = [0] * n
for i in range(n):
    T[i] = int(input())
 
T.sort()
ans, s, m = 0, 0, 0

for t in T:
    if m == 0:
        s = t
        m = 1
        ans += 1
    else:
        if t <= s + k:
            m += 1
        else:
            s = t
            m = 1
            ans += 1
    if m == c:
        m = 0
 
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 1
num = sum(l)
for i in range(0,n-1):
    num -= l[i]
    if num*2<l[i]:
        break
    ans += 1
print(ans)

Fixed submission:
n, c, k = map(int, input().split())
T = [0] * n
for i in range(n):
    T[i] = int(input())
 
T.sort()
ans, s, m = 0, 0, 0

for t in T:
    if m == 0:
        s = t
        m = 1
        ans += 1
    else:
        if t <= s + k:
            m += 1
        else:
            s = t
            m = 1
            ans += 1
    if m == c:
        m = 0
 
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
b = []
for j in range(n):
    l = list(map(int, input().split()))
    a.append(l[0])
    b.append(l[1])
 c = 0
for i in range(n-1, -1, -1):
    if (a[i]+c) % b[i] != 0:
        c += (b[i] - (a[i]+c) % b[i])
print(c)

Fixed submission:
n = int(input())
a = []
b = []
for j in range(n):
    l = list(map(int, input().split()))
    a.append(l[0])
    b.append(l[1])
c = 0
for i in range(n-1, -1, -1):
    if (a[i]+c) % b[i] != 0:
        c += (b[i] - (a[i]+c) % b[i])
print(c)
Buggy python submission (verdict: Runtime Error):
h, w = map(int,input().split())
a = [list(input()) for _ in range(H)]
c = 0
for p in a :
    for q in p:
        if q=="#":
            c +=1
 
if c == h + w - 1:
    print("Possible")
else:
    print("Impossible")

Fixed submission:
h, w = map(int,input().split())
a = [list(input()) for _ in range(h)]
c = 0
for p in a :
    for q in p:
        if q=="#":
            c +=1
 
if c == h + w - 1:
    print("Possible")
else:
    print("Impossible")