Harryxun/stf_run huggingface dataset:
N, A,B = map(int, input().split())
str = []
if A==0 and B==0:
    print('0')

else:
    
    list_ab = []
    list_b = ['b']*A
    list_ab+=(list_b)
    list_a = ['a']*B
    list_ab+=list_a

    count = (N//(A+B))+1
    str = list_ab*count

    str = str[:N]
    print(str.count('b'))


### FIXED CODE ###

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

count = N//(A+B)
if (N-count*(A+B))>A:
    print(count*A+A)
else:
    print(count*A+(N-count*(A+B)))
# -*- coding: utf-8 -*-
from math import factorial

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

def ncr(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r)) 

for i in range(1, K+1):
    print(ncr(K-1, i-1) * ncr(N-K+1, i) % (10**9 + 7))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from math import factorial

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

def ncr(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r)) 

for i in range(1, K+1):
    if i <= N-K+1:
        print(ncr(K-1, i-1) * ncr(N-K+1, i) % (10**9 + 7))
    else:
        print(0)
import math
a,b,x = map(int, input().split())

tan = (a*a*a)/(2*(a*a*b-x))
tan_thre = a/b

if tan > tan_thre:
    ans = math.degrees(math.atan(tan))
    print(90-ans)
else:
    tan = 2*x/(a*b*b)
    ans = math.degrees(math.atan(tan))
    print(90-ans)

### FIXED CODE ###

import math
a,b,x = map(int, input().split())

if a*a*b == x:
    print(0)
    exit()

tan = (a*a*a)/(2*(a*a*b-x))
tan_thre = a/b

if tan > tan_thre:
    ans = math.degrees(math.atan(tan))
    print(90-ans)
else:
    tan = 2*x/(a*b*b)
    ans = math.degrees(math.atan(tan))
    print(90-ans)
x,y = map(int,input().split())
z = int(str(x)+str(y))
for i in range(int(z**0.5)+1):
  if i**2 = z:
    print("Yes")
    exit()
print("No")

### FIXED CODE ###

a,b=map(int,input().split())
c=int(str(a)+str(b))
for i in range(int(c**(1/2))+1) :
  if i**2==c :
    print("Yes")
    exit()
print("No")
n=int(input())
l=list(map(int,input().split()))
b,i,c=10**9,1,True
while(i<n and c):
  p=sum(l[:i])
  q=sum(l[i:])
  if min(b,abs(p-q))!=abs(p-q):
    break
  else:
    b=min(b,abs(p-q))
    i+=1
print(b)

### FIXED CODE ###

a,b=map(int,input().split())
f=a%3==0 or b%3==0 or (a+b)%3==0
print("Possible" if f==True else "Impossible")
N,Wmax=map(int,input().split(' '))
W=[]
V=[]
for _ in range(N):
	w,v = map(int,input().split(' '))
	W.append(w)
	V.append(v)

#dp[i][j]=i番目の品物までだけを選び重量制限をjとしたときの価値の最大値
dp = []
dp.append([0]*min(W[0],Wmax+1)+ [V[0]]*max(0, Wmax+1-W[0]))


for i in range(1,N):
	#今回の重量制限をwとする
	#今回は荷物を積む場合: dp[i][w] = dp[i-1][w-w[i]]+v[i] 
	#今回は荷物を積まない場合: dp[i][w] = dp[i-1][w]
	#よってこの2つのうち大きいほうをdp[i][w]に採用する
	dpi = []
	for j in range(Wmax+1):
		if j<W[i]:
			dpi.append(dp[i-1][j])
		else:
			dpi.append(max(dp[i-1][j], dp[i-1][j-W[i]]+V[i]))
	dp.append(dpi)
print(dp[N-1][Wmax])

### FIXED CODE ###

N,Wmax=map(int,input().split(' '))
W=[]
V=[]
for _ in range(N):
	w,v = map(int,input().split(' '))
	W.append(w)
	V.append(v)

Vmax=sum(V)

# dp[i][v]=i番目の品物までだけを選び価値の合計をvとしたときの必要な重量の最小値
# ただしそのような価値の合計が実現不可能なときはNoneを格納

dp = []
for _ in range(N):
	dp.append([None]*(Vmax+1))

