peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
S = input()

r = S.count('R')
w = len(S)-r

if r == 0 or w == 0:
    print(0)
    exit()

ans = 0
for i in range(len(S)):
    if S[i] == "R":
        r -= 1
    else:
        r -= 1
        w -= 1
        ans += 1
    if r == 0 or w == 0:
        break
print(ans+r)
# Judge status: Wrong Answer
S =input()
T = input()
count = 0
for i in range(0,len(S)):
    if S[i] != T[i]:
        count=count+1
# Judge status: Accepted
K,X = map(int,input().split())
ans = []
for i in range(-K+1,K):
  ans.append(str(i+X))
print(' '.join(ans))
# Judge status: Accepted
n, k = map(int, input().split())
ans = 0
while n > 0:
  ans += 1
  n //= k
print(ans)
# Judge status: Wrong Answer
import re

S = input()
T = input()

results = []
for i in range(len(S) - len(T)+1):
    pattern = S[i:len(T) + i].replace('?', '.')
    m = re.search(pattern, T)
    if m:
        result = re.sub(pattern, T, S)
        results.append(result)

if len(results) > 0 :
    results = sorted([ r.replace('?', 'a') for r in results])
    output = results[0]
    
else :
    output = 'UNRESTORABLE'
print(output)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))  
cnt=0
for i in range(1,n):
  if i in a:
    cnt+=1
    del a[:a.index(i)]
  else:
    if i==1:
        print(-1)
        break
    else:
        break
        print(n-cnt)
# Judge status: Accepted
N=int(input())
ans=[]
for i in range(1,N):
    temp=(N-1)//i
    ans.append(temp)
Ans=sum(ans)
print(Ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = []
mod = 10 ** 9 + 7
for _ in range(m):
    a.append(int(input()))
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1
for i in range(2, n + 1):
    if i in a:
        continue
    else:
        dp[i] = dp[i - 1] + dp[i - 2]
print(dp[-1] % mod)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()

if a > b and c > d or a < b and c < d:
  if s[a - 1:c].count('##') + s[b - 1:d].count('##') == 0:
    print('Yes')
  else:
    print('No')
else:
  i, j = (b, d) if a < b else (a, c)
  if any(s[k - 1] == s[k] == s[k + 1] == '.' for k in range(i - 1, j)):
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
a,b,c,d=map(int,input().split())
while a>0 and b>0:
  c-=b
  a-=d
if a<=0 and c>0:
  print('No')
elif c<=0:
  print('Yes')
# Judge status: Accepted
from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
d = Counter(S)
md = d.most_common(1)[0][1]

for key, value in d.items():
    if value == md:
        A.append(key)

As = sorted(A)
for a in As:
    print(a)
# Judge status: Accepted
n = int(input())
b_list = list(map(int,input().split()))

a_list = [0]*n
a_list[0] = b_list[0]
k = 0
while k <= n-2:
  if a_list[k] > b_list[k]:
    a_list[k] = b_list[k]
  a_list[k+1] = b_list[k]
  k += 1
print(sum(a_list))
# Judge status: Wrong Answer
if __name__ == '__main__':
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+2, N):
                if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and j - i != k - j:
                    cnt += 1
    print(cnt)
# Judge status: Accepted
x = int(input())

if x >= 30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
score = [int(input()) for _ in range(n)]
score.append(0)
score.sort()
sum_value = sum(score)
cnt = 0

for num in score:
    if (sum_value-num) % 10 != 0:
        sum_value -= num
        break
    cnt += 1

if cnt == n+1:
    sum_value = 0

print(sum_value)
# Judge status: Accepted
s=input()
ls = len(s)
k= int(input())
for i in range(ls-1):
    tn = ord('z')-ord(s[i])+1
    if k>=tn and s[i]!='a':
        k-=tn
        print('a',end='')
    else:
        print(s[i],end='')
ik = (k + ord(s[-1])-ord('a')) % 26
print(chr(ord('a')+ik))
# Judge status: Accepted
A, B = map(int, input().split())
res = 1
cnt = 0
while res < B:
    res += A - 1
    cnt += 1
print(cnt)
# Judge status: Accepted
N = input()
SUM = 0
for n in N:
    SUM += int(n)
