A few years ago, Aaron left his old school and registered at another due to security reasons. Now he wishes to find Jane, one of his schoolmates and good friends.

There are `n` schools numbered from 1 to `n`. One can travel between each pair of schools by buying a ticket. The ticket between schools `i` and `j` costs `(i + j) modulo (n + 1)` and can be used multiple times. Help Aaron find the minimum total cost to visit all schools. He can start and finish at any school.

Range : 1 ≤ n ≤ 10^(6)

Difficulty: introductory

Starter code:

def find_jane(n):
	

Solutions:
def find_jane(n):
    return (n - 1) // 2

import math
def find_jane(n):
  return math.ceil((n-2)/2)

def find_jane(n):
    return (n-1) // 2
    
"""
1,2,3,...,n
cost = (a+b) % (n+1)

best association is:
    b = n+1-a  ->  cost=0
    
    1 2 3 4 5     -> 1 <-> 5
                     2 <-> 4

to link ("L") those two, the best remaining way is:
    b = n+1-a+1  -> cost=1

    1 2 3 4 5     -> 1 <-> 5: 0
                  L: 5 <-> 2: 1
                     2 <-> 4: 0
                  L: 4 <-> 3: 1
                 --------------
                 total cost = 2


    1 2 3 4       -> 1 <-> 4: 0
                  L: 4 <-> 2: 1
                     2 <-> 3: 0
                 --------------
                 total cost = 1

And so on...
"""

find_jane=lambda n:n-1>>1

def find_jane(n):
  return int(( n - 1 ) / 2)      

def find_jane(n):
    return n//2-1+n%2
    #5,6
    #4,7
    
    #3,8
    #2,9
    #1,10


find_jane=lambda n:~-n>>1

def find_jane(n):
  return (n - 1) >> 1

def find_jane(n):
     return n//2 - 1 if n&1==0 else n//2

def find_jane(n):
    return sum(divmod(n, 2), -1)