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

N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=N-AC_check.count(None)

for i in range(1, N+1):
    if AC_check[i-1]!=None:
        #AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

### FIXED CODE ###

N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)
### BUGGY CODE ###

n = int(input())
a = input().split()

flag = True
if n % 2 == 0:
    for i in range(int(n/2)):
        if a.count(str(i*2 + 1)) == 2:
            pass
        else:
            flag = False
            break
    ans = 2**(n/2) % (10**9 + 7)

else:  # n % 2 == 1
    if a.count('0') == 1:
        for i in range(int((n - 1) / 2)):
            if a.count(str((i + 1) * 2)) == 2:
                pass
            else:
                flag = False
                break
    else:
        flag = False

    ans = 2**((n-1)/2) % (10**9 + 7)

if flag:
    print(int(ans))
else:
    print(0)


### FIXED CODE ###


from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n // 2
ca = Counter(a)

if n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
elif n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
else:
    print(0)
### BUGGY CODE ###

K,S=input().split()
K,S=[int(K),int(S)]
a=0
for X in range(K+1):
    for Y in range(K+1):
        Z=S-X-Y
        if 0<=Z<=K and X+Y+Z==S:
           a+=1 
print(a)

### FIXED CODE ###

K,S=input().split()
K,S=[int(K),int(S)]
a=0
for X in range(K+1):
    for Y in range(K+1):
        Z=S-X-Y
        if 0<=Z<=K:
           a+=1 
print(a)
### BUGGY CODE ###

import numpy as np
N = int(input())
S = input()
length = len(S)
l = list()
for n in range(length-2):
    for m in range(n+1,length):
        for k in range(m+1, length):
            s = S[n]+S[m]+S[k]
            l.append(s)
print(len(np.unique(l)))


### FIXED CODE ###

import numpy as np
from collections import Counter
N = int(input())
S = input()
length = len(S)
first = list()
res = 0
for n in range(length-2):
    if S[n] not in first:
        first.append(S[n])
    else:
        continue
    second = list()
    for m in range(n+1, length-1):
        if S[m] not in second:
            second.append(S[m])
        else:
            continue
        third = list()
        for k in range(m+1, length):
            if S[k] not in third:
                third.append(S[k])
            else:
                continue
            res += 1
print(res)
### BUGGY CODE ###

import bisect
import sys

input = sys.stdin.readline

