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

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

R,G,B=[],[],[]
for i,s in enumerate(S):
    if s=='R': R.append(i+1)
    elif s=='G': G.append(i+1)
    else: B.append(i+1)

ans=0
for r in R:
    for g in G:
        for b in B:
            i=min(r,g,b)
            k=max(r,g,b)
            j=r+g+b-(i+k)
            if j-i!=k-j: ans+=1
print(ans)

### FIXED CODE ###

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

r,g,b=0,0,0
for s in S:
    if s=='R': r+=1
    elif s=='G': g+=1
    else: b+=1


ng=0
for i in range(N):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>=N: continue
        if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]:
            ng+=1

ans=r*g*b
print(ans-ng)
### BUGGY CODE ###

n,w = map(int,input().split())

ab = []
for _ in range(n):
    a, b= (int(x) for x in input().split())
    ab.append([a, b])

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j < ab[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max([dp[i][j], dp[i][j-ab[i][0]]+ab[i][1]])
print(dp[n][w])

### FIXED CODE ###

n,w = map(int,input().split())

ab = []
for _ in range(n):
    a, b= (int(x) for x in input().split())
    ab.append([a, b])

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j < ab[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max([dp[i][j], dp[i][j-ab[i][0]]+ab[i][1]])
print(dp[n][w])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = [0]*(max(A) + 5)
for i in range(N):
  ans[A[i]] += 1
  if ans[A[i]] == 1:
    for j in range(A[i]*2, max(A) + 5, A[i]):
      ans[j] = 2
cnt = 0
for a in A:
  if ans[a] == 1:
    cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
max_A = A[-1] + 1
ans = [0]*max_A
for i in A:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2, max_A, i):
      ans[j] = 2
print(ans.count(1))
### BUGGY CODE ###

N = int(input())
A = [int(s) for s in input().split()]
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = [int(s) for s in input().split()]
    B.append(b)
    C.append(c)

A_dict = {}
for a in A:
    A_dict[a] = A.count(a)

A_sum = sum(A)
for b, c in zip(B, C):
    if b in A_dict.keys():
        n = A_dict[b]
    else:
        n = 0
    A_dict[b] = 0
    if c in A_dict.keys():
        A_dict[c] += n
    else:
        A_dict[c] = n
    A_sum += (c - b) * n
    print(A_sum)


### FIXED CODE ###

from collections import defaultdict

N = int(input())
A = [int(s) for s in input().split()]
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = [int(s) for s in input().split()]
    B.append(b)
    C.append(c)

A_dict = defaultdict(int)
for a in A:
    A_dict[a] += 1

A_sum = sum(A)
for b, c in zip(B, C):
    n = A_dict[b]
    A_dict[b] = 0
    A_dict[c] += n
    A_sum += (c - b) * n
    print(A_sum)
### BUGGY CODE ###

N=int(input())
S=[]
count=0
for i in range(N):
    sample=input()
    if sample in S:
        count+=0
    else:
        S.append(sample)
        count+=1
    
    
print(count)

### FIXED CODE ###

N=int(input())
S=[]
count=0
for i in range(N):
    sample=input()
    S.append(sample)



    
    
print(len(set(S)))
### BUGGY CODE ###

def gcd (a,b):
	if a < b:
		a,b = b,a
	return a if b == 0 else gcd(b,a%b)
T = int(input())
for i in range(T):
	A,B,C,D = map(int,input().split(" "))
	if A < B:
		print("No")
		continue

	if D < B:
		print("No")
		continue

	if A > C:
		init = C + ((A - C) % B)
		if init != C:
			init -= B
		if init < 0:
			print("No")
			continue
	else:
		init = A

	if C >= (B-1):
		print("Yes")
		continue

	dif = (D - B)
	if dif == 0:
		print("Yes")
		continue
	i = C - ((C - init) % dif)
	m = B % dif

	k = 0
	flg = False
	while m * k < dif:
		if i + dif - m*k < B:
			print("No")
			flg = True
			break
		k += 1
	if not flg:
		print("Yes")




### FIXED CODE ###

T = int(input())

def gcd (a: int,b: int) -> int:
    if a < b: a,b = b,a
    return a if b == 0 else gcd(b,a%b)
def lcm (a: int,b: int) -> int:
    return a // gcd(a,b) * b


for i in range(T):
    A,B,C,D = map(int,input().split(" "))
    g = gcd(B,D)
    if A < B or D < B:
        print("No")
        continue
    if C >= ((B - g) + (A % g)):
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,Q = map(int,readline().split())
ki = [list(map(int,readline().split())) for i in range(N-1)]
co = [list(map(int,readline().split())) for i in range(Q)]
 
ki.sort()

kid = deque(ki)
ver = [0 for i in range(N)]
check = [False for i in range(N)]
 
for c in co:
    ver[c[0]-1] += c[1]

check[0] = True

kid2 = deque()

while len(kid) != 0:
    k = kid.popleft()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.append(k)

while len(kid2) != 0:
    k = kid2.pop()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.appendleft(k)


print(' '.join(map(str,ver)))


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,Q = map(int,readline().split())
ki = []
for i in range(N-1):
    ki.append(list(map(int,readline().split())))
co = []
for i in range(Q):
    co.append(list(map(int,readline().split())))
 
ki.sort(key=lambda x: x[1])

kid = deque(ki)
ver = []
check = []
for i in range(N):
    ver.append(0)
    check.append(False)
 
for c in co:
    ver[c[0]-1] += c[1]

check[0] = True

kid2 = deque()

while len(kid) != 0:
    k = kid.popleft()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.append(k)

while len(kid2) != 0:
    k = kid2.pop()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.appendleft(k)


print(' '.join(map(str,ver)))
### BUGGY CODE ###

import math
k=int(input())
s=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            s+=math.gcd(math.gcd(a,b),c)
print(s)

### FIXED CODE ###

from math import gcd
k=int(input())
s=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            s+=gcd(gcd(a,b),c)
print(s)
### BUGGY CODE ###

from collections import deque
A = deque(map(str, input()))
B = deque(map(str, input()))
C = deque(map(str, input()))
x = A.popleft()
for _ in range(10000000):
    if x == "a":
        if A:
            x = A.popleft()
        else:
            print("A")
            break
    elif x == "b":
        if B:
            x = B.popleft()
        else:
            print("B")
    else:
        if C:
            x = C.popleft()
        else:
            print("C")


### FIXED CODE ###

from collections import deque
A = deque(map(str, input()))
B = deque(map(str, input()))
C = deque(map(str, input()))
x = A.popleft()
for _ in range(10000000):
    if x == "a":
        if A:
            x = A.popleft()
        else:
            print("A")
            break
    elif x == "b":
        if B:
            x = B.popleft()
        else:
            print("B")
            break
    else:
        if C:
            x = C.popleft()
        else:
            print("C")
            break
### BUGGY CODE ###

# Union Find
class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)


# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


# 初期化
# 根なら-size,子なら親の頂点
N = int(input())

edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))

ans_sum = 0
edge_list.append(edge(N, N))
upper_l_edge_list = sorted(edge_list, key=lambda e: -e.max())

for l in range(N):
    par = [-1] * N
    num_cc = 0
    upper_l_edge_list_copy = [e for e in upper_l_edge_list if e.min() >= l]
    ### upper_l_edge_list_copy.append(edge(N, N))
    ### upper_l_edge_list = sorted(upper_l_edge_list_copy, key=lambda e: -e.max()) ###

    for r in range(l, N):
        size = 0
        # print([(e.u, e.v) for e in upper_l_edge_list])
        while upper_l_edge_list_copy[-1].max() <= r:
            e = upper_l_edge_list_copy.pop()
            if not same(e.u, e.v):
                size += 1
            unite(e.u, e.v)
        num_cc = num_cc - size + 1
        # print(l, r, num_cc, "size_r", size)
        ans_sum += num_cc

print(ans_sum)


### FIXED CODE ###

class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)

N = int(input())
 
edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))
 
ver_num = int(N * (N + 1) * (N + 2) / 6)
 
edge_num = 0
for e in edge_list:
    edge_num += (N + 1 - (e.max() + 1)) * (e.min() + 1)
    
print(ver_num - edge_num)
### BUGGY CODE ###

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