dp[0][0] = 0
dp[0][V[0]] = W[0]

for i in range(1,N):
	# 新しく積めるようになる荷物の価値をV[i]とする
	# このとき価値の合計をvにするのに必要な重量の最小値は
	#	  dp[i-1][v-V[i]]+W[i] と
	#   dp[i-1][v] のうち小さいほう
	for v in range(Vmax+1):
		if v-V[i]<0:
			dp[i][v] = dp[i-1][v]
		else:
			if dp[i-1][v] is not None:
				if dp[i-1][v-V[i]] is not None:
					dp[i][v] = min(dp[i-1][v],dp[i-1][v-V[i]]+W[i])
				else:
					dp[i][v] = dp[i-1][v]
			else:
				if dp[i-1][v-V[i]] is not None:
					dp[i][v] = dp[i-1][v-V[i]]+W[i]

ans = 0
for v in range(Vmax+1):
	try:
		ans = v if dp[-1][v]<=Wmax else ans
	except TypeError:
		pass

print(ans)
# E
import numpy as np
N, T = map(int, input().split())
# A=cost. B=value
A, B = np.array([input().split() for _ in range(N)], dtype=int).T

weight,value = A, B
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, まだ最後の食べ物を選んでない
d0 = np.zeros((N,T),int)
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, もう最後の食べ物を選んだ
d1 = np.zeros((N,T),int)
# 初期値として0番目の商品を加える
d0[0,weight[0]:] = value[0]
d1[0,:] = value[0]

for n in range(1, N):
  for w in range(T):
    if (w >= weight[n]):
      d0[n][w] = np.max(d0[n-1][w-weight[n]] + value[n], d0[n-1][w])
      d1[n][w] = np.max(d1[n-1][w-weight[n]] + value[n], d1[n-1][w], d0[n-1][w] + value[n])
    else:
      d0[n][w] = d0[n-1][w]
      d1[n][w] = np.max(d1[n-1][w], d0[n-1][w] + value[n])

print(d1[-1,-1])

### FIXED CODE ###

# E
import numpy as np
N, T = map(int, input().split())
# A=cost. B=value
A, B = np.array([input().split() for _ in range(N)], dtype=int).T

weight,value = A, B
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, まだ最後の食べ物を選んでない
d0 = np.zeros((N,T),int)
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, もう最後の食べ物を選んだ
d1 = np.zeros((N,T),int)
# 初期値として0番目の商品を加える
d0[0,weight[0]:] = value[0]
d1[0,:] = value[0]

for n in range(1, N):
  w = weight[n]
  # w < weight[n]
  d0[n][:w] = d0[n-1][:w]
  d1[n][:w] = np.fmax(d1[n-1][:w], d0[n-1][:w] + value[n])
  # w >= weight[n]
  d0[n][w:] = np.fmax(d0[n-1][:-w] + value[n], d0[n-1][w:])
  d1[n][w:] = np.fmax(np.fmax(d1[n-1][:-w] + value[n], d1[n-1][w:]), d0[n-1][w:] + value[n])

print(d1[-1,-1])
N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost=10000000000:
  print(-1)
else:
  print(min_cost)

### FIXED CODE ###

N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost==10000000000:
  print(-1)
else:
  print(min_cost)
N,K = map(int, input().strip().split(' '))
S = input().strip()

# 奇数番目は1のカタマリの人数　偶数番目は0のカタマリの人数 両端は必ず1のカタマリの人数
now_state, now_count = '1', 0
L = []
for i in range(len(S)):
  if S[i] == now_state:
    now_count += 1
  else:
    L.append(now_count)
    # reset
    now_count = 1
    now_state = '1' if now_state == '0' else '0'
L.append(now_count)
if now_state == '0':
  L.append(0)

#print(L)
# 0の塊をj個ひっくり返す
# j==1のとき101の3個の和の最大
# j==2のとき10101の5個の和の最大
# j==jのとき101...1のj*2+1個の和の最大

def ngram(n, _list):
  return [_list[i:i+n] for i in range(len(_list)-n+1)]

