peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    x=j+1
    y=n-1
    while y!=x+1 and y!=x:
      if L[i]+L[j]>L[(x+y)//2]:
        x=(x+y)//2
      else:
        y=(x+y)//2
    p=y if L[i]+L[j]>L[y] else x
    if L[i]+L[j]<=L[p]:
      count+=0
    else:
      count+=p-j
print(count)
# Judge status: Accepted
a, b, c = map(int,input().split())
if a+b < c:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
X, Y, Z = map(int, input().split())

"""
temp = Y
Y = X
X = temp

temp = Z
Z = X
X = temp
"""
print(Z, Y, X)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
s = input()
list = list(s)
list[K-1] == list[K-1].lower
print("".join(list))
# Judge status: Accepted
A,B,C,D=map(int,input().split())
Ans = [0] * 101
for i in range(100+1):
    if A<=i and i<B:
        Ans[i]+=1
    if C<=i and i<D:
        Ans[i]+=1

print(Ans.count(2))
# Judge status: Wrong Answer
num,loc = map(int,input().split())
dummy = ["" for i in range(num)]
moj = input()
count = 0
for j in moj:
  dummy[count] = j
  count = count + 1
S = dummy[loc-1]
W = S.swapcase()
dummy[loc-1] = W
print(dummy)
# Judge status: Accepted

KEY = "keyence"

def main():
    s = input()

    if s.startswith(KEY) or s.endswith(KEY):
        print("YES")
        return

    for i in range(1, len(KEY)):
        st = KEY[0:i]
        ed = KEY[i:]

        if s.startswith(st) and s.endswith(ed):
            print("YES")
            return

    print("NO")

main()
# Judge status: Accepted
n=int(input())
if n%2:
  print(0)
else:
  c=0
  n//=2
  while n:
    n//=5
    c+=n
  print(c)
# Judge status: Accepted
N, M = map(int, input().split())
E = [[] for _ in range(N)]

for _ in range(M):
    A, B = map(int, input().split())
    E[A-1].append(B-1)
    E[B-1].append(A-1)

ans = [None]*N
ans[0]=-1

queue=[0]
while queue:
    queue_new = []
    for q in queue:
        for e in E[q]:
            if ans[e] is not None: continue
            ans[e]=q
            queue_new.append(e)

    queue = queue_new

print("Yes")
for a in ans[1:]:
    print(a+1)
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

max1 = max(a)
max2 = sorted(a)[-2]

if a.count(max1) == 2:
    for i in range(n):
        print(max1)
elif a.count(max1) < 2:
    for i in range(n):
        if a[i] == max1:
            print(max2)
        else:
            print(max1)
# Judge status: Wrong Answer
N = int(input())
S = input()
diff = -1
ans = 0

for i in range(N):
  x = len(set(list(S[0:i])))
  y = len(set(list(S[i:len(S)])))
  if diff < x - y:
    diff = x - y
    ans = min(x, y)

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def get_ans(n):
    if n <= 1:
        return 0
    return get_ans(n - 1) + n - 1


def main():
    n, m = map(int, input().split())
    print(get_ans(n) + get_ans(m))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_max=max(a)

check = [0]*(a_max+1)

for i in a:
    if check[i] != 0:
        check[i] = 2
        continue
    if check[i] == 0:
        check[i] = 1
        for j in range(1,a_max//i):
            check[(j+1)*i] = 2

print(check.count(1))
# Judge status: Accepted
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-1)/(k-1)))
# Judge status: Wrong Answer
a, b, c, d=map(int,input().split())
k1=abs(a-b)
k2=abs(a-c)
k3=abs(b-c)
if k2<=d:
  print("Yes")
elif k1<=d or k3<=d:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
s = input()
r = len([i for i in range(n) if s[i] == 'R'])
g = len([i for i in range(n) if s[i] == 'G'])
b = len([i for i in range(n) if s[i] == 'B'])
ans = r * g * b
sub = 0
for j in range(n):
    for i in range(j):
        if s[i] == s[j]:
            continue
        k = 2 * j - i
        if k >= n or ((s[i] == s[k]) or (s[j] == s[k])):
            continue
        sub += 1
