TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y=map(int,input().split())
price=[]
for i in range(X+1):
    for j in range(Y+1):
        k=max(X-i,Y-j)*2
        price.append(A*i+B*j+C*k)
print(price)
print(min(price))

A,B,C,X,Y=map(int,input().split())
price=[]
for i in range(100000+1):
    price.append(i*2*C+max(0,X-i)*A+max(0,Y-i)*B)

print(min(price))

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y = map(int, input().split())

ans = 0
if a+b < 2*c:
    if x <= y:
        ans += x*(a+b)
        if b < 2*c:
            ans += b*(y-x)
        else:
            ans += 2*c*(y-x)
    else:
        ans += y*(a+b)
        if a < 2*c:
            ans += a*(x-y)
        else:
            ans += 2*c*(x-y)
else:
    if x <= y:
        ans += 2*c*x
        if b < 2*c:
            ans += b*(y-x)
        else:
            ans += 2*c*(y-x)
    else:
        ans += 2*c*(x+y)

print(ans)


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

ans = 0
if a+b < 2*c:
    if x <= y:
        ans += x*(a+b)
        if b < 2*c:
            ans += b*(y-x)
        else:
            ans += 2*c*(y-x)
    else:
        ans += y*(a+b)
        if a < 2*c:
            ans += a*(x-y)
        else:
            ans += 2*c*(x-y)
else:
    if x <= y:
        ans += 2*c*x
        if b < 2*c:
            ans += b*(y-x)
        else:
            ans += 2*c*(y-x)
    else:
        ans += 2*c*y
        if a < 2*c:
            ans += a*(x-y)
        else:
            ans += 2*c*(x-y)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A, B, C, X, Y = map(int,inut().split())
if(A + B >= 2 * C):
  if(X >= Y):
    print(C * 2 * Y + (X - Y) * min(A, 2 * C))
  else :
    print(C * 2 * X + (Y - X) * min(B, 2 * C))
else:
  print(A * X + B * Y)

A, B, C, X, Y = map(int,input().split())
if(A + B >= 2 * C):
  if(X >= Y):
    print(C * 2 * Y + (X - Y) * min(A, 2 * C))
  else :
    print(C * 2 * X + (Y - X) * min(B, 2 * C))
else:
  print(A * X + B * Y)

Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):

A, B, C, X, Y = [int(x) for x in input().split()]


def r(a, b, c, x, y):
    print(a, b, c, x, y)
    if x == 0 and y == 0:
        return 0
    if x == 0:
        return min(y*b, 2*y*c)
    if y == 0:
        return min(x*a, 2*x*c)
    if (a + b) / 2 < c:
        return a*x+b*y
    else:
        z = min(x, y) * 2
        x = x - z/2
        y = y - z/2
        return r(a, b, c, x, y) + z*c


print(int(r(A, B, C, X, Y)))

A, B, C, X, Y = [int(x) for x in input().split()]

def r(a, b, c, x, y):
    if x == 0 and y == 0:
        return 0
    if x == 0:
        return min(y*b, 2*y*c)
    if y == 0:
        return min(x*a, 2*x*c)
    if (a + b) / 2 < c:
        return a*x+b*y
    else:
        z = min(x, y) * 2
        x = x - z/2
        y = y - z/2
        return r(a, b, c, x, y) + z*c


print(int(r(A, B, C, X, Y)))

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C
 
 
print(min(price))

import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C 
print(min(price))

A, B, C, X, Y = map(int, input().split())





# l = []
# for j in range(max(X,Y)+1):
#     if j <= X+Y:
#         l.append(A*X + B*Y + (C-A*0.5-B*0.5)*j)

# print(int(min(l)))

X1 = X
Y1 = Y
price = []
for i in range(0, max(X,Y)+1):
    price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) 
