Harryxun/stf_run huggingface dataset:
A,B,C,D,E,F=map(int,input().split())
maxconc = 0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-(100*A*i))//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print(maxwater+maxsugar,maxsugar)    
    

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split(' '))

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-100*A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))

        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+100*(A*i+B*j))
        if temp_conc > max_conc:
            max_conc = temp_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))
from collections import defaultdict
def solve(N,A,B):
    d1=defaultdict(int)
    d2=defaultdict(int)
    for i in range(N):
        d1[A[i]]+=1
        d2[B[i]]+=1
    for i in d1:
        if d1[i]+d2[i]>N:
            return "No",[]
    else:
        return "Yes",B[::-1]
    
if __name__ == "__main__":
    N=int(input())
    A=[int(i) for i in input().split()][:N]
    B=[int(i) for i in input().split()][:N]
    a,b=solve(N,A,B)
    print(a)
    if b!=[]:
        #print(a)
        k,z=0,N-1
        for i in range(N):
            if A[i]==b[i] and b[i]!=A[k]:
                b[i],b[k]=b[k],b[i]
                k+=1
            elif A[i]==b[i] and b[i]==A[k]:
                b[i],b[z]=b[z],b[i]
                z-=1
        for i in range(N):
            if A[i]==b[i]:
                for j in range(N):
                    if A[j]!=b[i] and b[j]!=b[i]:
                        raise ArithmeticError
                        b[i],b[j]=b[j],b[i]
        print(*b)

### FIXED CODE ###

from collections import defaultdict
def solve(N,A,B):
    d1=defaultdict(int)
    d2=defaultdict(int)
    for i in range(N):
        d1[A[i]]+=1
        d2[B[i]]+=1
    for i in d1:
        if d1[i]+d2[i]>N:
            return "No",[]
    else:
        return "Yes",B[::-1]
    
if __name__ == "__main__":
    N=int(input())
    A=[int(i) for i in input().split()][:N]
    B=[int(i) for i in input().split()][:N]
    a,b=solve(N,A,B)
    print(a)
    if b!=[]:
        #print(a)
        k,z=0,N-1
        for i in range(N):
            if A[i]==b[i] and b[i]!=b[k]:
                b[i],b[k]=b[k],b[i]
                k+=1
            elif A[i]==b[i] and b[i]==b[k]:
                b[i],b[z]=b[z],b[i]
                z-=1
        z,k=0,N-1
        for i in range(N):
            if A[i]==b[i] and b[i]!=b[k]:
                b[i],b[k]=b[k],b[i]
                k-=1
            elif A[i]==b[i] and b[i]==b[k]:
                b[i],b[z]=b[z],b[i]
                z+=1
        print(*b)
import numpy as np
n = int(input())  #nは入力回数
num_list = [list(map(int, input().split())) for _ in range(n)]
dp_ini=0
dp=np.zeros((n+1,n))
for i in range(0,n):
  for j in range(3):
    for k in range(3):
      if(j==k):
        continue
      else:
        dp[i+1][k]=max(dp[i+1][k],dp[i][j]+num_list[i][k])
print(int(max(dp[n][0],dp[n][1],dp[n][2])))

### FIXED CODE ###

def main():
  n = int(input())  #nは入力回数
  num_list = [list(map(int, input().split())) for _ in range(n)]

  dp = [[0] * 3 for i in range(n+1)]
  for i in range(0,n):
    for j in range(3):
      for k in range(3):
        if(j==k):
          continue
        else:
          dp[i+1][k]=max(dp[i+1][k],dp[i][j]+num_list[i][k])
  print(int(max(dp[n][0],dp[n][1],dp[n][2])))

if __name__ == '__main__':
    main()
A,B,C,D = map(int,input().split())
list1 = [A,B]
list2 = [C,D]
X = min(list1)
Y = min(list2)
print(Y + X)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+ min(C,D))
N,X = map(int, input().split())
L = [x for x in map(int, input().split())]
accumL = [sum(L[:x]) for x in range(len(L)+1)]
TF = [i <= X for i in accumL]
print(TF.index(False))

### FIXED CODE ###

N,X = map(int, input().split())
L = [x for x in map(int, input().split())]
accumL = [sum(L[:x]) <= X for x in range(len(L)+1)]
if accumL[-1] == True:
  print(N + 1)
else:
  print(accumL.index(False))
a,b,c,d=map(int,input().split())
import math
cc=b//c-(a-1)//c
dd=b//d-(a-1)//d
gcd=math.gcd(c,d)
lcm=c*d//gcd
cd=b//lcm-(a-1)//lcm
print((b-a+1)-(cc+dd-cd))

