malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int solver(string s) {     if (s.length() == 1) {       if (s ==  0 ) return 1;       if (s ==  _ )         return 1;       else         return 0;     }     if (s[0] ==  0 ) {       return 0;     }     if (s.back() ==  _ ) {       int ans = 0;       for (char c =  0 ; c <=  9 ; c++) {         s[s.length() - 1] = c;         ans += solver(s);       }       return ans;     }     int _ = 0;     for (char c : s) {       _ += (c ==  _ );     }     if (s.back() >=  0  && s.back() <=  9  && s[s.length() - 2] >=  0  &&         s[s.length() - 2] <=  9 ) {       if (s.back() !=  0  && s.back() !=  5 ) {         return 0;       }       if (s.back() ==  0 ) {         if (s[s.length() - 2] !=  5  && s[s.length() - 2] !=  0 ) {           return 0;         }       }       if (s.back() ==  5 ) {         if (s[s.length() - 2] !=  2  && s[s.length() - 2] !=  7 ) {           return 0;         }       }       return pow(10, _);     }     if (s.back() >=  0  && s.back() <=  9  && s[s.length() - 2] ==  _ ) {       if (s.back() ==  0  || s.back() ==  5 )         return 2 * pow(10, _ - 1);       else         return 0;     }   }   vector<string> generate(string orig) {     vector<string> v;     string dum = orig;     int x = 0;     for (char c : orig) x += (c ==  X );     if (!x) {       return {orig};     }     for (char i =  0 ; i <=  9 ; i++) {       for (int j = 0; j < dum.length(); j++) {         if (dum[j] ==  X ) {           dum[j] = i;         }       }       v.push_back(dum);       dum = orig;     }     return v;   }   int main() {     string orig;     cin >> orig;     if (orig.length() == 1) {       if (orig ==  X )         cout << 1;       else         cout << solver(orig);       return 0;     }     vector<string> v = generate(orig);     int ans = 0;     for (string s : v) {       if (s[0] ==  0 ) {         ans += 0;       } else if (s[0] ==  _ ) {         for (char j =  1 ; j <=  9 ; j++) {           s[0] = j;           ans += solver(s);         }       } else {         ans += solver(s);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500010;   int ans[N], arr[N], MAX[N];   long long power_mod(long long x, long long y) {     x %= 1000000007;     long long res = 1;     while (y) {       if (y & 1) {         res = (res * x) % 1000000007;       }       y /= 2;       x = (x * x) % 1000000007;     }     return res;   }   void solve() {     int n;     cin >> n;     vector<pair<int, int>> v(N);     for (int i = 1; i <= n; i++) {       cin >> v[i].first >> v[i].second;       ans[i] = MAX[i] = 1;     }     sort(v.begin() + 1, v.begin() + n + 1);     arr[n + 1] = v[n].second + 1;     for (int i = 1; i <= n; i++) {       arr[i] = v[i].first;     }     int ma = 0;     for (int i = n; i >= 1; i--) {       int up = upper_bound(arr + 1, arr + 2 + n, v[i].second) - arr;       int p = ans[i];       ans[i] = max(ans[i], ans[i + 1]);       ans[i] = max(ans[i], p + ans[up]);     }     int res = *max_element(ans, ans + n + 1);     cout << res <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int tc = 1;     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p[11111], c[11111];   vector<pair<int, int> > ve;   int main() {     int a;     cin >> n;     for (int i = 2; i <= n; i++) {       cin >> a;       c[i] = a;     }     int s = 1;     cin >> p[1];     for (int i = 2; i <= n; i++) {       cin >> p[i];       if (p[i] != p[c[i]]) {         s++;       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int INF = 2147483647;   const int p[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29,                    31, 37, 41, 43, 47, 53, 59, 61, 67};   long long a[100][32], b[100][32];   int main() {     int n;     scanf( %d , &n);     a[0][0] = 1;     for (int i = 4; i < 19; i++) a[p[i]][0] = 1;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       int y = 0;       for (int j = 0; j < 4; j++)         if (x % p[j] == 0) {           int flag = 0;           while (x % p[j] == 0) flag ^= 1, x /= p[j];           y += (flag << j);         }       if (x > 1) {         y += 16;         for (int j = 0; j < 32; j++) b[x][j] = 0;         for (int j = 0; j < 32; j++) b[x][j ^ y] = (b[x][j ^ y] + a[x][j]) % mod;         for (int j = 0; j < 32; j++) a[x][j] = (a[x][j] + b[x][j]) % mod;       } else {         for (int j = 0; j < 16; j++) b[0][j] = 0;         for (int j = 0; j < 16; j++) b[0][j ^ y] = (b[0][j ^ y] + a[0][j]) % mod;         for (int j = 0; j < 16; j++) a[0][j] = (a[0][j] + b[0][j]) % mod;       }     }     for (int i = 4; i < 19; i++) {       a[p[i]][0] = (a[p[i]][0] + mod - 1) % mod;       for (int j = 0; j < 16; j++) b[0][j] = 0;       for (int j = 0; j < 16; j++)         for (int k = 0; k < 16; k++)           b[0][j ^ k] = (b[0][j ^ k] + a[0][j] * a[p[i]][k]) % mod;       for (int j = 0; j < 16; j++) a[0][j] = (a[0][j] + b[0][j]) % mod;     }     printf( %lld n , (a[0][0] + mod - 1) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<long long> s;     for (long long a = 1; a <= 2 * 1e9; a *= 2) {       for (long long b = 1; b <= 2 * 1e9; b *= 3) {         s.insert(a * b);       }     }     int l, r, ans = 0;     cin >> l >> r;     for (set<long long>::iterator it = s.begin(); it != s.end(); ++it)       ans += *it <= r && *it >= l;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const bool debug = 0;   int main() {     if (!debug) {       cin.tie(0);       cin.sync_with_stdio(0);       cout.tie(0);       cout.sync_with_stdio(0);     }     int n, m;     cin >> n >> m;     vector<vector<int>> d(m, vector<int>(n));     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++) cin >> d[i][j];     vector<int> out(m);     for (int i = 0; i < m; i++) out[i] = i;     for (int v = 0; v < n - 1; v++) {       vector<pair<int, int>> k(m);       int r = 0;       for (int i = 0; i < m; i++) {         k[i] = {d[i][n - 1] - d[i][v], i};         r += k[i].first;       }       sort(k.begin(), k.end());       reverse(k.begin(), k.end());       if (debug)         for (int i = 0; i < m; i++)           cout << k[i].first <<  :  << k[i].second <<    ;       if (debug) cout <<   n  << r <<   n ;       int i = 0;       for (; i < m; i++) {         if (r > 0)           r -= k[i].first;         else           break;       }       if (r <= 0 && out.size() > i) {         out.resize(i);         for (int j = 0; j < i; j++) out[j] = k[j].second;       }     }     cout << out.size() <<   n ;     for (int i = 0; i < out.size(); i++) cout << out[i] + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       unordered_map<int, long long> mmap;       while (n % 3 == 0) {         mmap[3]++;         n /= 3;       }       while (n % 2 == 0) {         mmap[2]++;         n /= 2;       }       if ((n > 1) || (mmap[2] > mmap[3]))         cout << -1 << endl;       else {         long long count = mmap[3];         count += (mmap[3] - mmap[2]);         cout << count << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 58;   vector<int> adj[maxn], V;   bitset<maxn> mark;   void dfs(int v) {     mark[v] = 1;     V.push_back(v);     for (auto u : adj[v]) {       if (!mark[u]) {         dfs(u);         V.push_back(v);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int v, u;       cin >> v >> u;       v--;       u--;       adj[v].push_back(u);       adj[u].push_back(v);     }     dfs(0);     int ptr = 0;     while (k) {       cout << (V.size() - ptr) / k <<    ;       for (int i = 0; i < (V.size() - ptr) / k; i++) {         cout << V[ptr + i] + 1 <<    ;       }       ptr += (V.size() - ptr) / k;       cout <<   n ;       k--;     }   }
#include <bits/stdc++.h>   const int N = 123456;   int arr[N], i, j;   using namespace std;   int main() {     long long n, k, a, b, ans1 = 0, ans2 = 0, ans = 0;     scanf( %lld %lld , &n, &k);     scanf( %lld %lld , &a, &b);     ans1 = (n - 1) * a;     if (k == 1) return cout << ans1 << endl, 0;     while (n != 0 && n != 1) {       if (n % k == 0) {         if (b < a * (n - n / k))           ans += b;         else           ans += a * (n - n / k);         n = n / k;       } else {         ans += ((n % k) * a);         n = n - (n % k);       }     }     if (n == 0) ans -= a;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while ( 0  <= c && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   int n, m, cnt, maxx, tab[300], f[1005][105][105];   char s[15];   struct Trie {     int bj, len, fail, ch[4];   } tree[105];   void Insert() {     int len = strlen(s + 1), now = 1;     maxx = max(maxx, len);     for (int i = 1; i <= len; ++i) {       int v = tab[s[i]];       int &o = tree[now].ch[v];       if (!o) o = ++cnt;       now = o;     }     tree[now].bj = 1;     tree[now].len = len;   }   void Build() {     queue<int> q;     for (int i = 0; i <= 3; ++i) tree[0].ch[i] = 1;     q.push(1);     while (!q.empty()) {       int x = q.front(), fail = tree[x].fail;       q.pop();       tree[x].bj |= tree[fail].bj;       tree[x].len = max(tree[x].len, tree[fail].len);       for (int i = 0; i <= 3; ++i) {         int &y = tree[x].ch[i];         if (!y)           y = tree[fail].ch[i];         else           tree[y].fail = tree[fail].ch[i], q.push(y);       }     }   }   inline int Mod(int x) { return x >= 1000000009 ? x - 1000000009 : x; }   int main() {     tab[ A ] = 0;     tab[ C ] = 1;     tab[ G ] = 2;     tab[ T ] = 3;     n = read();     m = read();     cnt = 1;     for (int i = 1; i <= m; ++i) scanf( %s , s + 1), Insert();     Build();     f[0][0][1] = 1;     for (int i = 0; i < n; ++i)       for (int j = 0; j <= maxx; ++j)         for (int k = 1; k <= cnt; ++k)           if (f[i][j][k])             for (int p = 0; p <= 3; ++p) {               int y = tree[k].ch[p];               if (j + 1 <= tree[y].len)                 f[i + 1][0][y] = Mod(f[i + 1][0][y] + f[i][j][k]);               else                 f[i + 1][j + 1][y] = Mod(f[i + 1][j + 1][y] + f[i][j][k]);             }     int ans = 0;     for (int k = 1; k <= cnt; ++k) ans = Mod(ans + f[n][0][k]);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100;   double pr[10][N][N], p[N][N], dp[10][N][N];   int n;   int main() {     double ans = 0;     cin >> n;     for (int i = 0; i < (1 << n); i++)       for (int j = 0; j < (1 << n); j++) cin >> p[i][j], p[i][j] /= 100;     for (int i = 0; i < (1 << n); i++) pr[0][i][i] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j < (1 << (n - i)); j++) {         int d = (1 << i);         for (int g = 0; g < d; g++) {           int o = d * j + g;           double t = pr[i - 1][j * 2 + (g >= d / 2)][o];           double k = 0;           for (int h = 0; h < d / 2; h++) {             int o2 = d * j + h;             if (g < d / 2) o2 += d / 2;             k += pr[i - 1][j * 2 + (g < d / 2)][o2] * p[o][o2];           }           pr[i][j][o] = k * t;         }       }     for (int i = 1; i <= n; i++)       for (int j = 0; j < (1 << (n - i)); j++) {         int d = (1 << i);         int p3 = (1 << (i - 1));         for (int g = 0; g < d; g++) {           int o = d * j + g;           double t = dp[i - 1][j * 2 + (g >= d / 2)][o];           double p1 = pr[i - 1][j * 2 + (g >= d / 2)][o];           double m = 0;           for (int h = 0; h < d / 2; h++) {             int o2 = d * j + h;             if (g < d / 2) o2 += d / 2;             m = max(m, dp[i - 1][j * 2 + (g < d / 2)][o2]);           }           t += m;           double k = 0;           for (int h = 0; h < d / 2; h++) {             int o2 = d * j + h;             if (g < d / 2) o2 += d / 2;             k += pr[i - 1][(j * 2 + (g < d / 2))][o2] * p[o][o2];           }           t += p1 * p3 * k;           dp[i][j][o] = t;           if (i == n) ans = max(ans, t);         }       }     cout << setprecision(9) << fixed << ans << endl;     return 0;   }
#include <bits/stdc++.h>   inline void in(int &MAGNUS) { scanf( %d , &MAGNUS); }   inline void out(int MAGNUS) { printf( %d n , MAGNUS); }   inline void in(int &MAGNUS, int &CLAR) { scanf( %d%d , &MAGNUS, &CLAR); }   inline void out(int MAGNUS, int CLAR) { printf( %d %d n , MAGNUS, CLAR); }   inline void inl(long long &LIV) { scanf( %lld , &LIV); }   inline void inl(long long &LIV, long long &MART) {     scanf( %lld%lld , &LIV, &MART);   }   inline void outl(long long LIV) { printf( %lld n , LIV); }   inline void outl(long long LIV, long long MART) {     printf( %lld %lld n , LIV, MART);   }   using namespace std;   int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};   int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};   int R, C, x[405][405], sum[8][405][405];   bool inside(int r, int c) { return 1 <= r && r <= R && 1 <= c && c <= C; }   int rsum(int dir, int r1, int c1, int r2, int c2) {     return abs(sum[dir][r2][c2] - sum[dir][r1 - dx[dir]][c1 - dy[dir]]);   }   int main() {     in(R, C);     for (int i = 1; i <= R; i++) {       for (int j = 1; j <= C; j++) {         char ch;         cin >> ch;         x[i][j] = ch -  0 ;       }     }     for (int dir = 0; dir <= 7; dir++) {       for (int i = 1; i <= R; i++) {         for (int j = 1; j <= C; j++) {           if (inside(i - dx[dir], j - dy[dir])) continue;           int r = i, c = j;           while (inside(r, c)) {             if (r == i && c == j)               sum[dir][r][c] = x[i][j];             else               sum[dir][r][c] = x[r][c] + sum[dir][r - dx[dir]][c - dy[dir]];             r += dx[dir];             c += dy[dir];           }         }       }     }     long long ans = 0;     for (int i = 1; i <= R; i++) {       for (int j = 1; j <= C; j++) {         for (int dir = 0; dir <= 3; dir++) {           for (int k = 1; k <= min(R, C); k++) {             int r1 = i + dx[dir] * k, c1 = j + dy[dir] * k;             int r2 = i + dx[(dir + 1) % 4] * k, c2 = j + dy[(dir + 1) % 4] * k;             if (!inside(r1, c1) || !inside(r2, c2)) continue;             int s1 = rsum(dir, i, j, r1, c1),                 s2 = rsum((dir + 1) % 4, i, j, r2, c2),                 s3 = rsum(dir + 4, r2, c2, r1, c1);             ans += (s1 == 0 && s2 == 0 && s3 == 0);           }           for (int k = 1; k <= min(R, C); k++) {             int r1 = i + dx[dir] * k, c1 = j + dy[dir] * k;             int r2 = i + dx[(dir + 1) % 4] * k, c2 = j + dy[(dir + 1) % 4] * k;             int r3 = i + dx[(dir + 2) % 4] * k, c3 = j + dy[(dir + 2) % 4] * k;             if (!inside(r1, c1) || !inside(r2, c2) || !inside(r3, c3)) continue;             int s1 = rsum(dir, i, j, r1, c1), s2 = rsum(dir + 4, r2, c2, r1, c1);             int s3 = rsum((dir + 2) % 4, i, j, r3, c3),                 s4 = rsum((dir + 1) % 4 + 4, r3, c3, r2, c2);             ans += (s1 == 0 && s2 == 0 && s3 == 0 && s4 == 0);           }         }       }     }     outl(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e7 + 7;   const int Mx = (int)1e7;   int n, m;   int A[N], B[N];   int lp[N];   map<int, vector<int> > a, b;   void precalc() {     for (int i = 2; i <= Mx; i++) {       if (!lp[i]) {         lp[i] = i;         if (i * 1ll * i <= Mx) {           for (int j = i * i; j <= Mx; j += i) {             if (!lp[j]) lp[j] = i;           }         }       }     }   }   int main() {     precalc();     scanf( %d%d , &n, &m);     for (int i = 1, x; i <= n; i++) {       scanf( %d , &A[i]);       x = A[i];       while (x > 1) {         int p = lp[x];         a[p].push_back(i);         x /= p;       }     }     for (int i = 1, x; i <= m; i++) {       scanf( %d , &B[i]);       x = B[i];       while (x > 1) {         int p = lp[x];         b[p].push_back(i);         x /= p;       }     }     for (int i = 2; i < N; i++) {       if (lp[i] == i) {         int len = min(a[i].size(), b[i].size());         while (len) {           len--;           A[a[i].back()] /= i;           B[b[i].back()] /= i;           a[i].pop_back();           b[i].pop_back();         }       }     }     printf( %d %d n , n, m);     for (int i = 1; i <= n; i++) {       printf( %d  , A[i]);     }     printf(  n );     for (int i = 1; i <= m; i++) {       printf( %d  , B[i]);     }     return 0;   }
#include <bits/stdc++.h>   int f[100001];   int a[100001];   using namespace std;   int main() {     bool isAm = false;     long long int n, m, x;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> x;       if (f[x] == 0)         f[x] = i + 1;       else         f[x] = -1;     }     for (int i = 0; i < m; i++) {       cin >> x;       if (f[x] == 0) {         cout <<  Impossible ;         return 0;       } else if (f[x] != -1) {         a[i] = f[x];       } else         isAm = true;     }     if (isAm) {       cout <<  Ambiguity ;       return 0;     }     cout <<  Possible n ;     for (int i = 0; i < m; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   long long binpow(long long base, long long exp, int mod) {     long long res = 1;     while (exp > 0) {       if (exp % 2 == 1) res = (res * base) % mod;       exp = exp >> 1;       base = (base * base) % mod;     }     return res;   }   long long mod(long long x) {     return ((x % 1000000007LL + 1000000007LL) % 1000000007LL);   }   long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }   long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int m;     cin >> m;     vector<long long int> v1;     for (long long int i = 0; i < m; i++) {       long long int x;       cin >> x;       v1.push_back(x);     };     sort(v1.begin(), v1.end());     long long int n;     cin >> n;     vector<long long int> v2;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       v2.push_back(x);     };     sort(v2.begin(), v2.end());     long long int sum = 0;     for (int i = 0; i < n; i++) sum += v2[i];     if (n < v1[0] + 2) {       cout << sum <<   n ;     } else {       long long int sum2 = 0;       for (long long int i = n - 1; i >= 0; i -= v1[0] + 2) {         for (long long int j = i; j >= max(i - v1[0] + 1, 0LL); j--)           sum2 += v2[j];       }       cout << sum2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   struct abc {     int left, right, capacity, cost;   } edge[12345];   int n, k, x, e = 0, cost[50], p[50];   void addEdge(int a, int b, int c, int d) {     edge[e].left = a;     edge[e].right = b;     edge[e].capacity = c;     edge[e].cost = d;     e++;     edge[e].left = b;     edge[e].right = a;     edge[e].capacity = 0;     edge[e].cost = -d;     e++;   }   bool getPath(int s, int t) {     for (int i = 0; i < n; i++) cost[i] = INF;     cost[s] = 0;     bool upd = true;     for (int it = 1; upd && it < n; it++)       for (int i = upd = 0; i < e; i++)         if (edge[i].capacity > 0 && cost[edge[i].left] < INF &&             cost[edge[i].right] > cost[edge[i].left] + edge[i].cost) {           cost[edge[i].right] = cost[edge[i].left] + edge[i].cost;           p[edge[i].right] = i;           upd = true;         }     return cost[t] < INF;   }   int minCostMaxFlow(int s, int t) {     int MaxFlow = 0, MinCost = 0, flow;     while (getPath(s, t)) {       MinCost += cost[t];       if (MinCost > k) return MaxFlow;       flow = INF;       for (int c = t; c != s; c = edge[p[c]].left) {         flow = min(flow, edge[p[c]].capacity);         if (edge[p[c]].cost != 0) flow = 1;       }       for (int c = t; c != s; c = edge[p[c]].left) {         edge[p[c]].capacity -= flow;         edge[p[c] ^ 1].capacity += flow;       }       MaxFlow += flow;     }     return MaxFlow;   }   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         cin >> x;         if (x) {           addEdge(i, j, x, 0);           addEdge(i, j, INF, 1);         }       }     cout << minCostMaxFlow(0, n - 1);   }
#include <bits/stdc++.h>   using namespace std;   int Month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int A[1000 + 1];   int B[126];   void omae_wa_mou_shindeiru() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     for (int i = 0; i < n; ++i) {       int c = 1;       while (s[i] == s[i + 1] && i < n) {         ++c;         ++i;       }       B[s[i]] += c / k;     }     int ans = 0;     for (int i =  a ; i <=  z ; ++i) {       ans = max(ans, B[i]);     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     ;     int t = 1;     while (t--) {       omae_wa_mou_shindeiru();       if (t) cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long w, j, i, m, n, a[2005][2005], k;   vector<int> v[2010];   int main() {     scanf( %d %d , &m, &n);     for (i = 1; i <= m; i++) {       a[i][1] = 1;     }     for (i = 1; i <= m; i++) {       for (j = 1; j * j <= i; j++) {         if (i % j != 0) continue;         if (j * j != i) {           v[i].push_back(j);           v[i].push_back(i / j);         } else           v[i].push_back(j);       }     }     for (j = 1; j <= n; j++) {       for (i = 1; i <= m; i++) {         for (w = 0; w < v[i].size(); w++) {           a[i][j] = (a[i][j] + a[v[i][w]][j - 1]) % 1000000007;         }       }     }     for (i = 1; i <= m; i++) k = (k + a[i][n]) % 1000000007;     cout << k % 1000000007;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxN = 1e5 + 10;   int n, m, s, f;   int t[maxN], l[maxN], r[maxN];   bool inside(int l, int m, int r) { return l <= m && m <= r; }   void slv() {     int d = f > s ? 1 : -1;     m++;     t[m] = inf, l[m] = inf, r[m] = -inf;     int tm = 1;     int p = 1;     while (true) {       if (s == f) break;       if (tm != t[p])         s += d, printf( %c , d > 0 ?  R  :  L );       else {         if (inside(l[p], s, r[p]) || inside(l[p], s + d, r[p]))           printf( X );         else           printf( %c , d > 0 ?  R  :  L ), s += d;         p++;       }       tm++;     }   }   int main() {     while (~scanf( %d%d%d%d , &n, &m, &s, &f)) {       for (int i = 1; i <= m; i++) scanf( %d%d%d , &t[i], &l[i], &r[i]);       slv();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string s[55];   vector<int> getRow(int x) {     vector<int> R;     for (int i = 1; i <= m; i++)       if (s[x][i] ==  # ) R.push_back(i);     return R;   }   vector<int> getCol(int x) {     vector<int> C;     for (int i = 1; i <= n; i++)       if (s[i][x] ==  # ) C.push_back(i);     return C;   }   int Viz[55];   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       string t;       cin >> t;       s[i] =  .  + t +  . ;     }     int nope = 0;     for (int i = 1; i <= n && !nope; i++) {       if (!Viz[i]) {         vector<int> V, R;         int ok = 0;         for (int j = 1; j <= m; j++) {           if (s[i][j] ==  # ) {             R.push_back(j);             if (!ok)               V = getCol(j), ok = 1;             else {               vector<int> U = getCol(j);               if (U != V) nope = 1;             }           }         }         for (int j : V) {           Viz[j] = 1;           vector<int> Row = getRow(j);           if (R != Row) {             nope = 1;           }         }       }     }     if (nope)       cout <<  No ;     else       cout <<  Yes ;     return 0;   }