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

import numpy as np
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in A:
  for j in B[np.searchsorted(B, i, side="right"):]:
    ans += n - np.searchsorted(C, j, side="right")
print(ans)

### FIXED CODE ###

import bisect
from itertools import accumulate
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
b_to_c = [0]*n
for i in range(n):
  b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate(b_to_c[::-1]))[::-1]
  
for i in A:
  t = bisect.bisect_right(B, i)
  if t < n:
    ans += Q[t]
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100001)
N, M = map(int,input().split())
if M == 0:
    print("Yes")
    exit(0)

INF = float("inf")
G = [[] for k in range(N)]
D = [INF for k in range(N)]
def dfs(x):
    if len(G[x]) == 0:
        D[x] = x
    else:
        for e in G[x]:
            if D[e[0]] == INF:
                D[e[0]] = D[x] + e[1]
                dfs(e[0])
            else:
                if D[e[0]] != D[x] + e[1]:
                    print("No")
                    exit(0)

for k in range(M):
    L, R, S = map(int,input().split())
    G[L-1].append([R-1,S])
    G[R-1].append([L-1,-S])

for k in range(N):
    if D[k] == INF:
        D[k] = k
        dfs(k)
print("Yes")


### FIXED CODE ###

import sys
sys.setrecursionlimit(100001)
def input():
    return sys.stdin.readline()[:-1]
N, M = map(int,input().split())
if M == 0:
    print("Yes")
    exit(0)

INF = float("inf")
G = [[] for k in range(N)]
D = [INF for k in range(N)]
def dfs(x):
    if len(G[x]) == 0:
        D[x] = x
    else:
        for e in G[x]:
            if D[e[0]] == INF:
                D[e[0]] = D[x] + e[1]
                dfs(e[0])
            else:
                if D[e[0]] != D[x] + e[1]:
                    print("No")
                    exit(0)

for k in range(M):
    L, R, S = map(int,input().split())
    G[L-1].append([R-1,S])
    G[R-1].append([L-1,-S])

for k in range(N):
    if D[k] == INF:
        D[k] = k
        dfs(k)
print("Yes")
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
k2 = 2
ans = 0
for i in range(N-2):
    for j in range(1,N-1-i):
        s = L[i] + L[N-j-1]
        if L[N-j] >= s:
            ans += j
        else:
            for k in range(N-j+1,N):
                if L[k] >= s:
                    ans += N-k
                    break