### FIXED CODE ###

a,b,c,d=map(int,input().split())
import fractions as f
cc=b//c-(a-1)//c
dd=b//d-(a-1)//d
gcd=f.gcd(c,d)
lcm=c*d//gcd
cd=b//lcm-(a-1)//lcm
print((b-a+1)-(cc+dd-cd))
from itertools import product
import numpy as np

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

if 0 in dl:
    print(0)
    exit()


doubles = []
dl1 = []
dl2 = []
for i in range(1,13):
    i_cnt = dl.count(i)
    if i_cnt > 2:
        print(0)
        exit()
    elif i_cnt == 2:
        dl2.append(24-i)
        dl2.append(i)
    elif i_cnt == 1:
        dl1.append(i)        


ans = 0
ite = list(product(range(2),repeat=len(dl1)))
for pattern in ite:
    dl24 = []
    for i, v in enumerate(pattern):
        if v == 1:
            dl24.append(24-dl1[i])
        else:
            dl24.append(dl1[i])
    dl24 = dl24 + dl2
    dl24.sort()
    diff = list(np.diff(dl24))
    ans = max(min(diff),ans)

print(ans)


### FIXED CODE ###

from itertools import product
import random

def solve(n,dl):
    # n = int(input())
    # dl = list(map(int, input().split()))

    if 0 in dl:
        return 0

    doubles = []
    dl1 = []
    dl2 = []
    for i in range(1,13):
        i_cnt = dl.count(i)
        if i_cnt > 2:
            return 0
        elif i_cnt == 2:
            dl2.append(24-i)
            dl2.append(i)
        elif i_cnt == 1:
            dl1.append(i)        

    ans = 0
    ite = list(product(range(2),repeat=len(dl1)))
    for pattern in ite:
        dl24 = [0,24]
        for i, v in enumerate(pattern):
            if v == 1:
                dl24.append(24-dl1[i])
            else:
                dl24.append(dl1[i])
        dl24 = dl24 + dl2
        dl24.sort()
        diff_min = 24
        # print(dl24)
        if len(dl24) == 1:
            ans = max(ans, min(dl24[0], 24-dl24[0]))
        else:
            for a,b in zip(dl24[:-1],dl24[1:]):
                diff = b-a
                if diff != 24:
                    diff_min = min(diff_min,diff)
            ans = max(diff_min,ans)
    return ans


def solve2(n,dl):
    ite = list(product(range(2),repeat=len(dl)))
    ans = 0
    for pattern in ite:
        dl_new = [0]
        for i, v in enumerate(pattern):
            if v == 1:
                dl_new.append(24-dl[i])
            else:
                dl_new.append(dl[i])
        dl_new.sort()
        diff_min = 24
        for a,b in zip(dl_new[:-1], dl_new[1:]):
            diff = b-a
            diff_min = min(diff_min, diff)
        ans = max(ans,diff_min)
    return ans


if __name__ == "__main__":
    n = int(input())
    dl = list(map(int, input().split()))
    ans = solve(n,dl)
    print(ans)
    # for _ in range(10):
    #     n = random.randint(1,10)
    #     dl = [random.randint(1,12) for _ in range(n)]
    #     ans1 = solve(n, dl[:])
        # ans2 = solve2(n,dl[:])
        # if ans1 != ans2:
        #     print(n)
        #     print(dl)
        #     print(ans1)
        #     print(ans2)
        #     print('----')
A, B = map(int, input().split())

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 1
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)


### FIXED CODE ###

A, B = map(int, input().split())

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 2
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1 and cur < length:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count + (num != 1))
N,K= map(int, input().split())

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

a = [0] * K
b = [0] * K

for i in range(K):
    a[i], b[i],= map(int, input().split())

X = 0

for (j) in range(K):

    if H[j-1] != H[j-1] :
        X += 1

print(X)

### FIXED CODE ###

#標準入力

N,M = map(int, input().split())

#[1,1,…,1]というリストを作成する
#最終的に良い展望台の数を和で求めるため、１で始める

good = [1 for i in range(N)]


#標準入力で高さの一覧を取得

height = list(map(int, input().split()))
 
#道の数Mだけ、入力を繰り返す

for i in range(M):
  a,b = map(int, input().split())

#一括で受け取らず、受取→処理をM回繰り返す
#高さのリストと一致させるため-1

  a -= 1
  b -= 1

#２つの高さを比較し、低い方の展望台を、最初のリストで０にする

  if height[a] <= height[b]:
    good[a] = 0

  if height[a] >= height[b]:
    good[b] = 0

