peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
a=[2,1]
if n==1:
  print(1)
else:
  for i in range(1,n):
    a.append(a[-1]+a[-2])
  print(a[-1])
# Judge status: Accepted
k=int(input())
n=7
for i in range(k+1):
    if n%k==0:
        print(i+1)
        exit()
    n=(10*n+7)%k
print(-1)
# Judge status: Accepted
A, B = map(int, input().split())

if A == B:
    print('Draw')
elif A == 1:
    print('Alice')
elif B == 1:
    print('Bob')
elif A > B:
    print('Alice')
elif A < B:
    print('Bob')
# Judge status: Wrong Answer
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    print(i,j)
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if ((abs(b-a)<=d) and (abs(c-b)<=d)) or (abs(c-a)<=d) :
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n, m = map(int, input().split())

print(n * (n-1) // 2 + m * (m-1) // 2)
# Judge status: Wrong Answer
from collections import Counter


def solve(n, arr):
    arr.sort()

    if arr[0] != 0:
        return 0

    c = Counter(arr)

    if len(c) != max(c.keys()) + 1:
        return 0

    c = list(c.values())

    prev = c[0]
    ans = 1
    mod = 998244353

    for i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))
# Judge status: Accepted
import sys

n=int(input())
ba=[[0]*2 for i in range(n)]
for i in range(n):
    ai,bi=map(int,input().split())
    ba[i]=[bi,ai]
    
ba.sort() 

t=0
for i in range(n):
    t+=ba[i][1]
    if t>ba[i][0]:
        print("No")
        sys.exit()
print("Yes")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [map(int,input().split()) for _ in range(Q)]
B, C = [i for i in zip(*BC)]
#print(B,C)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

ans = sum(A)
for q in range(Q):
  bc = C[q] - B[q]
  ans = ans + bc * dic.get(B[q],0)
  dic[C[q]] = dic.get(C[q],0) + dic.get(B[q],0)
  dic[B[q]] = 0
  print(ans)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())

    ans = int(b / a)
    if b % a == 0:
        print(ans)
    else:
        print(ans + 1)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
A,B,T=map(int,input().split())
print((T+0.5)//A *B)
# Judge status: Accepted
#ABC043-B
s = input()

result = []

for i in s:
    if i == '0':
        result.append('0')
    elif i == '1':
        result.append('1')
    else:
        if len(result) == 0:
            continue
        else:
            result.pop(-1)
            
print("".join(result))
# Judge status: Wrong Answer
"""
abc141-b
"""

import sys

S = input()

for i in range(int(len(S))-1):
    if (i % 2 == 0):
        if (S[i] == "L"):
            print("No")
            sys.exit()
    else:
        if (S[i] == "R"):
            print("No")
            sys.exit()

print("Yes")
# Judge status: Accepted
N = int(input())
H = [i for i in map(int,input().split())]
ok=1
for i in range(N-1,0,-1):
  if H[i-1] > H[i]:
    H[i-1] -= 1

for i in range(1,N-1):
  if not H[i-1] <= H[i] <= H[i+1]:
    ok=0
    break
      
if ok:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n,k=map(int,input().split())
lst=list(input())
while True:
    ans=True
    s=str(n)
    for i in s:
        if i in lst:
            ans=False
            break
    if ans==True:
        print(n)
        break
    n+=1
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

m = max(a)
a = sorted(a)

ans = 0

for i in a:
    if abs(m/2-i) < abs(m/2-ans):
        ans = i

print(m, ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

ans = -100
tmp = 10**10

for i in range(-100, 101):
    t = 0
    for j in a:
        t += (j - i) ** 2
    if t < tmp:
        ans = i
        tmp = t

print(tmp)
# Judge status: Accepted
import math

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

count = 0
for i in range(n):
    x, y = map(int, input().split())
    a = math.sqrt(x**2 + y**2)
    if a <= d:
        count += 1

print(count)
# Judge status: Wrong Answer
n = 123456789

m = {}
for i in range(0,26):
  m[i] = chr(97+i)

ans = ''
while 1:

  n -= 1

  x = n // 26
  y = n % 26

  ans = m[y] + ans

  n = x
  if n == 0:
    break

print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = list(input())
c = Counter(s)
ans = 1
for i in c.values():
    ans =  ans * ((i+1) % 1000000007)
print(ans-1)
# Judge status: Accepted
n = int(input())

k = []

for i in range(1, 10):
    for j in range(1, 10):
        if i <= j:
            k.append(i * j)

if n in k:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#AGC027-A
n,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

cnt = 0
flg = True
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        cnt += 1
        
    else:
        flg = False
        break
        
if flg and x != 0:
    cnt -= 1
print(cnt)
# Judge status: Wrong Answer
import numpy as np

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

As = np.array([["." for n in range(N)] for nn in range(N)])
for n in range(N):
  As[n,:] = np.array(list(input()))
  
Bs = np.array([["." for n in range(M)] for nn in range(M)])
for m in range(M):
  Bs[m,:] = np.array(list(input()))
  
ok = False
for j in range(N-M):
    if (As[:M,j:j+M] == Bs).all():
      ok = True
      break
if ok:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n + 1)]
for i in ab:
    t[i[1]].append(i[0])
