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

import sys
input = sys.stdin.readline

def solve():
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def addValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] += A
            iB += iB & -iB
    def getSum(iA):
        iB = iA + 1
        ans = 0
        while iB > 0:
            ans += data[iB]
            iB -= iB & -iB
        return ans
    def getRangeSum(iFr, iTo):
        return getSum(iTo) - getSum(iFr-1)

    N, Q = map(int, input().split())
    cs = list(map(lambda x: int(x)-1, input().split()))
    LRs = []
    Lss = [[] for _ in range(N)]
    for i in range(Q):
        L, R = map(int, input().split())
        L, R = L-1, R-1
        LRs.append((L, R))
        Lss[R].append((L, i))

    data, numPow2 = makeBIT(Q)

    anss = [0] * Q
    posRights = [-1] * N
    for R, c in enumerate(cs):
        if posRights[c] != -1:
            addValue(posRights[c], -1)
        addValue(R, 1)
        posRights[c] = R
        for L, i in Lss[R]:
            anss[i] = getRangeSum(L, R)

    print('\n'.join(map(str, anss)))


solve()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def solve():
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def addValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] += A
            iB += iB & -iB
    def getSum(iA):
        iB = iA + 1
        ans = 0
        while iB > 0:
            ans += data[iB]
            iB -= iB & -iB
        return ans
    def getRangeSum(iFr, iTo):
        return getSum(iTo) - getSum(iFr-1)

    N, Q = map(int, input().split())
    cs = list(map(lambda x: int(x)-1, input().split()))
    LRs = []
    Lss = [[] for _ in range(N)]
    for i in range(Q):
        L, R = map(int, input().split())
        L, R = L-1, R-1
        LRs.append((L, R))
        Lss[R].append((L, i))

    data, numPow2 = makeBIT(Q)

    anss = [0] * Q
    posRights = [-1] * N
    for R, c in enumerate(cs):
        if posRights[c] != -1:
            addValue(posRights[c], -1)
        addValue(R, 1)
        posRights[c] = R
        for L, i in Lss[R]:
            anss[i] = getRangeSum(L, R)

    print('\n'.join(map(str, anss)))


solve()
### BUGGY CODE ###

import math
def solve(n):
    def is_prime(x):
        if x <= 1:
            return False
        for i in range(2, int(math.sqrt(x))+1):
            if x % i == 0:
                return False
        return True

    lst_c = []
    for c in range(1,n): #c != n
        lst_c.append(n-c)

    lst_c2 = []
    prime_cnt = 0
    for i in range(len(lst_c)):
        if not(is_prime(lst_c[i])):
            lst_c2.append(lst_c[i])
        else:
            prime_cnt += 1
            
    #print(lst_c)

    cnt = 0
    cnt2 = 0
    for i in range(len(lst_c2)):
        if lst_c2[i] != 1:
            for j in range(1,int(lst_c2[i]**0.5)+1):
                if lst_c2[i]%j ==0:
                    cnt += 1
                    if lst_c2[i]/j == j:
                        cnt2 +=1
            lst_c2[i] = cnt
            cnt = 0
            #cnt2 = 0
    return sum(lst_c2)*2-cnt2 + 2*prime_cnt -1
    
n = int(input())
print(solve(n))
#print(lst_c)

### FIXED CODE ###

def func(x):
    ans = 0
    for a in range(1, n):
        for b in range(1, n):
            c = n - a * b
            if c <= 0:
                break
            ans += 1
    return ans

n = int(input())
print(func(n))
### BUGGY CODE ###

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

ans = 0

for x in range(n + 1):
  new = (a * x) // b - a * (x // b)
  if new > ans:
    ans = new

print(ans)



### FIXED CODE ###

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

if b <= n:
  if n != 1:
    n = b - 1

ans1 = math.floor((a * n) / b)
ans2 = a * math.floor(n / b)
ans3 = ans1 - ans2

print(ans3)
### BUGGY CODE ###

