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

N=int(input())
S =input()
count =0

Bcount = S.count("B")
for i in range(0,N-1):
    for j in range(i+1,N):
        if (S[i] == "R" and S[j] == "G") or (S[i] == "G" and S[j] == "R") :
            count += Bcount
            if j+(j-i) <N  and S[j+(j-i)] == "B":
                count  -=1
            if i-(j-i) >=0 and S[i-(j-i)] =="B":
                count -=1
            if (i+j)%2 ==0 and S[int((i+j)/2)] == "B":
                count -=1
print(count)

### FIXED CODE ###

N=int(input())
S =input()
count =0

Bcount = S.count("B")
for i in range(0,N-1):
    for j in range(i+1,N):
        if (S[i] == "R" and S[j] == "G") or (S[i] == "G" and S[j] == "R") :
            count += Bcount
            if j+(j-i) <N  and S[j+(j-i)] == "B":
                count  -=1
            if i-(j-i) >=0 and S[i-(j-i)] =="B":
                count -=1
            if (i+j)%2 ==0 and S[int((i+j)/2)] == "B":
                count -=1
print(count)
### BUGGY CODE ###

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

INF = 10 ** 12
dp = [0] * N
dp[0] = 0

for n in range(1, N):
	dp[n] = dp[n - 1] + abs(H[n] - H[n - 1])
	for i in range(2, K + 1):
		if 0 <= n - i:
			dp[n] = min(dp[n], dp[n - i] + abs(H[n] - H[n - i]))
print(dp[-1])


### FIXED CODE ###

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

INF = 10 ** 18

h = H
dp = [0] * N

for n in range(1, N):
	l, r = max(0, n - K), n
	dp[n] = min([dpl + abs(hl - h[r]) for dpl, hl in zip(dp[l:r], h[l:r])])
	#print(dp)
print(dp[N - 1])
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
for n in range(N):
    if n == 0:
        print(max(A[n + 1:]))
    elif n == N - 1:
        print(max(A[:n]))
    else:
        print(max(max(A[:n]), max(A[n + 1:])))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = list(map(str, [m for _ in range(N)]))
if A.count(m) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(m)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = str(mm)
        break
print('\n'.join(ans))
### BUGGY CODE ###

from bisect import bisect_left

s = input()
n = len(s)

ans = [0] * n
p = []
for i in range(n - 1):
    if s[i:i + 2] == 'RL':
        p.append(i)
        ans[i] += 1
        ans[i + 1] += 1

for i in range(n):
    if s[i] == 'L':
        if i - 1 in p:
            continue
        to = bisect_left(p, i) - 1
    else:
        if i in p:
            continue
        to = bisect_left(p, i)
    dist = abs(i - p[to])
    # print(p[to], dist)
    if dist % 2 == 0:
        ans[p[to]] += 1
    else:
        ans[p[to] + 1] += 1
print(*ans)


### FIXED CODE ###

from bisect import bisect_left

s = input()
n = len(s)

p = []
st = set()
for i, (sl, sr) in enumerate(zip(s, s[1:])):
    if sl == 'R' and sr == 'L':
        st.add(i)
        st.add(i + 1)
        p.append(i)

ans = [0] * n
for i, ss in enumerate(s):
    if i in st:
        ans[i] += 1
    else:
        idx = bisect_left(p, i)
        if ss == 'R':
            # p[idx]まで移動して、その後ループ
            loop_start_pos = p[idx]
            if (loop_start_pos - i) % 2 == 0:
                ans[loop_start_pos] += 1
            else:
                ans[loop_start_pos + 1] += 1
        else:
            # p[idx-1]まで移動して、その後ループ
            loop_start_pos = p[idx - 1]
            if (i - loop_start_pos) % 2 == 0:
                ans[loop_start_pos] += 1
            else:
                ans[loop_start_pos + 1] += 1

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

n,q = map(int,input().split())
s = list(str(input()))
k = [0 for i in range(n)]
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        k[i+1] = 1
#print(k)
for i in range(q):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    #print(k[a:b+1])
    ans = sum(k[a:b+1])
    if k[a] == 1:
        ans -= 1
    print(ans)

### FIXED CODE ###

