peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
si = sys.stdin.readline
so = sys.stdout.write


def main():
    n = int(si())
    s = si()[:-1]
    cnt = s.count('R')*s.count('G')*s.count('B')

    for i in range(n-2):
        for j in range(i+1, n-1):
            k = j+j-i
            if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt -= 1

    print(cnt)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    a, b = map(int, input().split())

    if a == 0 or b == 0:
        print("Zero")
    elif a < 0 and b < 0:
        if (b - a + 1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")
    elif a < 0 and 0 < b:
        print("Zero")
    elif 0 < a and 0 < b:
        print("Positive")


if __name__ == "__main__":
    main()
# Judge status: Accepted
def normalized(s):
  indexes = {}
  def translated(ch):
    if ch not in indexes:
      indexes[ch] = len(indexes)
    return indexes[ch]

  return list(map(translated, s))


def main():
  s = input()
  t = input()

  print('Yes' if normalized(s) == normalized(t) else 'No')


if __name__ == '__main__':
  main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

di = {}
B = set(A)
for b in B:
  di[b] = 0
total = 0
for a in A:
  di[a]+=1
for v in di.values():
  total += v*(v-1)//2
#print(di.values(),total)
ans = []
for a in A:
  ans.append(total-di[a]+1)
print(*ans,sep='\n')
# Judge status: Accepted
s = input()

if s == s[::-1]:
    s1 = s[: len(s) // 2]
    s2 = s[(len(s) // 2) + 1:]
    if s1 == s2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
s,t = map(str,input().split())
a,b = map(int,input().split())
u = input()

if s == u:
    print(a-1 , b)
else:
    print(a , b-1)
# Judge status: Accepted
Blue=[]
Red=[]

n=int(input())
for i in range(n):
    s=input()
    Blue.append(s)
    
m=int(input())
for i in range(m):
    t=input()
    Red.append(t)

ans=0
for a in Blue:
    plus = Blue.count(a)
    minus = Red.count(a)
    point = plus - minus
    ans = max(ans, point)
print(ans)
# Judge status: Accepted
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))

x.append(X)
x=sorted(x)
gcd=x[1]-x[0]

for i in range(1,N+1):
    gcd=fractions.gcd(gcd,x[i]-x[i-1])
print(gcd)
# Judge status: Accepted
import math

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

gcd_l = [0]
gcd_r = [0]

for n in range(N):
    gcd_l.append(math.gcd(gcd_l[n], A[n]))
    gcd_r.append(math.gcd(gcd_r[n], A[-(n + 1)]))
#print(gcd_r)
#print(gcd_l)

gcd_r = gcd_r[::-1]
#print(gcd_r)

ans = []
for n in range(N):
    ans.append(math.gcd(gcd_l[n], gcd_r[n + 1]))
print(max(ans))
#print(ans)
# Judge status: Wrong Answer
x, y, z = input().split()

print(x, y, z)

# print("shuffle")
c = x
x = y
y = c
# print(1, "回目", x, y, z)
c = x
x = z
z = c
# print(2, "回目", x, y, z)

# print("result")
print(x, y, z)
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))

a = []

for i in range(n):
    if i == 0:
        a.append(b[0])
    elif i == n-1:
        a.append(b[-1])    
    else:
        a.append(min(b[i-1], b[i]))

print(sum(a))
# Judge status: Accepted
N , A , B = map(int, input().split())

L = [i for i in range(1, N+1)]
M = []
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

for i in range(N):
    if digitSum(L[i]) >= A and digitSum(L[i]) <= B:
        M.append(L[i])
        

        
print(sum(M))
# Judge status: Accepted
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,n = mi()
p =li()

# small side
xs = x
while 1:
    if xs not in p:
        break
    xs -= 1

# large side
xl = x
while 1:
    if xl not in p:
        break
    xl += 1

if x-xs > xl - x:
    print(xl)
else:
    print(xs)
