Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

s = input()
q = int(input())

query = []
rev=1

for i in range(q):
    query.append(input().split())

for i in range(q):
    if query[i][0]=="1":
        rev*=-1
    else:
        if rev==1:
            if query[i][1]=="1":
                s = query[i][2]+s
            else:
                s += query[i][2]
        else:
            if query[i][1]=="2":
                s = query[i][2]+s
            else:
                s += query[i][2]

if rev==-1:
    s = s[::-1]
print(s)

### FIXED CODE ###

from collections import deque

s = deque(input())
q = int(input())

query = []
rev=1

for i in range(q):
    query.append(input().split())

for i in range(q):
    if query[i][0]=="1":
        rev*=-1
    else:
        if rev==1:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="2":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])

result="".join(list(s))
if rev==-1:
    result = result[::-1]
print(result)
### BUGGY CODE ###

import itertools


def main():
  N, K = list(map(int, input().split()))
  P = list(map(int, input().split()))

  min_ = float('inf')

  all_ = list(range(N))
  for items in itertools.combinations(all_, K):
    sum_ = sum([P[i] for i in items])
    min_ = min(min_, sum_)

  print(min_)


if(__name__ == '__main__'):
  main()

### FIXED CODE ###

def main():
  N, K = list(map(int, input().split()))
  P = list(map(int, input().split()))

  P.sort()
  print(sum(P[:K]))


if(__name__ == '__main__'):
  main()
### BUGGY CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = list()

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  if i == 0:
    R.append(sum(Q[i:i+K]))
  else:
    R.append(sum(Q[i:i+K]))

print(max(R))

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = list()
R = [0]
result = 0

for i in P:
  Q.append((i+1)/2)

for i in range(N):
  R.append(R[i] + Q[i])

for i in range(N - K + 1):
  result = max(result,R[i+K]-R[i])

print(result)
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())
F = [input() for _ in range(h)]
direct = [[0,1],[1,0]]
que = deque()
que.append([0,0])
INF = 10**5
dp = [[INF]*w for _ in range(h)]


dp[0][0] = 0

while len(que)>0:  
  x,y = que.pop()    
  for dy,dx in direct:    
    ny = y+dy
    nx = x+dx
    if (0 <= nx < w) and (0 <= ny < h):
      if F[ny][nx] == F[y][x]:        
        if dp[ny][nx] >= dp[y][x]:
          dp[ny][nx] = dp[y][x]
          que.append([ny,nx])
      else:        
        if dp[ny][nx] >= dp[y][x] + 1 :        
          dp[ny][nx] = dp[y][x] + 1          
          que.append([ny,nx])   

ans = (dp[-1][-1]+1)//2
if F[0][0] == '#':
  ans += 1
print(ans)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
F = [input() for _ in range(h)]
direct = [[0,1],[1,0]]
que = deque()
que.append([0,0])
INF = 10**5
dp = [[INF]*w for _ in range(h)]


dp[0][0] = 0

while len(que)>0:  
  y,x = que.popleft()    
  for dy,dx in direct:    
    ny = y+dy
    nx = x+dx
    if (0 <= nx < w) and (0 <= ny < h):
      if F[ny][nx] == F[y][x]:         
        if dp[ny][nx] > dp[y][x]:
          dp[ny][nx] = dp[y][x]
          que.append([ny,nx])
      else:                
        if dp[ny][nx] > dp[y][x] + 1 :        
          dp[ny][nx] = dp[y][x] + 1          
          que.append([ny,nx])   


ans = dp[-1][-1]//2
if F[0][0] == '#' or F[-1][-1] == '#':
  ans += 1

print(ans)
### BUGGY CODE ###

n,q=map(int,input().split())
c=list(map(int,input().split()))
lr=[list(map(int,input().split())) for _ in range(q)]
for l,r in lr:
  tmp=len(set(c[l-1:r]))
  print(tmp)

### FIXED CODE ###