print(min(price))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y=readInts()
for i in range(max(x,y)*2+1,2):
	ans=min(ans,max(x-i//2,0)*a+max(y-i//2,0)*b+i*c)
print(ans)



import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000


for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)



Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a, b, c, x, y = list(map(int, input().split()))

a_sum = a * x
b_sum = b * y
c_sum = c * (x+y)
price = 0

if a_sum + b_sum > c_sum:
    num = min(x, y)
    price += num * c * 2
    x -= num
    y -= num
    print(price)
    if x > 0:
        if a < c * 2:
            price += a * x
        else:
            price += c * 2 * x
    if y > 0:
        if b < c * 2:
            price += b * y
        else:
            price += c * 2 * y
else:
    price += a*x + b*y
print(price)


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

a_sum = a * x
b_sum = b * y
c_sum = c * (x+y)
price = 0

if a_sum + b_sum > c_sum:
    num = min(x, y)
    price += num * c * 2
    x -= num
    y -= num
    if x > 0:
        if a < c * 2:
            price += a * x
        else:
            price += c * 2 * x
    if y > 0:
        if b < c * 2:
            price += b * y
        else:
            price += c * 2 * y
else:
    price += a*x + b*y
print(price)

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A, B, C, X, Y = tuple(map(int, input().split()))


TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2

for a in range(X + 1):
    c = (X - a) * 2
    b = Y - c // 2
    total_tmp = A * a + B * b + C * c
    if total_tmp < TOTAL_MIN:
        TOTAL_MIN = total_tmp

print(TOTAL_MIN)


A, B, C, X, Y = tuple(map(int, input().split()))

A + 2 // C > X
B + 2 // C > Y


TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2
for i in range(X+1):
    for j in range(Y+1):
        k = max(X - i, Y - j) * 2
        total_tmp = A * i + B * j + C * k
        if X <= i + k and Y <= j + k\
                and total_tmp < TOTAL_MIN:
            print(i, j, k)
            TOTAL_MIN = total_tmp

print(TOTAL_MIN)


A, B, C, X, Y = tuple(map(int, input().split()))


TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2

for a in range(X + 1):
    c = (X - a) * 2
    if c // 2 < Y:
        if B < 2 * C:
            b = Y - c // 2
        else:
            b = 0
            c = max(c, Y * 2) 
    else:
        b = 0
    
    total_tmp = A * a + B * b + C * c
    if total_tmp < TOTAL_MIN:
        TOTAL_MIN = total_tmp
        

print(TOTAL_MIN)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y=map(int,input().split())
ans=10**18
for i in range(max(x,y)+1):
    price=a*max(0,x-i)+b*max(0,y-i)+s*c*i
    ans = min(ans,price)
print(ans)

a,b,c,x,y=map(int,input().split())
ans=10**18
for i in range(max(x,y)+1):
    price=a*max(0,x-i)+b*max(0,y-i)+2*c*i
    ans = min(ans,price)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y = map(int,input().split())
ans=0


if A+B > c*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)


A,B,C,X,Y = map(int,input().split())
ans=0


if A+B > C*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)


Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y=map(int,input().split())
print(min(i*c+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)))

a,b,c,x,y=map(int,input().split())
print(min([i*c+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)]))

a,b,c,x,y=map(int,input().split())
print(min([i*c*2+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)]))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y=map(int, input().split())
cnta=0
cntb=0
cntc=0
if a+b>2*c:
  cntc=min(x,y) * 2
else:
  cnta=min(x,y)
  cntb=min(x,y)

if x>y:
  if a>2*c:
    cntc+=2*(x-y)
  else:
    cnta+=x-y
else:
  if b>2*c:
    cntc+=2*(y-x)
  else:
    cntb+=y-x

ptint(cnta*a+cntb*b+cntc*c)



A,B,C,X,Y=map(int, input().split())
cnta=0
cntb=0
cntc=0
if X>Y:
  if A+B>2*C:
    cntc+=2*Y
  else:
    cnta+=Y
    cntb+=Y
  if A>2*C:
    cntc+=2*(X-Y)
  else:
    cnta+=(X-Y)
else:
  if A+B>2*C:
    cntc+=2*X
  else:
    cnta+=X
    cntb+=X
  if B>2*C:
    cntc+=2*(Y-X)
  else:
    cntb+=(Y-X)

print(cnta*A+cntb*B+cntc*C)

Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
#-*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())
m = min(x, y)
ans = 0
if (a + b) >= c * 2:
    ans += c * 2 * min(x, y)
    print(ans)
    x -= m
    y -= m

if a >= c * 2:
    ans += c * 2 * x
    x = 0
if b >= c * 2:
    ans += c * 2 * y
    y = 0
print(ans + x*a + y*b)


#-*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())
m = min(x, y)
ans = 0
if (a + b) >= c * 2:
    ans += c * 2 * min(x, y)
    x -= m
    y -= m

