peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
C = []
import numpy as np
for _ in range(3):
    C.append(list(map(int,input().split())))

for i in range(1,3):
    ALL = []
    for j in range(3):
        a = C[0][j] - C[i][j]
        ALL.append(a)

    if len(set(ALL)) != 1:
        print('No')
        exit()

print('Yes')
# Judge status: Accepted
n,m = map(int, input().split())
ball_cnts = [1]*(n+1)
ball_cnts[0] = 0
red_flag = [False]*(n+1)
red_flag[1] = True

for _ in range(m):
    x,y = map(int, input().split())
    if red_flag[x]:
        red_flag[y] = True
    if ball_cnts[x] == 1:
        red_flag[x] = False
    ball_cnts[x] -= 1
    ball_cnts[y] += 1

ans = 0
for v in red_flag:
    if v: ans += 1

print(ans)
# Judge status: Accepted
N = int(input())

def wa(x):
    s = 0
    while x > 0:
        s += x % 10
        x = int(x / 10)
    return s
L = []
for i in range(1,N):
    A = i
    B = N - i
    x = wa(A) + wa(B)
    L.append(x)
    
L = sorted(L)
    
print(L[0])
# Judge status: Accepted
N = int(input())
p = 1

for i in range(1,int(N**0.5+1)):
  if N%i == 0:
    p = i
    
print(p+N//p-2)
# Judge status: Wrong Answer
s=input();print(s[:2]+'8'+s[4:])
# Judge status: Accepted
N = int(input())
# X, L = [], []
A = []
for i in range(N):
    x, l = map(int, input().split())
    # X.append(x)
    # L.append(l)
    A.append((x - l, x + l))

A.sort(key=lambda x: x[1])
ans = 0
x = -10e50
for i in range(N):
    l, r = A[i]
    if x <= l:
        ans += 1
        x = r

print(ans)


# 選べるロボットの中で最もX+Lが小さいもの
# Judge status: Wrong Answer
a = input().split()
# a[0] is N個
# a[1] is K個
b = input().split()
b.sort()
sum = 0

for i in range(int(a[1])):
    sum += int(b[i])

print(sum)
# Judge status: Accepted
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 1<=s1<=12 and 0<=s2<=99:
    if 1<=s2<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<=s1<=99 and 1<=s2<=12:
        print("YYMM")
    else:
        print("NA")
# Judge status: Accepted
N = int(input())

count = 0
for i in range(1, N+1):
    if len(str(i)) % 2 != 0:
        count += 1

print(count)
# Judge status: Wrong Answer
N, M = map(int, input().split())
if N == M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M - 2)
else:
    print((N - 2) * (M - 2))
# Judge status: Accepted
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    if n >= m:
        print(0)
    else:
        diff = [abs(x[i] - x[i+1]) for i in range(m-1)]
        diff.sort(reverse=True)
        ans = sum(diff)
        for i in range(n-1):
            ans -= diff[i]
        print(ans)
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
a,b=map(int, input().split())

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)
 
x10 = a
c = Base_10_to_n(a,b )
print( len(c) )
# Judge status: Accepted
N = int(input())

if N == 1:
    print(0)
    exit()

if N == 2:
    print(2)
    exit()

# N >= 3

# 全事象
all_pattern = 10 ** N

# 0も9もない
pattern_a = 8 ** N

# 0あるが9ない
pattern_b = 9 ** N - 8 ** N

ans = all_pattern - pattern_a - pattern_b * 2
ans = ans % (10**9 + 7)

print(ans)
# Judge status: Wrong Answer
NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[1]-sum(ans))
# Judge status: Accepted
O = input()
E = input()

ans = ""
while len(O)>0:
  ans += O[:1]+E[:1]
  O = O[1:]
  E = E[1:]
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse = True)

if k > n:
  k = n

for i in range(k):
  h[i] = 0

ans = 0
for i in range(n):
  ans += h[i]
  
