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

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

def match(v,w):
    if(v != '?' and w != '?' and v != w):
        return 0
    else:
        return 1

def middle(x,y,z):
    X = [x,y,z]
    X.sort()
    return(X[1])


def milen(a,b,c):
    aa = len(a)
    bb = len(b)
    cc = len(c)

    minlen = aa + bb + cc
    s = '?'*(bb+cc) + a + '?'*(bb+cc)
    for i in range(-bb-cc,aa+cc+1):
        t = '?'*(bb+cc+i) + b + '?'*(aa+cc-i)
        for j in range(-bb-cc,aa+bb+1):
            u = '?'*(bb+cc+j) + c + '?'*(aa+bb-j)
            flag = 1
            for k in range(middle(0,i,j)+bb+cc,middle(aa,i+bb,j+cc)+bb+cc):
                if(match(s[k],u[k]) == 0):
                    flag = 0
                    break
                if(match(t[k],u[k]) == 0):
                    flag = 0
                    break
                if(match(s[k],t[k]) == 0):
                    flag = 0
                    break
            if(flag == 1):
                sta = min(0,i,j)
                en = max(aa,i+bb,j+cc)
                minlen = min(minlen,en-sta)
    return minlen

print(milen(A,B,C))

### FIXED CODE ###

a = input()
b = input()
c = input()

aa = len(a)
bb = len(b)
cc = len(c)

lensum = aa + bb + cc # 文字列の長さの最大値
ab = [0]*(lensum+cc+1) # 相対的位置に対して合わさるかどうかを記録
ac = [0]*(lensum+bb+1)
bc = [0]*(lensum+aa+1)

def match(v,w): # 2つの文字を合わせられるかどうかを調べる
    if(v != '?' and w != '?' and v != w):
        return 0
    else:
        return 1

def match2(A,B,k): # 2つの文字列とその相対的位置に対して合わさるかチェック
    AA = len(A)
    BB = len(B)
    if(k>=AA):
        return 1
    elif(k<-BB):
        return 1
    else:
        flg = 1
        st = max(0,k)
        la = min(AA,BB+k)
        for i in range(st,la):
            if(match(A[i],B[i-k])==0):
                flg = 0
                break
        return flg

#ab,ac,bcに対して計算する
for i in range(lensum+cc+1):
    ab[i] = match2(a,b,i-bb-cc)
for i in range(lensum+bb+1):
    ac[i] = match2(a,c,i-bb-cc)
for i in range(lensum+aa+1):
    bc[i] = match2(b,c,i-aa-cc)

def milen(a,b,c):
    minlen = lensum # 文字列の長さの最大値
    for i in range(-bb-cc,aa+cc+1): # iが文字列Bの開始位置
        for j in range(-bb-cc,aa+bb+1): # jが文字列Cの開始位置
            if(ab[i+bb+cc] == 0): 
                continue
            elif(ac[j+bb+cc] == 0):
                continue
            elif(j-i+aa+cc < 0 or j-i+aa+cc >= lensum+aa+1): #BとCが離れすぎている場合を除く
                continue  
            elif(bc[j-i+aa+cc] == 0):
                continue   
            else:
                sta = min(0,i,j) #文字列の中で一番左にある開始位置
                en = max(aa,i+bb,j+cc) #文字列の中で一番右にある終了位置
                minlen = min(minlen,en-sta) #更新
    return minlen

print(milen(a,b,c))
### BUGGY CODE ###

N,K = map(int,input().split())
h = [int(i) for i in input().split()]
dp = [10**10 for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    for k in range(1,K+1):
        if i+k < N:
            dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k]-h[i]))
print(dp[-1])

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
h = np.array([int(i) for i in input().split()])
dp = np.full(N,10**10,dtype=int)
dp[0] = 0
for i in range(1,N):
    dp[i:i+K] = np.fmin(dp[i:i+K], dp[i-1] + np.abs(h[i:i+K] - h[i-1]))
        
print(dp[-1])
### BUGGY CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k=LI()
h=LI()
dp=[float("INF") for i in range(n)]
dp[0]=0
for i in range(1,n):
    for j in range(1,min(i,k)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])