if a >= c * 2:
    ans += c * 2 * x
    x = 0
if b >= c * 2:
    ans += c * 2 * y
    y = 0
print(ans + x*a + y*b)


Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
# -*- coding: utf-8 -*-

import sys

args = sys.argv

a_value = int(args[1])
b_value = int(args[2])
c_value = int(args[3])
a_number = int(args[4])
b_number = int(args[5])

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * a_value
    print (value)

# -*- coding: utf-8 -*-

import sys

lst = list(map(int, input().split()))

a_value = lst[0]
b_value = lst[1]
c_value = lst[2]
a_number = lst[3]
b_number = lst[4]

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * b_value
    print (value)


Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y = map(int,input().split())

i = 0
SUM = X*A + Y*B
if Y >= X:
    while(X-i>=0):
        ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)
        i += 1
    else:
        for j in range(1,Y-X+1):
            ans = min(SUM,(Y-X-j)*B + 2*(X+j)*C)
else:
    while(Y-i>=0):
        ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)
        i += 1
    else:
        for j in range(1,X-Y+1):
            ans = min(SUM,(X-Y-j)*B + 2*(Y+j)*C)
print(ans)

# Half and Half
a,b,c,x,y = map(int,input().split())

ans = []
for i in range(max(x,y)):
    ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(ans)

print(min(ans))

A,B,C,X,Y = map(int,input().split())

i = 0
SUM = X*A + Y*B
if Y >= X:
    while(X-i>=0):
        ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)
        i += 1
    else:
        for j in range(1,Y-X+1):
            ans = min(SUM,(Y-X-j)*B + 2*(X+j)*C)
else:
    while(Y-i>=0):
        ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)
        i += 1
    else:
        for j in range(X-Y):
            ans = min(SUM,(X-Y-j)*B + 2*(Y+j)*C)
print(ans)

# Half and Half
a,b,c,x,y = map(int,input().split())

ans = []
for i in range(max(x,y)+1):
    ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))

print(min(ans))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y = map(int,input().split())
a = 0

if A+B < C*2:
    a += (A+B) * min(X,Y)
else
    a += C*2 * min(X,Y)
if X > Y:
    a += min(A,C*2)*(X-Y)
else:
    a += min(B,C*2)*(Y-X)
print(a)

A,B,C,X,Y = map(int,input().split())
a = 0

if A+B < C*2:
    a += (A+B) * min(X,Y)
else:
    a += C*2 * min(X,Y)
if X > Y:
    a += min(A,C*2) * (X-Y)
else:
    a += min(B,C*2) * (Y-X)
print(a)

Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
inputs = open(0).readlines()
a, b, c, x, y = map(int, open(0).read().split())

prices = []
prices.append(a*x + b*y)
prices.append(a*abs(x-y) + 2*c*min(x, y))
prices.append(b*abs(x-y) + 2*c*min(x, y))
prices.append(2*c*max(x, y))
print(min(prices))

a, b, c, x, y = map(int, open(0).read().split())
a, b, x, y = (b, a, y, x) if x > y else (a, b, x, y)

print(min(a*x + b*y, 2*c*x + b*(y-x), 2*c*y))

Verdicts: Runtime Error

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A, B, C, X, Y = [int(x) for x in input().split(" ")]

min = max(A,B,C*2) * 10**5

for k in range(0,2*max(X,Y)+1,2):
  if A*(X-k/2)+B*(Y-k/2)+C*k < min:
    min = A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k
        
print(int(min))

A, B, C, X, Y = [int(x) for x in input().split(" ")]

min = max(A,B,C)*max(X,Y)*2

for k in range(0,max(X,Y)*2+1,2):
  if A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k < min:
    min = A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k
        
print(int(min))

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y = map(int, input().split())

ans = 0

if (A<2*C)&(B<2*C):
  ans += A*X + B*Y
else:
  if A>=B:
    ans += 2*C * X
    if (B>2*C)&(Y>X):
      ans += 2*C * (Y - X)
    elif Y>X:
	    ans += B * (Y - X)
  else:
    ans += 2*C * Y
    if (A>2*C)&(X>Y):
      ans += 2*C * (X - Y)
    elif X>Y:
	    ans += A * (X - Y)
    
print(ans)