print(ans - sub)
# Judge status: Accepted
N,K=map(int,input().split(' '))
h = []
for i in range(K):
    d = int(input())
    l = list(map(int,input().split(' ')))
    for j in l:
        h.append(j)
print(N-len(list(set(h))))
# Judge status: Wrong Answer
n = int(input())

A = [0]*(n+1)

ans = 0
for i in range(n):
    a = int(input())
    ans += a//2
    A[i] = a%2
    
for i in range(n):
    if A[i]==1 and A[i+1]==1:
        ans += 1
        A[i+1] -= 1
        
print(ans)
# Judge status: Accepted
def func():
    n = int(input())
    a = [str(bin(int(x))) for x in input().split()]
    cnt = float('inf')
    for i in range(n):
        cnt = min(cnt, len(a[i]) - 1 - a[i].rfind('1'))
    print(cnt)


if __name__ == "__main__":
    func()
# Judge status: Wrong Answer
s,k,t=input(),int(input()),""
for q in s:
 if(p:=(122-ord(q))%26)<k:t+="a";k-=p
 else:t+=q
print(t[:-1]+chr((ord(t[-1])-97+k)%26+97))
# Judge status: Accepted
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())
          


n = 0
for i in range(N):
    if x[i] == y[i]:
        n = n+1
    elif n >=3:
        break
    elif x[i] != y[i]:
        n = 0

if n >= 3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
D = set(input().split())
num = {str(i) for i in range(10)} - D

while True:
    print(set(str(N)))
    if set(str(N)) == num:
        ans = N
        break
    else:
        N += 1
print(ans)
# Judge status: Accepted
a,b,c = map(str,input().split())

print("A"+b[0]+"C")
# Judge status: Wrong Answer
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    num = 0

    for i in range(1, N+1):
        y = math.floor(N/i)
        num += y*(y+1)*i/2

    print(num)


if __name__ == '__main__':
    main()
# Judge status: Accepted
MOD=10**9+7
N=int(input())
alist=list(map(int,input().split()))
#print(alist)

blist=[0]*60
for a in alist:
  bblist=[]
  while a:
    bblist.append(a%2)
    a//=2
    
  #print(bblist)
  for i in range(len(bblist)):
    blist[i]+=bblist[i]
      
#print(blist)
answer=0
pow2=1
for i in range(60):
  answer+=blist[i]*(N-blist[i])*pow2
  answer%=MOD
  pow2=2*pow2%MOD
  
print(answer)
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
sya = [0]*n
for a in A:
    sya[a-1]+=1
for i in range(n):
    print(sya[i])
# Judge status: Accepted
N = int(input())

a = list(map(int,input().split()))
cnt_4 = 0
cnt_2 = 0
for v in a:
    if v % 4 == 0:
        cnt_4 += 1
    elif v % 2 == 0:
        cnt_2 += 1
if cnt_2 <= 1:
    if N//2 <= cnt_4:
        print('Yes')
    else:
        print('No')
else:
    if (N-(cnt_2-1))//2 <= cnt_4:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

if P == Q:
    print(0)
    exit()

L = list(range(1, N+1, 1))

p = itertools.permutations(L, N)

cn = 0
cn1 = 0
cn2 = 0

for i in p:
    i = list(i)

    cn = cn + 1
    if i == P:
       cn1 = cn
    elif i == Q:
       cn2 = cn
       

print(abs(cn1 - cn2))
# Judge status: Accepted
n=int(input())
if n==1:
  print(0)
elif n==0:
  print(1)
# Judge status: Accepted
n=int(input())

for i in range(n,1000):
        s=str(i)
        if s[0] == s[1] == s[2]:
                print(i)
                exit()
# Judge status: Accepted
l = list(map(int, input().split()))

print(l.index(0)+1)
# Judge status: Accepted
from collections import deque

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

l, que = 0, deque([])
for i in s:
    que.append(i)
    if i == '(':
        l += 1
    if i == ')':
        if l == 0:
            que.appendleft('(')
        else:
            l -= 1
print(*que, ')' * l, sep='')
# Judge status: Accepted
import collections
N,K = map(int,input().split())
N_List = list(map(int,input().split()))

Chou_List = collections.Counter(N_List)
if len(Chou_List) <= K:
    print(0)
else:
    Chou_List = sorted(list(Chou_List.values()),reverse=True)
    print(sum(Chou_List[K:]))
# Judge status: Accepted
n=input()
if (n[0] == n[1] and  n[1] == n[2]) or (n[1]==n[2] and n[2] == n[3]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
s=input()

ans=s[1:].count("E")
c=ans

for i in range(1,n):
    if s[i]=="E":
        c-=1
    if s[i-1]=="W":
        c+=1
    ans=min(ans,c)

print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
n=1
while int(x*2**n)<=y:
  n+=1
print(n)
# Judge status: Accepted
N = int(input())
D = [list(map(int,input().split())) for _ in range(N)]

ans = 0

for i in range(N-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        ans += 1
    else:
        ans += 0
        
if ans >= 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,l=map(int,input().split())
ans=n*(l-1)+(n*(n+1))//2
if l>0:
    ans-=l
elif l+n-1<0:
    ans-=l+n-1
print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))

idx = a.index(1)

print(-(-idx // (k-1)) - (-(n - idx - 1) // (k-1)))
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N + 1, 2):
    count = 0
    n = 1
    while n * n <= i:
        if not i % n:
            if n * n == i:
                count += 1
            else:
                count += 2
        n += 2
    if count == 8:
        ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s_set = list(set(s))
win = max(s.count(s_set[i]) - t.count(s_set[i]) for i in range(len(s_set)))
print(max(0,win))
# Judge status: Wrong Answer
n = int(input().replace(" ",""))
if n%4 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
P, Q, R = map(int,input().split())
 
PQ = P + Q
QR = Q + R
RP = R + P

temp1 = min(PQ, QR)
temp2 = min(temp1, RP)

print(temp2)
# Judge status: Wrong Answer
S = input()
print(min([753 - int(S[i:i+3]) for i in range(len(S)-3 + 1)]))
# Judge status: Accepted
a, b, k = list(map(int, input().split()))
if 0 <= a - k:
    print(a - k, b)
elif 0 < b - (k - a):
    print(0, b - (k - a))
else:
    print(0, 0)
# Judge status: Accepted
from itertools import accumulate
n = int(input())
s = input()
aa = {'E':1, 'W':0}
e = list(map(aa.get, s))
aa = {'E':0, 'W':1}
w = list(map(aa.get, s))

ae = list(accumulate(e[::-1]))[::-1]
aw = list(accumulate(w))

ans = float('INF')
for i in range(1, n-1):
    if ans > ae[i+1] + aw[i-1]:
        ans = ae[i+1] + aw[i-1]
print(min([ans, ae[1], aw[-2]]))
# print(ae, aw)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

min_len = 2 * n
for i in range(n):
    if s[-1 - i:] == t[:i+1]:
        min_len = min(min_len, 2 * n - i - 1)
print(min_len)
# Judge status: Wrong Answer
n = input()
s = str(n)
l = len(s)
ans = 0
for i in range(l+1):
    ans += int(s[-i]) 
p = ans-(int(s[-l]))
if p%9 == 0:
    print("Yes")
    exit()
# Judge status: Accepted
N=int(input())

#https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

count=0
for i in range(1, N+1):
  if i%2==1 and len(make_divisors(i))==8:
    count+=1
print(count)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if(a*b <= 81):
    print(a*b)
else:
    print(-1)
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))

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

print(dp[-1])
# Judge status: Accepted
# A - Frog1
import numpy as np

N = int(input())
h = list(map(int, input().split()))
dp = [10**9]*(N+2)
dp[0] = 0

for i in range(N):
    if i+1<N:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i+2<N:
        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())

ar = [1,6,9,36,81,729,1296,6561,7776,46656,59049]

dp = [float('inf')]*101000
dp[0] = 0

