Harryxun/stf_run huggingface dataset:
A,B,C,D,E,F = map(int,input().split())
a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

### FIXED CODE ###

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans_total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)
if len(set(list(input())))==2:
  print('Yes')
else
  print('No')


### FIXED CODE ###

S = input()

if len(set(S)) == 2:
  print('Yes')
else:
  print('No')
a,b,c=input().split
if a+b+c>21:
    print("bust")
else print("win")


### FIXED CODE ###

print('bust'if sum(map(int,input().split()))>=22else 'win')
s = input()

if s[0] != "A" or (s[2] != "C" and s[-1] != "C"):
  print("WA")
elif s[0] == "A" and s[2] == "C":
  s = list(s)
  s.pop(0)
  s.pop(1)
  for i in s:
    if s[i] != s[i].lower():
      print("WA")
      exit()
elif s[0] == "A" and s[-1] == "C":
  s = list(s)
  s.pop(0)
  s.pop(-1)
  for i in s:
    if s[i] != s[i].lower():
      print("WA")
      exit()
      
print("AC")


### FIXED CODE ###

s = input()
n = len(s)
if s[0] == "A" and s[2:n-1].count("C") == 1 and len(set(s.upper()) & set(s)) == 2:
  print("AC")
else:
  print("WA")
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    print(comb(k - 1, i - 1) % divnum * comb(n - k + 1, i) % divnum)


### FIXED CODE ###

n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    if (n-k+1 >= i):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)
    else:
        print(0)
a,b,c,d=(int(x) for x in input().split())

if b<=c or d<=a:
    print(0)
else:
    print(min(b,d)-max(a,c))


### FIXED CODE ###

n=str(input())

if n[0]==n[2]:
    print("Yes")
else:
    print("No")
import sys
 
input = sys.stdin.readline
 
ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]
 
import sys
import numpy as np
import fractions
 
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    ans = 1
    for num in numbers:
        ans = ans * num // fractions.gcd(ans,num)
    return ans
 
def LI():
  return [int(s) for s in input().split()]
 
 
input = sys.stdin.readline
ri = lambda: int(input())
ril = lambda: list(map(int, input().split()))
 
N = ri()
A_s = ril()
mod = 10**9 + 7
 
#l = lcm_list(A_s)
l = 1
for num in numbers:
    l = l * num // fractions.gcd(l,num)
 
print(sum(map(lambda x : l//x, A_s)) % mod)

### FIXED CODE ###

import fractions
 
N = int(input())

def LI():
  return [int(s) for s in input().split()]

A_s = LI()
mod = 10**9 + 7

#l = lcm_list(A_s)
l = 1
for num in A_s:
    l = l * num // fractions.gcd(l,num)

count = 0
for a in A_s:
  count+=l//a
  
print(count % mod)
s = input()
r_cnt = 0
l_cnt = 0
lst = [0 for _ in range(len(s))]
  s += 'R'
for i in range(len(s)-1):
  if s[i] == 'R' and l_cnt == 0:
    r_cnt += 1
  elif s[i] == 'L' and r_cnt > 0:
    l_cnt += 1
    if r_cnt % 2 == 0:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2
    else:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2 + 1
    r_cnt = 0
  elif s[i] == 'L' and r_cnt == 0:
    l_cnt += 1
  elif s[i] == 'R' and l_cnt > 0:
    r_cnt += 1
    if l_cnt % 2 == 0:
      lst[i-1] += l_cnt // 2
      lst[i-2] += l_cnt // 2
    else:
      lst[i-1] += l_cnt // 2 + 1
      lst[i-2] += l_cnt // 2
    l_cnt = 0
print(*lst)

### FIXED CODE ###

s = input()
r_cnt = 0
l_cnt = 0
lst = [0 for _ in range(len(s))]
s += 'R'
for i in range(len(s)):
  if s[i] == 'R' and l_cnt == 0:
    r_cnt += 1
  elif s[i] == 'L' and r_cnt > 0:
    l_cnt += 1
    if r_cnt % 2 == 0:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2
    else:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2 + 1
    r_cnt = 0
    ind = i
  elif s[i] == 'L' and r_cnt == 0:
    l_cnt += 1
  elif s[i] == 'R' and l_cnt > 0:
    r_cnt += 1
    if l_cnt % 2 == 0:
      lst[ind] += l_cnt // 2
      lst[ind-1] += l_cnt // 2
    else:
      lst[ind] += l_cnt // 2 + 1
      lst[ind-1] += l_cnt // 2
    l_cnt = 0
print(*lst)
a = input()
print(x**3)



### FIXED CODE ###

# python3 では input()は文字列として処理される。

x = int(input())
print(x**3)
n = int(input())
x = sorted(list(map(int,input().split())))[::-1]
y = sorted(list(map(int,input().split())))[::-1]
z = sorted(list(map(int,input().split())))[::-1]
count = 0
for a in range(n):
  j = bisect.bisect_right(y,z[a])
  for b in range(j,n-1):
    k = bisect.bisect_right(x,y[b])
    count+=(n-k)
print(count)

### FIXED CODE ###

import bisect
n = int(input())
X = sorted(list(map(int,input().split())))
Y = sorted(list(map(int,input().split())))
Z = sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(X,b) * (n-bisect.bisect_right(Z,b)) for b in Y))
N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int,  input().split())
    A.append(a)
    B.append(b)
