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

import itertools

n = int(input())

arr = []
for i in range(n):
	arr.append(raw_input())

count = 0

for combs in list(itertools.combinations(range(n),3)):
	rest = 'MARCH'
	c = 0
	for i in combs:
		if arr[i][0] in rest:
			rest = rest.replace(arr[i][0],'')
			c += 1
		else :
			break

	if c == 3:
		count += 1

print count


### FIXED CODE ###

import itertools
n = int(raw_input())

d = {'M':0,'A':0,'R':0,'C':0,'H':0}

for i in range(n):
	s = raw_input()
	if d.has_key(s[0]):
		d[s[0]] += 1

count = 0

for comb in list(itertools.combinations(d.keys(),3)):
	count += d[comb[0]]* d[comb[1]]*d[comb[2]]

print count
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
lst = []
num = [1]*n
ans = 0
lst_append = lst.append
s_all = [sorted(input()) for _ in range(n)]
for s in s_all:
    if s not in lst:
        lst_append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

### FIXED CODE ###

from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)
### BUGGY CODE ###

n = int(input())
sl = [input() for _ in [0]*n]
for i in range(len(sl)):
  sl[i] = sorted(sl[i])
  sl[i] = ''.join(sl[i])
count = 0
sl.sort()
while len(sl)>1:
  i = 1
  flag = True
  while flag:
    if sl[-1] == sl[-(i+1)]:
      i += 1
      if i == len(sl):
        flag=False
    else:
      flag = False
  if i>1:
    count += i*(i-1)//2
  sl = sl[:-i]
  flag=True
print(count)

### FIXED CODE ###

n = int(input())
sl = sorted([''.join(sorted(input())) for _ in [0]*n])
count = 0
while len(sl)>1:
  i = 1
  flag = True
  while flag:
    if sl[-1] == sl[-(i+1)]:
      i += 1
      if i == len(sl):
        flag=False
    else:
      flag = False
  if i>1:
    count += i*(i-1)//2
  del sl[-i:]
  flag=True
print(count)
### BUGGY CODE ###

from collections import deque
N,Q=map(int,input().split())
nondirtree=[[] for _ in range(N)]
dirtree=[[] for _ in range(N)]
rootflag=[0]*N
rootflag[0]=1
for i in range(N-1):
    a,b=map(int,input().split())
    nondirtree[a-1].append(b-1)
    nondirtree[b - 1].append(a - 1)
points=[list(map(int,input().split())) for _ in range(Q)]
#print(points)
v=0
d=deque()
d.append(v)
seen=[0]*N
seen[0]=1
score=[0]*N
ans=[0]*N
while len(d)!=0:
    v=d.popleft()
    for j in nondirtree[v]:
        if seen[j]==0:
            dirtree[v].append(j)
            seen[j]=1
            d.append(j)
    #print(d,seen,dirtree)
    #input(
#print(dirtree)
for i in range(Q):
    score[points[i][0]-1]=score[points[i][0]-1]+points[i][1]
#print(score)
v=0
d=deque()
d.append(v)
dirtree=tuple(dirtree)
ans[0]=score[0]
while len(d)!=0:
    v=d.popleft()
    for j in dirtree[v]:
        ans[j]=ans[v]+score[j]
        d.append(j)
    #input()
    #print(ans)
print(*ans,sep=" ")


### FIXED CODE ###

from collections import deque
N,Q=map(int,input().split())
nondirtree=[[] for _ in range(N)]
dirtree=[[] for _ in range(N)]
rootflag=[0]*N
rootflag[0]=1
for i in range(N-1):
    a,b=map(int,input().split())
    nondirtree[a-1].append(b-1)
    nondirtree[b - 1].append(a - 1)
points=[list(map(int,input().split())) for _ in range(Q)]
#print(points)
v=0
d=deque()
d.append(v)
seen=[0]*N
seen[0]=1
score=[0]*N
ans=[0]*N
while len(d)!=0:
    v=d.popleft()
    for j in nondirtree[v]:
        if seen[j]==0:
            dirtree[v].append(j)
            seen[j]=1
            d.append(j)
    #print(d,seen,dirtree)
    #input(