print(ans)
# Judge status: Accepted
N, M = map(int, input().strip().split())
a = max(N*(N-1)//2, 0)
b = max(M*(M-1)//2, 0)

print(a+b)
# Judge status: Accepted
n,m,q=map(int,input().split())
q_list=[]
for i in range(q):
    a=list(map(int,input().split()))
    q_list.append(a)
import itertools
ans=0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
#     i=sorted(i)
    count=0
    for a,b,c,d in q_list:
        if i[b-1]-i[a-1]==c:
            count+=d

    ans=max(count,ans)
print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3

n = int(input())
X = []
L = []
T = []
for i in range(n):
    a, b = map(int, input().split())
    T.append( (a-b, a+b) )
    X.append(a)
    L.append(b)

T.sort(key=lambda x: -x[1])

ans = 1
cur = T[0][0]
for k, v in enumerate(T):
    if k == 0: continue
    if v[1] <= cur:
        ans += 1
        cur = T[k][0]

print(ans)
# Judge status: Wrong Answer
n,l=map(int,input().split())
min =1000
ans = 0
for i in range(n):
    if(min > abs(i+l)):
        min = abs(i+l)
    ans = ans+i+l
print(ans-min)
# Judge status: Accepted
Q,H,S,D=map(int,input().split())
N=int(input())

q=Q*8
h=H*4
s=S*2
d=D
if N%2==0:
    ans=(N//2)*min(q,h,s,d)
    print(ans)
else:
    ans=(N//2)*min(q,h,s,d)
    q=Q*4
    h=H*2
    s=S
    ans+=min(q,h,s)
    print(ans)
# Judge status: Wrong Answer
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
    t[i+1]=t[i]+(1 if S[i:i+2] == 'AC' else 0)
print(t)
for i in range(Q):
    l,r=map(int,input().split())
print(t[r-1]-t[l-1])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
    s = s ^ i
ans = [s ^ i for i in a]
print(*ans, sep=' ')
# Judge status: Accepted
N = int(input())
W = list(map(int,input().split()))
for i in range(N-1):
    W[i+1]+=W[i]
MIN = 10**8
for i in range(N-1):
    if MIN>abs(W[N-1]-2*W[i]):
        MIN = abs(W[N-1]-2*W[i])
print(MIN)
# Judge status: Accepted
A,B=map(int,input().split())

from fractions import gcd

print(int(A*B/gcd(A,B)))
# Judge status: Accepted
a, b, c = map(int, input().split())
if a + b + c <= 21:
  print("win")
else:
  print("bust")
# Judge status: Accepted
import math

a,b=map(int,input().split())
A=a/0.08
B=(a+1)/0.08
C=b/0.1
D=(b+1)/0.1

P=max(A,C)
Q=min(B,D)
if math.ceil(P)<Q:
    print(math.ceil(P))
else:
    print(-1)
# Judge status: Accepted
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(m):
  b.append(list(map(int,input().split())))
for i in range(n):
  tmp=10**9
  for j in range(m):
    man=abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])
    if man < tmp:
      tmp=man
      ans=j+1
  print(ans)
# Judge status: Wrong Answer
x,y=map(int,input().split())
n=1
while int(2**n)<=y/x:
  n+=1
print(n)
# Judge status: Accepted
def toStr(n,base):
    convertString = "0123456789ABCDEF"
    if n < base:
        return convertString[n]
    else:
        return toStr(n//base,base) + convertString[n%base]

a,b = map(int,input().split())
print(len(toStr(a,b)))
# Judge status: Wrong Answer
k = int(input())

n = k // 2
if n % 2 == 0:
  print(k**2)
else:
  print(k * (k + 1))
# Judge status: Accepted
import sys
input = sys.stdin.readline
s=input().strip()
print("2018/"+s[5:])
# Judge status: Accepted
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]


for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        c = l[j][0]
        s = l[j][1]
        f = l[j][2]
        if t < s:
            t = s
        if t%f != 0:
            t = t+f - t%f
        t += c
    print(t)
print(0)
# Judge status: Accepted
X,Y = map(int, input().split())
if X%Y == 0:
    print('-1')
else:
    print(X)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if (a*b) % 2:
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
n = list(input())
n.insert(0, '0')

ans = 0
for i in range(len(n)-1, -1, -1):
    if n[i] == '0':
        pass
    elif int(n[i]) <= 4:
        ans += int(n[i])
    elif int(n[i]) == 5 and int(n[i-1]) <= 4:
        ans += int(n[i])
    else:
        ans += 10 - int(n[i])
        n[i-1] = str(int(n[i-1]) + 1)

print(ans)
# Judge status: Accepted
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]

x = m
y = m+1
if n%2==1:
    for i in range(m):
        print(x-i,y+i)
else:
    num = 0
    while 1+num*2 < n//2 and num < m:
        print(x-num,y+num)
        num += 1
    while num < m:
        print(x-num,y+num+1)
        num += 1
# Judge status: Accepted
S = input()
Q = int(input())
t = ''
for i in range(Q):
  instructions = list(map(str, input().split()))
  if instructions[0] == '1':
    S, t = t, S
  else:
    if instructions[1] == '1':
      t += instructions[2]
    else:
      S += instructions[2]
print(t[::-1] + S)
# Judge status: Accepted
a = int (input())
b = int (input())
c = int (input())
x = int (input())

cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            
            if i*500 + j*100 + k*50 == x:
                cnt += 1
                
                
print(cnt)
# Judge status: Wrong Answer
a,b=map(int,input().split())
k=0
for i in range(1,max(a,b)):
    k+=i
    if k-a>0 or k-b>0:
        break
print(abs(min(a,b)-k))
# Judge status: Accepted
N = int(input())
result = 0
for i in range(1, N+1):
    if i%15 != 0 and i%3 != 0 and i%5 != 0:
        result += i
print(result)
# Judge status: Accepted
A,B = map(int,input().split())
def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
G = gcd(A,B)
S = set()
S.add(1)
n = G
for i in range(2,G+1):
    if i*i>n:
        S.add(n)
        break
    if n%i==0:
        S.add(i)
    while n%i==0:
        n//=i
print(len(S))
# Judge status: Wrong Answer
X = int(input())

if X <= 30:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for i in range(N):
    ans += bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i]))
