Harryxun/stf_run huggingface dataset:
n, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for m in range(m)]
p = list(map(int, input().split()))

for i in range(2 ** n):
    for m in range(M):
        switch = 0
        for j in range(n):
            if (i >> j) & 1:
                if j + 1 in s[m]:
                    switch += 1
        if switch % 2 != p[m]:
            break
    else:
        count += 1
print(count)

### FIXED CODE ###

N,M=map(int,input().split())
s=[list(map(int,input().split()))[1:] for m in range(M)]
p=list(map(int,input().split()))
count=0
for i in range(1<<N):
    for m in range(M):
        switch=0
        for j in range(N):
            if (i>>j)&1 and j+1 in s[m]:
                switch+=1
        if switch%2!=p[m]:
            break
    else:
        count+=1
print(count)
n = int(input())
num_list = [list(map(int, input().split())) for i in range(n)]

num_list[1].sort(reverse=True)
v = 1 / (4 * num_list[0][1]) * sum(num_list[1])

c = 1

for i in range(num_list[0][1]):
  if num_list[1][i] < v:
    c = 0
    
if c==1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = list(map(int,input().split()))
a[0], a[1] = a[1], a[0]
a[0], a[2] = a[2], a[0]
 
print(a[0], a[1], a[2])
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
count = 0
for i in range(len(S)):
  count += 1
  if S[i:i+2] == "#.":
    arr.append(count)
    count = 0  
  if S[i:i+2] == ".#":
    arr.append(count)
    count = 0
if S[-1] == ".":
  arr.append(count)
#print(arr)
 
result = sum([min(arr[i:i+2]) for i in range(0, len(arr)+1, 2)])
print(result)

### FIXED CODE ###

N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
b, w = 0, 0
for i in range(len(S)):
  if S[i] == ".":
    w += 1
  else:
    b += 1
  if S[i:i+2] == "#.":
    arr.append(b)
  if S[i:i+2] == ".#":
    arr.append(w)
if S[-1] == ".":
  arr.append(w)
#print(arr)
 
result = w
for i in range(0, len(arr), 2):
  result = min([arr[i]+w-arr[i+1], result])

print(result)
n = int(input())
ds = map(int, input().split())
t = 0
for i in range(n):
  for j in range(i, n):
    t += d[i] * d[j]
print(t)

### FIXED CODE ###

n = int(raw_input())
ds = map(int, raw_input().split())
t = 0
for i in range(n):
  for j in range(i+1, n):
    t += ds[i] * ds[j]
print(t)
s1, s2, s3 = map(int,input().split())
i = 0
if(s1 == 1):
    i = i + 1
if(s2 == 1):
    i = i + 1
if(s3 == 1):
    i = i + 1
print(i)

### FIXED CODE ###

