Problem:


Score : 300 points

Problem Statement

2N players are running a competitive table tennis training on N tables numbered from 1 to N.

The training consists of rounds.
In each round, the players form N pairs, one pair per table.
In each pair, competitors play a match against each other.
As a result, one of them wins and the other one loses.

The winner of the match on table X plays on table X-1 in the next round,
except for the winner of the match on table 1 who stays at table 1.

Similarly, the loser of the match on table X plays on table X+1 in the next round,
except for the loser of the match on table N who stays at table N.

Two friends are playing their first round matches on distinct tables A and B.
Let's assume that the friends are strong enough to win or lose any match at will.
What is the smallest number of rounds after which the friends can get to play a match against each other?

Constraints

2 \leq N \leq 10^{18}

1 \leq A < B \leq N

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the smallest number of rounds after which the friends can get to play a match against each other.

Sample Input 1

5 2 4

Sample Output 1

1

If the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.

Sample Input 2

5 2 3

Sample Output 2

2

If both friends win two matches in a row, they will both move to table 1.



Sample input:
5 2 4


Sample output:
1

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, A, B = rip()
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else :
        l = 0
        l += A - 1
        B -= A - 1
        A -= A - 1
        l += 1
        B -= 1
        l += (B - A) // 2
        
        r = 0
        r += N - B
        A += N - B
        B += N - B
        r += 1
        A += 1
        r += (B - A) // 2
        print(min(l, r))




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, A, B = rip()
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else :
        print(min(B - 1, N - A))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N,A,B = map(int,input().split())
    
    if (B-A)%2 == 0:
        print((B-A)//2)
    else:
        print(min((N-A),B-1))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N,A,B = map(int,input().split())
    ta,tb = -(-A//2),-(-B//2)
    
    if (tb-ta)%2 == 0:
        print((tb-ta)//2)
    else:
        print(min((N-ta),tb-1))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())

nearside = 0
mintable = 0
maxtable = 0
center = abs(a-b) / 2
# restore
if abs(a-b) % 2 == 0:
    print(int(center))
else:
    if a < b:
        mintable = a
        maxtable = b
    else:
        mintable = b
        maxtable = a
    
    if n/2 >= mintable and n/2 <= maxtable:
        print(int(max(n - mintable-1, maxtable-1))) 
    elif n/2 >= maxtable:
        print(maxtable-1)
    else:
        print(n - mintable)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())

nearside = 0
mintable = 0
maxtable = 0
center = abs(a-b) / 2
# restore
if abs(a-b) % 2 == 0:
    print(int(center))
else:
    if a < b:
        mintable = a
        maxtable = b
    else:
        mintable = b
        maxtable = a
    
    if n/2 >= mintable and n/2 <= maxtable:
        print(int(max(mintable - 1, n - maxtable))) 
    elif n/2 >= maxtable:
        print(maxtable-1)
    else:
        print(n - mintable)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())

nearside = 0
mintable = 0
maxtable = 0
# restore
if abs(a-b) % 2 == 0:
    print(int(abs(a-b) / 2))
else:
    if a < b:
        mintable = a
        maxtable = b
    else:
        mintable = b
        maxtable = a
    print(int(max(mintable - 1, n - maxtable)))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1] 
B = cont[2] 
if((B-A)%2==0): 
  print(int(abs(B-A)/2)) 
else: 
  dist1 = A - 1
  dist2 = N - B 
  if(dist1<dist2): 
    y = dist1
    y+=1
    y+=(B-A-1)/2
    print(int(y))
  else: 
    y = dist2
    y+=1
    y+=(B-A-1)/2
    print(int(y))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int ,input().split())