from itertools import *
n,q = map(int,input().split())
s = str(input())
k = [ 1 if s[i-1] == "A" and s[i] == "C" else 0  for i in range(n)]
cumsum = list(accumulate(k))
#print(k)
#print(cumsum)
for i in range(q):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    #print(k[a:b+1])
    ans = cumsum[b] - cumsum[a]
    """
    if k[a] == 1:
        ans -= 1
    """
    print(ans)
### BUGGY CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  n=I()
  a=int(n**(1/5))
  # print(a)
  b=n-a**5
  c=0
  while True:
    if c**5==b:
      return str(a)+' '+str(-c)
    c+=1

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  x=I()
  for a in range(-500,501):
    for b in range(-500,501):
      if a**5-b**5==x:
        return str(a)+' '+str(b)

# main()
print(main())
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    ans = 0
    ans = sum([bisect.bisect_left(L[j+1:], a+b)
               for i, a in enumerate(L[:-1], 1) for j, b in enumerate(L[i:], i)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    L = tuple(L)
    ans = 0
    ans = sum([bisect.bisect_left(L, a+L[j]) - j - 1
               for i, a in enumerate(L[:-1], 1) for j in range(i, N)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


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

# C
import numpy as np
from bisect import bisect

x1, y1, x2, y2 = map(int, input().split())
N = int(input())

xL = min(x1, x2)
xR = max(x1, x2)
yL = min(y1, y2)
yR = max(y1, y2)

xv = np.zeros(N, dtype='int')
yv = np.zeros(N, dtype='int')

ind = 0
for _ in range(N):
    x, y = map(int, input().split())
    if xL <= x and x <= xR and yL <= y and y <= yR:
        xv[ind] = x
        yv[ind] = y
        ind += 1

xv = xv[:ind]
yv = yv[:ind]

N = ind



if x1 < x2 and y1 > y2:
    direction = 'upper'
elif x1 > x2 and y1 < y2:
    direction = 'upper'
else:
    direction = 'down'

    
# sort
xv_s = np.argsort(xv)
yv_ = yv[xv_s]

if direction == 'upper':
    yv_s_ = np.argsort(-yv_)
else:
    yv_s_ = np.argsort(yv_)

yv_s = np.zeros(ind, dtype='int')
for i in range(ind):
    yv_s[yv_s_[i]] = i


# calculate
dp = [ind+1]*(ind)
for i in range(ind):
    y = yv_s[i]
    dp[bisect(dp,y)] = y
count_ = bisect(dp,ind)

diff = 5*np.pi - 20
diff2 = 10*np.pi - 20
if count_ == min((xR-xL), (yR-yL)) + 1:
    print(100*((xR-xL) + (yR-yL)) + (count_-1)*diff + diff2)
else:
    print(100*((xR-xL) + (yR-yL)) + count_*diff)

### FIXED CODE ###

# C
from bisect import bisect
import math
x1, y1, x2, y2 = map(int, input().split())
N = int(input())

xL = min(x1, x2)
xR = max(x1, x2)
yL = min(y1, y2)
yR = max(y1, y2)

xyl = []

if x1 < x2 and y1 > y2:
    direction = 'rightdown'
elif x1 > x2 and y1 < y2:
    direction = 'rightdown'
else:
    direction = 'rightup'
    
    
# sort
if direction == 'rightup':
    for _ in range(N):
        x, y = map(int, input().split())
        if xL <= x and x <= xR and yL <= y and y <= yR:
            xyl.append((x, y-yL))
else:
    for _ in range(N):
        x, y = map(int, input().split())
        if xL <= x and x <= xR and yL <= y and y <= yR:
            xyl.append((x, yR-y))

ind = len(xyl)
xyl.sort()

# calculate
dp = [yR-yL+1]*(ind)
for i in range(ind):
    _, y = xyl[i]
    dp[bisect(dp,y)] = y
count_ = bisect(dp,yR-yL)

diff = 5*math.pi - 20
diff2 = 10*math.pi - 20
if count_ == min((xR-xL), (yR-yL)) + 1:
    print(100*((xR-xL) + (yR-yL)) + (count_-1)*diff + diff2)
else:
    print(100*((xR-xL) + (yR-yL)) + count_*diff)
### BUGGY CODE ###

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

count = 0
for i in range(N):
  if not any([ P[i] >= j for j in P[:i]]):
    count += 1
print(count)


### FIXED CODE ###

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

count = 0
m = P[0]
for i in range(N):
  if (m >= P[i]):
    count += 1
    m = P[i]
print(count)
### BUGGY CODE ###

import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

d = len(set(a))
if d <= k:
  print('0')
else:
  i = 0
  while d > k:
    c = collections.Counter(a)
    c = sorted(c.items(), key=lambda x:x[1])
    a.remove(c[0][0])
    a.append(c[-1][0])
    d = len(set(a))
    i += 1
  else:
    print(i)
    

### FIXED CODE ###

import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

c = collections.Counter(a)
vs = []
for v in c.values():
  vs.append(v)
vs.sort(reverse=True)

i = 0
if len(vs) <= k:
  print(i)
  exit()
else:
  while len(vs) > k:
    i += vs[-1]
    vs.pop()
  else:
    print(i)
    exit()
### BUGGY CODE ###

def ma(li):
    # ループごとにifで大小比較
    max_num = 0
    for i in li:
        if max_num < i:
            max_num = i
    return max_num

def appen(li,yousa):
    li.append(yousa)
    return li
    
def main():
    res=0
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    a=[]
    a=[tuple(map(int,input().split())) for i in range(m)]
    for i in range(1,n+1):
        xx=[]
        for j in set(a):
            if i == j[0]:
                xx=appen(xx,h[j[1]-1])
            if i == j[1]:
                xx=appen(xx,h[j[0]-1])
        if len(xx)==0:
            res+=1
        elif ma(xx)<h[i-1]:
            res+=1
        else:
            continue
    print(res)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def ma(li):
    # ループごとにifで大小比較
    max_num = 0
    for i in li:
        if max_num < i:
            max_num = i
    return max_num

def appen(li,yousa):
    li.append(yousa)
    return li
    
def main():
    res=0
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    
    a=[list(map(int,input().split())) for i in range(m)]
    f=[]
    for i in range(n):
        f.append([0])
    for i in a:
        f[i[0]-1].append(h[i[1]-1])
        f[i[1]-1].append(h[i[0]-1])
    p=-1
    for i in f:
        p+=1
        if len(i)==1:
            res+=1
        elif ma(i)<h[p]:
            res+=1
        else:
            continue

    print(res)

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

n = int(input())

arg = list(map(int, input().split()))
ans = 1

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

    if ans > 1000000000000000000:
        ans = -1

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())

arg = list(map(int, input().split()))
ans = 1

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

        if ans > 1000000000000000000:
            ans = -1
            break

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

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 0
be = 0

for i in range(a[0]-a[1]+1):
    sum = 0
    if be < b[i+a[1]-1]:
        for j in range(a[1]):
            sum += (1 + b[i+j])/2
        if ans < sum:
            ans = sum
    be = b[i]

print(ans)

### FIXED CODE ###

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sum = 0
ans = 0

for i in range(a[0]):
    sum += (1 + b[i])/2
    if i > a[1]-1:
        sum -= (1 + b[i-a[1]])/2
    if ans < sum:
        ans = sum

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

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 10**10
    for i in range(1, n):
        g1 = a[0:i]
        g2 = a[i:n]
        tmp = abs(sum(g1) - sum(g2))
        if tmp < ans:
            ans = tmp

    print(ans)


### FIXED CODE ###

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    g1 = a[0]
    g2 = sum(a[1:n])
    ans = abs(g1 - g2)
    if n > 2:
        for i in range(1, n-1):
            g1 += a[i]
            g2 -= a[i]
            tmp = abs(g1 - g2)
            if tmp < ans:
                ans = tmp

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

N=int(input())
A=list(map(int,input().split()))
dp=[0]*61
for i in range(61):
  for j in A:
    if j>>i&1==1:
      dp[i]+=1
      j+=1
ans=0
mod=10**9+7
for i in range(61):
  ans+=pow(2,i,mod)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

### FIXED CODE ###

def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()
lst = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    s_part = s[(lst[i][0]-1):lst[i][1]]
    print(s_part.count("AC"))


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])
### BUGGY CODE ###

N= int(input())
S= input()
correct = ["RGB","RBG","GBR","GRB","BRG","BGR"]

cnt = 0
for i in range(N):
	for j in range(i+1,N):
		for k in range(j+1,N):
			if (j-i)!=(k-j):
				if "%s%s%s"%(S[i],S[j],S[k]) in correct:
					cnt+=1

print(cnt)
			

### FIXED CODE ###

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

ans = S.count("R")*S.count("G")*S.count("B")

for i in range(N):
	for j in range(N-i):
		if i+2*j>=N:
			break
		elif S[i]!=S[i+j] and S[i]!=S[i+2*j] and S[i+j]!=S[i+2*j]:
			ans-=1
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

### FIXED CODE ###

N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict,deque
import bisect

input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
g = defaultdict(list)
for i in range(N-1):
    u, v = map(int,input().split())
    g[u].append(v)
    g[v].append(u)

dq = deque([1])
visited = [False]*(N+1)

inf = 10**10
l = [inf] * (N+1)

lis = [0] * (N+1)
lis[1] = 1

def f(v,l,k):
    if visited[v]:
        return
    visited[v] = True
    A = a[v-1]
    i = bisect.bisect_left(l,A)
    if k < i:
        l.append(inf)
        k += 1
    l[i] = A 
    lis[v] = k
    #lis[v] = l.index(inf)
    for nv in g[v]:
        if not visited[nv]:
            f(nv,l[:],k)

l = [inf] * 1
f(1,l,0)

for i in range(1,N+1):
    print(lis[i]+1)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict,deque
import bisect
input = sys.stdin.readline

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

g = defaultdict(list)
for i in range(N-1):
    u, v = map(int,input().split())
    g[u].append(v)
    g[v].append(u)

def eulerTour(g,s):
    n = len(g)
    dq = [s]
    ls = [-1]*(n+1)
    rs = [-1]*(n+1)
    index = []
    visited = [False]*(n+1)
    def dfs(v):
        visited[v] = True
        ls[v] = len(index)
        index.append(v)
        for nv in g[v]:
            if not visited[nv]:
                dfs(nv)
        rs[v] = len(index)
        index.append(v)
    dfs(s)
    return ls,rs,index

ls,rs,index = eulerTour(g,1)
dq = deque([1])
visited = [False]*(N+1)

inf = 10**10
l = [inf] * (N+1)

ans = [0] * (N+1)
ans[1] = 1

visited = [False]*(N+1)
rollback = []

k = 1
for v in index:
    if visited[v]:
        i, pa = rollback.pop()
        l[i] = pa
        if pa == inf:
            k -= 1
    else:
        A = a[v-1]
        i = bisect.bisect_left(l,A)
        rollback.append((i,l[i]))
        if k <= i:
            k += 1
        l[i] = A
        #ans[v] = l.index(inf)
        ans[v] = k
        visited[v] = True


for i in range(1,N+1):
    print(ans[i])
### BUGGY CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f


def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    C = defaultdict(int)
    for a in A:
        tmp = fctr1(a)
        for i, j in tmp:
            C[i] = max(C[i],j)

    D = 1
    for i, j in C.items():
        D *= i ** j

    ans = 0
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


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

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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)]

