Language: C++

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