now_max = 0
j = min((len(L)-1)/2, K)
tmp = ngram(j*2+1, L)
# 偶数番目だけ
tmp = [sum(tmp[i]) for i in range(len(tmp)) if i%2 == 0]
tmp = max(tmp) if len(tmp) > 0 else 0
now_max = max(tmp, now_max)
print(now_max)



### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()
l,r,now_max,now_zeros = 0,0,1,0
for r in range(1,N):
  if S[r-1] == '0':
    if S[r] == '0':
      continue
    else:
      now_zeros += 1
  else:
    if S[r] == '0':
      if now_zeros < K:
        continue
      else:
        now_max = max(r-l, now_max)
        now_zeros -= 1
        for _ in range(l,r):
          l += 1
          if S[l-1:l+1] == '01':
            break
    else:
      continue
now_max = max(r-l+1, now_max)
print(now_max)
A ,B = map(int, raw_input().split())
S = raw_input().split("-")
print len(S) == 2 and len(S[0]) == A and len(S[1]) == B ? "Yes" : "No"

### FIXED CODE ###

A ,B = map(int, raw_input().split())
S = raw_input().split("-")
print  "Yes" if len(S) == 2 and len(S[0]) == A and len(S[1]) == B else "No"
s = input()
if s == "SUN":
    print(7)
elif s == "MON:
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED"
    print(4)
elif s == "THU"
    print(3)
elif s == "FRI"
    print(2)
else:
    print(1)

### FIXED CODE ###

s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)
def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())
    E = max(C, D)
    cnt = 0
    for i in range(A-1, E):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 2:
            print('No')
            return
    if C < D:
        print('Yes')
        return
    cnt = 0
    for i in range(B-1, D+2):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')
        
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())
    E = max(C, D)
    cnt = 0
    for i in range(A-1, E):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 2:
            print('No')
            return
    if C < D:
        print('Yes')
        return
    cnt = 0
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')
        
if __name__ == "__main__":
    main()
a,b = map(int,input().split())
if a * b // 2 == 1:
  print(Odd)
else:
  print(Even)

### FIXED CODE ###

a,b = map(int,input().split())
 
print("Even" if (a * b) % 2 == 0 else "Odd" )
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def need(m):
        s=1
        for i in range(m+1,n):
            a=aa[i]
            s|=s<<a
            s&=mask
        #print(m,bin(s))
        for i in range(max(0,k-aa[m]),k):
            if s>>i&1:return True
        return False

    n,k=MI()
    mask=(1<<k+1)-1
    #print(bin(mask))
    aa=LI()
    aa.sort()
    #print(aa)
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        while aa[m-1]==aa[m]:m-=1
        #print(m,aa[m],need(m))
        if need(m):r=m
        else:l=m
    print(l+1)

main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def need(m):
        s=1
        for i in range(n):
            if i==m:continue
            s|=s<<aa[i]
            s&=mask
        #print(m,bin(s),bin(s>>k-aa[m]))
        if s>>k-aa[m]:return True
        return False

    n,k=MI()
    mask=(1<<k)-1
    #print(bin(mask))
    aa=LI()
    aa.sort()
    for i in range(n):
        if aa[i]>k:
            aa=aa[:i]
            break
    n=len(aa)
    #print(aa)
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        #while aa[m-1]==aa[m]:m-=1
        #print(m,aa[m],need(m))
        if need(m):r=m
        else:l=m
    print(l+1)

main()
from collections import deque

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

nei_L = [[] for _ in range(M)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while len(queue) > 0:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)

### FIXED CODE ###

from collections import deque

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

nei_L = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while queue:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys


def main():
    count = int(raw_input())
    li = [int(n) for n in raw_input().split()]
    if count%2 == 1: # 奇数
        if li.count(0) != 1:
            print 0
            return
        for i in range(count)[2::2]:
            if li.count(i) != 2:
                print 0
                return
        print 2**(count/2)
    else: # 偶数
        for i in range(count)[1::2]:
            if li.count(i) != 2:
                print 0
                return
        print 2**(count/2)



if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding:utf-8 -*-

def main():
    a, op, b = raw_input().split()
    if op == '+':
        result = int(a) + int(b)
    else:
        result = int(a) - int(b)
    print result


if __name__ == "__main__":
    main()
S = input()
ans = 0
count = 0