print(ans)
# Judge status: Wrong Answer
n = int(input())
al = list(map(int, input().split()))
al_s = list(set(al))

ans = [0] * (10 ** 5 + 1)
for a in al_s:
    ans[a] += 1
    ans[a + 1] += 1
    ans[a - 1] += 1

print(max(ans))
# Judge status: Wrong Answer
n = int(input())
x = [int(input()) for i in range(5)]
d = n // min(x)
if n == min(x):
  print(d+4)
else:
  print(d+5)
# Judge status: Wrong Answer
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
a=10**9
for i in range(n-2):
    a1=max(h[i:i+3])-min(h[i:i+3])
    a=min(a,a1)
print(a)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
s = 0
for i in range(n):
    if s+a[i]==x or (i<n-1 and s+a[i]<=x):
        s += a[i]
#         print(s)
    else:
        i -= 1
        break
print(i+1)
# Judge status: Accepted
n=int(input())
l=[int(x) for x in input().split()]
ans=0
while all([l[i]%2==0 for i in range(n)]):
    ans+=1
    l=list(map(lambda k:k//2,l))
print(ans)
# Judge status: Wrong Answer
n, x = map(int,input().split())
cList = list(map(int,input().split()))

count = 0
for i in range(1,n):
  tmp = cList[i-1]+cList[i]-x
  if tmp > 0:
    cList[i] -= tmp
    count += tmp

print(count)
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
if a <= x and x <=a+b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[3]:


X = int(input())


# In[4]:


if X < 600:
    ans = 8
elif X < 800:
    ans = 7
elif X < 1000:
    ans = 6
elif X < 1200:
    ans = 5
elif X < 1400:
    ans = 4
elif X < 1600:
    ans = 3
elif X < 1800:
    ans = 2
elif X < 2000:
    ans = 1
print(ans)


# In[ ]:
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

lis = [1 if s=='#' else 0 for s in S]
from itertools import accumulate
lis = list(accumulate(lis))

ans = 10**18
cnt = 0
for i in range(N-1, -1, -1):
    s = S[i]
    ans = min(ans, cnt+lis[i])
    if s=='.':
        cnt += 1
ans = min(ans, cnt)

print(ans)
# Judge status: Wrong Answer
N = int(input(""))
A = input("").split()
A = [int(i) for i in A]
n = 1


for i in range(N):
    n = n * A[i]
    if n > 10 ** 18:
        n = -1
        break

print(n)
# Judge status: Accepted
def resolve():
    n = int(input())
    a = []

    for _ in range(n):
        x, l = map(int, input().split())
        a.append((x - l, x + l))

    t = -float('inf')
    a.sort(key=lambda x: x[1])
    ans = 0

    for start_t, end_t in a:
        if t <= start_t:
            ans += 1
            t = end_t

    print(ans)

resolve()
# Judge status: Wrong Answer
n,m=map(int,input().split())
l=[]
for _ in range(n):
    a,b=map(int,input().split())
    if a<=m:
        l.append((b,a))
l.sort(reverse=True)

ans=0
t=1
for i in l:
    a=i[1]
    b=i[0]
#    print(a,b,t+a-1)
    if t+a-1>m:
        continue
    else:
 #       print(a,b,end=' entered')
        ans+=b
        t+=1
print(ans)
# Judge status: Accepted
from collections import Counter

S = Counter(list(input()))

if ((S["N"] and S["S"]) or not(S["N"] or S["S"])) and ((S["W"] and S["E"]) or not(S["W"] or S["E"])):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = input()
if len(a) % 2 == 0:
    print('No')
else:
    N = int((len(a) - 1) / 2)
    if a[:N] == a[-N:] == a[:N:-1]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
dp[0] = 0
for i in range(N-1):
    #足場を一個飛んだ時
    dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i]))
    #足場を二個飛んだ時
    if i <= N-3:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i + 2]-H[i]))