H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[[0,0] for _ in range(W)] for _ in range(H)]
for i in range(H):
    cur = 0
    cnt = 0
    for j in range(W):
        if S[i][j]=="#":
            A[i][j-1][0] = cnt
            cur = j+1
            cnt = 0
        else:
            cnt += 1
        A[i][W-1][0] = cnt
for i in range(H):
    for j in range(W-1,-1,-1):
        if A[i][j][0]>0:
            cnt = A[i][j][0]
        else:
            if S[i][j]!="#":
                A[i][j][0] = cnt
            else:
                cnt = 0
for j in range(W):
    cur = 0
    cnt = 0
    for i in range(H):
        if S[i][j]=="#":
            A[i-1][j][1] = cnt
            cur = i+1
            cnt = 0
        else:
            cnt += 1
    A[H-1][j][1] = cnt
for j in range(W):
    for i in range(H-1,-1,-1):
        if A[i][j][1]>0:
            cnt = A[i][j][1]
        else:
            if S[i][j]!="#":
                A[i][j][1] = cnt
            else:
                cnt = 0
cmax = 0
for i in range(H):
    for j in range(W):
        cmax = max(cmax,sum(A[i][j]))
print(cmax-1)

### FIXED CODE ###

H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if j==0 and S[i][j]==".":
            L[i][j] = 1
        elif j>0 and S[i][j]==".":
            L[i][j] = L[i][j-1]+1
        if i==0 and S[i][j]==".":
            U[i][j] = 1
        elif i>0 and S[i][j]==".":
            U[i][j] = U[i-1][j]+1
for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if j==W-1 and S[i][j]==".":
            R[i][j] = 1
        elif j<W-1 and S[i][j]==".":
            R[i][j] = R[i][j+1]+1
        if i==H-1 and S[i][j]==".":
            D[i][j] = 1
        elif i>0 and S[i][j]==".":
            D[i][j] = D[i+1][j]+1
