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

N = int(input())
b = list(map(int, input().split()))
MOD = 1000000007
sum_n = 0
a = []
for i in b:
  a.append(i%MOD)
sum_sum = []
for i in range(1,N):
  sum_sum.append(sum(a[i:])%MOD)
for i in range(1,N):
  sum_n = (sum_n + (a[i-1] * sum_sum[i-1]) % MOD) % MOD
print(sum_n % MOD)

### FIXED CODE ###

N = int(input())
b = list(map(int, input().split()))
MOD = 1000000007
sum_n = 0
a = []
for i in b:
  a.append(i%MOD)
sum_sum = sum(a[1:])
for i in range(N):

  sum_n = (sum_n + (a[i] * sum_sum) % MOD) % MOD
  if i+1 < N:
  	sum_sum = sum_sum - a[i+1]
print(sum_n % MOD)
### BUGGY CODE ###

#import numpy as np

def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            #mod = np.mod([prod], 2019)[0]
            if mod < minmod:
                minmod = mod
    print(minmod)

main()

### FIXED CODE ###

def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            #mod = np.mod([prod], 2019)[0]
            if mod < minmod:
                minmod = mod
            if minmod < 1:
                break
        else: continue
        break
    print(minmod)

main()
### BUGGY CODE ###

s = input()
n = len(s)
s = [ord(c)-ord('a') for c in s]
h = [0] * (n+1)
for i in range(1,n+1):
  h[i] = h[i-1] ^ (1<<s[i-1])
dp = [0] * (n+1)
for i in range(n):
  syo = float("inf")
  for j in range(0,i+1):
    tmp = h[i+1] ^ h[j]
    if tmp == 0 or (tmp & (tmp-1)) == 0:
      syo = min(syo,dp[j]+1)
  dp[i+1] = syo
print(dp[-1])

### FIXED CODE ###

s = input()
n = len(s)
s = [ord(c)-ord('a') for c in s]
h = [0] * (n+1)
for i in range(1,n+1):
  h[i] = h[i-1] ^ (1<<s[i-1])
dp = {}
dp[0] = 0
bits = [2 ** i for i in range(26)]
for i in range(n):
  tmp = float("inf")
  for j in bits:
    try:
      tmp = min(dp[h[i+1]^j] + 1,tmp)
    except:
      pass
  try:
    e = dp[h[i+1]]
  except:
    e = float("inf")
  dp[h[i+1]] = min(tmp,e)
print(dp[h[n]] if dp[h[n]] != 0 else 1)
### BUGGY CODE ###

inputa = list(map(int, input().split()))
inputb = []
for i in range(inputa[0]):
  inputb.append(list(map(int, input().split())))
#座標、開始時間の順にソート
inputb.sort(key=lambda x:(x[2],x[0]))
#歩く人の処理
for i in range(inputa[1]):
  inputc = int(input())
  time = 0 + inputc
  walk = 0
  broken = 0
  #工事の気配あるとこまで歩く
  for j in range(inputa[0]):
    walk = inputb[j][2]
    time = inputc + inputb[j][2]
    if (time >= inputb[j][0]) and (time < inputb[j][1]):
      print(walk)
      broken = 1
      break
  if broken == 0:
    print(-1)

### FIXED CODE ###

from bisect import bisect_left as bl
N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda x: x[2])
Y = [int(input()) for _ in range(Q)]
res = [-1] * Q
jump = [-1] * Q
for s,t,x in X:
  l=bl(Y,s - x)
  r=bl(Y,t - x)
  while l < r:
    s = jump[l]
    if s == -1:
      res[l] = x
      jump[l] = r
      l += 1
    else:
      l = s
print(*res,sep = '\n')
### BUGGY CODE ###

import math

N,M,S=map(int,input().split())

Us=[0]*M
Vs=[0]*M
As=[0]*M
Bs=[0]*M
for i in range(M):
    Us[i],Vs[i],As[i],Bs[i] = map(int,input().split())

# ---
V={}
Ns = max(As)*N
Nv=N*(Ns+1)
cnt=0
for i in range(1,N+1):
    for ns in range(Ns+1):
        V[(i,ns)]=cnt
        cnt+=1
#T= copy.copy(V)


if S > Ns:
    S = Ns