print(dp[N-1])
# Judge status: Wrong Answer
n = int(input())
ans  = 0
if n == 100000 :
    ans = 90909
elif 10000 <= n <= 99999 :
    ans = n - 10000 + 1 + 900 + 9
elif 1000 <= n <= 9999 :
    ans = 909
elif 100 <= n <= 999 :
    ans = n - 100 + 1 + 9
elif 10 <= n < 99 :
    ans = 9
elif 1 <= n <= 9 :
    ans = n

print(ans)
# Judge status: Accepted
import sys
 
X, Y = map(int, input().split())
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

if 2*Y < X or 2*X < Y or (X+Y)%3 != 0:
  print(0)
  sys.exit()
  
n1 = (2*Y-X)//3
n2 = (2*X-Y)//3

print(combination(n1+n2, min(n1, n2), 10**9+7))
# Judge status: Accepted
n, k, x, y = (int(input()) for i in range(4))
if k >= n:
  print(n*x)
else:
  print(k*x + (n-k)*y)
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())

K=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            K+=(500*a+100*b+50*c==X)
print(K)
# Judge status: Accepted
import sys

S = list(sys.stdin.readline().rstrip())
T = list(sys.stdin.readline().rstrip())

len_s = len(S)
len_t = len(T)

for i in range(len_s - len_t, -1, -1):
    for j in range(len_t):
        if S[i+j] == T[j] or S[i+j] == "?":
            continue
        else:
            break
    else:
        for k in range(len_t):
            S[i+k] = T[k]

        print(("".join(S)).replace("?","a"))
        exit()

print("UNRESTORABLE")
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=[int(i)-1 for i in input().split()]
ed=[False]*n
go=0
c=0
cc=0
while not ed[go]:#既に通っていたら終了
    ed[go]=True
    go=a[go]
    c+=1
ed=[False]*n
while not ed[go]:#二回目のループは違う可能性があるため6,5,2,5,3,2の場合、6,2,5,3,2,5,3,2,5,...となる
    ed[go]=True
    go=a[go]
    cc+=1#別変数で保存