ans = []
ans.append(N * (N - 1) / 2)

n = [-1 for i in range(N)]

def find(x):
    if n[x] < 0:
        return x
    return n[x] = find(n[x])

def size(x):
    return -n[find(x)]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    n[x] += n[y]
    n[y] = x
    return 1

for i in range(1, M):
    if unite(A[-i], B[-i]) == 0:
        ans.append(ans[i])
    else:
        ans.append(ans[i] - size(A[-i]) * size(B[-i]))
for i in range(M):
    print(ans[-i])


### FIXED CODE ###

N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int,  input().split())
    A.append(a)
    B.append(b)
ans = []
ans.append(N * (N - 1) / 2)

n = [-1 for i in range(N)]

def find(x):
    if n[x] < 0:
        return x
    n[x] = find(n[x])
    return n[x]

def size(x):
    return -n[find(x)]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if size(x) < size(y):
        x, y = y, x
    n[x] += n[y]
    n[y] = x
    return 1

for i in range(1, M):
    sab = size(A[-i] - 1) * size(B[-i] - 1)
    if unite(A[-i] - 1, B[-i] - 1) == 0:
        ans.append(ans[i - 1])
    else:
        ans.append(ans[i - 1] - sab)
for i in range(1, M + 1):
    print(int(ans[-i]))
m,n = [int(x) for x in input().split()]
if m==n:
	print("Yes")
else
	print("No")

### FIXED CODE ###

n,m = [int(x) for x in input().split()]
if n==m:
	print("Yes")
else:
	print("No")
h, w = list(map(int, input().split()))
line = [input() for i in range(h)]

for l in line:
    print(l)
    print(l

### FIXED CODE ###

h, w = list(map(int, input().split()))
line = [input() for i in range(h)]

for l in line:
    print(l)
    print(l)
## coding: UTF-8


N, W = map(int,input().split())
l = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    for j in range(W+1):
        if(j >= l[i][0]):
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-l[i][0]] + l[i][1])
        else:
            dp[i][j] = dp[i-1][j]
#for k in range(N):
    #print(dp[k])
print(dp[-1][-1])

### FIXED CODE ###

## coding: UTF-8
import sys
#import time

#start = time.time()
N, W = map(int,input().split())
l = [list(map(int, input().split())) for _ in range(N)]


dp = [ [sys.maxsize] * (N * 1000) for _ in range(N) ]
for i in range(N):
    for j in range(N * 1000):
        w = l[i][0]
        v = l[i][1]
        if(j == 0):
            dp[i][j] = 0
        elif(j <= v):
            dp[i][j] = min(dp[i-1][j], w)
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v] + w)
#for k in range(N):
    #print(dp[k][:20])