flag = False
for j in t[n]:
    if 1 in t[j]:
        flag = True
        break
print("POSSIBLE") if flag else print("IMPOSSIBLE")
# Judge status: Accepted
a,b = map(int,input().split())
if a>b:print(a-1)
else:print(a)
# Judge status: Wrong Answer
s = input()
key = "keyence"
ptr = 0
cnt = 0
f = True
if s == key:
    print("YES")
    exit()

for i in range(len(s)):
    if ptr != 7 and s[i] == key[ptr]:
        f = True
        ptr += 1
    else:
        if f:
            cnt += 1
        f = False


print("YES" if ptr == 7 and cnt <= 1 else "NO")
# Judge status: Accepted
N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
# print(T)
T.sort()
# print(T)
time = T[0]
people = 0
bus = 1
for i in T:
    people += 1 #乗客を乗せようとする
    if i - time > K or people > C: #乗せられないとき
        bus += 1 
        time = i
        people = 1 #次のバスに客iを乗せる
print(bus)
# Judge status: Accepted
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")
# Judge status: Wrong Answer
H = int(input())

# INF = float('inf')

# dp = [INF for i in range(H+10)]
# dp[0] = 0
# dp[1] = 1

# for i in range(1, H+1):

#     dp[i+1] = min(dp[i+1], dp[(i+1)//2] * 2 + 1)

# print(dp[H])

cnt = 0
while H > 1:
    cnt += 1
    H //= 2
print(cnt)

ans = 0
for i in range(cnt):
    ans += 2**i
ans += 2**cnt
print(ans)
# Judge status: Accepted
# C - Walk on Multiplication Table

N = int(input())
start = [1, 1]
end = [0, 0]
for i in range(1, int(N ** (1 / 2)) + 1):
    if N % i == 0:
        end[0] = i
        end[1] = N // i

print((end[0] - start[0]) + (end[1] - start[1]))
# Judge status: Wrong Answer
n,m= map(int,input().split())
Nro=[0]*n
for i in range(m):
    s,c= map(int,input().split())
    Nro[s-1]=c
if (n>1) and (Nro[0]==0):
    print(-1)
else:
    print(''.join(map(str, Nro)))
# Judge status: Wrong Answer
X, A, B = map(int, input().split())

if X - A >= 0:
  print('delicious')
elif A - X < 0 and B - A <= X:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

a, b, c, d = map(int, input().split())
g = gcd(c, d)
l = int(c*d/g)

print((b - a + 1) - ((b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)))
# Judge status: Wrong Answer
from collections import Counter

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

acnt = Counter(A)

b = [k for k, v in acnt.items() if v >= 2]

if len(b) < 2:
    print(0)
else:
    b.sort()
    print(b[-1]*b[-2])
# Judge status: Accepted
N=int(input())
A=[]
for i in range(N): A.append(int(input()))
S=sorted(A,key=int)
max1=S[-1]
max2=S[-2]
for i in A:
    if i==max1: print(max2)
    else: print(max1)
# Judge status: Accepted
N, K = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]

from operator import itemgetter
S.sort(key=itemgetter(0)) 

#timesは今何番目に大きいものを表しているか
times=0
#indexは今のインデックス
index=0

while True:
    hoge = times+S[index][1]
    if hoge < K:
        times += S[index][1]
    else:
        re =S[index][0]
        break
    index += 1

