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:
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

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

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(b-1 ,N-a))

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:
  tip_1 = max(abs(A-1),abs(B-1))
  tip_N = max(abs(A-N),abs(B-N))
  print(min(tip_1,tip_N))

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-1,B-1) , max(5-A,5-B)))

Submission status: Wrong Answer

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

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 = (int(s) for s in input().split())
k = b-a
if k%2 == 0:
	print(k//2)
else:
	print(a-1+b-a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
d = abs(a - b)
if d % 2 == 0:
  print(d // 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())
c=b-a
if c%2==0:
    print(c//2)
else:
    if max(a,b)-1<n-min(a,b):
        print(max(a,b)-1)
    else:
        print(n-min(a,b))

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())
if (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:
n, a, b = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: int, B: int):
    if (B-A) % 2 == 0:
        print((B-A)//2)
    else:
        print(min(max(A, B)-1, N-min(A, B)))
    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:
# coding: utf-8
N,A,B=map(int,input().split())

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

print(ans)

Submission status: Wrong Answer

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

a, b = min(a,b), max(a,b)

if (b-a) % 2 == 0:
    print(b-a//2)
    exit(0)

d = min(a - 1, n - a)
print(d + 1 + (b-a-1)//2)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a > b: a, b = b, a
if (a - b) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(b - 1, n - a)
print(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(max(N-A, N-B), max(A-1, B-1)))

Submission status: Wrong Answer

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

diff = abs(A - B)

if diff % 2 == 0:
  print(diff//2)
else:
  L = N - max(A, B)
  S = min(A, B)
  print(min(L, S))

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(max(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(max(A-1, B-1), max(N-A, N-B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if (b-a)%2==0:
    print(int( (b-a)/2 ))
else:
    print(b-1)

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(B-1,N-A)

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(b-1, n-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if a%2==b%2:
    print(abs(a-b)//2)
else:
    print(min(max(n-a, n-b), max(a-1,b-1)))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
if abs(A-B) % 2 == 0:
    print(abs(A-B) // 2)
    quit()

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

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))

n,a,b = words(int)
if (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:

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

m = abs(B-A)
if m%2==0:
    ans = m//2
else:
    ans = min(B-1, N-A)
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:
  print( min( B-1 , N-A) )

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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:
    ans1 = max(A,B) - 1
    ans2 = N - min(A,B)
    print(min(ans1,ans2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    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)))

if __name__ == '__main__':
    main()

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(B-1,N-A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if A>B:
  tem=A
  A=B
  B=tem
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())
aa=b-a
if aa%2==0:
    ans=aa/2
else:
    ans=aa//2+2
print(int(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(" "))
cnt = 0
if (B - A) % 2 == 0:
    cnt = (B - A) / 2
else:
    cnt = B // 2 + 1
print(int(cnt))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a < b:
    a, b = b, a
if (a - b) % 2 == 0:
    print((a - b) // 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 abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    A, B = min(A, B), max(A, B)
    L = B - 1
    R = N - A
    print(min(L, R))

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 - min(A, B), max(A, B) - 1))

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:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n, a, b = [int(item) for item in input().split()]
diff = abs(a - b)
ans = diff // 2 + diff % 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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(N-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:
    print(min(b-1,n-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if (A-B) % 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())
if A % 2 == B % 2:
  print((B - A) // 2)
else:
  print(min(B, N - A - 1))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,a,b=map(int,input().split())
if abs(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:
n, a, b = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a)%2 == 0:
  print(int((b - a)/2))
else:
  aa = b-1
  bb = N-a
  print(min(aa,bb))

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)

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 (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:
def main():
    n, a, b = list(map(int, input().split()))
    a, b = min(a, b), max(a, b)
    if (b-a) % 2 == 0:
        print((b-a-1)//2+1)
    else:
        print(min(n-a, b-1))


main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1
n,a,b=map(int,input().split())
if abs(b-a)%2==0:
    print(abs(b-a)//2)
else:
    if a<b: a,b=b,a
    print(max(b,n-a))

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(max(A,B)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = input().split()
n = int(i[0])
a = int(i[1])
b = int(i[2])

if (b-a) % 2 == 0:
  print(int((b-a) / 2))
else:
  print(b-1)

Submission status: Wrong Answer

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


def main():
    N, A, B = [int(x) for x in input().split()]
    ans = (B - A) // 2
    if (B - A) % 2 == 1:
        ans += 2

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        print(min(max(a, b) - 1, n - min(a, b)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

#a = list(map(int, input().split()))


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

if((a-b)%2==0):
    print(abs(a-b)//2)
else:
    print(min(max(n-a,n-b),max(a-1,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(B-1, N-A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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-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:
    print(min(max(a,b),max(n-a,n-b)))
else:
    print(min(max(a,b),max(n-a,n-b),(abs(a-b))//2))

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())

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n,a,b = inpm()
    x = b-a
    if x%2==0:
        print(int(x/2))
        return
    else:
        print(min(b-1,n-a))
        return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = 10**20
if abs(a-b)%2==0:
    ans = abs(a-b)//2
ans = min(min(n-a,n-b),ans)
ans = min(min(a,b),ans)
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-1, B-1), max(N-A, N-B)))

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
    sys.exit()
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)
    exit()
else:
    print (min(B - 1, N - A))

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,a-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,a,b = LI()
    if (b-a)&1 == 0:
        print((b-a)>>1)
    else:
        print(min(b-1,n-a))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split(' ')]

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

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(abs(n-a), abs(a-n), abs(n-b), abs(b-n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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())
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    print(min(max(a, b) - 1, n - min(a, b)))

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    if (A-B)&1:
        ans = min(max(N-A,N-B), max(A-1,B-1))
        print(ans)
    else:
        print(abs(A-B)//2)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if a%2==b%2:
    print(abs(a-b)//2)
else:
    print(max(min(n-a,a), min(n-b,b)))

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        print(min(max(a, b) - 1, n - max(a, b)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n, a, b = (int(i) for i in input().split()) 

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())

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

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:
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:
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  print(min(n-b,a))

Submission status: Time Limit Exceeded

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

        cnt1 = 0
        cnt2 = 0
        for i in range(0, (min(n-a, b-1))):
            if (b-(a-1) - i) % 2 == 0 and cnt1 == 0:
                temp.append(a - 1 + i + (b-(a-1) - i) // 2)
                cnt1 += 1
            elif (n - (a+(n-b)+i)) % 2 == 0 and cnt2 == 0:
                temp.append(n - b + i + (n - (a+(n-b)+i)) // 2)
                cnt2 += 1

        print(min(temp))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


def solve(N: int, A: int, B: int):
    if A > B:
        tmp = A
        A = B
        B = A
    
    count = 0
    while True:
        if (B - A) % 2 == 0:
            count += (B - A) // 2
            break
        else:
            if max(A-1, B-1) < max(N-A, N-B):
                A = max(1, A-1)
                B -= 1
                count += 1
            else:
                A += 1
                B = min(N, B+1)
                count += 1
    print(count)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Time Limit Exceeded

Solution code:
inputString = input()
N = int(inputString.split(" ")[0], 10)
A = int(inputString.split(" ")[1], 10)
B = int(inputString.split(" ")[2], 10)
count = 0


while B != A:
	if (A - B) % 2 == 0:
		A += 1
		B -= 1
	else:
		if A - 1 < N - B:
			if A == 1:
				B -= 1
			else:
				A -= 1
				B -= 1
		else:
			if(B == N):
				A += 1
			else:
				B += 1
				A += 1			
	count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N, a_init, b_init = map(int, input().split())
 
a_candidate = [a_init]
b_candidate = [b_init]
def next_candidate(n):
  win = n-1 if n > 1 else 1
  lose = n + 1 if n < N else N
  return [win, lose]
 
def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]

i = 1
while True:
  a_candidate = set(flatten([next_candidate(a) for a in a_candidate]))
  b_candidate = set(flatten([next_candidate(b) for b in b_candidate]))
  if len(a_candidate & b_candidate) > 0:
    print(i)
    break
  else:
    i += 1

Submission status: Time Limit Exceeded

Solution code:
N, a_init, b_init = map(int, input().split())

a_candidate = [a_init]
b_candidate = [b_init]
def next_candidate(n):
  win = n-1 if n > 1 else 1
  lose = n + 1 if n < N else N
  return [win, lose]

def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]

i = 1
while True:
  a_candidate = flatten([next_candidate(a) for a in a_candidate])
  b_candidate = flatten([next_candidate(b) for b in b_candidate])
  if len(set(a_candidate) & set(b_candidate)) > 0:
    print(i)
    break
  else:
    i += 1

Submission status: Time Limit Exceeded

Solution code:
get_input = input().split(' ')
N = int(get_input[0])
A = int(get_input[1])
B = int(get_input[2])

round = 0
storage = []
value = [A, B]
storage.append(value)

def check(num, N):
    if num > N:
        return num
    if num < 1:
        return 1
    return num

def win_win(A,B,N):
    A = A - 1
    B = B - 1

    A = check(A, N)
    B = check(B, N)

    if A == B:
        return 0
    value = [A, B]
    return value


def win_lose(A, B, N):
    A = A - 1
    B = B + 1

    A = check(A, N)
    B = check(B, N)
    if A == B:
        return 0
    value = [A, B]
    return value


def lose_win(A, B, N):
    A = A + 1
    B = B - 1

    A = check(A, N)
    B = check(B, N)
    if A == B:
        return 0
    value = [A, B]
    return value


def lose_lose(A, B, N):
    A = A + 1
    B = B + 1

    A = check(A, N)
    B = check(B, N)
    if A == B:
        return 0
    value = [A, B]
    return value

out = True
while(out):
    power = 4**round
    round = round + 1
    for i in range(power):
        for j in range(4):
            if j == 0:
                step1 = win_win(storage[i][0], storage[i][1], N)
                if step1 == 0:
                    out = False
                    break
                if len(storage) <= ((i * 4) + 0):
                    storage.append(step1)
                else:
                    storage[((i * 4) + 0)] = step1
            elif j == 1:
                step2 = win_lose(storage[i][0], storage[i][1], N)
                if step2 == 0:
                    out = False
                    break
                if len(storage) <= ((i * 4) + 1):
                    storage.append(step2)
                else:
                    storage[((i * 4) + 1)] = step2
            elif j == 2:
                step3 = lose_win(storage[i][0], storage[i][1], N)
                if step3 == 0:
                    out = False
                    break
                if len(storage) <= ((i * 4) + 2):
                    storage.append(step3)
                else:
                    storage[((i * 4) + 2)] = step3
            else:
                step4 = lose_lose(storage[i][0], storage[i][1], N)
                if step4 == 0:
                    out = False
                    break
                if len(storage) <= ((i * 4) + 3):
                    storage.append(step4)
                else:
                    storage[((i * 4) + 3)] = step4

        if out == False:
            break

print(round)