import sys
input = sys.stdin.readline
def main():
  n,q=map(int,input().split())
  c=list(map(int,input().split()))
  lr=[list(map(int,input().split())) for _ in range(q)]
  lri=[[lr[i][0],lr[i][1],i] for i in range(q)]
  lri.sort(key=lambda x:x[1])
  
  class BIT:
      def __init__(self, n):
          self.n = n
          self.data = [0]*(n+1)
          self.el = [0]*(n+1)
      def sum(self, i):
          s = 0
          while i > 0:
              s += self.data[i]
              i -= i & -i
          return s
      def add(self, i, x):
          # assert i > 0
          self.el[i] += x
          while i <= self.n:
              self.data[i] += x
              i += i & -i
      def get(self, i, j=None):
          if j is None:
              return self.el[i]
          return self.sum(j) - self.sum(i)

  bt=BIT(n+1)
  dc={}
  ans=[0]*q
  j=0
  for i in range(n):
    x=c[i]
    if x in dc:
      bt.add(dc[x],-1)
    bt.add(i+1,1)
    dc[x]=i+1
    while j<q and i+1==lri[j][1]:
      l,r,k=lri[j]
      ans[k]=bt.get(l-1,r)
      j+=1
    if j==q:break
  print(*ans,sep='\n')


if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())
### BUGGY CODE ###

def solve():
  while True:
    try:
      s1 = input()
      s2 = input()
      ans = 0
      def search(x,y,count):
        while  x < len(s1) and y < len(s2) and s1[x] == s2[y]:
          count += 1
          x += 1
          y += 1
        return count

      for i in range(len(s1)):
        for j in range(len(s2)):
          if s1[i] == s2[j]:
            ans = max(ans,search(i,j,0))
      print(ans)
    except EOFError:
      break
solve()


### FIXED CODE ###

while True:
    try:
        s1 = input()
    except EOFError:
        break
    s2 = input()
    BASE = 27
    MOD = 1000000007


    def rolling_hash(s):
        h_lst = [0]
        for c in s:
            h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
        return h_lst


    h_lst1 = rolling_hash(s1)
    h_lst2 = rolling_hash(s2)
    length1 = len(s1)
    length2 = len(s2)

    pow_mem = [pow(BASE, i, MOD) for i in range(min(length1, length2) + 1)]


    def check(center):
        hash_set = {(h_lst1[i + center] - h_lst1[i] * pow_mem[center]) % MOD for i in range(length1 - center + 1)}
        for i in range(length2 - center + 1):
            h2 = (h_lst2[i + center] - h_lst2[i] * pow_mem[center]) % MOD
            if h2 in hash_set:return True
        return False


    left = 0
    right = min(length1, length2)
    while right > left + 1:
        center = (left + right) // 2
        if check(center):
            left = center
        else:
            right = center
    print(right if check(right) else left)
### BUGGY CODE ###

n = int(input())

cnt = 0
k = []
for i in range(1, n + 1):
    x = 1
    while x ** 2 < n:
        y = 1
        while x ** 2 + y ** 2 < n:
            z = 1
            while x ** 2 + y ** 2 + z ** 2 < n:
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
                    p = [x, y, z]
                    p = sorted(p)
                    s = set(p)

                    if p in k:
                        z += 1
                        continue
                    # print(x, y, z)
                    k.append(p)
                    if len(s) == 1:
                        cnt += 1
                    elif len(s) == 2:
                        cnt += 3
                    else:
                        cnt += 6

                z += 1
            y += 1
        x += 1
    print(cnt)
    cnt = 0
# print(k)

### FIXED CODE ###

n = int(input())
ans = [0] * n
cnt = 0
k = []
x = 1
while x ** 2 < n:
    y = 1
    s_x = x ** 2
    while y ** 2 < n:
        z = 1
        s_y = y ** 2
        while z ** 2 < n:
            ans_tmp = s_x + s_y + z ** 2 + x * y + y * z + z * x
            if ans_tmp <= n:
                ans[ans_tmp - 1] += 1
            cnt += 1
            z += 1
        y += 1
    x += 1

for i in range(n):
    print(ans[i])
### BUGGY CODE ###

from collections import deque
 
N = int(input())
P = list(map(int,input().split()))
 
MAP = [[min(i, j, N-i-1, N-j-1) for i in range(N)] for j in range(N)]
 
d = [[1 for i in range(N)] for j in range(N)]
 
tx = [1, 0, -1, 0]
ty = [0, 1, 0, -1]
 
ans = 0

q = deque()
 
for p in P:
    x = (p-1) // N
    y = (p-1) % N
    d[x][y] = 0
    
    ans += MAP[x][y]
    
    q.clear()
    
    q.append((x, y))
    
    while len(q) != 0:
        x, y = q.popleft()
        for i in range(4):
            nx = x + tx[i]
            ny = y + ty[i]
            if 0 <= nx < N and 0 <= ny < N and MAP[nx][ny] > MAP[x][y] + d[x][y]:
                MAP[nx][ny] = MAP[x][y] + d[x][y]
                q.append((nx, ny))
 
