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

# 15:20
n = int(input())
s = []
for i in range(n):
    s.append(input())
ans = 0
for i in range(n-1):
    L = []
    for j in range(10):
        L.append((s[i][j], s[i].count(s[i][j])))
    L = sorted(L)
    for k in range(i+1,n):
        R = []
        for l in range(10):
            R.append((s[k][l], s[k].count(s[k][l])))
        R = sorted(R)
        if L == R:
            ans += 1
print(ans)


### FIXED CODE ###

# 15:20 -16:08 giveup
# 21:45 -22:33 review
from collections import Counter

# 3
# acornistnt
# peanutbomb
# constraint
n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
# s is ['acinnorstt', 'abbemnoptu', 'acinnorstt']
counter = Counter(s)
# counter is Counter({'acinnorstt': 2, 'abbemnoptu': 1})
# counter.values() is dict_values([3, 2])
ans = sum(x*(x-1)//2 for x in counter.values())
print(ans)
### BUGGY CODE ###

from collections import deque


n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre




pre = dfs(graph, 0, n-1)
route = [n-1]
while route[0]!=0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)



def dfs_cnt(graph, start):
    que = deque([start])
    visited = [0] * n
    visited[start] = 1
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if visited[nxt] != 1:
                que.append(nxt)
                visited[nxt] = 1
    return sum(visited)


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt


if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')
### BUGGY CODE ###

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

def solve(i, m_i):
    if m_i == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m_i) or solve(i + 1, m_i - a[i])
    return res

for m_tmp in m:
    if solve(0, m_tmp):
        print("yes")
    else:
        print("no")

### FIXED CODE ###

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

def solve(i, m_i):
    if m_i == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m_i) or solve(i + 1, m_i - a[i])
    return res

for m_tmp in m:
    if sum(a) < m_tmp:
        print("no")
    elif solve(0, m_tmp):
        print("yes")
    else:
        print("no")
### BUGGY CODE ###

# -*- coding: utf-8 -*-
inf = 10**50
n,m = map(int, input().split())

ea = []
eb = []
cost = []

for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    ea.append(a)
    eb.append(b)
    cost.append(-c)

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            update = True
    if not update:
        break

ans = d[n-1]
negative = [False for _ in range(n)]
for _ in range(n):
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            negative[b] = True
        if negative[a]:
            negative[b] = True
# print(d)
if negative[n-1]:
    print("inf")
else:
    print(-ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
inf = 10**50
n,m = map(int, input().split())

ea = []
eb = []
cost = []

for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    ea.append(a)
    eb.append(b)
    cost.append(-c)

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            update = True
    if not update:
        break

ans = d[n-1]
negative = [False for _ in range(n)]
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            if not negative[b]:
                update = True
            negative[b] = True
        if negative[a] and not negative[b]:
            negative[b] = True
            update = True
    if not update:
        break
# print(d)
if negative[n-1]:
    print("inf")
else:
    print(-ans)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    num = int(input())
    if num in A:
        A.remove(num)
    else:
        A.append(num)

print(len(A))

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
dic = {}
for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i in dic.keys():
    if dic[i] % 2 == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([True]*(max_num))

if n == 1:
    print(1)
elif np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        if dp[i]:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
            if np.count_nonzero(a==i) >1:
                dp[i] = False
    print(np.count_nonzero(dp[np.unique(a)] == True))

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if n == 1:
    print(1)
elif np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))
### BUGGY CODE ###

# coding: UTF-8
def solve(i, goal):
    # to decrese goal
    # then return boolean
    if goal == 0:
        return True
    elif i == n:
        return False
    else:
        return solve(i + 1, goal) or solve(i + 1, goal - A[i])

n = input() # parts total
A = map (int, raw_input().split()) # parts
q = input() # goal total
M = map (int, raw_input().split()) # goal

for j in range(q):
    if solve(0, M[j]): # default
        print "yes"
    else:
        print "no"

### FIXED CODE ###

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    res = (solve(i+1, m) or solve(i+1, m-A[i]))
    return res

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

for m in M:
    if solve(0, m):
        print "yes"
    else:
        print "no"
### BUGGY CODE ###

s = input()
cube = s
ans = len(s)
while True:
    cube = cube.replace('01','').replace('10','')
    if ('01' not in cube) and ('10' not in cube):
        ans -= len(cube)
        break