if (b-a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans_2_1 = b-1
	ans_2_2 = n-a

	if b-a == 1:
		ans = min(ans_2_1, ans_2_2)
	else:
		ans_3_1 = (a-1) + (b-a+1-1-1)//2
		ans_3_2 = (n-b) + (n-(a+n-b+1))//2

		ans = min(ans_2_1,ans_2_2,ans_3_1,ans_3_2)

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    # Aが卓1で勝利して調整
    a = A + (B - A - 1) // 2
    # Bが卓Nで敗北して調整
    b = N - B + 1 + (N - B + 1 - A) // 2
    print(min(a, b))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(A + (B - A - 1) // 2)

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1] 
B = cont[2] 
if((B-A)%2==0): 
  print(int(abs(B-A)/2)) 
else: 
  dist1 = A - 1
  dist2 = N - B 
  if(dist1<dist2): 
    x = A - 1 
    y = x 
    x+=1 #parity 
    y = x 
    #B = B - y
    #A = 1 
    y+=(B-A-1)/2 
    print(int(y))
  else: 
    x = N - B 
    y = x 
    x+=1 
    y = x 
    #A = A + y 
    #B = N 
    y+= (B-A-1)/2 
    print(int(y))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    s = abs(B-A)
    if s == 1:
        print(2)
    else:
        from math import ceil
        print(ceil(s/2))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    s = abs(B-A)
    if s%2 == 0:
        print(s//2)
    else:
        print((s+1)//2+1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    s = abs(B-A)
    if s%2 == 0:
        print(s//2)
    else:
        print(s//2+2)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1] 
B = cont[2] 
if(A%2==B%2): 
  print(int(abs(B-A)/2)) 
else: 
  dist1 = A - 1
  dist2 = N - B 
  if(dist1<dist2): 
    x = A - 1 
    y = x 
    x+=1 #parity 
    y = x 
    #B = B - y
    #A = 1 
    y+=(B-A-1)/2 
    print(int(y))
  else: 
    x = N - B 
    y = x 
    x+=1 
    y = x 
    #A = A + y 
    #B = N 
    y+= (B-A-1)/2 
    print(int(y))

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1] 
B = cont[2] 
if(A%2==B%2): 
  print(int(abs(B-A)/2)) 
else: 
  dist1 = A - 1
  dist2 = N - B 
  if(dist1<dist2): 
    x = A - 1 
    y = x 
    x+=1 #parity 
    y = x 
    #B = B - y
    #A = 1 
    y+=(B-A-1)/2 
    print(int(y))
  else: 
    x = N - B 
    y = x 
    x+=1 
    y = x 
    #A = A + y 
    #B = N 
    y+= (B-A)/2 
    print(int(y))

Submission status: Wrong Answer

Solution code:
n,a,b =map(int,input().split())
if((b-a)%2== 0):
  print(int((b-a)/2))
else:
  if(b-1 <= n-a):
    print(int(b-1))
  else:
    print(int(n-a))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
D = B - A
if D % 2 == 0:
    print(D // 2)
else:
    print(min(B - 1, N - A))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
D = B - A
if D % 2 == 0:
    print(D // 2)
else:
    print(D // 2 + 1)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (B-A)%2==1:
   a=min(A-1,N-B)+1
   b=(B-A)-1//2
   print(a+b)

elif (B-A)%2==0:
   print((B-A)//2)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (B-A)%2==1:
   print(min(B-1,N-A))
elif (B-A)%2==0:
   print((B-A)//2)

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1]
B = cont[2]
if(A%2==B%2):
    print(int(abs(B-A)/2))
else:
    dist1 = A - 1
    dist2 = N - B
    if(dist1<dist2):
        x = A - 1
        y = x
        x+=1 #parity
        y = x
        B = B - x
        A = 1
        y+=(B-A)/2
        print(int(y))
    else:
        x = N - B
        y = x
        x+=1
        y = x
        A = A + y
        B = N
        y+= (B-A)/2
        print(int(y))

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1]
B = cont[2]
if(A%2==B%2):
    print(abs(B-A)/2)
else:
    dist1 = A - 1
    dist2 = N - B
    if(dist1<dist2):
        x = A - 1
        y = x
        x+=1 #parity
        y = x
        B = B - x
        A = 1
        y+=(B-A-1)/2
        print(int(y))
    else:
        x = N - B
        y = x
        x+=1
        y = x
        A = A + y
        B = N
        y+= (B-A-1)/2
        print(int(y))

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1]
B = cont[2]
if(A%2==B%2):
    print(abs(B-A)/2)
else:
    dist1 = A - 1
    dist2 = N - B
    if(dist1<dist2):
        x = A - 1
        y = x
        x+=1 #parity
        y = x
        B = B - x
        A = 1
        y+=(B-A)/2
        print(int(y))
    else:
        x = N - B
        y = x
        x+=1
        y = x
        A = A + y
        B = N
        y+= (B-A)/2
        print(int(y))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if abs(a-b)%2 == 0:
  print((a-b)//2)
else:
  print(min((a+b)//2,(2*n-a-b+1)//2))

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1]
B = cont[2]
x = 0
if(A%2==B%2):
    print(int(abs(B-A)/2))
else:
    print(min(A-1,N-B) + 1 + B-A-1/2)

Submission status: Wrong Answer

Solution code:
cont = list(map(int,input().rstrip().split()))
N = cont[0]
A = cont[1]
B = cont[2]
x = 0
if(A%2==B%2):
    print(int(abs(B-A)/2))
else:
    if(A>B):
        x = A
        t = x - 1
    else:
        x = B
        t = x - 1
    if(A<B):
        y = A
        s = N - y
    else:
        y = B
        s = N - y
    if(t>s):
        print(s)
    else:
        print(t)

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print(int((B - A)/2))
    
else:
    print(min(int((A + B - 1)/2), N - int((A + B - 1)/2)))

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print(int((B - A)/2))
    
else:
    print(min(int((A + B - 1)/2), N - int((A + B + 1)/2)))

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
    
else:
    print(min((A + B - 1) // 2, N - (A + B + 1) // 2))

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N, A, B = map(int, input().split())
if (A - B) % 2 == 0:
    print(abs(A - B) // 2)
    
else:
    print(min(max(A - 1, B - 1), max(N - A, N - B)))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n,a,b = map(int,input().split())
if ((a+b)%2==0):
    print ((b-a)//2)
else:
    print (min(max(a-1,b-1),max(n-a,n-b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if (A-B)%2 == 0:
    ans = abs(A-B)//2
else:
    ans = min(max(A-1, B-1), max(N-A, N-B))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,A,B = II()

if (A-B)%2==0:
    print(abs((A-B)//2))
else:
    a = max(A-1,B-1)
    b = max(N-A,N-B)
    print(min(a,b))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if a%2==b%2:
  print((b-a)//2)
else:
  ans=[]
  ans.append(((b-(a))-1)//2+a)
  ans.append((n-(a+(n-b+1)))//2+(n-b))
  print(min(ans))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if a%2==b%2:
  print(b-a//2)
else:
  ans=[]
  ans.append(((b-(a))-1)//2+a)
  ans.append((n-(a+(n-b+1)))//2+(n-b))
  print(min(ans))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  print(min(n-min(a,b),max(a,b)-1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b = list(map(int, input().split()))
if (b - a) % 2 == 0:
    ans = (b-a)/2
else:
    ans = min(a-1, n-b) + 1 + (b-a-1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b = list(map(int, input().split()))
if (b - a) % 2 == 0:
    ans = (b-a)/2
else:
    if (a - 1) <= (n - b):
        ans = a + (b-a-1)/2
    else:
        ans = n-b+1 + (b-a-1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split()))
if (b - a) % 2 == 0:
    ans = (b-a)/2
else:
    if (a - 1) <= (n - b):
        ans = a + (b-a-1)/2
    else:
        ans = n-b+1 + (b-a-1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
print(min(N-A, B-1) if (B-A)%2 else (B-A)//2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

if abs(a-b)%2 == 0:
    print((b-a)//2)
else:
    if b-1 >= n-a:
        if (b-a)//2+1 < n-a:
            print((b-a)//2+1)
        else:
            print(n-a)
    else:
        if (b-a)//2+1 < n-a:
            print((b-a)//2+1)
        else:
            print(b-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

if abs(a-b)%2 == 0:
    print((b-a)//2)
else:
    if b-1 >= n-a:
        print(n-a)
    else:
        print(b-1)

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, A, B = MAP()
if (B-A)%2 == 0:
	print((B-A)//2)
else:
	print(min(B-1, N-A))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
x = b-a
if x%2 == 0 :
    print((b-a)//2)
elif x == 1 :
    if n-a <= b-1 :
        print(n-a)
    else :
        print(b-1)
else :
    if n-a >= b-1 :
        ans = a + (b-a-1)//2
        print(ans)
    else :
        ans = n-b-1 + (a+b+1)//2
        print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
x = b-a
if x%2 == 0 :
    print((b-a)//2)
else :
    if n-a >= b-1 :
        ans = a + (b-a-1)//2
        print(ans)
    else :
        ans = n-b-1 + (a+b+1)//2

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
x = b-a
if x%2 == 0 :
    print((b-a)//2)
else :
    if n-a >= b-1 :
        print(b-1)
    else :
        print(n-a)

Submission status: Wrong Answer

Solution code:
def li():
    return list(map(int, input().split()))


[N, A, B] = li()
if abs(A-B) % 2 == 0:
    print(abs(A-B)//2)
else:
    a_min = abs(A-1)
    a_max = abs(A-N)
    b_min = abs(B-1)
    b_max = abs(B-N)

    if a_min < a_max and a_min < b_min and a_min < b_max:
        print((abs(B-a_min)-1)//2+a_min+1)
    elif a_max < a_min and a_max < b_min and a_max < b_max:
        print((abs(B-a_max)-1)//2+a_max+1)
    elif b_min < a_min and b_min < a_max and b_min < b_max:
        print((abs(A-b_min)-1)//2+b_min+1)
    else:
        print((abs(A-b_max)-1)//2+b_max+1)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

if abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
    exit()

a = min(abs(1 - B), abs(N - A))
if A == 1 or N == B:
    a = min(a, abs(A - B) // 2 + 1)

print(a)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

if abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
    exit()

print(min(abs(1 - B), abs(N - A)))

Submission status: Wrong Answer

Solution code:
# 読み込む 2 < A < B < N
N, A, B = map(int, input().split())

# 最大値と最小値の差を確認
diff_min = B - 1
diff_max = N - A

# 最大値と最小値のどちらか小さい方を採用
print_number = min(diff_min, diff_max)//2
print_number += 2

if (B - A) % 2 == 0:
  print_number = (B - A) / 2

  
print(int(print_number))

Submission status: Wrong Answer

Solution code:
# 読み込む 2 < A < B < N
N, A, B = map(int, input().split())

# 最大値と最小値の差を確認
diff_min = B - 1
diff_max = N - A

# 最大値と最小値のどちらか小さい方を採用
print_number = min(diff_min, diff_max)//2
print_number += 2

if (B - A) % 2 == 0:
  print_number = (B - A) / 2

  
print(print_number)

Submission status: Wrong Answer

Solution code:
# 読み込む
str = input()
param = str.split(" ")
n_max = int(param[0])
player_min = min([int(param[1]),int(param[2])])
player_max = max([int(param[1]),int(param[2])])

# 差が偶数なのかを確認
diff_number = player_max - player_min
even_number_flg = diff_number % 2 == 0

# 最大値と最小値の差を確認
diff_min = player_max - 1
diff_max = n_max - player_min

# 最大値と最小値のどちらか小さい方を採用
print_number = min([diff_min, diff_max])

if even_number_flg:
  print_number = int(diff_number/2)

print(print_number)

Submission status: Wrong Answer

Solution code:
# 読み込む
str = input()
param = str.split(" ")
n_max = int(param[0])
player_min = min([int(param[1]),int(param[2])])
player_max = max([int(param[1]),int(param[2])])

# 差が偶数なのかを確認
diff_number = player_max - player_min
even_number_flg = diff_number % 2 == 0

# 最大値と最小値の差を確認
diff_min = player_max - 1
diff_max = n_max - player_min

# 最大値と最小値のどちらか小さい方を採用
print_number = min([diff_min, diff_max])

if even_number_flg:
  print_number = min([int(diff_number/2), print_number])

print(print_number)

Submission status: Wrong Answer

Solution code:
# 読み込む
str = input()
param = str.split(" ")
n_max = int(param[0])
player_min = int(param[1])
player_max = int(param[2])

# 差が偶数なのかを確認
diff_number = player_max - player_min
even_number_flg = diff_number % 2 == 0

# 最大値と最小値の差を確認
diff_min = player_max - 1
diff_max = n_max - player_min

# 最大値と最小値のどちらか小さい方を採用
print_number = min([diff_min, diff_max])

if even_number_flg:
  print_number = min([int(diff_number/2), print_number])

print(print_number)

Submission status: Wrong Answer

Solution code:
# 読み込む
str = input()
param = str.split(" ")
n_max = int(param[0])
player_min = int(param[1])
player_max = int(param[2])

# 差が偶数なのかを確認
diff_number = player_max - player_min
even_number_flg = diff_number % 2 == 0

# 最大値と最小値の差を確認
diff_min = player_max - 1
diff_max = n_max - player_min

# 最大値と最小値のどちらか小さい方を採用
print_number = min([diff_min, diff_max])

if even_number_flg:
  print_number = min([diff_number/2, print_number])

print(print_number)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a>b:
  a, b = b, a;
r = b-a
if r%2==0:
  print(r//2)
else:
  res = min(a-1, n-b) + r+1
  print(res)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if b>a:
  a, b = b, a;
if a-b==1:
  print('2')
else:
  r = a-b
  if (r&1):
    print(r//2 +1)
  else:
    print(r//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if (A - B)% 2 == 0:
    print((B - A) // 2)
else:
    ans = B - 1
    ans = min(ans, N - A)
    ans = min(ans, N - B + 1 + (-A + B - 1) // 2)
    ans = min(ans, A + (1 + B - A) // 2)
    
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if (A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    print(min(max(A, B) - 1, N - min(A, B)))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

x, y, z = 10**18, 10**18, 10**18

if (abs(a-b)%2==0):
    x = abs(a-b)//2
    y = max(a,b)-1
    z = n-min(a,b)
else:
    y = max(a,b)-1
    z = n-min(a,b)

print(min(x,y,z))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if (abs(a-b)%2==0):
    print(min(abs(a-b) // 2, max(a,b)-1, n-min(a,b)))
else:
    print(min(max(a,b)-1, n-min(a,b)))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if (abs(a-b)%2==0):
    print(abs(a-b) // 2)
else:
    print(min(max(a,b)-1, n-min(a,b)))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(n-a,b-1))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(n-a,b))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(n-a,n-b))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split());
if (B-A) % 2 == 0:
    print((B-A)//2)
else:
    answer = B-1 if B-1 < N-A else N-A
    print(answer)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if (a - b) % 2 == 0:
  print(abs(a - b) // 2)
else:
  print(min(n - a, b - 1))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ans = 0
if a < b:
	a, b = b,a
if abs(a-b) % 2 == 0:
	ans = abs(a-b) // 2
else:
	ans = min(n-min(a,b), max(a,b)-1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  h = n // 2 + 1
  if (a - h) * (b - h) > 0:
    if (a - h) < 0:
      print(max(a, b))
    else:
      print(max(n - a, n - b))
  elif (a - h) * (b - h) < 0:
    if a < n - b:
      print(b - 1)
    else:
      print(n - a)
  else:
      print(n // 2)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  h = n // 2 + 1
  if (a - h) * (b - h) > 0:
    if (a - h) < 0:
      print(max(a, b))
    else:
      print(max(n - a, n - b))
  elif (a - h) * (b - h) < 0:
    if a < n - b:
      print(b - 1)
    else:
      print(n - a)
  else:
      print(n // 2)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())

if ((b-a) % 2 == 0):
  print((b-a)//2)
elif (a-1 <= n-b):
  tmp = a-1
  b -= a-1
  a = 1
  print(tmp+(b-a)//2)
else:
  tmp = n-b
  a = n-b
  b = n
  print(tmp+(b-a)//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(b-1,n-a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    n, a, b = map(int, input().split())
    diff = b - a

    if diff % 2 == 0:
        print(diff // 2)
    else:
        print(min(b - 1, n - a, b // 2 + 1, (n - a) // 2 + 1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

[N, A, B] = [int(i) for i in input().split()]

diff = B - A
A_even = A % 2
B_even = B % 2

if diff % 2 == 1:
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, N-B) + 1 + (B-A-1)/2

    print(int(total))
else:
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int((B-A) / 2))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
if b > a:
  a,b = b,a
if (a-b)%2:
  print(min(a-1,n-b))
else:
  print((a-b)//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, A, B = IL()

if (B - A)%2 == 0:
  print((B - A)//2)
else:
  ans = min(min(A, B) - 1, N - max(A, B))
  print(ans + (B - A)//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, A, B = IL()

if (B - A)%2 == 0:
  print((B - A)//2)
else:
  ans = min(max(A, B) - 1, N - min(A, B))
  print(ans + (B - A)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if not b-a % 2:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, A, B = IL()

if (B - A)%2 == 0:
  print((B - A)//2)
else:
  ans = min(max(A, B) - 1, N - min(A, B))
  if B - A == 1:
    print(ans)
  else:
    print(ans - 1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    s = ((b-(a-1))-1)//2 + (b-(a-1))
    t = (n - (a + (n-b)))//2 + (a+(n-b))
    print(min(s,t))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    print(min(n-a,b-1))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    s = max(n-a,n-b)
    t = max(a-1,b-1)
    print(min(s,t))