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


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

result = 1

num2 = int(p ** (1/n)) + 1


for i in range(p):

    compare = num2 ** n

    if p % compare == 0:
        result = num2
        break

    num2 -= 1

print(result)



### FIXED CODE ###

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

pp = p
# 2のべき乗チェック
count_2 = 0
while True:
    if pp % 2 == 0:
        pp = pp / 2
        count_2 += 1
    else:
        break


result = 2 ** (count_2 // n)

p = p / (2 ** count_2)

kisu = True if p / 2 != 0 else False

num2 = int(p ** (1/n)) + 1
if kisu:
    num2 = num2 - 1 if num2 % 2 == 0 else num2
else:
    num2 = num2 - 1 if num2 % 2 != 0 else num2


for i in range(num2, 1, -2):
    if p % (i ** n) == 0:
        print(result * i)
        break

else:
    print(result * 1)
### BUGGY CODE ###

import re
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()


for i in range(Q):
    lr = input().split()
    tmp = S[int(lr[0])-1:int(lr[1])]
    count = len(re.findall('AC', tmp))
    print(str(count))




### FIXED CODE ###

from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])
### BUGGY CODE ###

def candidates_of_no_shortest_paths(N: int, M: int, edges: list)->int:
    INF = float('inf')

    d = [[0 if i == j else INF for i in range(N)] for j in range(N)]

    for u, v, c in edges:
        d[u-1][v-1] = d[v-1][u-1] = c

    # warshall-floyd
    for k in range(N):
        for u in range(N):
            for v in range(N):
                if d[u][v] > d[u][k] + d[k][v]:
                    d[u][v] = d[u][k] + d[k][v]

    def used(edge: tuple)->bool:
        u, v, c = edge
        for s in range(N):
            for t in range(N):
                if d[s][u-1] + c + d[v-1][t] == d[s][t]:
                    return True
        return False

    return sum(not used(edge) for edge in edges)


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    edges = [tuple(int(s) for s in input().split()) for _ in range(M)]
    ans = candidates_of_no_shortest_paths(N, M, edges)
    print(ans)


### FIXED CODE ###

def candidates_of_no_shortest_paths(N: int, M: int, edges: list)->int:
    INF = float('inf')

    d = [[0 if i == j else INF for i in range(N)] for j in range(N)]

    for u, v, c in edges:
        d[u-1][v-1] = d[v-1][u-1] = c

    # warshall-floyd
    for k in range(N):
        for u in range(N):
            for v in range(N):
                if d[u][v] > d[u][k] + d[k][v]:
                    d[u][v] = d[u][k] + d[k][v]

    def used(edge: tuple)->bool:
        u, v, c = edge
        for s in range(N):
            if d[s][u-1] + c == d[s][v-1]:
                return True
        return False

    return sum(not used(edge) for edge in edges)


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    edges = [tuple(int(s) for s in input().split()) for _ in range(M)]
    ans = candidates_of_no_shortest_paths(N, M, edges)
    print(ans)
### BUGGY CODE ###

def get_prime_fact(n):
    primes = []
    append = primes.append
    while n % 2 == 0:
        append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        append(n)
    return primes


def get_knu(a):
    if a == 1:
        return 1
    n = 2
    while True:
        if a == (n * (n + 1)) // 2:
            return n
        n += 1


D = int(input())
p = get_prime_fact(D)

if len(p) != len(set(p)):
    res = 0
    for n in set(p):
        count = p.count(n)
        res += get_knu(count)

    print(res)
else:
    print(len(p))

### FIXED CODE ###

def get_prime_fact(n):
    primes = []
    append = primes.append
    while n % 2 == 0:
        append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        append(n)
    return primes


def get_knu(a):
    before = 1
    n = 2
    while True:
        knum = (n * (n + 1)) // 2
        if a == knum:
            return n
        elif knum > a > before:
            return n - 1
        else:
            n += 1
            before = knum


D = int(input())
p = get_prime_fact(D)

if len(p) != len(set(p)):
    res = 0
    for n in set(p):
        count = p.count(n)
        if count == 1:
            res += 1
        else:
            add = get_knu(count)
            res += add

    print(res)
else:
    print(len(p))
### BUGGY CODE ###

#https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c

N = int(input())
S = str(input())
Sarray = list(S)
Sarraynum = []

#白0
for i in range(len(Sarray)):
    if Sarray[i] == '.':
        Sarraynum.append(0)
    else:
        Sarraynum.append(1)