n, m, q = map(int, input().split())
ls = [[] for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    ls[l - 1].append(r - l)
for i in range(n):
    ls[i].sort()
for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    res = 0
    for i in range(min(r - l + 1, n - l)):
        res += bisect.bisect(ls[l + i], r - l - i)
    print(res)

### FIXED CODE ###

import itertools
import sys

input = sys.stdin.readline

n, m, q = map(int, input().split())
ls = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    ls[l - 1][r - l] += 1
for i in range(n):
    ls[i] = list(itertools.accumulate(ls[i]))
for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    res = 0
    for i in range(r - l + 1):
        res += ls[l + i][r - l - i]
    print(res)
### BUGGY CODE ###

import math

def f(A,B,x):
    return math.floor(A*x/B) - A*math.floor(x/B)

A,B,N = map(int,input().split())
ans = 0
for x in range(B//A , N+1):
    n = f(A,B,x)
    if n > ans:
        ans = n

print(ans)
        

### FIXED CODE ###

import math
def f(A,B,x):
    return math.floor(A*x/B) - A*math.floor(x/B)

A,B,N = map(int,input().split())
x = min(N,B-1)
print(f(A,B,x))
### BUGGY CODE ###

N , K = map(int,input().split())
Lum = [a for a in map(int,input().split())]

for i1 in range(K):
    B = [0 for i in range(N)]
    for i in range(N):
        for j in range(max(0,i-Lum[i]),min(i+Lum[i]+1,N)):
            B[j]+=1
    Lum = B

Lum = [str(l) for l in Lum]
Lum=" ".join(Lum)
print(Lum)


### FIXED CODE ###

import numpy as np
from numba import jit 
N , K = map(int,input().split())
Lum = np.array(list(map(int,input().split())))

@jit("i8,i8,i8[:]")
def fn(N,K,A):
    K1 = min(K,41)
    for i1 in range(K1):
        B = np.zeros(N,dtype=np.int64)
        for i in range(N):
            l = max(0,i-A[i])
            r = min(N-1,i+A[i])
            B[l]+=1
            if r+1<N:
                B[r+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]
        A = B
    return A

Lum = list(fn(N,K,Lum))
Lum = [str(l) for l in Lum]
Lum=" ".join(Lum)
print(Lum)
### BUGGY CODE ###

h, w, d = map(int, input().split())
cell = {}
for i in range(h):
  row = list(map(int, input().split()))
  for j, a in enumerate(row):
    cell[a] = (i, j)
max_point = h * w
req_mp = [-1 for _ in range(max_point)]

q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  result = 0
  p = l
  while p < r:
    if req_mp[p] == -1:
      magic = abs(cell[p+d][0] - cell[p][0]) + abs(cell[p+d][1] - cell[p][1])
      req_mp[p] = magic
    result += req_mp[p]
    p += d
  print(result)

### FIXED CODE ###

h, w, d = map(int, input().split())
cell = {}
for i in range(h):
  row = list(map(int, input().split()))
  for j, a in enumerate(row):
    cell[a] = (i, j)

max_point = h * w
req_mp = [0 for i in range(max_point)]
for i in range(max_point):
  if i < d:
    req_mp[i] = 0
  else:
    temp = req_mp[i-d]
    temp += abs(cell[i-d+1][0] - cell[i+1][0])
    temp += abs(cell[i-d+1][1] - cell[i+1][1])
    req_mp[i] = temp

q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  print(req_mp[r-1] - req_mp[l-1])
### BUGGY CODE ###

N = int(input())
S = list(input())
R = []
G = []
B = []
Rsize =0
Gsize =0
Bsize =0
for i in range(0,N,1):
    if S[i] == "R":
        R.append(i)
        Rsize+=1
    elif S[i] == "G":
        G.append(i)
        Gsize+=1
    elif S[i] == "B":
        B.append(i)
        Bsize+=1
counter = 0
for i in range(0,Rsize,1):
    for j in range(0,Gsize,1):
        for k in range(0, Bsize, 1):
            tmp = sorted([R[i],G[j],B[k]])
            if tmp[1]-tmp[0] != tmp[2] - tmp[1]:
                counter+=1

print(counter)

### FIXED CODE ###

N = int(input())
S = list(input())
R = []
G = []
B = []
Rsize =0
Gsize =0
Bsize =0
for i in range(0,N,1):
    if S[i] == "R":
        Rsize+=1
    elif S[i] == "G":
        Gsize+=1
    elif S[i] == "B":
        Bsize+=1
counter = Rsize*Gsize*Bsize
for i in range(0,N-1,1):
    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]:
                counter -=1
print(counter)
### BUGGY CODE ###

inf = 10**9+7
modlist = [1, 10, 9, 12, 3, 4]

S = list(input())
S.reverse()

dp = [[0 for i in range(13)] for j in range(len(S))]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1,len(S)):
    for l in range(10):
        if S[i] != "?" and int(S[i]) != l:
            continue
        for j in range(13):
            dp[i][(l*modlist[i%6]+j)%13] += dp[i-1][j]
            dp[i][(l*modlist[i%6]+j)%13] %= inf

ans = dp[len(S)-1][5]
print(ans)

### FIXED CODE ###

inf = 10**9+7
modlist = [1, 10, 9, 12, 3, 4]

S = list(input())
S.reverse()

dp = [[0 for i in range(13)] for j in range(len(S))]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1,len(S)):
    for l in range(10):
        if S[i] != "?" and int(S[i]) != l:
            continue
        for j in range(13):
            dp[i][(l*modlist[i%6]+j)%13] += dp[i-1][j]
            dp[i][(l*modlist[i%6]+j)%13] %= inf

ans = dp[len(S)-1][5]
print(ans)
### BUGGY CODE ###

MOD = 998244353

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

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

for i in range(N):
    DP[i + 1][0][0] = DP[i][0][0] 
    DP[i + 1][0][1] = DP[i][0][0] + DP[i][0][1]
    a = A[i]
    if a > S:
        for j in range(1, S + 1):
            DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1]) % MOD #以前から合計jになっている場合のみOK
    else:
        for j in range(1, a):
            DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1]) % MOD #以前から合計jになっている場合のみOK
        for j in range(a, S + 1):
            DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1] + DP[i][j - a][0] + DP[i][j - a][1]) % MOD

    DP[i + 1][S][2] = (DP[i][S][1] + DP[i][S][2]) % MOD
    if a <= S:
        DP[i + 1][S][2] += DP[i][S - a][0] + DP[i][S - a][1]
    DP[i + 1][S][2] %= MOD

print (DP[N][S][2])

# for i in range(N + 1):
#     print (DP[i])

### FIXED CODE ###