if SUM % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=input()
digit_sum=int(n[0])-1+9*(len(n)-1)
digit_n=sum(int(j) for j in n)
print(max(digit_n,digit_sum))
# Judge status: Wrong Answer
N = int(input())

C = [[0] * 10 for i in range(10)]

for i in range(1, 10):
    for j in range(1, 10):
        for n in range(1, N+1):
            if str(n)[0] == i and str(n)[-1] == j:
                C[i][j] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += C[i][j]*C[j][i]
print(ans)
# Judge status: Accepted
n=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
ans=0
for i in range(n):
    B1=A1[:i+1]
    B2=A2[i:]
    ans=max(ans,sum(B1)+sum(B2))
print(ans)
# Judge status: Accepted
O = input()
E = input()
if len(O) == len(E):
    for i in range(len(O)):
        print(O[i], end="")
        print(E[i], end="")
elif len(O) > len(E):
    for i in range(len(E)):
        print(O[i], end="")
        print(E[i], end="")
    print(O[i+1])
else:
    for i in range(len(E)):
        print(O[i], end="")
        print(E[i], end="")
    print(E[i+1])
# Judge status: Accepted
from sys import stdin
import math
from decimal import Decimal

A, B = input().split(" ")
a = int(A)
b = Decimal(B)
print (math.floor(a*b))
# Judge status: Wrong Answer
n,k,*a = map(int,open(0).read().split())
def func(b):
  c = k
  for i in a:
    if b == 0:
      c -= i+1
    else:
      c -= i//b
    if c < 0:
      return False
  return True
l = 0
r = max(a)
while(r>l):
  lr = (l+r)//2
  if func(lr):
    r = lr
  else:
    l = lr + 1
print(r)
# Judge status: Wrong Answer
def actual(n, L):
    max_l = max(L)
    others_l = sum(L) - max_l

    if max_l < others_l:
        return 'Yes'

    return 'No'

n = int(input())
L = map(int, input().split())
print(actual(n, L))
# Judge status: Accepted
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
if M>N:
  X.sort()
  D = []
  for i in range(M-1):
    d = X[i+1]-X[i]
    D.append(d)
  
  D.sort()
  D = D[:(M-N)]
  ans = sum(D)
  
print(ans)
# Judge status: Wrong Answer
n=int(input())
p=list(map(int,input().split()))

l=list(range(1,n+1))
k=0
for i in range(n):
    if p[i]==l[i]:
        k+=1
if k==0 or k==2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    score = 0
    for i in range(K, N):
        if T[i] == T[i-K]:
            T[i] = 'x'
    
    for t in T:
        if t == 'r':
            score += P
        elif t == 's':
            score += R
        elif t == 'p':
            score += S
    
    print(score)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())

alphabets = [chr(ord('a') + x) for x in range(26)]

ans = []


def dfs(d, i_max, S):
    if d == N-1:
        ans.append(S)
        return
    for i in range(i_max+2):
        dfs(d+1, max(i_max, i), S + alphabets[i])


dfs(0, 0, "a")
print(*ans, sep='\n')
# Judge status: Accepted
a = int(input())
print(a+a*a+a*a*a)
# Judge status: Accepted
S = input()
T = input()

print(sum(s != t for s, t in zip(S, T)))
# Judge status: Accepted
s = input()
acgt = 'ACGT'
max_count = 0
i = 0
while i < len(s):
    count = 0
    if s[i] not in acgt:
        i += 1
        continue
    count += 1
    for j in range(i+1, len(s)):
        if s[j] not in acgt:
            break
        count += 1
    if count > max_count:
        max_count = count
    i += count + 1
print(max_count)
# Judge status: Wrong Answer
S=input()
S2=S[:(len(S))//2]
while len(S)>=4:
    S=S[:-2]
    S2=S2[:-1]
    if S==S2+S2:
        print(len(S))
# Judge status: Accepted
N = int(input())
M = input()
if N >= 3200:
    print(M)
else:
    print('red')
# Judge status: Wrong Answer
x=input()
if x==1:
  print(0)
if x==0:
  print(1)
# Judge status: Accepted
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9
now = 0
for i in range(n-k+1):
    ltor = abs(now - x[i]) + abs(x[i+k-1] - x[i])
    rtol = abs(now - x[i+k-1]) + abs(x[i+k-1] - x[i])
    tmp = min(ltor, rtol)
    ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
L = max(A, B)
S = min(A, B)
ans = L
while True:
    if ans%S==0:
        print(ans)
        break
    ans+=L
# Judge status: Wrong Answer
a,b,c=map(int, input().split())

print("Yes" if a+2*b>=c else "No")
# Judge status: Accepted
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
# Judge status: Wrong Answer
n = int(input())
a = []
b = []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)
ans = 0
a = a[::-1]
b = b[::-1]
for i in range(n):
  if a[i] % b[i] == 0:
    next
  else:
    ans += b[i] - ((a[i]+ ans) % b[i])