print(re)
# Judge status: Wrong Answer
n = int(input())
ls = [int(input()) for _ in range(5)]
print(ls)
k = n/min(ls)
if k % 1 != 0:
    k = int(k) + 1
else:
    k = int(k)
print(k+4)
# Judge status: Wrong Answer
import math
n, k = map(int, input().split())
pro = 0
for i in range(1,n+1):
  x = i
  a = 0
  while x < k:
    a += 1
    x = x*2**a
  pro += (1/n) * 0.5**a
print(pro)
# Judge status: Accepted
N = int(input())
p = list(map(int,input().split()))

ans = 0
continuous_flag= 0

for n in range(N):
  if p[n] == n+1:
    if continuous_flag == 0:
      ans += 1
      continuous_flag = 1
    else:
      continuous_flag = 0
  else:
    continuous_flag = 0
print(ans)
# Judge status: Accepted
n = int(input())
b = [0] * n
a = list(map(int, input().split()))

for i in a:
    b[i-1] += 1
for i in b:
    print(i)
# Judge status: Wrong Answer
'''input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
 
import sys, time, threading


	
# main starts
arr = list(map(int, stdin.readline().split()))
if sum(arr) >= 22:
	print('burst')
else:
	print('win')
# Judge status: Wrong Answer
N=int(input())
S=input()
tmp=""
for i in range(len(S)):
  chtmp=ord(S[i])+N
  if(chtmp>ord('Z')):
    chtmp-=(ord('Z') - ord('A'))
  tmp+=chr(chtmp)
print(tmp)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

A = {}
for i in range(n):
  A = dict(Counter(A) + Counter({a[i]:1}))

ans = 0
for x in A.keys():
  ans += x * A[x]

q = int(input())
for i in range(q):
  b,c = list(map(int, input().split()))
  if b in A.keys():
    ans -= b * A[b]
    ans += c * A[b]
    A = dict(Counter(A) + Counter({c:A[b]}))
    A = dict(Counter(A) - Counter({b:A[b]}))
    print(ans)
# Judge status: Accepted

s = input()
n = len(s)
for i in range(1,2**n):
  ans = [s[0]]
  for j in range(1,n):
    if (i>>j) & 1:
      ans.append("+")
    else:
      ans.append("-")
    ans.append(s[j])
  if eval("".join(ans)) == 7:
    ans.append("=7")
    print("".join(ans))
    exit()
# Judge status: Accepted
def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    cumsumA = [0] * (N + 1)
    cumsumB = [0] * (N + 1)
    for i in range(N):
        cumsumA[i + 1] = cumsumA[i] + A[i]
        cumsumB[N - i - 1] = cumsumB[N - i] + A[N - i - 1]
    minA = 10**18
    for i in range(N + 1):
        minA = min(minA, abs(cumsumA[i] - cumsumB[i]))
    print(minA)


resolve()
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

if a<=0 and b>=0:
    print('Zero')
    exit()

if a>0 and b>0:
    print('Positive')
    exit()


if (b-a)%2 == 0:
    print('Negative')
else:
    print('Positive')
# Judge status: Wrong Answer
n,y=map(int, input().split())

for i in range(n):
    for j in range(n):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            exit()

print('-1 -1 -1')
# Judge status: Accepted
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s - x - y <= k :

      cnt += 1
print(cnt)
# Judge status: Wrong Answer
n = int(input())
if n % 2:
    print(0)
else:
    ans = 0
    i = 1
    while (2 * (5 ** i)) < n:
        ans += n // (2 * (5 ** i))
        i += 1
    print(ans)
# Judge status: Wrong Answer
a,b,c = input().split()

print(a[0],b[0],c[0])
# Judge status: Accepted
import math
A,B = map(int,input().split())
print(math.ceil((B-1)/(A-1)))
# Judge status: Accepted
A = list(map(int, input().split()))
A.sort()
if A == [5,5,7]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = input()

a = [0] * N
c = [False] * N
for i in range(1, N):
    if S[i - 1:i + 1] == "AC":
        a[i] = a[i - 1] + 1
        a[i] = True
    else:
        a[i] = a[i - 1]

for i in range(Q):
    l, r = map(int, input().split())
    if l - 1 == 0:
        print(a[r - 1])
    elif c[l - 1] is True:
        print(a[r - 1] - a[l - 1] - 1)
    else:
        print(a[r - 1] - a[l - 1])
# Judge status: Accepted
N = int(input())
lis = list(map(int, input().split()))
cnt = 0

if 1 not in lis:
    cnt = -1
else:
    for idx, val in enumerate(lis):
        if val != idx+1-cnt:
            cnt += 1

print(cnt)
# Judge status: Accepted
n, k = map(int, input().split())
s = list(input())
lr = 0
rl = 0
ans = 0
for i in range(n-1):
    if s[i]=='L' and s[i+1]=='R':
        lr += 1
    elif s[i]=='R' and s[i+1]=='L':
        rl += 1
    else:
        ans += 1

if lr >= k and rl >= k:
    ans += 2*k
elif lr == rl:
    ans += 2*lr
else:
    num = max(lr, rl)
    ans += 2*num-1

print(ans)
# Judge status: Accepted
import math
 
mod = 1000000007
 
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
 
n=int(input())
 
a = list(map(int,input().split()))
 
memo = a[0]
 
for i in range(1,n):
    memo = lcm(memo,a[i])
 
ans = 0
 
for i in range(n):
    ans += memo*pow(a[i], mod-2, mod)%mod
    ans %= mod
 
print(ans)
# Judge status: Accepted
import sys

a, b = map(float, sys.stdin.readline().split())
ans = -1
for i in range(1, 1251):
    if (int(i * 0.08) == a) and (int(i * 0.1) == b):
        ans = i
        break

print(ans)
# Judge status: Accepted
n=int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2 +1)
# Judge status: Accepted
from math import gcd
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(i, gcd(j, k)) 
print(ans)
# Judge status: Accepted
import numpy as np
n = int(input())
a = np.array([list(map(int,input().split())) for i in range(2)])

cnt = [0] * (n)
for i in range(0, n):
    cnt[i] = sum(a[0, :i+1]) + sum(a[1, i:])

print(max(cnt))
# Judge status: Wrong Answer
# ABC096B

def f(a, b, c, k):
    abc = sorted([a, b, c])
    if k != 0:
        abc[2] *= 2 * k
    print(sum(abc))

a, b, c = map(int, input().split())
k = int(input())
# Judge status: Wrong Answer
x = input().split()
y = input().split()
z = input().split()
s = 0

for nn in range(400000):
    if int(x[2]) < 0:
        break
    if int(y[0]) <= int(z[0]) :
        x[2] = int(x[2]) - int(y[0])
        del y[0]  
        y.append(1000000001) 
        s += 1
    else:
        x[2] = int(x[2]) - int(z[0])
        del z[0]
        z.append(1000000001)
        s += 1
print(s-1)
# Judge status: Accepted
# 入力
a, b, c, d = map(int, input().split())

# 処理&出力
if abs(a - c) <= d or abs(a - b) <= d and abs(b - c) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print(0 if min(b, d)-max(a, c) < 0 else min(b, d)-max(a, c))
# Judge status: Accepted
l = list(map(int, input().split()))
l.sort()
print(l[0] + l[1])
# Judge status: Accepted
import sys
import math

def main():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())

    print(4 + math.ceil(N / min(A, B, C, D, E)))

main()
# Judge status: Wrong Answer
a,b = map(int,input().split())
ansl = []
if min(a,b) == 1:
  print(max(a,b))
else:
  for i in range(1,min(a,b)//2+1):
    if a%i == 0 and b%i == 0:
      ansl.append(i)
  print(int(a*b/max(ansl)))
# Judge status: Wrong Answer
def main():
  s = input()
  n = len(s)
  num = 0
  for i in range(n-1):
    for j in range(i+1, n):
      if int(s[i:j]) % 2019:
        num += 1
  print(num)
  return num
# Judge status: Accepted
from fractions import gcd
from functools import reduce

n, x = map(int, input().split())
S_in = list(map(int, input().split()))
S = [abs(a-x) for a in S_in]

print(reduce(gcd, S))
# Judge status: Accepted
N, X = map(int, input().split())
city = list(map(int, input().split()))
city.sort()
distant = [abs(X - i) for i in city]

def gcd(a, b):
    mod = 1
    
    while (mod > 0):
        mod = a % b
        a = b
        b = mod
    
    return (a)

gc = distant[0]

for i in range(1, len(distant)):
    gc = gcd(gc, distant[i])

print(gc)
# Judge status: Accepted
A = input()

if 'RRR' in A:
    print(3)
elif 'RR' in A:
    print(2)
elif 'R' in A:
    print(1)
else:
    print(0)
# Judge status: Accepted
n,d=map(int,input().split())
A=[[0 for i in range(d)]for j in range(n)]
for i in range(n):
    A[i]=list(map(int,input().split()))
count=0
for i in range(n-1):
    for j in range(i+1,n):
        s=0
        for k in range(d):
            s=s+(A[i][k]-A[j][k])**2
        if (int(s**(1/2)))**2==s:
            count+=1
print(count)
# Judge status: Accepted
X=int(input())
n=100
for i in range(10000):
    if n>=X:
        print(i)
        exit()
    n+=n//100
# Judge status: Wrong Answer
n = list(input())
n = [int(i) for i in (n)]
m = len(n)
if m == 1:
    print(n[0])
else:
    flg = False
    for i in range(m):
        if n[i] != 9:
            flg = True
            break
    if flg:
        n[0] -= 1
        for i in range(1,m):
            n[i] = 9
    print(sum(n))
# Judge status: Wrong Answer
ss=input().strip()
d={}
for s in ss:
  d[s]=d.get(s,0)+1

flg=False
for s in ss:
  if d[s]!=2:
    flg=True
print("Yes" if flg else "No")
# Judge status: Accepted
n = int(input()) 
S = input()
T = input()
ans = 0
for i in range(n):
    if S[i:] == T[:n-i]:
        print(n-i+i*2)
        break
else:
    print(2*n)
# Judge status: Wrong Answer
X=int(input())
if X==(7 or 5 or 3):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
S = int(input())

Y = -(-S // (10**9))
X = -(S - (Y * (10**9)))

print('0 0 {} 1 {} {}'.format(10**9, X, Y))
# Judge status: Wrong Answer
c=input()
if c=="a"or c=="i" or c=="u" or c=="e" or c=="o":
    print("vowel")
    exit()
print("constant")
# Judge status: Wrong Answer
import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
p=0
while p<K:
  B=[0]*(N+1)
  for i in range(N):
    l = max(i-A[i],0)
    r = min(i+A[i]+1,N)
    B[l] +=1
    B[r] -=1
  A = np.cumsum(B)
  p +=1        
  if min(A[0:N-1])==N:
    break
print(*A[0:N-1])
# Judge status: Wrong Answer
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
if x[N-1] <= y[0] and X < Y and x[N-1] > X and y[0] < Y:
    print('No War')
else:
    print('War')
# Judge status: Accepted
# -*- coding: utf-8 -*-

def main():
     n, m = map(int, input().split())
     a_list = list(map(int, input().split()))

     a_sum = sum(a_list)
     if n >= a_sum:
          print(n - a_sum)
     else:
          print(-1)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
ans = 1
S=10*9+7
for i in range(n):
  ans = ans * (i+1) % S
print(ans)
# Judge status: Accepted
s = str(input())

w = ['Sunny','Cloudy','Rainy']

print(w[( w.index(s)+1) %3] )
# Judge status: Accepted
import math
def main():
  x=int(input())
  y=100
  t=0
  while(True):
    y=math.floor(y*1.01)
    t+=1
    if(x<=y):
      print(t)
      return 0

main()
# Judge status: Accepted
n, m = map(int, input().split())
h = list(map(int,input().split()))
A = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    A[a - 1] = max(A[a - 1], h[b - 1]) #ある展望台とつながる別の展望台の標高の最大値を更新
    A[b - 1] = max(A[b - 1], h[a - 1])
ans = 0
for i in range(n):
    if A[i] < h[i]:
        ans += 1
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(min(a + 1, x // 500 + 1)):
    rest1 = x - 500 * i
    for j in range(min(b + 1, rest1 // 100 + 1)):
        rest2 = rest1 - 100 * j
        if 50 * c >= rest2:
            ans = ans + 1

print(ans)
# Judge status: Accepted
K,S=map(int,input().split())

z = list(range(0,K+1))
ans = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print(sum(ans))
# Judge status: Wrong Answer
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]


n = inN()
s = input()


r = s.count('R')
b = s.count('B')
g = s.count('G')

#print(r,b,g,r*b*g)
print(r*b*g - min(b,g)**2)
# Judge status: Accepted
data1,data2 = [input() for i in range(2)]
data1 = int(data1)
if data1 >= 3200:
    print(data2)
else:
    print('red')
# Judge status: Wrong Answer
import itertools
N,M,X=map(int,input().split())
ans=10**6
List=[]
for _ in range(N):
  List.append([int(i) for i in input().split()])
for i in range(0,N):
  for j in itertools.combinations(range(N),i+1):
    tmp=[0]*(M+1)
    for k in j:      
      for l in range(M+1):
        tmp[l]+=List[k][l]
    if len([m for m in tmp[1:] if m>=X])==M:
      ans=min(ans,tmp[0])
if ans==10**6:
  print(-1)
else:
  print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
d = set(input().split())
while True:
    if not set(str(n)) & d:
        print(n)
        break
    else:
        n += 1
# Judge status: Wrong Answer
def solve():
  ans = 1
  N = int(input())
  A = list(map(int, input().split()))
  ud = 0
  for i in range(N-1):
    a = A[i+1]-A[i]
    if a*ud<0:
      ans += 1
      ud = 0
    elif a*ud==0:
      ud = a
  return ans
print(solve())
# Judge status: Accepted
a,b = map(int,input().split())
count,socket = 0,1
while socket < b:
  socket += (a - 1)
  count += 1
print(count)
# Judge status: Wrong Answer
n = int(input())
print((1 + n) * n / 2)
# Judge status: Wrong Answer
import math
def main():
  n = int(input())
  s = input()
  ans=0
  print(int(n/2)+1)
  for i in range(0,int(n/2)+2):
    sum=0
    x=s[:i+1]
    y=s[i+1:]
    while len(x)>0:
      if x[0] in y :
        sum+=1
      x=x.replace(x[0],'')
    if sum>ans:
      ans=sum
  print(ans)
main()
# Judge status: Accepted
import queue
N,M = map(int,input().split())
adj = [[]for i in range(N+1)]
parent = [-1] * (N+1)
for m in range(M):
    a,b = map(int,input().split())
    adj[a].append(b)
    adj[b].append(a)
q = queue.Queue()
q.put((1,0)) # 自分、親
while(not q.empty()):
    x, p = q.get()
    if parent[x] != -1:
        continue
    parent[x] = p
    for next in adj[x]:
        if parent[next] == -1:
            q.put((next,x))
#print (parent)

print ('Yes')
for p in parent[2:]:
    print(p)
# Judge status: Accepted
import math 
A, B, H, M = map(int,input().split())

timeHr = H + (M / 60)
angVelA = (1/6) * 180
angVelB = (2) * 180

degA = (angVelA * timeHr)
degB = (angVelB * timeHr) 

degDiff = math.radians(abs(degB - degA))

disX_2 = math.pow(B, 2) + math.pow(A, 2) - (2 * A * B * math.cos(degDiff))
disX = math.sqrt(disX_2)

print(disX)
# Judge status: Accepted
# -*- coding: utf-8 -*-
a,b = map(int,input().split())
s = list(str(input()))

number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
flag = True
for i in range(a):
    if s[i] not in number:
        flag = False
        #print("A")
if s[a] != '-':
    flag = False
    #print("B")
for i in range(a + 1, a + b + 1):
    if s[i] not in number:
        flag = False
        #print("C")

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S=input()
print("Yes" if len(S)==len(set(S)) else "No")
# Judge status: Wrong Answer
import numpy as np
import math
n, k = map(int, input().split())
t = 1/n
a = 0
for i in range(1, n+1):
    if i < k:
        s = (k + i-1) // i
        t2 = math.ceil(np.log2(s))
        print(i, t2)
        a += t*((1/2) ** t2)
    else: a += t
print(a)
# Judge status: Wrong Answer
k=int(input())
a,b = list(map(int,input().split()))
v1 = (a+k-1)//k
v2 = (b+k-1)//k
if(v1<=v2):
  print("OK")
else:
  print("NG")