Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define push_back pb
typedef pair<int,int> iP;
using namespace std;

int main(){
  int w,h,n;
  ll cnt = 0;
  cin >> w >> h >> n;
  vector<iP> v;
  for(int i=0;i<n;i++){
    int x,y; cin >> x >> y; v.pb(iP(--x,--y));
  }
  for(int i=0;i<n-1;i++){
    int x = v[i].fr,y = v[i].sc;
    int gx = v[i+1].fr,gy = v[i+1].sc;
    if(x > gx && y > gy) cnt += max(abs(x - gx),abs(gy-y));
    else if(x < gx && y < gy) cnt += max(abs(gx - x),abs(gy-y));
    else if(gx != x && gy != y) cnt += abs(gx - x) + abs(gy - y);
    else if(gx == x && gy != y) cnt += abs(y - gy);
    else if(gx != x && gy == y) cnt += abs(x - gx);
  }
  cout << cnt << endl;
}
    

Compiler output:
a.cc:7:9: error: 'pair' does not name a type
    7 | typedef pair<int,int> iP;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'll' was not declared in this scope
   12 |   ll cnt = 0;
      |   ^~
a.cc:14:10: error: 'iP' was not declared in this scope
   14 |   vector<iP> v;
      |          ^~
a.cc:14:12: error: template argument 1 is invalid
   14 |   vector<iP> v;
      |            ^
a.cc:14:12: error: template argument 2 is invalid
a.cc:16:31: error: request for member 'pb' in 'v', which is of non-class type 'int'
   16 |     int x,y; cin >> x >> y; v.pb(iP(--x,--y));
      |                               ^~
a.cc:19:14: error: invalid types 'int[int]' for array subscript
   19 |     int x = v[i].fr,y = v[i].sc;
      |              ^
a.cc:20:15: error: invalid types 'int[int]' for array subscript
   20 |     int gx = v[i+1].fr,gy = v[i+1].sc;
      |               ^
a.cc:21:18: error: 'y' was not declared in this scope
   21 |     if(x > gx && y > gy) cnt += max(abs(x - gx),abs(gy-y));
      |                  ^
a.cc:21:22: error: 'gy' was not declared in this scope; did you mean 'gx'?
   21 |     if(x > gx && y > gy) cnt += max(abs(x - gx),abs(gy-y));
      |                      ^~
      |                      gx
a.cc:21:26: error: 'cnt' was not declared in this scope; did you mean 'int'?
   21 |     if(x > gx && y > gy) cnt += max(abs(x - gx),abs(gy-y));
      |                          ^~~
      |                          int
a.cc:22:31: error: 'cnt' was not declared in this scope; did you mean 'int'?
   22 |     else if(x < gx && y < gy) cnt += max(abs(gx - x),abs(gy-y));
      |                               ^~~
      |                               int
a.cc:23:33: error: 'cnt' was not declared in this scope; did you mean 'int'?
   23 |     else if(gx != x && gy != y) cnt += abs(gx - x) + abs(gy - y);
      |                                 ^~~
      |                                 int
a.cc:24:33: error: 'cnt' was not declared in this scope; did you mean 'int'?
   24 |     else if(gx == x && gy != y) cnt += abs(y - gy);
      |                                 ^~~
      |                                 int
a.cc:25:33: error: 'cnt' was not declared in this scope; did you mean 'int'?
   25 |     else if(gx != x && gy == y) cnt += abs(x - gx);
      |                                 ^~~
      |                                 int
a.cc:27:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   27 |   cout << cnt << endl;
      |           ^~~
      |           int