A,B,C,X,Y = map(int, input().split())

ans = 0

if A+B <= 2*C:
  ans += A*X + B*Y
else:
  if A*X>B*Y:
    ans += C * 2*X
    if Y>X:
	    ans += B * (Y - X)
  else:
    ans += C * 2*Y
    if X>Y:
	    ans += A * (X - Y)
    
print(ans)

A,B,C,X,Y = map(int, input().split())

ans = 0

if A+B<2*C:
  ans += (A+B)*min(X,Y)
else:
  ans += 2*C * min(X,Y)
  
if X>Y:
  ans += min(A,2*C )*(X-Y)
else:
  ans += min(B,2*C )*(Y-X)
  
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y = map(int,input().split())
min_total = a*x + b*y
for ci in range(max(x,y)*2+1):
  ai = max(0,x - ci//2)
  bi = max(0,y - ci//2)
  
  total = ai*a + bi*b + ci*c
  if min_total > total:
    min_total = total
    if min_total < 100200000:
      print(ai,bi,ci)
print(min_total)      

a,b,c,x,y = map(int,input().split())
min_total = a*x + b*y
for ci in range(max(x,y)*2+1):
  ai = max(0,x - ci//2)
  bi = max(0,y - ci//2)
  
  total = ai*a + bi*b + ci*c
  if min_total > total:# and (ai+ci//2 >= x) and (bi+ci//2 >= y):                 
    min_total = total    
print(min_total)      

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
A,B,C,X,Y=map(int,input().split())
ans=0
tmp=0
for i in range(10**5+1):
    tmp = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)
    if i==0:
        ans = tmp
    if tmp < ans:
        ans = tmp
print(ans,i)

A,B,C,X,Y=map(int,input().split())
ans=0
tmp=0
for i in range(10**5+1):
    tmp = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)
    if i==0:
        ans = tmp
    if tmp < ans:
        ans = tmp
print(ans)



Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a,b,c,x,y=map(int,input().split())
l=[]
l.append(x*a+y*b)
l.append(2*x*c+max(0,y-x)*b)
l.append(2*b*c+max(0,x-y)*a)
print(min(l))

a,b,c,x,y=map(int,input().split())
l=[]
l.append(x*a+y*b)
l.append(2*x*c+max(0,y-x)*b)
l.append(2*y*c+max(0,x-y)*a)
print(min(l))

Verdicts: Wrong Answer

Accepted
Problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Submission attempts (in order):
a, b, ab, x, y = map(int, input().split())
if a + b > ab*2:
  ab1 = True
else:
  ab1 = False

if a > ab*2:
  a1 = True
else:
  a1 = False

if b > ab*2:
  b1 = True
else:
  b1 = False

price = 0
if x > y:
  if ab1 is True:
    price += ab*2*y
    if a1 is True:
  	  price += ab*2*(x-y)
    else:
      price += a*2*(x-y)
  else:
    price += a*x + b*y
else:
  if ab1 is True:
    price += ab*2*x
    if b1 is True:
      price += ab*2*(y-x)
    else:
      price += b*2*(y-x)
  else:
    price += a*x + b*y
    
print(price)

a, b, ab, x, y = map(int, input().split())
if a + b > ab*2:
  ab1 = True
else:
  ab1 = False

if a > ab*2:
  a1 = True
else:
  a1 = False

if b > ab*2:
  b1 = True
else:
  b1 = False

price = 0
if x > y:
  if ab1 is True:
    price += ab*2*y
    if a1 is True:
  	  price += ab*2*(x-y)
    else:
      price += a*(x-y)
  else:
    price += a*x + b*y
else:
  if ab1 is True:
    price += ab*2*x
    if b1 is True:
      price += ab*2*(y-x)
    else:
      price += b*(y-x)
  else:
    price += a*x + b*y
    
print(price)

Verdicts: Wrong Answer

Accepted
Problem: "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.  Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.  Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.  Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.

Submission attempts (in order):
from functools import reduce

import numpy as np


def get_max():
    a = 0

    def _max(x):
        nonlocal a
        a = max(a, x)
        return a

    return _max


def solve(fwd, bck):
    dp = []
    cur = 0
    for x, v in fwd:
        cur -= x
        cur += v
        dp.append(cur)

    dp = list(map(get_max(), dp))

    cur = 0
    ans = 0
    for i, (x, v) in enumerate(bck[:-1]):
        cur -= 2 * x
        cur += v
        
        ans = max(ans, dp[n - i - 2] + cur)
        

    return ans


n, c = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]

fwd = np.array(sushi).T
fwd[0] = np.diff(np.concatenate(([0], fwd[0])))
fwd = fwd.T.tolist()

bck = np.array(sushi).T
bck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))
bck[1] = bck[1][::-1]
bck = bck.T.tolist()