print((N*(N-1)*(N-2))//6 - ans)

### FIXED CODE ###

import bisect as bs
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        s = L[i] + L[j]
        ans += bs.bisect_left(L,s) - j - 1
        # bisect.bisect_left(list, x)
        # はリストにxを挿入できる点を返す
        # すなわち、
        # (val < x for val in list[0:i]) + (val >= x for val in list[i:len(list)])
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a*=i%mod
if n!=m:
    b*=max(n,m)*a
    print((a*b)%mod)
else:
    b=a
    print((2*a*b)%mod)

### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a=(a*i)%mod
if n!=m:
    b*=max(n,m)*a
    print((a*b)%mod)
else:
    b=a
    print((2*a*b)%mod)
### BUGGY CODE ###

MOD = 1000003
facts = [1,1] #階乗
invs = [1,1] #整数の逆元
invfacts = [1,1] #階乗の逆元
for ind in range(1, MOD):
    i = ind+1
    facts.append(facts[-1]*i % MOD)
    invs.append( -(MOD//i)*invs[MOD%i] % MOD )
    invfacts.append( invfacts[-1]*invs[i] % MOD )

def task(x, d, n, MOD=MOD):
    if x == 0:
        return 0
    if d == 0:
        return pow(x, n, MOD)
    
    xdivd = (x*invs[d]) % MOD
    if xdivd - 1 <= MOD and MOD <= xdivd + n -1:
        return 0
    ans = (facts[xdivd + n -1]*invfacts[xdivd - 1]) % MOD
    ans = (ans*pow(d, n, MOD)) % MOD
    return ans

Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())
    ret = task(x, d, n)
    print(ret)

### FIXED CODE ###

MOD = 1000003
facts = [1,1] #階乗
invs = [1,1] #整数の逆元
invfacts = [1,1] #階乗の逆元
for ind in range(1, MOD):
    i = ind+1
    facts.append(facts[-1]*i % MOD)
    invs.append( -(MOD//i)*invs[MOD%i] % MOD )
    invfacts.append( invfacts[-1]*invs[i] % MOD )

def task(x, d, n, MOD=MOD):
    if x == 0:
        return 0
    if d == 0:
        return pow(x, n, MOD)
    
    xdivd = (x*invs[d]) % MOD
    if MOD <= xdivd + n -1:
        return 0
    ans = (facts[xdivd + n -1]*invfacts[xdivd - 1]) % MOD
    ans = (ans*pow(d, n, MOD)) % MOD
    return ans

Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())
    ret = task(x, d, n)
    print(ret)
### BUGGY CODE ###

s=input()
K=int(input())

a=set([])

for x in range(len(s)):
	for y in range(x, len(s)):
		a.add(s[x:y+1])

print(sorted(a)[K-1])


### FIXED CODE ###

s=input()
K=int(input())

a=set([])

for x in range(len(s)):
	for y in range(x, x+5):
		a.add(s[x:y+1])

print(sorted(a)[K-1])
### BUGGY CODE ###

l = input()
a = l[0]
b = l[1]
c = l[2]
d = l[3]


while(True):
    if(a==b and b==c and c==d):
        print("No")
        break
    if(a==b and c==d):
        print("Yes")
        break
    if(a==c and b==d):
        print("Yes")
        break
    if(a==d and c==b):
        print("Yes")
        break
    print("No")

### FIXED CODE ###

l = input()
a = l[0]
b = l[1]
c = l[2]
d = l[3]


while(True):
    if(a==b and b==c and c==d):
        print("No")
        break
    if(a==b and c==d):
        print("Yes")
        break
    if(a==c and b==d):
        print("Yes")
        break
    if(a==d and c==b):
        print("Yes")
        break
    else:
      print("No")
      break
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    T = input()
    len_t = len(T)
    S = ""
    for t in T:
        if t == "?":
            S += "D"
        else:
            S += t
    print(S)


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    T = input()
    len_t = len(T)
    S = ""
    for t in T:
        if t == "?":
            S += "D"
        else:
            S += t
    print(S)


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

import sys
input = sys.stdin.readline


def f(N, x):
    n = 1
    for i in range(1, N):
        if i != x:
            n *= i
    return n


def main():
    N = int(input())
    X = list(map(int, input().split()))
    D = [0 for i in range(N)]

    for i in range(N-1):
        D[i] = X[i+1] - X[i]

    ans = 0
    r = 0
    for i in range(1, N):
        r += f(N, i)
        ans += D[i-1] * (r % (10**9+7))
    print(ans % (10**9+7))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.readline

mod = 10**9+7


def main():
    N = int(input())
    r1 = [1]
    for i in range(N-1):
        r1.append(r1[i] * (i+1) % mod)
    r2 = [1]
    for i in range(N-1):
        r2.append(r2[i] * (N-1-i) % mod)

    X = list(map(int, input().split()))
    D = [0 for i in range(N)]
    for i in range(N-1):
        D[i] = X[i+1] - X[i]

    ans = 0
    r = 0
    for i in range(N):
        r += r1[i] * r2[N-i-2]
        ans += D[i] * r
        ans %= mod
    print(ans)


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

n = int(input())

result_num = 0
words = [''.join(sorted(str(input())))]
count_dict = {}
count_dict[words[0]] = 1

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in words:
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    words.append(word)
    count_dict[word] = 1

print(result_num)

### FIXED CODE ###

n = int(input())

result_num = 0
count_dict = {''.join(sorted(str(input()))): 1}

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in count_dict.keys():
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    count_dict[word] = 1

print(result_num)
### BUGGY CODE ###

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    s = SI()
    t = SI()

    d = [[] for _ in range(26)]
    p = [0] * 26
    for i,x in enumerate(s):
        d[ord(x)-ord('a')].append(i+1)

    rev = 0
    a = 0
    for x in t:
        x = ord(x) - ord('a')
        if len(d[x]) == 0:
            print(-1)
            return

        c = p[x]
        while d[x][c] <= a:
            c += 1
            if c >= len(d[x]):
                rev += 1
                p = [0] * 26
                a = 0
                c = 0
        a = d[x][c]

    print(rev*len(s) + a)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    s = SI()
    ds = s + s
    t = SI()

    z = [0] * 26
    nt = [[] for _ in range(len(ds))]

    for i in range(len(ds),0,-1):
        z[ord(ds[i-1])-ord('a')] = i
        nt[i-1] = copy.copy(z)

    rev = 0
    a = 0
    for x in t:
        x = ord(x) - ord('a')
        a = nt[a][x]
        if a == 0:
            print(-1)
            return
        if a >= len(s):
            a -= len(s)
            rev += 1
    print(rev*len(s)+a)

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

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
for _ in range(M):
    A[0] = A[0]//2
    A = sorted(A, reverse=True)

print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-a for a in A]
A = sorted(A)
heapq.heapify(A)
for _ in range(M):
    ma = heapq.heappop(A)
    ma = -((-ma)//2)
    heapq.heappush(A, ma)
    # print(A, ma)
print(-sum(A))
### BUGGY CODE ###

R,G,B,N=map(int,input().split())

ans=0

for i in range(N+1):
  if i*R > N:
    break
  else:
    for j in range(N+1):
      if i*R+j*G > N:
        break
      else:
        if N-(i*R+j*G) == 0 or (N-(i*R+j*G)) % B == 0:
          ans+=1
          
print(ans)


### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=0

for i in range(N+1):
  if i*R > N:
    break
  else:
    for j in range(N+1):
      if i*R+j*G > N:
        break
      else:
        if N-(i*R+j*G) == 0 or (N-(i*R+j*G)) % B == 0:
          ans+=1
          
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=float('inf')
for i in range(n):
  d=abs(sum(a[0:i+1])-sum(a[i+1:n]))
  ans=min(ans,d)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=float('inf')
s=sum(a)
res=0
for i in range(n):
  res+=a[i]
  s-=a[i]
  ans=min(ans,abs(s-res))
print(ans)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm(x, y):
    return x * y // gcd(x, y)
B = list(map(lambda x:x&-x, A))
if all(map(lambda x:x==B[0], B[1:])):
    a = reduce(lcm, AA)
    print(M//a - M//(2*a))
else:
    print(0)

### FIXED CODE ###

from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm(x, y):
    return x * y // gcd(x, y)
b0 = AA[0]&-AA[0]
for a in AA[1:]:
    if b0 != a&-a:
        print(0)
        break
else:
    a = reduce(lcm, AA)
    print(M//a - M//(2*a))
### BUGGY CODE ###

import math

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)

### FIXED CODE ###

import math

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)
### BUGGY CODE ###

# N = int(input())
def cmb(n, r, mod):
    x = 1
    for i in range(r):
        x = x * (n-i) % mod
    return (x * g2[r]) % mod


mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def pow_(x, n):
    if n == 0:
        return 1

    k = 1
    while n > 1:
        if n % 2 != 0:
            k *= x
        x *= x
        n //= 2

    return (k * x) % MOD

n, a, b = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
n_num = pow_(2, n) - 1
a_num = cmb(n, a, MOD)
b_num = cmb(n, b, MOD)
print((n_num - a_num - b_num) % MOD)


### FIXED CODE ###

# N = int(input())
def cmb(n, r, mod):
    x = 1
    for i in range(r):
        x = x * (n-i) % mod
    return (x * g2[r]) % mod


mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def pow_(x, n):
    if n == 0:
        return 1

    k = 1
    while n > 1:
        if n % 2 != 0:
            k = (k * x) % MOD
        x = (x * x) % MOD
        n //= 2

    return (k * x) % MOD

n, a, b = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
n_num = pow_(2, n) - 1
a_num = cmb(n, a, MOD)
b_num = cmb(n, b, MOD)
print((n_num - a_num - b_num) % MOD)
### BUGGY CODE ###

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

p_m=1
for n in range(N):
    p_m*=LA[n]
    
LA_absolute=[i*(-1) if i<0 else i for i in LA]


if p_m>=0:
    print(sum(LA_absolute))
else:
    LA_absolute.sort()
    print(sum(LA_absolute)-2*LA_absolute[0])

### FIXED CODE ###

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

Minus=0
Zero=0
L_absolute=[]

for i in LA:
    if i<0:
        L_absolute.append(i*(-1))
        Minus+=1
    elif i==0:
        Zero=1
    else:
        L_absolute.append(i)
        
L_absolute.sort()

if Zero==1:
    ans=sum(L_absolute)
elif Minus%2==1:
    ans=sum(L_absolute)-2*L_absolute[0]
else:
    ans=sum(L_absolute)
    
print(ans)
### BUGGY CODE ###

n = int(input())
A = [int(input()) for i in range(n)]

for i in range(n):
    tmp = A[:]
    del tmp[i]
    print(max(tmp))


### FIXED CODE ###

n = int(input())
A = [int(input()) for i in range(n)]
tmp = sorted(A,reverse=True)
Max = tmp[0]
Second = tmp[1]
for i in range(n):
    if A[i] != Max:
        print(Max)
    else:
        print(Second)
### BUGGY CODE ###

k, s = map(int,input().split())

count=0
for X in range(k+1):
    for Y in range(k+1):
        for Z in range(k+1):
            if X + Y + Z == s:
                count+=1

print(count)

### FIXED CODE ###

k, s = map(int,input().split())

count=0
for X in range(k+1):
    for Y in range(k+1):
        Z = s - X - Y
        if k>=Z>=0:
            count+=1

print(count)
### BUGGY CODE ###

n = int(input())
#h  = list(map(int, input().split()))
#h, w = list(map(int, input().split()))


s = input()
count = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i]!=s[j]:    
            for k in range(j+1, n):
                if j-i!=k-j:
                    if s[i]!=s[k] and s[j]!=s[k]:
                        count += 1

print(count)





### FIXED CODE ###

n = int(input())
#h  = list(map(int, input().split()))
#h, w = list(map(int, input().split()))

#j-i=k-jではない 2j=k+i i=2j-k

s = input()
count = 0

"""
for i in range(n):
    for j in range(i+1, n):
        if s[i]!=s[j]:    
            for k in range(j+1, n):
                if j-i!=k-j:
                    if s[i]!=s[k] and s[j]!=s[k]:
                        count += 1
"""
for i in range(n):
    a = s[i:]
    if s[i]=="R":
        point = a.count("G")*a.count("B")
    elif s[i]=="G":
        point = a.count("R")*a.count("B")
    else:
        point = a.count("R")*a.count("G")
    count += point

#j-i=k-jではない 2j=k+i i=2j-k
#rgb

kom = 0
for i in range(n):
    for j in range(i+1, n):
        if 2*j-i < n:
            if s[i]!=s[j] and s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
                kom += 1


print(count-kom)
### BUGGY CODE ###

num ,m =map(int,input().split())
arr = list(map(int,input().split()))

for i in range(m):
    arr[arr.index(max(arr))] = max(arr) //2


print(sum(arr))
    

### FIXED CODE ###

import heapq as hq

num ,m =map(int,input().split())

arr = [-i for i in list(map(int,input().split()))]
hq.heapify(arr)

for i in range(m):
    hq.heappush(arr, -1*(-1*hq.heappop(arr)//2))

    
print(-1*sum(arr))
### BUGGY CODE ###

N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    x, y = map(int,input().split())
    w.append(x)
    v.append(y)
    
dp = [ [0 for i in range(W+1)] for j in range(N+1) ]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] )
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    x, y = map(int,input().split())
    w.append(x)
    v.append(y)
    
dp = [ [0 for i in range(W+1)] for j in range(N+1) ]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] )
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])
### BUGGY CODE ###

