Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
class sieve:
  def __init__(self, n):
    self.n = n
    self.sv = [1] * (n + 1)
    self.sv[0] = 0
    self.sv[1] = 0
    for i in range(2, n + 1):
      if self.sv[i]:
        for j in range(i * 2, n + 1, i):
          self.sv[j] = 0
  def isprime(self, x):
    if x > self.n:
      return False
    return self.sv[x] == 1
  def factorize(self, x):
    res = []
    for i in range(2, self.n + 1):
      if self.sv[i]:
        while x % i == 0:
          x //= i
          res.append(i)
    if x != 1:
      res.append(x)
    return res
  def modgcd(self, a, mod):
    res = [float("inf")] * (self.n + 1)
    vis = set()
    f = self.factorize(a[0])
    for j in f:
      res[j] = f.count(j)
      vis.add(j)
    for i in range(1, len(a)):
      f = self.factorize(a[i])
      for j in vis:
        res[j] = min(f.count(j), res[j])
        vis.add(j)
    rres = 1
    for i in range(self.n + 1):
      if res[i] != float("inf"):
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
  def modlcm(self, a, mod):
    res = [0] * (self.n + 1)
    for i in range(len(a)):
      f = self.factorize(a[i])
      for j in f:
        res[j] = max(f.count(j), res[j])
    rres = 1
    for i in range(self.n + 1):
      if res[i] != 0:
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
sv = sieve(10 ** 3)
lcm = sv.modlcm(a, 10 ** 9 + 7)
res = 0
for x in a:
  res += lcm * pow(x, 10 ** 9 + 5, 10 ** 9 + 7)
  res %= 10 ** 9 + 7
print(res)

### FIXED CODE ###