print(ans)

### FIXED CODE ###

from collections import deque

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

MAP = [min(i, j, N-i-1, N-j-1) for i in range(N) for j in range(N)]

d = [1] * (N ** 2)

ans = 0

def update(np, p):
    if MAP[np] > MAP[p] + d[p]:
        q.append(np)
        MAP[np] = MAP[p] + d[p]

for p in P:
    p -= 1
    
    d[p] = 0
    
    ans += MAP[p]
    
    q = deque()
    
    q.append(p)
    
    while len(q) != 0:
        p = q.popleft()
        if p % N != N-1:
            update(p+1, p)
        if p % N != 0:
            update(p-1, p)
        if p // N != N-1:
            update(p+N, p)
        if p // N != 0:
            update(p-N, p)

print(ans)
### BUGGY CODE ###

import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())

ss=sorted(s)
t=0
c=1
count=[]
for i in range(1,n):
    if i==n-1:
        if ss[t]==ss[i]:
            count.append(c+1)
        else:
            count.append(c)
            count.append(1)
    else:
        if ss[t]==ss[i]:
            c+=1
        else:
            t=i
            count.append(c)
            c=1
u=0
for i in count:
    if i==max(count):
        print(ss[u])
    u+=i


### FIXED CODE ###

n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i
### BUGGY CODE ###

N = int(input())
S = [sorted(input()) for i in range(N)]
c = 0
for i in range(N):
    for j in range(N-i-1):
        if S[i] == S[i+j+1]:
            c+=1
print(c)


### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
existed = {}
c = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))

  if sorted_s in existed:
    c += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(c)
### BUGGY CODE ###

# 813~
# 解法 826
# 各数字について，２進数に直したときの各桁の値を計算する．(桁数＊(0,1))の形を持ったリストに対して,各桁数ごとの値で
# 足し合わせていく．各桁ごとに(0,1)の要素数をかけ合わせて，最後に足し合わせれば答えになる
# 計算量は　O(N*60)くらい

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

Large = 10**9 + 7
BA = [[0,0] for _ in range(60)] # <2^60なので
for a in A:
    a = a + pow(2,60)
    a_bin = bin(a)
    for i,ab in enumerate(a_bin[::-1][:-3]): # 最初の'0x'みたいなのを取り除く，あと最初につけた'1'を除く
        ab = int(ab)
        BA[i][ab] += 1
ans = 0
for i,ba in enumerate(BA):
    ans += ba[0] * ba[1] * pow(2,i,Large)
    ans %= Large

print(ans)







### FIXED CODE ###

##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = int((A&1).sum())
    ans += sum1*(N-sum1) * 2**i
    #ans %= Large
    A>>=1 # A = A>>1とする
print(ans%Large)
### BUGGY CODE ###

n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]

import numpy as np

a=np.array(h)
b=[[0 for i in range(n)] for j in range(n)]
b=np.array(b)

for j in range(n):
    for i in range(n):
        if j>i:
            b[j][i]=abs(a[j]-a[i])
#print(b)

dp=[int(0) for i in range(n)]
dp0=[[1000000000000000 for i in range(n)] for j in range(n)]

dp0[0]=0
dp[0]=0

dp0[1]=b[1][0]
dp[1]=dp0[1]

if k==1:
    for i in range(2,n):
        dp[i]=dp[i-1]+b[i][i-1]
    
if k > 1:
    for j in range(2,n):
        if j <=k:
            for i in range(j):
                dp0[j][i]=dp[i]+b[j][i]
            dp[j]=min(dp0[j])
        else:
            for i in range(k):
                dp0[j][i+j-k]=dp[i+j-k]+b[j][i+j-k]
            dp[j]=min(dp0[j])

#print(dp0)
print(dp[n-1])

### FIXED CODE ###

n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
#print(n,k,h)
dp=[float('inf') for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])

if k > 1 and n > 2:
  for y in range(2,k):
    dp[y]=abs(h[y]-h[0])
    x=1
    while x < k:
      tmp=dp[x]+abs(h[y]-h[x])
      if tmp < dp[y]:
        dp[y]=tmp
      x+=1
  for y in range(k,n):    
    dp[y]=dp[y-1]+abs(h[y]-h[y-1])
    for x in range(2,k+1):
      tmp=dp[y-x]+abs(h[y]-h[y-x])
      if tmp < dp[y]:
        dp[y]=tmp
        