for i in range(1, n+1):
    mins = float('inf')
    for a in ar:
        if i >= a:
            # i円の最小操作回数 = min(i-1円の最小操作回数+1, i-ar[j]円の最小操作回数+1
            mins = min(mins, min(dp[i-1] + 1, dp[i-a]+1))
    dp[i] = mins
print(dp[n])
# Judge status: Accepted
X = int(input())

ans = 1
for i in range(2, X + 1):
    p = 2
    while i ** p <= X:
        ans = max(ans, i ** p)
        p += 1
        #ans = max(ans, i ** p)

print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
jud=[]
for _ in range(M):
  a,b=map(str,input().split())
  jud.append(a)
  jud.append(b)
for j in range(1,N+1):
  print(jud.count(str(j)))
# Judge status: Accepted
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] = A[i] % 2
    if A[i] == 1 and i + 1 < N and A[i + 1] > 0:
        ans += 1
        A[i] -= 1
        A[i + 1] -= 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
fl = True
for i in A:
    if i&1:
        continue
    else:
        if i%3!=0 or i%5!=0:
            fl = False
            break

print('APPROVED') if fl else print('DENIED')
# Judge status: Accepted
n=input()

ans=753
for i in range(len(n)-2):
  a=int(n[i:i+3])
  if a==753:
    print(0)
    exit()
  b=abs(753-a)
  ans=min(b,ans)
  
print(ans)
# Judge status: Accepted
N = input()

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def digit_sum(x): 
    y = str(x) 
    y_len = len(y) 
    ans = 0
    for j in range(y_len):
        ans += int(y[j]) 

    return ans

answer=0
n,a,b = map(int,input().split()) 
for i in range(1, n+1):
    if a<= digit_sum(i) <= b:
        answer+=i

print(answer)
# Judge status: Wrong Answer
a,b=[int(x) for x in input().split()]

ans=max(a,b)*2
if a==b:
  ans+=1
print(ans)
# Judge status: Wrong Answer
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7:
    print("YES")
    exit()

print("NO")
# Judge status: Wrong Answer
x, y = map(int, input().split())

ans = 1
while x <= y:
    x *= 2
    ans += 1
else:
    print(ans)
# Judge status: Wrong Answer
s = input()
if 0 in [s.count("W"),s.count("E"),s.count("N"),s.count("S")]:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a == 2 or b == 2:
  print('No')
elif a == (4 or 6 or 9 or 11):
  if b == (4 or 6 or 9 or 11):
    print('Yes')
  else:
    print('No')
else:
  if b == (4 or 6 or 9 or 11 or 2):
    print('No')
  else:
    print('Yes')
# Judge status: Accepted
from queue import deque
s = []
for _ in range(3):
    s.append(deque(input()))
f = lambda x: ord(x)-ord('a')
nxt = 0
while len(s[nxt])>0:
    now = nxt
    nxt = f(s[now].popleft())
print(chr(nxt+ord('A')))
# Judge status: Accepted
a,b=list(map(int,input().split()))
d=b-a
sum=0
l=[]
for i in range(1,d):
    sum+=i
    l.append(sum)
print(sum-a)
# Judge status: Accepted
import sys
import math
x=int(input())
if not ( 1 <= x <= 10**15 ): sys.exit()

print(math.ceil(((x-6)/11)*2)+1)
# Judge status: Accepted
N=int(input())
s=list(input())
from collections import Counter
d=Counter(s)
ans=1
for v in d.values():
  ans*=(v+1)
ans-=1
ans=ans%(10**9+7)
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()
print("Yes" if s[:a].isdecimal() and s[a:b] == "-" and s[b:].isdecimal() and len(s) == a+b+1 else "No")
# Judge status: Accepted
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    if A <= sum(map(int, list(str(i)))) <= B:
        ans += i
print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
#ls=[0]+[int(x) for i in input().split()]
ls=list(map(int,input().split()))

#d=[]
#d.append(0)
ans=0
d=0
for i in ls:
	d=d+i
	if d>x:
		break
	ans +=1
	
