malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 110000;   int s1, s2;   int n, a[N];   int mi[17][N * 2], ma[17][N * 2];   int BB[N * 2];   int getmi(int l, int r) {     return min(mi[BB[r - l + 1]][l],                mi[BB[r - l + 1]][r - (1 << BB[r - l + 1]) + 1]);   }   int getma(int l, int r) {     return max(ma[BB[r - l + 1]][l],                ma[BB[r - l + 1]][r - (1 << BB[r - l + 1]) + 1]);   }   void init() {     for (int j = (int)0; j <= (int)16; j++)       for (int i = (int)(1 << j); i <= (int)(1 << (j + 1)) - 1; i++) BB[i] = j;     for (int i = (int)1; i <= (int)n; i++) {       mi[0][i] = ma[0][i] = a[i];     }     for (int j = (int)1; j <= (int)16; j++)       for (int i = (int)1; i <= (int)n - (1 << j) + 1; i++) {         mi[j][i] = min(mi[j - 1][i], mi[j - 1][i + (1 << (j - 1))]);         ma[j][i] = max(ma[j - 1][i], ma[j - 1][i + (1 << (j - 1))]);       }   }   bool f[N], g[N];   bool check(int S) {     for (int i = (int)0; i <= (int)n; i++) f[i] = g[i] = 0;     f[0] = g[0] = 1;     int maf, mag;     maf = mag = 0;     for (int i = (int)0; i <= (int)n - 1; i++) {       bool f1 = (i <= maf);       bool f2 = (i <= mag);       if (f1) {         int now = a[i];         if (i == 0) now = s1;         int l = i + 1;         int r = n;         int rt = 0;         while (l < r) {           int mid = (l + r) >> 1;           if ((abs(getma(i + 1, mid) - now) > S) ||               (abs(getmi(i + 1, mid) - now) > S))             r = mid;           else             l = mid + 1, rt = mid;         }         if (!(abs((getma(i + 1, l) - now) > S) ||               (abs(getmi(i + 1, l) - now) > S)))           rt = l;         mag = max(mag, rt);       }       if (f2) {         int now = a[i];         if (i == 0) now = s2;         int l = i + 1;         int r = n;         int rt = 0;         while (l < r) {           int mid = (l + r) >> 1;           if ((abs(getma(i + 1, mid) - now) > S) ||               (abs(getmi(i + 1, mid) - now) > S))             r = mid;           else             l = mid + 1, rt = mid;         }         if (!((abs(getma(i + 1, l) - now) > S) ||               (abs(getmi(i + 1, l) - now) > S)))           rt = l;         maf = max(maf, rt);       }     }     return (maf == n) || (mag == n);   }   int main() {     scanf( %d%d%d , &n, &s1, &s2);     for (int i = (int)1; i <= (int)n; i++) scanf( %d , &a[i]);     init();     int L = abs(s1 - s2);     int R = 1000000000;     int ans = 0;     while (L < R) {       int mid = (L + R) >> 1;       if (check(mid))         ans = mid, R = mid;       else         L = mid + 1;     }     if (check(L)) ans = L;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 503;   int m, n, vis[N][N];   vector<int> adj[N * N];   void init() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int id(int x, int y) { return (x - 1) * n + y; }   struct ds {     char c;     int x, y;   };   vector<ds> V;   void print(int u, int cc, int type = -1) {     int x = (u - 1) / n + 1, y = u - (x - 1) * n;     if (adj[u].size() == 0 && !type) {       V.push_back((ds){ R , x, y});       return;     }     V.push_back((ds){ B , x, y});     for (int v : adj[u]) print(v, cc, 0);     if (!type) V.push_back((ds){ D , x, y}), V.push_back((ds){ R , x, y});   }   int cc = 0;   queue<pair<int, int> > Q;   int hang[4] = {0, 0, 1, -1};   int cot[4] = {1, -1, 0, 0};   void build(int orgx, int orgy, int cc) {     vis[orgx][orgy] = cc;     Q.push({orgx, orgy});     while (Q.size()) {       int x = Q.front().first, y = Q.front().second;       Q.pop();       for (int t = 0; t <= (int)3; ++t) {         int nx = x + hang[t], ny = y + cot[t];         if (nx < 1 || nx > m || ny < 1 || ny > n || vis[nx][ny]) continue;         adj[id(x, y)].push_back(id(nx, ny));         vis[nx][ny] = cc;         Q.push({nx, ny});       }     }     print(id(orgx, orgy), cc);   }   void solve() {     cin >> m >> n;     for (int i = 1; i <= (int)m; ++i)       for (int j = 1; j <= (int)n; ++j) {         char c;         cin >> c;         if (c ==  # ) vis[i][j] = -1;       }     for (int i = 1; i <= (int)m; ++i)       for (int j = 1; j <= (int)n; ++j)         if (!vis[i][j]) build(i, j, ++cc);     cout << V.size() <<   n ;     for (ds it : V) cout << it.c <<     << it.x <<     << it.y <<   n ;   }   int main() {     init();     solve();   }
#include <bits/stdc++.h>   using namespace std;   queue<int> q;   const int maxn = 40007;   const int maxm = 800007;   const int inf = 0x7f7f7f7f;   struct E {     int u, v, w, cf;   } e[maxm];   int first[maxn], nt[maxm], ES = 1;   bool acc[maxm];   inline void addE(int u, int v, int w, int cf) {     e[++ES] = (E){u, v, w, cf};     nt[ES] = first[u];     first[u] = ES;     return;   }   inline void add(int u, int v, int w) {     addE(u, v, w, 1);     addE(v, u, w, 0);     return;   }   int tot;   int N, M;   int cur[maxn];   int dep[maxn];   int S, T;   bool BFS() {     memset(dep, 0, sizeof(dep));     dep[S] = 1;     q.push(S);     int u, v;     while (!q.empty()) {       u = q.front();       q.pop();       for (int i = first[u]; i; i = nt[i]) {         v = e[i].v;         if (e[i].cf > 0 && acc[i] && !dep[v]) {           dep[v] = dep[u] + 1;           q.push(v);         }       }     }     return dep[T] != 0;   }   int dfs(int u, int f) {     if (u == T) return f;     int v, d, sum = 0;     for (int &i = cur[u]; i; i = nt[i]) {       v = e[i].v;       if (dep[v] == dep[u] + 1 && e[i].cf > 0 && acc[i]) {         d = dfs(v, min(f, e[i].cf));         if (d > 0) {           sum += d;           f -= d;           e[i].cf -= d;           e[i ^ 1].cf += d;           if (f <= 0) return sum;         }       }     }     return sum;   }   int solve() {     int re = 0;     while (BFS()) {       memcpy(cur, first, sizeof(first));       re += dfs(S, inf);     }     return re;   }   bool check(int p) {     for (int i = 1; i <= ES; i++) {       if (e[i].w <= p)         acc[i] = true;       else         acc[i] = false;       e[i].cf = (i & 1) ^ 1;     }     return solve() == N;   }   int main() {     scanf( %d%d , &N, &M);     int u, v, w;     int L = 0, R = 0, mid, ans = -1;     for (int i = 1; i <= M; i++) scanf( %d%d%d , &u, &v, &w), add(u, v + N, w);     S = 0;     T = 2 * N + 1;     for (int i = 1; i <= N; i++) add(S, i, -1), add(i + N, T, -1);     R = 1e9;     while (L <= R) {       mid = L + R >> 1;       if (check(mid))         ans = mid, R = mid - 1;       else         L = mid + 1;     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   int Left[N], Right[N];   void pre(int node) {     if (node == -1) return;     pre(Left[node]);     printf( %d n , node + 1);     pre(Right[node]);   }   int main() {     memset(Left, -1, sizeof Left);     memset(Right, -1, sizeof Right);     string s;     cin >> s;     for (int i = 0; i + 1 < (int)s.size(); ++i)       if (s[i] ==  l )         Left[i] = i + 1;       else         Right[i] = i + 1;     pre(0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   const int maxm = 1e3 + 5;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   int a[maxn], ans[maxn], l[maxn][6], r[maxn][6];   inline void solve() {     int n;     scanf( %d , &n);     for (int i = 1; i < n + 1; i++) scanf( %d , &a[i]);     memset(l, -1, sizeof l);     memset(r, -1, sizeof r);     if (a[1] > 1) {       puts( -1 );       exit(0);     }     l[1][1] = r[1][1] = 1;     for (int i = 2; i < n + 1; i++) {       for (int j = 2; j < 5 + 1; j++) {         if (l[i - 1][j - 1] != -1) {           l[i][j] = l[i - 1][j - 1];           r[i][j] = r[i - 1][j - 1];         }       }       for (int j = 2; j < 5 + 1; j++) {         if (l[i - 1][j] != -1) {           if (l[i][1] == -1) l[i][1] = inf;           l[i][1] = min(l[i][1], l[i - 1][j] + 1);           r[i][1] = max(r[i][1], r[i - 1][j] + 1);         }       }       if (a[i]) {         for (int j = 1; j < 5 + 1; j++) {           if (l[i][j] != -1) {             if (l[i][j] <= a[i] && a[i] <= r[i][j])               l[i][j] = r[i][j] = a[i];             else               l[i][j] = r[i][j] = -1;           } else             r[i][j] = -1;         }       }       bool ok = 0;       for (int j = 1; j < 5 + 1; j++) {         if (l[i][j] <= r[i][j] && l[i][j] != -1) {           ok = 1;           break;         }       }       if (!ok) {         puts( -1 );         exit(0);       }     }     int up = 0, j = 2;     for (int i = 2; i < 5 + 1; i++) {       if (l[n][i] <= r[n][i] && l[n][i] != -1) {         if (r[n][i] > up) {           up = r[n][i];           j = i;         }       }     }     if (up == 0) {       puts( -1 );       exit(0);     }     printf( %d n , up);     int m = n;     while (m) {       for (int i = m - j; i < m + 1; i++) ans[i] = up;       m -= j;       up--;       for (int i = 2; i < 5 + 1; i++) {         if (l[m][i] <= up && up <= r[m][i]) j = i;       }     }     for (int i = 1; i < n + 1; i++) {       if (i == 1)         printf( %d , ans[i]);       else         printf(  %d , ans[i]);     }     puts(  );   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int v, next;   } edge[2050];   int e, ft[2050];   int a, n, m;   bool rain[2050];   int x[2050], p[2050];   long long dp[2050][2050];   long long opt[2050];   int main() {     int l, r;     while (cin >> a >> n >> m) {       e = 0;       for (int i = 0; i <= a; i++) {         rain[i] = false;         for (int j = 0; j <= m; j++) dp[i][j] = (1ll << 60);         ft[i] = -1;       }       for (int i = 0; i < n; i++) {         scanf( %d%d , &l, &r);         while (l < r) {           rain[l++] = true;         }       }       for (int i = 0; i < m; i++) {         scanf( %d%d , x + i, p + i);         edge[e].v = i;         edge[e].next = ft[x[i]];         ft[x[i]] = e++;         if (x[i] == 0) dp[0][i] = 0;       }       dp[0][m] = 0;       p[m] = 0;       opt[0] = 0;       for (int i = 0; i < a; i++) {         for (int j = 0; j <= m; j++) {           if (dp[i][j] >= (1ll << 60)) continue;           if (j < m || !rain[i])             dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + p[j]);         }         opt[i + 1] = (1ll << 60);         for (int j = 0; j <= m; j++) opt[i + 1] = min(opt[i + 1], dp[i + 1][j]);         for (int j = ft[i + 1]; j != -1; j = edge[j].next) {           int idx = edge[j].v;           dp[i + 1][idx] = min(dp[i + 1][idx], opt[i + 1]);         }         dp[i + 1][m] = min(dp[i + 1][m], opt[i + 1]);       }       long long ans = -1;       if (opt[a] < (1ll << 60)) ans = opt[a];       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fastIO(void);   void decimal(int);   long long int modmulti(long long int, long long int, long long int);   long long int modadd(long long int, long long int, long long int);   long long int modpower(long long int, long long int, long long int);   long long int gcd(long long int, long long int);   long long int modinv(long long int, long long int);   int main() {     fastIO();     long long int n;     cin >> n;     long long int t1, t2;     vector<long long int> a(n);     multiset<long long int> b;     for (long long int i = 0; i < n; i++) cin >> a[i];     for (long long int i = 0; i < n; i++) {       cin >> t1;       b.insert(t1);     }     long long int c[n];     for (long long int i = 0; i < n; i++) {       t2 = n - a[i];       auto itr = b.lower_bound(n - a[i]);       if (itr == b.end()) itr = b.begin();       c[i] = (a[i] + *itr) % n;       b.erase(itr);     }     for (long long int i = 0; i < n; i++) cout << c[i] <<    ;     cout <<   n ;   }   void fastIO(void) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void decimal(int n) {     cout << fixed;     cout << setprecision(n);   }   long long int modmulti(long long int a, long long int b, long long int m) {     return ((a % m) * (b % m)) % m;   }   long long int modadd(long long int a, long long int b, long long int m) {     return ((a % m) + (b % m) + m) % m;   }   long long int modpower(long long int a, long long int n, long long int m) {     if (n == 0) return 1;     long long int result = 1;     while (n > 0) {       if (n % 2 == 1) result = modmulti(result, a, m);       a = modmulti(a, a, m);       n = n / 2;     }     return result;   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int modinv(long long int a, long long int m) {     return modpower(a, m - 2, m);   }
#include <bits/stdc++.h>   using namespace std;   const static int maxN = 1000;   struct {     int r, c;   } tooth[maxN];   int toothrow[maxN + 1];   int main() {     int n, m, k;     int i;     int ans;     while (scanf( %d%d%d , &n, &m, &k) != EOF) {       for (i = 0; i < n; i++) {         scanf( %d%d , &tooth[i].r, &tooth[i].c);       }       memset(toothrow, -1, sizeof(int) * (m + 1));       ans = 0;       for (i = 0; i < n; i++) {         if (toothrow[tooth[i].r] != -1) {           if (tooth[i].c < toothrow[tooth[i].r]) {             ans -= toothrow[tooth[i].r];             ans += tooth[i].c;             toothrow[tooth[i].r] = tooth[i].c;           }         } else {           ans += tooth[i].c;           toothrow[tooth[i].r] = tooth[i].c;         }       }       printf( %d n , min(ans, k));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 5;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   void solve() {     vector<long long> v(14);     long long curr_score = 0;     long long o = 0;     for (int i = 0; i < 14; i++) {       cin >> v[i];     }     for (int i = 0; i < 14; i++) {       vector<long long> t(14);       for (int k = 0; k < 14; k++) {         t[k] = v[k];       }       long long p = v[i] / 14, q = v[i] % 14;       t[i] = 0;       for (int j = 0; j < 14; j++) {         t[j] += p;       }       long long j = i + 1;       while (q--) {         if (j == 14) {           j = 0;         }         t[j++]++;       }       long long cnt = 0;       for (int i = 0; i < 14; i++) {         if (t[i] % 2 == 0) {           cnt += t[i];         }       }       curr_score = max(curr_score, cnt);     }     cout << curr_score <<   n ;   }   int main() {     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     long long a, b, cost;     edge(long long x, long long y, long long z) : a(x), b(y), cost(z){};   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, k, p;     cin >> n >> k >> p;     vector<long long> v(n), a(k);     for (long long i = 0; i < (long long)(n); i++) cin >> v[i];     for (long long i = 0; i < (long long)(k); i++) cin >> a[i];     sort((v).begin(), (v).end());     sort((a).begin(), (a).end());     long long ans = INT_MAX;     for (long long i = (long long)(0); i <= (long long)(k - n); i++) {       long long res = INT_MIN;       for (long long j = (long long)(0); j <= (long long)(n - 1); j++) {         res = max(res, abs(v[j] - a[i + j]) + abs(a[i + j] - p));       }       ans = min(ans, res);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long ans;   int n, i, j, k, u, v;   int size[80011], fa[80011];   vector<int> e[80011];   void dfs(int now) {     unsigned long long o = 0;     size[now] = 1;     for (int i = 0; i < e[now].size(); i++)       if (e[now][i] != fa[now]) {         fa[e[now][i]] = now;         dfs(e[now][i]);         o += (unsigned long long)size[now] * size[e[now][i]];         size[now] += size[e[now][i]];       }     ans -= o * (o + 2LL * size[now] * (n - size[now]));   }   int main() {     scanf( %d , &n);     for (i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       e[u].push_back(v);       e[v].push_back(u);     }     ans = (n - 1LL) * n / 2;     ans *= ans;     dfs(1);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans = 0;   string str;   int n;   int main() {     ios::sync_with_stdio(false);     cin >> n;     cin >> str;     for (int i = 0; i < n; ++i) ans += (str[i] -  0 ) & 1 ? 0 : i + 1;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long test(vector<long long>& h, int l, int r) {     long long ret = 0;     for (int i = l; i < r; i++) {       long long tmp = 0;       for (int j = i + 1; j < r; j++) {         tmp = max(tmp, abs(h[j] - h[j - 1]));         ret += tmp;       }     }     return ret;   }   int main() {     int n, q;     cin >> n >> q;     vector<long long> h(n);     for (int i = 0; i < n; i++) {       scanf( %I64d , &h[i]);     }     while (q--) {       int l, r;       scanf( %d%d , &l, &r);       l--;       long long ans = 0;       long long last = 0;       deque<pair<long long, int>> dq;       for (int i = l + 1; i < r; i++) {         long long tmp = abs(h[i] - h[i - 1]);         long long len = 1;         while (dq.size() && dq.back().first <= tmp) {           auto val = dq.back();           dq.pop_back();           len += val.second;           last -= val.first * val.second;         }         dq.push_back({tmp, len});         last += tmp * len;         ans += last;       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cont = 0;   template <typename T, typename F>   struct AHO_CORASICK {     const long long ALPHA = 26;     long long cv(F c) { return c -  0 ; }     vector<map<long long, long long>> tgo;     vector<long long> link;     vector<long long> ch;     vector<long long> p;     vector<bool> flag;     long long sz = 0;     long long size() { return sz; }     void new_node(long long tp, long long tch) {       sz++;       tgo.emplace_back();       link.push_back(0);       ch.push_back(tch);       p.push_back(tp);       flag.push_back(false);     }     AHO_CORASICK() {       new_node(0, 0);       new_node(1, 0);     }     void add_string(T cad) {       long long pt = 1;       for (long long i = 0; i < cad.size(); i++) {         long long tch = cv(cad[i]);         if (tgo[pt][tch] == 0) {           tgo[pt][tch] = sz;           new_node(pt, tch);         }         pt = tgo[pt][tch];       }       flag[pt] = true;     }     long long get_link(long long nodo) {       if (link[nodo] == 0) {         if (nodo == 1 || p[nodo] == 1)           link[nodo] = 1;         else           link[nodo] = go(get_link(p[nodo]), ch[nodo]);         flag[nodo] = flag[nodo] | flag[link[nodo]];       }       return link[nodo];     }     long long go(long long nodo, F tch) { return go(nodo, cv(tch)); }     long long go(long long nodo, long long tch) {       if (tgo[nodo][tch] == 0) {         tgo[nodo][tch] = (nodo == 1) ? 1 : go(get_link(nodo), tch);       }       return tgo[nodo][tch];     }   };   long long X;   vector<string> bf;   string temp;   void fff(long long sum) {     if (sum > X) return;     for (long long i = 0; i < temp.size(); i++) {       long long s = 0;       for (long long j = i; j < temp.size(); j++) {         s += temp[j] -  0 ;         if (s != X && X % s == 0) return;       }     }     if (sum == X) {       bf.push_back(temp);       return;     }     for (long long i = 1; i <= 9; i++) {       temp += (i +  0 );       fff(sum + i);       temp.pop_back();     }   }   const long long MAXN = 1010;   long long dp[MAXN][MAXN * 5];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     for (long long i = 0; i < MAXN; i++) {       for (long long j = 0; j < 5 * MAXN; j++) {         dp[i][j] = 1e9;       }     }     string cad;     cin >> cad;     cin >> X;     long long N = cad.size();     fff(0);     AHO_CORASICK<string, char> ac;     for (auto x : bf) {       ac.add_string(x);     }     dp[0][1] = 0;     for (long long i = 0; i < N; i++) {       for (long long j = 1; j < ac.size(); j++) {         long long pt = ac.go(j, cad[i]);         if (ac.flag[pt] == false) dp[i + 1][pt] = min(dp[i + 1][pt], dp[i][j]);         dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);       }     }     long long res = 1e9;     for (long long i = 0; i < ac.sz; i++) {       res = min(res, dp[N][i]);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char name[5][10] = { Sheldon ,  Leonard ,  Penny ,  Rajesh ,  Howard };     int n, c = 5;     scanf( %d , &n);     while (n > c) {       n -= c;       c *= 2;     }     printf( %s n , name[(n - 1) / (c / 5)]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     map<string, pair<string, long long>> best;     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       string name;       long long score;       cin >> name >> score;       best[name].second = max(best[name].second, score);     }     for (auto itr = best.begin(); itr != best.end(); itr++) {       long long count = 0;       for (auto i = best.begin(); i != best.end(); i++) {         if (itr->second.second >= i->second.second) count++;       }       double percent = ((double)count / best.size() * 1.0) * 100.0;       if (percent < 50.0)         itr->second.first =  noob ;       else if (percent >= 50.0 && percent < 80.0)         itr->second.first =  random ;       else if (percent >= 80.0 && percent < 90.0)         itr->second.first =  average ;       else if (percent >= 90.0 && percent < 99.0)         itr->second.first =  hardcore ;       else         itr->second.first =  pro ;     }     cout << best.size() << endl;     for (auto x : best) {       cout << x.first <<     << x.second.first << endl;     }   }   int32_t main() {     long long testcases = 1;     while (testcases--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void run_case() {     string A, B, C, D;     cin >> A;     cin >> B;     C = (A + B);     sort(C.begin(), C.end());     cin >> D;     sort(D.begin(), D.end());     if (C == D)       cout <<  YES n ;     else       cout <<  NO n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long T = 1;     while (T--) run_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:200000000 )   const double EPS = 1E-9;   const int INF = 1000000000;   const long long INF64 = (long long)1E18;   const double PI = 3.1415926535897932384626433832795;   char s[2100][2100];   int ans[2100];   int main() {     int n, m, k;     scanf( %d%d%d n , &n, &m, &k);     for (int i = 0; i < (int)(n); i++) gets(s[i]);     for (int i = 0; i < (int)(n); i++)       for (int j = 0; j < (int)(m); j++) {         if (s[i][j] ==  .  || s[i][j] ==  D ) continue;         if (s[i][j] ==  U ) {           if (i % 2 == 1) continue;           ans[j]++;           continue;         }         int nj;         if (s[i][j] ==  L )           nj = j - i;         else           nj = j + i;         if (0 <= nj && nj < m) ans[nj]++;       }     for (int i = 0; i < (int)(m); i++) printf(i ?   %d  :  %d , ans[i]);     puts(  );     return 0;   }