for i in range((k-c-cc)%cc):
    go=a[go]
print(go+1)
# Judge status: Accepted
from collections import deque

S = deque(list(input()))
Q = int(input())

inv = 0
for i in range(Q):
  query = input().split()
  if query == ['1']:
    inv = (inv + 1)%2
  else:
    f, c = query[1], query[2]
    if f == '1':
      if inv:
        S.append(c)
      else:
        S.appendleft(c)
    else:
      if inv:
        S.appendleft(c)
      else:
        S.append(c)

S = list(S)
if inv:
  print(''.join(S[::-1]))
else:
  print(''.join(S))
# Judge status: Accepted
n, m = map(int, input().split())

if n%2:
  for i in range(1, m+1):
    print(i, n-i)
else:
  for i in range(1, m+1):
    if 2*i >= n/2:
      print(i, n-i-1)
    else:
      print(i, n-i)
# Judge status: Wrong Answer
#! python3
# coding:utf-8
 
def main():
    n = int(input())
    ans = [0 for _ in range(n+1)]

    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                eq = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if eq < n+1:
                    ans[eq]+=1

    for i in ans:
        print(i)    

if __name__ == "__main__":
    main()
# Judge status: Accepted
x = int(input())
now = 0

for i in range(1, x+1):
    now += i
    if 0 <= now-x <= i * (i-1)//2:
        print(i)
        break
# Judge status: Accepted
n,k=map(int,input().split())
hs=list(map(int,input().split()))
hs.sort()
print(sum(hs) if k==0 else sum(hs[:-k]))
# Judge status: Accepted
from math import floor
import sys
input = sys.stdin.readline
X=int(input().rstrip('\n'))
res = 0
now = 100
while now < X:
  res += 1
  now = now + floor(now*0.01)
print(res)
# Judge status: Accepted
a,b = list(input().split())
n = int(a+b)
result = 'No'
for i in range(1,1001):
    if n == i * i:
        result = "Yes"
        break
print(result)
# Judge status: Wrong Answer
import numpy as np
n = int(input())
x = np.arange(1,10**6)
div = x[n%x==0]
d = len(div)
print(div[d//2]+div[d//2-1]-2)
# Judge status: Wrong Answer
a,b = map(int,input().split())
c = abs(b - a)
x = 0
while(a % c != 0):
  a += 1
  x += 1
print(x)
# Judge status: Accepted
# -*- coding: utf-8 -*-

import random

D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(j) for j in input().split()])

for i in range(D):
    print(random.randint(1, 26))
# Judge status: Wrong Answer
H , N = map ( int , input().strip().split(" ") ) ;
L = sum ( map ( int , input().strip().split(" ") ) ) ;
print ( "Yes" if L > H else "No" ) ;
# Judge status: Accepted
a = int(input())
n = a // 2
if 2*n == a:
    print(n)
else:
    print(n + 1)
# Judge status: Accepted
N, A, B = map(int, input().split())

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    mini_1 = min(left, right)
    
    kado = min(A - 1, N - B)
    mini_2 = kado + 1 + (d - 1) // 2
    
    ans = min(mini_1, mini_2)

print(ans)
# Judge status: Accepted
r,g,b = input().split()

num = int(r+g+b)

if (num%4 == 0):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import math

n,d=map(int,input().split())
xy= [[int(i) for i in input().split()] for i in range(n)]
an=0
for i in range(n):
    if math.sqrt(xy[i][0]**2+xy[i][1]**2)<=d:
        an+=1
print(an)
# Judge status: Wrong Answer
n,k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*(n-1)

for i in range(1,n-1):
    temp = 10**10
    for j in range(1, min(k+1, i+1) ):
        temp = min(temp, abs(h[i] - h[i-j]) + dp[i-j])
    dp[i] = temp

print(dp[n-2])
# Judge status: Wrong Answer
n = int(input())
a = [i for i in map(int, input().split()) if i < n]
num = len(a)
ans = 0

