func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 4e5 + 5;   const string s[] = { NW ,  NE ,  SE ,  SW };   inline int read() {     int x = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x;   }   struct Node {     int x, y, k;     inline bool operator==(const Node B) const {       return this->x == B.x && this->y == B.y && this->k == B.k;     }     inline bool operator!=(const Node B) const { return !(*this == B); }   };   int n, m, k;   long long ans;   set<int> s1[MAXN], s2[MAXN];   map<pair<int, int>, int> mp;   inline void add(int x, int y) {     s1[(1 == 1 ? x - y + m + 1 : x + y)].insert(x);     s2[(2 == 1 ? x - y + m + 1 : x + y)].insert(x);     mp[make_pair(x, y)] = 1;   }   inline void prepare() {     for (int i = 0; i <= n + 1; i++) add(i, 0), add(i, m + 1);     for (int i = 0; i <= m + 1; i++) add(0, i), add(n + 1, i);   }   inline Node change(Node x, int opt = 1) {     Node now = x;     int cur = 0;     if (x.k == 1) {       cur = *(--s1[(1 == 1 ? x.x - x.y + m + 1 : x.x + x.y)].lower_bound(x.x));       now.x -= (abs(cur - x.x) - 1), now.y -= (abs(cur - x.x) - 1);       if ((mp.find(make_pair(now.x - 1, now.y)) != mp.end()) &&           (mp.find(make_pair(now.x, now.y - 1)) != mp.end()))         now.k = 3;       else if ((mp.find(make_pair(now.x - 1, now.y)) != mp.end()))         now.y--, now.k = 4;       else if ((mp.find(make_pair(now.x, now.y - 1)) != mp.end()))         now.x--, now.k = 2;       else         now.k = 3;     }     if (x.k == 2) {       cur = *(--s2[(2 == 1 ? x.x - x.y + m + 1 : x.x + x.y)].lower_bound(x.x));       now.x -= (abs(cur - x.x) - 1), now.y += (abs(cur - x.x) - 1);       if ((mp.find(make_pair(now.x - 1, now.y)) != mp.end()) &&           (mp.find(make_pair(now.x, now.y + 1)) != mp.end()))         now.k = 4;       else if ((mp.find(make_pair(now.x - 1, now.y)) != mp.end()))         now.y++, now.k = 3;       else if ((mp.find(make_pair(now.x, now.y + 1)) != mp.end()))         now.x--, now.k = 1;       else         now.k = 4;     }     if (x.k == 3) {       cur = *(s1[(1 == 1 ? x.x - x.y + m + 1 : x.x + x.y)].lower_bound(x.x));       now.x += (abs(cur - x.x) - 1), now.y += (abs(cur - x.x) - 1);       if ((mp.find(make_pair(now.x + 1, now.y)) != mp.end()) &&           (mp.find(make_pair(now.x, now.y + 1)) != mp.end()))         now.k = 1;       else if ((mp.find(make_pair(now.x + 1, now.y)) != mp.end()))         now.y++, now.k = 2;       else if ((mp.find(make_pair(now.x, now.y + 1)) != mp.end()))         now.x++, now.k = 4;       else         now.k = 1;     }     if (x.k == 4) {       cur = *(s2[(2 == 1 ? x.x - x.y + m + 1 : x.x + x.y)].lower_bound(x.x));       now.x += (abs(cur - x.x) - 1), now.y -= (abs(cur - x.x) - 1);       if ((mp.find(make_pair(now.x + 1, now.y)) != mp.end()) &&           (mp.find(make_pair(now.x, now.y - 1)) != mp.end()))         now.k = 2;       else if ((mp.find(make_pair(now.x + 1, now.y)) != mp.end()))         now.y--, now.k = 1;       else if ((mp.find(make_pair(now.x, now.y - 1)) != mp.end()))         now.x++, now.k = 3;       else         now.k = 2;     }     opt && (ans += abs(cur - x.x));     return now;   }   inline bool check_it(Node x) {     Node tmp = x;     Node y = change(x);     x = y;     if (((tmp.k + 1) % 4 == y.k - 1)) return false;     while (tmp != x) {       y = change(y);       if (((x.k + 1) % 4 == y.k - 1)) return false;       x = y;     }     return 1;   }   int main() {     n = read(), m = read();     k = read(), prepare();     for (int i = 1; i <= k; i++) {       int x = read();       int y = read();       add(x, y);     }     int sx = read(), sy = read(), sd = -1;     string str;     cin >> str;     for (int i = 0; i < 4; i++)       if (str == s[i]) sd = i + 1;     assert(~sd);     Node st = Node{sx, sy, sd};     st = change(st, 0);     if (!check_it(st)) {       ans--;       st.k = (st.k + 1) % 4 + 1;       check_it(st);     }     printf( %lld n , ans);     return 0;   }   