### FIXED CODE ###

import numpy as np
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k=IL()
h=np.array(IL())
dp=np.full(n,pow(10,6),dtype=int)
dp[0]=0
for i in range(1,n):
    t=i-min(i,k)
    dp[i]=np.min(dp[t:i]+abs(h[t:i]-h[i]))
print(dp[n-1])
### BUGGY CODE ###

s = input()
x, y = map(int, input().split())
x += 8500
y += 8500

dpx = [0 for i in range(17000)]
dpy = [0 for i in range(17000)]

dpx[8500] = 1
dpy[8500] = 1

f = s.split("T")

fx = []
fy = []

for i, fi in enumerate(f):
    if i % 2:
        fy.append(len(fi))
    else:
        fx.append(len(fi))

for i, fxi in enumerate(fx):
    nex = [0] * 17000
    for j in range(17000):
        if dpx[j]:
            if fxi + j < 17000:
                nex[fxi + j] = 1
            if i > 0 and j - fxi >= 0:
                nex[j - fxi] = 1
    dpx = nex[:]
        
for fyi in fy:
    nex = [0] * 17000
    for j in range(17000):
        if dpy[j]:
            if fyi + j < 17000:
                nex[fyi + j] = 1
            if j - fyi >= 0:
                nex[j - fyi] = 1
    dpy = nex[:]

if dpx[x] and dpy[y]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
x += 8500
y += 8500

dpx = [0 for i in range(17000)]
dpy = [0 for i in range(17000)]

dpx[8500] = 1
dpy[8500] = 1

f = s.split("T")

fx = []
fy = []

for i, fi in enumerate(f):
    if i % 2:
        fy.append(len(fi))
    else:
        fx.append(len(fi))

for i, fxi in enumerate(fx):
    nex = [0] * 17000
    for j in range(17000):
        if dpx[j]:
            if fxi + j < 17000:
                nex[fxi + j] = 1
            if i > 0 and j - fxi >= 0:
                nex[j - fxi] = 1
    dpx = nex[:]
        
for fyi in fy:
    nex = [0] * 17000
    for j in range(17000):
        if dpy[j]:
            if fyi + j < 17000:
                nex[fyi + j] = 1
            if j - fyi >= 0:
                nex[j - fyi] = 1
    dpy = nex[:]

if dpx[x] and dpy[y]:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

# Contest: AtCoder Beginner Contest 152 (https://atcoder.jp/contests/abc152)
# Problem: E: Flatten (https://atcoder.jp/contests/abc152/tasks/abc152_e)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


from fractions import gcd
from functools import reduce
def lcm(a, b):
    return a * b // gcd(a, b)
