func_code_string: #include <bits/stdc++.h>   using namespace std;   struct point {     int x, y;   };   point moves[2020];   queue<int> Q;   const int lin[] = {1, -1, 0, 0};   const int col[] = {0, 0, 1, -1};   int A[2020][2020];   int X[3 * 2020], Y[3 * 2020];   int n;   void new_point(int x, int y) {     X[++X[0]] = x;     Y[++Y[0]] = y;   }   void normalizare(int X[]) {     sort(X + 1, X + X[0] + 1);     int c = 1;     for (int i = 2; i <= X[0]; i++) {       if (X[c] != X[i]) {         X[++c] = X[i];       }     }     X[0] = c;   }   void precomp() {     normalizare(X);     normalizare(Y);   }   void find(int x, int X[], int &poz) {     int step = 0;     for (; (1 << step) <= X[0]; step++)       ;     step--;     poz = 0;     for (int i = step; i >= 0; i--) {       if (poz + (1 << i) <= X[0] && X[poz + (1 << i)] < x) {         poz += (1 << i);       }     }     poz++;   }   void vecini(int x, int y) {     for (int t = 0; t < 4; t++) {       int xx = x + lin[t], yy = y + col[t];       if (xx >= 0 && xx <= X[0] && yy >= 0 && yy <= Y[0] && A[xx][yy] == 0) {         A[xx][yy] = 2;         Q.push(xx + (yy << 13));       }     }   }   void bf() {     Q.push(0);     A[0][0] = 2;     while (!Q.empty()) {       int x = Q.front() & ((1 << 13) - 1), y = Q.front() >> 13;       Q.pop();       vecini(x, y);     }   }   void solve() {     precomp();     int x1, y1;     find(moves[0].x, X, x1);     find(moves[0].y, Y, y1);     for (int i = 1; i <= n; i++) {       int x2, y2, chg;       if (moves[i].x == moves[i - 1].x) {         x2 = x1;         chg = 2 * (moves[i].y > moves[i - 1].y) - 1;         find(moves[i].y, Y, y2);         for (int j = y1; j != y2; j += chg) {           A[x1][j] = 1;         }         A[x1][y2] = 1;       } else {         y2 = y1;         chg = 2 * (moves[i].x > moves[i - 1].x) - 1;         find(moves[i].x, X, x2);         for (int j = x1; j != x2; j += chg) {           A[j][y1] = 1;         }         A[x2][y1] = 1;       }       x1 = x2;       y1 = y2;     }     bf();     long long sol = 0;     for (int i = 1; i < X[0]; i++) {       for (int j = 1; j < Y[0]; j++) {         if (A[i][j] <= 1) {           sol += (long long)(X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);         }       }     }     cout << sol;   }   int main() {     scanf( %d n , &n);     int x = 0, y = 0;     X[++X[0]] = x;     Y[++Y[0]] = y;     new_point(1, 1);     for (int i = 1; i <= n; i++) {       char c;       int val;       scanf( %c %d n , &c, &val);       if (c ==  R ) {         x += val;       } else if (c ==  L ) {         x -= val;       } else if (c ==  D ) {         y += val;       } else {         y -= val;       }       moves[i].x = x;       moves[i].y = y;       new_point(x, y);       new_point(x + 1, y + 1);     }     solve();     return 0;   }   