for k in range(K):
    for i in range(N):
        if A[i] != N:
            break
    else:
        break

    B = [0] * N
    for i in range(N):
        d = A[i]
        left = max(0, i - d)
        right = min(N-1, i + d)
        B[left] += 1
        if right + 1 < N:
            B[right+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B
print(" ".join(map(str, A)))


### FIXED CODE ###

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

for k in range(K):
    for i in range(N):
        if A[i] != N:
            break
    else:
        break

    B = [0] * N
    for i in range(N):
        d = A[i]
        left = max(0, i - d)
        right = min(N-1, i + d)
        B[left] += 1
        if right + 1 < N:
            B[right+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B
print(" ".join(map(str, A)))
### BUGGY CODE ###

memo = {}

def gcd(a, b):
    if (a, b) in memo.keys():
        return memo[(a, b)]
    if b == 0:
        return a
    return gcd(b, a % b)

n = input()
a_list = map(int, raw_input().split())
max_g = 0
for exclude in xrange(n):
    g = a_list[0] if exclude > 0 else a_list[1]
    for i in xrange(1, n):
        if i == exclude:
            continue
        a = a_list[i]
        g_new = gcd(g, a)
        memo[(g, a)] = g_new
        g = g_new
        if g <= max_g:
            break
    if g > max_g:
        max_g = g
print(max_g)


### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    g = gcd(b, a % b)
    return g

n = input()
a_list = map(int, raw_input().split())

gs1 = [None] * n
gs1[0] = a_list[0]
for i in xrange(1, n):
    gs1[i] = gcd(gs1[i - 1], a_list[i])

gs2 = [None] * n
gs2[n - 1] = a_list[n - 1]
for i in reversed(xrange(n - 1)):
    gs2[i] = gcd(gs2[i + 1], a_list[i])

max_g = 0
for exclude in xrange(n):
    if exclude == 0:
        g = gs2[1]
    elif exclude == n - 1:
        g = gs1[n - 2]
    else:
        g = gcd(gs1[exclude - 1], gs2[exclude + 1])
    if g > max_g:
        max_g = g
print(max_g)
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
nums = list()
for i in range(a, b+1):
    if i%c == 0 or i%d == 0:
        continue
    nums.append(i)

print(len(nums))

### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def lcd(a, b):
    return a*b // gcd(a, b)


a, b, c, d = map(int, input().split())

higher = b//c + b//d - b//lcd(c, d)
lower = (a-1)//c + (a-1)//d - (a-1)//lcd(c, d)

print((b-a+1)-higher+lower)
### BUGGY CODE ###

N, M = map(int, input().split())
X = [[] for i in range(N)] # iからの行き先
Y = [[] for i in range(N)] # iに来る元

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    X[x].append(y)
    Y[y].append(x)
    
Z = [0 for i in range(N)] # iまでの最長pathの長さ
L = []
k = 0

L.append([])
for i in range(N):
    if len(Y[i]) == 0:
        L[k].append(i)
        Z[i] = 1

while True:
    k += 1
    L.append([])
    for l in L[k-1]:
        for x in X[l]:
            L[k].append(x)
            Z[x] = k + 1
    
    if len(L[k]) == 0:
        print(k-1)
        break



### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
X = [[] for i in range(N)] # iからの行き先
Y = [0 for i in range(N)] # iに来る辺の数
dp = [0 for i in range(N)] # iで終わる最長経路の長さ

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    X[x].append(y)
    Y[y] += 1


Q = deque([])
for i in range(N):
    if Y[i] == 0:
        Q.append(i)

while len(Q) > 0:
    i = Q.popleft()
    for x in X[i]:
        dp[x] = max(dp[x], dp[i] + 1)
        Y[x] -= 1
        if Y[x] == 0:
            Q.append(x)

print(max(dp))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
print(A.count(1))
for i in range(len(A)):
    print(A.count(i+2))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
x = [0] * N
for s in A:
    x[s-1] += 1
for s in x:
    print(s)
### BUGGY CODE ###

l=list()
for i in range(int(input())):
    s=input()
    if s not in l:
        l.append(s)
print(len(l))

### FIXED CODE ###

n,*l=open(0).read().split()
print(len(set(l)))
### BUGGY CODE ###

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

for i in range(1, n+1):
  c = data.count(i)
  print(c)


### FIXED CODE ###

import collections

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

c = collections.Counter(data)

for i in range(1, n+1):
  print(c[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n

if (z == x):
  u = n - 1
  d = n - 1
elif (z == o):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def toggle(i):
  if (i == '1'):
    return '0'
  else:
    return '1'


def solve(i, count):
  if (i <= 2 * 10**5 + 1 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, count):
  if (i <= 2 * 10**5 + 1):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


ans = [0] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5):
  ans[i] = solve(i, 0)
for i in range(n):
  if(i == 0):
    _x = toggle(x[0]) + x[1: n]
  elif (i == n - 1):
    _x = x[:i] + toggle(x[n - 1])
  else:
    _x = x[:i] + toggle(x[i]) + x[i + 1:n]
  print(solve2(int(_x, 2), 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n
X = int(x, 2)

if (n == 1 and x == '1'):
  print(0)
  exit()

if (z == x):
  u = n - 1
  d = n - 1
elif (o == x):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def solve(i, count):
  if (i <= 2 * 10**5 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, div):
  if (i <= 2 * 10**5):
    return ans[i]
  else:
    return ans[i % div] + 1


ans = [0] * (2 * 10 ** 5 + 4)
_u = (2 * 10 ** 5) // u
U = X % u + (u * _u) + u
if(d != 0):
  _d = (2 * 10 ** 5) // d
  D = X % d + (d * _d) * 2 + d * 2
Us = [0] * (2 * 10 ** 5)
Ds = [0] * (2 * 10 ** 5)
for i in range(1, 2 * 10 ** 5 + 4):
  ans[i] = solve(i, 0)
Us[0] = 1 % u
if(d != 0):
  Ds[0] = 1 % d
for i in range(1, 2 * 10 ** 5):
  Us[i] = (Us[i - 1] * 2) % u
  if(d != 0):
    Ds[i] = (Ds[i-1] * 2) % d

for i in range(n):
  if(x[i] == '0'):
    print(solve2(U + Us[n-i-1], u))
  else:
    if (d == 0):
      print(0)
    else:
      print(solve2(D - Ds[n-i-1], d))
### BUGGY CODE ###

N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = 0
n = 2
for X in range(1,2**len(D)):
  k = Base_10_to_n(X, n).zfill(len(D))
  cur = 1
  for i in range(len(k)):
    if k[i] == '1':
      cur *= D[i]
  ans += cur
print(ans%(10**9+7))

### FIXED CODE ###

N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
ans = 1
for i in range(len(D)):
  ans *= (D[i]+1)
  ans = ans%(10**9+7)
print((ans-1)%(10**9+7))
### BUGGY CODE ###

class SegmentTree:
    def __init__(self, A, n=18, inf=10**20):
        l = len(A)
        self.size = n
        self.array = [inf]*(2**(n+1)-1)
        for i in range(l):
            self.array[i+2**n-1] = A[i]
        for i in range(2**n-2, -1, -1):
            self.array[i] = max(self.array[2*i+1], self.array[2*i+2])

    def _subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return 0
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_max = self._subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_max = self._subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return max(l_max, r_max)

    def max(self, l, r):
        return self._subquery(l, r, 0, 0, 2**self.size)

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = c
        while tmp > 0:
            tmp = (tmp - 1) // 2
            l = self.array[2 * tmp + 1]
            r = self.array[2 * tmp + 2]
            self.array[tmp] = max(l, r)

n = int(input())
*H, = map(lambda x: int(x)-1, input().split())
*A, = map(int, input().split())
DP = SegmentTree([0]*n)
for i in range(n):
    tmp = DP.max(0, H[i])
    DP.update(H[i], tmp+A[i])
print(DP.max(0, n))


### FIXED CODE ###

class SegmentTree:
    def __init__(self, A, n=18, inf=10**20):
        l = len(A)
        self.size = n
        self.array = [inf]*(2**(n+1)-1)
        for i in range(l):
            self.array[i+2**n-1] = A[i]
        for i in range(2**n-2, -1, -1):
            self.array[i] = max(self.array[2*i+1], self.array[2*i+2])

    def _subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return 0
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_max = self._subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_max = self._subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return max(l_max, r_max)

    def max(self, l, r):
        return self._subquery(l, r, 0, 0, 2**self.size)

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = c
        while tmp > 0:
            tmp = (tmp - 1) // 2
            l = self.array[2 * tmp + 1]
            r = self.array[2 * tmp + 2]
            self.array[tmp] = max(l, r)

n = int(input())
*H, = map(lambda x: int(x)-1, input().split())
*A, = map(int, input().split())
DP = SegmentTree([0]*n)
for i in range(n):
    tmp = DP.max(0, H[i])
    DP.update(H[i], tmp+A[i])
print(DP.max(0, n))
### BUGGY CODE ###

while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    sieve = map(lambda x:False, range(2, n + 1))
    for i in range(2, n + 1):
        if sieve[i - 2]:
            continue
        for j in range(i * 2, n + 1, i):
            sieve[j - 2] = True
    print sieve.count(False)

### FIXED CODE ###

N = 10 ** 6
sieve = map(lambda x:False, range(2, N + 1))
for i in range(2, N + 1):
    if sieve[i - 2]:
        continue
    for j in range(i * 2, N + 1, i):
        sieve[j - 2] = True
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    print sieve[:n - 1].count(False)
### BUGGY CODE ###

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

### FIXED CODE ###

s=list(map(int,list(input())[::-1]))
n=len(s)
cnt=[0]*2019
cnt[0]+=1
c=0
for i in range(n):
  c+=s[i]*pow(10,i,2019)%2019
  cnt[c%2019]+=1
ans=0
for i in cnt:
  if i<=1:
    pass
  else:
    ans+=i*(i-1)//2
print(ans)
### BUGGY CODE ###

import collections

N = int(input())
S = input()
ans = 0

count = collections.Counter(S)

R_list = [count['R']]
G_list = [count['G']]
B_list = [count['B']]

for i in range(N):
    if S[i] == 'R':
        R_list.append(R_list[i] - 1)
        G_list.append(G_list[i])
        B_list.append(B_list[i])
    elif S[i] == 'G':
        R_list.append(R_list[i])
        G_list.append(G_list[i] - 1)
        B_list.append(B_list[i])
    else:
        R_list.append(R_list[i])
        G_list.append(G_list[i])
        B_list.append(B_list[i] - 1)

for i in range(N - 2):
    for j in range(i, N - 1):
        if {S[i], S[j]} == {'R', 'G'}:
            ans += B_list[j + 1]
        elif {S[i], S[j]} == {'G', 'B'}:
            ans += R_list[j + 1]
        elif {S[i], S[j]} == {'B', 'R'}:
            ans += G_list[j + 1]
        
        if j + (j - i) <= N -1:
            if {S[i], S[j], S[2 * j - i]} == {'R', 'B', 'G'}:
                ans -= 1
print(ans)

### FIXED CODE ###

import collections

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

count = collections.Counter(S)

ans = count['R'] * count['G'] * count['B']

for distance in range(1, (N - 1) // 2 + 1):
    for i in range(N):
        if i + 2 * distance >= N:
            break
        
        if len({S[i], S[i + distance], S[i + 2 * distance]}) == 3:
             ans -= 1
    

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

s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j != 0:
  j = 0
  start = 0
  end = l-1
  for i in range(start, end):
    if slist[i:i+2] == ['B','W']:
      slist[i:i+2] = ['W','B']
      n += 1
      j = 1
    start += 1
    end -= 1

print(n)

### FIXED CODE ###

S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split( )))
ans = 0
mod = 10**9+7
Bit = [[0]*2 for j in range(60)]# for i in range(n+1)

for i in range(1,n):##1から
    for j in range(60):
        if not ((a[i-1]>>j)&1):#a[i-1]のjビット目0
            Bit[j][0] += 1
        else:#ｊビット目1
            Bit[j][1] += 1
        if ((a[i]>>j)&1):#aiのjビット目1
            ans += Bit[j][0]<<j
            ans %=mod
        else:
            ans += Bit[j][1]<<j
            ans %= mod
    #print(Bit[:6])
"""
for i in range(1,n):##1から
    for j in range(60):

    #ans += a[i]
    #ans %=mod
    #自身の分
        #print(ans)
"""
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split( )))
ans = 0
mod = 10**9+7
Bit = [0 for j in range(60)]# for i in range(n+1)
for j in range(60):#ループ交換
    for i in range(1,n):##1から
        if not ((a[i-1]>>j)&1):#a[i-1]のjビット目0
            Bit[j] += 1
        if ((a[i]>>j)&1):#aiのjビット目1
            ans += Bit[j]<<j
            ans %=mod
        else:
            ans += (i-Bit[j])<<j
            ans %= mod
    
print(ans)