#print(dirtree)
for i in range(Q):
    score[points[i][0]-1]=score[points[i][0]-1]+points[i][1]
#print(score)
v=0
d=deque()
d.append(v)
ans[0]=score[0]
while len(d)!=0:
    v=d.popleft()
    for j in dirtree[v]:
        ans[j]=ans[v]+score[j]
        d.append(j)
    #input()
    #print(ans)
print(*ans,sep=" ")
### BUGGY CODE ###

N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)		
print(min(abs_list))	

### FIXED CODE ###

N=int(input())
a=list (map(int,input().split()))
abs_list=[]
c=0
for i in range(N):
	c=(a[i]-(i+1))
	abs_list.append(c)
abs_list.sort()
b=abs_list[int(N/2)]	
d=0
for i in range(N):
	d=abs(abs_list[i]-b)+d		
print(d)
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

# 迷路読み込み
H,W = map(int, input().split())
c1,c2= map(int, input().split())
d1,d2= map(int, input().split())
A=[list(input()) for i in range(H)]
edges = [[] for i in range(H * W)]

for i in range(H):
    for j in range(W):
        for di in range(-2,3):
            for dj in range(-2, 3):
                ni, nj = i + di, j + dj
                if 0 <= ni < H and 0 <= nj < W and A[i][j]!='#' and A[ni][nj]!='#':
                    if di==0 and dj==0:
                        continue
                    elif (di==0 and dj==1) or (di==1 and dj==0) or (di==-1 and dj==0) or (di==0 and dj==-1):
                        edges[i * W + j].append((ni * W + nj,0))
                    else:
                        edges[i * W + j].append((ni * W + nj,1))


#ダイクストラ法
from heapq import heappush, heappop

def dijkstra(edges, size, source):
    # edge=探索するグラフ
    # size=グラフの点の数
    # source=スタート点
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance[g]

s=(c1-1)*W+(c2-1)
g=(d1-1)*W+d2-1
ans=dijkstra(edges,H*W,s)
if ans==float('inf'):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

# 迷路読み込み
H,W = map(int, input().split())
c1,c2= map(int, input().split())
d1,d2= map(int, input().split())
A=[list(input()) for i in range(H)]
edges = [[] for i in range(H * W)]

for i in range(H):
    for j in range(W):
        for di in range(-2,3):
            for dj in range(-2, 3):
                ni, nj = i + di, j + dj
                if 0 <= ni < H and 0 <= nj < W and A[i][j]!='#' and A[ni][nj]!='#':
                    if di==0 and dj==0:
                        continue
                    elif (di==0 and dj==1) or (di==1 and dj==0) or (di==-1 and dj==0) or (di==0 and dj==-1):
                        edges[i * W + j].append((ni * W + nj,0))
                    else:
                        edges[i * W + j].append((ni * W + nj,1))

s=(c1-1)*W+c2-1
g=(d1-1)*W+d2-1
dist = [10**9]*(H*W)
dist[s] = 0
que = deque()
que.append(s)

while len(que) > 0:
    i = que.popleft()
    for j, c in edges[i]:
        d = dist[i] + c
        if d < dist[j]:
            dist[j] = d
            if c == 1:
                que.append(j)
            else:
                que.appendleft(j)


ans=dist[g]
if ans==pow(10,9):
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

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

ans = 1

for a in A:
    ans *= a

if (ans > 1000000000000000000):
    print('-1')
else:
    print(ans)


### FIXED CODE ###

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

ans = 1

has_zero = False
for a in A:
    if a == 0:
        has_zero = True

# print("here?")

for a in A:
    # print("here?2")
    # print(a)
    ans *= a
    if ans > 1000000000000000000:
        ans = -1
        break

if has_zero is True:
    print('0')
else:
    print(ans)
### BUGGY CODE ###

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

MOD = 998244353

A.sort()
s = 0
for idx, a in enumerate(A):
    s += a
    if s > S:
        break
idx += 1

dp = [[0] * (idx + 1) for _ in range(S + 1)]
dp[0][0] = 1

for i in range(N):
    a = A[i]
    for j in range(S, -1, -1):
        for k in range(idx, -1, -1):
            here = dp[j][k]
            if j + a <= S and k + 1 <= idx:
                dp[j + a][k + 1] += here