def main():
    MOD = 998244353

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

    DP0 = [[0] * (S + 1) for _ in range(N + 1)]
    DP1 = [[0] * (S + 1) for _ in range(N + 1)]
    DP2 = [[0] * (S + 1) for _ in range(N + 1)]

    DP0[0][0] = 1

    for i in range(N):
        DP0[i + 1][0] = DP0[i][0] 
        DP1[i + 1][0] = DP0[i][0] + DP1[i][0]
        a = A[i]
        if a > S:
            for j in range(1, S + 1):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
        else:
            for j in range(1, a):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
            for j in range(a, S + 1):
                DP1[i + 1][j] = (DP1[i][j] + DP0[i][j - a] + DP1[i][j - a]) % MOD
                # DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1] + DP[i + 1][j - a][1]) % MOD

        DP2[i + 1][S] = (DP1[i][S] + DP2[i][S])
        if a <= S:
            DP2[i + 1][S] += DP0[i][S - a] + DP1[i][S - a]
        DP2[i + 1][S] %= MOD

    print (DP2[N][S])

    # for i in range(N + 1):
    #     print (DP[i])

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

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**3
    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()

    N = NI()
    P = LI()

    seat = [[1] * N for _ in range(N)]
    zero = [[1] * N for _ in range(N)]

    ans = 0

    for i in P:
        x = (i-1) % N
        y = (i-1) // N

        dp = [[INF] * N for _ in range(N)]
        d = 0
        q = []
        heapify(q)
        heappush(q,(d,x,y))
        dp[x][y] = 0
        min_cnt = INF
        while q:
            d,i,j = heappop(q)
            for di,dj in ((1,0),(0,1),(-1,0),(0,-1)):
                if not(0 <= i+di < N and 0 <= j+dj < N):
                    break
                if zero[i+di][j+dj] == 0:
                    break
                e = seat[i+di][j+dj]
                if dp[i+di][j+dj] > d+e:
                    dp[i+di][j+dj] = d+e
                    heappush(q,(d+e,i+di,j+dj))
            else:
                continue
            min_cnt = d
            break

        seat[x][y] = 0
        if min_cnt == 0:
            q = collections.deque()
            q.append((x,y))
            zero[x][y] = 0
            while q:
                i,j = q.popleft()
                for di,dj in ((1,0),(0,1),(-1,0),(0,-1)):
                    if not(0 <= i+di < N and 0 <= j+dj < N): continue
                    if seat[i+di][j+dj] == 1 or zero[i+di][j+dj] == 0: continue
                    zero[i+di][j+dj] = 0
                    q.append((i+di,j+dj))
        ans += min_cnt
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    P = LI()

    s = []
    for i in range(N):
        for j in range(N):
            s.append(min(i,N-1-i,j,N-1-j))

    r = [1] * (N*N)

    ans = 0
    q = []
    for p in P:
        p -= 1
        ans += s[p]
        r[p] = 0
        q.append(p)
        while q:
            a = q.pop()
            nc = s[a] + r[a]

            if a >= N:
                if s[a-N] > nc:
                    s[a-N] = nc
                    q.append(a-N)
            if a + N < N*N:
                if s[a+N] > nc:
                    s[a+N] = nc
                    q.append(a+N)
            if a % N:
                if s[a-1] > nc:
                    s[a-1] = nc
                    q.append(a-1)
            if a % N < N -1:
                if s[a+1] > nc:
                    s[a+1] = nc
                    q.append(a+1)

    print(ans)

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