a = 0
for i in range(len(Sarraynum)):
    a += Sarraynum[i]
a = len(Sarraynum) - a
for i in range(len(Sarraynum)):
    b = 0
    jmax = len(Sarraynum) - i - 1
    if jmax < i:
        jmax = i
    c = int(len(Sarraynum) / 2)
    for j in range(c,jmax):
        if j <= i:
            b += Sarraynum[j]
        if i + 1 + j < len(Sarraynum):
            if Sarraynum[i + 1 + j] == 0:
                b += 1
        if b >= a:
            break

    for j in range(c):
        if j <= i:
            b += Sarraynum[j]
        if i + 1 + j < len(Sarraynum):
            if Sarraynum[i + 1 + j] == 0:
                b += 1
        if b >= a:
            break
    
    if b < a:
        a = b


print(a)

### FIXED CODE ###

N = int(input())
S = str(input())
Sarray = list(S)

white = 0 #にしなきゃ
black = 0 #にしなきゃ
for i in range(len(Sarray)):
    if Sarray[i] == '.':
        black += 1

a = [white + black]
for i in range(len(Sarray)):
    if Sarray[i] == '.':
        black -= 1
    else:
        white += 1
    a.append(white + black)
a.sort()
print(a[0])
### BUGGY CODE ###



def ryuka(n):
    if n > 2:
        return ryuka(n - 1) + ryuka(n - 2)
    elif n == 2:
        return 1
    elif n == 1:
        return 2

n = int(input()) +1
print(ryuka(n))

### FIXED CODE ###


n = int(input())

ans = 4
pre = 1
prepre = 2

if n == 1:
    ans = 1
elif n == 2:
    ans = 3
elif n == 3:
    ans = 4
else:
    for n in range(n - 3):
        ans += pre + prepre
        a = prepre
        prepre = pre
        pre = pre + a

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

from collections import deque

def penetrate(x, y, count):
    global max_idx
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]

        if 0 <= nx < h and 0 <= ny < w and A[nx][ny] == "." and d[nx][ny] == -1:
            d[nx][ny] = count + 1
            q.append((nx, ny, d[nx][ny]))
            max_idx = max(max_idx, d[nx][ny])


h, w = map(int, input().split())
d = [[-1] * w for _ in range(h)]

A = [[] for i in range(h)]
q = deque()

for i in range(h):
    A[i] = list(input())
    for j in range(w):
        if A[i][j] == "#":
            d[i][j] = 0
            q.append((i, j, d[i][j]))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
max_idx = 0

while len(q) > 0:
    idx = q.popleft()
    penetrate(idx[0], idx[1], idx[2])

print(max_idx)

### FIXED CODE ###

from collections import deque

def penetrate(x, y, count):
    global max_idx
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]

        if 0 <= nx < h and 0 <= ny < w and A[nx][ny] == "." and d[nx][ny] == -1:
            d[nx][ny] = count + 1
            q.append((nx, ny, d[nx][ny]))
            max_idx = max(max_idx, d[nx][ny])


h, w = map(int, input().split())
d = [[-1] * w for _ in range(h)]

A = [[] for i in range(h)]
q = deque()

for i in range(h):
    A[i] = list(input())
    for j in range(w):
        if A[i][j] == "#":
            d[i][j] = 0
            q.append((i, j, d[i][j]))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
max_idx = 0

while len(q) > 0:
    idx = q.popleft()
    penetrate(idx[0], idx[1], idx[2])

print(max_idx)
### BUGGY CODE ###

X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = [(0,0,0,a[0]+b[0]+c[0])]
unvisited = [[[True for i in range(X)] for j in range(Y)] for k in range(Z)]
unvisited[0][0][0] = False
for i in range(K):
    xt,yt,zt,pt = l.pop(0)
    print(pt)
    list_dx = [1,0,0]
    list_dy = [0,1,0]
    list_dz = [0,0,1]
    for j in range(3):
        dx = list_dx[j]
        dy = list_dy[j]
        dz = list_dz[j]
        if xt+dx<X and yt+dy<Y and zt+dz<Z and xt+yt+zt<=K-3 and unvisited[xt+dx][yt+dy][zt+dz]:
            l.append((xt+dx,yt+dy,zt+dz,a[xt+dx]+b[yt+dy]+c[zt+dz]))
            l.sort(key=lambda x:x[3], reverse=True)
            unvisited[xt+dx][yt+dy][zt+dz] = False