n,m = list(map(int,input().split()))
d = []
for i in range(m):
  a,b = list(map(int,input().split()))
  d.append( ((1<<a)-1) ^ ((1<<b)-1) )

for bit in range(1<<n):
    spr = [True]*m
    for k in range(m):
      if (d[k] & bit) > 0:
        spr[k] = False
    if sum(spr) == 0:
      print(sum([1 for i in range(n) if bit & 1<<i]))
      exit()


### FIXED CODE ###


n,m = list(map(int,input().split()))
d = [0]*m
spr = [True]*m
ma = 0
mi = 0
for i in range(m):
    a,b = list(map(int,input().split()))
    d[i] = [a,b]

d = sorted(d)
pre = d[0][1]
ans = 1
for i,(a,b) in enumerate(d):
  if a < pre:
    if b < pre:
      pre = b
  else:
    ans += 1
    pre = b

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

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

i_range = [int(x) for x in range(1, N-1)]
j_range = [int(x) for x in range(2, N)]
k_range = [int(x) for x in range(3, N+1)]

val = 0

for k in k_range:
    for j in j_range:
        if(j >= k):
            break
        for i in i_range:
            if(i >= j):
                break
            if((S[i-1] != S[j-1]) and (S[j-1] != S[k-1]) and (S[i-1] != S[k-1])):
                if(j-i != k-j):
                    val = val + 1