n = int(input())
s = input()
# combinationの準備
md = 10 ** 9 + 7
n_max = 3005
fac = [1]
inv = [1] * (n_max + 1)
k_fac_inv = 1
for i in range(1, n_max + 1):
    k_fac_inv = k_fac_inv * i % md
    fac.append(k_fac_inv)
k_fac_inv = pow(k_fac_inv, md - 2, md)
for i in range(n_max, 1, -1):
    inv[i] = k_fac_inv
    k_fac_inv = k_fac_inv * i % md

def com(com_n, com_r):
    return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md

def way(a):
    an = len(a)
    if an <= 1: return 1
    if a in memo: return memo[a]
    res = 0
    if a[0]: res += way(a[1:])
    if not a[-1]: res += way(a[:-1])
    for i in range(an - 1):
        if not a[i] and a[i + 1]:
            res += way(a[:i]) * way(a[i + 2:]) * com(an, i + 1)
    res %= md
    memo[a] = res
    return res
memo = {}

def main():
    a = [c == "<" for c in s]
    a=tuple(a)
    print(way(a))

main()


### FIXED CODE ###

md = 10 ** 9 + 7
n = int(input())
s = input()
dp = [1] * n
for i in range(n - 1):
    if s[i] == "<":
        for dpi in range(1, n - i - 1):
            dp[dpi] = (dp[dpi] + dp[dpi - 1]) % md
        dp = dp[:-1]
    else:
        for dpi in range(n - i - 2, 0, -1):
            dp[dpi] = (dp[dpi] + dp[dpi + 1]) % md
        dp = dp[1:]