cnt = 0
K = dp[-1]
for i, c in enumerate(K):
    cnt += c * (pow(2, N - i, MOD))
    cnt %= MOD

print(cnt)


### FIXED CODE ###

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

MOD = 998244353

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    ai = A[i]
    for j in range(S + 1):
        here = dp[i][j]
        # aiがTに含まれない
        dp[i + 1][j] += here
        # aiがTに含まれるが, Uに含まれない
        dp[i + 1][j] += here

        dp[i + 1][j] %= MOD

        # aiがUに含まれる
        if j + ai <= S:
            dp[i + 1][j + ai] += dp[i][j]
            dp[i + 1][j + ai] %= MOD

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

N,W = map(int,input().split())
weight = []
value = []

for _ in range(N):
  w,v = map(int,input().split())
  weight.append(w)
  value.append(v)

def knapsack(n,w):
  if w >W:
    return -1000
  if n >= len(weight):
    return 0
  return max(knapsack(n+1,w),knapsack(n+1,w+weight[n])+value[n])
print(knapsack(0,0))

### FIXED CODE ###

def dynamicprogramming():
  N, W = map(int, input().split())
  dp = [-1] * (W + 1)
  dp[0] = 0
  for _ in range(N):
    w, v = map(int, input().split())
    for i in range(W - w, -1, -1):
        dpi = dp[i]
        if dpi != -1:
          if dp[i + w] < dpi + v:
            dp[i + w] = dpi + v
  print(max(dp))

dynamicprogramming()
### BUGGY CODE ###

n = int(input())
ary = [int(i) for i in input().split()]

pr = 1
for i in range(n):
  pr *= ary[i]

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

### FIXED CODE ###

def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

    from math import log2
    lt = log2(10**18)

    if ary[0] == 0:
        print(0)
        return
      
    if any(log2(ary[i]) > lt / (n-i) for i in range(n)):
        print('-1')

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

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h,w = map(int,input().split())
s = [list(input().strip()) for _ in range(h)]
l = [[0]*w for _ in range(h)]
r = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
d = [[0]*w for _ in range(h)]
for i in range(h):
  c1 = 0
  c2 = 0
  for j in range(w):
    if s[i][j] == "#":
      c1 = 0
    else:
      c1 += 1
      l[i][j] = c1
    if s[i][w-j-1] == "#":
      c2 = 0
    else:
      c2 += 1
      r[i][w-j-1] = c2
for j in range(w):
  c1 = 0
  c2 = 0
  for i in range(h):
    if s[i][j] == "#":
      c1 = 0
    else:
      c1 += 1
      u[i][j] = c1
    if s[h-i-1][j] == "#":
      c2 = 0
    else:
      c2 += 1
      d[h-i-1][j] = c2
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)

### FIXED CODE ###

import sys
import numpy as np
input = sys.stdin.readline
h,w = map(int,input().split())
s = (np.array([list(input().strip()) for _ in range(h)])==".").astype(np.int)
l,r,u,d = s.copy(),s.copy(),s.copy(),s.copy()
for i in range(1,w):
  l[:,i] *= l[:,i-1] + 1
  r[:,w-i-1] *= r[:,w-i] + 1

for i in range(1,h):
  u[i] *= u[i-1] + 1
  d[h-i-1] *= d[h-i] + 1
print(max([max(i) for i in l+r+u+d-3]))
### BUGGY CODE ###

class Combination:
    def __init__(self, size, MOD):
        self.MOD = MOD
        self.size = size + 2

        f = 1
        self.fact = fact = [f]
        for i in range(1, size+1):
            f = f * i % MOD
            fact.append(f)
        f = pow(f, MOD-2, MOD)
        self.factInv = factInv = [f]
        for i in range(size, 0, -1):
            f = f * i % MOD
            factInv.append(f)
        factInv.reverse()

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.MOD) % self.MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

def sol():
    K = int(input())
    N = len(input())
    MOD = 10**9 + 7
    comb = Combination(N + K + 10, MOD)

    ans = 0
    for l in range(K + 1):
        r = K - l
        ans += comb.nhr(N, l) * pow(25, l, MOD) * pow(26, r, MOD)
        ans %= MOD
    print(ans)
