output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 B_1
      A_2 B_2
      :
      A_N B_N
attempt: n = int(input())
  ab = []
  ba = []
  for _ in range(n):
      a, b = map(int, input().split())
      ab.append([a, b])
      ba.append([b, a])
  
  ab.sort()
  ba.sort(reverse=True)
  
  ans = 0
  if n % 2 == 1:  # nが奇数
      left = ab[n // 2][0]
      right_end = ba[n // 2][0]
      right = min(ab[n // 2][1], right_end)
      for i in range(n // 2 + 1, n):
          if right >= ab[i][0]:  # 右端が次の左端より大きい
              right = min(max(right, ab[i][1]), right_end)  # 次の領域につなげる
          elif ab[i][0] < right_end:  # 右端が次の左端より小さい＆まだ領域がある
              ans += (right - left) + 1  # 一旦切れる
              left = ab[i][0]
              right = min(ab[i][1], right_end)
          else:  # 終了
              break
      ans += (right - left) + 1 * 0
  else:  # nが偶数
      # まずn//2番目の値の範囲
      ans0 = 0
      left_end = ab[n // 2 - 1][0]
      right_end = ba[n // 2][0]
      left = left_end
      right = min(ab[n // 2][1], right_end)
      for i in range(n // 2 + 1, n):
          if right >= ab[i][0]:  # 右端が次の左端より大きい
              right = min(max(right, ab[i][1]), right_end)  # 次の領域につなげる
          elif ab[i][0] < right_end:  # 右端が次の左端より小さい＆まだ領域がある
              ans0 += (right - left) + 1  # 一旦切れる
              left = ab[i][0]
              right = min(ab[i][1], right_end)
          else:  # 終了
              break
      ans0 += (right - left) + 1
      left_end0 = left_end
      right_end0 = right_end
      # 次に(n//2+1)番目の値の範囲
      ans1 = 0
      left_end = ab[n // 2][0]
      right_end = ba[n // 2 - 1][0]
      left = left_end
      right = min(ab[n // 2][1], right_end)
      for i in range(n // 2 + 1, n):
          if right >= ab[i][0]:  # 右端が次の左端より大きい
              right = min(max(right, ab[i][1]), right_end)  # 次の領域につなげる
          elif ab[i][0] < right_end:  # 右端が次の左端より小さい＆まだ領域がある
              ans1 += (right - left) + 1  # 一旦切れる
              left = ab[i][0]
              right = min(ab[i][1], right_end)
          else:  # 終了
              break
      ans1 += (right - left) + 1
      left_end1 = left_end
      right_end1 = right_end
      # print(left_end0,right_end0,left_end1,right_end1)
      ans = (((right_end1 + right_end0) // 2) - ((left_end1 + left_end0) // 2)) * 2 + 1
  
  print(ans)
  
problem_description: Statement
  
  There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
  B_i. Find the number of different values that the median of X_1, X_2, \cdots,
  X_N can take.
samples: [{"input": "2\n    1 2\n    2 3", "output": "3\n    \n\n  * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n  * if X_1 = 1 and X_2 = 3, the median is 2;\n\n  * if X_1 = 2 and X_2 = 2, the median is 2;\n\n  * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n    100 100\n    10 10000\n    1 1000000000", "output": "9991"}]