import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)
def inp():
    ls=set(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(1, 102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

### FIXED CODE ###

def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ans=0
d=float('inf')
for i in range(102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)
n = int(input())
s = input()

black_right, min_val = 0, 2000001
white_left = s.count('.')
ans = []

for moji in s:
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    ans.append[white_left+black_right]
    #min_val = min(min_val, white_left+black_right)

print(min(ans))

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()
xin = input().split()
x = list(map(int, xin))

a = x[0]*2 - x[1]/2
b = -x[0]/2 + x[1]/2

if a>=0 and b>= 0:
	if(a.isinteger() and b.isinteger()):
		print("yes")
	else;
		print("no")
else:
	print("no")
	 


### FIXED CODE ###

xin = input().split()
x = list(map(int, xin))

a = x[0]*2 - x[1]/2
b = -x[0] + x[1]/2

if (a>=0 and b>= 0):
	if(a.is_integer() and b.is_integer()):
		print("Yes")
	else:
		print("No")
else:
	print("No")
n = int(input())
bara=list(map(int,input().split()))

number=[1]
for i in range(2,):
  List.append(i)
    
for i in range n-1:
  if bara[i]==number[i]:
    count+=1

if count==2:
  print("YES")
else:
  print("NO")



### FIXED CODE ###

n = int(input())
bara=list(map(int,input().split()))
number=list(range(1,n+1))

count = 0
    
for i in range (0,n):
    if bara[i] != number[i]:
        count += 1

if count==2 or count==0:
    print("YES")
else:
    print("NO")
N,K = list(map(int,input().split()))
TDlist = []

for x in range(0,N):
    TDlist.append(list(map(int,input().split())))

TDlist.reverse(key = lambda x: x[1])
kinds = []
seconds = []
answer = 0

for x in TDlist[:K]:
    if not x[0] in kinds:
        kinds.append(x[0])
    else:
        seconds.append(x[1])
    answer += x[1]

answer += len(kinds)**2
score = answer
max_score = answer

for x in TDlist[K:]:
    if seconds == []:
        break
    if x[0] in kinds:
        continue
    kinds.append(x[0])
    y = seconds.pop()
    score += (x[1] - y) + (len(kinds)*2 -1)
    max_score = max(score,answer)
    

answer = max(answer,max_score)

print(answer)

### FIXED CODE ###

N,K = list(map(int,input().split()))
TDlist = []

for x in range(0,N):
    TDlist.append(list(map(int,input().split())))

TDlist= sorted(TDlist, key = lambda x: x[1],reverse=True)
kinds = set()
seconds = []
answer = 0

for x in TDlist[:K]:
    if not x[0] in kinds:
        kinds.add(x[0])
    else:
        seconds.append(x[1])
    answer += x[1]

answer += len(kinds)**2
score = answer

for x in TDlist[K:]:
    if seconds == []:
        break
    if x[0] in kinds:
        continue
    kinds.add(x[0])
    y = seconds.pop()
    score += (x[1] - y) + (len(kinds)*2 -1)
    answer = max(score,answer)

print(answer)
import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
max_ = 2**n
min_nedan = 10**9
for j in range(max_):
  bit = format(j, "0"+str(n)+"b")
  count_list = [0]*m
  nedan = 0
  for b in range(n):
    if bit[b] == "1":
      naiyou = book[b]
      nedan += naiyou[0]
      for i in range(1, m+1):
        count_list[i-1] += naiyou[i]
  if min(count_list)>=x:
    if nedan a< min_nedan:
      min_nedan = nedan
if min_nedan == 10**9:
  print(-1)
else:
  print(min_nedan)
  


### FIXED CODE ###

import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
max_ = 2**n
min_nedan = 10**9
for j in range(max_):
  bit = format(j, "0"+str(n)+"b")
  count_list = [0]*m
  nedan = 0
  for b in range(n):
    if bit[b] == "1":
      naiyou = book[b]
      nedan += naiyou[0]
      for i in range(1, m+1):
        count_list[i-1] += naiyou[i]
  if min(count_list)>=x:
    if nedan < min_nedan:
      min_nedan = nedan
if min_nedan == 10**9:
  print(-1)
else:
  print(min_nedan)
import collections
N = int(input())

cost = 0
diff_list = []
x_y_list = []

if N == 1:
    print(1)

for n in range(N):
    x, y = map(int, input().split())
    x_y_list.append((x, y))
    cost += 1

for n in range(N):
    x, y = x_y_list.pop()
    for tmp_x, tmp_y in x_y_list:
        diff_list.append((x - tmp_x, y - tmp_y))

counter = collections.Counter(diff_list)
print(cost - max(counter.values()))

### FIXED CODE ###

import collections
import copy
import sys
N = int(input())

cost = 0
diff_list = []
x_y_list = []

if N == 1:
    print(1)
    sys.exit()

for n in range(N):
    x, y = map(int, input().split())
    x_y_list.append((x, y))
    cost += 1

x_y_list_copy = copy.copy(x_y_list)

for n in range(N):
    x_y = x_y_list.pop()
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list:
        diff_list.append((x - tmp_x, y - tmp_y))

for n in range(N):
    x_y = x_y_list_copy.pop(0)
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list_copy:
        diff_list.append((x - tmp_x, y - tmp_y))

counter = collections.Counter(diff_list)
print(cost - max(counter.values()))
n = int(input())
h = list(map(int,input().split()))

dp = [0, abs(h[1]-[0])]

for i in range(2,n):
    dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i] + abs(h[i]-h[i+2])))
    
print(dp[-1])

### FIXED CODE ###

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

dp = [0, abs(h[1]-h[0])]

for i in range(2, n):
    dp.append(min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] + abs(h[i-2]-h[i])))

print(dp[-1])
A,B = map(int, input().split())
if (a+b)%2==0:
    print(int((A+B)/2))
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

A,B = map(int, input().split())
if (A+B)%2==0:
    print(int((A+B)/2))
else:
    print('IMPOSSIBLE')
n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 0
b = []
for k in range(n):
    if k == 0:
        b = a.copy()
    else:
        for i in range(n):
            b[i] = min(a[(i-k)%n],b[i])
    cost = k*x+sum(b)
    if k == 0:
        ans = cost
    else:
        ans = min(ans,cost)
        if ans != cost:
            break
    if ans < (k+1)*x:
        break
print ans

### FIXED CODE ###

def solve(n, x, a):
	costs = []
	cost_min = 0
	for k in range(n):
		if k == 0:
			costs = a.copy()
		else:
			for i in range(n):
				costs[i] = min(costs[i], a[(i-k)%n])
		cost_k = sum(costs) + k*x
		if k == 0:
			cost_min = cost_k
		else:
			cost_min = min(cost_min, cost_k)
			if cost_min != cost_k:
				break
		if cost_min < (k+1) *x:
			break
 
	return cost_min
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(solve(n,x,a))
import math
 
A,B,H,M=map(int,input().split())
x=abs(((60*H+M)*0.5)-(6*M))
if x>=180:
    x=x-180
