Harryxun/stf_run huggingface dataset:
from itertools import combinations
import numpy as np

n = int(input())
l = set(map(int, input().split()))

hoge = np.sort(l)
ans = 0

for v in combinations(hoge, 3):
    if v[2] < v[0] + v[1]:
        ans += 1

print(ans)


### FIXED CODE ###

import bisect

N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()

# O(N^2 * logN)の全探索で解く
ans = 0
for a_i in range(N):
    for b_i in range(a_i+1, N):
        c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
        if c_i > b_i:
            ans += c_i - b_i - 1
        else:
            pass

print(ans)

# from itertools import combinations
# import numpy as np
#
# n = int(input())
# hoge = list(map(int, input().split()))
# hoge.sort()
#
# # hoge = np.sort(l)
# ll = []
# ans = 0
#
# def triangle(target, v1, v2):
#     return target < v1 + v2
#
# for i in range(len(hoge)):
#     for j in range(i + 1, len(hoge)):
#         left = hoge[j]
#         right = hoge[-1] + 1
#         while left + 1 < right:
#             mid = (left + right) / 2
#             if triangle(mid, hoge[i], hoge[j]):
#                 ans += len(hoge[hoge >= mid])
#                 break
#             else:
#                 left = mid
#
# print(ans)

"""3回目
# 事前の各要素xより大きい要素個数を求める
for v in hoge:
    ll.append([v, len(hoge[v <= hoge])])

# 事前にコンビネーションを確保する。ループはしない！
combi = np.array([[sum(v), v[1]] for v in combinations(hoge, 2)])

print(combi)
print(combi[:, 0])
print(ll)

# 要素のループをもう一度回し、各
for v, cnt in ll:
    print(v, cnt, len(combi[(v < combi[:, 0]) & (combi[] < v)]), sep=',')
    ans += cnt * len(combi[v < combi])

print(ans)

"""


"""2回目 comnbinationループがだめ
for v in combinations(hoge, 2):
    s = sum(v)
    ans += len(hoge[(v[1] < hoge) & (hoge < s)])

"""



"""1
これだとTLEが出る
combinationの全パターンを数え上げると遅すぎる
ソート済み配列 × なにかで組み合わせを数え上げる必要

from itertools import combinations

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

ans = 0

for v in combinations(l, 3): # combination を使ってループした時点ででn^2
    if v[0] < v[1] + v[2] and v[1] < v[0] + v[2] and v[2] < v[0] + v[1]:
        ans += 1

print(ans)
"""
n = int(input())
s = input()
k = int(input())
t = n[k-1]
for i in s:
    if i!=t:
        s.replace(i,"*")
print(s)

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
t = s[k-1]
for i in s:
    if i!=t:
        s = s.replace(i,"*")
print(s)
N, K = int(input().split())
if N % K == 0:
  print("0")
else :
  print("1")


### FIXED CODE ###

N, K = map(int, input().split())
if N % K == 0:
  print(0)
else :
  l = [(N + i) // K for i in range(K)]
  print(max(l) - min(l))
s=input()
k=int(input())
t=set(s)
t.append(s)
n=len(s)-1
for i in range(n):
  t.append(s[i:i+2])
  if i == n:
    break
  t.append(s[i:i+3])
  if i == n-1:
    continue
  t.append(s[i:i+4])
t.sort()
print(t[k])


### FIXED CODE ###

s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()
While True:
  a, op, b = raw_input().split()
  a = int(a)
  b = int(b)
  if op == '+':
    print a+b
  elif op == '-':
    print a-b
  elif op == '*':
    print a*b
  elif op == '/':
    print a/b
  else:
    break

### FIXED CODE ###

while True:
  s = raw_input().split()
  a = int(s[0])
  op = s[1]
  b = int(s[2])
  if op == '?':
    break
  elif op == '+':
    print (a+b)
  elif op == '-':
    print (a-b)
  elif op == '*':
    print (a*b)
  elif op == '/':
    print (a/b)
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))
B = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))

A.sort()
C.sort()

def bin_search_withR(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] >= targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

def bin_search_withL(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] > targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

total = 0
for b in B:
    a_ub, a_lb = bin_search_r(A, b)
    c_ub, c_lb = bin_search_l(C, b)
    total += a_ub * (N - c_ub)

print(total)


### FIXED CODE ###


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

A.sort()
C.sort()

def bin_search_withR(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] >= targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

def bin_search_withL(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] > targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

total = 0
for b in B:
    a_ub, a_lb = bin_search_withR(A, b)
    c_ub, c_lb = bin_search_withL(C, b)
    total += a_ub * (N - c_ub)

print(total)
A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import math
lcm = int(C * D / math.gcd(C, D))
cnt_2 = int(B/C) - int((A-1)/C)
cnt_3 = int(B/D) - int((A-1)/D)
cnt_4 = int(B/lcm) - int((A-1)/lcm)
print(max_cnt - cnt_2 - cnt_3 + cnt_4)

### FIXED CODE ###

A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import fractions
lcm = int(C * D / fractions.gcd(C, D))
cnt_2 = B//C - (A-1)//C
cnt_3 = B//D - (A-1)//D
cnt_4 = B//lcm - (A-1)//lcm
print(max_cnt - cnt_2 - cnt_3 + cnt_4)
def main():
    X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    return X[K]
print(main())

### FIXED CODE ###

def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()
def solve(m, prefers):
    if m == 1:
        return len(prefers)

    items = [True] * (m + 1)
    competes = {i: 0 for i in range(1, m + 1)}
    persons = [set() for _ in range(m + 1)]

    for i, prefer in enumerate(prefers):
        item = prefer[-1]
        competes[item] += 1
        persons[item].add(i)

    ans = m
    remain = m
    while ans > m // remain:
        mx = max(competes.values())
        ans = min(ans, mx)
        del_items = [a for a, k in competes.items() if k == mx]
        for a in del_items:
            items[a] = False
            del competes[a]
        if not competes:
            return ans
        for a in del_items:
            ps_a = persons[a]
            for p in ps_a:
                prefer = prefers[p]
                while not items[prefer[-1]]:
                    prefer.pop()
                item = prefer[-1]
                persons[item].add(p)
                competes[item] += 1
        remain -= 1

    return ans


n, m = map(int, input().split())
prefers = [list(reversed(list(map(int, input().split())))) for _ in range(n)]

print(solve(m, prefers))
def solve(m, prefers):
    if m == 1:
        return len(prefers)

    items = [True] * (m + 1)
    competes = {i: 0 for i in range(1, m + 1)}
    persons = [set() for _ in range(m + 1)]

    for i, prefer in enumerate(prefers):
        item = prefer[-1]
        competes[item] += 1
        persons[item].add(i)

    ans = m
    remain = m
    while ans > m // remain:
        mx = max(competes.values())
        ans = min(ans, mx)
        del_items = [a for a, k in competes.items() if k == mx]
        for a in del_items:
            items[a] = False
            del competes[a]
        if not competes:
            return ans
        for a in del_items:
            ps_a = persons[a]
            for p in ps_a:
                prefer = prefers[p]
                while not items[prefer[-1]]:
                    prefer.pop()
                item = prefer[-1]
                persons[item].add(p)
                competes[item] += 1
        remain -= 1

    return ans


n, m = map(int, input().split())
prefers = [list(reversed(list(map(int, input().split())))) for _ in range(n)]

print(solve(m, prefers))


### FIXED CODE ###

from collections import defaultdict
from operator import itemgetter


def sub(prefers, canceled):
    res = defaultdict(int)
    for pref in prefers:
        p = pref[-1]
        while p in canceled:
            pref.pop()
            p = pref[-1]
        res[p] += 1

    return max(res.items(), key=itemgetter(1))


def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in range(m):
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans


n, m = map(int, input().split())
prefers = [list(reversed(list(map(int, input().split())))) for _ in range(n)]

print(solve(m, prefers))
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    l=list(range(a,b+1))
    seki=1
    for i in l:
        seki*=i
    if seki>0:
        print('Positive')
    elif seki==0:
        print('Zero')
    else:
        print('Negative')
resolve()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    if a>0:
        print('Positive')
    elif a==0 or b==0:
        print('Zero')
    elif a<0 and b>0:
        print('Zero')
    elif b<0 and (b-a)%2==0:
        print('Negative')
    else:
        print('Positive')
resolve()
import numpy as np
def f(n):
        m = np.matrix('1 1 ; 1 0') ** n
        return m.item(0)
print(f(int(input())))

### FIXED CODE ###

def g(a,b,n):
    if n==1:return a
    else:return g(a+b,a,n-1)
print(g(1,1,int(input())))
a, b = map( int, input().split())
  print(['Even','Odd'][a * b % 2])

### FIXED CODE ###

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

d = a * b

if( d % 2 == 0):
  print('Even')
  
else:
  print('Odd')
M, N = map(int, input().split())
A = list(map(int, input().split()))

j = 0
sum = []

for i in range(N+1):
    if i == A[j]:
        sum.append(0)
        if j < M-1:
            j += 1
    elif i == 0 or i == 1:
        sum.append(1)
    else:
        sum.append(sum[i-2] + sum[i-1])