if k == 1 and n > 2:
  for y in range(2,n):
    dp[y]=dp[y-1]+abs(h[y]-h[y-1])

print(dp[-1])
### BUGGY CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*50+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+2):
        for k in range(50*50+1):
            if k>= x[i]:
                dp[i+1][j][k] = dp[i][j-1][k-x[i]] + dp[i][j][k]
            elif k<x[i]:
                dp[i+1][j][k] = dp[i][j][k]
for k in range(50*50+1):
    for j in range(1,n+1):
        if a*j == k:
            ans += dp[n][j][k]
print(ans)

### FIXED CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+2):
        for k in range(x_max*n+1):
            if k>= x[i]:
                dp[i+1][j][k] = dp[i][j-1][k-x[i]] + dp[i][j][k]
            else:
                dp[i+1][j][k] = dp[i][j][k]
            
for k in range(x_max*n+1):
    for j in range(1,n+1):
        if a*j == k:
            ans += dp[n][j][k]
print(ans)
### BUGGY CODE ###

X, N = input().split()
X = int(X)
N = int(N)

if N == 0:
    print(X)
    exit()

P = input().split()
for i in range(len(P)):
    P[i] = int(P[i])

if X not in P:
    print(X)
    exit()

flag_p = True
flag_n = True

abs_num = 0
abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False

    if(flag_p == True & flag_n == True):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_p == True & flag_n == False):
        print(abs_num_n)
        break;
    elif(flag_p == False):
        print(abs_num_p)
        break;


### FIXED CODE ###

X, N = input().split()
X = int(X)
N = int(N)

if N == 0:
    print(X)
    exit()

P = input().split()
for i in range(len(P)):
    P[i] = int(P[i])

if X not in P:
    print(X)
    exit()


abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False
    if(  flag_p == True  and flag_n == True ):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_p == True  and flag_n == False):
        print(abs_num_n)
        break;
    elif(flag_p == False and flag_n == True ):
        print(abs_num_p)
        break;
    elif(flag_p == False and flag_n == False):
        print(abs_num_n)
        break;

    i += 1
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    r = reduce(math.gcd, numbers)
    return r

def main():
    K = int(input())
    l = []
    for i in range(1, K+1, 1):
        for j in range(1, K+1, 1):
            for k in range(1, K+1, 1):
                g = gcd(i, j, k)
                l.append(g)            
    print(sum(l))
main()

### FIXED CODE ###

from math import gcd
 
k=int(input())
 
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1, k+1):
      ans+=gcd(gcd(i,j),l)
 
print(ans)
### BUGGY CODE ###

import numpy as np

def main():
    n,k,q = [int(x) for x in input().split()]
    life = [k]*n
    a = []
    for i in range(q):
        a.append(int(input()))

    life = np.array(life)
    for i in range(q):
        temp = [1]*n
        temp[a[i]-1] = 0
        life -= temp

    for i in range(n):
        if life[i] <= 0:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    main()


### FIXED CODE ###

import collections

def main():
    n,k,q = [int(x) for x in input().split()]
    a = []
    for i in range(q):
        a.append(int(input()))

    c = collections.Counter(a)

    for i in range(n):
        index = int('{}'.format(i+1))
        point = k + c[index] - q
        if point > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush
import numpy as np


