malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, count = 0;     vector<int> vect, keep;     cin >> n;     while (n != 0) {       keep.push_back(n % 10);       n = n / 10;       ++count;     }     reverse(keep.begin(), keep.end());     for (auto itr = keep.begin(); itr != keep.end(); itr++) {       int num = pow(10, count - 1);       int k;       vector<int>::iterator itc;       for (itc = vect.begin(), k = *itr; itc != vect.end() && k > 0; itc++, k--) {         *itc = *itc + num;       }       if (k > 0) {         while (k--) {           vect.push_back(num);         }       }       count--;     }     cout << vect.size() << endl;     for (auto itr = vect.begin(); itr != vect.end(); itr++) cout << *itr <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct QUERY {     int query, time, number;   };   vector<map<int, int> > tree;   void update(int v, int tl, int tr, int pos, int query, int value) {     int tm = (tl + tr) / 2;     if (query == 1) {       if (tl == tr) return;       tree[v][value]++;       if (pos <= tm)         update(2 * v, tl, tm, pos, query, value);       else         update(2 * v + 1, tm + 1, tr, pos, query, value);     } else if (query == 2) {       if (tl == tr) return;       tree[v][value]--;       if (pos <= tm)         update(2 * v, tl, tm, pos, query, value);       else         update(2 * v + 1, tm + 1, tr, pos, query, value);     }   }   int sum(vector<map<int, int> > &tree, int v, int tl, int tr, int i, int j,           int value) {     if (i > tr || j < tl) return 0;     if (tl == i && tr == j) return tree[v][value];     int tm = (tl + tr) / 2;     return sum(tree, 2 * v, tl, (tr + tl) / 2, i, min(j, tm), value) +            sum(tree, 2 * v + 1, (tr + tl) / 2 + 1, tr, max(i, tm + 1), j, value);   }   int main() {     int n;     cin >> n;     vector<QUERY> a(n + 1);     vector<int> num(n + 1);     vector<int> t(n + 1);     for (int i = 1; i <= n; ++i) {       cin >> a[i].query >> a[i].time >> a[i].number;       num[i] = a[i].number;       t[i] = a[i].time;     }     sort(num.begin(), num.end());     num.erase(unique(num.begin(), num.end()), num.end());     sort(t.begin(), t.end());     t.erase(unique(t.begin(), t.end()), t.end());     map<int, int> help;     for (unsigned int i = 1; i < num.size(); ++i) {       help.insert(make_pair(num[i], i));     }     for (int i = 1; i <= n; ++i) {       a[i].number = help[a[i].number];     }     help.clear();     for (unsigned int i = 1; i < t.size(); ++i) {       help.insert(make_pair(t[i], i));     }     for (int i = 1; i <= n; ++i) {       a[i].time = help[a[i].time];     }     int len = t.size() - 1;     int tree_size = 4 * len;     tree.resize(tree_size);     for (int i = 1; i <= n; ++i) {       if (a[i].query != 3)         update(1, 1, len, a[i].time, a[i].query, a[i].number);       else         cout << sum(tree, 1, 1, len, 1, a[i].time, a[i].number) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1010;   set<int> X, Y;   int n, m;   char st[maxn][maxn], sz[maxn][maxn];   bool fill(int x1, int y1, int x2, int y2) {     int i;     for (i = x1; i <= x2; ++i) {       if (st[i][y1] ==  . ) return 0;       if (st[i][y2] ==  . ) return 0;       sz[i][y1] = sz[i][y2] =  # ;     }     for (i = y1; i <= y2; ++i) {       if (st[x1][i] ==  . ) return 0;       if (st[x2][i] ==  . ) return 0;       sz[x1][i] = sz[x2][i] =  # ;     }     return true;   }   int main() {     int i, j;     scanf( %d %d n , &n, &m);     for (i = 1; i <= n; ++i) scanf( %s , st[i] + 1);     for (i = 1; i <= n; ++i)       for (j = 1; j <= m; ++j) {         if (st[i][j - 1] ==  #  && st[i][j] ==  #  && st[i][j + 1] ==  # )           X.insert(i);         if (st[i - 1][j] ==  #  && st[i][j] ==  #  && st[i + 1][j] ==  # )           Y.insert(j);       }     if (X.size() > 4) X.erase(++ ++X.begin(), -- --X.end());     if (Y.size() > 4) Y.erase(++ ++Y.begin(), -- --Y.end());     for (set<int>::iterator x1 = X.begin(); x1 != X.end(); ++x1)       for (set<int>::iterator x2 = X.begin(); x2 != X.end(); ++x2)         for (set<int>::iterator x3 = X.begin(); x3 != X.end(); ++x3)           for (set<int>::iterator x4 = X.begin(); x4 != X.end(); ++x4)             for (set<int>::iterator y1 = Y.begin(); y1 != Y.end(); ++y1)               for (set<int>::iterator y2 = Y.begin(); y2 != Y.end(); ++y2)                 for (set<int>::iterator y3 = Y.begin(); y3 != Y.end(); ++y3)                   for (set<int>::iterator y4 = Y.begin(); y4 != Y.end(); ++y4)                     if (*x1 + 1 < *x2 && *x3 + 1 < *x4 && *y1 + 1 < *y2 &&                         *y3 + 1 < *y4) {                       memset(sz,  . , sizeof(sz));                       if (fill(*x1, *y1, *x2, *y2) && fill(*x3, *y3, *x4, *y4)) {                         bool ok = true;                         for (i = 1; i <= n; ++i)                           for (j = 1; j <= m; ++j)                             if (st[i][j] != sz[i][j]) ok = false;                         if (ok) {                           printf( YES n );                           printf( %d %d %d %d n , *x1, *y1, *x2, *y2);                           printf( %d %d %d %d n , *x3, *y3, *x4, *y4);                           return 0;                         }                       }                     }     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   int s, k;   long long f[1000], res[1000];   int main() {     scanf( %d %d , &s, &k);     f[0] = 0;     f[1] = 1;     int i;     for (i = 2; f[i - 1] <= s; i++)       for (int j = 1; i - j > 0 && j <= k; j++) f[i] += f[i - j];     int cnt = 0;     for (i = i - 1; i >= 0; i--)       if (f[i] <= s) {         s -= f[i];         res[cnt++] = f[i];       }     printf( %d n , cnt);     for (int i = 0; i < cnt; i++) printf( %d  , res[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int w, h, h1, w1, h2, w2;     cin >> w >> h >> w1 >> h1 >> w2 >> h2;     for (int i = h; i >= 0; i--) {       w += i;       if (i == h1) w -= w1;       if (i == h2) w -= w2;       if (w < 0) w = 0;     }     cout << w << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, cnt, num, sub_d[(2600)], d[(2600)], root, cut[(2600)], t;   char s[55][55];   bool mark[(2600)], p, cycle;   vector<long long> e[(2600)];   void dfs(long long x, long long par = 0) {     bool tmp = 0;     if (!t) cnt++;     mark[x] = 1;     sub_d[x] = d[x];     for (int i = 0; i < e[x].size(); i++) {       if (mark[e[x][i]] && e[x][i] != par) cycle = 1;       if (!mark[e[x][i]]) {         d[e[x][i]] = d[x] + 1;         dfs(e[x][i], x);         sub_d[x] = min(sub_d[x], sub_d[e[x][i]]);         if (sub_d[e[x][i]] >= d[x]) tmp = 1;       } else if (e[x][i] != par)         sub_d[x] = min(sub_d[x], d[e[x][i]]);     }     cut[x] += tmp;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> s[i][j];         if (s[i][j] ==  # ) num++;       }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         for (int p = -1; p <= 1; p++)           for (int q = -1; q <= 1; q++)             if ((!p ^ !q) && i + p >= 0 && j + q >= 0 && i + p < n && j + q < m &&                 s[i][j] ==  #  && s[i + p][j + q] ==  # )               e[i * m + j].push_back((i + p) * m + j + q);     for (int i = 0; i < n * m && t < 2; i++)       if (s[i / m][i % m] ==  # ) {         for (int j = 0; j < n * m; j++) mark[j] = d[j] = sub_d[j] = 0;         root = i;         dfs(i);         t++;       }     for (int i = 0; i < n * m; i++)       if (cut[i] == 2) p = 1;     if (p)       cout << 1;     else if (cnt != num)       cout << 0;     else if (cycle)       cout << 2;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using ll = long long int;   int main() {     int n, m;     std::cin >> n >> m;     std::vector<std::vector<int>> matr1(n);     std::vector<std::vector<int>> matr2(n);     std::vector<std::vector<int>> matr_min(n);     std::vector<std::vector<int>> matr_max(n);     for (int i = 0; i < n; i++) {       matr1[i].resize(m);       matr2[i].resize(m);       matr_min[i].resize(m);       matr_max[i].resize(m);     }     for (int i = 0; i < n; i++) {       for (auto &it : matr1[i]) {         std::cin >> it;       }     }     for (int i = 0; i < n; i++) {       for (auto &it : matr2[i]) {         std::cin >> it;       }     }     for (int i = 0; i < n; i++) {       for (int z = 0; z < m; z++) {         matr_min[i][z] = std::min(matr1[i][z], matr2[i][z]);         matr_max[i][z] = std::max(matr1[i][z], matr2[i][z]);       }     }     for (int i = 0; i < n; i++) {       for (int z = 0; z < m; z++) {         if (z - 1 >= 0 && matr_min[i][z - 1] >= matr_min[i][z]) {           std::cout <<  Impossible  << std::endl;           return 0;         }         if (i - 1 >= 0 && matr_min[i - 1][z] >= matr_min[i][z]) {           std::cout <<  Impossible  << std::endl;           return 0;         }         if (z - 1 >= 0 && matr_max[i][z - 1] >= matr_max[i][z]) {           std::cout <<  Impossible  << std::endl;           return 0;         }         if (i - 1 >= 0 && matr_max[i - 1][z] >= matr_max[i][z]) {           std::cout <<  Impossible  << std::endl;           return 0;         }       }     }     std::cout <<  Possible  << std::endl;   }
#include <bits/stdc++.h>   using namespace std;   int ans[15];   int n, q;   string in;   string tmp;   void go(int l, int r) {     tmp =     + in.substr(l - 1, r - l + 1);     string::iterator cp = tmp.begin() + 1;     int dp = 1;     while (cp != tmp.begin() && cp != tmp.end()) {       if (*cp >=  0  && *cp <=  9 ) {         ans[*cp -  0 ]++;         *cp -= 1;         if (*cp ==  0  - 1) {           tmp.erase(cp);           if (dp == -1) cp--;         } else           cp += dp;       } else {         if (*cp ==  < )           dp = -1;         else           dp = 1;         if (*(cp + dp) ==  <  || *(cp + dp) ==  > ) {           tmp.erase(cp);           if (dp == -1) cp--;         } else           cp = cp + dp;       }     }   }   int main() {     scanf( %d %d , &n, &q);     cin >> in;     for (int tt = 0; tt < q; tt++) {       int l, r;       memset(ans, 0, sizeof(ans));       scanf( %d %d , &l, &r);       go(l, r);       for (int i = 0; i < 10; i++) printf( %d  , ans[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string to_string(char c) { return string(1, c); }   string to_string(bool b) { return b ?  true  :  false ; }   string to_string(const char* s) { return (string)s; }   string to_string(string s) { return s; }   template <class A>   string to_string(complex<A> c) {     stringstream ss;     ss << c;     return ss.str();   }   string to_string(vector<bool> v) {     string res =  { ;     for (int i = 0; i < (int)v.size(); i++) res += char( 0  + v[i]);     res +=  } ;     return res;   }   template <size_t SZ>   string to_string(bitset<SZ> b) {     string res =   ;     for (size_t i = 0; i < SZ; i++) res += char( 0  + b[i]);     return res;   }   template <class A, class B>   string to_string(pair<A, B> p);   template <class T>   string to_string(T v) {     bool fst = 1;     string res =  { ;     for (const auto& x : v) {       if (!fst) res +=  ,  ;       fst = 0;       res += to_string(x);     }     res +=  } ;     return res;   }   template <class A, class B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   void DBG() { cerr <<  ]  << endl; }   template <class H, class... T>   void DBG(H h, T... t) {     cerr << to_string(h);     if (sizeof...(t)) cerr <<  ,  ;     DBG(t...);   }   inline void test_case() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int l = a[0];     int r = a[n - 1];     n = a.size();     int negah = 0;     for (int& i : a) {       if (i < negah) {         cout <<  NO  <<   n ;         return;       }       if (i > l && i - l > negah) {         negah = i - l;         i -= l;       } else {         l = min(l, i - negah);         i -= l;       }     }     reverse((a).begin(), (a).end());     for (int& i : a) {       r = min(r, i);       i = max(i - r, 0);     }     if (count((a).begin(), (a).end(), 0) == (int)a.size()) {       cout <<  YES  <<   n ;     } else {       cout <<  NO  <<   n ;     }   }   int main() {     ios::sync_with_stdio(0);     int tt;     cin >> tt;     while (tt--) {       test_case();     }   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   int m, n;   pii a[100001];   vector<int> adj[100001];   bool is_chosen[100001];   bool is_visited[100001];   int cnt = 0;   template <typename T>   inline T read() {     T x = 0;     T multiplier = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) {         multiplier = -1;       }       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch & 15);       ch = getchar();     }     return x * multiplier;   }   void dfs(int u, int prt) {     if (is_chosen[a[u].first] && is_chosen[a[u].second]) {       return;     }     if (is_visited[u]) {       return;     }     is_visited[u] = true;     bool x = is_chosen[a[u].first], y = is_chosen[a[u].second];     if (!x) {       is_chosen[a[u].first] = true;       is_chosen[a[u].second] = true;       for (auto v : adj[a[u].first]) {         if (v != prt) {           dfs(v, u);         }       }     }     if (!y) {       is_chosen[a[u].first] = true;       is_chosen[a[u].second] = true;       for (auto v : adj[a[u].second]) {         if (v != prt) {           dfs(v, u);         }       }     }     is_chosen[a[u].first] = true;     is_chosen[a[u].second] = true;   }   int main() {     n = read<int>(), m = read<int>();     for (int i = 1; i <= m; i++) {       a[i].first = read<int>();       a[i].second = read<int>();     }     sort(a + 1, a + m + 1);     for (int i = 1; i <= m; i++) {       adj[a[i].first].push_back(i);       adj[a[i].second].push_back(i);     }     for (int i = 1; i <= m; i++) {       if (!is_visited[i]) {         dfs(i, -1);       }     }     for (int i = 1; i <= m; i++) {       cnt += !is_visited[i];     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long n;     cin >> n;     long long result = 1;     long long x = n;     for (long long i = 2; i * i <= x; ++i) {       if (n % i == 0) {         result *= i;         while (n % i == 0) n /= i;       }     }     result *= n;     cout << result << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[100005], vis[100005], cnt, t;   void Solve() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (!vis[a[i]]) cnt++;       ++vis[a[i]];       if (cnt == k) {         t = 1;         while (cnt == k) {           --vis[a[t]];           if (!vis[a[t]]) --cnt;           t++;         }         printf( %d %d n , t - 1, i);         return;       }     }     printf( -1 -1 n );   }   int main(void) {     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[200010];   int n;   bool query(int x) {     int t = -1, l = -1;     for (int i = 0; i < n; i++) {       l--;       if (s[i] ==  . ) continue;       if (s[i] ==  P ) {         if (t == -1) t = i;         int tmp = max(x - (i - t) * 2, (x - (i - t)) / 2);         l = max(tmp, l);         if (i - t > x) return 0;         t = -1;       }       if (s[i] ==  * ) {         if (l >= 0) continue;         if (t == -1) t = i;       }     }     if (t != -1) return 0;     return 1;   }   int bs(int l, int r) {     if (l == r) return l;     int m = (l + r) / 2;     if (query(m))       return bs(l, m);     else       return bs(m + 1, r);   }   int main() {     cin >> n;     scanf( %s , s);     cout << bs(0, n * 2) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, sgn = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) sgn = -1;     for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);     return x * sgn;   }   const int N = 1e5 + 10;   int n;   long long ans1, ans2;   struct line {     int x, y, l, r;   } seg[N];   bool cmp1(line a, line b) { return a.x < b.x; }   bool cmp2(line a, line b) { return a.y < b.y; }   struct BITT {     int arr[N << 1];     void add(int x, int v = 1) {       for (; x <= (n * 2); x += x & -x) arr[x] += v;       return;     }     int q(int x, int v = 0) {       for (; x; x -= x & -x) v += arr[x];       return v;     }     void clear() { memset(arr, 0, sizeof(arr)); }   } BIT;   int main() {     n = read();     for (int i = 1; i <= n; i++) seg[i].x = read(), seg[i].y = read();     for (int i = 1; i <= n; i++)       if (seg[i].x > seg[i].y) swap(seg[i].x, seg[i].y);     sort(seg + 1, seg + n + 1, cmp1);     for (int i = 1; i <= n; i++) {       seg[i].l += BIT.q(seg[i].x) + BIT.q(n << 1) - BIT.q(seg[i].y);       BIT.add(seg[i].y);     }     BIT.clear();     for (int i = n; i >= 1; i--) {       seg[i].r += BIT.q(seg[i].y);       BIT.add(seg[i].y);     }     BIT.clear();     sort(seg + 1, seg + n + 1, cmp2);     for (int i = n; i >= 1; i--) {       seg[i].l += BIT.q(n << 1) - BIT.q(seg[i].y);       BIT.add(seg[i].x);     }     ans1 = 1ll * n * (n - 1) * (n - 2) / 6;     for (int i = 1; i <= n; i++) {       ans1 -= 1ll * seg[i].l * seg[i].r;       ans2 += 1ll * (seg[i].l + seg[i].r) * (n - seg[i].l - seg[i].r - 1);     }     printf( %lld n , ans1 - ans2 / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   const long long mod = 1e9 + 7;   void solve();   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long tests = 1;     while (tests--) solve();     return 0;   }   void solve() {     long long n;     cin >> n;     pair<long long, long long> a[n];     for (long long i = 0; i < n; i++) {       cin >> a[i].second;       long long x = a[i].second;       long long cnt = 0;       while (x % 3 == 0) {         x = x / 3;         ++cnt;       }       a[i].first = -cnt;     }     sort(a, a + n);     for (long long i = 0; i < n; i++) {       cout << a[i].second <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const long long INF = 1e9 + 19;   int n;   pair<long long, long long> b[N];   long long T;   void read() {     scanf( %d , &n);     long long w;     scanf( %lld%lld , &T, &w);     n--;     for (int i = 0; i < n; i++) {       scanf( %lld%lld , &b[i].first, &b[i].second);     }   }   void solve() {     sort(b, b + n, greater<pair<long long, long long>>());     multiset<long long> q;     int answer = INF;     int rem = 0;     int cur = 0;     for (;;) {       for (; cur < n && b[cur].first > T; cur++) {         q.insert(b[cur].second - b[cur].first + 1);       }       answer = min(answer, cur - rem);       if (q.empty()) break;       long long x = *q.begin();       if (T >= x) {         T -= x;         rem++;         q.erase(q.begin());       } else         break;     }     cout << answer + 1 << endl;   }   void stress() {}   int main() {     if (1) {       int k = 1;       for (int tt = 0; tt < k; tt++) {         read();         solve();       }     } else {       stress();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout.precision(10);     int n;     cin >> n;     if (n % 2) {       cout <<  black n ;     } else {       cout <<  white n ;       cout << 1 <<     << 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 10, inf = 1e18, mod = 1e9 + 7;   long long a[N], b[N], q[N], q2[N];   unordered_map<int, int> mp;   vector<long long> cmp;   struct node {     int l, r, col = 0;     int size() { return r - l; }     int unity(int lq, int rq) { return max(0, min(r, rq) - max(l, lq)); }     bool init(int lq, int rq) { return unity(lq, rq) == size(); }     bool leaf() { return size() == 1; }   };   node seg[4 * N];   void build(int v, int l, int r) {     seg[v].l = l;     seg[v].r = r;     if (seg[v].leaf()) return;     int mid = (l + r) / 2;     build(2 * v, l, mid);     build(2 * v + 1, mid, r);   }   void add(int v, int l, int r, int cl) {     if (!seg[v].unity(l, r)) return;     if (seg[v].init(l, r)) {       seg[v].col = cl;       return;     }     add(v * 2, l, r, cl);     add(v * 2 + 1, l, r, cl);   }   int get(int v, int ind) {     if (!seg[v].unity(ind, ind + 1)) return 0;     if (seg[v].leaf()) {       return seg[v].col;     }     return max(max(get(v * 2, ind), get(v * 2 + 1, ind)), seg[v].col);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     long long id = 1;     build(1, 1, n + 1);     for (int i = 0; i < m; i++) {       int tp;       cin >> tp;       if (tp == 1) {         long long x, y, k;         cin >> x >> y >> k;         q[id] = x;         q2[id] = y;         add(1, y, y + k, id);         id++;       } else {         long long ind;         cin >> ind;         long long c = get(1, ind);         if (c == 0)           cout << b[ind] <<   n ;         else {           long long x = q[c], y = q2[c];           cout << a[x + ind - y] <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, x;     cin >> n >> x;     set<long long> s;     long long a;     for (long long i = 0; i < n; i++) {       cin >> a;       s.insert(a);     }     for (auto it = s.begin(); it != s.end(); it++) {       if (*it <= x)         x++;       else {         if (x + 1 == *it) x++;       }     }     cout << x <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long test;     cin >> test;     while (test--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, flow[200100][2], dtion[200100], Eg[200100];   bool vis[200100];   queue<int> q;   struct node {     int v, d, i;     node *next;   } edge[200100 * 2];   node *cnt = &edge[0];   node *adj[200100];   void Addedge(int u, int v, int d, int i) {     node *p = ++cnt;     p->v = v;     p->d = d;     p->i = i;     p->next = adj[u];     adj[u] = p;   }   void Solve() {     int u, v, d;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &Eg[i], &v, &d);       Addedge(Eg[i], v, d, i);       flow[Eg[i]][0] += d;       Addedge(v, Eg[i], d, i);       flow[v][0] += d;     }     q.push(1);     vis[1] = true;     while (!q.empty()) {       u = q.front();       q.pop();       for (node *p = adj[u]; p; p = p->next) {         v = p->v;         d = p->d;         if (vis[v]) continue;         dtion[p->i] = u;         flow[v][1] += d;         flow[v][0] -= d;         if (v != n && flow[v][1] == flow[v][0]) {           vis[v] = true;           q.push(v);         }       }     }     for (int i = 1; i <= m; i++) {       if (dtion[i] == Eg[i])         printf( 0 n );       else         printf( 1 n );     }   }   int main() {     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int maxn = 1e5 + 5;   long long a[15], b[15];   int main() {     for (int i = 0; i < 14; ++i) {       cin >> a[i];     }     long long ans = 0;     for (int i = 0; i < 14; ++i) {       if (a[i] == 0) continue;       for (int j = 0; j < 14; ++j) b[j] = a[j];       b[i] = 0;       for (int j = 0; j < 14; ++j) b[j] += a[i] / 14;       long long tmp = a[i] % 14;       int now = (i + 1) % 14;       while (tmp--) {         ++b[now];         now = (now + 1) % 14;       }       long long ans1 = 0;       for (int j = 0; j < 14; ++j) {         if (b[j] & 1) continue;         ans1 += b[j];       }       ans = max(ans, ans1);     }     cout << ans << endl;     return 0;   }