print(dp[0])
### BUGGY CODE ###

N = input()
num = len(N)
ans = 0
for i in range(0,num-3):
  for j in range(i+3,num):
    s = int(N[i:j+1])
    if s% 2019 == 0:
      ans += 1
print(ans)

### FIXED CODE ###

N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

h = []
i = 0
s = 1

ans = 0
while i < k: 
  g = a[s-1]
  if g not in h:
    h.append(g)
    s = g
    i+=1
  else:
    c = h.index(g)
    l = (k-1-c) % (i-c)
    ans = h[c+l]
    break
    
if ans == 0:
  ans = h[-1]

print(ans)

    

### FIXED CODE ###

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

s = 1
g = 0
i = 1
history = [s]
flag = [False] * n
flag[0] = True

while True:
    g = a[s-1]
    if flag[g-1] == True:
        break
    else:
        flag[g-1] = True
        history.append(g)
        s = g
        i += 1


x = history.index(g)

if k < i:
    ans = history[k]
else:
    d = (k-x) % (i - x)

    ans = history[x + d]

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

n, k = map(int, input().split())
H = list(map(int, input().split()))

Dp = [0]

for i in range(1, n):
    can = []
    if i < k:
        for j in range(i):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    else:
        for j in range(k):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    Dp.append(min(can))