print(ans)
# Judge status: Wrong Answer
def candy():
    boxNum, x = [int(i) for i in input().split()]
    ain = input()
    alist = ain.split(' ')

    s = 0
    for i in range(0, boxNum-1):
        if int(alist[i]) > x:
            s = s + (int(alist[i+1]) -x)
            alist[i+1] = 0

        elif int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        
    print(s)
    
candy()
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    X, Y = map(int, input().split())

    if X % Y != 0:
        ans = X
    else:
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
N,M=map(int,input().split())
d=abs(N-M)
if d>1:
  print(0)
elif d==1:
  ans=math.factorial(N)*math.factorial(M)%(10**9+7)
  print(ans)
else:
  ans=math.factorial(N)*math.factorial(M)*2%(10*9+7)
  print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
if a > b:
  print(a-1)
else:
  print(a)
# Judge status: Accepted
# import numpy as np
# import math
# import copy
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    K = int(input())

    queue = deque()

    for i in range(1,10):
        queue.append(i)

    for i in range(K):
        x = queue.popleft()
        d = x % 10
        temp = 10 * x + d
        if d != 0:
            queue.append(temp - 1)
        queue.append(temp)
        if d != 9:
            queue.append(temp + 1)

    print(x)



main()
# Judge status: Accepted
N = int(input())
a=list(map(int,input().split()))
c = 0
for i in range(N):
  if i%2==0:
    if a[i]%2==1:
      c = c+1
print(c)
# Judge status: Accepted
# https://atcoder.jp/contests/abc142/tasks/abc142_a

N = int(input())

ans = 1 - ((N // 2) / N)

print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
ans = [a*c, a*d, b*c, b*d]
print(max(ans))
# Judge status: Accepted
x,k,d = map(int,input().split())
n = abs(x)//d
if n>k:
  ans = min(abs(x-k*d),abs(x+k*d))
else:
  ans = min(abs(x+min(k,n)*d),abs(x-min(k,n)*d))
  if (k-n)%2:
    ans = min(abs(ans-d),abs(ans+d))
print(ans)
# Judge status: Accepted
n = int(input())
l_list = list(map(int, input().split()))

if sum(l_list) - 2* max(l_list) > 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
s=input()
x=0
ans=0
for i in range(n):
    if s[i]=="I":
        x+=1
        if ans<x:
            ans=x
    else:
        x-=1
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())

import math

ans = 0
for i in range(1, N + 1):
    tmp = max(0, math.ceil(math.log2(K) - math.log2(i)))
    # print("#", i, tmp, 0.5 ** tmp)
    ans += 0.5 ** tmp

ans /= N

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

i = 0
l = len(A)
n = 1



while True:

    i = A[i] - 1

    if A[i] == 2:
        n += 1
        print(n)
        break
    n += 1
    if n == l+1:
        print(-1)
        break
# Judge status: Wrong Answer
n=int(input())
A=list(map(int,input().split()))
ans4 = 0
ans2 = 0
for a in A:
  if a % 4 == 0:
    ans4 += 1
  elif a % 2 == 0:
    ans2 += 1
if ans4 * 3 + ans2//2 >= n:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
p = list(map(int, input().split()))
print(sum(p) - max(p))
# Judge status: Accepted
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("Yes" if s >= 0 == s%2 else "No")
# Judge status: Accepted
import queue

k = int(input())

q = queue.Queue()
x = 0

for i in range(1, 10):
    q.put(i)

for j in range(k):
    x = q.get()
    if x%10!=0:
        q.put((x*10)+(x%10)-1)
    q.put((x*10)+(x%10))
    if x%10!=9:
        q.put((x*10)+(x%10)+1)

print(x)
# Judge status: Wrong Answer
n=int(input())
ans=0
for i in range(n):
    ans+=i+1

print(ans)
# Judge status: Accepted
import math

def comb(n, r, mod):
    return math.factorial(n + r - 1)//(math.factorial(n - 1)*math.factorial(r))%mod

s = int(input())
mod = 10**9 + 7
ans = 1

if s < 3:
    ans = 0

for i in range(2, 700): #分割数, 1の時は1通りなので除外
    if s < 3*i:
        break
    r = s - i*3
    ans = (ans + comb(i, r, mod))%mod

print(ans)
# Judge status: Accepted
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])
# Judge status: Accepted
N = int(input())
dict = {}
for i in range(N):
    a = int(input())
    if not a in dict.keys():
        dict[a] = 1
    else:
        dict[a] += 1