# Judge status: Accepted
N,T=map(int,input().split())
ans=2000
for i in range(N):
  c,t=map(int,input().split())
  if t<=T:
    ans=min(ans,c)
print(ans if ans!=2000 else "TLE")
# Judge status: Wrong Answer
a = int(input())
s = input()

if a < 3200:
    print('red')

elif a >= 3200:
    print('s')
# Judge status: Accepted
mod = 10**9 + 7
 
def C(n, r, mod):
    x=y=1
    for i in range(r):
        x *= n; y *= r
        x %= mod; y %= mod
        n -= 1; r -= 1
    return x * pow(y, mod - 2, mod) % mod
 
 
n, a, b = map(int, input().split())
 
print((pow(2, n, mod) - 1 - C(n, a, mod) - C(n, b, mod)) % mod)
# Judge status: Accepted
s = list(input())
K = int(input())

for i in range(len(s)):
    if K == 0:
        continue
    n = ord(s[i]) - ord("a")
    if n == 0:
        continue
    m = 26 - n
    if K >= m:
        s[i] = "a"
        K -= m

if K != 0:
    K %= 26
    s[-1] = chr(ord(s[i]) + K)

print("".join(map(str,s)))
# Judge status: Accepted
# -*- coding: utf-8 -*-
n = int(input())
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    tmp = sum(a1[:i+1]) + sum(a2[i:])
    if tmp > ans:
        ans = tmp
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
WL = 0
WR = 0
BL = 0
BR = 0

for i in range(N):
    if S[i] == '#':
        BR += 1
    else:
        WR += 1

ans = BL+WR

for i in range(N):
    if S[i] == '#':
        BR -= 1
        BL += 1
    else:
        WR -= 1
        WL += 1
    ans = min(ans,BL+WR)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
now = 1
for i in range(15000):
  now = A[now-1]
  if now == 2:
    print(i+1)
    exit()
print(-1)
# Judge status: Accepted
# input
S = input()
K = int(input())

# check
n_num = 0
for i in range(len(S)):
    if S[i] == "1":
        n_num += 1
    else:
        break

if n_num >= K:
    print(1)
else:
    print(S[n_num])
# Judge status: Wrong Answer
n=int(input())
a=list(input().split())
b=list(input().split())
for i in range(len(a)):
    a[i]=int(a[i])
for i in range(len(b)):
    b[i]=int(b[i])
print(min(sum(a),sum(b)))
# Judge status: Accepted
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

avg = [T - H[i] * 0.006 for i in range(N)]
diff = [abs(avg[i] - A) for i in range(N)]
idx = diff.index(min(diff))
print(idx + 1)
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if k % 2 == 0:
    print(a - b)
else:
    print(b - a)
# Judge status: Accepted
X,Y,A,B,C=map(int,input().split())
p=sorted([int(p) for p in input().split()])[-X:]
q=sorted([int(q) for q in input().split()])[-Y:]
r=[int(r) for r in input().split()]
lst=sorted(p+q+r)
print(sum(lst[-(X+Y):]))
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)

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

D = [-1] * N

for _ in range(M):
    s, c = map(int, input().split())

    if D[s-1] == -1 or D[s-1] == c:
        D[s-1] = c
    else:
        print('-1')
        exit()

if D[0] == -1:
    D[0] = 1
elif D[0] == 0:
    print('-1')
    exit()

ans = []

for d in D:
    if d == -1:
        ans.append(str(0))
    else:
        ans.append(str(d))

# print(ans)
print(''.join(ans))
# Judge status: Accepted
N,P = map(int,input().split())
A = list(map(int,input().split()))
odd = 0
even = 0
for i in range(N):
  if A[i] % 2 == 0:
    even += 1
  else:
    odd += 1
if odd == 0:
  print(0) if P==1 else print(2**N)
else:
  N -=1
  print(2**N)
# Judge status: Accepted
l = list(map(int,input().split()))
for i in range(5):
   if(l[i]==0):
      print(i+1)
      break