sol()

### FIXED CODE ###

MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

K = int(input())
S = input()
N = len(S)

comb = Combination(N + K + 100)

ans = 0
for l in range(K + 1):
    r = K - l
    ans += pow(25, l, MOD) * comb.nhr(N, l) * pow(26, r, MOD)
    ans %= MOD

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

X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 100000):
  for j in range(0, 100000):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))

### FIXED CODE ###

X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(-120, 120):
  for j in range(-120, 120):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = -j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K, Q = map(int, input().split())
    # A = [int(input()) for _ in range(Q)]
    # print(N, K, Q, A)
    P = [K] * N
    for q in range(Q):
        a = int(input())
        P[a - 1] += 1
        for i in range(N):
            P[i] -= 1

    for p in P:
        if p > 0:
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    main()


### FIXED CODE ###

# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
import numpy as np


def main():
    N, K, Q = map(int, input().split())
    result = np.array([K - Q] * N)
    for _ in range(Q):
        a = int(input())
        result[a - 1] += 1

    for r in result:
        print('Yes'if r > 0 else 'No')


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

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0
pool = [tuple(C)]

while(pool):
    y, x = pool.pop()
    for dx in [-2,-1,0,1,2]:
        for dy in [-2,-1,0,1,2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.append((y+dy, x+dx))
            if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((y+dy, x+dx))

print(V[D[0]][D[1]])


### FIXED CODE ###

from collections import deque

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0

pool = deque()
pool.append(tuple([0, C[0], C[1]]))
while(pool):
    c, y, x = pool.popleft()
    if c != V[y][x]:
        continue
    for dx in [-2, -1, 0, 1, 2]:
        for dy in [-2, -1, 0, 1, 2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.appendleft((c, y+dy, x+dx))
            elif V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((c+1, y+dy, x+dx))
print(V[D[0]][D[1]])
### BUGGY CODE ###

if __name__ == '__main__':
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    answer = 0
    for a in A:
        for b in [b for b in B if b > a]:
            for c in [c for c in C if c > b]:
                answer += 1
    print(answer)

### FIXED CODE ###

import bisect


if __name__ == '__main__':
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    answer = 0
    for b in B:
        answer += (bisect.bisect_left(A, b)) * (N - bisect.bisect_right(C, b))
    print(answer)
### BUGGY CODE ###

import sys

H, W, M = map(int, sys.stdin.readline().strip().split())

h = [0] * H
w = [0] * W

g = [[False] * W for _ in range(H)]

for _ in range(M):
    Th, Tw = map(int, sys.stdin.readline().strip().split())

    h[Th - 1] += 1
    w[Tw - 1] += 1

    g[Th - 1][Tw - 1] = True

ans = max(h) + max(w)

index_h = [n for n, v in enumerate(h) if v == max(h)]
index_w = [n for n, v in enumerate(w) if v == max(w)]

sub = 1
for ih in index_h:
    for iv in index_w:
        if g[ih][iv] is False:
            sub = 0
            break
    else:
        continue
    break

ans -= sub


print(ans)



### FIXED CODE ###

import sys

H, W, M = map(int, sys.stdin.readline().strip().split())

h = [0] * H
w = [0] * W

# g = [[False] * W for _ in range(H)]
S = set()
for _ in range(M):
    Th, Tw = map(int, sys.stdin.readline().strip().split())

    h[Th - 1] += 1
    w[Tw - 1] += 1

    # g[Th - 1][Tw - 1] = True
    S.add((Th - 1, Tw - 1))

max_h = max(h)
max_w = max(w)
ans = max_h + max_w

index_h = [n for n, v in enumerate(h) if v == max_h]
index_w = [n for n, v in enumerate(w) if v == max_w]

sub = 1
# for ih in index_h:
#     for iv in index_w:
#         if g[ih][iv] is False:
#             sub = 0
#             break
#     else:
#         continue
#     break
# ans -= sub
# print(ans)


for ih in index_h:
    for iv in index_w:
        if not (ih, iv) in S:
            print(ans)
            exit()
print(ans - 1)
### BUGGY CODE ###

import sys
import math
from operator import mul
from functools import reduce
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**9
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 )

x,y= (int(_) for _ in input().split()) 
if (x+y)%3!=0:
    print(0)
    sys.exit()
else:
    n=(x+y)/3
    n=int(n)
    if x<n or y<n:
         print(0)
         sys.exit()
    else:
        x=x-n
        y=y-n
        ans=int(cmb(x+y, x,mod))
        print(ans%1000000007)

### FIXED CODE ###

import sys
import math
from operator import mul
from functools import reduce
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-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 )