# --
w = [[math.inf]*Nv for _ in range(Nv) ]
# U <-> V
for _ in range(M):
    u = Us.pop()
    v = Vs.pop()
    a = As.pop()
    b = Bs.pop()
    #
    for i in range(Ns+1): # i = 0,..,Ns
        ns_s = Ns - i
        ns_g = ns_s - a
        if ns_g >= 0:
            # U -> V
            w[ V[(u,ns_s)] ][ V[(v,ns_g)] ] = b
            # V -> U
            w[ V[(v,ns_s)] ][ V[(u,ns_g)] ] = b
            #print(u,v,a,b,ns_s,ns_g,V[(u,ns_s)],V[(v,ns_g)])

# -----

for i in range(N):
    c,d = map(int,input().split())
    v = i+1
    for j in range(Ns): # j = 0,...,Ns-1
        ns_s = j
        ns_g = j + c
        if ns_g > Ns:
            ns_g = Ns
        w[ V[(v,ns_s)] ][ V[(v,ns_g)] ] = d

# -----
D=[-1]*Nv
# -----
T=set(range(Nv))
visited = set([1])
allcity = set(range(1,N+1))

s=V[(1,S)]
T.remove(s) #del T[s]
D[s] = 0
for v in T:
    D[v] = w[ s ][ v ]
#while len(T) > 0:
for _ in range(Nv-1):
    u = min(T,key=lambda x:D[x])
    T.remove(u)

    visited.add(u//(Ns+1)+1)
    if visited == allcity:
        break

    for v in T:
        D[ v ] = min( D[ v ], D[ u ] + w[ u ][ v ] )

for i in range(1,N):
    ans = min([D[i*(Ns+1)+v] for v in range(Ns+1)])
    print(ans)

### FIXED CODE ###

import math
import heapq

N,M,S=map(int,input().split())

Us=[0]*M
Vs=[0]*M
As=[0]*M
Bs=[0]*M
for i in range(M):
    Us[i],Vs[i],As[i],Bs[i] = map(int,input().split())
    Us[i] -= 1
    Vs[i] -= 1

# ---
V={}
Ns = max(As)*N
Nv=N*(Ns+1)
cnt=0
for i in range(N):
    for ns in range(Ns+1):
        V[(i,ns)]=cnt
        cnt+=1

G=[[] for _ in range(Nv)]

if S > Ns:
    S = Ns

# U <-> V
for _ in range(M):
    u = Us.pop()
    v = Vs.pop()
    a = As.pop()
    b = Bs.pop()
    #
    for i in range(Ns+1): # i = 0,..,Ns
        ns_s = Ns - i
        ns_g = ns_s - a
        if ns_g >= 0:
            # U -> V
            G[ V[(u,ns_s)] ].append( (V[(v,ns_g)],b) )
            # V -> U
            G[ V[(v,ns_s)] ].append( (V[(u,ns_g)],b) )
            #print(u,v,a,b,ns_s,ns_g,V[(u,ns_s)],V[(v,ns_g)])

# -----

for i in range(N):
    c,d = map(int,input().split())
    for j in range(Ns): # j = 0,...,Ns-1
        ns_s = j
        ns_g = j + c
        if ns_g > Ns:
            ns_g = Ns
        G[ V[(i,ns_s)] ].append( (V[(i,ns_g)],d) )

# -----
D=[math.inf]*Nv
q=[]
# -----

s=V[(0,S)]
D[s] = 0
heapq.heappush(q,(0,s))

while len(q) > 0:
    p_cost,p_v = heapq.heappop(q)
    if D[p_v] < p_cost:
        continue
    for e_to,e_cost in G[p_v]:
        if D[ e_to ] > D[p_v] + e_cost:
            D[e_to] = D[p_v] + e_cost
            heapq.heappush(q, (D[e_to], e_to))

for i in range(1,N):
    ans = min([D[i*(Ns+1)+v] for v in range(Ns+1)])
    print(ans)
### BUGGY CODE ###

H, W, M = map(int, input().split())
h = [0] * (H+1)
w = [0] * (W+1)
l = []
for i in range(M):
  x, y = map(int, input().split())
  h[x] += 1
  w[y] += 1
  l.append([x, y])
  
a = []
b = []
c = max(h)
d = max(w)
for i in range(H+1):
  if h[i] == c:
    a.append(i)
for i in range(W+1):
  if w[i] == d:
    b.append(i)

flag = False
for s in a:
  for t in b:
    if [s, t] not in l:
      flag = True
      break
if flag:
  ans = c+d
else:
  ans = c+d-1
print(ans)


### FIXED CODE ###

H, W, M = map(int, input().split())
h = [0] * (H+1)
w = [0] * (W+1)
l = set()
for i in range(M):
  x, y = map(int, input().split())
  h[x] += 1
  w[y] += 1
  l.add((x, y))
  
c = max(h)
d = max(w)
a = [i for i, x in enumerate(h) if x == c]
b = [i for i, x in enumerate(w) if x == d]

flag = False
for s in a:
  for t in b:
    if (s, t) not in l:
      flag = True
      break
  if flag:
    break
ans = c+d
if not flag:
  ans -= 1
print(ans)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())

