Harryxun/stf_run huggingface dataset:
import sys
from math import hypot
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

inf = 10**9+7
EPS = 1e-8
ans = inf
for i in range(N):
    for j in range(i):
        a = Points[i][0]
        b = Points[i][1]
        c = Points[j][0]
        d = Points[j][1]
        px, py = (a+c)/2, (b+d)/2
        R = hypot(a-px, b-py)
        if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
            ans = min(ans, R)
            
for i in range(N):
    for j in range(i):
        for k in range(j):
            a = Points[i][0]
            b = Points[i][1]
            c = Points[j][0]
            d = Points[j][1]
            e = Points[k][0]
            f = Points[k][1]
            
            ea = hypot(c-e, d-f)
            eb = hypot(a-e, b-f)
            ec = hypot(a-c, b-d)
            cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
            cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
            cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
            sA = (1-cA**2)**0.5
            sB = (1-cB**2)**0.5
            sC = (1-cC**2)**0.5
            s2A = 2*sA*cA
            s2B = 2*sB*cB
            s2C = 2*sC*cC
            if max(s2A, s2B, s2C) < EPS:
                continue
            else:
                px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                R = hypot(px - a, py - b)
            
            if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                ans = min(ans, R)
print(ans)


### FIXED CODE ###

import sys
from math import hypot
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

inf = 10**9+7
EPS = 1e-8
ans = inf
for i in range(N):
    for j in range(i):
        a = Points[i][0]
        b = Points[i][1]
        c = Points[j][0]
        d = Points[j][1]
        px, py = (a+c)/2, (b+d)/2
        R = hypot(a-px, b-py)
        if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
            ans = min(ans, R)
            
for i in range(N):
    for j in range(i):
        for k in range(j):
            a = Points[i][0]
            b = Points[i][1]
            c = Points[j][0]
            d = Points[j][1]
            e = Points[k][0]
            f = Points[k][1]
            
            ea = hypot(c-e, d-f) + EPS
            eb = hypot(a-e, b-f) + EPS
            ec = hypot(a-c, b-d) + EPS
            cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
            cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
            cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
            sA = (1-cA**2)**0.5
            sB = (1-cB**2)**0.5
            sC = (1-cC**2)**0.5
            s2A = 2*sA*cA
            s2B = 2*sB*cB
            s2C = 2*sC*cC
            if max(s2A, s2B, s2C) < EPS:
                continue
            else:
                px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                R = hypot(px - a, py - b)
            
            if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                ans = min(ans, R)
print(ans)
a = []
for i in (5):
  a += [int(input())]
a.sort()
kekka = ":("
if a[4] - a[0] <= k:
  kekka = "Yay!"
print(kekka)

### FIXED CODE ###

a = []
for i in range (5):
  a += [int(input())]
k = int(input())
a.sort()
kekka = ":("
if a[4] - a[0] <= k:
  kekka = "Yay!"
print(kekka)
aaa

### FIXED CODE ###

while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        det=a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        if x==0:x=0
        if y==0:y=0
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

### FIXED CODE ###

N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j] = li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)
a = input()
if a = 'ABC':
  print('ARC')
else:
  print('ABC')
  

### FIXED CODE ###

a = input()
if a == 'ABC':
  print('ARC')
elif a == 'ARC':
  print('ABC')
a=int(input())
s =0
for i in range(a):
    for j in range(a):
        for k in range(a):
            for n in range(min(i,j,k)+1):
                if a%(n+1) == 0 and b%(n+1) == 0 and c%(n+1) ==0:
                    gcd = n+1
            s = s + gcd
print(s)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

import itertools
a=int(input())
A=[]
for i in range(a):
    A.append(str(i+1))

li=list(itertools.combinations_with_replacement(A, 3))
s = 0
for lis in li:
    a = int(lis[0])
    b = int(lis[1])
    c = int(lis[2])
    
    if math.gcd(b,c) == 1:
        gcd1 = 1
    else:
        gcd1 = gcd(a,b,c)
    
    if a==b and b==c:
        s = s + gcd1
    elif a==b or b==c:
        s = s + 3*gcd1
    else:
        s = s + 6*gcd1
print(s)
from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l　% mod)



### FIXED CODE ###

from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l % mod)
n = int(input())
a = [int(input()) for _ in range(n)]
m = int(input())
for _ in range(m):
  b,c = [int(x) for x in input.split()]
  a[b-1] = c
  print(sum(a))


### FIXED CODE ###

a,o,b = input().split()
print(int(a) + int(o+b))
from itertools import accumulate
import numpy as np
N=int(input())-1
L=[26**(i+1) for i in range(10)]
sL=list(accumulate(L))
result=[]
for i in range(10):
    if N<=sL[i] and N>=26:
        N-=sL[i-1]
        k=i
        break