print(ans+1)
# Judge status: Wrong Answer
T=input()
lis=[T[i] for i in range(len(T))]
for i in range(len(T)):
	if lis[i]=="?":
		if lis[min(i+1,len(T)-1)]!="P":
			lis[i]="P"
		else:
			lis[i]="D"
k="".join(lis)
print(k)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a==b and b==c and a%2==0 and b%2==0 and c%2==0:
    print(-1)
else:
    k=0
    while a%2==0 and b%2==0 and c%2==0:
        A=a
        B=b
        C=c
        a=B//2+C//2
        b=A//2+C//2
        c=A//2+B//2
        k+=1
    print(k)
# Judge status: Accepted
arg = input()
a, b = arg.split()
if int(a)*int(b)%2 == 0 :
  print("Even")
else :
  print("Odd")
# Judge status: Accepted
def kill(life):
    if life == 1:
        return 1
    elif life > 1:
        return kill(life//2) * 2 + 1
h = int(input())
print(kill(h))
# Judge status: Wrong Answer
S = input()
N = len(S)
ans = 1
i = 1
prev_two = 1
while i < N:
    if prev_two:
        i += 1
        prev_two = 0
    elif S[i] == S[i-1]:
        i += 2
        prev_two = 1
    else:
        i += 1
    ans += 1
if i == N:
    ans -= 1
print(ans)
# Judge status: Wrong Answer
def mulit(a):
  a_copy = list(a)
  return len(a) == len(set(a_copy))

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
a_len = len(A)
answer = []
for i in range(0, a_len-2):
  for j in range(i+1, a_len-1):
    for k in range(j+1, a_len):
      answer.append([A[i], A[j], A[k]])

answer = [i for i in answer if mulit(i)]
answer_len = len(answer)
print(f"{answer_len}")
# Judge status: Accepted
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))
# Judge status: Accepted
A, B, C, D = map(int, input().split())
start = max(A, C)
end = min(B, D)
print(end - start if start <= end else 0)
# Judge status: Wrong Answer
n,m = list(map(int, input("").split()))
a=set([int(input()) for i in range(m)])

print(a)

mod = 10 ** 9 + 7

dp = [0] * (n+2)
dp[1] = 1

for i in range(2,n+2):
    if i-1 not in a:
        dp[i] = dp[i-1] % mod + dp[i-2] % mod
        