y=(A**2)+(B**2)-2*A*B*math.cos(math.radians(x))
print((math.sqrt(y))

### FIXED CODE ###

import math
 
A,B,H,M=map(int,input().split())
x=abs(((60*H+M)*0.5)-(6*M))
y=A**2+B**2-2*A*B*math.cos(math.radians(x))
print(math.sqrt(y))
if S == ("ABC"):
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

S = input()
if S ==("ABC"):
  print("ARC")
else:
  print("ABC")
def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def union(i, j, m):
    pi, pj = find(i, m), find(j, m)
    if pi != pj:
        m[pj] += m[pi]
        m[pi] = pj

    return m


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)
    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = count(u, par), count(v, par)
            utl.append(tmp)
            tmp -= i * j
            par = union(u, v, par)

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main()
import sys
sys.setrecursionlimit(100000) 

n,m = list(map(int,input().split()))
a = [0]*m
for i in range(m):
    a[i] = int(input())
memo = [-1]*(n+1)

for i in a:
    memo[i] = 0

def stair(k):
    if memo[k] != -1:
        return memo[k]
    else:
        if k == 1:
            if 1 not in a:
                memo[k] = 1
            else:
                memo[k] = 0
        elif k == 2:
            if 2 not in a:
                memo[k] = 1 + stair(1)
            else:
                memo[k] = 0 + stair(1)
        elif k not in a:
            if k-1 not in a or k-2 not in a:
                    memo[k] = (stair(k-1)+stair(k-2))%1000000007
            else:
                memo[k] = 0
        else:
            memo[k] = 0
        return memo[k]

print(stair(n))

### FIXED CODE ###

n,m = list(map(int,input().split()))
a = [0]*m
for i in range(m):
    a[i] = int(input())
dp = [0]*(n+2)
for i in a:
    dp[i] = -1
dp[0] = 1

for i in range(n):
    if dp[i]<0:
        continue
    dp[i] %= 10**9+7
    if dp[i+1]>=0:
        dp[i+1] += dp[i]
    if dp[i+2]>=0:
        dp[i+2] += dp[i]
print(dp[n]%(10**9+7))
import numpy as np
x,y=map(int,input().split())
print(math.floor(np.log2(y/x)+1))


### FIXED CODE ###

