TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
y = N-1
for i in range(P,N):
  a = A[i]
  if x==a:
    ans+=1
  else:
    y=i
    break

if y==N-1:
  print(N)
z = sum(A[P-1:y])
for i in range(y,N):
  a = A[i]
  d = a+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    e = z+c
    f = d*(i-P+1)
    if f>=e:
      ans+=1
      
  z+=a
print(ans)


N,A,B = map(int,input().split())
x = B-A
if x%2==0:
  print(x//2)
  
else:
  x = min(max(A-1,B-1),max(N-A,N-B))
  y = N-B+1+(B-A-1)//2
  z = A+(B-A-1)//2
  print(min(x,y,z))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
strargs = [10, 3, ]

n, a, b = map(lambda x: int(x), strargs)

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

else:
  print(b - 1)

strargs = input()

n, a, b = map(lambda x: int(x), strargs)

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

else:
  print(b - 1)

strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

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

else:
  newA = (a + (n - b + 1))
  print((n - b + 1) + (n - newA)//2)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    if B - A == 1: 
        print(min(N-A, B-1))
    elif A == 1:
        print(1+(B-1-A)//2)
    elif B == N:
        print(1+(B-A-1)//2)
    else:
        print(min((A+(B-A-1)//2, N-B+1+(B-A+1)//2))

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)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# coding: utf-8


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

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

    print(ans)

if __name__ == "__main__":
    main()


# coding: utf-8


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

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

    print(ans)

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):


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


distance =(B - A - 1 )//2
ans = min(A-1,N - B) + 1 + distance

print(ans)


def myAnswer(N:int,A:int,B:int) -> int:
   ans = 0
   BN = N - B
   A1 = A - 1
   while True:
      if((B - A) % 2== 0):
         ans += (B - A)//2
         break
      elif(A == 1):
         ans += 1
         B -= 1
      elif(B == N):
         ans += 1
         A += 1
      else:
         if(BN > A1):
            ans +=A1
            B -= A1
            A = 1
         else:
            ans += BN
            A += BN
            B = N
   return ans

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    ans = (b - a) // 2
ans = min((b - a - 1) // 2 + a, (n - b + 1 + (b - a - 1) // 2))

print(ans)

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

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

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)
 
    
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps


def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))


numbers = raw_input().split(' ')

n = numbers[0]
a = numbers[1]
b = numbers[2]

def even_diff(A, B):
  return (B - A) / 2


def odd_diff(N, A, B):
  a_diff = A - 1
  b_diff = N - B
  
  if a_diff > b_diff:
    return N - A
  else:
    return B - 1

if (a - b) % 2 == 0:
  result = even_diff(a, b)
else:
  result = odd_diff(n, a, b)    
  
print(result)

import numpy as np

def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
5 2 3

import sys
n, a, b = map(int, sys.stdin.readline().split())
c = b - a
if c % 2:
  d = min(a - 1, n - b)
  e = 1
  f = (b - a - 1) // 2
  print(d + e + f)
else:
  print(c // 2)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
#-*-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))
    elif b==1:
        print(str(a))
    else:
        if a > b:
            print(a-b)
        else:
            print(b-a)

if __name__=="__main__":
    main()

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
diff = abs(A - B)

if diff % 2 == 0:
    print(-1)

else:
    gap_1 = (A - 1) + (B - 1)
    gap_n = (N - A) + (N - B)

    if gap_1 <= gap_n:
        n = A-1 if A > B else B-1
        print(n)

    else:
        n = N-A if A < B else N-B
        print(n)


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

if diff % 2 != 0:
    gap_1 = (A - 1) + (B - 1)
    gap_n = (N - A) + (N - B)

    if gap_1 <= gap_n:
        n = A-1 if A > B else B-1
        print(n)

    else:
        n = N-A if A < B else N-B
        print(n)


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

if diff % 2 == 0:
    print(diff // 2)

else:
    n = (diff // 2) + 1 + min(N-B, A-1)
    print(n)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = map(int, input().split())

if a-b & 1:
  mi = min(a - 1, n - b)
  print(mi + 1 + int(b - a - 1 // 2))
else:
  print(int(b - a // 2))

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

dist = b - a
if dist & 1:
  print(min(a - 1, n - b) + 1 + (dist - 1)//2)
else:
    print(dist//2)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = map(int, input().split())
d = b-1
e = n-a
c =  min(d, e)
if (b-a%2)==0:
    print((b-a)//2)
else:
    print(c)

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B=map(int,input().split())

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

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

print(B-A)
if B-A==1:
  if N-B<=A-1:
    if B==N:
      print(1)
    else:
      print(N-B+1)
  elif A==1:
    print(1)
  else:
    print(A)

else:
  i=0
  while B-A>=1:
    B=B-1
    A=A+1
    i=i+1
    if A==B:
      print(i)
      break

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

if (A%2==0 and A%2==0) or (A%2==1 and A%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)/2))

else:
  print(int(N-B+1+(B-A-1)/2))

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print(int((B-A)//2))

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)//2))

else:
  print(int(N-B+1+(B-A-1)//2))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())

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


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

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

    
    ans2 = 0
    ans2 += N - B + 1
    a = A + (N - B + 1)
    b = N
    ans2 += (b - a) // 2

    ans = min(ans1, ans2)
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())


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


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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
t = min(B - 1, t)
t = min(N - A, t)
t = min((B - A - 1) // 2, t)
t = min((N - A + (N - B + 1)) // 2, t)
print(t)


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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
t = min(B - 1, t)
t = min(N - A, t)
t = min((B - A - 1) // 2, t)
t = min((N - A + (N - B + 1)) // 2, t)
print(t)


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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math

n, a, b = [int(i) for i in input().split()]

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


import math

n, a, b = [int(i) for i in input().split()]

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from inspect import currentframe

def main():
    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    dic_A = {k:v for (k, v) in enumerate(A)}
    sorted_dic_A = sorted(dic_A.items(), key=lambda x: x[1], reverse=True)

    B = sorted_dic_A[:P]
    P_min_val = min(B, key=lambda  x: x[1])[1]
    C = sorted_dic_A[P:]

    num_vote = M * V
    a = 0
    b = len(C)
    flag = True
    while a < b:
        def is_margin_plus(i):
            v = C[i][1]
            margin = num_vote
            margin -= M * (P-1)
            margin_list = [v+M-w for (j,w) in C if j!=i]
            mod_margin_list = list(map(lambda x: x if x < M else M, margin_list))
            margin -= M
            margin -= sum(mod_margin_list)
            # print("margin: {}".format(margin))

            return margin > 0

        i = (a + b) // 2
        # input()
        # print("(a, i, b): ({}, {}, {})".format(a, i, b))

        if is_margin_plus(i):
            
            b = i
        else:
            
            a = i + 1
            flag = False

    ans = a + P + 1 if flag else (a + P)
    print(ans)


if __name__ == '__main__':
    main()


def main():
    N, A, B = map(int, input().split())
    result = N
    if (A % 2 == 0 and B % 2 == 0) or  (A % 2 == 1 and B % 2 == 1):
        result = abs(A - B) // 2
    else:
        if A - 1 < N - B:
            result = ((B - 1) - (A - 1 + 1)) // 2 + (A - 1 + 1)
        else:
            result = ((N - A) - (N - B + 1)) // 2 + (N - B + 1)

    print(int(result))

if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
N, A, B = map(int, input().split())
now_A = A
now_B = B
diff = abs(now_A - now_B)
print(now_A, now_B)
if diff == 0:
    print(0)
    exit()
if diff % 2 == 0:
    print(diff//2)
    exit()
else:
    print(min(max(now_A - 1, now_B - 1), max(N - now_A, N - now_B)))
    exit()

N, A, B = map(int, input().split())
diff = B - A
if diff % 2 == 0:
    print(diff//2)
else:
    tmp1 = (B - A + 1) // 2
    tmp1 = B - tmp1
    tmp2 = (2 * N - B + A + 1) // 2 
    tmp2 = tmp2 - A
    print(min(N-A, B-1, tmp1, tmp2))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
    N, A, B = [int(i) for i in input().split()]
    ans = []
    if (B-A)%2 == 0:
        print(int((B-A)/2))
    else:
        print(int((B-A)//2+1+min([A-1,N-B])))

    N, A, B = [int(i) for i in input().split()]
    ans = []
    if (B-A)%2 == 0:
        print(int(int(B-A)/2))
    else:
        print(int((B-A)//2+1+min([A-1,N-B])))

N, A, B = [int(i) for i in input().split()]
ans = []
if (B-A)%2 == 0:
print(int(int(B-A)/2))
else:
print(int((B-A)//2+1+min([A-1,N-B])))

N, A, B = [int(i) for i in input().split()]
ans = []
if (B-A)%2 == 0:
    print(int((B-A)//2))
else:
    print(int((B-A)//2+1+min([A-1,N-B])))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B = map(int,input().split())

C = B-A

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



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

if C == 1:
    kabe = int(min(N-B,A-1))
    print(kabe + 1)
elif C % 2 == 0:
    print(int(C / 2))
else:
    NB = N-B
    A1 = A-1
    if NB < A1:
        NA = N-A
        zan = int((NA-NB-1)/2)
        print(int(NB+1+zan))
    else:
        zan = int(((B-1)-A1-1)/2)
        print(int(A1+1+zan)
    

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

C = B-A

if C % 2 == 0:
    dec = (B-A)//2
    print(int(dec))
else:
    if N-B > A-1:
        dec = (B+A)//2
        print(int(dec))
    else:
        dec = N - (A+B-1)//2
        print(int(dec))
        

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
ma = lambda :map(int,input().split())

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


ma = lambda :map(int,input().split())

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
cnt=0
if (b-a)%2 == 0:
  cnt=b-(b+a)/2
  print(cnt)
  exit()
if (b-a)%2 == 1:
    if a-1 >= n-b:
      cnt=n-a
      print(cnt)
      exit()
    if a-1 <= n-b:
      cnt=b-1
      print(cnt)
      exit()

n,a,b=map(int,input().split()))
cnt=0
if (b-a) != 1:
    while a:
        a+=1
        b-=1
        cnt+=1
        if a == b:
            print(cnt)
            exit()
if (b-a) == 1:
    if a-1 > n-b:
        while a:
            if b != n:
                b+=1
                a+=1
                cnt+=1
            if b == n:
                a+=1
                cnt+=1
            if a == n and b == n:
                print(cnt)
                exit()
    if a-1 < n-b:
        while a:
            if a != 1:
                a-=1
                b-=1
                cnt+=1
            if a == 1:
                b-=1
                cnt+=1
            if a == 1 and b == 1:
                print(cnt)
                exit()

n,a,b=map(int,input().split())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=b-(b+a)//2
  print(cnt)
  exit()
if (b-a)%2 == 1:
  if a==1:
    if b==n:
        c=n-a
    d=1+((b-1)-(((b-1)+a)//2))
    cnt=min(c,d)
    print(cnt)
    exit()
  if b==n:
    if a==1:
        c=b-1
    d=1+(b-(b+a+1)//2)
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1==n-b:
    c=(a-1)+(b-(a-1)-1+1)//2
    d=round(b-1)
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1 > n-b:
    c=n-b+1+(n-(n+(a+1+(n-b)))//2)
    d=n-a
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1 < n-b:
    c=(a-1)+(b-(a-1)-1+1)//2
    d=b-1
    cnt=min(c,d)
    print(cnt)
    exit()

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print(min((B-A)//2),N-A,B-1)
else:
    print(min(N-A,B-1))

from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    ans1 = 0
    a1 = A
    b1 = B
    ans1 += (a1-1)
    b1 -= (a1-1)
    a1 = 1
    
    if b1 % 2 == 0:
        b1 -= 1
        ans1 += 1
    ans1 += ((b1 -1)//2)
    
    ans2 = 0
    a2 = A
    b2 = B
    ans2 += (N-B)
    a2 += (N-B)
    b2 += (N-B)
    if (a2 % 2) != (b2 % 2):
        a2 += 1
        ans2 += 1
    ans2 += ((b2 - a2)//2)
    print(min(ans1,ans2,B-1,N-A))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = map(int, input().split())
diff = b - a
print(b-1 if (b-a)%2 else int(diff/2))
if diff%2 :
    print(b-1)
else :
    print(int(diff/2))


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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())

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

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

Abs = B - A
if Abs % 2 == 0:
  ans = Abs // 2
else:
  a, b = A-1, N-B
  if a < b:
    ans, B = a+1, B-(a+1)
    ans += (B-1) // 2
  else:
    ans, A = b+1, A+(b+1)
    ans += (N-A) // 2
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print((B-A)/2)
elif B-1>=N-A:
  print(N-A)
else:
  print(B-1)

N,A,B=map(int,input().split())
if (B-A)%2==0:
  print((B-A)//2)
elif (B-1)>=(N-A):
  #ans+=N-B+1
  #B=N
  
  print(((B-A-1)//2)+(N-B+1))
else:
  #ans=A-1+1
  #A=1
  #B-=A
  print(((B-A-1)//2)+A)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):

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

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



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

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



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = 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)
    elif a-1 == n-b:
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)/2)

print(int(ans))

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
C=B-A
D=min(A-1,N-B)+1 + (B - A - 1)/2
if C%2==1:
    print (D)
else:
    print(C)



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

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



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B = map(int,input().split()) 
if abs(A-B)%2==0 :
	print((B-A)/2)
else:
	print(min(N-A,B-1))

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted