Harryxun/stf_run huggingface dataset:
import math
n = int(input())
half = math.floor(n**0.5)
#print(half)

for i in range(half+1,0,-1):
  if n % i == 0 and 1 <=n/i<=9 :
    num1,num2 = i,n//i  
    #print("Yes")
    break

if not num1:
  print(n-1)
else:
  print(num1+num2-2)
    

### FIXED CODE ###

import math
n = int(input())
half = math.floor(n**0.5)
#print(half)

num1 = 0
for i in range(half+1,0,-1):
  if n % i == 0:
    num1,num2 = i,n//i  
    #print("Yes")
    break

if num1 == 0:
  print(n-1)
else:
  print(num1+num2-2)
x,y = map(int,input().split())

#print(x,y)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
x_li=(make_divisors(x))
y_li=(make_divisors(y))
z_li=(list(set(x_li)&set(y_li)))
#print(z_li)

import math
count=1
c=[]
"""
for n in z_li:
  if n == 1:
    count=count+1
    continue
  for k in range(2, int(math.sqrt(n)) + 1):
    print(n,k)
    if n % k == 0:
      break;
    else:
      c.append(n)
      count = count+1
print(c,count)
"""

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
  
  
for n in z_li:
  if(is_prime(n)==True):
    count=count+1
print(count)

### FIXED CODE ###

import math
a=int(input())
if(a%2==0):
  print(0.5000)
else:
  print(math.floor(a/2+1)/a)
S = input()
l=len(S)
ans=[1]*l
for i in range(l-2):
    if s[i]==s[i+1]=="R":
        ans[i+2]+=ans[i]
        ans[i]=0
for i in range(l-1,1,-1):
    if s[i]==s[i-1]=="L":
        ans[i-2]+=ans[i]
        ans[i]=0
print(*ans)

### FIXED CODE ###

s = input()
l=len(s)
ans=[1]*l
for i in range(l-1):
    if s[i]==s[i+1]=="R":
        ans[i+2]+=ans[i]
        ans[i]=0
for i in range(l-1,1,-1):
    if s[i]==s[i-1]=="L":
        ans[i-2]+=ans[i]
        ans[i]=0
print(*ans)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
x = b - a
y = v - w
n = (a + v * t) - (b + w)
if y <= 0:
    print("NO")
if　n >= 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if abs(b - a) <= (v - w) * t:
    print("YES")
else:
    print("NO")
n=int(input())
data=list(map(int, input().split()))
print('%d %d %d' % (min(data), max(data), sum(data) )))

### FIXED CODE ###

n=int(input())
data=list(map(int, input().split()))
print('%d %d %d' % (min(data), max(data), sum(data) ))
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0086

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    while True:
        routes = []
        while True:
            a, b = map(int, input().split())
            if a == 0 and b == 0:
                break
            routes.append([a, b])
        if len(routes) < 1:
            quit()

        degree = [0] * 101
        for a, b in routes:
            degree[a] += 1
            degree[b] += 1
        odds = [x for x in degree if x%2==1]
        evens = [x for x in degree if x%2==0]

        if len(odds) == 0 or len(odds) == 2:
            print('OK')
        else:
            print('NG')






if __name__ == '__main__':
    main(sys.argv[1:])
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0086

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    for line in sys.stdin:
        routes = []
        a, b = map(int, line.split())
        if a == 0 and b == 0:
            break
        while a != 0 or b!= 0:
            routes.append([a, b])
            a, b = map(int, input().split())

        degrees = [0] * 101
        for a, b in routes:
            degrees[a] += 1
            degrees[b] += 1
        odds = [x for x in degrees if x%2==1]
        # evens = [x for x in degrees if x%2==0]
        # print(degrees)

        if len(odds) == 2 and degrees[1]%2==1 and degrees[2]%2==1:
            print('OK')
        else:
            print('NG')


if __name__ == '__main__':
    main(sys.argv[1:])
M, N = map(int,input().split())

if M == 1 or N == 1:
  print(1)
  break
  if M * N % 2 == 1:
    print(M * N // 2 + 1)
  elif M*  N % 2 == 0:
    print(M * N // 2)


### FIXED CODE ###

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

if M == 1 or N == 1:
  print(1)
elif M * N % 2 == 1:
    print(M * N // 2 + 1)
elif M*  N % 2 == 0:
    print(M * N // 2)
h,w,k=map(int,input().split())
pos=[0]*(h*w+1)
for _ in range(h):
  tmp=list(map(int,input().split()))
  for i in range(w):
    pos[tmp[w]]=[i+1,w+1]
print(pos)h,w,k=map(int,input().split())
pos=[0]*(h*w+1)
for i in range(h):
  tmp=list(map(int,input().split()))
  for j in range(w):
    pos[tmp[j]]=[i+1,j+1]
cs=[[0] for _ in range(k+1)]
for i in range(1,k+1):
  for j in range(1,(h*w-i)//k+1):
    x1,y1=pos[i+k*(j-1)][1],pos[i+k*(j-1)][0]
    x2,y2=pos[i+k*j][1],pos[i+k*j][0]
    cs[i].append(abs(y2-y1)+abs(x2-x1)+cs[i][j-1])
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  tmp=l%k
  if tmp==0:
    tmp=k
  l,r=(l-tmp)//k,(r-tmp)//k
  print(cs[tmp][r]-cs[tmp][l])

### FIXED CODE ###

h,w,k=map(int,input().split())
pos=[0]*(h*w+1)
for i in range(h):
  tmp=list(map(int,input().split()))
  for j in range(w):
    pos[tmp[j]]=[i+1,j+1]
cs=[[0] for _ in range(k+1)]
for i in range(1,k+1):
  for j in range(1,(h*w-i)//k+1):
    x1,y1=pos[i+k*(j-1)][1],pos[i+k*(j-1)][0]
    x2,y2=pos[i+k*j][1],pos[i+k*j][0]
    cs[i].append(abs(y2-y1)+abs(x2-x1)+cs[i][j-1])
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  tmp=l%k
  if tmp==0:
    tmp=k
  l,r=(l-tmp)//k,(r-tmp)//k
  print(cs[tmp][r]-cs[tmp][l])
N,M = map(int,input().split())
path = [[] for _ in range(N*3+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v+N)
    path[u+N].append(v+N+N)
    path[u+N+N].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [-1 for _ in range(N*3+3)]
def bfs():
    while len(q) > 0:
        now,cnt = q.popleft()
        #print(now,T,cnt,path[now],q)
        vis[now] = cnt
        if now == T: 
            return cnt
        for x in path[now]:
            if vis[x] == -1:
                q.append((x,cnt+1))
vis[S] = 1
q.append([S,0])
ans = bfs()
if vis[T] == -1: print(-1)
else: print(ans//3)




### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,K = map(int,input().split())
for i in range(1,1+K):
    ans = cmb(1+N-K,i,mod)
    ans *= cmb(K-1,K-i,mod)
    print(ans%mod)
N = int(input())
S = input()
result = 0
'''
for i in range(N):
    print(result)
    for j in range(i+1,N):
        if S[i] != S[j]:
            for k in range(j ,N):
                if k- j == j - i:
                    continue
                if S[j] != S[k] and S[i] != S[k]:
                    result +=1
print(result)
'''
r = S.count('R')
g = S.count('G')
b = S.count('B')
target = set('RGB')
result = r * g * b
for i in range(N):
    for j in range(1, min(i, (N - i + 1)) + 1):
        if target == set(S[i] + S[i-j] + S[j + i]):
            result -= 1
print(result)

### FIXED CODE ###

N = int(input())
S = input()
result = 0
'''
for i in range(N):
    print(result)
    for j in range(i+1,N):
        if S[i] != S[j]:
            for k in range(j ,N):
                if k- j == j - i:
                    continue
                if S[j] != S[k] and S[i] != S[k]:
                    result +=1
print(result)
'''
r = S.count('R')
g = S.count('G')
b = S.count('B')
target = set('RGB')
result = r * g * b
for i in range(N):
    for j in range(1, min(i, (N - i - 1)) + 1):
        if target == set(S[i] + S[i-j] + S[j + i]):
            result -= 1
print(result)
a = int(input())
b = int(input())
h = int(input())
m = int(input())
ans = 0

m_r = m/5

h_r = h + m/60

reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)

### FIXED CODE ###

s = str(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]


if int(s[-1]) in hon:
    print("hon")
elif int(s[-1]) in pon:
    print("pon")
else:
    print("bon")
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1:M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


### FIXED CODE ###

N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1,M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
N, M = map(int, input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

if M == 0:
    print(cmb(N, 2))
elif N == 0:
    print(cmb(M, 2))
elif M <= 1 and N <= 1:
    print(0)
else:
    a = cmb(M, 2)
    b = cmb(N, 2)
    print(a + b)

### FIXED CODE ###

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

if M == 0 and N == 0:
    print(0)
elif M == 1 and N == 1:
    print(0)
elif M <= 1:
    print(cmb(N, 2))
elif N <= 1:
    print(cmb(M, 2))
else:
    a = cmb(M, 2)
    b = cmb(N, 2)
    print(a + b)
from bisect import bisect

n = int(input())
ma = [-int(input()) for _ in range(n)]

ans = [ma[0]]
for ai in ma[1:]:
    tmp = bisect(ans, ai)
    if tmp == len(ans):
        ans.append(ai)
    elif tmp < len(ans):
        ans[tmp] = ai
    print(ans)
print(len(ans))


### FIXED CODE ###

from bisect import bisect

n = int(input())
ma = [-int(input()) for _ in range(n)]

ans = [ma[0]]
for ai in ma[1:]:
    tmp = bisect(ans, ai)
    if tmp == len(ans):
        ans.append(ai)
    elif tmp < len(ans):
        ans[tmp] = ai
print(len(ans))
a,s = int(input()),input()
if a >= 3200:
  print(s)
else
  print('red')

### FIXED CODE ###

a,s = int(input()),input()
if a >= 3200:
  print(s)
else:
  print('red')
mport heapq
n,m=map(int,input().split())
list=[[] for i in range(m)]
h=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    list[a-1].append(-b)
ans=0
for i in range(m):
  for j in list[i]:
    heapq.heappush(h,j)
  if h:
    ans+=-heapq.heappop(h)
  else:
    continue
print(ans)  

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
list=[[] for i in range(m)]
h=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    list[a-1].append(-b)
ans=0
for i in range(m):
  for j in list[i]:
    heapq.heappush(h,j)
  if h:
    ans+=-heapq.heappop(h)
  else:
    continue
print(ans)
n, k = input().split()
d = list(map(int, input().split()))

a = []

for i in range(10):
    if i not in d:
        a.append(i)

n = list(map(int, list(n)))

for i in range(len(n)):
    if n[i] in d:
        ind = i

        done = False
        while not done:
            for j in range(n[ind]+1, 10):
                if j in a:
                    n[ind] = j
                    done = True
                    break

            if not done:
                ind -= 1

                if ind < 0:
                    n.insert(0, a[1] if a[0] == 0 else a[0])
                    ind = 0
                    done = True

        for j in range(ind+1, len(n)):
            n[j] = a[0]

        break

print("".join(list(map(str, n))))

### FIXED CODE ###

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

a = []

for i in range(10):
    if i not in d:
        a.append(i)

n = list(map(int, list(n)))

for i in range(len(n)):
    if n[i] in d:
        ind = i

        done = False
        while not done:
            for j in range(n[ind]+1, 10):
                if j in a:
                    n[ind] = j
                    done = True
                    break

            if not done:
                ind -= 1

                if ind < 0:
                    n.insert(0, a[1] if a[0] == 0 else a[0])
                    ind = 0
                    done = True

        for j in range(ind+1, len(n)):
            n[j] = a[0]

        break

print("".join(list(map(str, n))))
import numpy as np
h,w,k = map(int,input().split())
c = np.zeros((h,w))
for _ in range(h):
  row = [1 if a=='#' else 0 for a in input()]
  c[_]=row
ans = 0
for bit in range(1<<h+w):
  d = np.copy(c)
  for i in range(h+w):
    if (bit>>i)&1:
      if i<h:
        d[i]=0
      else:
        d[:,i-h]=0
  if np.sum(d)==k:
    ans += 1
print(ans)

### FIXED CODE ###

import numpy as np
h,w,k = map(int,input().split())
c = []
for _ in range(h):
  row = [1 if a=='#' else 0 for a in input()]
  c.append(row)
c = np.array(c).reshape(h,w)
ans = 0
for bith in range(1<<h+w):
  d = np.copy(c)
  for i in range(h+w):
    if (bith>>i)&1:
      if i<h:
        d[i]=0
      else:
        d[:,i-h]=0
  if np.sum(d)==k:
    ans += 1
print(ans)
import fractions

N = int(input())
A = list(map(int, input().split()))
L = [0] * (N+1)
R = [0] * (N+2)
M = [0] * (N+1)

for i in range(1, N+1):
  L[i] = fractions.gcd(L[i-1], A[i-1])
  R[N-i+] = fractions.gcd(R[N-i+2], A[i-1])

for i in range(1, N+1):
  M[i] = fractions.gcd(L[i], R[i+1])

print(max(M[1:]))
    


### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))
L = [0] * (N+1)
R = [0] * (N+2)
M = [0] * (N+1)

for i in range(1, N+1):
  L[i] = fractions.gcd(L[i-1], A[i-1])
  R[N-i+1] = fractions.gcd(R[N-i+2], A[N-i])

for i in range(1, N+1):
  M[i] = fractions.gcd(L[i-1], R[i+1])
print(max(M[1:]))
import itertools as it

N = int(input())
A = [0] + list(map(int, input().split()))
A = A.append(0)

L = [0]
for i in range(N):
    L.append(L[-1] + abs(A[i+1] - A[i]))

L.append(L[-1] + abs(A[-2] - A[0]))

for i in range(N):
    print(L[i] + (L[-1] - L[i+2]) + abs(A[i] - A[i+2]))


### FIXED CODE ###

import itertools as it

N = int(input())
A = [0] + list(map(int, input().split())) + [0]

L = 0
for i in range(N+1):
    L += abs(A[i+1] - A[i])
    
for i in range(1,N+1):
    print(L - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])) + abs(A[i+1] - A[i-1]))
N,M = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(M)]
R = [list(map(int,input().split())) for _ in range(M)]
L.sort()
R.sort()
count = 0
for i in range(1,N+1):
  if i >= L[-1] and i <= R[0]:
    count += 1
print(count)

### FIXED CODE ###

N,M = map(int,input().split())
L = []
R = []
ans = 0
for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)
ans = max(0,min(R) - max(L) + 1)
print(ans)
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

x.sort()
y = []
for i in range(m-1):
    y.append(x[i+1] - x[i])

for i in range(n-1):
    y.remove(max(y))

w = sum(y)
print(w)


### FIXED CODE ###

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

x.sort()
y = []
for i in range(m-1):
    y.append(x[i+1] - x[i])

y.sort()


'''
for i in range(n-1):
    y.remove(max(y))
'''
if m > n: w = sum(y[:m-n])
else: w = 0
print(w)
A = input("enter number for A: ")
B = input("enter number for B: ")
C = input("enter number for C: ")

a1 = A
b1 = B
c1 = C
a = c1
b = a1
c = b1
print(f"valuse after reverse A = {a}")
print(f"valuse after reverse B= {b}")
print(f"valuse after reverse C= {c}")

### FIXED CODE ###

x,y,z = list(map(int,input().split()))
 
def swap(a,b):
    tmp = a
    a = b
    b = tmp
    return (a,b)
 
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)
n,m=map(int,input().split())
print((n(n-1)//2)*(m(m-1)//2))

### FIXED CODE ###

n,m=map(int, input().split())
r = 0
if n>=2:
	r += n*(n-1)//2
if m>=2:
	r += m*(m-1)//2
print(r)
n = int(input())
s = list(input())
r = []
g = []
b = []
for i,j in enumerate(s):
    if j == "R":
        r.append(i)
    elif j == "G":
        g.append(i)
    else:
        b.append(i)
ans = 0
for i in r:
    for j in g:
        for k in b:
            a=[i,j,k]
            a.sort()
            if a[2]-a[1] != a[1]-a[0]:
                ans+=1
print(ans)


### FIXED CODE ###

s = list(input())
if "7" in s:
    print("Yes")
else:
    print("No")
A = input()
B = input()
C = input()
T = "a"
while not ((A=="" and T=="a") and (B==""and T=="b") and (C==""and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A==""):
  print("a")
elif (B==""):
  print("b")
elif (C==""):
  print("c")

### FIXED CODE ###

A = input()
B = input()
C = input()
T = "a"
while  not ((A=="" and T=="a") or (B=="" and T=="b") or (C=="" and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A=="" and T=="a"):
  print("A")
elif (B=="" and T=="b"):
  print("B")
elif (C=="" and T=="c"):
  print("C")
S = input()
num = 0
while(True):
    num += S.count("BW")
    S = S.replace("BW", "WB")
    print(S)
    if not "BW" in S:
        break
print(num)

### FIXED CODE ###

S = input()
indexes = [i for i, x in enumerate(S) if x == "W"]
print(sum([x-i for i, x in enumerate(indexes)]))
import numpy as np

h, w, m = map(int, input().split())
bb = [[0] * w for _ in range(h)]
mx = 0
for _ in range(m):
    bh, bw = map(int, input().split())
    bb[bh - 1][bw - 1] = 1
smr = np.sum(bb,axis=1)
bb.pop(np.argmax(smr))
smc = np.sum(bb,axis=0)
print(max(smr) + max(smc))

### FIXED CODE ###

h, w, m = map(int, input().split())
s = []
r = [0] * (h + 1)
c = [0] * (w + 1)
for i in range(m):
    bh, bw = map(int, input().split())
    s.append([bh, bw])
    r[bh] += 1
    c[bw] += 1
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = sum(x in nr and y in nc for x, y in s)
print(R + C - (len(nr) * len(nc) == count))
i = N
while True:
    if i % 2 == 0 and i % N ==0:
        print(i)
        break
    i+=i

### FIXED CODE ###

N = int(input())
i = N
while True:
    if i % 2 == 0 and i % N ==0:
        print(i)
        break
    i+=i
import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**6)+1):
    di[i] = 0
for i in range(1, 2*(10**6)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    if mod_m <= 0:
        continue
    di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        s_m += di_m[i]
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)


### FIXED CODE ###

import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**6)+1):
    di[i] = 0
for i in range(1, 2*(10**6)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    if mod_m >= 1:
        di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        if mod_m >= 1:
            s_m += di_m[i]
    else:
        continue
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1' and (mod_m == 0 or mod_m == -1):
        print(0)
    elif x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    li_s = max(a[:i])
    li_g = max(a[i+1:])
    print(max(li_s,li_g))

### FIXED CODE ###

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[1])
N=0

N = int(input())
K = int(input())
p = [int(input()) for i in range(N)]

p.sort()
print(sum(p[0:K]))


### FIXED CODE ###


S = input()
if(S.isupper()):
    print('A')
else:
    print('a')
import sys
input = sys.stdin.readline


def main():
    N,A,B = (int(x) for x in input().split())


    def calc(n, a, b, ans):
        if abs(a-b)%2 == 0:
            return ans + (abs(a-b)//2)
        else:
            if min(a,b) - (n - max(a,b)) <= 0:
                a -= 1 if not a==1 else 0
                b -= 1 if not b==1 else 0
            else:
                a += 1 if not a==n else 0
                b += 1 if not b==n else 0
            ans += 1
            return calc(n,a,b,ans)



    # お互いに近づくのが最高のパターン
    if abs(A-B)%2 == 0:
        print(abs(a-b)//2)
        quit()
    
    # どちらかの端に寄ってから考えるパターン
    # 寄るための試合数
    left = min(A,B) -1
    right = N - max(A,B) - 1
    
    # 左によるパターン
    if left - right <= 0:
        print(calc(N, 1, B-left, left))
    else:
        print(calc(N, A+right, N, right))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def calc(n, a, b, ans, move):
    if (b-a)%2 == 0:
        return ans + (b-a)//2
    else:
        if move == 1:
            a += move
        else:
            b += move
        return calc(n, a, b, ans+1, move)
            
        

def main():
    N,A,B = (int(x) for x in input().split())

    if (B-A)%2 == 0:
        print((B-A)//2)
    else:
        left = A - 1
        right = N - B
        
        if left <= right:
            print(calc(N, 1, B-left, left, -1))
        else:
            print(calc(N, A+right, N, right, 1))        



if __name__ == '__main__':
    main()
n = int(input())
li = list(map(int, input().split()))

for i in range(1,1+n):
    li.sort()
    a =  li[i]
    li.pop(i)
    b = li[int((n+1)/2)]
    print(b)
    li.append(a)

### FIXED CODE ###

x,y,z=map(int,input().split())
if x <= z <= x+y :
  print("YES")
else:
  print("NO")
# Author:      kira924age
while True:
    m, f, r = map(raw_input().split())
    if m == f == r == -1:
        break;
    if m+f < 30 or m == -1 or f == -1:
        print 'F'
    elif 80 <= m+f:
        print 'A'
    elif 65 <= m+f < 80:
        print 'B'
    elif 50 <= m+f < 65 or (30 <= m+f < 50 and 50 <= r):
        print 'C'
    else:
        print 'D'

### FIXED CODE ###

while True:
	m,f,r = map(int,raw_input().split())
	if m==f==r==-1:
		break
	if m == -1 or f == -1 or m+f < 30:
		print 'F'
	elif m+f >= 80:
		print 'A'
	elif 80 > m+f >= 65:
		print 'B'
	elif 65 > m+f >= 50:
		print 'C'
	elif 50 > m+f >= 30:
		if r < 50:
			print 'D'
		else:
			print 'C'
N, X = [int(i) for i in input().split()]
m = [0 for i in range(N)]

for i in range(N):
  m(i) = int(input())

X = X - sum(m)
num = X // min(m)
num = num + N

print(num)


### FIXED CODE ###

N, X = [int(i) for i in input().split()]
m = [0 for i in range(N)]

for i in range(N):
  m[i] = int(input())

X = X - sum(m)
num = X // min(m)
num = num + N

print(num)
weather=["Sunny","Cloudy","Rainy"]
s=input()
print(weather[weather.index[s]-2])

### FIXED CODE ###

weather=["Sunny","Cloudy","Rainy"]
S=input()
print(weather[weather.index(S)-2])
s='S'
if s[2]==s[3] and s[4]==s[5]:
  print('Yes")
else:
  print('No')

### FIXED CODE ###

S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')