n = rint()
a = rints()
l = reduce(lcm, a)
m = 10**9 + 7
print(sum(l // ai % m for ai in a) % m)


### FIXED CODE ###

# Contest: AtCoder Beginner Contest 152 (https://atcoder.jp/contests/abc152)
# Problem: E: Flatten (https://atcoder.jp/contests/abc152/tasks/abc152_e)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


from fractions import gcd
from functools import reduce
m = 10**9 + 7
def inv(a):
    return pow(a, m - 2, m)
def mod_lcm(a, b):
    return a * b // gcd(a, b)
n = rint()
a = rints()
l = reduce(mod_lcm, a) % m
print(sum(l * inv(ai) % m for ai in a) % m)
### BUGGY CODE ###

#-----------------------------------
#リストera_list[n]を返す
#0～ｎの各インデックスが素数であれば1、そうでなければ0
#ex：eratosthenes(10)
#　　→ [0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0]
#-----------------------------------

def eratosthenes(n):
  era_list = [1] * (n + 1)
  era_list[0] = 0; era_list[1] = 0
  
  for i in range(2,n+1):
    if era_list[i] == 0:
      continue
    else:
      j = i + i
      while j <= n:
        era_list[j] = 0
        j += i
        
  return era_list

Q = int(input())
PN = eratosthenes(100001)
TF = [0] * 100001

for i in range(1,100001,2):
  if PN[i] == 1 and PN[int((i+1)/2)] == 1:
    TF[i] = 1
    
for j in range(1,Q+1):
  l,r = map(int, input().split())
  Ans = sum(TF[:r+1]) - sum(TF[:l])
  print(Ans)

### FIXED CODE ###

#-----------------------------------
#リストera_list[n]を返す
#0～ｎの各インデックスが素数であれば1、そうでなければ0
#ex：eratosthenes(10)
#　　→ [0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0]
#-----------------------------------

def eratosthenes(n):
  era_list = [1] * (n + 1)
  era_list[0] = 0; era_list[1] = 0
  
  for i in range(2,n+1):
    if era_list[i] == 0:
      continue
    else:
      j = i + i
      while j <= n:
        era_list[j] = 0
        j += i
        
  return era_list

Q = int(input())
PN = eratosthenes(100001)
TF = [0] * 100001

for i in range(1,100001,2):
  if PN[i] == 1 and PN[int((i+1)/2)] == 1:
    TF[i] = 1 + TF[i-2]
  else:
    TF[i] = TF[i-2]
    
for j in range(1,Q+1):
  l,r = map(int, input().split())
  Ans = TF[r] - TF[l-2]
  print(Ans)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
icount = 0
for i in range(n):
    pi = li[i]
    for i in range(i + 1):
        if pi > li[i]:
            break
    if pi <= li[i]:
        icount += 1
print(icount)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 1
min_p = p[0]
for i in range(n):
    if min_p > p[i]:
        count += 1
        min_p = p[i]
print(count)
### BUGGY CODE ###

# vim: set fileencoding=utf-8:
import bisect


def main():
    N, K = map(int, raw_input().split())
    x = [int(ele) for ele in raw_input().split()]
    o = bisect.bisect_right(x, 0)

    zenpou = x
    kouhou = x
    if N <= o + K:  # ただし、もしo+Kやo-Kが超過していたら？
        zenpou = zenpou[::-1][0:K][::-1]
    else:
        zenpou = zenpou[o:o + K]

    if o - K <= 0:
        kouhou = kouhou[0:K]
    else:
        kouhou = kouhou[o - K:o]

    x = list(set(kouhou + zenpou))
    x.sort()

    best = 999999999999
    u = len(x)
    for i in range(u):
        if u < i + K:
            break

        hani = x[i:i + K]
        if hani[0] < 0 and hani[-1] < 0:
            best = min(best, abs(hani[0]))
        elif hani[0] < 0 <= hani[-1]:
            best = min(best, 2 * abs(hani[0]) + hani[-1])
        elif 0 <= hani[0] and 0 <= hani[-1]:
            best = min(best, hani[-1])

    print(best)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# vim: set fileencoding=utf-8:
import bisect


def main():
    N, K = map(int, raw_input().split())
    x = [int(ele) for ele in raw_input().split()]
    o = bisect.bisect_right(x, 0)
    top = min(o + K, N)
    bottom = max(o - K, 0)
    best = 999999999999
    for i in xrange(K):
        if top < bottom + i + K:
            break

        if x[bottom + i + K - 1] < 0:
            best = min(best, abs(x[bottom + i]))
        elif x[bottom + i] < 0 <= x[bottom + i + K - 1]:
            ans1 = 2 * min(abs(x[bottom + i]), x[bottom + i + K - 1])
            ans2 = max(abs(x[bottom + i]), x[bottom + i + K - 1])
            ans = min(best, ans1 + ans2)
            best = min(best, ans)
        elif 0 <= x[bottom + i]:
            best = min(best, x[bottom + i + K - 1])

    print(best)


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

def resolve():
    a, b = map(int, input().split())
    d = []
    for i in range(2, min(a, b) + 1):
        if a % i == 0 and b % i == 0 and all([i % di != 0 for di in d]):
            d.append(i)
    d.append(1)
    print(len(d))


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    a, b = map(int, input().split())
    div_a = set(prime_factorize(a))
    div_b = set(prime_factorize(b))
    print(len(div_a & div_b) + 1)
    # print(div_a)
    # print(div_b)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

s=input()
N=int(input())
D={}

for i in range(1,len(s)+1):
    for j in range(len(s)):
        if D.get(s[j:j+i],None) == None:
            D[s[j:j+i]]=1
D=sorted(D)
print(D[N-1])

### FIXED CODE ###

s=input()
N=int(input())
#s="atcoderandatcodeera"
#N=5
D={}

if(len(s)<=1):
    for i in range(1,len(s)+1):
        for j in range(len(s)):
            if D.get(s[j:j+i],None) == None:
                D[s[j:j+i]]=1
    D=sorted(D)
    print(D[N-1])
    exit()
else:
    t=sorted(s)
    i=0
    k=0
    for c in t:
        if(c!=k):
            i=0
            if(len(D)>=5):
                break
        k=c
        while(i<len(s)):
            if(s[i]==c):
                break
            i+=1
        j=i+1
        while(j<=min(len(s),i+5)):
            D[s[i:j]]=1
            j+=1
        i+=1
    
    D=sorted(D)
    print(D[N-1])
    exit()
### BUGGY CODE ###

import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
tree = [a[0]]

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    bisect.insort(tree, a)
  else:
    tree[index-1] = a
print(len(tree))

    


    
    

### FIXED CODE ###

import bisect
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
tree = deque([]) 
tree.append(a[0])

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    tree.appendleft(a)
  else:
    tree[index-1] = a
print(len(tree))
### BUGGY CODE ###

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

L = sorted(L)
ans = 0
H = {}
for i in range(N-1):
    for j in range(i+1, N):
        H.update({(i,j): L[i]+L[j]})


for h, v in H.items():
    for j in range(h[1]+1, N):
        if v <= L[j]:
            break
        ans += 1

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(len(L)):
    for j in range(i+1, len(L)):
        b_i = bisect.bisect_left(L, L[i]+L[j]) # a+bより小さい数
        ans += b_i - (j+1)
print(ans)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(list(input()))
    s[i].sort()
sa = []
for i in range(n):
    s[i].sort()
    tmp = ''
    for j in range(10):
        tmp += s[i][j]
    sa.append(tmp)
count = 0
for i in range(n-1):
    k = 1
    while i+k <= n-1:
        if sa[i] == sa[i+k]:
            count += 1
        k += 1
print(count)

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
ss = [''.join(sorted(s_tmp)) for s_tmp in s]
ss.sort()
count = 1
ans = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        count += 1
    else:
        ans += int((count*(count-1))/2)
        count = 1
ans += int((count*(count-1))/2)
print(ans)
### BUGGY CODE ###

from collections import deque

N,Q=map(int,input().split())
out=[set() for i in range(N+1)];out[0]=None # 頂点は1-initial
for j in range(N-1):
    a,b=map(int,input().split())
    out[a].add(b)
    out[b].add(a)
# print(out) #DB

a=[0 for i in range(N+1)];a[0]=None

for k in range(Q):
    p,x=map(int,input().split())
    a[p]+=x

# print(a) #DB
r=[False for i in range(N+1)];r[0]=None
q=deque()
q.append(1);r[1]=True
while q:
    u=q.popleft()
    for v in out[u]:
        if not r[v]:
            a[v]+=a[u]
            q.append(v)
            r[v]=True
            # print(q) #DB

print(*a[1:])

### FIXED CODE ###

from collections import deque

N,Q=map(int,input().split())
out=[set() for i in range(N+1)];out[0]=None # 頂点は1-initial
for j in range(N-1):
    a,b=map(int,input().split())
    out[a].add(b)
    out[b].add(a)
# print(out) #DB

a=[0 for i in range(N+1)];a[0]=None

for k in range(Q):
    p,x=map(int,input().split())
    a[p]+=x

# print(a) #DB

q=deque()
q.append(1)
while q:
    u=q.popleft()
    for v in out[u]:
        a[v]+=a[u]
        q.append(v)
        out[v].remove(u)
        # print(q) #DB
    out[u].clear()

print(*a[1:])
### BUGGY CODE ###

N = int(input())
H = [int(e) for e in input().split()]
count_max = 0
for i in range(N):
  count = 0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      count += 1
    else:
      i += j + 1
      break;

  if count_max < count:
    count_max = count
  if count_max > N / 2:
    break;

print(count_max)

### FIXED CODE ###

N = int(input())
H = [int(e) for e in input().split()]
count_max = 0
i = 0
while i < N:
  judge = True
  count = 0
  tmp = i
  for j in range(tmp,N):
    if j < N-1:
      if H[j] >= H[j+1]:
        count += 1
      else:
        break;

  #print(count)
  if count_max < count:
    count_max = count
  if judge == True:
    i += count + 1

print(count_max)
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
found = False
for l in range(N//2, 0, -1):
    for i in range(N-(2*l)+1):
        target = S[i:i+l]
        if target in S[i+l:]:
            ans = l
            found = True
        if found: break
    if found: break
print(ans)

### FIXED CODE ###

def z_algo(S):
    '''
    Input: a string S
    Output: an array Z[0..|S| - 1]
            Z[i] = l: the length of the longest prefix of S[i..|S| - 1] which is also a prefix of S,
            i.e.,
                S[j] = S[i + j] for all 0 <= j < l (l != 0),
                S[0] != S[i] (l == 0)
    Time complexity: O(|S|) time
    '''
    N = len(S)
    Z = [-1] * N
    Z[0] = N
    L = 0; R = 0 # algorithm invariant: S[L..R] is always set to be the longest common prefix of S[L..|S| - 1]
    for i in range(1, N):
        if i > R: # naive calculation
            j = 0
            while i + j < N and S[j] == S[i + j]: j += 1
            Z[i] = j
            if j > 0: L = i; R = i + j - 1
        else: # i in [L, R]
            k = i - L
            if Z[k] < R - i + 1: Z[i] = Z[k]
            else:
                L = i
                while R < N and S[R - L] == S[R]: R += 1
                Z[i] = R - L
                R -= 1
    return Z

N = int(input())
S = input()
ans = 0
for i in range(N-1):
    Z = z_algo(S[i:])
    for j, z in enumerate(Z):
        ans = max(ans, min(z, j))
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0,2,5,5,4,5,6,3,7,6]
ab = {}
for i in a:
    ab[i] = b[i]
dp = [0]*(n+10)
dp[0] = ""
for i in range(n+1):
    if dp[i] == 0:
        continue
    for j in ab.keys():
        try:
            dp[i+ab[j]] = str(max(int(dp[i+ab[j]]),int(dp[i]+str(j)),int(str(j)+dp[i])))
        except:
            dp[i+ab[j]] = str(max(int(dp[i+ab[j]]),j))
print(dp[n])

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0,2,5,5,4,5,6,3,7,6]
ab = {}
for i in a:
    ab[i] = b[i]
dp = [0]*(n+10)
dp[0] = ""
for i in range(n+1):
    if dp[i] == 0:
        continue
    for j in ab.keys():
        if dp[i] == "":
            dp[i+ab[j]] = str(max(int(dp[i+ab[j]]),j))
        else:
            if dp[i][0]> str(j):
                next0 = dp[i]+str(j)
            else:
                next0 = str(j)+dp[i]
            if dp[i+ab[j]] == 0:
                dp[i+ab[j]] = next0
                continue
            if len(next0) > len(dp[i+ab[j]]):
                dp[i+ab[j]] = next0
            elif len(next0) < len(dp[i+ab[j]]):
                continue
            else:
                for k in range(len(next0)):
                    if next0[k]> dp[i+ab[j]][k]:
                        dp[i+ab[j]] = next0
                        break
                    elif next0[k]< dp[i+ab[j]][k]:
                        break
                else:
                    dp[i+ab[j]] = next0

print(dp[n])
### BUGGY CODE ###

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

N, Ma, Mb = map(int, input().split())

d = []
for i in range(N):
    a, b, c = map(int, input().split())
    d.append((a, b, c))

# それぞれの薬品を購入するかしないかでbit全探索
can = False
min = -1
n = len(d)
for i in range(2**n):
    sum_a = 0
    sum_b = 0
    sum_c = 0
    for j in range(n):
        if (i >> j) & 1:
            sum_a += d[j][0]
            sum_b += d[j][1]
            sum_c += d[j][2]
    if sum_a > 0 and Ma*sum_b == Mb*sum_a:
        if min < 0 or sum_c < min:
            min = sum_c

print(min)



### FIXED CODE ###

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

N, Ma, Mb = map(int, input().split())

d = []
for i in range(N):
    a, b, c = map(int, input().split())
    d.append((a, b, c))

# 全探索だとTLEなのでDPを用いる

# dp[i][ca][cb] := i-1番目までの組み合わせでAがca,Bがcbとなるときの最小コスト

INF = float('inf')
g_max = 10 * N
dp = [[[INF for cb in range(g_max+1)] for ca in range(g_max+1)] for i in range(N+1)]

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

for i in range(N):
    for ca in range(g_max+1):
        for cb in range(g_max+1):
            if dp[i][ca][cb] == INF:
                continue
            a, b, c = d[i]
            # i番目の薬品を選ばない場合
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            # i番目の薬品を選ぶ場合
            dp[i+1][ca+a][cb+b] = min(dp[i+1][ca+a][cb+b], dp[i][ca][cb]+c)

ans = -1
for ca in range(g_max+1):
    for cb in range(g_max+1):
        c = dp[N][ca][cb]
        if c == INF:
            continue
        if ca*Mb == cb*Ma and c > 0:
            if ans < 0 or c < ans:
                ans = c

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

n = int(input())
a_list = [int(x) for x in input().split()]
b = []
for i, a in enumerate(a_list):
    if i % 2 == 0:
        b = b + [a]
    else:
        b = [a] + b       
if n % 2 == 1:
    b = list(reversed(b))
print(*b)

### FIXED CODE ###

from collections import deque
n = int(input())
a_list = [int(x) for x in input().split()]
left_flag = n % 2 == 1
d = deque()
for a in a_list:
    if left_flag:
        d.appendleft(a)
    else:
        d.append(a)
    left_flag = not left_flag
print(*d)
### BUGGY CODE ###

N, M = [int(i) for i in input().strip().split()]
A = [int(i) for i in input().strip().split()]
B = [0] * M
C = [0] * M
for i in range(M):
    B[i], C[i] = [int(i) for i in input().strip().split()]

for i in range(M):
    A.sort()
    for j in range(0, B[i]):
        if A[j] < C[i]:
            A[j] = C[i]
        else:
            break
print(sum(A))


### FIXED CODE ###

N, M = [int(i) for i in input().strip().split()]
A = [int(i) for i in input().strip().split()]
A.sort()

BC = [[0, 0] for _ in range(M)]
for j in range(M):
    BC[j][0], BC[j][1] = [int(i) for i in input().strip().split()]
BC.sort(key=lambda x: x[1])

res = 0
cnt = 0
i = N - 1
j = M - 1
while True:
    if cnt == N:
        break

    if j == -1:
        res += A[i]
        i -= 1
    elif A[i] > BC[j][1]:
        res += A[i]
        i -= 1
    elif A[i] <= BC[j][1]:
        res += BC[j][1]
        BC[j][0] -= 1
        if BC[j][0] == 0:
            j -= 1
    else:
        raise ValueError
    cnt += 1
print(res)
### BUGGY CODE ###

N, M = map(int, input().split())
li = {i+1 for i in range(N)}
# print(li)
box = []
for _ in range(M):
    l, r = map(int, input().split())
    # print(l, r)
    for i in li:
        # print(i)
        if l <= i and i <= r:
            box.append(i)
    li = list(set(li) & set(box))
    box.clear()
    # print(li)
print(len(li))


### FIXED CODE ###

N, M = map(int, input().split())
l, r = map(int, input().split())
for _ in range(M-1):
    new_l, new_r = map(int, input().split())
    if l < new_l:
        l = new_l
    if new_r < r:
        r = new_r

score = r-l+1
if score > 0:
    print(score)
else:
    print(0)
### BUGGY CODE ###

n = int(input())

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

for i in range(n):
  if i == 0:
    b = c[i]
  else:
    b = b*c[i]
if b>10**18:
  b = -1
print(b)

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
if min(a)==0:
    print(0)
else:
    s=1
    for i in range(len(a)):
       s=s*a[i]
       if s>10**18:
           print(-1)
           break
    else:
        print(s)