malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t, i, j, k, z, x, num[2];     string s;     cin >> t;     while (t--) {       cin >> s;       memset(num, 0, sizeof(num));       for (i = 0; i < s.size(); i++) {         if (s[i] ==  1 )           num[1]++;         else           num[0]++;       }       z = min(num[0], num[1]);       if (z % 2)         cout <<  DA n ;       else         cout <<  NET n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const MAX = 2005;   int mp[MAX][MAX];   int main() {     int n;     bool flag = true;     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) scanf( %d , &mp[i][j]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (mp[i][i] || mp[i][j] != mp[j][i] || (i != j && !mp[i][j])) {           printf( NO n );           return 0;         }       }     }     for (int i = 1; i <= n; i++) {       int u = 1;       for (int j = 1; j <= n; j++) {         if (i == j) continue;         if (mp[i][j] < mp[i][u]) u = j;       }       for (int j = 1; j <= n; j++) {         if (i == j) continue;         if (abs(mp[i][j] - mp[j][u]) != mp[i][u]) {           printf( NO n );           return 0;         }       }     }     printf( YES n );   }
#include <bits/stdc++.h>   using namespace std;   const int MAXPOW = 20;   const int MAXA = 1048577;   const int MAXN = 100009;   const int MAXM = 100009;   const int INF = 1e9 + 7;   struct Node {     Node(int val) : val(val) {}     int val;   };   struct MinIntervalTree {     MinIntervalTree(int n, int val) {       N = 1;       while (N < n) {         N *= 2;       }       nodes.resize(N * 2 + 2, Node(val));     }     int getMin(int L, int R) { return getMin(0, 0, N, L, R + 1); }     void set(int x, int val) { set(0, 0, N, x, val); }       private:     int getMin(int v, int L, int R, int A, int B) {       if (L == A && R == B) {         return nodes[v].val;       }       int M = (L + R) / 2;       if (B <= M) {         return getMin(v * 2 + 1, L, M, A, B);       }       if (A >= M) {         return getMin(v * 2 + 2, M, R, A, B);       }       return min(getMin(v * 2 + 1, L, M, A, M), getMin(v * 2 + 2, M, R, M, B));     }     void set(int v, int L, int R, int P, int val) {       if (L + 1 == R) {         nodes[v] = val;         return;       }       int M = (L + R) / 2;       if (P < M) {         set(v * 2 + 1, L, M, P, val);       } else {         set(v * 2 + 2, M, R, P, val);       }       nodes[v].val = min(nodes[v * 2 + 1].val, nodes[v * 2 + 2].val);     }     int N;     vector<Node> nodes;   };   void testTree() { MinIntervalTree t(10, 1e9); }   int main() {     ios::sync_with_stdio(false);     int n, s, l;     cin >> n >> s >> l;     vector<int> a(n);     vector<int> maxLeft(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];       maxLeft[i] = 0;     }     set<pair<int, int> > aliveUp;     set<pair<int, int> > aliveDown;     for (int i = n - 1; i >= 0; --i) {       {         auto it = aliveUp.lower_bound(make_pair(a[i] + s + 1, 0));         while (it != aliveUp.end()) {           aliveUp.erase(it);           maxLeft[it->second] = max(maxLeft[it->second], i + 1);           it = aliveUp.lower_bound(make_pair(a[i] + s + 1, 0));         }       }       {         auto it = aliveDown.lower_bound(make_pair(-a[i] + s + 1, 0));         while (it != aliveDown.end()) {           aliveDown.erase(it);           maxLeft[it->second] = max(maxLeft[it->second], i + 1);           it = aliveDown.lower_bound(make_pair(-a[i] + s + 1, 0));         }       }       aliveUp.insert(make_pair(a[i], i));       aliveDown.insert(make_pair(-a[i], i));     }     for (int i = 1; i < n; ++i) {       maxLeft[i] = max(maxLeft[i], maxLeft[i - 1]);     }     vector<int> dp(n + 1, 1e9);     MinIntervalTree T(n + 3, 1e9);     dp[0] = 0;     T.set(0, 0);     for (int i = 0; i < n; ++i) {       int L = maxLeft[i] - 1 + 1;       int R = i - l + 1;       if (L > R) {         continue;       }       dp[i + 1] = 1 + T.getMin(L, R);       T.set(i + 1, dp[i + 1]);     }     if (dp[n] >= 1e9) {       cout << -1 << endl;     } else {       cout << dp[n] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     long long x, d, k = 1;     cin >> x >> d;     vector<long long> ans;     while (x) {       long long rem = 0;       for (int i = 31; i >= 0; --i) {         if (x >> i & 1) {           long long tmp = i;           if (i == 0) {             ans.push_back(k);             rem--;           }           while (tmp--) ans.push_back(k);           k += d;           rem++;         }       }       x = rem;     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t, n, k;     cin >> t;     while (t--) {       cin >> n >> k;       long long a[n], b[n], c = 0;       for (int i = 0; i < n; i++) cin >> a[i], b[i] = (a[i] % k);       sort(b, b + n);       reverse(b, b + n);       map<long long, long long> mp;       for (int i = 0; i < n && b[i]; i++)         if (i) {           if (b[i - 1] == b[i])             mp[b[i]] += k;           else             mp[b[i]] = k - b[i] + 1;         } else           mp[b[i]] = k - b[i] + 1;       for (auto &it : mp) c = max(c, it.second);       cout << c <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   map<int, vector<pair<int, int> > > mp;   int n, tt;   int arr[300000];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> arr[i];     for (int r = 1; r <= n; r++) {       long long sum = 0;       for (int l = r; l >= 1; l--) {         sum += arr[l];         mp[sum].push_back(make_pair(l, r));       }     }     map<int, vector<pair<int, int> > >::iterator it;     vector<pair<int, int> > ans;     for (it = mp.begin(); it != mp.end(); it++) {       int sum = 0;       vector<pair<int, int> > &now = it->second;       vector<pair<int, int> > cnt;       int r = -1;       for (int i = 0; i < now.size(); i++) {         if (now[i].first > r)           sum++, r = now[i].second,                  cnt.push_back(make_pair(now[i].first, now[i].second));       }       if (sum > tt) ans = cnt, tt = sum;     }     cout << tt << endl;     for (int i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, v[102], c, g[102], k, S;   int main(void) {     cin >> n >> d;     for (int i = 1; i <= n; i++) cin >> v[i];     for (int i = 1; i < n; i++) {       if (v[i] % 2)         c++;       else         c--;       if (c == 0) g[k++] = abs(v[i] - v[i + 1]);     }     sort(g, g + k);     for (S = 0; S < k && d >= g[S]; S++) d -= g[S];     cout << S;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, m, k;     cin >> n >> m >> k;     if (k > 1) {       if (m == n) {         cout << 2 * k + 1 << endl;         for (int i = (int)(1); i < ((int)k + 1); i++) {           cout << 1 <<    ;         }         cout << n <<    ;         for (int i = (int)(1); i < ((int)k); i++) {           cout << n + 1 <<    ;         }         cout << n + m << endl;       } else {         cout << 2 * k << endl;         for (int i = (int)(1); i < ((int)k + 1); i++) {           cout << 1 <<    ;         }         cout << n <<    ;         for (int i = (int)(1); i < ((int)k); i++) {           cout << n + 1 <<    ;         }         cout << endl;       }     } else {       if (m + 2 <= n) {         cout << 2 << endl;         cout << 1 <<     << n << endl;       } else {         if (n == 2 and m == 2) {           cout << 4 << endl;           cout <<  1 2 3 4  << endl;         } else {           cout << 3 << endl;           cout << 1 <<     << n <<     << 2 * n - 1 << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, ans = 0;   int main() {     cin >> n >> m >> k;     if (n - 1 + m - 1 < k) {       cout << -1 << endl;       return 0;     }     long long buf = sqrt(n);     buf++;     for (int i = 0; i <= buf; i++) {       long long x = n / (i + 1);       if (k - i < 0) continue;       long long y = m / (k - i + 1);       ans = max(ans, x * y);     }     for (int i = 1; i <= buf; i++) {       long long cut = n / i - 1;       if (cut < 0) continue;       long long left = k - cut;       if (left < 0) left = 0;       ans = max(ans, i * (m / (left + 1)));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int N;     cin >> N;     long long int dp_D = 1, dp = 0, dp_temp;     for (int i = 0; i < N; i++) {       dp_temp = dp_D;       dp_D = 3 * dp;       dp = dp * 2 + dp_temp;       dp %= 1000000007;       dp_D %= 1000000007;     }     cout << dp_D << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cal(long long x) { return (x + 1) * (x + 2) >> 1; }   int main() {     int a, b, c, l;     while (scanf( %d%d%d%d , &a, &b, &c, &l) != EOF) {       long long ans = 0;       for (int i = 0; i <= l; i++) ans += 1LL * (i + 1) * (i + 2) / 2;       for (long long i = 0; i <= l; i++) {         if (a + i >= b + c) ans -= cal(min(l - i, a + i - b - c));         if (b + i >= a + c) ans -= cal(min(l - i, b + i - a - c));         if (c + i >= a + b) ans -= cal(min(l - i, c + i - a - b));       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e9 + 3;   long long n, sum;   vector<int> vec;   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = n - 100; i <= n; i++) {       long long x = i;       while (x) {         sum += x % 10;         x /= 10;       }       sum += i;       if (sum == n) vec.push_back(i);       sum = 0;     }     cout << vec.size() << endl;     for (int i = 0; i < vec.size(); i++) cout << vec[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string d[] = { monday ,  tuesday ,   wednesday ,  thursday ,                    friday ,  saturday ,  sunday };     string a, b;     int e, c, g, f, u;     bool o;     cin >> a >> b;     for (int i = 0; i < 7; i++) {       if (a == d[i]) {         e = i;       }       if (b == d[i]) {         c = i;       }     }     u = abs(e - c);     for (int m = 1; m <= 12; m++) {       if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {         g = 4;         f = e - g;         if (f < 0) {           f = 7 - abs(f);         }         if (d[f] == d[c]) {           o = 1;           cout <<  YES ;           break;         } else           o = 0;       } else if (m == 2) {         g = 0;         f = e - g;         if (f < 0) {           f = 7 - abs(f);         }         if (d[f] == d[c]) {           o = 1;           cout <<  YES ;           break;         } else           o = 0;       } else if (m == 4 || m == 6 || m == 9 || m == 1) {         g = 5;         f = e - g;         if (f < 0) {           f = 7 - abs(f);         }         if (d[f] == d[c]) {           o = 1;           cout <<  YES ;           break;         } else           o = 0;       }     }     if (o == 0) {       cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; ++i) {       cin >> arr[i];     }     stack<pair<long long, long long>> s1, s2;     s1.push({0, -1});     long long left[n], right[n];     for (long long i = 0; i < n; ++i) {       while (s1.top().first >= arr[i]) s1.pop();       left[i] = s1.top().second + 1;       s1.push({arr[i], i});     }     s2.push({0, n});     for (long long i = n - 1; i >= 0; --i) {       while (s2.top().first >= arr[i]) s2.pop();       right[i] = s2.top().second - 1;       s2.push({arr[i], i});     }     long long ans[n + 1];     memset(ans, 0, sizeof(ans));     for (long long i = 0; i < n; ++i) {       ans[right[i] - left[i] + 1] = max(arr[i], ans[right[i] - left[i] + 1]);     }     for (long long i = n - 1; i >= 1; --i) {       if (ans[i] < ans[i + 1]) ans[i] = ans[i + 1];     }     for (long long i = 0; i < n; ++i) {       cout << ans[i + 1] <<    ;     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, cnt = 1;   string s;   bool ok = true, mtest = true;   void solve() {     cin >> b;     vector<int> v(b), vc(b);     for (auto& i : v) cin >> i;     for (auto& i : vc) cin >> i;     sort(v.begin(), v.end());     sort(vc.begin(), vc.end());     for (auto i : v) cout << i <<    ;     cout <<   n ;     for (auto i : vc) cout << i <<    ;     cout <<   n ;   }   int main() {     cin >> a;     while (a--) solve();     cerr <<   nTime elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n;     vector<int> a(n);     vector<pair<int, int> > d;     for (int i = 0; i < n; i++) {       cin >> a[i];       d.push_back(make_pair(a[i], 0));     }     cin >> m;     vector<int> b(m);     vector<pair<int, int> > c(n + m);     vector<pair<int, int> > sum(n + m, make_pair(0, 0));     for (int i = 0; i < m; i++) {       cin >> b[i];       d.push_back(make_pair(b[i], 1));     }     sort(d.begin(), d.end());     int tog = 0;     if (d[0].second)       sum[0].second = 1;     else       sum[0].first = 1;     for (int i = 0; i < n + m; i++) {       if (i > 0) {         sum[i].first = sum[i - 1].first;         sum[i].second = sum[i - 1].second;       }       if (!d[i].second) {         tog++;         if (i > 0) sum[i].first++;       } else {         tog--;         if (i > 0) sum[i].second++;       }       c[i].first = tog;       c[i].second = i;     }     sort(c.begin(), c.end());     if (c[0].first < 0)       cout << 3 * n - sum[c[0].second].first <<  :             << 3 * m - sum[c[0].second].second << endl;     else       cout << 3 * n <<  :  << 3 * m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1, M = 1e9 + 7;   mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());   int n, q, bit[N], inv[N], a[N], last[N], INVER[N], ans[N];   bool prime[N];   vector<int> v[N];   struct query {     int l, r, id;     void sc(int temp) {       scanf( %d%d , &l, &r);       id = temp;     }   } Q[N];   int power(int base, int to) {     int ret = 1;     while (to) {       if (to & 1) ret = ret * 1LL * base % M;       to >>= 1;       base = base * 1LL * base % M;     }     return ret;   }   int INV(int a) {     if (INVER[a] != -1) return INVER[a];     return INVER[a] = power(a, M - 2);   }   void add(int at, int *bit, int val) {     for (; at < N; at += (-at) & at) bit[at] = bit[at] * 1LL * val % M;   }   int get(int at, int *bit) {     int ret = 1;     for (; at; at -= at & (-at)) ret = ret * 1LL * bit[at] % M;     return ret;   }   int main() {     for (int i = 0; i < N; i++) bit[i] = inv[i] = 1;     memset(last, -1, sizeof last);     memset(INVER, -1, sizeof INVER);     scanf( %d , &n);     for (int i = 2; i < N; i++)       if (!prime[i]) {         for (int j = i; j < N; j += i) {           prime[j] = 1;           v[j].push_back(i);         }       }     for (int i = 1; i <= n; i++) scanf( %d , a + i);     scanf( %d , &q);     for (int i = 0; i < q; i++) Q[i].sc(i);     sort(Q, Q + q, [&](query a, query b) { return a.r < b.r; });     int j = 1;     for (int i = 0; i < q; i++) {       while (j <= Q[i].r) {         add(j, bit, a[j]);         add(j, inv, INV(a[j]));         for (auto k : v[a[j]]) {           if (last[k] != -1) {             add(last[k], bit, INV(k - 1) * 1LL * k % M);             add(last[k], inv, (k - 1LL) * INV(k) % M);           }           last[k] = j;           add(last[k], bit, (k - 1LL) * INV(k) % M);           add(last[k], inv, k * 1LL * INV(k - 1) % M);         }         j++;       }       ans[Q[i].id] = get(Q[i].r, bit);       ans[Q[i].id] = ans[Q[i].id] * 1LL * get(Q[i].l - 1, inv) % M;     }     for (int i = 0; i < q; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int ans[300005];   int main() {     int n, m;     scanf( %d%d , &n, &m);     set<int> alive;     for (int i = 1; i <= n; i++) alive.insert(i);     for (int i = 0; i < m; i++) {       int l, r, x;       scanf( %d%d%d , &l, &r, &x);       set<int>::iterator it = alive.lower_bound(l);       vector<int> dead;       while (it != alive.end()) {         int now = *it;         if (now > r) break;         if (now != x) dead.push_back(now), ans[now] = x;         it++;       }       for (int j = 0; j < (int)((dead).size()); j++) alive.erase(dead[j]);     }     for (int i = 1; i <= n; i++) printf( %d%c , ans[i], i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, long long> da;   inline long long p(long long x) { return x * x * x; }   long long m;   void dfs(long long now, int sum, long long maxnum) {     if (!now)       da = max(da, make_pair(sum, maxnum));     else {       long long i = 1;       for (; p(i + 1) <= now; ++i)         ;       dfs(now - p(i), sum + 1, maxnum + p(i));       if (now) dfs(p(i) - p(i - 1) - 1, sum + 1, maxnum + p(i - 1));     }   }   int main() {     scanf( %lld , &m);     dfs(m, 0, 0);     printf( %d %lld , da.first, da.second);   }
#include <bits/stdc++.h>   std::map<std::string, std::string> opcodes;   std::string next(std::string s) {     std::string res = s;     res[res.size() - 1]++;     for (int i = (int)res.size() - 1; i >= 0; i--) {       if (res[i] >  f ) {         res[i] =  a ;         res[i - 1]++;       }     }     return res;   }   int check(std::string s) {     if (s.size() == 1) return !!(s[0] ==  a );     std::string f = s.substr(0, 2);     s.erase(0, 2);     auto it = opcodes.find(f);     if (it == opcodes.end()) return 0;     s = it->second + s;     return check(s);   }   int main() {     std::ios_base::sync_with_stdio(0);     int n, q;     std::cin >> n >> q;     std::string str =   , fff, a, b;     for (int i = 0; i < n; i++) str.push_back( a );     for (int i = 0; i < n; i++) fff.push_back( f );     for (int i = 0; i < q; i++) {       std::cin >> a >> b;       opcodes[a] = b;     }     int ans = 0;     while (true) {       ans += check(str);       if (str == fff)         break;       else         str = next(str);     }     std::cout << ans << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1e9 + 7;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     long long int a[n];     for (long long int i = 0; i < n; i++) {       cin >> a[i];     }     if (n == 1) {       cout << 1 <<   n ;       return 0;     }     long long int pre[n + 5];     long long int suf[n + 5];     long long int ans = 1;     pre[0] = 1;     suf[n - 1] = 1;     for (long long int i = 1; i < n; i++) {       if (a[i] > a[i - 1]) {         pre[i] = pre[i - 1];         pre[i]++;       } else {         pre[i] = 1;       }       ans = max(pre[i], ans);     }     for (long long int i = n - 2; i >= 0; i--) {       if (a[i] < a[i + 1]) {         suf[i] = suf[i + 1];         suf[i]++;       } else {         suf[i] = 1;       }       ans = max(pre[i], ans);     }     for (long long int i = 1; i + 1 < n; i++) {       if (a[i + 1] - a[i - 1] >= 2) {         ans = max(ans, 1 + pre[i - 1] + suf[i + 1]);       }       ans = max(ans, 1 + pre[i - 1]);       ans = max(ans, 1 + suf[i + 1]);     }     ans = max(ans, 1 + suf[1]);     ans = max(ans, 1 + pre[n - 2]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   const int mod = 1e9 + 7;   const int N = 1e6 + 10;   const long long INF = 1e18;   long long power(long long x, long long y) {     long long t = 1;     while (y > 0) {       if (y % 2)         y -= 1, t = t * x % mod;       else         y /= 2, x = x * x % mod;     }     return t;   }   vector<int> G[N];   vector<long long> snd[N];   long long sub[N], sum[N], red[N], dol[N];   long long mns[N], mxs[N];   int lol[N];   vector<pair<int, pair<long long, long long> > > edges;   void done() {     printf( -1 n );     exit(0);   }   void dfs(int v) {     for (int i = 0; i < G[v].size(); ++i) {       int ed = G[v][i];       dfs(edges[ed].first);       long long &w = edges[ed].second.first, &p = edges[ed].second.second;       if (mns[edges[ed].first] > p) done();       long long z = min(w - 1, p - mns[edges[ed].first]);       mns[v] += mns[edges[ed].first] + w - z;       snd[v].push_back(mns[edges[ed].first] + w - z);       mxs[v] += w + min(p, mxs[edges[ed].first]);       assert(mns[v] <= mxs[v]);     }   }   void dfs1(int v, long long nd) {     for (int i = 0; i < G[v].size(); ++i) nd -= snd[v][i];     for (int i = 0; i < G[v].size(); ++i) {       int ed = G[v][i], to = edges[ed].first;       long long &w = edges[ed].second.first, &p = edges[ed].second.second;       long long z = min(w - 1, p - mns[edges[ed].first]);       w -= z;       p -= z;       long long k = min(nd, z);       w += k;       p += k;       nd -= k;       k = min(min(nd, p - mns[edges[ed].first]),               mxs[edges[ed].first] - mns[edges[ed].first]);       dfs1(to, mns[edges[ed].first] + k);       nd -= k;     }     assert(nd == 0);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; ++i) {       int x, y;       long long w, p;       scanf( %d%d%lld%lld , &x, &y, &w, &p);       x--;       y--;       G[x].push_back(edges.size());       lol[i] = x;       edges.push_back(make_pair(y, make_pair(w, p)));     }     dfs(0);     dfs1(0, mxs[0]);     printf( %d n , n);     for (int i = 0; i < n - 1; ++i) {       printf( %d %d %lld %lld n , lol[i] + 1, edges[i].first + 1,              edges[i].second.first, edges[i].second.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 5005;   const int MOD = 998244353;   const int MX = 3e5 + 5;   const long long INF = 1e18;   const long double PI = acos((long double)-1);   void msm() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);   }   int sol();   int main() {     msm();     sol();     return 0;   }   int sol() {     long long n;     cin >> n;     ;     long long ar[105], arr[105][5005];     for (long long i = (0); i < (n); ++i) {       long long a;       cin >> a;       ;       ar[a]++;       arr[a][ar[a]] = i + 1;     }     long long y = min(ar[1], min(ar[2], ar[3]));     cout << y << endl;     for (long long i = (1); i <= (y); ++i)       cout << arr[1][i] <<     << arr[2][i] <<     << arr[3][i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, d, l;   int main() {     cin >> n >> d >> m >> l;     long long x = 0;     for (long long i = 0; i < n; i++) {       if (x < i * m) {         break;       }       while (x <= i * m + l) x = (((i * m + l) / d) + 1) * d;     }     cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1E9;   int main() {     int n;     string s;     cin >> n >> s;     for (int len = 1; len <= n; len++) {       bool ok = true;       for (int i = 0; i < n; i++) {         if (i + len * 4 < n && s[i] ==  *  && s[i] == s[i + len] &&             s[i] == s[i + len + len] && s[i] == s[i + len * 3] &&             s[i] == s[i + len * 4]) {           ok = 0;           break;         }       }       if (!ok) {         puts( yes );         return 0;       }     }     puts( no );     return 0;   }