#print(dp[-1][2999])
#print(dp[-1][3000])
cnt = 0
i = 0
while cnt <= W:
    cnt = dp[-1][i]
    i += 1
    if(i == N*1000):
        i += 2
        break
print(i-2)#0-index , while分の構造上、iが2多くなる
N = int(input())
print(str(math.ceil(N) - (N)))

### FIXED CODE ###

import math
N = int(input())
print(str((math.ceil((N)/1000))*1000 - (N)))
a =0
while True:
    n =int(input())
    i=i+1
    if n==0:
        break
    else:
        print("Case"+str(i)+": "+str(n))


### FIXED CODE ###

l = []
while True:
  i = str(input())
  if i == '0':
    break
  else:
    l.append(i)
t = 0
for i in l:
  t += 1
  print('Case '+str(t)+': '+i)
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    X, N = map(int, input().split())
    P = list(map(int, sysread().split()))
    exist = [False] * 101
    for p in P:
        exist[p] = True
    resid = 0

    while True:
        if not exist[X - resid]:
            print(X - resid)
            return None
        if not exist[X + resid]:
            print(X+resid)
            return None
        resid += 1


if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    X, N = map(int, input().split())
    P = list(map(int, sysread().split()))
    exist = [False] * 201
    for p in P:
        exist[p] = True
    resid = 0

    while True:
        if not exist[X - resid]:
            print(X - resid)
            return None
        if not exist[X + resid]:
            print(X+resid)
            return None
        resid += 1


if __name__ == "__main__":
    run()
a, b, c = input().split()
print(a, b, c)

### FIXED CODE ###

a, b, c  = input().split(",")
print(a, b, c)
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]
for i in range(1, n):
    dp += [min([dp[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])]
print(dp[-1])

### FIXED CODE ###

N = int(input())
abc = [[int(j) for j in input().split()] for i in range(N)]
dp = [[0] * 3]
for day in range(N):
    dp += [[max([dp[-1][p] + abc[day][n] for p in range(3) if p != n]) for n in range(3)]]
print(max(dp[-1]))
def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[-5:] == 'dream':
    return check(string[:-5])
  if l >= 7 and string[-7:] == 'dreamer':
    return check(string[:-7])
  if string[-5:] == 'erase':
    return check(string[:-5])
  if l >= 6 and string[-6:] == 'eraser':
    return check(string[:-6])
      
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')
if a <= b:
    print(a)
else:
    print(a - 1)

### FIXED CODE ###

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

# check
if a <= b:
    print(a)
else:
    print(a - 1)
import math
r = int(input())

S = r * r * math.pi
fraction = S / (1 * 1 * math.pi)

print(fractions)

### FIXED CODE ###

r = int(input())
print(r*r)
N = input()
answer = N % 1000
print(answer)

### FIXED CODE ###

N = int(input())
answer = 0
for i in range(1, 1000):
  pay = 1000 * i
  if pay >= N:
    answer = pay - N
    break
print(answer)
a=int(input())
b=int(input())
c=int(input())
if a==1:
  print("Hello World")
if a==2:
  print(int(b+c))

### FIXED CODE ###

a=int(input())
if a==1:
  print("Hello World")
if a==2:
  b=int(input())
  c=int(input())
  print(int(b+c))
N, K = map(int, input().split())
menu = []

for i in range(N):
    t, d = map(int, input().split())
    menu.append((t, d))

sorted(menu, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans) 

### FIXED CODE ###

N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans)
a=[0]*100000
b=[0]*100000

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

for i in range(0,n,2):
  a[v[i]]+=1


for i in range(1,n,2):
  b[v[i]]+=1

