malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<   n ;     err(++it, args...);   }   long long powMod(long long x, long long y) {     long long p = 1;     while (y) {       if (y % 2) {         p = (p * (x % ((long long)1e9 + 7))) % ((long long)1e9 + 7);       }       y /= 2;       x = ((x % ((long long)1e9 + 7)) * (x % ((long long)1e9 + 7))) %           ((long long)1e9 + 7);     }     return p;   }   long long CpowMod(long long x, long long y, long long w) {     long long p = 1;     while (y) {       if (y % 2) {         p = (p * (x % w)) % w;       }       y /= 2;       x = ((x % w) * (x % w)) % w;     }     return p;   }   long long invMod(long long x) { return powMod(x, ((long long)1e9 + 7) - 2); }   long long CinvMod(long long x, long long w) { return CpowMod(x, w - 2, w); }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long totLeaf;   vector<set<long long> > edges;   long long bud = -1;   long long n;   void removeEdge(long long x, long long y) {     {};     edges[x].erase(y);   }   void dfs(long long node, long long par) {     for (auto &it : edges[node]) {       if (it != par) {         dfs(it, node);       }     }     long long cnt = 0;     for (auto &it : edges[node]) {       if (it == par || edges[it].count(node) == 0) {         continue;       }       cnt++;     }     if (cnt) {       totLeaf += cnt;       bud++;       removeEdge(node, par);     }   }   void solve() {     long long T;     cin >> T;     while (T--) {       totLeaf = 0;       bud = -1;       cin >> n;       edges = vector<set<long long> >(n + 1);       for (long long i = 0; i <= n - 2; i++) {         long long x, y;         cin >> x >> y;         edges[x].insert(y);         edges[y].insert(x);       }       dfs(1, 0);       cout << totLeaf - (bud) <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.precision(10);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 5;   const int N = 1e4 + 5;   const int inf = 0x3f3f3f3f;   struct hor {     int x1, x2, y;     bool operator<(const hor& a) const { return y < a.y; }   } h[maxn];   struct ver {     int y1, y2, x;     bool operator<(const ver& a) const { return y1 < a.y1; }   } v[maxn];   int n, cntv, cnth;   int c[N];   int lowbit(int x) { return x & (-x); }   int sum(int x) {     int ans = 0;     for (int i = x; i > 0; i -= lowbit(i)) ans += c[i];     return ans;   }   int get_sum(int l, int r) { return sum(r) - sum(l - 1); }   void update(int x, int val) {     for (int i = x; i <= N; i += lowbit(i)) c[i] += val;   }   int main() {     scanf( %d , &n);     cntv = cnth = 0;     for (int i = 1; i <= n; ++i) {       int x1, y1, x2, y2;       scanf( %d %d %d %d , &x1, &y1, &x2, &y2);       x1 += 5001, y1 += 5001, x2 += 5001, y2 += 5001;       if (x1 == x2)         v[++cntv] = {min(y1, y2), max(y1, y2), x1};       else         h[++cnth] = {min(x1, x2), max(x1, x2), y1};     }     sort(h + 1, h + cnth + 1);     sort(v + 1, v + cntv + 1);     long long ans = 0;     for (int i = 1; i <= cnth; ++i) {       memset(c, 0, sizeof(c));       for (int j = 1, k = 1; k < i;) {         if (v[j].y1 <= h[k].y && j <= cntv) {           if (v[j].x >= h[i].x1 && v[j].x <= h[i].x2 && v[j].y2 >= h[i].y)             update(v[j].x, 1);           ++j;         } else {           int res = get_sum(h[k].x1, h[k].x2);           ans += 1ll * res * (res - 1) / 2;           ++k;         }       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   const int INF = 500000001;   const double EPS = 1e-9;   const double PI = acos(-1.0);   using namespace std;   int main() {     srand(time(NULL));     char ch[101][105];     int n, m;     int bl[105][105];     while (~scanf( %d %d , &n, &m)) {       for (int i = 0; i < n; i++) {         scanf( %s , ch[i]);       }       int ans = 0;       for (int j = 0; j < m; j++) {         int flag = 1;         bl[0][j] = 1;         for (int i = 1; i < n; i++) {           if (ch[i][j] < ch[i - 1][j] && (j == 0 || bl[i][j - 1] <= 1)) {             flag = 0;             break;           } else if (ch[i][j] == ch[i - 1][j] && (j == 0 || bl[i][j - 1] == 1)) {             bl[i][j] = 1;           } else if (j == 0 || bl[i][j - 1] >= 1) {             bl[i][j] = 2;           } else {             bl[i][j] = 0;           }         }         if (!flag) {           ++ans;           for (int i = 0; i < n; i++) {             ch[i][j] = ch[0][j];             if (j == 0)               bl[i][j] = 1;             else               bl[i][j] = bl[i][j - 1];           }         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long vec3[17][1 << 17];   long long mn(int i, int j) {     int p = 31 - __builtin_clz(j - i);     return min(vec3[p][i], vec3[p][j - (1 << p)]);   }   void mn_init(int n) {     int mp = 31 - __builtin_clz(n);     for (int p = 0; p < mp; ++p)       for (int x = 0; x < n - (1 << p); ++x)         vec3[p + 1][x] = min(vec3[p][x], vec3[p][x + (1 << p)]);   }   long long vec2[17][1 << 17];   long long mx(int i, int j) {     int p = 31 - __builtin_clz(j - i);     return max(vec2[p][i], vec2[p][j - (1 << p)]);   }   void mx_init(int n) {     int mp = 31 - __builtin_clz(n);     for (int p = 0; p < mp; ++p)       for (int x = 0; x < n - (1 << p); ++x)         vec2[p + 1][x] = max(vec2[p][x], vec2[p][x + (1 << p)]);   }   int izq[100010];   struct rmq {     int MAX;     long long vec[4 * 100000];     long long* init(int n) {       MAX = 1 << (32 - __builtin_clz(n));       fill(vec, vec + 2 * MAX, 0);       return vec + MAX;     }     void updall() {       for (int i = MAX - 1; i >= 0; --i) vec[i] = min(vec[2 * i], vec[2 * i + 1]);     }     void pset(int i, long long vl) {       vec[i += MAX] = vl;       while (i) {         i /= 2;         vec[i] = min(vec[2 * i], vec[2 * i + 1]);       }     }     long long pget(int i, int j) { return _pget(i + MAX, j + MAX); }     long long _pget(int i, int j) {       long long res = 100000000;       if (j - i <= 0) return res;       if (i % 2) res = min(res, vec[i++]);       res = min(res, _pget(i / 2, j / 2));       if (j % 2) res = min(res, vec[--j]);       return res;     }   };   rmq DP;   int main() {     long long n, s, l;     cin >> n >> s >> l;     for (int i = 0; i < n; i++) {       cin >> vec3[0][i];       vec2[0][i] = vec3[0][i];     }     mn_init(n);     mx_init(n);     for (int i = 1; i < n; i++) {       if (mn(0, i) < vec3[0][i] - s) {         int bot = 0, top = i;         while (top - bot > 1) {           int mid = (top + bot) / 2;           if (mn(mid, i) < vec3[0][i] - s)             bot = mid;           else             top = mid;         }         izq[i] = max(izq[i], top);       }       if (mx(0, i) > vec3[0][i] + s) {         int bot = 0, top = i;         while (top - bot > 1) {           int mid = (top + bot) / 2;           if (mx(mid, i) > vec3[0][i] + s)             bot = mid;           else             top = mid;         }         izq[i] = max(izq[i], top);       }     }     for (int i = 1; i < n; i++) izq[i] = max(izq[i], izq[i - 1]);     for (int i = 0; i < n; ++i) izq[i]--;     long long* v = DP.init(n);     for (int i = 0; i < n; ++i) v[i] = 100000000;     DP.updall();     for (int i = 0; i < n; ++i) {       if (izq[i] == -1 && i >= l - 1)         DP.pset(i, 1);       else {         DP.pset(i, DP.pget(izq[i], i - l + 1) + 1);       }     }     if (DP.pget(n - 1, n) <= n)       cout << DP.pget(n - 1, n) << endl;     else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v;   vector<string> veg;   bool comp(pair<int, int> p1, pair<int, int> p2) {     return (p1.first < p2.first or             ((p1.first == p2.first) and (p1.second < p2.second)));   }   int main() {     int n, m, k, t, x, y;     veg.push_back( Grapes );     veg.push_back( Carrots );     veg.push_back( Kiwis );     cin >> n >> m >> k >> t;     while (k--) {       cin >> x >> y;       v.push_back(make_pair(x, y));     }     sort(v.begin(), v.end(), comp);     while (t--) {       int f = 0, s = 0;       int left = 0, right = v.size() - 1;       cin >> f >> s;       int mid = (left + right) / 2, flag = 0;       while (left < right) {         mid = left + (right - left) / 2 + 1;         if (v[mid].first == f and v[mid].second == s) {           flag = 1;           cout <<  Waste  << endl;           break;         }         if (f < v[mid].first or (f == v[mid].first and s < v[mid].second))           right = mid - 1;         else           left = mid;       }       if (!flag) {         if (v[left].first == f and v[left].second == s)           cout <<  Waste  << endl;         else {           if (v[left].first > f or v[left].first == f and v[left].second > s)             left--;           cout << veg[((f - 1) * m + s - left - 1) % 3] << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxlongint = 2147483647;   const int inf = 1000000000;   char s[10], a[1000][1100];   ;   int main() {     scanf( %s , s);     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %s , a[i]);     int ans = 0;     for (int i = 1; i <= n; i++) {       if (a[i][0] == s[0] && a[i][1] == s[1]) ans = 1;       for (int j = 1; j <= n; j++)         if (a[i][1] == s[0] && a[j][0] == s[1]) ans = 1;     }     if (ans)       printf( YES );     else       printf( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 7;   vector<int> G[N];   int vis[N] = {0}, p[N];   long long sum[N] = {0};   stack<int> s;   void dfs(int u, int fa) {     s.push(u);     vis[u] = 1;     for (int i = 0; i < (int)G[u].size(); i++) {       int v = G[u][i];       if (v == fa) continue;       if (!vis[v])         dfs(v, u);       else if (vis[v] == 1) {         int maxx = u, minn = u;         while (!s.empty()) {           int t = s.top();           s.pop();           maxx = max(t, maxx);           minn = min(t, minn);           if (t == v) break;         }         p[minn] = maxx;       }     }     if (!s.empty() && s.top() == u) s.pop();     vis[u] = 2;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     for (int i = 1; i <= n + 1; i++) p[i] = n + 1;     for (int i = 1; i <= n; i++)       if (!vis[i]) dfs(i, -1);     for (int i = n; i >= 1; i--) {       p[i] = min(p[i], p[i + 1]);       sum[i] = sum[i + 1] + p[i] - i;     }     int q;     cin >> q;     while (q--) {       int l, r;       cin >> l >> r;       int L = l, R = r + 1;       while (L < R) {         int m = (L + R) / 2;         if (p[m] > r)           R = m;         else           L = m + 1;       }       cout << sum[l] - sum[L] + 1ll * (r - L + 1) * (r - L + 2) / 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t[10], card[105];   int main() {     int i, sum, ans;     sum = 0;     for (i = 1; i <= 5; i++) {       cin >> t[i];       sum = sum + t[i];       card[t[i]]++;     }     ans = sum;     for (i = 100; i >= 1; i--) {       if (card[i] == 2) {         if (sum - 2 * i < ans) ans = sum - 2 * i;       }       if (card[i] >= 3) {         if (sum - 3 * i < ans) ans = sum - 3 * i;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mM(long long a, long long b, long long mod) {     long long res = 0;     a %= mod;     while (b) {       if (b & 1) res = (res + a) % mod;       a = (2 * a) % mod;       b >>= 1;     }     return res;   }   long long fpow(long long first, long long second, long long p) {     first = first % p;     long long res = 1;     while (second) {       if (second & 1) res = mM(res, first, p);       res %= p;       if (res < 0) res = (res + p) % p;       second = second >> 1;       first = mM(first, first, p);       if (first < 0) first = (first + p) % p;       first %= p;     }     return res;   }   long long inv(long long n) { return fpow(n, 1000000007 - 2, 1000000007); }   long long modmul(long long first, long long second) {     return mM(first, second, 1000000007);   }   long long modadd(long long first, long long second) {     long long temp = first % 1000000007 + second % 1000000007;     temp %= 1000000007;     if (temp < 0) temp = (temp + 1000000007) % 1000000007;     return temp;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       long long n, m;       cin >> n >> m;       string s, p;       cin >> s >> p;       string s1 =   , s2 =   ;       for (int i = 0; i < s.size(); i++)         if (s[i] !=  * )           s1 += s[i];         else           break;       for (int i = n - 1; i >= 0; i--)         if (s[i] !=  * )           s2 += s[i];         else           break;       if (s == p) {         cout <<  YES n ;         return 0;       }       string jk = s2;       reverse(jk.begin(), jk.end());       if (s1 == s && jk == s && s != p) {         cout <<  NO n ;         return 0;       }       if (s1.size() + s2.size() > p.size()) {         cout <<  NO n ;         return 0;       }       int i;       for (i = 0; i < s1.size(); i++)         if (s1[i] != p[i]) break;       int j, k = m - 1;       for (j = 0; j < s2.size(); j++)         if (s2[j] != p[k])           break;         else           k--;       if (i != s1.size() || j != s2.size())         cout <<  NO n ;       else         cout <<  YES n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   vector<int> e[N];   set<int> s[N];   queue<int> q;   bool vis[N];   int d[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       d[u]++, d[v]++;       e[u].push_back(v), e[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (d[i] == 1) q.push(i), s[i].insert(0);     while (q.size()) {       int tp = q.front();       q.pop();       vis[tp] = true;       for (int i = 0; i < e[tp].size(); i++) {         int v = e[tp][i];         if (vis[v]) continue;         d[v]--;         s[v].insert(*(s[tp].begin()) + 1);         if (d[v] == 1 && s[v].size() == 1) q.push(v);       }     }     int cnt = 0, ans = 0;     for (int i = 1; i <= n; i++)       if (s[i].size() > 2 || s[i].size() == 0)         return 0 * puts( -1 );       else if (s[i].size() == 1)         ans = max(ans, *s[i].begin());       else         cnt++, ans = max(ans, (*s[i].begin()) + (*s[i].rbegin()));     if (cnt > 1)       puts( -1 );     else {       while (ans % 2 == 0) ans /= 2;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, m;   int main() {     cin >> x >> y >> m;     if (x >= m || y >= m)       cout << 0 <<   n ;     else {       if (x <= 0 && y <= 0)         cout << -1 <<   n ;       else {         long long cc = 0;         if (x > y) swap(x, y);         if (x < 0) {           cc += x >= 0 ? x : -x / y;           x += y * (long long)cc;         }         while (x < m && y < m) {           if (x < y)             x = x + y;           else             y = x + y;           cc++;         }         cout << cc <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v;     int n, m;     cin >> n >> m;     int maks = 0;     for (int i = 0; i < n; i++) v.push_back(i + 1);     do {       int res = 0;       for (int i = 0; i < n; i++) {         for (int j = i; j < n; j++) {           int x = 100;           for (int k = i; k <= j; k++) x = min(x, v[k]);           res += x;         }       }       maks = max(res, maks);     } while (next_permutation(v.begin(), v.end()));     v.clear();     for (int i = 0; i < n; i++) v.push_back(i + 1);     do {       int res = 0;       for (int i = 0; i < n; i++) {         for (int j = i; j < n; j++) {           int x = 100;           for (int k = i; k <= j; k++) x = min(x, v[k]);           res += x;         }       }       if (res == maks) {         m--;         if (m > 0) continue;         for (int i = 0; i < n; i++) cout << v[i] <<    ;         cout <<   n ;         break;       }     } while (next_permutation(v.begin(), v.end()));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2, s3;     long long a = 0, b = 0, c = 0;     string unia;     cin >> s1 >> s2 >> s3;     long long *trm1, *trm2;     string *uni;     uni = &unia;     if (s1[0] ==  A )       trm1 = &a;     else if (s1[0] ==  B )       trm1 = &b;     else if (s1[0] ==  C )       trm1 = &c;     if (s1[2] ==  A )       trm2 = &a;     else if (s1[2] ==  B )       trm2 = &b;     else if (s1[2] ==  C )       trm2 = &c;     if (s1[1] ==  > ) {       *uni += s1[0];       *trm1 = *trm2 + 1 + *trm1;     } else if (s1[1] ==  < ) {       *uni += s1[2];       *trm2 = *trm1 + 1 + *trm2;     }     if (s2[0] ==  A )       trm1 = &a;     else if (s2[0] ==  B )       trm1 = &b;     else if (s2[0] ==  C )       trm1 = &c;     if (s2[2] ==  A )       trm2 = &a;     else if (s2[2] ==  B )       trm2 = &b;     else if (s2[2] ==  C )       trm2 = &c;     if (s2[1] ==  > ) {       *uni += s2[0];       *trm1 = *trm2 + 1 + *trm1;     } else if (s2[1] ==  < ) {       *uni += s2[2];       *trm2 = *trm1 + 1 + *trm2;     }     if (s3[0] ==  A )       trm1 = &a;     else if (s3[0] ==  B )       trm1 = &b;     else if (s3[0] ==  C )       trm1 = &c;     if (s3[2] ==  A )       trm2 = &a;     else if (s3[2] ==  B )       trm2 = &b;     else if (s3[2] ==  C )       trm2 = &c;     if (s3[1] ==  > ) {       *uni += s3[0];       *trm1 = *trm2 + 1 + *trm1;     } else if (s3[1] ==  < ) {       *uni += s3[2];       *trm2 = *trm1 + 1 + *trm2;     }     long long unicnt = 0;     long long repcnt = 0;     for (long long i = 0; i < 3; i++) {       if (i == 0)         unicnt++;       else {         long long j;         for (j = i - 1; j >= 0; j = j - 1) {           if (unia[i] == unia[j]) {             repcnt++;             break;           }         }         if (j < 0) unicnt++;       }     }     if (repcnt != 1) {       cout <<  Impossible  << endl;     } else {       vector<pair<long long, char>> m;       m.push_back(make_pair(a,  A ));       m.push_back(make_pair(b,  B ));       m.push_back(make_pair(c,  C ));       sort(m.begin(), m.end());       for (long long i = 0; i < m.size(); i++) {         cout << m[i].second;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     ios_base::sync_with_stdio(0);     cin >> N;     string K;     cin >> K;     int zm = N;     for (int i = 1; i < N; i++) {       if (K[i] != K[i - 1]) {         zm--;         if (i < N - 1) K[i] = K[i + 1];       }     }     cout << zm;   }
#include <bits/stdc++.h>   int mod = 1000000007;   using namespace std;   using namespace std;   int n, k;   int a[400005];   int pos[400005];   map<int, int> m;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ;     cin >> n >> k;     for (int i = 1; i <= n; i++) pos[i] = 1e7;     m[a[1]] = 1e7;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       pos[m[a[i]]] = i;       m[a[i]] = i;     }     int ans = 0;     set<int> s;     set<pair<int, int> > ss;     for (int i = 1; i <= n; i++) {       if (!s.count(a[i])) {         if (s.size() < k) {           ans++;           s.insert(a[i]);           ss.insert(make_pair(pos[i], a[i]));         } else {           ans++;           set<pair<int, int> >::iterator it = ss.end();           it--;           int val = (*it).second;           ss.erase(it);           s.erase((val));           s.insert(a[i]);           ss.insert(make_pair(pos[i], a[i]));         }       } else {         ss.erase(ss.begin());         ss.insert(make_pair(pos[i], a[i]));       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int arr[11][11];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       arr[1][i] = 1;     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= n; j++) {         arr[i][j] = arr[i - 1][j] + arr[i][j - 1];       }     }     cout << arr[n][n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, n, m, k;     int h;     while (scanf( %d%d%d , &n, &m, &h) != EOF) {       int sum1, sum2;       sum1 = sum2 = 0;       for (i = 1; i <= m; i++) {         scanf( %d , &k);         if (i == h)           sum1 = k;         else           sum2 += k;       }       k = n - 1;       if (sum1 + sum2 < n)         puts( -1 );       else if (sum2 < k - 1)         puts( 1 );       else {         k = n - 1;         h = sum2;         double ans = 1;         for (i = 1; i <= k; i++) {           ans *= h;           h--;         }         h = sum2 + sum1 - 1;         for (i = 1; i <= k; i++) {           ans /= h;           h--;         }         printf( %.7lf n , 1 - ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n, m, c;     cin >> n >> m >> c;     vector<int> a(n), b(m);     for (int i = 0; i < n; i++) cin >> a[i];     for (int j = 0; j < m; j++) cin >> b[j];     vector<int> beg(n);     beg.assign(n, 0);     vector<int> start(n), end(n);     start.assign(n, 0);     end.assign(n, 0);     int max;     if (n >= 2 * m) {       for (int i = 0; i < m; ++i) {         beg[i] = i + 1;         start[i] = 0;         end[i] = start[i] + beg[i];       }       for (int i = m; i < n - m + 1; ++i) {         beg[i] = m;         start[i] = 0;         end[i] = start[i] + beg[i];       }       for (int i = n - m + 1; i < n; ++i) {         beg[i] = n - i;         start[i] = start[i - 1] + 1;         end[i] = start[i] + beg[i];       }     } else {       for (int i = 0; i < n - m + 1; ++i) {         beg[i] = i + 1;         start[i] = 0;         end[i] = start[i] + beg[i];       }       for (int i = n - m + 1; i < m; ++i) {         beg[i] = n - m + 1;         start[i] = start[i - 1] + 1;         end[i] = start[i] + beg[i];       }       for (int i = m; i < n; ++i) {         beg[i] = n - i;         start[i] = start[i - 1] + 1;         end[i] = start[i] + beg[i];       }     }     for (int i = 0; i < n; ++i) {       for (int j = start[i]; j < end[i]; ++j) a[i] = (a[i] + b[j]) % c;       cout << a[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int a[100];     int e, n, i, j;     scanf( %d , &n);     for (i = 0; i < n; i++) {       a[i] = 0;     }     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         scanf( %d , &e);         if (i >= j) {           continue;         }         a[i] |= e;         a[j] |= e;       }     }     for (i = 0; i < n; i++) {       printf( %d  , a[i]);     }     return 0;   }