sum = 0
for i in dict.keys():
    if dict[i]%2 == 1:
        sum += 1
print(sum)
# Judge status: Accepted
a = int(input())

print(a + a**2 + a**3)
# Judge status: Accepted
strin = input()
D, T, S = int(strin.split(" ")[0]), int(strin.split(" ")[1]), int(strin.split(" ")[2])
if (D / S) <= T:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#043c
N = int(input()) #N <= 100
a_list = list(map(int, input().split())) #-100 <= ai <= 100

#ループ数は200*100 = 20000.総当たりでOK
min_cost = 111*(200**2)

for y in range(min(a_list),max(a_list) + 1):
    cost = 0
    
    for x in a_list:
        cost += (x - y)**2
    
    if cost < min_cost:
        min_cost = cost

print(min_cost)
# Judge status: Accepted
n=int(input())

num=10**n-2*9**n+8**n

numa=num%(10**9+7)

print(numa)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
hold = 0
money  = 1000
for i in range(n-1):
    if a[i+1] > a[i]:#buy
        hold = money//a[i]
        money = money % a[i]
    if a[i+1] < a[i]:#sell
        money += hold*a[i]
        hold = 0
print(money+a[-1]*hold)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a <= c and c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import itertools
n = int(input())
p = tuple(int(i) for i in input().split())
q = tuple(int(i) for i in input().split())
a = tuple(itertools.permutations(list(range(1, n+1)), n))
print(abs(a.index(p) - a.index(q)))
# Judge status: Wrong Answer
O = list(input())
E = list(input())
for x,y in zip(O,E):
    print(x+y,end="")
# Judge status: Accepted
l,m=2,1
for _ in range(int(input())): l,m=m,l+m
print(l)
# Judge status: Wrong Answer
w,h,x,y = list(map(int, input().split()))