#goodリストで「１」のままの展望台は、つながっている道でいけるどの展望台よりも高い

print(sum(good))
import numpy as np
n = int(input())
arr = list(map(float, input().split()))

dp = np.array([[0.0] * (n + 1) for _ in range(n + 1)])

dp[0, 0] = 1.0

for i in range(n):
    for j in range(i + 1):
        dp[i + 1, j + 1] += dp[i, j] * arr[i]
        dp[i + 1, j] += dp[i, j] * (1 - arr[i])

print(dp[-1, -(n + 1)//2:].sum())

### FIXED CODE ###

n = int(input())
arr = list(map(float, input().split()))

dp = [[0.0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * arr[i]
        dp[i + 1][j] += dp[i][j] * (1 - arr[i])

dp = dp[-1]

print(sum(dp[-(n + 1) // 2:]))
s = list(map(int, list(input())))
k = int(input())

if s[0] == 1:
    print(s[1])
else:
    print(s[0])


### FIXED CODE ###

s = list(map(int, list(input())))
k = int(input())
ans = 1

if len(s) <= k:
    for i in s:
        if i != 1:
            ans = i
            break
else:
    for i in range(0,k):
        if s[i] != 1:
            ans = s[i]
            break

print(ans)
def main():
    while True:
        n = int(input())
        if n == 0:
            exit()
        f = [s for input().split()]
        pm = 'd'
        cnt = 0
        for m in f:
            if m[1] == pm:
                cnt += 1
            pm = m[1]
        print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    while True:
        n = int(input())
        if n == 0:
            exit()
        f = [s for s in input().split()]
        pm = 'd'
        cnt = 0
        for m in f:
            if m[1] == pm:
                cnt += 1
            pm = m[1]
        print(cnt)

if __name__ == '__main__':
    main()
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


s = input().rstrip()
t = intput().rstrip()
result = 0
for i in range(len(s)):
    if s[i] != t[i]:
        result += 1
        
print(result)

### FIXED CODE ###

#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


s = input().rstrip()
t = input().rstrip()
result = 0
for i in range(len(s)):
    if s[i] != t[i]:
        result += 1
        
print(result)
h,a = map(int,input().split())
print(h//a+map(h%a!=0))

### FIXED CODE ###

h,a = map(int,input().split())
print(h//a+(h%a!=0))
a,b,c=int(input())
if a<=c<-a+b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a<=c<=a+b:
    print("YES")
else:
    print("NO")
import numpy as np
s = str(input())
s_list = np.array([int(list(s)[i]) for i in range(len(s))])

if len(s_list) % 2 == 0:
    s01 = np.array([0,1]*(len(s_list)//2))
    s10 = np.array([1,0]*(len(s_list)//2))
else:
    s01 = np.array([0,1]*(len(s_list)//2))
    s01 = np.append(s01, 0)
    s10 = np.array([1,0]*(len(s_list)//2))
    s10 = np.append(s10, 1)

ans = min(np.sum(s_list == s01), np.sum(s_list == s10))
print(ans)

### FIXED CODE ###

s = str(input())
ans1 = s[::2].count('0') + s[1::2].count('1')
ans2 = s[::2].count('1') + s[1::2].count('0')
print(min(ans1, ans2))
n = int(input())
an = map(int, input().split())

count = 0
flg = 0
while flg == 0:
  for i in n:
    if (int(an[i]))%2 == 1:
      flg = 1
    elif i == n-1 && flg == 0:
      count = count + 1


### FIXED CODE ###

n = int(input())
an = map(int, input().split())
anlist = list(an)
count = 0
flg = 0
while flg == 0:
  for i in range(n):
    if (anlist[i])%2 == 1:
      flg = 1
    else:
      anlist[i] = anlist[i]/2
  if flg == 0:
    count = count + 1
print(count)
flg = 0
count = 0
def main():
    n, m = map(int, input().split())
    a = [int(x)*-1 for x in input().split()]
    ans = sum(a)*-1
    diff = 0
    
    heapify(a)
    for _ in range(1, m+1):
        _h_a = heappop(a) * -1
        diff += _h_a - _h_a // 2
        heappush(a, (_h_a // 2)*-1)
    ans -= diff
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

from heapq import heapify, heappush, heappop

def main():
    n, m = map(int, input().split())
    a = [int(x)*-1 for x in input().split()]
    ans = sum(a)*-1
    diff = 0
    
    heapify(a)
    for _ in range(1, m+1):
        _h_a = heappop(a) * -1
        diff += _h_a - _h_a // 2
        heappush(a, (_h_a // 2)*-1)
    ans -= diff
    print(ans)
    
if __name__ == '__main__':
    main()
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

if __name__ == "__main__":
	main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

if __name__ == "__main__":
	main()
n, m = map(int, unput().split())
c = 0
if n >= 2:
  c += n*(n-1) /2
if m >= 2:
  c += n*(n-1) /2
print(c)

### FIXED CODE ###

n, m = map(int, input().split())
c = 0
if n >= 2:
  c += n*(n-1) /2
if m >= 2:
  c += m*(m-1) /2
print(int(c))
def main():
    n, m, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    B = [int(e) for e in input().split()]

    t = 0
    ca, cb = 0, 0
    for a in A:
        t += a
        if t > k:
            t -= a
            break

        ca += 1

    while True:
        if t > k:
            cb -= 1
            t -= B[cb]
            break

        if cb == len(B):
            break

        t += B[cb]
        cb += 1

    AA = [ca + cb]
    while True:
        if ca == 0 or cb == len(B):
            break

        ca -= 1
        t -= A[ca]
        while True:
            t += B[cb]
            if t > k or cb == len(B):
                break

            cb += 1

        AA.append(ca + cb)

    print(max(AA))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    B = [int(e) for e in input().split()]

    AS = [0]
    for i in range(n):
        AS.append(AS[i] + A[i])

    BS = [0]
    for i in range(m):
        BS.append(BS[i] + B[i])

    ans = 0
    bi = 0
    for ai in range(n, -1, -1):
        if bi == m + 1:
            break

        if AS[ai] > k:
            continue

        while bi < m + 1 and AS[ai] + BS[bi] <= k:
            bi += 1

        ans = max(ai + bi - 1, ans)

    print(ans)


if __name__ == '__main__':
    main()
x=int(input())
for i in range(-100,100):
    a=i
    for j in range(-100,100):
        b=j
        if a**5-b**5==x:
            am=a
            bm=b
        else:
            c=0
print(am,bm)

### FIXED CODE ###

x=int(input())
for i in range(200):
    a=i
    for j in range(-200,i):
        b=j
        if a**5-b**5==x:
            am=a
            bm=b
        else:
            c=0
print(am,bm)
n = int(input().split()[0])

data = dict(25="Christmas", 24="Christmas Eve",
            23="Christmas Eve Eve",
            22="Christmas Eve Eve Eve")

print(data[n])


### FIXED CODE ###

n = int(input().split()[0])

data = {25:"Christmas",
        24:"Christmas Eve",
        23:"Christmas Eve Eve",
        22:"Christmas Eve Eve Eve"}

print(data[n])
N=int(input())
A=map(str,input().split())
if P in A and W in A and Y in A and G in A:
  print("Four")
else:
  print("Three")

### FIXED CODE ###

input()
A=map(str,input().split())
if len(set(A))==4:
  print("Four")
else:
  print("Three")
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(key=lambda x: x[1], reverse=True)
A.sort()
s = 0
for B, C in BC:
    print(A)
    mn = A[0]
    if mn >= C:
        s += sum(A)
        break
    n = len(A)
    if B > n:
        B = n
    if A[B - 1] <= C:
        s += B * C
        if B == n:
            break
        A = A[B:]
    else:
        a, b = 0, B
        while a + 1 < b:
            i = a + (b - a) // 2
            if A[i] >= C:
                b = i
            else:
                a = i
        s += b * C
        s += sum(A[b:])
        break
else:
    s += sum(A)
print(s)

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(key=lambda x: x[1], reverse=True)
A.sort()
l, r = 0, N
for B, C in BC:
    if A[l] >= C:
        break
    a, b = l, r
    if A[r - 1] >= C:
        while a + 1 < b:
            i = a + (b - a) // 2
            if A[i] >= C:
                b = i
            else:
                a = i
        r = b
    n = B + l
    if n > r:
        n = r
        B = n - l
    if n <= b:
        A[l:n] = [C] * B
        l = n
    else:
        A[l:b] = [C] * B
        l = b
    if l == r:
        break

print(sum(A))
print(0 if eval(input().replace(" ","/"))<1 else 10)

### FIXED CODE ###

print(0 if eval(input().replace(" ","-"))<0 else 10)
a = None
b = None
if (a*b)%2 == 1:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2 == 1:
  print("Odd")
else:
  print("Even")
s=sorter(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")
S=input()
T=input()
check=[]
for i,ss in enumerate(S[:-len(T)]):
    check.append(0)
    for j,tt in enumerate(T):
        if tt==S[i+j]:
            check[i]+=1
# print(check)
print(len(T)-max(check))

### FIXED CODE ###


S=input()
T=input()
check=[]
for i in range(len(S)-len(T)+1):
    check.append(0)
    for j,tt in enumerate(T):
        if tt==S[i+j]:
            check[i]+=1
# print(check)
check.append(0)
# print(check)
print(len(T)-max(check))
x,n=map(int,input().split())
I=list(map(int,input().split()))
S=[]
T=[]
ans=[]
for i in range(1,101):
    S.append(i)
    if i in I:
        S.remove(i)
for j in range(len(S)-1):
    if j==0:
        T.append(S[0])
    elif abs(x-S[j])>abs(x-S[j+1]):
        T.clear()
        T.append(S[j+1])
print(min(T))


### FIXED CODE ###

x,n=map(int,input().split())
I=list(map(int,input().split()))
S=[]
T=[]
ans=[]
for i in range(-200,200):
    S.append(i)
    if i in I:
        S.remove(i)
for j in range(len(S)):
    if j==0:
        T.append(S[0])
    elif abs(x-S[j-1])>abs(x-S[j]):
        T.clear()
        T.append(S[j])
print(min(T))
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h

def cost(place):
    if place==n:
        return 0
    elif place==n-1:
        return abs(h[n-1]-h[n])
    else:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        return min(a,b)
print(cost(1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))
A,B,C = map(int, input().split())
print((A+B)*C)


### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())

print(int((A+B)*C/2))
s = input()
K = int(input())

ans = []
flg = False
for i in range(len(s)):
  for j in range(len(s)-i):
    c = s[j:j+i+1]
    if (i != 0 and c.count(c[0]) == len(c)):
      c = c[0]
    ans.append(c)
    
set_ans = list(set(ans))
set_ans.sort()
print(set_ans[K-1])

### FIXED CODE ###

s = input()
K = int(input())
S = set()
ans = []
for i in range(K):
  for j in range(len(s)-i):
    c = s[j:j+i+1]
    S.add(c)
  
set_ans = sorted(list(S))
print(set_ans[K-1])
l = input()
h, w = l.split(" ")
n = h * w
a = n/2
if n%2==0:
  print(a)
  

else:
  print(a+0.5)

### FIXED CODE ###

h, w = input().split()
n = int(h) * int(w)
a = n//2
if int(h)==1 or int(w)==1:
  print(1)
  
elif n%2==1:
  print(a+1)
  
else:
  print(a)
S_dict = {}
N = int(input())
for _ in range(N):
    s = ''.join(sorted(input()))
    if s not in S_dict.keys():
        S_dict[s] = 0
    else:
        S_dict[s] += S_dict[s] + 1
print(sum(map(long, S_dict.values())))

### FIXED CODE ###

ans = 0
N = int(input())
s_list = [''.join(sorted(input())) for _ in range(N)]
s_list.sort()

count = 1
for i in range(1, N):
    if s_list[i] == s_list[i-1]:
        count += 1
    else:
        ans += (count*(count-1))/2
        count = 1

    if i == N-1:
        ans += (count*(count-1))/2

print(int(ans))
# -*- coding: utf-8 -*-

import sys

def reachable(td, l, r, d):
    if not(l in td):
        return (False, d)
    vl = td[l]
    for v in vl:
        vr, vd = v
        if vr == r:
            return (True, d + vd)
        rb, rd = reachable(td, vr, r, d + vd)
        if rb:
            return (rb, rd)
    return (False, d)

n, m = [int(i) for i in raw_input().split()]
tl = list()
for i in range(m):
    l = [int(i) for i in raw_input().split()]
    tl.append(l)
# print n, m
# print tl

consistent = 'Yes'
td = {}
for t in tl:
    l, r, d = t
    
    found, fd = reachable(td, r, l, 0)
    if found:
        consistent = 'No'
        break
    
    found, fd = reachable(td, l, r, 0)
    if found:
        if fd != d:
            consistent = 'No'
            break
        else:
            v = (r, d)
            td[l].add(v)
    else:
        if not (l in td):
            td[l] = set()
        v = (r, d)
        td[l].add(v)

sys.stdout.write('%s\n' % consistent)
sys.stdout.flush()


### FIXED CODE ###

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

import sys

x = int(raw_input().split()[0])
a = int(raw_input().split()[0])
b = int(raw_input().split()[0])

sys.stdout.write('%d\n' % ((x - a) % b))
sys.stdout.flush()