print(max(solve(fwd, bck), solve(bck, fwd)))


import numpy as np


def get_max():
    a = 0

    def _max(x):
        nonlocal a
        a = max(a, x)
        return a

    return _max


def solve(fwd, bck):
    dp = []
    cur = 0
    for x, v in fwd:
        cur -= x
        cur += v
        dp.append(cur)

    dp = list(map(get_max(), dp))

    cur = 0
    ans = dp[-1]
    for i, (x, v) in enumerate(bck[:-1]):
        cur -= 2 * x
        cur += v
        
        ans = max(ans, dp[n - i - 2] + cur)
        

    return ans


n, c = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]

fwd = np.array(sushi).T
fwd[0] = np.diff(np.concatenate(([0], fwd[0])))
fwd = fwd.T.tolist()

bck = np.array(sushi).T
bck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))
bck[1] = bck[1][::-1]
bck = bck.T.tolist()

# print(fwd)
# print(bck)

print(max(solve(fwd, bck), solve(bck, fwd)))


Verdicts: Wrong Answer

Accepted
Problem: "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.  Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.  Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.  Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.

Submission attempts (in order):
n,c = map(int,input().split())
x = [0]
v = [0]
rf = [0] * (n+2)
rg = [0] * (n+2)
lf = [0] * (n+2)
lg = [0] * (n+2)
for i in range(0,n):
    X,V = map(int,input().split())
    x.append(X)
    v.append(V)
for i in range(0,n):
    rf[i+1] = rf[i] + v[i+1]
    rg[i+1] = max(rg[i],rf[i+1] - x[i+1])
for i in range(n+1,1,-1):
    lf[i-1] = lf[i] + v[i-1]
    lg[i-1] = max(lg[i],lf[i-1] - (c-x[i-1]))

#print(lg[::-1])
#print(rg)

for i in range(1,n):
    ans = max(ans,rg[i]+lg[i+1] - x[i],rg[i]+lg[i+1] - (c - x[i+1]))
print(ans)

from itertools import*
from numpy import array
n,c=map(int,input().split())

l1=[]
l2=[]
for i in range(n):
    x,v=map(int,input().split())
    l1.append(x)
    l2.append(v)
#print(l1,l2)

ll=array([0]+l1)
lll=array([0]+list(accumulate(l2)))
lr=array([0]+[c-i for i in l1][::-1])
llr=array([0]+list(accumulate(l2[::-1])))
x=lll-ll
y=llr-lr
for i in range(1,n+1):
    x[i]=max(x[i-1],x[i])
    y[i]=max(y[i-1],y[i])
z=array([min(ll[::-1][i],lr[i])for i in range(n+1)])
print(max(x[::-1]+y-z))


Verdicts: Runtime Error

Accepted
Problem: "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.  Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.  Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.  Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.

Submission attempts (in order):
N, C = map(int, input().split())
X = []
V = []
for i in range(N):
  x, v = map(int, input().split())
  X.append(x)
  V.append(v)

frontS = []
prevX = 0
v = 0
for i in range(N):
  v = v + V[i] - (X[i] - prevX)
  frontS.append(v)
  prevX= X[i]


backMaxS = []
prevX = C
v = 0
tmpMax = float('-inf')
for i in range(N-1, -1, -1):
  v = v + V[i] - (prevX - X[i])
  tmpMax = max(tmpMax, v)
  backMaxS.append(tmpMax)
  prevX = X[i]
backMaxS.reverse()
backMaxS.append(0)

print([0]+X)
print([0]+frontS)
print(backMaxS)

ans = backMaxS[0]
for i in range(N):
  
  ans = max(
    ans,
    frontS[i],
    frontS[i] - X[i] + backMaxS[i+1]
  )

print(ans)

N, C = map(int, input().split())
X = []
V = []
for i in range(N):
  x, v = map(int, input().split())
  X.append(x)
  V.append(v)