for s in S:
    if s in ["A", "C", "G", "T"]:
        count += 1
        ans = max(max_count, count)
    else:
        count = 0

print(ans)

### FIXED CODE ###


S = input()
ans = 0
count = 0

for s in S:
    if s in ["A", "C", "G", "T"]:
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)
n,m,x = map(int,input().split())
a = [int(input()) for _ in range(m)]
c = sum(0+a[i] for i in range(len(a)) if x<i)
print(c)

### FIXED CODE ###

n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))
import sys
HK,WK,M = map(int, input().split())
hw_s = [list(map(int, input().split())) for _ in range(M)]
W = [0 for _ in range(HK+1)]
H = [0 for _ in range(WK+1)]
HW = [[0 for i in range(WK+1)] for _ in range(HK+1)]
# 3*10^5

for i, hw in enumerate(hw_s):
    h=hw[0]
    w=hw[1]

    H[h] += 1
    W[w] += 1

    HW[h][w] = 1

HMAXES = []
WMAXES = []
answer = 0
HMAX = max(H)
WMAX = max(W)


# 3*10^5
for i, h in enumerate(H):
    if h == HMAX:
        HMAXES.append(i)
for i, w in enumerate(W):
    if w == WMAX:
        HMAXES.append(i)
# 3*10^5
answer = HMAX + WMAX
for i, h in enumerate(HMAXES):
    for j, w in enumerate(WMAXES):
        if HW[i][j] == 0:
            print(answer)
            sys.exit(0)
print(answer-1)

### FIXED CODE ###

import sys
HK,WK,M = map(int, input().split())
W = [0] * (WK + 1)
H = [0] * (HK + 1)
HW = {}
# 3*10^5

for i in range(M):
    h, w = map(int, input().split())

    H[h] += 1
    W[w] += 1

    HW[(h,w)] = 1

answer = 0
HMAX = max(H)
WMAX = max(W)

HEMAX = H.count(HMAX)
WEMAX = W.count(WMAX)
if HEMAX * WEMAX > M:
    print(HMAX + WMAX)
    sys.exit(0)

HMAXES = [i for i, _ in enumerate(H) if _ == HMAX]
WMAXES = [i for i, _ in enumerate(W) if _ == WMAX]

# 3*10^5
answer = HMAX + WMAX
for h in HMAXES:
    for w in WMAXES:
        if not (h,w) in HW:
            print(answer)
            sys.exit(0)
print(answer-1)
n = input()
s = [input() for i in range(n)]
 
print(len(list(set(s))))

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
 
print(len(list(set(s))))
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def main():
    N ,Q = ints_raw()
    origST = []

    for idx  in range(N):
        S,T,X = ints_raw()
        origST.append([S-X,T-X,X])
    Ds = [int(input()) for _ in range(Q)]

    origST.sort()
    stidx = 0
    cur_set = []
    for d in Ds:

        while stidx < len(origST):
            st = origST[stidx]
            if st[0] > d:
                break
            heappush(cur_set,(st[2],st[1]))
            stidx+=1
        while cur_set and cur_set[0][1] <=d:
            heappop(cur_set)
        if cur_set:
            print(-1)
        else:
            print(cur_set[0][0])
main()


### FIXED CODE ###

import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def main():
    N ,Q = ints_raw()
    origST = []

    for idx  in range(N):
        S,T,X = ints_raw()
        origST.append([S-X,T-X,X])
    Ds = [int(input()) for _ in range(Q)]

    origST.sort()
    stidx = 0
    cur_set = []
    for q in Ds:

        while stidx < len(origST):
            st = origST[stidx]
            if st[0] > q:
                break
            heappush(cur_set,(st[2],st[1]))
            stidx+=1
        while cur_set and cur_set[0][1] <=q:
            heappop(cur_set)
        if len(cur_set)==0:
            print(-1)
        else:
            print(cur_set[0][0])
main()
N , K = map(int , input().split())
R , S , P = map(int , input().split())
T = input()

dic = {"r":"p" , "s":"r" , "p":"s"}
ANS = []

for i in range(N):
    ANS.append(dic[T[i]])
    
ans = "".join(ANS)

VANISH = []
    