import math
x,y=map(int,input().split())
print(len(bin(y//x))-2)
n = int(input())
S = n % 10
if(S == 0):
  print("pon")
else if(S == 1):
  print("pon")
else if(S == 6):
  print("pon")
else if(S == 8):
  print("pon")
else if(S == 3):
  print("bon")
else:
  print("hon")

### FIXED CODE ###

N = int(input())
S = N % 10
if(S == 0):
  print("pon")
elif(S == 1):
  print("pon")
elif(S == 6):
  print("pon")
elif(S == 8):
  print("pon")
elif(S == 3):
  print("bon")
else:
  print("hon")
# coding: utf-8

x = int(input())
t = int(input())

1<= x <=10^99
1<= t <=10^99

if (x - t) < 0 : 
    print(0) 
else :
    print(x - t)

### FIXED CODE ###

# coding: utf-8

s = input().split()

x = int(s[0])
t = int(s[1])

if (x - t) < 0 : 
    print(0) 
else :
    print(x - t)
import math

h, n = map(int,input().split())
a = list(map(int,input().split()))
sum = 0
for i in range(n):
    sum += a[i]

if sum >= h:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import math
h, a = map(int,input().split())
num = math.ceil(h/a)

print(num)
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

suma = [0] * n
sumb = [0] * m
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = suma[j-1]+b[j]

    
ans, cur= 0, m-1
for i in range(n):
    target = k - suma[i]
    if (i > 0) & (target <= 0):
        break
    for j in range(cur,-1,-1):
        if sumb[j] <= target:
            ans = max(ans, i+j+2)
            cur = j
            break
        else:
          	ans = i+1
print(ans)

### FIXED CODE ###

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

suma = [0] * (n)
sumb = [0] * (m)
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = sumb[j-1]+b[j]
    
suma.insert(0,0)
sumb.insert(0,0)

ans, cur = 0, m
for i in range(n+1):
  target = k - suma[i]
  if target < 0:
      break
  while sumb[cur] > target:
      cur -= 1
  ans = max(ans, i+cur)
print(ans)
n=int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if x+y>t or (x+y+t)%2==1:
      print("NO")
      exit()
print("YES")


### FIXED CODE ###

a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
def solve(N, M, ABs):
    ans = 0
    for i in range(M):
        m = {j: j for j in range(M)}
        for k, (a, b) in enumerate(ABs):
            a -= 1
            b -= 1
            if k == i:
                continue
            d = min(m[a], m[b])
            for mk in m:
                if m[mk] == m[a] or m[mk] == m[b]:
                    m[mk] = d
        if len(set(m.values())) != 1:
            ans += 1
    return ans

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(M)]
    print(solve(N, M, ABs))


### FIXED CODE ###

def solve(N, M, ABs):
    ans = 0
    for i in range(M):
        adjMat = [[0 for _ in range(N)] for _ in range(N)]
        for k, (a, b) in enumerate(ABs):
            if k != i:
                adjMat[a - 1][b - 1] = 1
                adjMat[b - 1][a - 1] = 1

        def dps(a, visited):
            n = [i for i, b in enumerate(adjMat[a]) if b == 1]
            for nn in n:
                if nn not in visited:
                    visited.append(nn)
                    dps(nn, visited)
            return visited

        visited = dps(0, [])
        if len(visited) != N:
            ans += 1
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(M)]
    print(solve(N, M, ABs))
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

### FIXED CODE ###

n,q=map(int,input().split())
s=list(input())
#print(s)
i=1
a=[0]
x=0
while i!=n:
    if s[i-1]=="A":
        if s[i]=="C":
            x=x+1
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break
print((a + b) * h // 2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
n , m ,l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for mi in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for  li in range(l):
    print(" ",join([str(s) for s in C[ni]]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]
 
A = []
B = []
C = []
 
for ni in range(n):
    A.append([int(i) for i in input().split()])
 
for mi in range(m):
    B.append([int(i) for i in input().split()])
 
for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
 
for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))
p = [1]*100001
p[0] = p[1] = 0
for i in range(2,int(100001**0.5)+1):
    if p[i]:
        p[2*i::i] = [0]*len(p[2*i::i])
p = [i for i in range(100001) if p[i]]

while 1:
    m,a,b = map(int,raw_input().split())
    if m == 0: break
    
    aw = ah = 2
    mx = 4
    for w in p:
        for h in p:
            if w*h > m: break
            if w*h > mx and 1 >= w*1.0/h >= a*1.0/b:
                mx = w*h
                aw,ah = w,h
    print aw,ah            

### FIXED CODE ###

import bisect
R = 100001/2
p = [1]*R
p[0] = p[1] = 0
for i in range(2,int(R**0.5)+1):
    if p[i]:
        p[2*i::i] = [0]*len(p[2*i::i])
p = [i for i in range(R) if p[i]]
n = len(p)
pxp = []
for i in range(n):
    for j in range(i,n):
        if p[i]*p[j] > 100000: break
        pxp.append([p[i]*p[j],p[i],p[j]])
pxp = sorted(pxp)
p,xyr = [e[0] for e in pxp],[[e[1],e[2],e[1]*1.0/e[2]] for e in pxp]
while 1:
    m,a,b = map(int,raw_input().split())
    if m == 0: break
    ab = a*1.0/b

    sp = bisect.bisect(p,m)
    for i in range(sp)[::-1]:
        if 1 >= xyr[i][2] >= ab:
            print xyr[i][0],xyr[i][1]
            break
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
else:
  for i in range(m-n+1):
    ans += a[i]
  print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  for i in range(m-n):
    ans += a[i]
  print(ans)
a = int(input())
b = int(input())
if a > b:
    print("a > b")
else if a == b:
    print("a == b")
else if a < b:
    print("a < b")

### FIXED CODE ###

a, b = map(int, input().split())
if a > b:
    print("a > b")
elif a == b:
    print("a == b")
else:
    print("a < b")
N, M, X, Y = map(int, input().split())
 
x = list(map(int, input().split()))
y = list(map(int, input().split()))    
 
for z in range(-100, 101):
    if (X < z) and (max(x) < z) and (z <= min(y)) and (z <= Y):
        print("No War")
    else:
        print("War")

### FIXED CODE ###

a, b, c = (int(x) for x in input().split())
print(a + b + c + max(a, b, c)*9)
l=[]
N,W=list(map(int,input().split()))
for i in range(N):
	item=list(map(int,input().split))
	l.append([item[1],item[0]])

# n=4
# l=[[2,3],[1,2],[3,4],[2,2]] #w,v
# W=5

def solve(i,w):
	if i==n or w<0:
		return(0)
	elif w-l[i][0]<0:
		return(0)
	else:
		return(max(solve(i+1,w),l[i][1]+solve(i+1,w-l[i][0])))

print(solve(0,W))

### FIXED CODE ###

value=[0]
weight=[0]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split()))
	value.append(item[0])
	weight.append(item[1])