if max(a)+max(b)==n and v[1]==v[0]:
  print(n//2)
else:
  print(n-max(a)-max(b))
  
  

### FIXED CODE ###

a=[0]*100001
b=[0]*100001

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

for i in range(0,n,2):
  a[v[i]]+=1
for i in range(1,n,2):
  b[v[i]]+=1

if a.index(max(a))==b.index(max(b)):
  a= sorted(a, reverse=True)
  b= sorted(b, reverse=True)
  print(min(n-a[1]-b[0],n-a[0]-b[1]))
else:
  print(n-max(a)-max(b))
import copy
import heapq

from typing import List, Tuple


def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))

    print(ag(v, g))


def ag(v: List[Tuple[int, int]], g: int) -> int:
    rs = []
    # ex. [(3, 500), (5, 800)] -> [(1, 3, 500), (2, 5, 800)]
    v = [(i, p, c) for i, (p, c) in enumerate(v, 1)]

    for j in range(len(v) ** 2):
        cb = []
        for k in range(len(v)):
            if ((j >> k) & 1):
                cb.append(v[k])

        sc = 0
        cnt = 0
        # calc bonus score
        for (i, p, c) in cb:
            sc += i * 100 * p + c
            cnt += p

        vv = [x for x in copy.copy(v) if not x in cb]
        while sc < g:
            if not vv:
                break
            i, p, _ = vv.pop()
            for _ in range(p - 1):
                if sc >= g:
                    break
                sc += i * 100
                cnt += 1

        if sc >= g:
            heapq.heappush(rs, cnt)

    return heapq.heappop(rs)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import copy
import heapq

from typing import List, Tuple


def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))

    print(ag(v, g))


def ag(v: List[Tuple[int, int]], g: int) -> int:
    rs = []
    # ex. [(3, 500), (5, 800)] -> [(1, 3, 500), (2, 5, 800)]
    v = [(i, p, c) for i, (p, c) in enumerate(v, 1)]

    for j in range(2 ** len(v)):
        cb = []
        for k in range(len(v)):
            if ((j >> k) & 1):
                cb.append(v[k])

        sc = 0
        cnt = 0
        # calc bonus score
        for (i, p, c) in cb:
            sc += i * 100 * p + c
            cnt += p

        vv = [x for x in copy.copy(v) if not x in cb]
        while sc < g:
            if not vv:
                break
            i, p, _ = vv.pop()
            for _ in range(p - 1):
                if sc >= g:
                    break
                sc += i * 100
                cnt += 1

        if sc >= g:
            heapq.heappush(rs, cnt)
    return heapq.heappop(rs)


if __name__ == '__main__':
    main()
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

### FIXED CODE ###

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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N+1):
    try:
        dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
        dp[i+1] = min(dp[i+1], dp[i-1]+abs(H[i+1]-H[i-1]))
    except:
        continue

print(dp[-1])
a=input()
x=a+a*a+a*a*a
print(a)

### FIXED CODE ###

num = int(input())
num2 = num + num*num+num*num*num
print(num2)
import math
a,b = [int(i) for i in input().split()]
print(a*b//math.gcd(a,b))


### FIXED CODE ###

a,b = [int(i) for i in input().split()]
a_ = []
b_ = []
for i in range(1,a+1):
    if a%i == 0:
        a_.append(i)

for i in range(1,b+1):
    if b%i == 0:
        b_.append(i)

for i in a_[::-1]:
    if i in b_:
        m = i
        break


print(a*b//m)
N = int(input())

x,y,z = 1,1,1

def is_true(x,y,z,i):
    if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
        return True
    return False

loop = int(N ** (1/2))

for i in range(5):
    print(0)
print(1)

for i in range(7,N+1):
    a = 0
    b = 0
    c = 0
    if i
    for ai in range(loop):
        for bi in range(loop):
            for ci in range(loop):
                X = x+a
                Y = y+b
                Z = z+c
                if is_true(X,Y,Z,i):
                    count += 1
    print(count)


### FIXED CODE ###

N = int(input())

ans = [0 for _ in range(10050)]

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if a < 10050:
                ans[a] += 1
for i in range(1,N+1):
    print(ans[i])
da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:

	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = list(map(int,input().split()))
		su += k[i][0] * k[i][1]

	sorted(k,reverse = True)
	while da[1] != 0:
		if da[1] >= k[j][0]:
			su -= k[j][0] * k[j][1]
			da[1] -= k[j][0]
			j += 1

		else:
			su -= da[1] * k[j][1]
			da[1] = 0
			j += 1

	print(su)

	da = list(map(int,input().split()))
	k = [[0 for i in range(2)]for j in range(10000)]



### FIXED CODE ###

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

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] + da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())


	k = sorted(k,key = lambda x: x[1],reverse = True)

	while j != i + 1:
		if da[1] > k[j][0]:
			da[1] -= k[j][0]
			j += 1
		elif da[1] <= k[j][0] and da[1] > 0:
			su += (k[j][0] - da[1]) * k[j][1]
			da[1] = 0
			j += 1
		else:
			su += k[j][0] * k[j][1]
			j += 1

	print(su)

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

	k = [[0 for i in range(2)]for j in range(10001)]
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N, dtype=int)
h = np.array(h)
 
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
 