s = int(input())
i = 0
if(s//100==1):
    i = i + 1
    s = s - 100
if(s//10==1):
    i = i + 1
    s = s-10
if(s==1):
    i = i + 1
print(i)
import sys
sys.setrecursionlimit(10**6)
n = int(input())
edge = [[] for _ in range(n)]

for i in range(n-1):
    s, g, d = map(int, input().split())
    edge[s-1].append((g, d%2))
    edge[g-1].append((s, d%2))

ans = [None for _ in range(n)]

def set_color(x, col):
    ans[x-1] = col
    print(ans, edge[x-1])
    for g, d in edge[x-1]:
        if ans[g-1] == None:
            set_color(g, d^col)

set_color(1, 0)
for i in range(n):
    print(ans[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n=int(input())
edge=[[]for i in range(n+1)]

for i in range(n-1):
    u,v,w=map(int,input().split())
    if w%2==0:
        edge[u].append((v,1))
        edge[v].append((u,1))
    else:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
        
color=[None]*(n+1)

def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)

set_color(1,1)
for i in color[1:]:
    print((i+1)//2)
N=int(input())
sum=0
for i range(N):
  l, r =map(int, input().split())
  sum+=(r-l+1)
print(sum)

### FIXED CODE ###

n=int(input())
sum=0
for i in range(n):
  l, r =map(int, input().split())
  sum+=(r-l+1)
print(sum)
import functools
import math
N = int(input())
a = list(map(int, input().split()))

gcd = []
for i in range(N) :
    list_not_i = a.copy()
    list_not_i.remove(a[i])
    gcd.append(functools.reduce(math.gcd, list_not_i))

print(str(max(gcd)))

### FIXED CODE ###

import functools
import fractions
N = int(input())
a = list(map(int, input().split()))

L = [0] * N
for i in range(N) :
        if i == 0 :
                L[0] = 0
        elif i == 1 :
                L[1] = a[0]
        else :
                L[i] = fractions.gcd(L[i-1], a[i-1])

a.reverse()
R = [0] * N
for i in range(N) :
        if i == 0 :
                R[0] = 0
        elif i == 1 :
                R[1] = a[0]
        else :
                R[i] = fractions.gcd(R[i-1], a[i-1])
R.reverse()
a.reverse()

gcd = [0] * N
for i in range(N) :
        if i == 0 :
                gcd[0] = R[0]
        elif i == N-1 :
                gcd[N-1] = L[N-1]
        else :
                gcd[i] = fractions.gcd(L[i],R[i])

print(max(gcd))
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

S.append(0)
cnt = 0
for j in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
        else if T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt

### FIXED CODE ###

n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for j in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
            break
        elif T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt
import sys
from functools import reduce

def _main():
    n, m, k = map(int, sys.stdin.readline().split(" "))
    a = list(map(int, sys.stdin.readline().split(" ")))
    b = list(map(int, sys.stdin.readline().split(" ")))

    bestScore = 0
    _k = 0
    _ai = 0

    while _k < k and _ai < n:
        _k = _k + a[_ai]
        if _k > k:
            _k = _k - a[_ai]
            bestScore = _ai
            break
        _ai = _ai + 1

    _bi = 0

    while _bi < m and _ai >= 0:
        _k = _k + b[_bi]

        while _k > k and _ai >= 0:
            _k = _k - a[_ai] 
            _ai = _ai - 1

        _bi = _bi + 1

        if _k <= k and _ai + _bi > bestScore:
            bestScore = _ai + _bi

    print(bestScore)

if __name__ == "__main__":
    _main()

### FIXED CODE ###

import sys
from functools import reduce

def main(n, m, k, a, b):
    """ main
    """

    bestScore = 0
    _k = 0
    _ai = 0

    while True:
        if _ai >= n or _k + a[_ai] > k:
            bestScore = _ai
            break
        else:
            _k = _k + a[_ai]
            _ai = _ai + 1

    _bi = 0

    while _bi < m:
        _k = _k + b[_bi]

        while _k > k and _ai - 1 >= 0:
            _k = _k - a[_ai - 1] 
            _ai = _ai - 1

        if _k > k:
            break

        _bi = _bi + 1

        if _ai + _bi > bestScore:
            bestScore = _ai + _bi

    return bestScore

if __name__ == "__main__":
    N, M, K = map(int, sys.stdin.readline().split(" "))
    A = list(map(int, sys.stdin.readline().split(" ")))
    B = list(map(int, sys.stdin.readline().split(" ")))

    print(main(N, M, K, A, B))
import numpy as np
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
HH=np.zeros((N,N))
for i in range(M):
  A,B=list(map(int,input().split()))
  HH[A-1][B-1]=1
HH=HH+HH.T
count=0
#print(HH)
for i in range(N):
  for j in range(N):
    if(HH[i][j]>0):
      if(H[i]<=H[j]):
        count+=1
        break
print(N-count)        

### FIXED CODE ###

import numpy as np
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
F=[0]*len(H)
for i in range(M):
  A,B=list(map(int,input().split()))
  if(H[A-1]<H[B-1]):
    F[A-1]=1
  elif(H[A-1]>H[B-1]):
    F[B-1]=1
  else:
    F[B-1]=1
    F[A-1]=1
print(F.count(0))
p=input().rstrip().split(' ')
if p[1]=='+':
  print(int(p[0]) + int(p[1]))
else:
  print(int(p[0]) + int(p[1]))

### FIXED CODE ###

p=input().rstrip().split(' ')
if p[1]=='+':
  print(int(p[0]) + int(p[2]))
else:
  print(int(p[0]) - int(p[2]))
for i in list(range(1,10)):
???for ii in list(range(1,10)):
??????print('%d x %d = %d * %d' % (i, ii, i*ii))

### FIXED CODE ###

for x in range(1,10):
    for y in range(1,10):
        print("%dx%d=%d" % (x, y, x*y))
n,a,b=map(int,input().split())
print min(n*a,b)

### FIXED CODE ###

n,a,b=list(map(int,input().split()))
print(min(n*a,b))
# 拡張ユークリッド互除法
    # ax + by = gcd(a,b)の最小整数解を返す
    def egcd(a, b):
        if a == 0:
            return b, 0, 1
        else:
            g, y, x = egcd(b % a, a)
            return g, x - (b // a) * y, y
     
     
    # mを法とするaの乗法的逆元
    def modinv(a, m):
        g, x, y = egcd(a, m)
        if g != 1:
            raise Exception('modular inverse does not exist')
        else:
            return x % m
     
          
    n = int(input())
    A = list(map(int, input().split()))
    C = [-1] * (n+1)
    lr = 0
    for i, a in enumerate(A):
        if C[a] == -1:
            C[a] = i
        else:
            lr = C[a] + n - i
            break
     
     
    def combination(n):
        lst = [1]
        mod = 10**9+7
        for i in range(1, n+1):
            lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
        return lst
     
     
    NC = combination(n+1)
    LRC = combination(lr)
    for i in range(1, n+2):
        print(NC[i] - (LRC[i-1] if i-1 <= lr else 0))

### FIXED CODE ###

# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


n = int(input())
A = list(map(int, input().split()))
C = [-1] * (n+1)
lr = 0
for i, a in enumerate(A):
    if C[a] == -1:
        C[a] = i
    else:
        lr = C[a] + n - i
        break


def combination(n, mod):
    lst = [1]
    for i in range(1, n+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst


mod = 10**9+7
NC = combination(n+1, mod)
LRC = combination(lr, mod)
for i in range(1, n+2):
    print((NC[i] - (LRC[i-1] if i-1 <= lr else 0)) % mod)
d = 1000000007
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]
safe = [True for i in range(N+1)]
for ai in a:
  safe[ai] = False
dp = [0 for i in range(N+1)]
dp[1] = 1 if safe[1] else 0
dp[2] = 1+dp[1] if safe[2] else 0
for i in range(3, N+1):
  dp[i] = (dp[i-2]+dp[i-1]) % d if safe[i] else 0
print(dp[N])

### FIXED CODE ###

d = 1000000007
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]
safe = [True for i in range(N+1)]
for ai in a:
  safe[ai] = False
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1 if safe[1] else 0
for i in range(2, N+1):
  dp[i] = (dp[i-2]+dp[i-1]) % d if safe[i] else 0
print(dp[N])
while 1:
    n,i=int(input()),0
    if n==0:break
    n=str(math.factorial(n))[::-1]
    while n[i]=='0':i+=1
    print(i)

### FIXED CODE ###

import math
while 1:
    n,i=int(input()),0
    if n==0:break
    n=str(math.factorial(n))[::-1]
    while n[i]=='0':i+=1
    print(i)
import math
import sys
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while True:
        if num==1:
            print(ans)
            sys.exit(0)
        else:
            if num%count==0:
                ans+=1
                while num%count==0:
                    num= num/count
                count+=1
            else:
                count+=1


### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())
# ans = 1
count = 2
n=gcd(a,b)

ans = set([1])
while n % 2 == 0:
    ans.add(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ans.add(f)
        n //= f
    else:
        f += 2
if n != 1:
    ans.add(n)
print(len(ans))
N = int(input())
height = [int(i) for i in input().split()] + [0]
k = 0
while True :
    for i in range(N):
        if height[i] > 0 :
            lv = i 
            break 

    for i in range(lv,N+1):
        if height[i] == 0 :
            uv = i 
            break 
    for i in range(lv,uv):
        height[i] -= 1
    k += 1
    if sum(height) == 0 :
        break 
print(k)

### FIXED CODE ###

N = int(input())
height = [int(i) for i in input().split()] + [0]
k = 0
while True :
    if sum(height) == 0 :
        break 
    for i in range(N):
        if height[i] > 0 :
            lv = i 
            break 

    for i in range(lv,N+1):
        if height[i] == 0 :
            uv = i 
            break 
    for i in range(lv,uv):
        height[i] -= 1
    k += 1
print(k)
def main():
    H, W = map(int, input().split())
    a = [[0] * W]
    for _ in range(H):
        ai = list(map(int, input().split()))
        ai.insert(0, 0)
        a.append(ai)
    N = 0
    yx = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if a[i][j] % 2 == 0:
                continue
            if W >= j + 1:
                a[i][j] -= 1
                a[i][j + 1] += 1
                N += 1
                yx.append([i, j, i, j + 1])
            elif H >= i + 1:
                a[i][j] -= 1
                a[i + 1][j] += 1
                N += 1
                yx.append([i, j, i + 1, j])
        if H > i + 1 and a[i][j + 1] % 2 != 0:
            a[i][j + 1] -= 1
            a[i + 1][j + 1] += 1
            N += 1
            yx.append([i, j + 1, i + 1, j + 1])
    print(N)
    for row in yx:
        print(' '.join(list(map(str, row))))


main()


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    a = [[0] * W]
    for _ in range(H):
        ai = list(map(int, input().split()))
        ai.insert(0, 0)
        a.append(ai)
    N = 0
    yx = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if a[i][j] % 2 == 0:
                continue
            if W >= j + 1:
                a[i][j] -= 1
                a[i][j + 1] += 1
                N += 1
                yx.append([i, j, i, j + 1])
            elif H >= i + 1:
                a[i][j] -= 1
                a[i + 1][j] += 1
                N += 1
                yx.append([i, j, i + 1, j])
        if H > i + 1 and a[i][j] % 2 != 0:
            a[i][j] -= 1
            a[i + 1][j] += 1
            N += 1
            yx.append([i, j + 1, i + 1, j])
    print(N)
    for row in yx:
        print(' '.join(list(map(str, row))))


main()
print(1-int(input())

### FIXED CODE ###

print(1-int(input()))
print(input().counter("1"))

### FIXED CODE ###

print(input().count("1"))
x=list(map(int,input().split()))
for k in range(5)
    if x[k]=0:
        print(k)
    else:
        continue

### FIXED CODE ###

x=list(map(int,input().split()))
for k in range(5):
    if x[k]==0:
        print(k+1)
    else:
        continue
N =int(input())
X = list(map(int,input().split()))
X.sort()
tans=[]
for i in range(1,X[N-1]):
  P=i
  ans=0
  for j in range(N):
    ans+=(X[j]-P)**2
  tans.append(ans)
print(min(tans))

### FIXED CODE ###

N =int(input())
X = list(map(int,input().split()))
X.sort()
tans=[]
try:
  for i in range(1,X[N-1]+1):
    P=i
    ans=0
    for j in range(N):
      ans+=(X[j]-P)**2
    tans.append(ans)
  print(min(tans))
except:
  print(0)
N = int(input())
*a, = map(int, input().split())

dp = [[''] *  N for _ in range(N)]

def rec(i, j):
    if dp[i][j] != '':
        return dp[i][j]
    if i == j: 
        dp[i][j] = a[i]
        return a[i]
    ans = max(a[i] - rec(i+1, j), a[j] - rec(i, j-1))
    dp[i][j] = ans
    return ans

print(rec(0, N-1))

### FIXED CODE ###

N = int(input())
*a, = map(int, input().split())

dp = [[None] *  N for _ in range(N)]
for i in range(N): dp[i][i] = a[i]

for j in range(1, N):
    for i in range(j-1, -1, -1):
        dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1])

print(dp[0][N-1])
n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

def dp(i, a):
    if i == 0:
        return action[0][a]
    else:
        return max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]

print(max([dp(n-1,a) for a in range(3)]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

print(max([dp(n-1,a) for a in range(3)]))
# -*- coding: utf-8 -*-
import heapq
N = input()
a = []
for i in range(N):
	x,y=map(int,raw_input().split())
	a.append((i,x,y))

#a => point,x,y
a1=sorted(a, key=lambda x: x[1])
a2=sorted(a, key=lambda x: x[2])


#Union Find
#初めは各頂点が根
par=[ i for i in range(N) ]
#木の根を求める
def root(x):
	if par[x]==x:
		return x
	else:
		r=root(par[x])
		#経路圧縮
		par[x]=r
		return r
#xとyが同じ集合に属するか
def same(x,y):
	return root(x)==root(y)

#xとyが同じ根に所属していた場合、連結
def unite(x,y):
	x=root(x)
	y=root(y)
	if x==y:
		return
	else:
		par[x]=y


b=[]
for i in range(N-1):
	# len_x,x,y
	heapq.heappush( b, ( abs(a1[i+1][1]-a1[i][1]),a1[i][0],a1[i+1][0],  ))

for i in range(N-1):
	# len_y,x,y
	heapq.heappush( b, ( abs(a2[i+1][2]-a2[i][2]),a2[i][0],a2[i+1][0],  ))

#print "# b"
#print b


ans=0
cnt=0
for i in range(len(b)):
	if cnt==N-1:
		break
	val=heapq.heappop(b)
	#２点が同じ根でない場合は、木を結合する
	if not same(val[1],val[2]):
		unite(val[1],val[2])
		ans+=val[0]
		cnt+=1

print ans
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq
import sys
sys.setrecursionlimit(10**6)
N = input()
a = []
for i in range(N):
	x,y=map(int,raw_input().split())
	a.append((i,x,y))

#a => point,x,y
a1=sorted(a, key=lambda x: x[1])
a2=sorted(a, key=lambda x: x[2])


#Union Find
#初めは各頂点が根
par=[ i for i in range(N) ]
#木の根を求める
def root(x):
	if par[x]==x:
		return x
	else:
		r=root(par[x])
		#経路圧縮
		par[x]=r
		return r
#xとyが同じ集合に属するか
def same(x,y):
	return root(x)==root(y)

#xとyが同じ根に所属していた場合、連結
def unite(x,y):
	x=root(x)
	y=root(y)
	if x==y:
		return
	else:
		par[x]=y


b=[]
for i in range(N-1):
	# len_x,x,y
	heapq.heappush( b, ( abs(a1[i+1][1]-a1[i][1]),a1[i][0],a1[i+1][0],  ))

for i in range(N-1):
	# len_y,x,y
	heapq.heappush( b, ( abs(a2[i+1][2]-a2[i][2]),a2[i][0],a2[i+1][0],  ))

#print "# b"
#print b


ans=0
cnt=0
for i in range(len(b)):
	if cnt==N-1:
		break
	val=heapq.heappop(b)
	#２点が同じ根でない場合は、木を結合する
	if not same(val[1],val[2]):
		unite(val[1],val[2])
		ans+=val[0]
		cnt+=1

print ans
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)
print(min(ans))                

### FIXED CODE ###

L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)                
    print(min(ans))
from math import pi
r=int(raw_input())
print ("%f %f" %(pi*r**2, 2*pi*r))

### FIXED CODE ###

from math import pi
r=float(raw_input())
print ("%f %f" %(pi*r**2, 2*pi*r))
# a: 総数hiki， b: 足の数
a, b = map(int, input().split())

# かめiひき
for i in range(a+1):
  total = 4*i + 2*(a-i)
  if total == b:
    ans = 'Yes'
    break
  else:
    ans = 'No'

print(ans)

### FIXED CODE ###

a_list = list(map(int, input().split()))
print(1 + a_list.index(0))
n,*a = map(int,input().split())
s = [[*input()] for _ in range(n)]
a = {p:q for p,q in zip("ABC",a)}
ans = ["Yes"]+[0]*n
def dfs(i):
	if i==n:
	    print("\n".join(ans))
	    exit()
	for p,m in [s[i],s[i][::-1]]:
		if a[p]:
		    a[p]+=1; a[m]-=1; ans[i+1]=p
		    dfs(i+1)
		    a[p]-=1; a[m]+=1
dfs(0)
print("No")

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
n,*a = [int(i) for i in readline().split()]
s = read().split()

ans = ""
ok = 1

d = {"AB":0,"BC":1,"AC":2}
d2 = "ABC"

if sum(a) >= 3 or sum(a) <= 1:
    for i in s:
        v = d[i]
        w = (v+1)%3
        if a[w] < a[v]: v,w = w,v
        a[v] += 1
        a[w] -= 1
        ans += d2[v]
        if a[w] < 0: ok = 0
    
        #print(i,a,d2[v])
    if ok:
        print("Yes")
        print(*ans,sep="\n")
    else:
        print("No")


#d = {"AB":0,"BC":1,"AC":2}
#d2 = "ABC"

else: # (1,1,0) or (2,0,0)型
    for idx,c in enumerate(s):
        v = d[c]
        w = (v+1)%3
        
        if a[v]==1 and a[w]==1 and idx<n-1 and s[idx+1] != c:#先読み
            vv = d[s[idx+1]]
            ww = (vv+1)%3
            r = [0]*3
            r[v] += 1; r[w] += 1; r[vv] += 1; r[ww] += 1
            vv = r.index(2)
            ww = (vv+1)%3 if vv==v else (vv-1)%3
            a[vv] += 1
            a[ww] -= 1
            ans += d2[vv]
            if a[ww] < 0: ok = 0
        else: 
            if a[w] < a[v]: v,w = w,v
            a[v] += 1
            a[w] -= 1
            ans += d2[v]
            if a[w] < 0: ok = 0
        
        #print(a,c,ans[-1])
        
    if ok:
        print("Yes")
        print(*ans,sep="\n")
    else:
        print("No")
s = input()

ans = 0

q = s.count('?')

rc = [0]
rq = [0]
la = [0]
lq = [0]

for i in range(len(s)-1):
    if s[len(s)-i-1]=='C':
        rc.append(rc[-1]+1)
    else:
        rc.append(rc[-1])
    if s[len(s)-i-1]=='?':
        rq.append(rq[-1] + 1)
    else:
        rq.append(rq[-1])
    if s[i]=='A':
        la.append(la[-1]+1)
    else:
        la.append(la[-1])
    if s[i]=='?':
        lq.append(lq[-1]+1)
    else:
        lq.append(lq[-1])
rc.reverse()
rq.reverse()

t = 10**9+7

for i in range(len(s)):
    if s[i]=='B' or s[i]=='?':
        lq_ = lq[i]-1
        rq_ = rq[i]-1
        l = 1
        r = 1
        while lq_ > 20:
            l *= 3**20%t
            lq -=20
        while rq_ > 20:
            r *= 3**20%t
            rq_ -= 20
        l *= 3**lq_%t
        r *= 3**rq_%t
        l %= t
        r %= t
        ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t

print(int(ans%t))


### FIXED CODE ###

s = input()

ans = 0

rc = [0]
rq = [0]
la = [0]
lq = [0]
q3 = [1]
t = 10**9+7

for i in range(len(s)-1):
    if s[len(s)-i-1]=='C':
        rc.append(rc[-1]+1)
        rq.append(rq[-1])
    elif s[len(s)-i-1]=='?':
        rc.append(rc[-1])
        rq.append(rq[-1]+1)
    else:
        rc.append(rc[-1])
        rq.append(rq[-1])
    if s[i]=='A':
        la.append(la[-1]+1)
        lq.append(lq[-1])
    elif s[i]=='?':
        la.append(la[-1])
        lq.append(lq[-1]+1)
    else:
        la.append(la[-1])
        lq.append(lq[-1])
    q3.append(q3[-1] * 3 % t)
rc.reverse()
rq.reverse()

q3.append(1/3)

for i in range(len(s)):
    if s[i]=='B' or s[i]=='?':
        l = q3[lq[i]-1]
        r = q3[rq[i]-1]
        ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t

print(round(ans%t))
def main():
    [n,a,b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1,n+1):
        cost += min(a*(m[i]-m[i-1]), b)
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

### FIXED CODE ###


def main():
    [n, a, b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1, n):
        cost += min([a*(m[i]-m[i-1]), b])
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()
a=list(input().split()))
a=sorted(a)
print(int(a[2])+int(a[0]+a[1])))

### FIXED CODE ###

a=list(input().split())
a=sorted(a)
print(int(a[0])+int(a[2]+a[1]))