print(sum[N]%1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

j = 0
sum = []

for i in range(N+1):
    if j < M and i == A[j]:
        sum.append(0)
        if j < M-1:
            j += 1
    elif i == 0 or i == 1:
        sum.append(1)
    else:
        sum.append(sum[i-2] + sum[i-1])


print(sum[N]%1000000007)
S = input()

N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    bit = ('{:0' + str(N - 1) + 'b}').format(i)
    formula = S[0]
    for j in range(len(bit)):
        if bit[j] == '1':
            formula += '+'
        formula += S[j + 1]
    ans += eval(formula)
print(ans)


### FIXED CODE ###

S = input()

N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    bit = '{:010b}'.format(i)[11 - N:]
    formula = S[0]
    for j in range(len(bit)):
        if bit[j] == '1':
            formula += '+'
        formula += S[j + 1]
    ans += eval(formula)
print(ans)
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x = int(input())
    p1 = 1
    while True:
        p15 = p1 ** 5
        rt1 = ((x + p15) ** 0.2) % 1
        rt2 = ((x - p15) ** 0.2) % 1
        if rt1 == 0:
            r = (int((x + p15) ** 0.2), p15)
            break
        elif rt2 == 0:
            r = (int((x - p15) ** 0.2), -p15)
            break
        else:
            p1 += 1
    print(*r, sep=' ')
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from math import pow
def main():
    x = int(input())
    for a in range(-1000,1001):
        for b in range(-1000,1001):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                sys.exit()

if __name__ == '__main__':
    main()
def dpWcount(a,b,dpW,k):
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       return k
def dpHcount(a,b,dpH,k):
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       return k

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)
ansC = int(0)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

### FIXED CODE ###

def examC():
    N, M = LI()
    A = [I() for _ in range(M)]
    A.append(N+1)
    fib = [1]*(N+2)
    for i in range(1,N):
        fib[i+2] = fib[i+1] + fib[i]
    fib[0] = 0
#    print(fib)
    ans = fib[A[0]]%mod
    for i in range(M):
        ans *= fib[A[i+1]-A[i]-1]
        ans %=mod
    print(ans)
    return

def examD():
    H, W = LI()
    S = [SI() for _ in range(H)]
    width = [[0]*W for _ in range(H)]
    height = [[0]*W for _ in range(H)]
    for i in range(H):
        cur = 0; keep = []
        for j in range(W):
            if S[i][j]==".":
                cur +=1
                keep.append(j)
            else:
                for k in keep:
                    width[i][k] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                width[i][k] = cur
    for j in range(W):
        cur = 0; keep = []
        for i in range(H):
            if S[i][j]==".":
                cur +=1
                keep.append(i)
            else:
                for k in keep:
                    height[k][j] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                height[k][j] = cur
    ans = 0
    for i in range(H):
        for j in range(W):
            cur = width[i][j] + height[i][j]
            if ans<cur:
                ans = cur
    print(ans-1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()
def gyaku(x):
    y = []
    for i in range(len(x)):
        y.append(x.pop())
    return y

n = input()
a = map(int, raw_input().split())
b = []
for i in range(n):
    b.append(a[i])
    b = gyaku(b)
print(' '.join(map(str, b)))

### FIXED CODE ###

p = map(int, raw_input().split())
print sum(p)-max(p)
n = input()
if '7' in j:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
if '7' in n:
  print("Yes")
else:
  print("No")
import math
N, M = list(map(int, input().split()))
print(math.factorial(N) // (2*math.factorial(N-2)) + math.factorial(M) // (2*math.factorial(M-2)))

### FIXED CODE ###

import math
N, M = list(map(int, input().split()))
n_pairs = math.factorial(N) // (2*math.factorial(N-2)) if N > 1 else 0
m_pairs = math.factorial(M) // (2*math.factorial(M-2)) if M > 1 else 0
print(n_pairs + m_pairs)
m = int(input())
a = {}
for i in range(2, int(m**0.5)+1):
    if m % i == 0:
        n = m // i
        a[i] = n
b = min(a.values())
if b < 10: print("Yes")
else: print("No")
  

### FIXED CODE ###

m = int(input())
a = {}
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        n = m // i
        a[i] = n
b = min(a.values())
if b < 10: print("Yes")
else: print("No")
from math import factorial
print(factorial(int(input()))

### FIXED CODE ###

from math import factorial
print(factorial(int(input())))
N = int(input())
A = [int(input()) for i in range(N)]

A_count = [0] * max(A)
for i in A:
    A_count[i-1] += 1

ans = 0
for count in A_count:
    if count % 2 == 1:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
sorted_A = sorted(A)

pre = sorted_A[0]
ans = 0
if len(sorted_A) == 1:
    print(1)
else:
    count = 1
    for i in range(1, len(sorted_A)):
        if sorted_A[i] == pre:
            count += 1
            if i == len(sorted_A)-1:
                if count % 2 == 1:
                    ans += 1
        else:
            if i == len(sorted_A)-1:
                ans += 1
            if count % 2 == 1:
                ans += 1
            pre = sorted_A[i]
            count = 1
    print(ans)
n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = [0 for _ in range(10**6+5)]
ans = 0
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
    exit()
for x in a:
    for i in range(x, 10**6+5, x):
        cnt[i] += 1
for x in a:
    if cnt[x] == 1:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = [0 for _ in range(10**6+5)]
ans = 0
if n == 1:
    print(1)
    exit()
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
    exit()
for x in a:
    for i in range(x, 10**6+5, x):
        cnt[i] += 1
for x in a:
    if cnt[x] == 1:
        ans += 1
print(ans)
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(K):
    if i < pl and K-2-i < pn :
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(K):
    if i < pn and K-2-i < pl and K-2-i >= 0:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

### FIXED CODE ###

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

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)
import os
import sys
input = sys.stdin.buffer.readline
S = input().rstrip().decode()
ans = 0
for s in S:
    i = int(s)
    ans += min(i, 10-i)

s0, s1 = int(S[0]), int(S[1])
if s1 >= 6:
    ans += 1
elif s1 <=4 and s0 >= 5:
    ans += 1
print(ans)


### FIXED CODE ###

S = input()
dp = [0, 1]
for s in S:
    i = int(s)
    a = min(dp[0] + i,   dp[1] + 10 - i)
    b = min(dp[0] + i+1, dp[1] + 10 - (i+1))
    dp = [a, b]
    # print(dp)
print(dp[0])
N = int(input())

if N[0] == N[1] and N[1] == N[2] :
    print('Yes')

elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')

else:
    print('No')

### FIXED CODE ###


N = str(input())

if N[0] == N[1] and N[1] == N[2] :
    print('Yes')

elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')

else:
    print('No')
n=int(input())
S=list(input())

i,cnt1=0,0
ins=[0]*(n+1)
while i<len(S):
  if S[i]=='(':
    cnt1+=1
    i+=1
  else:
    j,cnt2=0,0
    while i<len(S):
      if S[i]=='(':
        break
      else:
        cnt2+=1
      i+=1
      
    tmp=''
    if cnt2>cnt1:
      for _ in range(cnt2-cnt1):
        tmp+='('
      ins[i-(cnt1+cnt2)]=tmp
    elif cnt1>cnt2:
      for _ in range(cnt1-cnt2):
        tmp+=')'
      ins[i]=tmp
    cnt1,cnt2=0,0

if cnt1>0 and cnt2==0:
  tmp=''
  for _ in range(cnt1):
    tmp+=')'
  ins[-1]=tmp
for i,s in enumerate(ins):
  if s!=0:
    if i==0:
      S.insert(i,s)
    else:
      S.insert(i+1,s)
print(*S,sep='')

### FIXED CODE ###

n=int(input())
S=input()

l,cnt1=0,0
for s in S:
  if s=='(':
    cnt1+=1
  else:
    cnt1-=1
    l=min(l,cnt1)
r,cnt2=0,0
for s in S[::-1]:
  if s==')':
    cnt2+=1
  else:
    cnt2-=1
    r=min(r,cnt2)
print('('*-l+ S + ')'*-r)
process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]


if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.push = {
            "name": name,
            "time": int(time),
        }

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > 100:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc >= len(procs)-1:
                current_proc = 0


### FIXED CODE ###

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

raw_proc = [input() for i in range(N)]
queue = [{} for i in range(N+1)]
limit = N+1
for i in range(N):
    name, time = raw_proc[i].split()
    time = int(time)
    queue[i] = {"name": name, "time": time}

def enque(tail, p):
    queue[tail] = p
    tail = (tail+1) % limit
    return tail

def deque(head):
    proc = queue[head]
    head = (head+1) % limit
    return proc, head


if __name__ == '__main__':
    head = 0
    tail = N
    total_time = 0
    while head != tail:
        p, head = deque(head)
        t = min(qms, p["time"])
        p["time"] = p["time"] - t
        total_time += t
        if p["time"] > 0:
            tail = enque(tail, p)
        else:
            print("{} {}".format(p["name"], total_time))
# -*- coding:utf8 -*-
import math

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [math.factorial(s.count(i)) for i in set(s)]
print(sum(c)/2)

### FIXED CODE ###

# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    if a==b:
        print(0)
    elif a==1:
        print(str(b-1))
    elif b==1:
        print(str(a-1))
    elif a==n:
        print(str(b+1))
    elif b==n:
        print(str(a+1))
    else:
        if abs(a-b)%2==0:
            ans=abs(a-b)//2
        else:
            if n-min(a,b)>=max(a,b)-1:
                ans=max(a,b)-1
            else:
                ans=n-min(a,b)
    print(ans)

if __name__=="__main__":
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    ans=0
    if (b-a) % 2 == 0:
        print((b-a) // 2)
    else:
        print((b-a)//2 + min(a-1,n-b) + 1)

if __name__=="__main__":
    main()