### FIXED CODE ###

X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])
### BUGGY CODE ###

N,Q = map(int, input().split())
chi = [[0] * (N) for i in range(N)]

for n in range(N-1):
    a,b = map(int, input().split())
    chi[a-1][b-1] = 1
    for i in range(N):
        if chi[i][a-1] == 1:
            for j in range(N):
                chi[i][j] = max(chi[i][j],chi[a-1][j])

cnt = [0]*N   
for q in range(Q):
   p,x = map(int, input().split())
   cnt[p-1] += x
   for i in range(N):
       if chi[p-1][i] == 1:
           cnt[i] += x

for n in range(N):
    print(cnt[n], end=" ")

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
        
N,Q = (int(i) for i in input().split())
A = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = (int(i) for i in input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

cnt = [0]*N   
for q in range(Q):
   p,x = (int(i) for i in input().split())
   cnt[p-1] += x

st = deque([(0,-1)])
while st:
    n,par = st.popleft()
    val = cnt[n]   
    for node in A[n]:
        if node == par:
            continue
        else:
            cnt[node] += val
            st.append([node,n])

print(*cnt)
### BUGGY CODE ###

MOD = 10**9+7
fac = [1, 1]
f_inv = [1, 1]
inv = [0, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = 0
    for i in range(1,c2+2):
        ans += f(r2, i)
        ans %= MOD

    for i in range(1,c2+2):
        ans -= f(r1-1, i)
        ans %= MOD

    for i in range(1,c1+1):
        ans -= f(r2, i)
        ans %= MOD

    for i in range(1,c1+1):
        ans += f(r1-1, i)
        ans %= MOD

    print(ans % MOD)


if __name__ == "__main__":
    main()


### FIXED CODE ###

MOD = 10**9+7
fac = [1, 1]
f_inv = [1, 1]
inv = [0, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = 0
    for i in range(1,c2+2):
        ans += f(r2, i)
        ans %= MOD

    for i in range(1,c2+2):
        ans -= f(r1-1, i)
        ans %= MOD

    for i in range(1,c1+1):
        ans -= f(r2, i)
        ans %= MOD

    for i in range(1,c1+1):
        ans += f(r1-1, i)
        ans %= MOD

    print(ans % MOD)


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

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,k = I2()
    h = Intl()
    dp = [float("inf")]*n
    dp[0] = 0
    for i in range(1,n):
        for j in range(max(0,i-k),i):
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
    print(dp[-1])

### FIXED CODE ###

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,k = I2()
    h = Intl()
    dp = [float("inf")]*n
    dp[0] = 0
    for i in range(1,n):
        for j in range(max(0,i-k),i):
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
    print(dp[-1])
### BUGGY CODE ###

k , s = map(int,input().split())
a = 0
for i in range(k+1):
    for j in range(k+1):
        for h in range(k+1):
            if (i + j + h ) == s:
                a += 1
print(a)


### FIXED CODE ###

k, s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z and z <= k:
            ans += 1
print(ans)
### BUGGY CODE ###

N=int(input())
ab=[]
for i in range(N-1):
  ab.append(list(map(int, input().split())))

def BFS(i):
  dist=[0]*N
  d=[-1]*N
  d[i]=0#未訪問ならd=-1,訪問済みならiからの距離
  que=[i]
  dist=1
  while que:
    for j in range(len(que)):
      label=que.pop(0)+1
      for i in range(N-1):
        if ab[i][0]==label and d[ab[i][1]-1]==-1:
          d[ab[i][1]-1]=dist
          que+=[ab[i][1]-1]
        if ab[i][1]==label and d[ab[i][0]-1]==-1:
          d[ab[i][0]-1]=dist
          que+=[ab[i][0]-1]
    dist+=1
  return(d)

dist1=BFS(0)
dist2=BFS(N-1)
Fe=0
Su=0
for i in range(N):
  if dist1[i]<=dist2[i]:
    Fe+=1
  else:
    Su+=1
if Fe>Su:
  print("Fennec")
else:
  print("Snuke")

### FIXED CODE ###

N=int(input())
ab=[]
for i in range(N-1):
  ab.append(list(map(int, input().split())))
A=[ [] for i in range(N) ]
for i in range(N-1):
  A[ab[i][0]-1]+=[ab[i][1]-1]
  A[ab[i][1]-1]+=[ab[i][0]-1]

def BFS(i,A):
  dist=[0]*N
  d=[-1]*N
  d[i]=0#未訪問ならd=-1,訪問済みならiからの距離
  que=[i]
  dist=1
  while que:
    for j in range(len(que)):
      label=que.pop(0)
      for i in range(len(A[label])):
        if d[A[label][i]]==-1:
          d[A[label][i]]=dist
          que+=[A[label][i]]
    dist+=1
  return(d)

dist1=BFS(0,A)
dist2=BFS(N-1,A)
Fe=0
Su=0
for i in range(N):
  if dist1[i]<=dist2[i]:
    Fe+=1
  else:
    Su+=1
if Fe>Su:
  print("Fennec")
else:
  print("Snuke")
### BUGGY CODE ###

Q=int(input())
q=[]
a=[]
b=0
def dist(A,x):
  ret=0
  for i in range(len(A)):
    ret+=abs(A[i]-x)
  return ret
for i in range(Q):
  q.append(list(map(int,input().split())))
  if q[i][0]==2:
    if len(a)%2==0:
      x=a[len(a)//2-1]
      fx=dist(a,x)+b
      print(x,fx)
    else:
      x=a[len(a)//2]
      fx=dist(a,x)+b
      print(x,fx)
  else:
    a.append(q[i][1])
    b+=q[i][2]
    a.sort()

### FIXED CODE ###

import heapq
q=int(input())
L=[]
R=[]
heapq.heapify(L)
heapq.heapify(R)
fx=0
for i in range(q):
  Q=list(map(int,input().split()))
  if Q[0]==1:
    a,b=Q[1],Q[2]
    heapq.heappush(L,-a)
    heapq.heappush(R,a)
    l=-heapq.heappop(L)
    r=heapq.heappop(R)
    if l==a and r==a:
      heapq.heappush(L,-l)
      heapq.heappush(R,r)
    else:
      fx+=abs(r-l)
      heapq.heappush(L,-r)
      heapq.heappush(R,l)
    x=-L[0]
    fx+=b
  else:
    print(x,fx)
### BUGGY CODE ###

import fractions
import collections
import copy

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

num = 10**6+1

mod = 10**9+7

if n == 1:
    print(1)
    exit()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

pri_li = []

for i in range(n):
    pri_li.append(collections.Counter(prime_factorize(ai[i])))

com_ab = [0]*(num)

sosu_li = [[i,0] for i in range(num)]
kosu = 0

for i in range(n):
    #print(len(b_li[i]))
    keys = pri_li[i].keys()
    #print(keys)
    for j in keys:
        #print(sosu_li)
        if sosu_li[j][1] == 0:
            sosu_li[j][1] = 1
            kosu += 1
        com_ab[j] = max(com_ab[j],pri_li[i][j])

sosu_li.sort(reverse=True,key=lambda x: x[1])
"""
for i in range(10**3):
    if com_ab[i] > 0:
        com_num *= pow(i,com_ab[i],mod)
"""
ans = 0

for i in range(n):
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    keys = pri_li[i].keys()
    for j in keys:
        com_ab[j] -= pri_li[i][j]
    kari = 1
    for j in range(kosu):
        kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    ans += kari
    ans %= mod
    for j in keys:
        com_ab[j] += pri_li[i][j]
    #print(ans)
        
print(ans)


### FIXED CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)
### BUGGY CODE ###

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

sum = 1
for i in range(n):
  sum = sum * int(a[i])

if sum > 1000000000000000000 :
  print(-1)
else:
  print(sum)

### FIXED CODE ###

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

sum = 1
for i in a:
  sum = sum * int(i)
  if sum > 1000000000000000000:
    break

if "0" in a:
  print(0)
elif sum > 1000000000000000000:
  print(-1)
else:
  print(sum)
### BUGGY CODE ###

N,K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

INF = 10**20
dp = [INF] * N
dp[0] = 0

for i in range(0, N - 1):
    for k in range(0, min(i+1,K)):
            dp[i + 1] = min(dp[i + 1], dp[i - k] + abs(H[i + 1] - H[i - k]))

print(dp[N-1])

### FIXED CODE ###

N,K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

INF = 10**9
dp = [INF] * N
dp[0] = 0

for i in range(0, N - 1):
    for k in range(0, min(i + 1, K)):
        if dp[i + 1] > dp[i - k] + abs(H[i + 1] - H[i - k]):
            dp[i + 1] = dp[i - k] + abs(H[i + 1] - H[i - k])


print(dp[N - 1])
### BUGGY CODE ###

def d():
  N = int(input())
  A = list(map(int,input().split()))
  
  ans = 0
  for i in range(60):
    num_one = sum([1 for x in range(N) if A[x] & (1 << i) != 0])
    ans = (ans + (1 << i) * num_one * (N - num_one)) % 1000000007
  print(ans)
        
d()


### FIXED CODE ###

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

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)
### BUGGY CODE ###

import numpy as np

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


network = {}
for i in range(N+1):
    network[i] = list()
res = np.zeros((N+1), dtype="int32")
distance = np.full((N+1), N+1)
distance[1] = 0


for _ in range(M):
    i, j = list(map(int, input().split()))
    network[i].append(j)
    network[j].append(i)

s = []

from collections import deque


n = 0
queue = deque([1])
while n < N:
    top = queue.popleft()
    s.append(top)
    for i in network[top]:
        if i not in s:
            queue.append(i)
            if distance[i] > distance[top]+1:
                distance[i] = distance[top]+1
                res[i] = top

    n += 1


print("Yes")  
for r in res[2:]:
    print(r)

### FIXED CODE ###

import numpy as np

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

network = [[] for _ in range(N+1)]
res = [0 for _ in range(N+1)]
distance = [N+1 for _ in range(N+1)]
distance[1] = 0


for _ in range(M):
    i, j = map(int, input().split())
    network[i].append(j)
    network[j].append(i)


from collections import deque


n = 0
s = []
queue = deque([1])
while n < N:
    top = queue.popleft()
    for i in network[top]:
        if distance[i] > distance[top]+1:
            distance[i] = distance[top]+1
            res[i] = top
            queue.append(i)
    n += 1


print("Yes")  
for r in res[2:]:
    print(r)
### BUGGY CODE ###

L,R = list(map(int, input().split()))

A =[]
for i in range(L ,R):
    for j in range(L+1,R+1):
        #print(i,j)
        b = i*j % 2019
        A.append(b)
ans = min(A) 
print(ans)

### FIXED CODE ###

L,R = list(map(int, input().split()))

if R - L > 2019:
    print("0")
else:
    A =[]
    for i in range(L ,R):
            for j in range(L+1,R+1):
                b = i*j % 2019
                A.append(b)
    ans = min(A) 
    print(ans)
### BUGGY CODE ###

# coding: utf-8
import sys
sys.setrecursionlimit(4100000)

ans = str(input())
n = int(input())
r = 2

for i in range(n) :
    x = input().split(" ")
    if x[0] == "1" :
        r = r + 1
    else :
        pp = int(x[1])
        if r % 2 == 1 :
            pp = pp + 1
        if pp % 2  == 1 :
            ans = x[2] + ans
        else :
            ans = ans + x[2]

if r % 2 == 1 :
    ans = ans[::-1]

print(ans)

### FIXED CODE ###

# coding: utf-8
import sys
from collections import deque
 
ans = str(input())
n = int(input())
r = 2
be=deque()
af=deque()
 
for i in range(n) :
    x = input().split(" ")
    if int(x[0]) == 1 :
        r = r + 1
    else :
        pp = int(x[1])
        if r % 2 == 1 :
            pp = pp + 1
        if pp % 2  == 1 :
            be.appendleft(str(x[2]))
        else :
            af.append(str(x[2]))

ans = ''.join(be) + ans + ''.join(af)
if r % 2 == 1 :
    ans = ans[::-1]

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

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

def main():
    cnt = 0
    cnt_1 = 0
    for i in range(N) :
        for j in range(i+1,N) :
            for k in range(j+1,N) :
                cnt_1 += 1
                if ((S[i] == S[j]) or (S[i] == S[k]) or (S[j] == S[k])) or (k == 2*j-i) :
                    cnt += 1
    print(cnt_1 - cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
S = list(input())
r,g,b = 0,0,0
k = 0
buf = 0

for i in range(N) :
    if S[i] == 'R' :
        r += 1
    elif S[i] == 'G' :
        g += 1
    else :
        b += 1

for j in range(N) :
    for i in range(j) :
        k = 2 * j - i
        if k <= N-1 :
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] :
                buf += 1

print(r*g*b - buf)