Language: C++

#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, b, range[8] = {};
vector<pair<ll, ll>> ab;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		ab.pub(mp(a, b));
	}
	stable_sort(ab.begin(), ab.end());
	if (n % 2) {
		for (int i = n / 2; i > 0; i--) {
			if (ab[i - 1].second < ab[i].second) {
				range[0] = i;
				break;
			}
			if (i == 1)range[0] = 0;
		}
		for (int i = n / 2; i <= n; i++) {
			if (ab[i].second > ab[i + 1].second) {
				range[1] = i;
				break;
			}
			if (i == n - 1)range[1] = n - 1;
		}
		if ((range[1] - range[0]) % 2) {
			cout << (ab[(range[1] - range[0]) / 2 - 1].second + ab[(range[1] - range[0]) / 2].second) / 2 - ab[(range[1] - range[0]) / 2 - 1].first + ab[(range[1] - range[0]) / 2].first) / 2 << endl;
			return 0;
		}
		else {
			cout << ab[(range[1] - range[0]) / 2].second - ab[(range[1] - range[0]) / 2].first << endl;
			return 0;
		}
	}
	else {
		for (int i = n / 2; i > 0; i--) {
			if (ab[i - 1].second < ab[i].second) {
				range[0] = i;
				break;
			}
			if (i == 1)range[0] = 0;
		}
		for (int i = n / 2 + 1; i <= n; i++) {
			if (ab[i].second > ab[i + 1].second) {
				range[1] = i;
				break;
			}
			if (i == n - 1)range[1] = n - 1;
		}
		if ((range[1] - range[0]) % 2) {
			cout << (ab[(range[1] - range[0]) / 2 - 1].second + ab[(range[1] - range[0]) / 2].second) / 2 - ab[(range[1] - range[0]) / 2 - 1].first + ab[(range[1] - range[0]) / 2].first) / 2 << endl;
			return 0;
		}
		else {
			cout << ab[(range[1] - range[0]) / 2].second - ab[(range[1] - range[0]) / 2].first << endl;
			return 0;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:198: error: expected ';' before ')' token
   55 |                         cout << (ab[(range[1] - range[0]) / 2 - 1].second + ab[(range[1] - range[0]) / 2].second) / 2 - ab[(range[1] - range[0]) / 2 - 1].first + ab[(range[1] - range[0]) / 2].first) / 2 << endl;
      |                                                                                                                                                                                                      ^
      |                                                                                                                                                                                                      ;
a.cc:79:198: error: expected ';' before ')' token
   79 |                         cout << (ab[(range[1] - range[0]) / 2 - 1].second + ab[(range[1] - range[0]) / 2].second) / 2 - ab[(range[1] - range[0]) / 2 - 1].first + ab[(range[1] - range[0]) / 2].first) / 2 << endl;
      |                                                                                                                                                                                                      ^
      |                                                                                                                                                                                                      ;