# Judge status: Wrong Answer
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(4):
    for j in range(i+1,5):
        if abs(a[i]-a[j])>k:
            print(":)")
            exit()
print("Yay!")
# Judge status: Accepted
s = input()
n = len(s)
L=[0]
R=[0]
cnt = 0

for i in range(n):
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
    L.append(cnt)
cnt = 0
s = s[::-1]
for i in range(n):
    if s[i]  == '>':
        cnt += 1
    else:
        cnt = 0
    R.append(cnt)

R = R[::-1]
ans = 0
for i in range(n+1):
    ans += max(R[i], L[i])

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

if len(S)%2==0 and S[:len(S)//2]==S[len(S)//2:]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#!/usr/bin/env python3
from itertools import*
from fractions import*
ac = lambda l: list(accumulate([0] + l, gcd))
n, *a = map(int, open(0).read().split())
print(max(gcd(s, t) for s, t in zip(ac(a), ac(a[::-1])[::-1][1:])))
# Judge status: Wrong Answer
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
N = int(input())

cntt = 0
for i in range(1, N+1, 2):
    cnt = 0
    for j in range(1, int(math.sqrt(i)), 2):
        if i%j==0:
            cnt += 2
    if cnt == 8:
        cntt += 1
print(cntt)
# Judge status: Accepted
A,B,C = map(int,input().split())
print(max(C-A+B,0))
# Judge status: Accepted
def main():
    import math

    N,D = map(int,input().split())
    print(math.ceil(N/(2*D+1)))

    
if __name__=="__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

a,b,c = sorted(list(map(int,input().split())))
print('YES' if a==b and b==5 and c==7 else 'NO')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A = A * 2
A = sorted(A, reverse=True)
A.pop(0)
SUM = 0
for i in range(N-1):
  SUM += A[i]
print(SUM)
# Judge status: Wrong Answer
n = int(input())
a_li = list(map(int,input().split()))

import collections
c = collections.Counter(a_li)

mc = c.most_common()
# [('a', 4), ('c', 2), ('b', 1)]

if len(mc) == 1:
    print(0)
    exit()
all_li = []
for m in mc:
    if m[1]>=2:
        all_li.append(m[0])
if len(all_li) <= 1:
    print(0)
    exit()
all_li.sort(reverse=True)
print(all_li[0]*all_li[1])
# Judge status: Accepted
N, A, B = map(int, input().split())
ab = A + B
cnt = N // ab
remain = N - (cnt * ab)
blue = 0
if remain > A:
    blue = A
else:
    blue = remain
ans = A * cnt + blue
print(ans)
# Judge status: Accepted
from math import ceil as c,floor as f
a,b=map(int,input().split())
ah,bh=a+.99,b+.99
a1,a2=c(a/.08),f(ah/.08)
b1,b2=c(b/.1),f(bh/.1)
if a2<b1 or b2<a1: print(-1)
else:
    if b1<=a1<=b2: print(a1)
    elif a1<=b1<=a2: print(b1)
    elif b1<=a2<=b2: print(a2)
    elif a1<=b2<=a2: print(b2)
# Judge status: Accepted
x, y = list(map(int, input().split()))
bits = len(format(y, 'b'))

cnt = 0
for i in range(bits):
  if x * (2 ** i) > y:
    break
  cnt += 1
print(cnt)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *

S = list(input()[:-1])
S[3] = '8'
print(''.join(S))
# Judge status: Accepted
mod = 1000000007

n = int(input())

a = 1
b = 1
c = 1
for i in range(n):
    a = a * 10 % mod
    b = b * 8 % mod
    c = c * 9 % mod


d = (a - 2 * c + b + mod) % mod
d = (d + mod) % mod
print(d)
# Judge status: Wrong Answer
s = list(input())
l = len(s)
rain =int()
for x in range(l):
  if s[x]=="R":
    rain=rain+1
  else:
    if rain==0:
      rain=0
    else:
      rain=rain
print(rain)
# Judge status: Wrong Answer
n = int(input())
hs = list(map(int, input().split()))

result = 'Yes'

for i in range(1, n - 1):
    cur, prev, nex = hs[i], hs[i - 1], hs[i + 1]
    if cur < prev or cur > nex:
        cur -= 1
        hs[i] = cur

    if not prev <= cur <= nex:
        result = 'No'
        break


print(result)
# Judge status: Accepted
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    x = 0
    ans = 0

    for i in range(1, n):
        x = (x + a_list[i - 1]) % mod
        ans = (ans + a_list[i] * x) % mod

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
A, B = input().split(" ")
A = int(A.strip())
B = int(B.strip().replace(".", ""))
print(A * B // 100)
# Judge status: Wrong Answer
import resource

resource.setrlimit(
    resource.RLIMIT_DATA,
    (1024 * 1024 ** 2, -1))

n = int(input())
s = input().split()

min_s = s[0]
count = 0

for num in s:
  if min_s >= num:
    count += 1
    if min_s > num:
      min_s = num

print(count)
# Judge status: Accepted
k = int(input())
a,b = map(int,input().split())
x = a//k
y = b//k
if y - x == 0:
  if a%k == 0:
    print('OK')
  else:
    print('NG')
else:
  print('OK')
# Judge status: Accepted
#B
n = int(input())
l = list(map(int, input().split()))
lmax = max(l)
l.sort(reverse=True)
if lmax < sum(l[1:]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
for i in range(1,1000000):
  if (i*b+c)%a==0:
    print('YES')
    exit()
    
print('NO')
# Judge status: Accepted
s=input()
a=[0]*(len(s)+1)
for i in range(len(s)):
    if s[i]=="<":
        a[i+1]=a[i]+1
for i in range(len(s)-1,-1,-1):
    if s[i]==">":
        a[i]=max(a[i],a[i+1]+1)
print(sum(a))
# Judge status: Accepted
d, n = map(int, input().split())
if n < 100:
  ans = n * 100**d
  print(ans)
else:
  ans = 101 * 100**d
  print(ans)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print('0')
elif b<=d:
    print(min(b-c,b-a))
else:
    print(min(d-a,d-c))
# Judge status: Accepted
K = int(input())
j = 7%K
p = -1
for i in range(1,K+1):
    if j == 0:
        print(i)
        p = 0
        break
    j = ((j*10)+7)%K
if p == -1:
    print("-1")
# Judge status: Accepted
n = int(input())
A = [0]*n
for i in range(n):
    count = 0
    flg_odd = 0
    l = i
    i = i+1
    while(True):
        if ( i%2 != 0):
            flg_odd = 1
        if ( flg_odd == 1):
            A[l] = count
            break
        i = i//2
        count += 1
m = A.index(max(A))
print(m+1)
# Judge status: Accepted
import numpy as np

N = int(input())
A = np.fromiter(map(int, input().split()), np.int64)

m = 1000000007

result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % m
print(result)
# Judge status: Accepted
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍することで，最小最大を逆転

heapq.heapify(a)#優先度付きキューに変換

for i in range(m):
  tmp = heapq.heappop(a)
  heapq.heappush(a,(-tmp//2)*(-1))#負の剰余では切り捨て方向が異なってしまうので，いったんプラスにする．
  
print(-sum(a))
# Judge status: Accepted
# ABC098C
N = int(input())
S = input()

all_W_E = [0, 0]
for s in S:
    if s == "W":
        all_W_E[0] += 1
    else:
        all_W_E[1] += 1

now_W = 0
now_E = 0
ans_list = [0] * N

for i in range(N):
    if S[i] == "W":
        ans_list[i] = (now_W + all_W_E[1] - now_E)
        now_W += 1
    else:
        ans_list[i] = (now_W + all_W_E[1] - now_E - 1)
        now_E += 1

##print(ans_list)
print(min(ans_list))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

ans = "No"
for i in range(1, B + 1):
    if i * A % B == C:
        ans = "Yes"

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) 
           for nesya in range(m)]
start = set()
end = set()
for ab in ab_list:
  if ab[0] == 1:
    start.add(ab[1])
  elif ab[1] == n:
    end.add(ab[0])
ans = start&end
if len(ans) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
n = int(input())
s = input().split()[0]
s = list(s)
sum = 0
for i in range(1, n):
    for j in range(i, n):
        for k in range(j, n):
            if ((s[i-1]!=s[j-1])&(s[j-1]!=s[k-1])&(s[i-1]!=s[k-1]))&((j-i)!=(k-j)):
                sum+=1
print(sum)
# Judge status: Accepted
A = list(map(int, input().split()))
if sum(A) >= 22:
    print("bust")
else:
    print("win")
# Judge status: Wrong Answer
n,_ = map(int,input().split())
l = sorted(input() for _ in range(n))
print(l)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = [list(input().rstrip()) for _ in range(N)]
    B = [list(input().rstrip()) for _ in range(M)]
    mv = N - M + 1
    for i in range(mv):
        for j in range(mv):
            sub_A = [r[j:j+M] for r in A[i:i+M]]
            if sub_A == B:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
l, m = list(), list()
for _ in range(int(input())):
    x, y = map(int, input().split())
    l.append([x, y])
    m.append([y, x])
l.sort(), m.sort()
print(max(l[-1][0]-l[0][0]+l[-1][1]-l[0][1], m[-1][0]-l[0][0]+l[-1][1]-l[0][1]))
# Judge status: Accepted
n=int(input())
mod=10**9+7
ans=pow(10,n,mod)
ans-=pow(9,n,mod)*2
ans+=pow(8,n,mod)
ans%=mod
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
    
for i in range(K, N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    X = input().strip()
    stack = list()
    for s in X:
        if s == "S" or len(stack) < 1:
            stack.append(s)
        elif s == "T" and stack[-1] == "T":
            stack.append(s)
        else:
            stack.pop()
    return len(stack)


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n = int(input())
w = list(map(int,input().split()))
ans = 10000000000

for i in range(1,n):
  x = abs(sum(w[:i]) - sum(w[i:]))
  if x < ans:
    ans = x

print(ans)
# Judge status: Accepted
num = int(input())
grid = [list(int(s) for s in input().split()) for _ in range(2)]

max = 0
for i in range(num):
    candies = sum(grid[0][: i + 1] + grid[1][i: ])
    max = candies if max < candies else max

print(max)
# Judge status: Accepted
h=int(input())
ans=0
t=1
while t<=h:
    t*=2
print(t-1)
# Judge status: Wrong Answer
n=int(input())
print('ABC' if 1<=999 else 'ABD')
# Judge status: Accepted
print(0 if input() == '1' else 1)
# Judge status: Accepted
data = list(map(int, input().split()))
A = data[0]
B = data[1]
C = data[2]

rest = A - B
remain = max(0, C - rest)

print(remain)
# Judge status: Wrong Answer
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**8] * n
dp[0] = 0

for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
print(dp[n - 1])
# Judge status: Accepted
x,y=map(int, input().split())
if y>=2*x and 4*x>=y:
  if (y-2*x)%2==0 and (4*x-y)%2==0:
    print("Yes")
  else:
    print("No")
else:
  print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
print((a*b)//2)
# Judge status: Wrong Answer
n,d = map(int,input().split())
try:
  a = [list(map(int,input().split())) for j in range(0,n)]
except EOFError:
  pass
c = 0
r = 0
for i in range(0,n):
  for j in range(i+1,n):
    for k in range(0,d):
      c+=(a[i][k]-a[j][k])**2
ans = c**(1/2)
if isinstance(ans,int) == True:
  r += 1
print(r)
# Judge status: Accepted
a, b, c = list(map(int, input().rstrip().split()))
if (c >= a and c <= b) or (c >= b and c <= a):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
d.sort(key=lambda x: x[1])
ans = 'Yes'
t = 0
for i in d:
    t += i[0]
    if t>i[1]:ans='No'
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = 0
for i in range(a, b + 1):
  if i % c == 0:
    ans += 1
print(ans)
# Judge status: Wrong Answer
from math import log

x, y = map(int, input().split())
a = int(log(y // x, 2))
print(a + 1)
# Judge status: Accepted
x = int(input())
for a in range(-118,119):
    for b in range(-119,118):
        if a**5 - b**5 == x:
            print(a,b)
            exit()
# Judge status: Accepted
N=int(input())
print(N*(N-1)//2)
# Judge status: Accepted
N = int(input())

def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

ans = 0
for i in range(1,-(-N//2)+1):
    now = 2*i-1
    if len(make_divisors(now)) == 8:
        ans += 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
count = 0
t = 0

for c in range (1, N):
  t = N-c
  for a in range(1,t):
    if t % a == 0:
      count +=1
print(count)
# Judge status: Accepted
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
C = [int(a) for a in input().split()]

ans = sum(B)
pre_A = -1
for i in range(N):
    if pre_A + 1 == A[i]:
        ans += C[pre_A - 1]
    pre_A = A[i]

print(ans)
# Judge status: Accepted
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
# table = [0] * 100005
table = [0] * n
for i in range(1, n):
    table[i] = table[i - 1]
    if s[i] == "C" and s[i - 1] == "A":
        table[i] += 1

for i in range(q):
    first, last = map(int, input().split())
    print(table[last - 1] - table[first - 1])
# Judge status: Accepted
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b,c,k = map(int,input().split())

    if abs(a-b)>10**18:
        print("Unfair")
    elif k % 2==0:
        print(a-b)
    else:
        print(b-a) 

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
lst = list(map(int,input().split()))

ans = []
for i in range(len(lst)):
    num = lst.index(i+1)
    ans.append(num)
print(ans)
# Judge status: Accepted
input1 = str(input())

temp = ""

for i in range(len(input1)):
    if input1[i] == "P":
        temp += "P"
    else:
        temp += "D"
        
print(temp)
# Judge status: Accepted
N = list(map(int, str(input())))
s = sum(N)
 
if(s % 9 == 0): print('Yes')
else: print('No')
# Judge status: Accepted
a,v=map(int,input().split())
b,w=map(int,input().split())
T=int(input())
if abs(a-b)<=T*(v-w):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
gcd_sum_of_2 = 9
if N == 1:
    print(1)
elif N == 2:
    print(gcd_sum_of_2)
else:
    M = N - 2
    for i in range(M):
        gcd_sum_of_2 += (i + 2) * 3 + i + 3
    print(gcd_sum_of_2)
# Judge status: Accepted
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)

for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    while b != 0:
        c = a%b
        a = b
        b = c
    return a

for i in range(1, n):
    A[i] = gcd(A[i-1], A[i])
print(A[-1])
# Judge status: Accepted
n = int(input())
x = [int(input()) for i in range(5)]
d = n // min(x)
if n%min(x)==0:
  print(d+4)
else:
  print(d+5)
# Judge status: Wrong Answer
n = input()
if len(set(n)) <= 2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
    ans += A[0] - x
    A[0] = x
 
for i in range(1, N):
    if A[i]+A[i-1] > x:
        ans += A[i]+A[i-1]-x
        A[i] -= A[i]+A[i-1]-x
 
print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l1 = [0]
for i in l:
  a = l1.pop()
  if i==a+1:
    l1.append(a)
    l1.append(i)
  else:
    l1.append(a)
if len(l1)==1:
  print(-1)
else:
  print(n-len(l1)+1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
A=[]
for i in range(n):
    x=0
    for j in range(10**5):
        if a[i]%2==0:
            a[i]//=2
            x+=1
        if a[i]%2!=0:
            A.append(x)
            break
print(min(A))