def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k >= 2:
        dp = np.zeros(N+1, dtype=int)
        for w in range(1,N+1):
            dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
        N = dp[-1]
        return N
        
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        if (N//X[1][0]+1)*(N//X[0][0]+1) <= 10**6 :
            return max(X[0][1]*i + max(X[1][1]*j + X[2][1]*((N-i*X[0][0]-j*X[1][0])//X[2][0]) + ((N-i*X[0][0]-j*X[1][0])%X[2][0]) for j in range((N-i*X[0][0])//X[1][0]+1)) for i in range(N//X[0][0]+1))
        else:
            import numpy as np
            dp = np.zeros(N+1, dtype=int)
            for w in range(1,N+1):
                dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
            N = dp[-1]
            return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

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

all_add = 0
for i in range(M):
    bj, cj = map(int, input().split())
    A.extend([cj]*bj)
    all_add += bj

A.sort()

print(sum(A[all_add:]))

### FIXED CODE ###

import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

k = 0
judge = 0
for i in range(M):
    if k+b[i]-1 < N:
        if A[k+b[i]-1] < c[i]:
            A[k:k+b[i]] = [c[i]] * b[i]
            k += b[i]
        else:
            for j in range(b[i]):
                if k < N:
                    if A[k] < c[i]:
                        A[k] = c[i]
                        k += 1
                    else:
                        judge = 1
                        break
            if judge == 1:
                break
    elif k < N:
        for j in range(b[i]):
            if k < N:
                if A[k] < c[i]:
                    A[k] = c[i]
                    k += 1
                else:
                    judge = 1
                    break
        if judge == 1:
            break
    else:
        break

print(sum(A))
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
L = list(map(int, input().split()))
L.sort()
# a,b,cの順序に大きいとして、6倍…はしなくていいのか。組み合わせらしい
# a-c<b<a+c
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        p = L[i]
        q = L[j]
        hidari = max(i + 1, bisect_left(L, q - p + 1))
        migi = min(j - 1, bisect_right(L, p + q - 1))
        delta = migi - hidari
        if delta >= 0:
            cnt += delta + 1
print(cnt)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
L = list(map(int, input().split()))
L.sort()
# a,b,cの順序に大きいとして、6倍…はしなくていいのか。組み合わせらしい
# a-c<b<a+c
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        p = L[i]
        q = L[j]
        hidari = max(i + 1, bisect_left(L, q - p + 1))
        migi = min(j - 1, bisect_right(L, p + q - 1))
        delta = migi - hidari
        if delta >= 0:
            cnt += delta + 1
print(cnt)
### BUGGY CODE ###

N = input()
A = list(input().split())
num = 1
for i in A:
  if 0 in A:
    break
  num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
newA = sorted(A,reverse=True)
num = 1
if 0 in A:
  num = 0
else:
  for i in newA:
    if num > 1000000000000000000:
      break
    num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from itertools import accumulate

n, x = map(int, input().split())
BLU = [list(map(int, input().split())) for _ in range(n)]
B, L, U = zip(*BLU)
S = [b*l+(x-b)*u for b, l, u in BLU]
sortedS = sorted([(s, i) for i, s in enumerate(S)], reverse=True)
S, idx = zip(*sortedS)
B = [B[i] for i in idx]
L = [L[i] for i in idx]
U = [U[i] for i in idx]
M = sum([b*l for b, l, u in BLU])
A = list(accumulate(S))

def select(q, r):
  f = A[q]
  for i in range(n):
    temp = f - S[min(i, q)]
    temp += L[i]*min(B[i], r) + U[i]*max(r-B[i], 0)
    if temp>=M:
      return True
  return False

ng = -1
ok = sum(B)
while ok-ng > 1:
  mid = (ok+ng)//2
  q, r = divmod(mid, x)
  if select(q, r):
    ok = mid
  else:
    ng = mid
print(ok)

### FIXED CODE ###

"""

重要度はlかuしかとらないと考えてよい
高橋君のほうが青木君より低い点数を取ると決めた科目に対してはl、それ以外はuと定める
それぞれのテストの点数の差をdとして、Σ[a>=b](d*u) - Σ[a<b](d*l) >= 0 を満たす
最小のΣaを求める
→各iについて、biまではli個ずつ減らすことができ、それより多く減らす場合はXを超えない範囲で
 ui個ずつ減らすことができる
→heapqでできそう
 単純なheapqだと、例えば一つのテストの中でlとuの値の差がとても大きい時に
 正しい答えが出せない
→二分探索

"""
import sys
input = sys.stdin.readline

n, x = map(int, input().split())
BLU = [list(map(int, input().split())) for _ in range(n)]
SBLU = sorted([(b*l+(x-b)*u, b, l, u) for b, l, u in BLU], reverse=True)
S, B, L, U = zip(*SBLU)
M = sum([b*l for b, l, u in BLU])

def select(q, r):
  f = sum(S[:q+1])
  for i in range(n):
    temp = f - S[min(i, q)]
    temp += L[i]*min(B[i], r) + U[i]*max(r-B[i], 0)
    if temp>=M:
      return True
  return False


ng = -1
ok = sum(B)
while ok-ng > 1:
  mid = (ok+ng)//2
  q, r = divmod(mid, x)
  if select(q, r):
    ok = mid
  else:
    ng = mid
print(ok)
### BUGGY CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
    for i in range(r):
        ret *= pow(i+1, MOD-2, MOD)

    return ret % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret %= MOD
    for i in range(r):
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD

    return ret % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)