func_code_string: #include <bits/stdc++.h>   int n;   char dir[1010];   int len[1010];   int realx[2030], cntx = 0;   int realy[2030], cnty = 0;   void unique(int *real, int &cnt) {     std::sort(real, real + cnt);     int t2 = 1;     for (int t1 = 1; t1 < cnt; t1++)       if (real[t1] ^ real[t1 - 1]) real[t2++] = real[t1];     cnt = t2;   }   int map[2030][2030];   inline bool legal(int x, int y) {     return x >= 0 && x <= cntx && y >= 0 && y <= cnty;   }   void dfs(int x, int y) {     map[x][y] = -1;     if (legal(x + 1, y) && !map[x + 1][y]) dfs(x + 1, y);     if (legal(x - 1, y) && !map[x - 1][y]) dfs(x - 1, y);     if (legal(x, y + 1) && !map[x][y + 1]) dfs(x, y + 1);     if (legal(x, y - 1) && !map[x][y - 1]) dfs(x, y - 1);   }   int main() {     scanf( %d , &n);     int curx = 0, cury = 0;     for (int i = 0; i < n; i++) {       scanf( %s%d , dir + i, len + i);       switch (dir[i]) {         case  L :           realx[cntx++] = curx + 1;           realx[cntx++] = curx -= len[i];           realy[cnty++] = cury;           realy[cnty++] = cury + 1;           break;         case  R :           realx[cntx++] = curx;           realx[cntx++] = (curx += len[i]) + 1;           realy[cnty++] = cury;           realy[cnty++] = cury + 1;           break;         case  U :           realy[cnty++] = cury;           realy[cnty++] = (cury += len[i]) + 1;           realx[cntx++] = curx;           realx[cntx++] = curx + 1;           break;         case  D :           realy[cnty++] = cury + 1;           realy[cnty++] = cury -= len[i];           realx[cntx++] = curx;           realx[cntx++] = curx + 1;           break;       }     }     unique(realx, cntx);     unique(realy, cnty);     int curxid = std::upper_bound(realx, realx + cntx, curx = 0) - realx,         curyid = std::upper_bound(realy, realy + cnty, cury = 0) - realy, nextid;     for (int i = 0; i < n; i++) switch (dir[i]) {         case  L :           nextid = std::upper_bound(realx, realx + cntx, curx -= len[i]) - realx;           for (; curxid > nextid; curxid--) map[curxid][curyid] = 1;           break;         case  R :           nextid = std::upper_bound(realx, realx + cntx, curx += len[i]) - realx;           for (; curxid < nextid; curxid++) map[curxid][curyid] = 1;           break;         case  U :           nextid = std::upper_bound(realy, realy + cnty, cury += len[i]) - realy;           for (; curyid < nextid; curyid++) map[curxid][curyid] = 1;           break;         case  D :           nextid = std::upper_bound(realy, realy + cnty, cury -= len[i]) - realy;           for (; curyid > nextid; curyid--) map[curxid][curyid] = 1;           break;       }     map[curxid][curyid] = 1;     for (int x = 0; x <= cntx; x++) {       if (!map[x][0]) dfs(x, 0);       if (!map[x][cnty]) dfs(x, cnty);     }     for (int y = 1; y < cnty; y++) {       if (!map[0][y]) dfs(0, y);       if (!map[cntx][y]) dfs(cntx, y);     }     long long ans = 0;     for (int x = 1; x <= cntx; x++)       for (int y = 1; y <= cnty; y++)         if (~map[x][y])           ans += (long long)(realx[x] - realx[x - 1]) * (realy[y] - realy[y - 1]);     printf( %lld n , ans);     return 0;   }   