Language: C++

#include <bits/stdc++.h>
using namespace std;

const int N = 8e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

typedef pair<int,int> pun;
typedef long long ll;

const long double M_PI = 3.141592653589793238462643383279

int MAX[N];

void ustaw(int v, int p, int k, int a, int x) {
	if (k <= a) return;
	if (p > a) return;
	if (p + 1 == k) MAX[v] = max(MAX[v], x);
	else {
		int s = (p + k) / 2;
		ustaw(2*v, p, s, a, x);
		ustaw(2*v+1, s, k, a, x);
		MAX[v] = max(MAX[2 * v], MAX[2 * v + 1]);
	}
}

int czytaj(int v, int p, int k, int a, int b) {
	if (k <= a || p >= b) return 0;
	if (a <= p && k <= b) return MAX[v];
	int s = (p+k)/2;
	return max(czytaj(2*v, p, s, a, b), czytaj(2*v+1, s, k, a, b));
}

map<int, int> skalowanie;

int main() {
	vector<int> ska;
	int x1, y1, x2, y2;
	long long y1old, y2old;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	y1old = y1;
	y2old = y2;
	ska.push_back(y1);
	ska.push_back(y2);
	int n;
	scanf("%d", &n);
	vector<pair<int,int>> pun;
	for (int i = 0; i < n; i ++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ska.push_back(y);
		pun.push_back({x, y});
	}
	sort(ska.begin(), ska.end());
	int id = -1;
	int last = -1;
	for (int x: ska) {
		if (x > last) {
			id ++;
			skalowanie[x] = id;
		}
		last = x;
	}
	int n2 = 1;
	while(n2 <= id) n2 *= 2;
	y1 = skalowanie[y1];
	y2 = skalowanie[y2];
	for (int i = 0; i < pun.size(); i ++) {
		pun[i].second = skalowanie[pun[i].second];
	}
	if (x1 > x2) {
		swap(x1, x2);
		swap(y1, y2);
	}
	sort(pun.begin(), pun.end());
	int ile = 0;
	for (auto p : pun) {
// 		printf("%d\n", p.first);
		if (p.first < x1) continue;
		if (p.first > x2) continue;
		if (p.second > max(y1, y2) || p.second < min(y1, y2)) continue;
		int wynik = 0;
		ile ++;
		if (y1 < y2) {
// 			printf("male %d\n", p.second);
			wynik = czytaj(1, 0, n2, 0, p.second + 1);
		} else {
// 			printf("duze\n");
			wynik = czytaj(1, 0, n2, p.second, n2);
		}
		ustaw(1, 0, n2, p.second, wynik + 1);
	}
	long double cwiartka = M_PI / 2 * 10;
	cout.precision(30);
	if (x1 == x2 || y1 == y2) {
		if (ile > 0) {
			cout << 100 * (long long)(abs(y1old - y2old) + abs(x1 - x2)) + 2 * cwiartka - 20;
		} else {
			cout << 100 * (long long)(abs(y1old - y2old) + abs(x1 - x2));
		}
	}
	else {
		int ile = czytaj(1, 0, n2, min(y1, y2), max(y1, y2));
// 		cout << ile << " ";
		cout << 100 * (long long)(abs(y1old - y2old) + abs(x1 - x2)) - 20 * ile + cwiartka * ile;
	}
}


Compiler output:
In file included from /usr/include/c++/14/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114,
                 from a.cc:1:
a.cc:13:19: error: expected unqualified-id before numeric constant
   13 | const long double M_PI = 3.141592653589793238462643383279
      |                   ^~~~
a.cc: In function 'void ustaw(int, int, int, int, int)':
a.cc:20:25: error: 'MAX' was not declared in this scope
   20 |         if (p + 1 == k) MAX[v] = max(MAX[v], x);
      |                         ^~~
a.cc:25:17: error: 'MAX' was not declared in this scope
   25 |                 MAX[v] = max(MAX[2 * v], MAX[2 * v + 1]);
      |                 ^~~
a.cc: In function 'int czytaj(int, int, int, int, int)':
a.cc:31:38: error: 'MAX' was not declared in this scope
   31 |         if (a <= p && k <= b) return MAX[v];
      |                                      ^~~