x,y= (int(_) for _ in input().split()) 
if (x+y)%3!=0:
    print(0)
    sys.exit()
else:
    n=(x+y)/3
    n=int(n)
    if x<n or y<n:
         print(0)
         sys.exit()
    else:
        x=x-n
        y=y-n
        ans=int(cmb(x+y, x,mod))
        print(ans%1000000007)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100010)

def main():
    def input():
        return sys.stdin.readline()[:-1]

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

    p = list(map(lambda x: int(x)-1, input().split()))
    parent = [k for k in range(N)]

    def find(x):
        if parent[x] == x:
            return x
        else:
            return find(parent[x])

    def unite(x,y):
        parent[find(x)] = find(y)

    for k in range(M):
        x, y = map(int,input().split())
        unite(x-1,y-1)

    ans = 0
    for k in range(N):
        if find(k) == find(p[k]):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(100010)

def main():
    def input():
        return sys.stdin.readline()[:-1]

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

    p = list(map(lambda x: int(x)-1, input().split()))
    parent = [k for k in range(N)]

    def find(x):
        if parent[x] == x:
            return x
        else:
            parent[x] = find(parent[x])
            return find(parent[x])

    def unite(x,y):
        parent[find(x)] = find(y)

    for k in range(M):
        x, y = map(int,input().split())
        unite(x-1,y-1)

    ans = 0
    for k in range(N):
        if find(k) == find(p[k]):
            ans += 1
    print(ans)

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



def popcnt(n):
    return bin(n).count("1")

def f(n):
    k = n
    cnt = 0
    while k>0:
        k = k%popcnt(k)
        cnt+= 1
    return cnt

def solve(X):
    for i in reversed(range(N)):
        if P[N-1-i] == 0:
            print(0)
        else:
            K = X ^ (1 << i)
            K2 = K%P[N-1-i]
            print(f(K2) + 1)




N = int(input())
X = input()
X = X.zfill(N)
count_1 = X.count("1")

P = [0]*N
for i in range(N):
    if X[i] == "1":
        P[i] = count_1 - 1
    else:
        P[i] = count_1 + 1
Y = int(X,2)

solve(Y)

### FIXED CODE ###

def popcnt(n):
    return bin(n).count("1")

def f(n):
    cnt = 0
    while n>0:
        n = n%popcnt(n)
        cnt += 1
    return cnt

def solve(X):
    Y = int(X, 2)
    c = X.count("1")
    m, p = c-1, c+1
    Ym, Yp = Y%m if m else -1, Y%p
    for i in range(N):
        if X[i] == "1":
            Y = (Ym - pow(2,N-i-1,m))%m if Ym!=-1 else -1
        else:
            Y = (Yp + pow(2,N-i-1,p))%p
        print(f(Y) + 1 if Y!=-1 else 0)

N = int(input())
solve(input())
### BUGGY CODE ###

import bisect
N = int(input())
l = [int(x) for x in input().split()]
l.sort()
ans = 0
for i in range(1,N-1):
  for j in range(i+1, N):
    a = l[:-j]
    L = len(a)
    Min = l[-j]-(l[-i]-1)
    Max = (l[-i]+1) - l[-j]
    n = max(bisect.bisect_left(a, Min), bisect.bisect_left(a, Max))
    ans += (L - n)
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
from bisect import bisect_left
for i in range(n-2):
  for j in range(i+1, n-1):
    ab = l[i] + l[j]
    idx = bisect_left(l, ab)
    ans += max(idx-j-1, 0)
print(ans)