for m in range(k):
    time=0
    while N>=L[k-m-1]:
        N-=L[k-m-1]
        time+=1
    result.append(chr(time+97))
result.append(chr(N+97))
print(''.join(result))

### FIXED CODE ###

from itertools import accumulate
import numpy as np
N=int(input())
N-=1
L=[26**(i+1) for i in range(15)]
sL=list(accumulate(L))
result=[]
k=0
for i in range(15):
    if N+1<=sL[i] and N>=25:
        N-=sL[i-1]
        k=i
        break
for m in range(k):
    time=0
    while N>=L[k-m-1]:
        N-=L[k-m-1]
        time+=1
    result.append(chr(time+97))
result.append(chr(N+97))
print(''.join(result))
n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=defaultdict(int)
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>=h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))

### FIXED CODE ###

n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=[-float('inf')]*(n+1)
dp[0]=0
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))
n = int(input())
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
count = 0
for x in range(n):
 if v[x] > c[x]:
  count = count + v[x] - c[x]
print(count)

### FIXED CODE ###

n = int(input())
money = 0
for i in range(n):
    x,u = input().split()
    if u == "JPY":
        x = int(x)
        money = money + x
    else:
        x = float(x)
        money = money + x*380000
print(money)
n, k = map(int, input().split())
TO = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

# print(n,k)
# print(TO)
# print(C)

vis = [False]*(n+1)
def dfs(i, t):
    if vis[i]: return t
    vis[i] = True
    t.append(i)
    return dfs(TO[i], t)

INF = 1*((10**9)*5000 + 1)
score = -INF
for f in range(n):
    T = dfs(f, [])
    len_t = len(T)
    if len_t == 0: continue
    costs = [0] * (len_t)
    for i in range(len_t): costs[i] = C[T[i]]
    loops = k // len_t
    cost = sum(costs)
    # print(len_t, T, 'costs',costs, cost, loops)
    if cost >= 0:
        k -= loops * len_t
        cost = cost * loops

    peak_cost = -INF
    for i in range(len_t):
        sum_cost = 0
        for j in range(k):
            sum_cost += costs[(i+j)%len_t]
            peak_cost = max(peak_cost, sum_cost)
    # print(k,'peak_cost',peak_cost, cost)
    cost = max({cost, cost + peak_cost, peak_cost})
    # print('cost',cost)
    score = max(score, cost)
print(score)



### FIXED CODE ###

n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