cmax = 0
for i in range(H):
    for j in range(W):
        cmax = max(cmax,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(cmax)
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

h,w,k = map(int, input().split())
x1,y1,x2,y2 = map(lambda x: int(x)-1, input().split())
s = [None]*h
for i in range(h):
    s[i] = input()
    
from heapq import heappop as hpp, heappush as hp
q = []
hp(q, (0,x1,y1,(0,0),0))

dx = [0,1,0,-1]
dy = [1,0,-1,0]
dist = [[None]*w for _ in range(h)]
dist[x1][y1] = 0

while q:
    d, x, y, t, td = hpp(q)
    for xx, yy in zip(dx,dy):
        if (-xx,-yy)==t:
            continue
        nx, ny = xx+x, yy+y
        if nx<0 or nx>=h or ny<0 or ny>=w:
            continue
        if s[nx][ny]=="@":
            continue
        if (xx,yy)==t and td<k:
            nd = d
            ntd = td+1
        else:
            nd = d+1
            ntd = 1
        if dist[nx][ny] is None or nd<=dist[nx][ny]:
            hp(q, (nd,nx,ny,(xx,yy),ntd))
            dist[nx][ny] = nd
if dist[x2][y2] is None:
    print(-1)
else:
    print(dist[x2][y2])

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

h,w,k = map(int, input().split())
x1,y1,x2,y2 = map(lambda x: int(x)-1, input().split())
s = [None]*h
for i in range(h):
    s[i] = input()
    
from queue import deque
q0 = deque([(0,x1,y1,(0,0),0)])
q1 = deque()

dx = [0,1,0,-1]
dy = [1,0,-1,0]
# dist = [[None]*w for _ in range(h)]
dist = [None]*(w*h)
dist[x1*w+y1] = 0
# done = [[0]*w for _ in range(h)]
done = [0]*(w*h)
done[x1*w+y1] = 15

while q0 or q1:
    if not q0:
        q0 = q1
        q1 = deque()
    d, x, y, t, td = q0.popleft()
    for i,(xx, yy) in enumerate(zip(dx,dy)):
        if (-xx,-yy)==t:
            continue
        nx, ny = xx+x, yy+y
        if nx<0 or nx>=h or ny<0 or ny>=w or s[nx][ny]=="@":
            continue
        if (xx,yy)==t and td<k:
            nd = d
            ntd = td+1
            q = q0
        else:
            nd = d+1
            ntd = 1
            q = q1
        if dist[nx*w+ny] is None or nd<dist[nx*w+ny]:
            q.append((nd,nx,ny,(xx,yy),ntd))
            dist[nx*w+ny] = nd
            done[nx*w+ny] = 1<<(i)
        elif nd==dist[nx*w+ny]and ((done[nx*w+ny]&1<<(i))==0):
            q.append((nd,nx,ny,(xx,yy),ntd))
            done[nx*w+ny] |= 1<<(i)
            
if dist[x2*w+y2] is None:
    print(-1)
else:
    print(dist[x2*w+y2])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
 
for i in range(n):
    print(a.count(i+1))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in a:
    b[i-1]+=1

[print(i) for i in b]
### BUGGY CODE ###

from numba import njit
"""
@njit('i8(i8)', cache=True)
def popcount(n):
    a = 0
    while n:
        a += n % 2
        n //= 2
    return a
"""
from functools import lru_cache
@lru_cache(maxsize = 10000)
def popcount(n):
    if n == 0:
        return 0
    else:
        return n % 2 + popcount(n // 2)


#@njit('i8(i8)', cache=True)
def fun(n):
    ops = 0
    while n:
        bits = popcount(n)
        n %= bits
        ops += 1
    return ops

def funwrap(n, pc):
    if n == 0:
        return 0
    return 1 + fun(n % pc)

n = int(input())
xs = list(map(int, input()))

from functools import reduce
sm = reduce(lambda x,y: x*2+y, xs)
pc = xs.count(1)

for i in range(n):
    xs[i] ^= 1
    df = 1 if xs[i] == 1 else -1
    pc += df

    dn = 1 << (n - (i + 1))
    smi = sm + dn * df

    print(funwrap(smi, pc))

    xs[i] ^= 1
    pc -= df


### FIXED CODE ###

from numba import njit

@njit('i8(i8)', cache=True)
def popcount(n):
    a = 0
    while n != 0:
        a += n & 1
        n >>= 1
    return a

@njit('i8(i8)', cache=True)
def fun(n):
    ops = 0
    while n:
        pc = popcount(n)
        n %= pc
        ops += 1
    return ops

n = int(input())
xs = list(map(int, input()))

from functools import reduce
sm = reduce(lambda x,y: x*2+y, xs)
pc = xs.count(1)

# pcの差分を出した後の剰余計算を速くするため、事前にmod pc+1, mod pc-1を計算しておく
mp = sm % (pc + 1)
mm = sm % (pc - 1) if pc > 1 else 0

for i in range(n):
    df = 1 if xs[i] == 0 else -1
    pci = pc + df
    if pci == 0:
        print(0)
        continue

    rest = pow(2, n - i - 1, pci)

    if xs[i] == 0:
        smi = (mp + rest) % pci
        print(1 + fun(smi))
    else:
        smi = (mm - rest) % pci
        print(1 + fun(smi))
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
m = list(set(a))

for i in a:
    if i!=int(m[-1]):
        print(m[-1])
    elif a.count(m[-1]) > 1:
        print(m[-1])
    else:
        print(m[-2])


### FIXED CODE ###

import collections

n = int(input())
a = [int(input()) for i in range(n)]
m = sorted(list(set(a)))
c =collections.Counter(a)

t = [max(a)]*n

if c[max(a)] == 1:
    t[a.index(max(a))] = m[-2]

[print(i) for i in t]
### BUGGY CODE ###

N=int(input())
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
left=0
right=0

for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        A=Ln[di-1]
        B=Ln[dj-1]
        if (B+Ln[dj])<A : break

        right=N-1
        left=dj
        while left<=right :
            mid=int((right+left)/2)
            if (B+Ln[mid])>A :
                left=mid+1
            else :
                right=mid-1
        Ans+=(left-1)-(dj-1)

print(Ans)


### FIXED CODE ###

N=int(input())
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
left=0
right=0
 
for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        A=Ln[di-1]
        B=Ln[dj-1]
        if (B+Ln[dj])<A : break
 
        right=N-1
        left=dj
        while left<=right :
            mid=int((right+left)/2)
            if (B+Ln[mid])>A :
                left=mid+1
            else :
                right=mid-1
        Ans+=(left-1)-(dj-1)
 
print(Ans)
### BUGGY CODE ###

n = int(input())
s = input()

res = -1
for i in range(n):
  if res == -1:
    res = s[:i].count('W') + s[i+1:].count('E')
  else:
    if res > s[:i].count('W') + s[i+1:].count('E'):
      res = s[:i].count('W') + s[i+1:].count('E')
print(res)

### FIXED CODE ###

n = int(input())
s = input()

w_lst = [0] * n
e_lst = [0] * n

for i in range(1, n):
    if s[i - 1] == "W":
        w_lst[i] = w_lst[i - 1] + 1
    else:
        w_lst[i] = w_lst[i - 1]
for i in range(n - 2, -1, -1):
    if s[i + 1] == "E":
        e_lst[i] = e_lst[i + 1] + 1
    else:
        e_lst[i] = e_lst[i + 1]

ans = 10**10
for i in range(n):
    ans = min(ans, w_lst[i] + e_lst[i])
print(ans)
### BUGGY CODE ###


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

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
b_start=0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - sum(A[:(A_n_max - a_sub_i)])
   # print(a_sub_i)
   # print(time_left)
    for b_j in range(b_start, len(B)):
      #  print(b_j)
        if (time_left - sum(B[:(b_j+1)])) < 0:
            cnt = cnt + b_j
    #        print(f"b done {b_j}")
            break
        if b_j == (len(B)-1):
            cnt = cnt + b_j +1
     #       print(f"b done__ {b_j}")
            break
    b_start = b_j        
    if cnt > best_cnt:
        best_cnt = cnt
        
print(best_cnt)

### FIXED CODE ###

N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)
### BUGGY CODE ###

import sys
    
global distance

def shortest_path(GRAPH):
    global distance
    
    nodes2=range(len(distance))
    p1 = 0
    distance[p1] = 0;

    while True:
        dp1 = distance[p1]
        gp1 = GRAPH[p1]
        nodes2.remove(p1)
        for p2 in nodes2:
            if gp1.has_key(p2):
                tmp = gp1[p2] + dp1
                if tmp < distance[p2]:
                    distance[p2] = tmp

        p1 = -1
        mini = 1000000
        for p2 in nodes2:
            if distance[p2]<mini:
                p1 = p2
                mini = distance[p2]
        if mini == 1000000:
            break
    return

def resultout():
    for i in xrange(len(distance)):
        print "%d %d" %(i, distance[i])
    return

n = int(raw_input())
x = [{} for i in xrange(n)]
distance = [1000000 for i in xrange(n)]

for i in xrange(n):
    seq = map(int, raw_input().split())
    i2 = seq[0]
    tmp={}
    for j in xrange(2, len(seq), 2):
        j2,weight = seq[j:j+2]
        tmp[j2] = weight
    x[i2] = tmp

shortest_path(x)
resultout()

### FIXED CODE ###

import sys
    
def shortest_path(GRAPH, distance):
    
    nodes = set()
    p1 = 0
    distance[p1] = 0

    while True:
        dp1 = distance[p1]
        gp1 = GRAPH[p1]
        status[p1]=1
        for p2 in gp1.keys():
            tmp = gp1[p2] + dp1
            if status[p2]==0 and tmp < distance[p2]:
                distance[p2] = tmp
                nodes.add(p2)

        p1 = -1
        mini = 1000000
            
        for p2 in nodes:
            if distance[p2]<mini:
                p1 = p2
                mini = distance[p2]
        if mini == 1000000:
            break
        nodes.remove(p1)
    return

def resultout(distance):
    for i in xrange(len(distance)):
        print "%d %d" %(i, distance[i])
    return

n = int(raw_input())
x = [{} for i in xrange(n)]
status = [0 for i in xrange(n)]
distance = [1000000 for i in xrange(n)]

for i in xrange(n):
    seq = map(int, raw_input().split())
    tmp={}
    for j in xrange(2, len(seq), 2):
        j2, weight = seq[j:j+2]
        tmp[j2] = weight
    x[seq[0]] = tmp
    status[i] = 0

shortest_path(x, distance)
resultout(distance)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

s = input().rstrip()
n = int(input().rstrip())
front = ''
back = ''
count = 1
for i in range(n):
    q = input().rstrip().split()
    if q[0] == '1':
        count *= -1
    else:
        if q[1] == '1':
            if count == 1:
                front += q[2]
            else:
                back += q[2]
        else:
            if count == 1:
                back += q[2]
            else:
                front += q[2]
if count == 1:
    print(front[::-1] + s + back)
else:
    print(back[::-1] + s[::-1] + front)

### FIXED CODE ###

from collections import deque

s = deque(input())
n = int(input())
q_list = [input().split() for i in range(n)]
count = 1
for i in q_list:
    if i[0] == '1':
        count *= -1
    else:
        if i[1] == '1':
            if count == 1:
                s.appendleft(i[2])
            else:
                s.append(i[2])
        else:
            if count == 1:
                s.append(i[2])
            else:
                s.appendleft(i[2])
if count != 1:
    s.reverse()
print(*s, sep='')
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

for i in range(N):
    AC = A.copy()
    del AC[i]
    print(max(AC))

### FIXED CODE ###

N = int(input())
A = []

for i in range(N):
    a = int(input())
    A.append(a)

SA = sorted(A)
mx = max(A)

for i in range(N):
    if A[i] == mx:
        print(SA[-2])
    else:
        print(mx)
### BUGGY CODE ###

from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

N = int(input())
edge = [[-1]*(N+2)for i in range(N+2)]

for i in range(N-1):
  a,b,c = map(int,input().split())
  edge[a][b] = c
  edge[b][a] = c
  
Q,K = map(int,input().split())

G = csgraph_from_dense(edge, null_value=-1)
d = dijkstra(G,indices = K)

for i in range(Q):
  x,y = map(int,input().split())
  print(int(d[x]+d[y]))

### FIXED CODE ###

from collections import deque

N = int(input())

gr = { i:[] for i in range(N+1)}

for i in range(N-1):
  a,b,c = map(int,input().split())
  gr[a].append([b,c])
  gr[b].append([a,c])  
  
Q,K = map(int,input().split())

sta = deque([K])
dis = [10**10 for i in range(N+1)]
dis[K] = 0
sumi = [-1 for i in range(N+1)]

while len(sta) >= 1:
  a = sta.pop()
  sumi[a] += 1
  
  for j in gr[a]:
    if sumi[ j[0] ] != -1:
      continue
    else:
      sta.append(j[0])
      dis[j[0]] = dis[a] + j[1]
    
for i in range(Q):
  x,y = map(int,input().split())
  
  print(int(dis[x] + dis[y] ))
### BUGGY CODE ###

N = int(input())
s = []
for _ in range(N):
    s.append(sorted(input()))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter

d = Counter()
N = int(input())
ans = 0
for i in range(N):
    t = str("".join(sorted(input())))
    if t in d:
        ans += d[t]
    d[t] += 1
print(ans)
### BUGGY CODE ###

N = int(input())

def ff(n):
    ans = 0
    for x in range(1,int(-(-n**0.5//1))+1):
        for y in range(1,x+1):
            for z in range(1, y+1):
                if x*x + y*y + z*z + x*y + y*z + z*x == n:
                    if x == y and y == z and z == x:
                        ans +=1
                    elif x == y or y == z or z == x:
                        ans += 3
                    else:
                        ans += 6
    return ans
for i in range(1, N+1):                                      
    print(ff(i))

### FIXED CODE ###

N = int(input())
n = 10**4
tmp = [0]*((10**4)+1)
for x in range(1,int(-(-n**0.5//1))+1):
    for y in range(1,x+1):
        for z in range(1, y+1):
            if x*x + y*y + z*z + x*y + y*z + z*x <= 10**4:
                if x == y and y == z and z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x] +=1
                elif x == y or y == z or z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 3
                else:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 6
for i in range(1, N+1):
    print(tmp[i])
### BUGGY CODE ###

#original submission: https://atcoder.jp/contests/abc162/submissions/11865868

MOD = 10**9 +7

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

ans = 0
gcd_equal_i = [0]*(K+1) #gcd(A) == i なるAの作り方がgcd_equal_i[i]個

for D in range(K, 0, -1):
    num_of_mul = K // D
    tmp = num_of_mul**N

    i = 2
    while D*i <= K:
        tmp -= gcd_equal_i[D*i]
        i += 1
    
    gcd_equal_i[D] = tmp
    ans += D*tmp
    ans %= MOD


print(ans)


### FIXED CODE ###

#original submission: https://atcoder.jp/contests/abc162/submissions/11865868

MOD = 10**9 +7

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

ans = 0
gcd_equal_i = [0]*(K+1) #gcd(A) == i なるAの作り方がgcd_equal_i[i]個

for D in range(K, 0, -1):
    num_of_mul = K // D
    tmp = pow(num_of_mul, N, MOD)

    i = 2
    while D*i <= K:
        tmp -= gcd_equal_i[D*i]
        i += 1
    
    gcd_equal_i[D] = tmp
    ans += D*tmp
    ans %= MOD


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

N = int(input())
S = input()

r, g, b = S.count("R"), S.count("G"), S.count("B")
count = r * g * b

for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2 * j - i
    if 0 <= k < N:
      a, b, c = S[i], S[j], S[k]
      if a != b and b != c and c != a: count -= 1
print(count)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S = input()

ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2 * j - i
    if k < N:
      A, B, C = S[i], S[j], S[k]
      if A != B and B != C and C != A: ans -= 1

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

div = 10**9 + 7
ans = 0

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

memo = {}

for i in range(N):
    for j in range(i+1,N):
        #print(str(i) + " : " + str(j))

        if (i,j) in memo:
            ans += memo[(i,j)]

        else:
            a = A[i]^A[j]
            memo[(i,j)] = a
            ans+= a

#print(ans)
print(ans%div)


### FIXED CODE ###

div = 10**9 + 7
ans = 0

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

#最大値
A_max = max(A)
#最大値を２進数化
A_max_bin = format(A_max, 'b')
#その桁数
max_digits = len(A_max_bin)

#print(max_digits)

input_format = '0' + str(max_digits) + 'b'

A_bin = [ format(item,input_format) for item in A]

#print(A_bin)

ans = 0

for i in range(1,max_digits+1):
    num0 = 0
    num1 = 0
    #print("桁数 : " + str(i))
    for A_i in A_bin:

        #print(str(A_i) + " : " + str(A_i[-i]))
        #i桁目が0だったら

        #print(type(A_i[-1]))

        if A_i[-i] == '0':
            num0 += 1
        else:
            num1 += 1

    ans += num0 * num1 * 2**(i-1)
    #print(ans)

    num0 = 0
    num1 = 0

#print(ans)
print(ans%div)
### BUGGY CODE ###

n = int(input())

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

#print(A)

flag = 0
b = 1
for a in A:
  b = b * a

if(b > 10**18):
  flag = 1
  
  
if flag:
  print(-1)
else:
  print(b)


### FIXED CODE ###

n = int(input())

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

#print(A)

flag = 0
b = 1

for a in A:
  if a == 0:
    flag = 2

if flag == 0:
  for a in A:
    b = b * a
    if(b > 10**18):
      flag = 1
      break

#if(b > 10**18):
#  flag = 1
  
  
if flag == 1:
  print(-1)
elif flag == 0:
  print(b)
else:
  print(0)