n = int(input())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
ans = 0
a = a[::-1]
b = b[::-1]
for i in range(n):
    if a[i] % b[i] == 0:
        continue
    p = (a[i] // b[i] + 1) * b[i] - a[i]
    ans += p
    for j in range(i, n):
        a[j] += p
print(ans)

### FIXED CODE ###

n = int(input())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
ans = 0
a = a[::-1]
b = b[::-1]
for i in range(n):
    a[i] += ans
    if a[i] % b[i] == 0:
        continue
    ans += (a[i] // b[i] + 1) * b[i] - a[i]
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
N = int(input())
G = [[0]*N for _ in range(N)]
for i in range(N-1) :
    a, b = map(int,input().split())
    G[a-1][b-1] = G[b-1][a-1] = 1

col = [-1]*N
col[0] = 0
stack = [0]
while stack :
    now = stack.pop()
    for i in range(N) :
        if G[now][i] == 1 :
            if col[i] == -1 :
                col[i] = (col[now] + 1)%2
                stack.append(i)

mod0 = [x for x in range(1, N+1) if x%3 == 0]
mod1 = [x for x in range(1, N+1) if x%3 == 1]
mod2 = [x for x in range(1, N+1) if x%3 == 2]

ans = [0 for _ in range(N)]
if sum(col) <= N//3 :
    mods = mod0 + mod1 + mod2
    for i in range(N) :
        if col[i] == 1 :
            ans[i] = mods.pop(0)
        else :
            ans[i] = mods.pop()
elif sum(col) >= 2*N//3 :
    mods = mod0 + mod1 + mod2
    for i in range(N) :
        if col[i] == 0 :
            ans[i] = mods.pop(0)
        else :
            ans[i] = mods.pop()
else :
    mods = mod1 + mod0 + mod2
    for i in range(N) :
        if col[i] == 0 :
            ans[i] = mods.pop(0)
        else :
            ans[i] = mods.pop()

print(*ans)


### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
N = int(input())
G = [[] for _ in range(N)]
for i in range(N-1) :
    a, b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

col = [-1]*N
col[0] = 0
stack = deque([0])
while stack :
    now = stack.pop()
    for i in G[now] :
        if col[i] == -1 :
            col[i] = (col[now] + 1)%2
            stack.append(i)

mod0 = [x for x in range(1, N+1) if x%3 == 0]
mod1 = [x for x in range(1, N+1) if x%3 == 1]
mod2 = [x for x in range(1, N+1) if x%3 == 2]

ans = [0 for _ in range(N)]
if sum(col) <= N//3 :
    mods = deque(mod0 + mod1 + mod2)
    for i in range(N) :
        if col[i] == 1 :
            ans[i] = mods.popleft()
        else :
            ans[i] = mods.pop()
elif sum(col) >= 2*N//3 :
    mods = deque(mod0 + mod1 + mod2)
    for i in range(N) :
        if col[i] == 0 :
            ans[i] = mods.popleft()
        else :
            ans[i] = mods.pop()
else :
    mods = deque(mod1 + mod0 + mod2)
    for i in range(N) :
        if col[i] == 0 :
            ans[i] = mods.popleft()
        else :
            ans[i] = mods.pop()

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

#n = 5
#C = list(map(int,"1 2 3 4 5".split()))
#line = ["1 2", "2 3", "3 4", "3 5"]
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
C = list(map(int,input().split()))
 
ci = [set() for _ in range(n)]
for i,c in enumerate(C):
    ci[c-1].add(i)

path = [set() for _ in range(n)]
 
#line = ["1 2", "2 3"]
    
for i in range(n-1):
    a,b = map(int,input().split())
    #a,b = map(int,line[i].split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        size[p] = 0
        if reached[nxt]:
            continue
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

path = [set() for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        
        if reached[nxt]:
            continue
        size[p] = 0
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)
### BUGGY CODE ###

n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

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

### FIXED CODE ###

n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

for i in range(0, n-2):
    for j in range(i+1, n-1):
        k = j - i + j
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            total -= 1
print(total)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def DFS(v, parent):
  global v_count
  for u in adj[v]:
    if u != parent:
      v_count[u] += v_count[v]
      DFS(u,v)

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

adj = [[] for _ in range(N)]
v_count = [0] * N

for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)# aがbの親とは限らないため

for j in range(Q):
  p, x = map(int, input().split())
  v_count[p-1] += x

# 0起点に親ノードの数字を子ノードに足していく
DFS(0, -1)# 現在のノード, 親ノード
print(*v_count)

### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6)

def DFS(v, parent):
  for u in adj[v]:
    if u != parent:
      v_count[u] += v_count[v]
      DFS(u,v)

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

adj = [[] for _ in range(N)]
v_count = [0] * N

for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)# aがbの親とは限らないため

for j in range(Q):
  p, x = map(int, input().split())
  v_count[p-1] += x

# 0起点に親ノードの数字を子ノードに足していく
DFS(0, -1)# 現在のノード, 親ノード
print(*v_count)
### BUGGY CODE ###

N = int(input())
S = list(map(str,input()))

ans = 0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            if j-i==k-j:
                continue
            else:
                if S[i]==S[j] or S[i]==S[k] or S[k]==S[j]:
                    continue
                else:
                    ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
S = list(map(str,input()))

r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r+=1
    elif S[i] == "G":
        g+=1
    else:
        b+=1
ans = 0
for i in range(N):
    for j in range(1,N//2+2):
        if i+2*j < N:
            if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
                ans +=1

print(r*g*b-ans)
### BUGGY 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


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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()
s = S()
cnt = 0
for i in range(10 ** 3):
    flag = 0
    for j in range(n):
        for k in range(3):
            if flag == k and str(i).zfill(3)[k] == s[j]:
                flag += 1
                break
        if flag == 3:
            cnt += 1
            break


print(cnt)

### 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


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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()
s = S()
cnt = 0
ans = set()
one_digit_set = set()
two_digit_set = set()
for i in range(n):
    for two_d in two_digit_set:
        ans.add(s[i] + two_d)
    for one_d in one_digit_set:
        two_digit_set.add(s[i] + one_d)
    one_digit_set.add(s[i])


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

I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))
A.sort(reverse = True)
for i in range(M):
    A[0] = A[0] / 2
    A.sort(reverse = True)
ans = 0
for i in range(N):
    ans += int(A[i])
print(ans)

### FIXED CODE ###

import heapq
import math
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(lambda x:-x,map(int,input().split())))
heapq.heapify(A)
for i in range(M):
    num = heapq.heappop(A)
    num = math.ceil(num / 2)
    heapq.heappush(A,num)

print(-sum(A))