print(dp[-1])

### FIXED CODE ###

import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N, dtype=int)
h = np.array(h)
 
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
 
print(dp[-1])
def lcm (a,b):
	if a<b:
		t=a
		a=b
		b=t
	x=a*b
	r=a%b
	while r!=0:
		a=b
		b=r
		r=a%b
	return x/b

[n, m]=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
i=0
a_lcm=a[0]
for i in range(n-1):
	a_lcm = lcm(a_lcm,a[i+1])

print(int(((m*2/a_lcm)+1)/2))

### FIXED CODE ###

[s,t] = [int(x) for x in input().split()]
if 500*s >= t:
	print("Yes")
else:
	print("No")
N = int(input())
A = list(map(int, input().split()))


def solve(i, s, k, sign):
    if i == N:
        return k

    if sign * (s + A[i]) > 0:
        return solve(i + 1, s + A[i], k, sign * -1)
    else:
        return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)


a = solve(0, 0, 0, 1)
b = solve(0, 0, 0, -1)

if a < b:
    print(a)
else:
    print(b)


### FIXED CODE ###

_ = int(input())
A = list(map(int, input().split()))

ret = float('inf')

sign = 1
s = 0
k = 0
for a in A:
    if sign * (s + a) > 0:
        s += a
    else:
        k += abs(s + a) + 1
        s = sign
    sign *= -1
ret = min(ret, k)

sign = -1
s = 0
k = 0
for a in A:
    if sign * (s + a) > 0:
        s += a
    else:
        k += abs(s + a) + 1
        s = sign
    sign *= -1

ret = min(ret, k)


print(ret)
import math
n=int(input())
s=list(input() for i in range(n))
m=[]
a=[]
r=[]
c=[]
h=[]
ans=1
for i in range(n):
    if s[i][0] == "M" and not s[i] in m:
        m.append(s[i])
    elif s[i][0] == "A" and not s[i] in a:
        a.append(s[i])
    elif s[i][0] == "R" and not s[i] in r:
        r.append(s[i])
    elif s[i][0] == "C" and not s[i] in c:
        c.append(s[i])
    elif s[i][0] == "H" and not s[i] in h:
        h.append(s[i])
num=len(m)+len(a)+len(r)+len(c)+len(h)
if num == 0:
    print(0)
else:
    lis = list(len(m),len(a),len(r),len(c),len(h))
    ans = ans*lis[i] for i in range(5)
    print(ans)

### FIXED CODE ###

n=int(input())
s=list(input() for i in range(n))
mc=ac=rc=cc=hc=0
cnt=0
for i in range(n):
    if s[i][0] == "M":
        mc+=1
    elif s[i][0] == "A":
        ac+=1
    elif s[i][0] == "R":
        rc+=1
    elif s[i][0] == "C":
        cc+=1
    elif s[i][0] == "H":
        hc+=1
lis = [mc,ac,rc,cc,hc]
if sum(lis) == 0:
    print(0)
else:
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                cnt+=lis[i]*lis[j]*lis[k]
    print(cnt)