# print(N, K)
S = input()
index_array = np.array([])
now_letter = "1"
letter_count = 0
for s in S:
    if s != now_letter:
        index_array = np.append(index_array, letter_count)
        now_letter = s
        letter_count = 1
    else:
        letter_count += 1
else:
    index_array = np.append(index_array, letter_count)
    if now_letter == "0":
        index_array = np.append(index_array, 0)
# print(index_array)
ans = 0

array_len = len(index_array)
if (K * 2 + 1) >= array_len:
    print(N)
    exit()
candidate = (array_len + 1) // 2 - K
for i in range(candidate):
    # print(index_array[i * 2:(i + K) * 2 + 1])
    ans = max(np.sum(index_array[i * 2:(i + K) * 2 + 1]), ans)
print(int(ans))


### FIXED CODE ###

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

# print(N, K)
S = input()
index_array = [0]
now_letter = "1"
for i, s in enumerate(S):
    if s != now_letter:
        now_letter = s
        index_array.append(i)
else:
    if now_letter == "1":
        index_array.append(N)
    else:
        index_array.append(N)
        index_array.append(N)        

# print(index_array)
ans = 0
array_len = len(index_array)
if (K + 1) * 2 > array_len:
    print(N)
    exit()
candidate = array_len // 2 - K
for i in range(candidate):
    # print(index_array[(i + K) * 2 + 1] - index_array[i * 2])
    ans = max(index_array[(i + K) * 2 + 1] - index_array[i * 2], ans)
print(int(ans))
### BUGGY CODE ###

s = input()
t = input()