frontS = []

frontMaxS = []
prevX = 0
v = 0
tmpMax = float('-inf')
for i in range(N):
  v = v + V[i] - (X[i] - prevX)
  frontS.append(v)
  tmpMax = max(tmpMax, v)
  frontMaxS.append(tmpMax)
  prevX= X[i]
frontMaxS.reverse()
frontMaxS.append(0)

backS = []

backMaxS = []
prevX = C
v = 0
tmpMax = float('-inf')
for i in range(N-1, -1, -1):
  v = v + V[i] - (prevX - X[i])
  backS.append(v)
  tmpMax = max(tmpMax, v)
  backMaxS.append(tmpMax)
  prevX = X[i]
backMaxS.reverse()
backMaxS.append(0)

ans = max(0, backMaxS[0], frontMaxS[0])
for i in range(N):
  
  ans = max(
    ans,
    frontS[i],
    frontS[i] - X[i] + backMaxS[i+1],
    backS[i],
    backS[i] - (C-X[-i-1]) + frontMaxS[i+1]
  )

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered.  Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions:    * Do not order multiple bowls of ramen with the exactly same set of toppings.   * Each of the N kinds of toppings is on two or more bowls of ramen ordered.  You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine.

Submission attempts (in order):
N,M = list(map(int,input().split()))

table = [1,1]
while len(table) <= N:
    temp = 1
    for i in range(len(table)-1):
        table[i+1] += temp
        temp = table[i+1]- temp
        table[i+1] = M
    table.append(1)

S = [1]

rev2 = pow(2, M-2, M)
base = pow(2, N, M)
ans = 0
S = [1]
for K in range(N+1):
    res = table[K] % M
    res = (res * pow(2, pow(2, N - K, M-1), M)) % M
    b = 1
    v = 0
    T = [0]*(K+2)
    for L in range(K):
        T[L+1] = s = (S[L] + (L+1)*S[L+1]) % M
        v += s * b
        b = (b * base) % M
    v += b
    T[K+1] = 1
    S = T
    res = (res * v) % M
    if K % 2:
        ans -= res
    else:
        ans += res
    ans %= M

    base = (base * rev2) % M
print(ans)


N, M = map(int, input().split())
fact = [1]*(N+1)
rfact = [1]*(N+1)
for i in range(1, N+1):
    fact[i] = r = (i * fact[i-1]) % M
    rfact[i] = pow(r, M-2, M)

S = [1]

rev2 = pow(2, M-2, M)
base = pow(2, N, M)
ans = 0
S = [1]
for K in range(N+1):
    res = (fact[N] * rfact[K] * rfact[N-K]) % M
    res = (res * pow(2, pow(2, N - K, M-1), M)) % M
    b = 1
    v = 0
    T = [0]*(K+2)
    for L in range(K):
        T[L+1] = s = (S[L] + (L+1)*S[L+1]) % M
        v += s * b
        b = (b * base) % M
    v += b
    T[K+1] = 1
    S = T
    res = (res * v) % M
    if K % 2:
        ans -= res
    else:
        ans += res
    ans %= M

    base = (base * rev2) % M
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
X = [int(i) for i in input().split()]
X.sort()
if N%2 == 0:
    for i in range(N):
        if i <= N//2 - 1:
            print(X[N//2])
        else:
            print(X[N//2 - 1])
else:
    for i in range(N):
        if i < N//2:
            print((X[N//2] + X[N//2 + 1])/2)
        elif i == N//2 -1:
            print((X[N//2 - 1] + X[N//2 + 1])/2)
        else:
            print((X[N//2 - 1] + X[N//2])/2)

from copy import deepcopy
N = int(input())
X = [int(i) for i in input().split()]
x = deepcopy(X)
X.sort()
if N%2 == 0:
    for i in x:
        if i <= X[N//2 - 1]:
            print(X[N//2])
        else:
            print(X[N//2 - 1])
else:
    for i in x:
        if i < X[N//2]:
            print((X[N//2] + X[N//2 + 1])/2)
        elif i == X[N//2 -1]:
            print((X[N//2 - 1] + X[N//2 + 1])/2)
        else:
            print((X[N//2 - 1] + X[N//2])/2)

Verdicts: Wrong Answer

Accepted