func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /stack:20000000 )   #pragma warning(disable : 4146)   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int inf = 1e9;   const long long lnf = 1e18;   const long long h1 = 239017, h2 = 731604233;   const long long mod = 1000000007, mod2 = 1000000009;   const long double pi = 3.141592653589793238462643383279;   const long double EPS = 1e-9;   struct rectangle {     int x1, x2;     int y1, y2;     rectangle(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}   };   vector<rectangle> v;   int n, x, y, first, second;   int xm[2005], ym[2005];   bool obs[2005][2005], a[2005][2005];   map<int, int> mx, my;   void dfs(int x, int y) {     if (x < 0 || x >= first || y < 0 || y >= second || obs[x][y] || a[x][y])       return;     a[x][y] = true;     dfs(x + 1, y);     dfs(x - 1, y);     dfs(x, y + 1);     dfs(x, y - 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     cout.tie();     cout << setprecision(20);     cin >> n;     for (int i = 0; i < (n); i++) {       char dir;       int d;       cin >> dir >> d;       if (dir ==  L ) {         rectangle r = {x - d, y, x + 1, y + 1};         v.push_back(r);         x -= d;       }       if (dir ==  R ) {         rectangle r = {x, y, x + d + 1, y + 1};         v.push_back(r);         x += d;       }       if (dir ==  U ) {         rectangle r = {x, y, x + 1, y + d + 1};         v.push_back(r);         y += d;       }       if (dir ==  D ) {         rectangle r = {x, y - d, x + 1, y + 1};         v.push_back(r);         y -= d;       }     }     for (int i = 0; i < (n); i++) {       mx[v[i].x1] = mx[v[i].x2] = 0;       my[v[i].y1] = my[v[i].y2] = 0;     }     for (auto &it : mx) {       it.second = first;       xm[first++] = it.first;     }     for (auto &it : my) {       it.second = second;       ym[second++] = it.first;     }     --first, --second;     for (int i = 0; i < (n); i++) {       int x1 = mx[v[i].x1], x2 = mx[v[i].x2], y1 = my[v[i].y1], y2 = my[v[i].y2];       for (int j = x1; j < x2; ++j)         for (int k = y1; k < y2; ++k) obs[j][k] = true;     }     for (int i = 0; i < (first); i++)       for (int j = 0; j < (second); j++)         if (!i || i == first - 1 || !j || j == second - 1) dfs(i, j);     long long ans = 0;     for (int i = 0; i < (first); i++)       for (int j = 0; j < (second); j++)         if (!a[i][j]) {           long long dx = xm[i + 1] - xm[i], dy = ym[j + 1] - ym[j];           ans += dx * dy;         }     cout << ans << endl;     cerr <<  Time used :   << (double)clock() * 1.0 / 1000 <<   seconds. n           << endl;     return 0;   }   