Harryxun/stf_run huggingface dataset:
def gcd(l, r):
  while r != 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = abs(A[1] - A[0])
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if (K % g) == (A[0] % g) and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()


### FIXED CODE ###

def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  g = A[0]
  for a in A:
    g = gcd(g, a)
  if K % g == 0 and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()
n, q = map(int, input().split())
a = list(map(int, input().split()))
x = [int(input()) for _ in range(q)]
sort_x = sorted(x)
ans = {}
len_x = len(a)
flag = True
if len_x%2== 1:
    small_position = 0
    border_position = int((len_x-1)/2)
    sum_all = sum(a[border_position:])
    a.append(1000000000)
    for x_i in sort_x:
        for compare in a[border_position:]:
            if x_i - a[small_position] > compare-x_i:
                sum_all = sum_all + a[small_position] - compare
                small_position += 2
                border_position += 1
                ans[x_i] = sum_all
            else:
                ans[x_i] = sum_all
                break

else:
    small_position = 1
    border_position = int(len_x/2)
    sum_all = sum(a[border_position:])
    a.append(1000000000)
    for x_i in sort_x:
        for compare in a[border_position:]:
            if x_i - a[small_position] > compare-x_i:
                sum_all = sum_all + a[small_position] - compare
                small_position += 2
                border_position += 1
                ans[x_i] = sum_all
            else:
                ans[x_i] = sum_all
                break

for x_i in x:
    print(ans[x_i])

### FIXED CODE ###

n, q = map(int, input().split())
a = list(map(int, input().split()))
x = [int(input()) for _ in range(q)]
sort_x = sorted(x)
ans = {}
if n%2== 1:
    small_position = 0
    border_position = int((n-1)/2)
else:
    small_position = 1
    border_position = int(n/2)
sum_all = sum(a[border_position:])
a.append(10000000000)
a.append(10000000000)
x_index = 0
flag = False
for compare in a[border_position:]:
    compare_x = sort_x[x_index]
    small_a = a[small_position]
    while 2*sort_x[x_index] - small_a <= compare:
        ans[sort_x[x_index]] = sum_all
        x_index += 1
        if x_index == q:
            flag = True
            break
    sum_all = sum_all + small_a - compare
    small_position += 2
    if flag:
        break

for x_i in x:
    print(ans[x_i])
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
s = sum(a)
l = a // (4 * m)

a = sorted(a, reverse = True)
f = 0
for i in a:
  i < l:
    f = i
    break
if(f < m):
  print('No')
else:
  print('Yes')

### FIXED CODE ###

N, M = map(int, input().split())
vote_nums = sorted([float(i) for i in input().split()], reverse=True)
 
border_rate = 1 / (4 * M)
target = vote_nums[:M]
 
for vote_num in target:
  if vote_num < border_rate * sum(vote_nums):
    print('No')
    exit()
 
print('Yes')
s=input()
a=s.find("A")
z0=s.count("Z")
for i in range (z0-1):
    s=s[:s.find("Z")]+"a"+s[s.find("Z")+1:]
    z=s.find("Z")
print(z-a+1)
    

### FIXED CODE ###

s=input()
for i in range(len(s)):
    if s[i]=="A":
        a=i
        break
for j in range(len(s)):
    if s[-j-1]=="Z":
        z=(len(s)-j)
        break
print(z-a)
N = int(input())
list = list(map(int, input().split()))
no = 0 
ans = 1
c = 0
if list.count("0") >0:
  print("0")
  exit()
else:
  for i in range(N):
    ans = ans * list[no]
    c = c + len(str(list[no]))
    no += 1
    if lens >= 19:
      exit()
    else:
      continue
print(ans)

### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
resolve()
b = input()

if b = A :
	print("T")
elif b = T :
	print("A")
if b = C :
	print("G")
elif b = G :
	print("C")

### FIXED CODE ###

b = str(input())

if b == "A" :
	print("T")
elif b == "T" :
	print("A")
elif b == "C" :
	print("G")
elif b == "G" :
	print("C")
N,K = map(int,input().split())

P = [0]*N
m = 0
for i in range(K):
  a = int(input())
  b = list(int,input().split())
  for j in range(a):
    P[b[j]-1] = 1
    j += 1
    
for l in range(N):
  if P[l] == 1:
    m += 1
    