for i in range(num):
    for j in range(i+1, num):
        if a[i]+a[j] == j-i:
            ans += 1
print(ans)
# Judge status: Accepted
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (_a if not _a % c and _a // c % 2 else 2 * m + 2 for _a in a))
    return str((m - l // 2) // l + 1) if l <= 2 * m else "0"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Wrong Answer
n,m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
c = 0
for i in range(n):
    for j in range(1,n+1):
        if j not in k[i][1:]:
            break
    else:
        c+=1
print(c)
# Judge status: Wrong Answer
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

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

ans = []

if len(A) == 1:
    ans.append(A[0])
else:
    ans.append(gcd(A[1:]))
    ans.append(gcd(A[:N]))

    for i in range(1, N-1):
        l = []
        l.append(gcd(A[:i]))
        l.append(gcd(A[i+1:]))
        ans.append(gcd(l))

print(max(ans))
# Judge status: Wrong Answer
w,a,b = map(int,input().split())
aw = a+w
bw =b+w
print(min(abs(b-aw),abs(bw-a)))
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range((n+1)//2):
  print(l[n-2*i-1],end=' ')
for i in range(n//2):
  print(l[2*i],end=' ')
# Judge status: Accepted
def resolve():
    N = int(input())
    if N >= 1000:
        print("ABD")
    else:
        print("ABC")

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
def solution():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    for i in range(n):
        for j in range(i+1, n+1):
            k = (j - i) + j
            if k < 1 or k >= n:
                continue
            if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:              
                ans -= 1
    print(ans)

solution()
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    w,h,x,y = map(int, input().split())
    if x==w/2 and y==h/2:
        print(w*h/2, 1)
    else:
        print(w*h/2, 0)

if __name__ == '__main__':
    main()
# Judge status: Accepted
lst=list(map(int,input().split()))
print(15-sum(lst))
# Judge status: Accepted
a, b, c = map(int, input().split())

cnt = 0

while True:
    if a % 2 == 1:
        print(cnt)
        exit()
    if b % 2 == 1:
        print(cnt)
        exit()
    if c % 2 == 1:
        print(cnt)
        exit()
    if a == b and a == c:
        print(-1)
        exit()
    lis = []
    lis.append((b+c)/2)
    lis.append((a+c)/2)
    lis.append((a+b)/2)
    a, b, c = lis

    cnt += 1
# Judge status: Wrong Answer
N = int(input())
W = list(map(int,input().split()))
weight= sum(W)
cnt = 0
for i in range(N):
  if weight <= cnt:
    print(cnt-weight)
    exit()
  weight -= W[i]
  cnt += W[i]
# Judge status: Accepted
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import re
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  S=pin()[:-1]
  if re.fullmatch(r"(hi)+",S)==None:
    print("No")
    return 
  print("Yes")
  return 

main()
# Judge status: Wrong Answer
n,k=map(int, input().split())
peoples=[]
for i in range(k):
    candies = input()
    # リストに追加
    tmp = [int(i) for i in list(input().split())]
    peoples.extend(tmp)

# listから重複を削除し
print(3-len(set(peoples)))
# Judge status: Accepted
x = int(input())

for i in range(-200,200):
    for j in range(-200,200):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())

high = max(h,w)
low = min(h,w)

count = 0
ans = 0
for i in range(low):
  count += high
  ans += 1
  if count >= n:
    break
print(ans)
# Judge status: Accepted
s,t=input(),input();l,m=len(s),len(t)
for i in range(l-m+1):
 if all(c in"?"+d for c,d in zip(s[-i-m:],t)):s=s.replace(*"?a");exit(print(s[:-i-m]+t+s[l-i:]))
print("UNRESTORABLE")
# Judge status: Wrong Answer
data = [int(k) for k in input().split()]
print(data)
takashi = 500 * data[0]

if takashi >= data[1]:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
a = int(input())
b = int(input())
lst = [1, 2, 3]
lst.remove(a)
lst.remove(b)
print(lst[0])