dp = [[""]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if (s[i]==t[j]):
            if (len(dp[i][j])+1>=len(dp[i+1][j]) and len(dp[i][j])+1>=len(dp[i][j+1])):
                dp[i+1][j+1] = dp[i][j]+s[i]
            elif (len(dp[i+1][j])>=len(dp[i][j])+1 and len(dp[i+1][j])>=len(dp[i][j+1])):
                dp[i+1][j+1] = dp[i+1][j]
            else:
                dp[i+1][j+1] = dp[i][j+1]
        else:
            if (len(dp[i+1][j])>=len(dp[i][j+1])):
                dp[i+1][j+1] = dp[i+1][j]
            else:
                dp[i+1][j+1] = dp[i][j+1]

print(dp[-1][-1])

### FIXED CODE ###

tmp1 = input()
tmp2 = input()
s = ""
t = ""
if (len(tmp1)<=len(tmp2)):
    s = tmp1
    t = tmp2
else:
    t = tmp1
    s = tmp2

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if (s[i]==t[j]):
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ret = ""
i = len(s)
j = len(t)

while(i>0 and j>0):
    if(dp[i][j]==dp[i-1][j]):
        i -= 1
    elif(dp[i][j]==dp[i][j-1]):
        j -= 1
    elif(dp[i][j] != dp[i-1][j-1]):
        ret = s[i-1] + ret
        i -= 1
        j -= 1

print(ret)
### BUGGY CODE ###

from collections import deque
N, K = map(int, input().split())
score = list(map(int, input().split()))
add = deque()
sc = 1
for i in range(K):
    sc *= score[i]
add.append(sc)
for i in range(K, N):
    sc = sc // score[i-K]
    sc *= score[i]
    add.append(sc)
pre = 0
for num, val in enumerate(add):
    if num != 0:
        print("Yes" if val > pre else "No")
    pre = val

### FIXED CODE ###

N, K = map(int, input().split())
score = list(map(int, input().split()))
for i in range(K, N):
    print("Yes" if score[i - K] < score[i] else "No")
### BUGGY CODE ###

import itertools

MAX_DIS = 10**10
N,M,R = map(int,input().split(" "))
r_list = list(map(int,input().split(" ")))
roads = [[MAX_DIS for i in range(N)] for i in range(N)]
for i in range(N):
    roads[i][i] = 0
for i in range(M):
    A,B,C = map(int,input().split(" "))
    roads[A-1][B-1] = C
    roads[B-1][A-1] = C
for i in range(N):
    for j in range(N):
        for k in range(N):
            roads[i][j] = min(roads[i][j],roads[i][k]+roads[k][j])
min_dis = MAX_DIS
for directions in itertools.permutations(r_list):
    distance  = 0
    for dir in range(1,len(directions)):
        distance += roads[directions[dir-1]-1][directions[dir]-1]
    if distance < min_dis:
        min_dis =distance
print(min_dis)


### FIXED CODE ###

import itertools

MAX_DIS = 10**10
N,M,R = map(int,input().split(" "))
r_list = list(map(int,input().split(" ")))
roads = [[MAX_DIS]*N for i in range(N)]
for i in range(N):
    roads[i][i] = 0
for i in range(M):
    A,B,C = map(int,input().split(" "))
    roads[A-1][B-1] = C
    roads[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(N):
            roads[i][j] = min(roads[i][j],roads[i][k]+roads[k][j])
min_dis = MAX_DIS
for directions in itertools.permutations(r_list):
    distance  = 0
    for dir in range(1,len(directions)):
        distance += roads[directions[dir-1]-1][directions[dir]-1]
    if distance < min_dis:
        min_dis =distance
print(min_dis)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
bs = 1
for i in range(K):
    bs *= A[i]
for i in range(N - K):
    s = bs * A[K + i] // A[i]
    if s > bs:
        print('Yes')
    else:
        print('No')
    bs = s


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N - K):
    if A[K + i] >  A[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

from heapq import heapify, heappop, heappush
import sys

input = sys.stdin.readline

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

BC = [tuple(map(int, input().split())) for _ in range(m)]

for b, c in BC:
    for _ in range(b):
        A.append(c)

A = list(map(lambda x: -x, A))
heapify(A)

answer = 0
for _ in range(n):
    answer += heappop(A)

print(-answer)


### FIXED CODE ###

from heapq import heapify, heappop, heappush
import sys

input = sys.stdin.readline

n, m = map(int, input().split())
A = list(map(int, input().split()))
heapify(A)

BC = [tuple(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: x[1], reverse=True)

for i in range(m):
    for _ in range(BC[i][0]):
        min_num = heappop(A)
        if min_num < BC[i][1]:
            heappush(A, BC[i][1])
        else:
            heappush(A, min_num)
            break

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

nums , types = map(int, input().split())
array = list(map(int,input().split()))
array.sort()
type_count = 0
count = 0
result = 0
ary_count = []
array.append(1000000000)

for i in range (nums):
    if array[i] == array[i +1]:
        count += 1
    elif array[i] < array[i +1]:
        ary_count.append(count)
        type_count += 1
        count = 0

if type_count > types:
    for i in range(type_count - types):
        result += min(ary_count)+1
        ary_count.pop(ary_count.index(min(ary_count)))

print(result)

### FIXED CODE ###

nums , types = map(int, input().split())
array = list(map(int,input().split()))
array.sort()
type_count = 0
count = 0
result = 0
ary_count = []
array.append(1000000000)

for i in range (nums):
    if array[i] == array[i +1]:
        count += 1
    elif array[i] < array[i +1]:
        ary_count.append(count)
        type_count += 1
        count = 0

ary_count.sort()

if type_count > types:
    for i in range(type_count - types):
        result += ary_count[i]+1
print(result)
### BUGGY CODE ###

t = input()
u = list(t)
for i in range(len(u)):
    if u[i] == '?':
        u[i] = 'P'
        tmp = ''.join(u).count('D') + ''.join(u).count('PD')
        u[i] = 'D'
        tmp2 = ''.join(u).count('D') + ''.join(u).count('PD')
        if tmp >= tmp2:
            u[i] = 'P'
        else:
            u[i] = 'D'
print(''.join(u))

### FIXED CODE ###

t = input()
u = list(t)
if u[0] == '?':
    u[0] = 'D'
if u[-1] == '?':
    u[-1] = 'D'
for i in range(1, len(u)-1):
    if u[i] == '?':
        if u[i-1] == 'P':
            u[i] = 'D'
        elif u[i+1] == 'D':
            u[i] = 'P'
        else:
            u[i] = 'D'
print(''.join(u))
### BUGGY CODE ###

if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1

    for i in b:
        if  0 in b:
            ans = 0
            break
        ans = ans*i
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)


### FIXED CODE ###

if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    if 0 in b:
        ans = 0
    else:
        for i in range(len(b)):
            ans *= b[i]
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
list_A = list(map(int, input().split()))

for i in range(m):
    list_A = sorted(list_A)
    list_A[-1] = int(list_A[-1]/2)

            # print(i, j, list_A[j])

print(sum(list_A))

### FIXED CODE ###

import heapq as hp
n, m = map(int, input().split())
list_A = list(map(int, input().split()))
# list_A = sorted(list_A)

a_q = []
for i in list_A:
    hp.heappush(a_q, -1*i)

for i in range(m):
    tmp = hp.heappop(a_q)
    tmp = hp.heappush(a_q, int(tmp/2))

print(-sum(a_q))
### BUGGY CODE ###

n, q = map(int,input().split())
cnt = [0] * (n+1)
import sys
sys.setrecursionlimit(10**6)
import numpy as np
tree = [[] for _ in range(n+1)]
seen = [0] * (n+1)
child = [0] * (n+1)
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
def dfs(i):
    global child
    child[i] = []
    if tree[i] == []:
        seen[i] = 1
        return
    for j in tree[i]:
        if seen[j] == 0:
            child[i].append(j)
            seen[i] = 1
            dfs(j)
    return

dfs(1)
#print(child)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x
def plus(c):
    global cnt
    if child[c] == []:
        return
    for target in child[c]:
        cnt[target] += cnt[c]
        plus(target)
    return
plus(1)
print(*cnt[1:])

### FIXED CODE ###

n, q = map(int,input().split())
cnt = [0] * (n+1)
tree = [[] for _ in range(n+1)]
seen = [0] * (n+1)
todo = [1]
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x

while todo != []:
    i = todo.pop()
    seen[i] = 1
    for j in tree[i]:
        if seen[j] == 0:
            todo.append(j)
            cnt[j] += cnt[i]
print(*cnt[1:])
### BUGGY CODE ###

n, k, q = list(map(int,input().split(' ')))
import numpy as np
point =np.full(n,k)
for i in range(q):
  point-=1
  point[int(input())-1]+=1

  
  
for i in point:
  if i>0:
    print('Yes')
  else:
    print('No')


### FIXED CODE ###

n, k, q = list(map(int,input().split(' ')))
import numpy as np
point =np.full(n,k-q)
for i in range(q):
  win = int(input())
  point[win-1]+=1
  
  
#print(np.where(point>0,'Yes','No'))
for i in point:
  if i>0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

from itertools import combinations

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

diff = sorted([t[1]-t[0] for t in combinations(a, 2)], reverse=True)

print(diff.count(diff[0]))

### FIXED CODE ###

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

mn = a[0]
l = []

for x in a:
    l.append(x-mn)
    mn = min(mn, x)

l.sort()
print(l.count(l[-1]))
### BUGGY CODE ###

import queue
H, W = map(int, input().split())
S= [input() for i in range(H)]

ans=-1

def dfs(start,goal):
    distance=[[-1]*H for j in range(W)]
    li_x=[1,-1,0,0]
    li_y=[0,0,1,-1]
    q = queue.Queue()
    q.put(start)
    distance[start[0]][start[1]]=0

    while not q.empty():
        hoge=q.get()
        x=hoge[0]
        y=hoge[1]
        dis=distance[x][y]

        for i in range(4):
            x1=x+li_x[i]
            y1=y+li_y[i]
            if (0 <=x1 < W and 0 <= y1 < H):
                if distance[x1][y1] == -1:
                    if S[y1][x1]=='.':
                        q.put([x1,y1])
                        distance[x1][y1]=dis+1

    return distance[goal[0]][goal[1]]

for sx in range(W):
    for gx in range(W):
        for sy in range(H):
            for gy in range(H):
                if S[sy][sx]=='.' and S[gy][gx]=='.':
                    re=dfs([sx,sy],[gx,gy])
                    if re > ans:
                        ans=re

print(ans)

### FIXED CODE ###

import queue
from itertools import product

H, W = map(int, input().split())
S= [input() for i in range(H)]

ans=-1

def bfs(start):
    distance=[[-1]*H for j in range(W)]
    li_x=[1,-1,0,0]
    li_y=[0,0,1,-1]
    q = queue.Queue()
    q.put(start)
    distance[start[0]][start[1]]=0

    while not q.empty():
        hoge=q.get()
        x=hoge[0]
        y=hoge[1]
        dis=distance[x][y]

        for i in range(4):
            x1=x+li_x[i]
            y1=y+li_y[i]
            if (0 <=x1 < W and 0 <= y1 < H):
                if distance[x1][y1] == -1:
                    if S[y1][x1]=='.':
                        q.put([x1,y1])
                        distance[x1][y1]=dis+1
    m=[]
    for i in range(W):
        m.extend(distance[i])
    return max(m)

for sx,sy in product(range(W),range(H)):

                if S[sy][sx]=='.':
                    re=bfs([sx,sy])
                    if re > ans:
                        ans=re

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

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]

def terasu(a):
    new_a = [0]*n
    for j,l in enumerate(a):
        for i in range(-l,l+1):
            if j+i >= 0 and j+i<n:
                new_a[j+i]+=1                
    return(new_a)

for x in range(k):
    a = terasu(a)
print(" ".join([str(x) for x in a]))

### FIXED CODE ###

import math
import numpy as np

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]