print(dp[n+1] % mod)
# Judge status: Wrong Answer
s =input()
cnt =0
for i in range(int(len(s)//2)-1):
    if s[i]!=s[i-1]:
        cnt +=1
        
print(cnt)
# Judge status: Wrong Answer
import numpy as np
d, n = list(map(int, input().split()))

print(pow(100, d)*n)
# Judge status: Accepted
def solve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        ans += min(B[i], A[i] + A[i + 1])
        A[i + 1] = min(A[i + 1], max(A[i] + A[i + 1] - B[i], 0))
    print(ans)


solve()
# Judge status: Accepted
n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

num = 0

for i, b in enumerate(b):
    if b > a[i]:
        b -= a[i]
        num += a[i]
        if b > a[i+1]:
            num += a[i+1]
            a[i+1] = 0
        else:
            a[i+1] -= b
            num += b
    else:
        num += b

print(num)
# Judge status: Wrong Answer
a = input()

if a.lower() == a:
  print('A')

else:
  print('a')
# Judge status: Accepted
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
A = []
for _ in range(5) :
  A.append(int(input()))

pmax = 0
sumA = 0
for i in range(5) :
  p = 0
  while A[i]%10 != 0 :
    A[i] += 1
    p += 1
  sumA += A[i]
  pmax = max(pmax, p)

print (sumA - pmax)
# Judge status: Wrong Answer
N=int(input())
S=input()
c = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i] != S[j]:
      RGB = 'RGB'.strip(S[i]).strip(S[j])
      S_ = S[j+1:]
      d = j - i - 1
      S_ = S_[:d]+S_[d+1:]
      c += S_.count(RGB)
print(c)
# Judge status: Accepted
import math
n,h=map(int,input().split())
a_l=[]
b_l=[]
c=0
for i in range(n):
  a,b=map(int,input().split())
  a_l.append(a)
  b_l.append(b)
a_l.sort()
b_l.sort()
for i in range(1,n+1):
  if a_l[-1]<=b_l[(-1)*i]:
    h-=b_l[(-1)*i]
    c+=1
    if h<=0:
      break
  else:
    break
if h>0:
  c+=math.ceil(h/a_l[-1])
print(c)
# Judge status: Accepted
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
if s<t:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
d_list = list(map(int,input().split()))
p = 998244353
import collections
result = 0
check = True
for i in range(1,len(d_list)):
  if d_list[i] == 0:
    check = False
 
if d_list[0] != 0:
  print(result)
elif check == False:
  print(result)
else:
  result = 0
  c = collections.Counter(d_list)
  for i in range(1,max(d_list) + 1):
    if i == 1:
      result += 1
    elif  c[i] == 0:
        result = 0
    else:
      result = result * (c[i -1] ** c[i])

  print(result % p)
# Judge status: Accepted
m = int(input())
mod = m % 1000
if mod == 0:
    print(0)
else:
    print(1000 - mod)
# Judge status: Accepted
N = int(input())
a = N % 10
if a == 2 or a == 4 or a ==5 or a == 7 or a == 9:
    print('hon')
elif a == 3:
    print('bon')
else:
    print('pon')
# Judge status: Wrong Answer
import numpy as np
p,q= input().split()
a,b =(int(p), int(q))
list_np = np.arange(-1000000, 1000000,1)
ans_list = []
for i in range(a):
    ans_list.append(b + i)
    ans_list.append(b - i)
ans_list.pop(0)
ans_list.sort()
ans=''
print(ans_list)
for i in range(a*2 -1):
    if i < a * 2 -1 :
        ans += str(ans_list[i])
        ans +=' '
    else:
        ans +=str(ans_list[i])
        break
print(ans)
# Judge status: Wrong Answer
import sys
s = sorted(list(str(input())))
t = sorted(list(str(input())), reverse = True)
u = min(len(s), len(t))
for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print('Yes')
        sys.exit()
    if s[i] > t[i]:
        print('No')
        sys.exit()
    elif len(s) < len(t):
        print('Yes')
        sys.exit()
    elif len(s) >= len(t):
        print('No')
        sys.exit()
# Judge status: Accepted
n,k = map(int,input().split())
r,s,p = map(int,input().split())
x=0
t = list(input())
for i in range(k):
  temp=t[i::k]
  for j in range(1,len(temp)):
    if temp[j-1]==temp[j]:
      temp[j]='x'
      t[j*k+i]='x'
point=0
for i in t:
  if i == 'r':
    point+=p
  if i == 's':
    point+=r
  if i == 'p':
    point+=s
print(point)
# Judge status: Accepted
import math

N = int(input())
S = input()
alphabets = ['A']
for i in range(25):
  alphabets.append(chr(ord(alphabets[-1]) + 1))
ans = ''
for s in S:
  ans += alphabets[(alphabets.index(s)+N)%26]

print(ans)
# Judge status: Accepted
def resolve():
    N, D = list(map(int, input().split()))
    print(N//(2*D+1) if N%(2*D+1)==0 else (N//(2*D+1))+1)
    
if '__main__' == __name__:
    resolve()
# Judge status: Accepted
N,A,B=map(int,input().split())
k=0
for i in range(0,N+1):
  D=list(str(i))
  C=sum(int(j) for j in D)
  if A<=C<=B:
            k += i
print(k)
# Judge status: Accepted
def search_group(a):
    if a in zone_one:
        ret = 1
    elif a in zone_two:
        ret = 2
    else:
        ret = 3
    return ret

zone_one = {1,3,5,7,8,10,12}
zone_two = {4,6,9,11}
zone_three = {2}

x,y = map(int,input().split())

ret_x = search_group(x)
ret_y = search_group(y)

if ret_x == ret_y:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
print(4*(n**2)//15)