for i in range(N-K):
    if ans[i] == ans[i+K]:
        VANISH.append(ans[i])
        
if N - (2*K) > 0:
    for i in range(N - (2*K)):
        if ans[i] == ans[i+(2*K)]:
            VANISH.remove(ans[i])
            
vanish = "".join(VANISH)
        
point = ((ans.count("r")-vanish.count("r"))*R + (ans.count("s")-vanish.count("s"))*S + (ans.count("p")-vanish.count("p"))*P)

print(point)

### FIXED CODE ###

S , T = input().split()

print(T + S)
MOD = 10**9+7
memo = [0]*10000

N = int(input())

def primeLst(k):
  acc = []
  if k == 1:
    return acc
  f = 2
  while f * f <= k:
    if k % f == 0:
      acc.append(f)
      k //= f
    else:
      f += 1
  if k != 1:
    acc.append(k)
  return acc

for i in range(N):
  l = primeLst(i+1)
  for x in l:
    memo[x] += 1

res = 1
for i in range(1,N):
  res *= memo[i+1] + 1
  res %= MOD

print(acc)

### FIXED CODE ###

MOD = 10**9+7
memo = [0]*10000

N = int(input())

def primeLst(k):
  acc = []
  if k == 1:
    return acc
  f = 2
  while f * f <= k:
    if k % f == 0:
      acc.append(f)
      k //= f
    else:
      f += 1
  if k != 1:
    acc.append(k)
  return acc

for i in range(N):
  l = primeLst(i+1)
  for x in l:
    memo[x] += 1

res = 1
for i in range(1,N):
  res *= memo[i+1] + 1
  res %= MOD

print(res)
a,b = [int(input()) for i in range(2)]

print(a*b)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
import sys
n, m = map(int, input().split())

ans = 0
li = [list(map(int, input().split())) for i in range(m)] 

for i in range(m):
    for j in range(m):
        if (li[i][0] == li[j][0]) and (li[i][1] != li[j][1]):
            print(-1)
            sys.exit()

for i in range(m):
    if (li[i][0] == 1) and (li[i][1] == 0) and (n != 1):
        print(-1)
        sys.exit()
        
if n == 1:
    ans = li[0][1]
    print(ans)

elif n == 2:
    for i in range(m):
        if (li[i][0] == 1):
            ans -= (ans//10)*10
            ans += li[i][1]*10
        else:
            ans -= (ans%10)
            ans += li[i][1]
        
        if ans < 10:
            ans += 10
            
    print(ans)

else:
    for i in range(m):
        if (li[i][0] == 1):
            ans -= (ans//100)*100
            ans += li[i][1]*100
        elif (li[i][0] == 2):
            ans -= ((ans-(ans//100)*100)//10)*10
            ans += li[i][1]*10
        else:
            ans -= (ans%10)
            ans += li[i][1]
            
        if ans < 100:
            ans += 100
            
    print(ans)

### FIXED CODE ###

import sys
N, M = map(int, input().split())
li = [-1] * N
for i in range(M):
    s, c = map(int, input().split())
    if li[s-1] == -1 or li[s-1] == c:
        li[s-1] = c
    else:
        print(-1)
        sys.exit()
if N == 1:
    if li[0] == -1:
        ans = 0
    else:
        ans = li[0]
elif N == 2:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        ans = li[0]*10 + li[1]
else:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        if li[2] == -1:
            li[2] = 0
        ans = li[0]*100 + li[1]*10 + li[2]
print(ans)
import collections
 
n=int(input())
a=list(map(int, input().split()))
a.sort()
a.reverse()
c=collections.Counter(a)
ans=0
for i in a:
  for j in range(20):
    if(2**j>i):
      k=2**j-i
      break
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)

### FIXED CODE ###

import collections
import math
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=collections.Counter(a)
ans=0
for i in a:
  j=int(math.log2(i))+1
  k=2**j-i
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)
a = int(input())
b = int(input())
print(max([a+b, a-b, a*b]))

### FIXED CODE ###

A, B = [int(i) for i in input().split(" ")] 
print(max([A+B, A-B, A*B]))
n=int(input())

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return n-march.count(0),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)


### FIXED CODE ###

n=int(input())

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return len(ans),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)
import sys
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')


### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')