INF = 10**18
max_score = -INF
for st in range(n):
    lc = 0 # lap count
    lap_sc = 0 # lap score
    nx = st
    while True:
        lc += 1
        lap_sc += C[nx]
        nx = P[nx]
        if nx == st: break

    sum_sc = 0
    kc = 0
    while True:
        kc += 1
        if k < kc: break

        sum_sc += C[nx]
        score = sum_sc + max(0, lap_sc) * ((k - kc) // lc)
        max_score = max(max_score, score)

        nx = P[nx]
        if nx == st: break

print(max_score)

# print('===')
# print(n,k)
# print(P)
# print(C,end='\n\n')
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 li in range(l):
    print(" ".join(C[li]))

### 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]]))
N, M = map(int, input().split())
pathmat=[[0]*N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    pathmat[a-1][b-1] = 1
    pathmat[b-1][a-1] = 1

visited =  [False]*N
visited[0] = True
ans = 0

def DFS(now, visited):
    if all(visited):
        return 1
    for i in range(N):
        if not pathmat[now][i]:
            continue
        if visited[i]:
            continue
        visited[i]=True
        ans += DFS(i, visited)
        visited[i]=False
    return ans

print(DFS(0,visited))

        
            


### FIXED CODE ###

N, M = map(int, input().split())
pathmat=[[0]*N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    pathmat[a-1][b-1] = 1
    pathmat[b-1][a-1] = 1

visited =  [False]*N
visited[0] = True


def DFS(now, visited):
    if all(visited):
        return 1
    ans = 0
    for i in range(N):
        if not pathmat[now][i]:
            continue
        if visited[i]:
            continue
        visited[i]=True
        ans += DFS(i, visited)
        visited[i]=False
    return ans

print(DFS(0,visited))
import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n<1:
        return 0
    if n==1:
        return 1
    return ( math.factorial(n+x-1)//math.factorial(n-1)//math.factorial(x) % 1000000007)

for i in range (1,k+1):
    cb=place(  i,  k-i  )
    cr=place(i+1,n-k-i+1)
    cr=cr%1000000007
    print(cb*cr%1000000007)


### FIXED CODE ###

import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n==1:
        return 1
    ans=1
    if n-1 < x:
        for i in range(x+1,n+x):
            ans*=i
        ans//=math.factorial(n-1)
    else:
        for i in range(n, n+x):
            ans*=i
        ans//=math.factorial(x)
    return ans%1000000007


for i in range (1,k+1):
    if n-k < i-1:
        print(0)
    else:
        cb=place(  i,  k-i  )
        cr=place(i+1,n-k-i+1)
        cr=cr%1000000007
        print(cb*cr%1000000007)
a, b = [int(i) for i in input().split]

if a < b:
    print(a < b)
elif a > b:
    print(a > b)
else:
    print(a == b)

### FIXED CODE ###

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

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
a = input().split()
b = input().split()
c = input()

if(int(b[0]>int(a[0]))):
	if(int(b[1])>=int(a[1])):
		print("NO")
	else:
		length = int(b[0]) - int(a[0])
		v = int(a[1]) - int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")
else:
	if(int(b[1])<=int(a[1])):
		print("NO")
	else:
		length = -int(b[0]) + int(a[0])
		v = int(-a[1]) + int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")


### FIXED CODE ###


a = input().split()
b = input().split()
c = input()

A = int(a[0])
V = int(a[1])
B = int(b[0])
W = int(b[1])
T = int(c)

if (B>A):
	if(W>=V):
		print("NO")
	else:
		times = (B-A) / (V-W)
		if(times <= T):
			print("YES")
		else:
			print("NO")
else:
	if(W>=V):
		print("NO")
	else:
		times = (A-B) / (V-W)
		if(abs(times) <= T):
			print("YES")
		else:
			print("NO")
N,K = map(int,input().split(' '))
P = list(map(int,input().spllit(' ')))
if(k==1):
  print(min(P))
else:
  res=[]
  for i in range(K):
    res[i].append(min(P))
    P.remove(min(P))
  print(sum(res)) 

### FIXED CODE ###

N,K = map(int,input().split(' '))
P = list(map(int,input().split(' ')))
if(K==1):
  print(min(P))
else:
  res=[]
  for i in range(K):
    res.append(min(P))
    P.remove(min(P))
  print(sum(res))
n,q = input().split()
#print(str(n))
#print(str(q))
 
n = int(n)
q = int(q)
a = [0] * (n-1)
b = [0] * (n-1)
p = [0] * q
x = [0] * q
counter = [0] * n
children = []
parent = [-1] * n
 
for c in range(n):
  children.append(str(c+1))
#print(children)
 
for i in range(n-1):
  a[i],b[i] = input().split()
  parent[int(b[i]) - 1] = int(a[i])-1#親の配列インデックス
  children[int(a[i])-1]+=(" "+b[i])
  children[parent[int(a[i])-1]] += (" "+b[i])
 
for j in range(q):
  p[j],x[j] = input().split()
  list = children[int(p[j])-1].split()
  #print(list)
  for aa in list:
    counter[int(aa)-1] += int(x[j])
for bb in counter:
  print(bb, end="")
  print(" ", end="")

### FIXED CODE ###

a = int(input())
s = input()

if(a >= 3200):
  print(s)
else:
  print("red")
n = input()
f = [for i in range(2000)] = [1]
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1
 
Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n = int(raw_input())
A = map(int,raw_input().split())
Q = int(raw_input())
m = map(int,raw_input().split())

def s(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  r = s(i + 1, m) or s(i + 1, m - A[i])
  return r

for j in range(Q):
  if s(0, m[j]):
    print "yes"
  else:
    print "no"
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

S = input()
N = int(S)
lenS = len(S)
num = 2019

dp = [[0]*2020 for _ in range(lenS)]
dp[0][0] = 1
dp[3][int(S[0:3])] = 1
dp[3][int(S[1:3])] = 1
dp[3][int(S[2:3])] = 1

for i in range(3, lenS-1):
    moji = int(S[i])
    dp[i+1][moji] += 1
    for j in range(2019):
        dp[i+1][(j*10 + moji)%2019] += dp[i][j]
#pri(dp)

cnt = 0 
for i in range(3, lenS):
    cnt += dp[i][0]
print(cnt+1)


### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 2019
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

S = input()
N = len(S)

d = defaultdict(int)
d[0] += 1
# nums = [0]*(N+1)
m = 0
last = 0
dd = 1
for i in range(N):
    m += int(S[N-i-1])*dd
    m %= MOD
    # val = (int(S[i])*m + nums[i])%MOD
    # cnt += d[val]
    dd = (dd*10)%MOD
    d[m] += 1

cnt = 0
for i, v in d.items():
    cnt += v*(v-1)//2
print(cnt)
from decimal import Decimal
import math 
X = int(input())
yen = 100
n = 1
while True:
    yen = decimal(math.floor(yen*1.01*n))
    if X <= yen:
        print(n)
        break
    n = n + 1

### FIXED CODE ###

import math 
X = int(input())
yen = 100
n = 0
while yen < X:
    n = n + 1
    yen = math.floor(yen*1.01)
    if X <= yen:
        print(n)
3 3
1 2 3

### FIXED CODE ###

def solve():
    n,k = map(int, input().split())
    A = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

if __name__ == '__main__':
    print(solve())
n = int(input())
a = list(map(1/(int,input().split())))
print(1/sum(a))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a = [1/a[i] for i in range(n)]
print(1/sum(a))
# -*- condig:utf-8 -*-

import sys
import collections

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

counter = [0 for _ in range(n+1)]
o = collections.defaultdict(int)
g = collections.defaultdict(list)

for i in range(n-1):
  a,b= map(int, input().split())
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x= map(int, input().split())
  o[p] += x


def dfs(p, parent):
  counter[p] += o[p]
  for i in g[p]:
    if i == parent:
      counter[p] += counter[i]
    else:
      dfs(i, p)
 
dfs(1, 0)
print(*counter[1:])

 
  


### FIXED CODE ###


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

ct = [0] * (n+1)
o = [0] * (n+1)
g = [[] for _ in range(n+1)]

for i in range(n-1):
  a,b= map(int, input().split())
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x= map(int, input().split())
  o[p] += x

todo = [1]
seen = [False] * (n+1)
while todo:
  p = todo.pop(-1)
  ct[p] += o[p]
  seen[p] = True
  for i in g[p]:
    if seen[i]:
      ct[p] += ct[i]
    else:
      todo.append(i)

print(*ct[1:])
n,m=map(int,input().split())
hoge=list(map(int,input().split()))

if(sum(hoge)>n):
  print(-1)
else:
  print(n-sum(hoge))


### FIXED CODE ###

n=int(input())

print(2*n*3.141592)
count = 0

N = int(input())
S = input()
for j in range(1,N+1):
    for string in itertools.combinations(S, r = j):
        if len(set(string)) == len(string):
            print(string)
            count += 1


print(count)

### FIXED CODE ###

counter = 1
N = int(input())
S = input()

n = 10**9 + 7
for i in set(S):
    counter *= (S.count(i)+1)
    counter = counter % n
 
print(counter-1)
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

### FIXED CODE ###

n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)
import math
import sys
sys.setrecursionlimit(10000000)

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

up = math.sqrt(n)

def colsum(num, base):
    if num < base:
        return num
    else:
        return num%base + colsum(num//base,base)

#s = n(n<b)
if s == n:
    print(n+1)
    exit()


#sqrt(n)まで探索
for i in range(2,int(up)+1):
    if s == colsum(n,i):
        print(i)
        exit()

#2桁しかあり得ない場合(sqrt(n)<b<n)
for j in range(1,int(up)+1):
    b = int((n-s)/j) + 1
    if s == colsum(n,b) and b > 1:
        print(i)
        exit()

print(-1)

### FIXED CODE ###

import math
import sys

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

up = math.sqrt(n)

def colsum(num, base):
    if num < base:
        return num
    else:
        return num%base + colsum(num//base,base)

#s >= n
if s == n:
    print(n+1)
elif s > n:
    print(-1)
else:
    #sqrt(n)まで探索
    for i in range(2,int(up)+1):
        if colsum(n,i) == s:
            print(i)
            sys.exit()

    #2桁しかあり得ない場合(sqrt(n)<b<n)
    for j in range(int(up),0,-1):
        if (n-s)%j == 0:
            b = (n-s)/j + 1
            if colsum(n,b) == s and b > 1:
                print(int(b))
                sys.exit()

    print(-1)
def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
x = int(input())
n = int(input())
a = list(map(int,input().split()))
print(serch_1(a,x),serch_2(a,x))
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))

    

### FIXED CODE ###

def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
s = list(map(int,input().split()))
# n = int(input())
a = list(map(int,input().split()))
# print(serch_1(a,x),serch_2(a,x))
x=s[0]
n=s[1]
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))
N,M = map(int, input().split())
A = [input().split() for _ in range(N)]

B = [0]*30

for i in range(N):
	for j in range(int(A[i][0])):
		#print(i,j)
		B[int(A[i][j])] += 1

print(B.count(N)) 


### FIXED CODE ###

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

B = [0]*30

for i in range(N):
	K, *A = map(int, input().split())
	for a in A:
		B[a-1] += 1

print(sum(c == N for c in B))
def main():
    s = input()

    zero = s.count('0')
    one = len(s) - zero

    print(min(zero, one) *)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s = input()

    zero = s.count('0')
    one = len(s) - zero

    print(min(zero, one) * 2)

if __name__ == '__main__':
    main()