print(val)

### FIXED CODE ###

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


"""
脳死で全探索で探すとO(n^3）で時間がかかる。
→1つめの条件で予め絞った後に、そこからさらに絞り込むやり方をやる。（補集合を引くパターン）
j-i=k-jを満たすもの（すなわちk=2j-i）を求めて、あとで引き算すればOK.
≠は＝で考えて引き算のほうがよい。
"""

r_count = S.count('R')
g_count = S.count('G')
b_count = S.count('B')


val = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        k = 2*j-i
        if(k < N):
            if((S[i] != S[j]) and (S[j] != S[k]) and (S[i] != S[k])):
                val += 1

print((r_count * g_count * b_count) - val)
### BUGGY CODE ###

import math

K = int(input())
result = 0
sum = 0




for a in range(1,K+1):
    for b in range(1,K+1):
        result = math.gcd(a, b)
        for c in range(1,K+1):
            result = math.gcd(a, b)
            sum = sum + math.gcd(result, c)

print(sum)    

### FIXED CODE ###

K = int(input())
import math
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        value = math.gcd(i,j)
        for k in range(1, K+1):
            sum += math.gcd(value,k)
 
print(sum)
### BUGGY CODE ###

import math
  
def yo(n):
    if n==1:    return False
    s=2
    while s <= int(math.sqrt(n)):
        if n%s == 0:    return False
        s+=1
    return True
  