peint(m)
    


### FIXED CODE ###

n, k = map(int, input().split())
 
m = [0]*n
 
for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for j in range(d):
        m[a[j]-1] += 1
 
print(m.count(0))
import sys
N = int(input())
P = [input() for i in range(N)]

P = list(map(int,P))

ans = 0
if N == 1:
    print(1)
    sys.exti()
err = [1]
P_lft = []
P_rgh = []
while len(err) > 0:
#    print(P)
    del err
    err = []
    del P_lft

    P_lft = P[:N//2]

    for i in P_lft:
        if i > N//2:
            err.append(i)
            P.remove(i)

    ans = ans + len(err)

    err.sort()
    P = P + err


P_lft = P[:N//2]
tmp = [int(i+1) for i in range(N//2)]

while tmp != P_lft:
    ans = ans + 1
    if P_lft[0] != 1:
        P_lft.remove(P_lft[0]-1)
        P_lft.insert(0,P_lft[0]-1)
    else:
        P_lft.remove(N//2)
        P_lft.insert(0,N//2)

del P_lft
P_lft = P[N//2:]
tmp =[]
tmp = [int(i+N//2+1) for i in range(N//2)]

while tmp != P_lft:

    ans = ans + 1
    if P_lft[-1] != N:
        P_lft.remove(P_lft[-1]+1)
        P_lft.append(P_lft[-1]+1)
    else:
        P_lft.remove(N//2+1)
        P_lft.append(P_lft[-1]+1)

print(ans)


### FIXED CODE ###

def main():
    N = int(input())
    P = [int(input()) for _ in range(N)]

    #f1(N, P)
    editorial(N, P)


def editorial(N, P):
    """
    入力例3
        N=8
        P=63127485
         |6   7 8 |
         | 3   4 5|
         |  12    |
        上記の3つの列は要素ai+1=aiである部分列
            連続する列が長いほど、移動しなくて済む要素は多い
            連続するためには、最小未満は左・最大より大きいものは末尾に移動する
        部分列(wikipediaより)
            残った要素がもとの数列における相対的な序列を保つ
            与えられた列からいくつかの要素を取り去ることによって得られる列
    ksomemo様にお借りしました
    """
    if N == 1:
        print(0)
        return

    # WA(N, P)
    a = [0] * (N+1)
    for i, p in enumerate(P):
        a[p] = i

    tmp = 1
    max_len = 1
    for i in range(1, N):
        if a[i] < a[i+1]:
            tmp += 1
            max_len = max(max_len, tmp)
        else:
            tmp = 1
    ans = N - max_len
    print(ans)


def WA(N, P):
    tmp = 0
    ans = 0
    for i, p in enumerate(P):
        if i == 0 or P[i-1] + 1 == p:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 1

    print(N - ans)


if __name__ == '__main__':
    main()
a=input()
c=int(a)
b=input()
d=int(b)
  
if a*b%2=0
    print('Even')
else
    print('Odd')

### FIXED CODE ###

def main():
    a, b = [int(_) for _ in input().split()]
    print("Even") if a * b % 2 == 0 else print("Odd")

main()
def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N+1))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  def search_and_mark(recent_rooms, depth):
    if len(recent_rooms) == 0 or depth >= N:
      return True

    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth

    return search_and_mark(list(temp_recent), depth+1)

  _ = search_and_mark([0], 0)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N+1))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  recent_rooms = [0]
  depth = 1
  while len(not_finished) != 0 and depth < N:
    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth
    depth += 1
    recent_rooms = list(temp_recent)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)

if __name__ == "__main__":
    resolve()
n = int(input())

yesno = "No"

if int(n/100)==7:
  yesno = "Yes"
if n$10==7:
  yesno = "Yes"
n = n%100
if int(n/10)==7:
  yesno = "Yes"
print(yesno)

### FIXED CODE ###

n = int(input())
 
yesno = "No"
 
if int(n/100)==7:
  yesno = "Yes"
if n%10==7:
  yesno = "Yes"
n = n%100
if int(n/10)==7:
  yesno = "Yes"
print(yesno)
import sys
from collections import deque

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [n, m] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = list(read_func().strip().split())
    min_cost = sys.maxint
    for i in range(m):
        x = i + 1
        cost = 0
        for j in range(n - 1):
            now = int(input_raw[j])
            target = int(input_raw[j + 1])
            if now < target:
                if x < target:
                    cost += min( (target - now),  1 +(target - x))
                elif x > target:
                    cost += min( (target - now), 1 + (m + target - x))
                else:
                    cost += 1
            elif now > target:
                if x < target:
                    cost += min((m + target - now),  1 +(target - x))
                elif x > target:
                    cost += min((m + target - now), 1 + (m + target - x))
                else:
                    cost += 1
        #print cost
        if cost < min_cost:
            min_cost = cost

    print min_cost


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    n = int(input_raw[0])
    input_raw = list(read_func().strip().split())
    b_list = deque([])
    is_last_first = False
    for i in range(n):
        is_last_first = not(is_last_first)
        if is_last_first == True:
            b_list.append((input_raw[i]))
        else:
            b_list.appendleft(input_raw[i])

    if is_last_first == True:
        b_list.reverse()
    print " ".join(b_list)


if __name__ == '__main__':
    main()
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
p = ["" for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    tmp = input().split()
    p[i] = int(tmp[0])
    s[i] = tmp[1]

isACed = [0 for _ in range(m)]

n_correct = 0
n_penalty = 0

for i in range(m):
    if isACed[p[i]-1] != 1:
        if s[i] == "AC":
            n_correct += 1

            #正解ラベルを付ける
            isACed[p[i]-1] = 1
        else: #"WA"の時
            n_penalty += 1
print(n_correct, n_penalty)


### FIXED CODE ###

# -*- coding: utf-8 -*-

n, m = map(int, input().split())
p = ["" for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    tmp = input().split()
    p[i] = int(tmp[0])
    s[i] = tmp[1]

isACed = [[0,0] for _ in range(n)]

n_correct = 0
n_penalty = 0
for i in range(m):
    if isACed[p[i]-1][1] != 1:
        if s[i] == "WA": #"WA"の時
            isACed[p[i]-1][0] += 1
        else: #"AC"の時
            n_correct += 1
            isACed[p[i]-1][1] = 1
            n_penalty += isACed[p[i]-1][0]

print(n_correct, n_penalty)
n=int(input())
s=input()
if n%2==0:
  s_1=s[0:n/2]
  s_2=s[n/2:n]
  if s_1==s_2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

### FIXED CODE ###

n=int(input())
s=input()
if n%2==0:
    k=int(n/2)
    s_1=s[0:k]
    s_2=s[k:n]
    if s_1==s_2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
import math
step = [1,1,2,4] + [0]*27
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

while True:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

### FIXED CODE ###

import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

while True:
  n = input()
  if n == 0: break
  print int(math.ceil(steps[n]/3650.0))
a=int(input())
b=[input().split() for i in range(a)]
c=0
for i in range(a):
  if b[i][1]=="JPY":
    c=c+int(b[i][0])
  if b[i][1]=="BTC":
    c=c+int(b[i][0])*380000
print(c)

### FIXED CODE ###

a=int(input())
b=[input().split() for i in range(a)]
c=0
for i in range(a):
  if b[i][1]=="JPY":
    c=c+int(b[i][0])
  if b[i][1]=="BTC":
    c=c+float(b[i][0])*380000
print(c)
n=input()
if("Yes" if n[0]==n[2] else "No")

### FIXED CODE ###

a,b,c=input()
print("Yes" if a == c else "No")
n = int(input())
a = map(int, input().split())

m = (10**9 + 7)
result = [(a[i]*a[j])%m for i in range(n) for j in range(n) if i < j]
print(sum(result)%m)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = (10**9 + 7)

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
import heapq
from heapq import heappush
from heapq import heappop
import random


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n,m = map(int, input().split())
p=np.zeros(m+1,dtype=int)
y=np.zeros(m+1,dtype=int)
for i in range(1,m+1):
    p[i],y[i] = map(int, input().split())


l_pref=[[] for _ in range(n+1)]    # 県の数(==n)だけ空リストを用意
for i in range(1,m+1):
    l_pref[p[i]].append((y[i],i))
for i in range(1,n+1):
    l_pref[i].sort()

# eprint(l_pref)


lll = np.zeros(m+1,dtype=(int,int))
for i in range(1,n+1):
    for j in range(len(l_pref[i])):
        lll[l_pref[i][j][1]] = p[l_pref[i][j][0]]
# eprint(lll)

        
for i in range(1,m+1):
    # temp =  l_pref[p[i]].index((y[i],i))  + 1
    print("0"*(6-len(str(p[i])))  +  str(p[i])  +  "0"*(6-len(str(lll[i]))) + str(lll[i]) )


### FIXED CODE ###

from __future__ import print_function
# import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
import heapq
from heapq import heappush
from heapq import heappop
import random


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n,m = map(int, input().split())
p=[i for i in range(m+1)]
y=[i for i in range(m+1)]
for i in range(1,m+1):
    p[i],y[i] = map(int, input().split())


l_pref=[[] for _ in range(n+1)]    # 県の数(==n)だけ空リストを用意
for i in range(1,m+1):
    l_pref[p[i]].append((y[i],i))
for i in range(1,n+1):
    l_pref[i].sort()

# eprint(l_pref)


lll = [(1,1) for i in range(m+1)]
for i in range(1,n+1):
    for j in range(len(l_pref[i])):
        lll[l_pref[i][j][1]] = j+1
# eprint(lll)

for i in range(1,m+1):
    # temp =  l_pref[p[i]].index((y[i],i))  + 1
    print("0"*(6-len(str(p[i])))  +  str(p[i])  +  "0"*(6-len(str(lll[i]))) + str(lll[i]) )
a, b = map( int, input())

print( max( 0, a - 2 * b ))


### FIXED CODE ###

a, b = map( int, input().split())
print( max( 0, a - b * 2 ))
n = int(raw_input())
 
G = [0 for i in range(n)] 
a = [[0 for i in range(n)] for j in range(n)]
dis = [-1 for i in range(n)]
dis[0] = 0
 
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        a[G[0]-1][G[2+j]-1] = 1
 
def bfs_visit(s):
    for k in range(n):
      if a[s][k] == 1 and dis[k] == -1:
         dis[k] = dis[s] + 1
         bfs_visit(k)

for s in range(n):
    bfs_visit()
for s in range(n):
    print (s+1,dis[s])
 

### FIXED CODE ###

n = int(raw_input())
   
dis = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
   
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if dis[e] > dis[s] + 1:
        dis[e] = dis[s]+1
        BFS(e)
   
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
   
dis[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if dis[s] == 99999:
    dis[s] = -1
for s in range(n):
  print'{0} {1}'.format(s+1, dis[s])
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(a,b))

### FIXED CODE ###

import fractions
 
A, B = map(int, input().split())
 
print((A * B) // fractions.gcd(A, B))
s = input()
s.sort()
if s[0] == s[1] and s[0] != s[2] and s[2] == s[3]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = list(input())
s.sort()
if s[0] == s[1] and s[0] != s[2] and s[2] == s[3]:
  print('Yes')
else:
  print('No')
N = int(input())
A = list(map(int, input().split()))
A.sort()

M = 10**6 + 1
flag = [True]*M

for a in A:
    if flag[a+a] == False:
        continue
    for i in range(M)[a+a::a]:
        flag[i] = False

ans = 0
for a in A:
    if flag[a] == True:
        ans += 1

print(ans)

### FIXED CODE ###

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

M = 10**6 + 1
cnt = [0]*M

for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for i in range(M)[a::a]:
        cnt[i] += 1

ans = 0
for a in A:
    if cnt[a] == 1:
        ans += 1

print(ans)
from fractions import gcd
from functools import reduce
N = int(input())
Alist = list(map(int, input().split()))
Alist = AList+[Alist[0]]
def gcd_list(numbers):
  return reduce(gcd, numbers)
if len(Alist) == 2:
    print(max(Alist))
else:
    gcdlist=[gcd_list(Alist[i:i+2]) for i in range(N)]
    ind = gcdlist.index(min(gcdlist))
    if ind == N:
      print(max([gcd_list(Alist[:N]), gcd_list(Alist[1:])]))
    else:
      print(max([gcd_list(Alist[:ind]+Alist[ind+1:]), gcd_list(Alist[:ind+1]+Alist[ind+2:])]))


### FIXED CODE ###

from fractions import gcd
N = int(input())
Alist = [0]+list(map(int, input().split()))+[0]
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(1,N+1)]))
A, W = list(map(str, input().split()))
output = W + A
print(output)

### FIXED CODE ###

A, W = list(map(str, input().split()))
output = W + A
print(output)
S = input().split(" ")
n = int(S[0])
m = int(S[1])

py = []

for i in range(n+1):
    py.append([int(s) for s in input().split(" ")])

def prepare(n, data):
    result = [0 for i in range(n)]
    dict = {}
    data = sorted(data,key=lambda x:x[1])
    for d in data:
        i = d[0] - 1
        result[i] = result[i] + 1
        dict.__setitem__(generateID(d[0], d[1]), str(d[0]).zfill(6) + str(result[i]).zfill(6))

    return dict


def generateID(start, to):
    if start < to:
        start, to = to, start

    return start * 100000 + to

dict = prepare(n, py)

for p in py:
    print(dict[generateID(p[0],p[1])])




### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)
S = input().split(" ")
n = int(S[0])
m = int(S[1])

py = []

for i in range(m):
    py.append([int(s) for s in input().split(" ")])

def prepare(n, data):
    result = [0 for i in range(n)]
    dict = {}
    data = sorted(data,key=lambda x:x[1])
    for d in data:
        i = d[0] - 1
        result[i] = result[i] + 1
        dict.__setitem__(generateID(d[0], d[1]), str(d[0]).zfill(6) + str(result[i]).zfill(6))

    return dict


def generateID(start, to):
    if start < to:
        start, to = to, start

    return start * 100000 + to

dict = prepare(n, py)

for p in py:
    print(dict[generateID(p[0],p[1])])
n = int(input())
h_list = list(map(int,input().split()))
count_list = []
i = 0
counter = 0
for i in range(n-1):
    if n == 1:
      count_list.append(0)
      break
    if h_list[i] >= h_list[i + 1]:
       count_list.append(1)
    else :
       count_list.append(0)
result_list = []
result = 0
for m in count_list:
    if m == 1:
        result += 1
        result_list.append(result)
        
    else :
        result = 0
        result_list.append(result)
        
print(max(result_list))  
  
    
    
    
  


### FIXED CODE ###

n = int(input())
h_list = list(map(int,input().split()))
count_list = []
i = 0
counter = 0
for i in range(n-1):
    if h_list[i] >= h_list[i + 1]:
       count_list.append(1)
    else :
       count_list.append(0)
result_list = []
result = 0
for m in count_list:
    if m == 1:
        result += 1
        result_list.append(result)
        
    else :
        result = 0
        result_list.append(result)
        
if result_list == []:
    print(0)
else:
    print(max(result_list))
S = list(input())
a_to_z = "abcdefghijklmnopqrstuvwxyz"
s.sort()
ans = "None"
for string in a_to_z:
    if string not in S:
        ans = string
        break
print(ans)
        
        

### FIXED CODE ###

S = list(input())
a_to_z = "abcdefghijklmnopqrstuvwxyz"
S.sort()
ans = "None"
for string in a_to_z:
    if string not in S:
        ans = string
        break
print(ans)
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(N):
  if(i%2==0):
    ans+=a[i]
  else:
    ans+=a[i]
print(ans)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(N):
  if(i%2==0):
    ans += a[i]
  else:
    ans-=a[i]
print(ans)
S=input()
if S="AAA" or S="BBB":
    print("No")
else:
    print("Yes")

### FIXED CODE ###

S=input()
if S=="AAA" or S=="BBB":
    print("No")
else:
    print("Yes")
def main():
    N = int(input())
    S = list(str(input()))
    print()
    sum = 0
    for i in range(0, N-2):
        si = S[i]
        for j in range(i, N-1):
            sj = S[j]
            for k in range(j, N):
                sk = S[k]
                #if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                if si != sj and sj != sk and sj != sk
                    if j - i != k -j:
                        sum += 1
    print(sum)



main()

### FIXED CODE ###

def main():
    N = int(input())
    S = list(str(input()))
    sum = S.count("R") * S.count("G") * S.count("B")
    for i in range(0, N-2):
        si = S[i]
        for j in range(i+1, N-1):
            sj = S[j]
            k = 2*j -i  # Nを超える
            if k < N:
                sk = S[k]
                #if j - i != k -j and si != sj and si != sk and sj != sk:
                if si != sj and si != sk and sj != sk:
                    sum -= 1
    print(sum)

    # 提出 #11871188


main()