print(ans)

### FIXED CODE ###

s = list(input())
print(len(s) - (abs(s.count('0')-s.count('1'))))
### BUGGY CODE ###

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


### FIXED CODE ###

S = input()[::-1]
N = len(S)
amari = [0 for i in range(2019)]
before = int(S[0])
amari[before] += 1
S = S[1::]
keta = 1
for i in S:
    i = int(i)
    keta = (keta * 10) % 2019
    x = (keta * i + before) % 2019
    amari[x] += 1
    before = x
ans = amari[0]
for i in amari:
    ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

from bisect import bisect_left
n = int(input())
llist = list(map(int, input().split()))

llist.sort()
res = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        num = llist[i] + llist[j] 
        idx = bisect_left(llist, num, lo=j+1, hi=n)
        res += idx - j - 1

print(res)

### FIXED CODE ###

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

llist.sort()
res = 0
for i in range(n-2):
    prev = n-1
    for j in range(n-2,i,-1):
        for k in range(prev, j, -1):
            if llist[k] < llist[i] + llist[j]:
                res += k - j
                prev = k
                break            
print(res)
### BUGGY CODE ###

import sys
from collections import deque


input = sys.stdin.readline

def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    M = max(max(A), 1).bit_length()
    A = iter(deque(bin(a)[2:]) for a in A)
    B = [0] * M
    p = 10 ** 9 + 7
    ans = 0

    for n in range(N):
        a = next(A)
        for i in range(len(a)):
            B[i] += int(a.pop())

    for i, b in enumerate(B):
        tmp = b * (N - b) * 2 ** i
        tmp %= p
        ans = ans + tmp
        ans %= p

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np


input = sys.stdin.readline

def main():
    N = int(input().rstrip())
    A = np.array(input().rstrip().split(), dtype=np.int64)
    M = 60
    p = 10 ** 9 + 7
    ans = 0

    for m in range(M):
        B = (A >> m) & 1
        x = np.count_nonzero(B)
        x *= N-x
        
        x *= 2 ** m
        x %= p
        ans += x

    print(ans % p)


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

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

for i in range(M):
    B,C = map(int,input().split())
    A += [C]*B
A.sort()
print(sum(A[-N:]))

### FIXED CODE ###

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

L = []
for i in range(M):
    bc = tuple(map(int,input().split()))
    L.append(bc)

L = sorted(L,key=lambda x:-x[1])
n = 0
for b,c in L:
    n += b
    A += [c] * b
    if n >= N:
        break
        
A.sort()
print(sum(A[-N:]))
### BUGGY CODE ###

N, M = map(int, input().split())
mod = 10**9 + 7
# 一個数列が決まった場合に、その数列と同じ数字が同じ場所にあるものが禁止される。


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


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 modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)


MPN = [0]*M
MPN[0] = M
for i in range(M-1, 0, -1):
    MPN[M - i] = MPN[M-1-i]*i % mod

ans = MPN[N-1]
# print(ans)
prev = 1
ansB = M-1

for i in range(1, N):
    tmp = (prev)*i

    tmp2 = ansB - tmp
    # print(tmp2)

    ansB = tmp * (M-i) + (tmp2)*(M-i-1)
    # print(tmp, tmp2)
    # ansB = tmp + tmp2
    ansB %= mod
    prev = tmp2
    # print(ansB)
# print(ansB)

print((ans*ansB) % mod)


### FIXED CODE ###

N, M = map(int, input().split())
mod = 10**9 + 7

ans = M
for i in range(M-1, M-N, -1):
    ans = ans*i % mod


# print(ans)
prev = 1
ansB = M-1


for i in range(1, N):
    tmp = (prev)*i % mod
    tmp2 = ansB - tmp % mod
    # print(tmp2)
    ansB = tmp * (M-i) % mod
    ansB += (tmp2)*(M-i-1) % mod
    # print(tmp, tmp2)
    # ansB = tmp + tmp2
    ansB %= mod
    prev = tmp2
    # print(ansB)

# print(ansB)

print((ans*ansB) % mod)
### BUGGY CODE ###

from collections import Counter
from math import factorial
Q = 10**9+7
def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac

def combination(a,b):
    return ( (factorial(a)//factorial(b))//factorial(a-b))%Q
N, M = map( int, input().split())
C = Counter( primes(M))
ans = 1
if N == 1:
    print(1)
else:
    for x in C:
        ans = (ans * combination(C[x]+N-1,N-1))%Q
    print(ans)


### FIXED CODE ###

from collections import Counter
from math import factorial
Q = 10**9+7
def primes(n):
    primfac = [0]
    d = 2
    while d*d <= n:
        while n%d == 0:
            primfac[-1] += 1
            n //= d
        d += 1
        if primfac[-1] != 0:
            primfac.append(0)
    if n > 1:
        if primfac[-1] == 0:
            primfac[-1] += 1
        else:
            primfac.append(1)
    return primfac
def combination(a,b):
    return ( (factorial(a)//factorial(b))//factorial(a-b))%Q
N, M = map( int, input().split())
C = primes(M)
ans = 1
if N == 1:
    print(1)
else:
    for x in C:
        ans = (ans * combination(x+N-1,N-1))%Q
    print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

ans = A
for k in range(K):
    temp = [0 for _ in range(N)]
    for i in range(N):
        a = ans[i]
        temp[max(i-a, 0)] += 1
        if i + a + 1 < N:
            temp[i+a+1] -= 1

    ans[0] = temp[0]
    for j in range(1, N):
        ans[j] = ans[j-1] + temp[j]

    if ans.count(N) == N:
        break

for i in range(N):
    print(ans[i], end=" ")

### FIXED CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

ans = A
for k in range(K):
    temp = [0 for _ in range(N)]
    for i in range(N):
        a = ans[i]
        temp[max(i-a, 0)] += 1
        if i + a + 1 < N:
            temp[i+a+1] -= 1

    ans[0] = temp[0]
    for j in range(1, N):
        ans[j] = ans[j-1] + temp[j]

    if ans.count(N) == N:
        break

for i in range(N):
    print(ans[i], end=" ")
### BUGGY CODE ###

import collections
N = int(input())
l = []
for i in range(N):
  s = input()
  ls = []
  for j in range(10):
    ls.append(s[j])
  c = collections.Counter(ls)
  l.append(c)
cnt = 0
for i in range(N):
  for j in range(i+1,N):
    if l[i] == l[j]:
      cnt += 1
print(cnt)        

### FIXED CODE ###

import collections
N = int(input())
l = []
for i in range(N):
  s = input()
  ls = []
  for j in range(10):
    ls.append(s[j])
  ls.sort()
  sm = ""
  for j in range(10):
    sm += ls[j]
  l.append(sm)

cnt = 0
c = collections.Counter(l)
for i in c.values():
  cnt += i*(i-1)//2
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N % 2 == 1 :
  print (0)
  exit()
  
ans = 1
for i in range(1, N+1) :
  if i % 2 == 0 :
    ans *= i
    #print (i)

cnt = 0
s = str(ans)
for i in range(len(s)) :
  if s[len(s)-i-1] == "0" :
    cnt += 1
  else :
    break
print (cnt)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
  exit()
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
  print (cnt)
### BUGGY CODE ###

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
num=lcm_list(a)
ans=0
for tmp in a:
    ans+=num//tmp
print(ans%(10**9+7))

### FIXED CODE ###

import sys
input=sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
num=lcm_list(a)
ans=0
for tmp in a:
    ans+=num//tmp
print(ans%(10**9+7))
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])
### BUGGY CODE ###

def fact(n, factors):
    rtn = factors
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            if i in rtn:
                rtn[i] = max(rtn[i],cnt)
            else:
                rtn[i] = cnt

    if temp!=1:
        if temp in rtn:
            rtn[temp] = max(rtn[temp],1)
        else:
            rtn[temp] = 1

    return rtn

def lcm(factors,MOD):
    # 素因数分解をもとにarr全体のLCMを求める
    lcm = 1
    for k,v in factors.items():
        lcm *= pow(k,v,MOD)
    return lcm

def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10**9+7
    # 方針.A全体のlcmをLとすると、ans=Σ(i=[0,N])x/Ai
    ans = 0
    factors = {}
    for a in A:
        factors = fact(a,factors)
    L = lcm(factors,MOD)
    for a in A:
        ans += (L//a)%MOD
        ans %= MOD
    print(ans)

main()


### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=pow(10,9)+7
    lcma={}
    for ai in a:
      f=factorization(ai)
      for fi in f:
        if fi[0] in lcma:
          lcma[fi[0]]=max(lcma[fi[0]],fi[1])
        else:
          lcma[fi[0]]=fi[1]
    l=1
    for k,v in lcma.items():
      l*=pow(k,v,mod)
      l%=mod
    ans=0
    for ai in a:
      ans+=l*pow(ai,mod-2,mod)
      ans%=mod
    print(ans)

main()
### BUGGY CODE ###

def main():
    N=int(input())
    a=[]
    for i in range(N):
        a.append(list(map(int,input().split())))
    mod=10**9+7
    
    dp=[0]*(2**N)
    dp[0]=1
    for i in range(1,2**N):
        m=bin(i).count("1")
        for j in range(N):
            if i>>j&1==1:
                dp[i]+=dp[i-2**j]*a[m-1][j]
        dp[i]%=mod
    
    print(dp[-1])

if __name__=="__main__":
    main()

### FIXED CODE ###

def main():
    N=int(input())
    a=[]
    for i in range(N):
        a.append(list(map(int,input().split())))
    mod=10**9+7

    dp=[0]*(2**N)
    dp[0]=1
    for i in range(1,2**N):
        m=[j for j in range(N) if i>>j &1==1]
        for j in m:
            dp[i]+=dp[i-2**j]*a[len(m)-1][j]
        dp[i]%=mod
    
    print(dp[-1])

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

n = int(input())
lis = []
count = 0
for _ in range(n):
    i = input()
    if not i in lis:
        count += 1
        lis.append(i)
print(count)

### FIXED CODE ###

n = int(input())
lis = set()
count = 0
for _ in range(n):
    lis.add(input())

print(len(lis))
### BUGGY CODE ###


n = int(input())
v = []
for i in range(n+1):
    v.append([])

colorv = [None] * (n+1)

for i in range(n-1):
    a,b = map(int, input().split())
    v[a].append([b,i])
    v[b].append([a,i])

for cur in range(1, n+1):

    #print("cur", cur)

    used = [False] * (n+1)

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is None:
            continue
        #print(" line", linenum, "is", colorv[linenum])
        used[colorv[linenum]] = True

    ncolor = 1

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is not None:
            continue
        while used[ncolor] is True:
            ncolor += 1
        colorv[linenum] = ncolor
        #print(" set line", linenum, "is", ncolor)
        used[ncolor] = True

print(max(colorv[:-2]))
for i in range(n-1):
    print(colorv[i])



### FIXED CODE ###


n = int(input())
v = []
for i in range(n+1):
    v.append([])

colorv = [None] * (n+1)

for i in range(n-1):
    a,b = map(int, input().split())
    v[a].append([b,i])
    v[b].append([a,i])

for cur in range(1, n+1):

    #print("cur", cur)

    used = dict()

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is None:
            continue
        #print(" line", linenum, "is", colorv[linenum])
        used[colorv[linenum]] = True

    ncolor = 1

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is not None:
            continue
        while ncolor in used:
            ncolor += 1
        colorv[linenum] = ncolor
        #print(" set line", linenum, "is", ncolor)
        used[ncolor] = True

print(max(colorv[:-2]))
for i in range(n-1):
    print(colorv[i])
### BUGGY CODE ###

N = int(input())
S = list(str(input()))
from collections import Counter

ans = 0
for i in range(N-1):
    for j in range(i, N):
        if S[i]==S[j]:
            continue
        c = Counter(S[j:])
        c_lis = ['R', 'G', 'B']
        c_lis.remove(S[i])
        c_lis.remove(S[j])
        chara = c_lis[0]
        ans += c[chara]
        try:
            if S[i+(j-i)*2]==chara:
                ans-=1
        except:
            pass
print(ans)

### FIXED CODE ###

N = int(input())
S = list(str(input()))
from collections import Counter

c = Counter(S)
ans = c['B']*c['G']*c['R']
for i in range(N-1):
    for j in range(i, N):
        if S[i]==S[j]:
            continue
        elif i+(j-i)*2>N-1:
            break
        s = S[i+(j-i)*2]
        if s!=S[i] and s!=S[j]:
            ans -= 1
print(ans)