while True:
    c=0
    try:
        for i in range(1, int(input(">>"))+1,2):
            if yo(i)==True:    c+=1
        print(c)
    except:
        break

### FIXED CODE ###

def pri(s,n): 
    tab=[i for i in range(n+1) if s[i] and i>=2]
    return(tab)
 
s=[True for _ in range(999999+1)]
i=2
while i**2<=999999:
    if s[i]:
        j=i*2
        while j<=999999:
            s[j]=False
            j+=i
    i+=1

while True:
    try:
        print(len(pri(s,int(input()))))
    except:
        break
### BUGGY CODE ###

from collections import Counter
from itertools import combinations

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

cnter = Counter(S)
alpha = set(cnter)

ans = 0

for i in range(1, len(alpha) + 1):
    if i == 1:
       ans += len(S)
    else:
        for pat in combinations(alpha, i):
            tmp = 1
            for v in pat:
                tmp *= cnter[v]
            ans += tmp

print(ans % (10 ** 9 + 7))

### FIXED CODE ###

from collections import Counter

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

cnter = Counter(S)
alpha = set(cnter)

ans = 1

for i in alpha:
    ans *= (cnter[i] + 1)

print((ans - 1) % (10 ** 9 + 7))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
for _ in range(q):
  b, c = map(int, input().split())
  if a.count(b):
    l = a.index(b)
    r = n - a[::-1].index(b)
    for i in range(l, r):
      if a[i] == b:
        a[i] = c
  print(sum(a))
    

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
d = dict() 
for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
s = sum(a)
for _ in range(int(input())):
  b, c = map(int, input().split())
  if b in d:
    s += ((c - b) * d[b])
    if c in d:
      d[c] += d[b]
    else:
      d[c] = d[b]
    d[b] = 0
  print(s)
### BUGGY CODE ###

def main():
    n = int(input())
    s = input()
    dp = [[0 for i in range(n+1)] for j in range(n+1)]
    
    for i in range(n-1,-1,-1):#後ろから
        for j in range(i-1,-1,-1):
            if s[i]!=s[j]:
              	dp[i][j] = 0#continueではない
        	    
            else:
              	dp[i][j] = dp[i+1][j+1] +1
              	"""
              	これでは結局ループしている
                cnt = 0
                for k in range(min(n-j,j-i)):
                    if s[i+k] ==s[j+k]:
                        cnt += 1
                    else:
                        break
                dp[i][j] = cnt
             	"""
    mx = 0
    #print(dp)
    for i in range(n):
      	for j in range(i):###
        	mx = max(mx,min(i-j,dp[i][j]))###
    print(mx)

if __name__ =='__main__':main()
            
            
            


### FIXED CODE ###

def main():
    n = int(input())
    s = input()
    dp = [[0 for i in range(n+1)] for j in range(n+1)]
    
    from itertools import product
    for i,j in product(reversed(range(n)),repeat=2):###for を置き換え
        if j>i:
            continue
        if s[i]!=s[j]:
            dp[i][j] = 0 #continueではない	    
        else:
           	dp[i][j] = dp[i+1][j+1] +1
           	"""
            これでは結局ループしている
            cnt = 0
            for k in range(min(n-j,j-i)):
                if s[i+k] ==s[j+k]:
                    cnt += 1
                else:
                    break
            dp[i][j] = cnt
            """
    mx = 0
    #print(dp)
    for i in range(n):
      	for j in range(i):###
        	mx = max(mx,min(i-j,dp[i][j]))###i-jで抑える
    print(mx)

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

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

for i in range(1, n +1):
    print(a.count(i))

### FIXED CODE ###

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

result = [0 for _ in range(n)]
for i in range(n - 1):
    result[a[i]-1] += 1

for v in result:
    print(v)
### BUGGY CODE ###

a,b=open(0);c=1;
for i in b.split():c*=int(i)
if c>10**18:print(-1);exit()
print(c)

### FIXED CODE ###

a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)