if((x == w//2 or y == h//2)):
  print((w*h)//2 , 1)
else:
  print((w*h)//2, 0)
# Judge status: Wrong Answer
a, b = map(int, input().split())
d = b - a
c = 1
for i in range(2, 999):
	if d == i:
		print(c-a)
		exit()
	c += i
# Judge status: Accepted
K = int(input())
f = 1
j = 7%K
while f < K and j != 0:
  j = (j*10 + 7)%K
  f += 1
if j == 0:
  print(f)
else:
  print('-1')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print(b // a)
# Judge status: Wrong Answer
import math
N, X, T = map(int,input().split())
print((math.floor(N/X)+1)*T)
# Judge status: Accepted
n = int(input())
s = input()
tmp = s

while True:
    if tmp.count("()") == 0:
        break
    tmp = "".join(tmp.split("()"))

x = 0
y = 0
for c in tmp:
    if c == ")":
        x += 1
    else:
        y += 1

ans = "("*x + s + ")"*y
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
from collections import Counter
ctr = Counter(S)
MOD = 10**9+7

ans = 1
for v in ctr.values():
    ans *= (v+1)
    ans %= MOD
ans -= 1
ans %= MOD
print(ans)
# Judge status: Wrong Answer
S=input('')

if ('ABC==S'):
  print('ARC')
else:
  print('ABC')
# Judge status: Accepted
w, a, b = map(int, input().split())

if b > a+w:
  print(b-a-w)
elif b+w < a:
  print(a-b-w)
else:
  print(0)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
d=0
if a ==b:
  if b==c:
    d =1
  else:
    d =2
else:
  if b==c:
    d =2
  else:
    d =3
print(d)
# Judge status: Accepted
abc = sorted(list(map(int, input().split())))
k = int(input())

ans = abc[0] + abc[1] + abc[2] * (2 ** k)
print(ans)
# Judge status: Wrong Answer
N = int(input())

ans = 0
for c in range(N-1):
    for a in range(N-1):
        for b in range(N-1):
            if a*b+c == N:
                ans += 1
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())
print(x+y//2)
# Judge status: Accepted
S = list(input())

i = 1
r = len(S)
while True:
    if i >= len(S):
        break
    if S[i-1] == S[i]:
        r -= 1
        i += 2
    i += 1

print(r)
# Judge status: Accepted
def main():
    # n = int(input())
    n, m = map(int, input().split())
    # v = list(map(int, input().split()))
    # s = input()
    h = [int(input()) for _ in range(n)]

    h.sort()

    temp = []
    for i in range(n-m+1):
        temp.append(h[i+m-1]-h[i])

    temp.sort()
    print(temp[0])


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

k = []
for h in H:
    temp = T - h * 0.006
    sa = abs(A - temp)
    k.append(sa)

min_k = min(k)
print(k.index(min_k)+1)
# Judge status: Accepted
a,b=map(int, input().split())
if a<=8 and b<=8:
  print("Yay!")
else:
  print(":(")
# Judge status: Wrong Answer
a = input()

for i in range (4):
   if a.islower():
     break
   elif a[0]==a[1] or a[0]==a[2] or a[0]==a[3] and a[1]==a[2] or a[1]==a[3]:
      print("Yes")
   else:
       print("No")
   break
# Judge status: Accepted
eat_N = int(input())

x = eat_N * 800

y = (eat_N // 15) * 200

print( x - y)
# Judge status: Wrong Answer
n = int(input())
d = list(map(int, input().split()))

d = sorted(d)

if d[n//2] == d[n//2]:
    print(0)
else:
    print(d[n//2] - d[n//2-1])
# Judge status: Accepted
from fractions import gcd

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

gcdl = [0] * n
gcdr = gcdl[:]

gcdl[0]  = a[0]
gcdr[-1] = a[-1] 

for i in range(1, n):
  gcdl[i] = gcd(a[i], gcdl[i - 1])

for i in range(n - 2, -1, -1):
  gcdr[i] = gcd(a[i], gcdr[i + 1])

max_gcd = max(gcdl[-2], gcdr[1])

for i in range(1, n - 1):
  temp_gcd = gcd(gcdl[i - 1], gcdr[i + 1])
  if temp_gcd > max_gcd:
    max_gcd = temp_gcd

print(max_gcd)
# Judge status: Accepted
def main():
    import heapq
    n, m, *a = map(lambda x: -int(x), open(0).read().split())
    heapq.heapify(a)
    for _ in range(-m):
        x = heapq.heappop(a)
        heapq.heappush(a, x / 2)

    ans = -sum(map(lambda x: int(x), a))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
	if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
		cnt += 1
print(cnt)
# Judge status: Wrong Answer
word = input()
if word == "SSS":
    print(0)
elif word == "RSS" or "SRS" or "SSR" or  "RSR":
    print(1)
elif word == "SRR" or "RRS":
    print(2)
elif word == "RRR":
    print(3)
# Judge status: Accepted
n,m=map(int,input().split())
List=[]
for i in range(m):
    road=list(map(int,input().split()))
    List.append(road)
    road=[road[1],road[0]]
    List.append(road)
ans=0
for i in range(1,n+1):
    for j in range(len(List)):
        if i==List[j][0]:
            ans+=1
    print(ans)
    ans=0
# Judge status: Accepted
S=list(input())
s=len(S)
T=list(input())
t=len(T)
for i in range(s-t+1):
  a=0
  for j in range(t):
    if S[-1-i-j]=="?":
      continue
    if S[-1-i-j]!=T[-1-j]:
      a=1
  if a==0:
    for j in range(s):
      if S[j]=="?":
        S[j]="a"
    S[s-t-i:s-i]=T
    for j in range(s):
      print(S[j],end="")
    print()
    exit()
print("UNRESTORABLE")
# Judge status: Accepted
N,K = map(int,input().split())

ans_sum=0#確率合計

for i in range(1,N+1):
    num=i#現在の数字格納用
    ans=1/N #Nの目が出る確率
    while num<K:
        num*=2
        ans/=2
    #print(ans)
    ans_sum+=ans
print(ans_sum)
# Judge status: Accepted
n,k = map(int,input().split())
s = input()
s = s[:k-1] + chr(ord(s[k-1])+ord('a')-ord('A')) + s[k:]
print(s)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

for i in a:
    if i % 2 == 0:
        if i % 6 > 0 and i % 10 > 0:
            print('DENIED')
            exit()
print('APPROVED')
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 1
for i in range(K, N, K - 1):
    ans += 1
print(ans)
# Judge status: Accepted
N, K = map(int,input().split())
h = [int(input()) for i in range(N)]
s_h = sorted(h)
tmp = []
ans1 = 0
ans2 = 0
ans3 = 0
for i in range(N-K+1):
    ans1 = s_h[i+K-1]
    ans2 = s_h[i]
    ans3 = ans1 - ans2
    tmp.append(ans3)

print(min(tmp))
# Judge status: Accepted
s = str(input())
ans = 0
for i in range(3):
    if s[i]== '1':
        ans = ans +1
else:
    print(ans)
# Judge status: Accepted
a,b,c,d,e = map(int, input().split())
print(c*60+d-a*60-b-e)
# Judge status: Wrong Answer
def main():
    S = input()
    T = input()
    temp = ''
    for i in range(1, len(T)+1):
        print(T[0:i])
        if T[0:i] in S:
            temp = T[0:i]

    print(len(T)- len(temp))

if __name__ == '__main__':
    main()
# Judge status: Accepted
s,w=map(int,input().split())
if s>w: print("safe")
else: print("unsafe")
# Judge status: Accepted
import math
p = 3.14159
a,b,x = map(int,input().split())
x /= a
if x >= a*b/2:
    print(math.atan(2/(a**2)*(a*b-x))/p*180) 
else:
    print(90-(math.atan((2*x/b**2))/p*180))
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
a,b = map(int,input().split(" "))

if a == b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())

# 被りの要素が削除される
a = set(input().split())
print('YES' if len(a) == n else 'NO')
# Judge status: Accepted
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
a = 1

for n in range(N):
  D+=L[n]
  if D<=X:
    a+=1

print(a)
# Judge status: Accepted
N = int(input())
numMap = {}
answer = 0
def StartEnd(x):
    start = str(x)[0]
    end = str(x)[-1]
    return start, end

for i in range(1, N+1):
    # print('numMap:', numMap)
    pair = StartEnd(i)
    if pair in numMap:
        numMap[pair] += 1
    else:
        numMap[pair] = 1

for i in range(1, N+1):
    key = StartEnd(i)
    rev = key[::-1]
    # print('rev:', rev)
    if rev in numMap:
        answer += numMap[rev]
    
print(answer)
# Judge status: Accepted
a,b=map(int,input().split())
s=input()
print("Yes" if s[a]=="-" and s.count("-")==1 else "No")
# Judge status: Wrong Answer
i = [input() for i in range(2)]

if 1 not in i:
  print("1")
elif 2 not in i:
  print("2")
else:
  print("3")
# Judge status: Wrong Answer
s = input()
ret = ''
if( s =='Sunny'):
    ret = 'Cloudy'
elif( s =='Cloudy'):
    ret = 'Rainy'
elif( s =='Rainy '):
    ret = 'Sunny'
print(ret)
# Judge status: Accepted
S = input()
N = len(S)
A = [0] * (N + 1)
B = [0] * (N + 1)
for i in range(N):
    if S[i] == "<":
        A[i+1] = A[i] + 1
    else:
        A[i+1] = 0

for i in range(N-1, -1, -1):
    if S[i] == ">":
        B[i] = B[i+1] + 1
    else:
        B[i] = 0

print(sum([max(A[i], B[i]) for i in range(N + 1)]))
# Judge status: Accepted
from math import ceil
N = int(input())
A, B = [], []
for _ in range(N):
    ai, bi = map(int, input().split())
    A.append(ai)
    B.append(bi)

# 回数だけ確定する
# 後ろから順番にすれば良い気がする (iのボタンは1からiまでしか作用しないので)
count = 0
for j in range(N - 1, -1, -1):
    if (count + A[j]) % B[j] == 0:
        continue
    else:
        # 足りない分をカウントする
        count += B[j] - (count + A[j]) % B[j]
print(count)
# Judge status: Accepted
r = int(input())
ans = r**2
print(ans)