dp=[[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	for j in range(W+1):
		if i==0:
			res=0
		elif j-weight[i]<0:
			res=dp[i-1][j]
		else:
			res=max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j])
		dp[i][j]=res
print(dp[n][W])
import math
N, K = map(int, input().split())

expo = (math.ceil(math.log(K,2)))

ans = 0
bunbo = 1/N
for i in range(N):
    ans = ans + (bunbo * (1/2)**expo)
    expo = expo - 1

print(ans)

### FIXED CODE ###

import math
N, K = map(int, input().split())
p = 0
for i in range(1,N+1):
  if i < K:
    times = math.ceil(math.log2(K/i))
    p = p + (1/N)*(1/2)**times
  else:
    p = p + (1/N)
print(p)
d, n = map(int, input().split())
print([i*100**d for i in range(101) if i != 100][n])

### FIXED CODE ###

d, n = map(int, input().split())
print([i*100**d for i in range(1, 102) if i != 100][n - 1])
n,m=map(int,input().split())

x=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if b not in x[a-i]:
        x[a-1].append(b)
        if a not in x[b-i]:
            x[b-1].append(a)

ans=0

while True:
    idx,flg=0,0
    for i in x:
        if len(i)==1:
            flg=1
            x[i[0]-1].remove(idx+1)
            x[idx]=[]
            ans+=1
        idx+=1
    if flg==0:
        break
print(ans)


### FIXED CODE ###

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

x=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if b not in x[a-1]:
        x[a-1].append(b)
        if a not in x[b-1]:
            x[b-1].append(a)

ans=0

while True:
    idx,flg=0,0
    for i in x:
        if len(i)==1:
            flg=1
            x[i[0]-1].remove(idx+1)
            x[idx]=[]
            ans+=1
        idx+=1
    if flg==0:
        break
print(ans)
N, M , X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))

min_y = min(y)
max_x = max(x)

count_x = sum(min_y < Z for t in x)

re = 'War'
if count_x == N : # and count_y == M:
    if  X < min_y and min_y <= Y:
        re = 'No War'
    elif X < max_x + 1 and max_x + 1 <= Y:
        re = 'No War'
    
print(re)

### FIXED CODE ###

N, M , X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))

min_y = min(y)
max_x = max(x)

count_x = sum(t < min_y for t in x)

re = 'War'
if count_x == N : # and count_y == M:
    if  X < min_y and min_y <= Y:
        re = 'No War'
    elif X < max_x + 1 and max_x + 1 <= Y:
        re = 'No War'
    
print(re)
n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]!="1":
    i=t+1
    break
if m<i:
  print(1)
else:
  print(int(n[i]))


### FIXED CODE ###

n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]!="1":
    i=t+1
    break
if m<i:
  print(1)
else:
  print(int(n[i-1]))
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
m = min(a,b,c,d,e)
print(ceil(n/m) + 4)

### FIXED CODE ###

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
m = min(a,b,c,d,e)
if n % m == 0:
    print(n//m + 4)
else:
    print(n//m + 5)
a,b,c,x,y = map(int,input().split())
if x > y:
	z = a
else:
	z = b

ans1 = min(x,y) * min(a + b,c*2),abs(x-y) * z
ans2 = c * max(x,y)
print(min(ans1,ans2))

### FIXED CODE ###

a,b,c,x,y = map(int,input().split())
if x > y:
	z = a
else:
	z = b

ans1 = min(x,y) * min(a + b,c*2) + abs(x-y) * z
ans2 = c * max(x,y) * 2
print(min(ans1,ans2))
N, K = list(map(int, input().split()))
S = list(map(int, input().split()))
 
happy = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    happy += 1
print(min([N-1, happy + 2 * K]))

### FIXED CODE ###

N, K = list(map(int, input().split()))
S = input()

happy = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    happy += 1
print(min([N-1, happy + 2 * K]))