ans = Dp[-1]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
H = list(map(int, input().split()))

Dp = [0]

for i in range(1, n):
    can = []
    if i < k:
        for j in range(i):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    else:
        for j in range(k):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    Dp.append(min(can))

ans = Dp[-1]
print(ans)
### BUGGY CODE ###

n = int(input())


k=1
for i in range(1,n+1):
  k = k * i
print(k % (10**9 + 7))
  
 


### FIXED CODE ###

n = int(input())

x = (10**9 + 7)
k=1
for i in range(1,n+1):
  k = k * i
  k = k%x

print(k)
### BUGGY CODE ###

import sys
from bisect import bisect_right, insort_left

def I(): return int(sys.stdin.readline())

def main():
  n = int(input())
  a = [I() for i in range(n)]
  b = []

  for i in range(n-1, -1, -1):
    #print(a[i])
    t = bisect_right(b, a[i])
    if len(b)-1<t or b[t]==a[i]:
      insort_left(b, a[i])
    else:
      b[t] = a[i]
    #print(b)
  print(len(b))

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
from bisect import bisect_right, insort

def I(): return int(sys.stdin.readline())

def main():
  n = I()
  a = [I() for i in range(n)]
  b = []

  for i in range(n-1, -1, -1):
    t = bisect_right(b, a[i])
    if len(b)-1<t or b[t]==a[i]:
      insort(b, a[i])
    else:
      b[t] = a[i]
  print(len(b))

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

a,b,c,d=map(int,input().split())
while(True):
    if (d<=0):
        ans="Yes"
    c=c-b
    if (d<=0):
        ans="Yes"
        break
    a=a-d
    if (b<=0):
        ans="No"
        break

print(ans)

##print("Yes" if   -(-d//a) <=-(-b//c)  else "No")

### FIXED CODE ###

a,b,c,d=map(int,input().split())
"""
while(True):
    if (d<=0):
        ans="Yes"
    c=c-b
    if (d<=0):
        ans="Yes"
        break
    a=a-d
    if (b<=0):
        ans="No"
        break

print(ans)
"""
print("Yes" if   -(-c//b) <=-(-a//d)  else "No")
### BUGGY CODE ###

N = int(input())
data = [int(i) for i in input().split()]
sum = 1

for j in data:
    sum *= j

if sum > 10 ** 18:
    print(-1)
        
else:
    print(sum)

### FIXED CODE ###

import sys
N = int(input())
data = [int(i) for i in input().split()]
sum = 1

if 0 in data:
    print(0)
    sys.exit()

for j in data:
    sum *= j
    if sum > 10 ** 18:
        print(-1)
        sys.exit()
        
else:
    print(sum)