Link to this code: https://cses.fi/paste/8147d1bfec6e3377237960/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); 
	int n; 
	cin >> n; 
	
	map <int, int> fre; 
	for (int i = 1; i <= n; i++) {
		int time_arrival, time_leaving; 
		
		cin >> time_arrival >> time_leaving; 
		
		fre[time_arrival]++; 
		
		fre[time_leaving]--; 
	}
	
	int res = 0, people_cnt = 0; 
	for (auto x : fre) {
		people_cnt += x.second; 
		
		res = max(res, people_cnt); 
	}
	
	cout << res << "\n";
}