for _ in range(k):
    new_a = np.zeros(n+1,dtype=int)
    np.add.at(new_a, np.maximum(0,np.arange(0, n)-a), 1)
    np.add.at(new_a, np.minimum(n,np.arange(0, n)+a+1), -1)
    a = new_a.cumsum()[:-1]
    if np.all(a==n):
        break

print(" ".join([str(x) for x in a]))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int, readline().split())
a = sorted(list(map(int, readline().split())), reverse=True)
b = sorted(list(map(int, readline().split())), reverse=True)
c = sorted(list(map(int, readline().split())), reverse=True)

sums = []
lower = a[min(X-1,20)]+b[min(Y-1,20)]+c[min(Z-1,20)]
b_max,c_max = max(b),max(c)
for i in range(X):
    if a[i]+b_max+c_max<lower:
        break
    for j in range(Y):
        if a[i]+b[j]+c_max<lower:
            break
        for k in range(Z):
            s = a[i]+b[j]+c[k]
            if s<lower:
                break
            sums.append(s)
sums.sort(reverse=True)
for si in sums[:K]:
    print(si)


### FIXED CODE ###

import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int, readline().split())
a = sorted(list(map(int, readline().split())), reverse=True)
b = sorted(list(map(int, readline().split())), reverse=True)
c = sorted(list(map(int, readline().split())), reverse=True)

ab = []
for ai in a:
    for bj in b:
        ab.append(ai+bj)
ab.sort(reverse=True)
ab = ab[:K]
cond = []
for abi in ab:
    for cj in c:
        cond.append(abi+cj)
cond = sorted(cond, reverse=True)[:K]
for condi in cond:
    print(condi)
### BUGGY CODE ###

input()
ns = [n for n in input()]
 
answers = []
first = []
second = []
third = []
third_nums = None
 
for i in range(len(ns) - 2):
  if i in first:
    continue
  else:
    first.append(i)
  for j in range(i+1, len(ns) - 1):
    if ''.join([ns[i], ns[j]]) in second:
      continue
    else:
      second.append(''.join([ns[i], ns[j]]))
      third_nums = set(ns[j+1:])
      for k in third_nums:
        answers.append(''.join([ns[i], ns[j], k]))
print(len(set(answers)))

### FIXED CODE ###

input()
ns = [n for n in input()]
 
scores = 0
first = []
second = []
third = []
third_nums = None
 
for i in range(len(ns) - 2):
  if ns[i] in first:
    continue
  else:
    first.append(ns[i])
  for j in range(i+1, len(ns) - 1):
    if ''.join([ns[i], ns[j]]) in second:
      continue
    else:
      second.append(''.join([ns[i], ns[j]]))
      third_nums = set(ns[j+1:])
      scores += len(third_nums)
      
print(scores)