malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   ostream& operator<<(ostream& os, const pair<T, U>& p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& v) {     os <<  { ;     for (int i = 0; i < (int)v.size(); i++) {       if (i) os <<  ,  ;       os << v[i];     }     os <<  } ;     return os;   }   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int mod = 1e9 + 7;   const int N = 2005;   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int sub(int x, int y) {     x -= y;     if (x < 0) x += mod;     return x;   }   inline int mul(int x, int y) { return (x * 1ll * y) % mod; }   inline int powr(int a, long long b) {     int x = 1 % mod;     while (b) {       if (b & 1) x = mul(x, a);       a = mul(a, a);       b >>= 1;     }     return x;   }   inline int inv(int a) { return powr(a, mod - 2); }   char s[N][N];   int dp[2][N][N], dp2[2][N][N];   int num[2][N][N];   int main() {     int n = 2000, m = 2000;     scanf( %d , &(n)), scanf( %d , &(m));     for (int i = 1; i <= n; i++) {       scanf( %s , s[i] + 1);     }     for (int i = n; i >= 1; i--) {       for (int j = m; j >= 1; j--) {         num[0][i][j] = num[0][i][j + 1] + (s[i][j] ==  R );         num[1][i][j] = num[1][i + 1][j] + (s[i][j] ==  R );         if (i == n) dp[0][i][j] = (num[0][i][j] == 0);         if (j == m) dp[1][i][j] = (num[1][i][j] == 0);         int mxj = m - num[0][i][j];         int mxi = n - num[1][i][j];         if (i != n) dp[0][i][j] = sub(dp2[1][i + 1][j], dp2[1][i + 1][mxj + 1]);         if (j != m) dp[1][i][j] = sub(dp2[0][i][j + 1], dp2[0][mxi + 1][j + 1]);         dp2[0][i][j] = add(dp[0][i][j], dp2[0][i + 1][j]);         dp2[1][i][j] = add(dp[1][i][j], dp2[1][i][j + 1]);       }     }     assert(dp[0][1][1] == dp[1][1][1]);     printf( %d n , dp[0][1][1]);   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char mat[100][100];   char c;   vector<int> us;   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> mat[i];     for (int i = 0; i < n; i++) {       us.clear();       for (int j = 0; j < m; j++) {         if (mat[i][j] ==  # ) us.push_back(j);       }       if (us.size() > 0) {         for (int j = 0; j < n; j++) {           c = mat[j][us[0]];           for (int k = 1; k < (int)us.size(); k++) {             if (mat[j][us[k]] != c) {               cout <<  No ;               return 0;             }           }         }       }     }     for (int i = 0; i < m; i++) {       us.clear();       for (int j = 0; j < n; j++) {         if (mat[j][i] ==  # ) us.push_back(j);       }       if (us.size() > 0) {         for (int j = 0; j < m; j++) {           c = mat[us[0]][j];           for (int k = 1; k < (int)us.size(); k++) {             if (mat[us[k]][j] != c) {               cout <<  No ;               return 0;             }           }         }       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<long long int> dif;   vector<long long int> vec;   long long int a[1000000], b[1000000];   int main() {     long long int x, d, contador = 0, i;     long long int pot, exp;     cin >> x >> d;     while (x > 0) {       x++;       pot = 1;       exp = 0;       while (pot <= x) {         pot = pot * 2;         exp++;       }       for (i = 0; i < exp - 1; i++) {         vec.push_back(d * contador + 1);       }       contador++;       x = x - pot / 2;     }     cout << vec.size() <<   n ;     for (i = 0; i < vec.size(); i++) cout << vec[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long pw10[] = {1, 10, 100, 1000, 10000, 100000};   long long K, F[7], Q, dp[7][2000000];   signed main() {     cin >> K;     for (long long i = 1; i <= 6; ++i) cin >> F[i];     memset(dp, -0x3f, sizeof(dp));     dp[0][0] = 0;     for (long long i = 1; i <= 6; ++i) {       for (long long j = 0; j < 3 * pw10[i - 1]; ++j) {         deque<pair<long long, long long> > q;         for (long long k = j, cnt = 0; k < 1e6; k += 3 * pw10[i - 1], ++cnt) {           long long val = dp[i - 1][k] - cnt * F[i];           while (q.size() && q.back().first <= val) q.pop_back();           q.push_back(make_pair(val, cnt));           if (cnt - q.front().second > 3 * K) q.pop_front();           dp[i][k] = max(dp[i][k], cnt * F[i] + q.front().first);           long long pos = 0;           while (cnt - q[pos].second > 3 * (K - 1)) ++pos;           long long v = cnt * F[i] + q[pos].first;           for (long long t = 0; t < 10; ++t)             dp[i][k + t * pw10[i - 1]] = max(dp[i][k + t * pw10[i - 1]], v);         }       }     }     for (cin >> Q; Q; --Q) {       long long x;       cin >> x;       cout << max(0ll, dp[6][x]) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 500000 + 5;   long long a[maxn], tmp[maxn];   multiset<long long> save;   vector<pair<long long, long long> > b;   int main() {     long long total = 0;     long long n;     scanf( %lld , &n);     for (long long i = 0; i < n; i++) scanf( %lld , a + i), total += a[i];     sort(a, a + n, greater<long long>());     for (long long i = 0, cnt = 1; i < n; i++, cnt++)       if (i == n - 1 || a[i] != a[i + 1])         b.push_back(make_pair(a[i], cnt)), cnt = 0;     for (long long i = 0, sizesum = 0; i < (long long)b.size(); i++) {       long long num = b[i].first, nowsize = b[i].second;       long long save_size = min(sizesum, sizesum + nowsize >> 1);       long long cnt = max(0LL, save_size - nowsize);       for (long long j = save_size - 1; j >= cnt; j--)         if (j < (long long)save.size())           tmp[j] = *save.begin(), save.erase(save.begin());         else           tmp[j] = 0;       for (long long j = cnt, k = sizesum - cnt; j < k && j < save_size; j++)         if (tmp[j] < num)           tmp[j] = num;         else if (--k < save_size)           tmp[k] = max(0LL, 2LL * num - tmp[j]);       save.insert(tmp + cnt, tmp + save_size);       sizesum += nowsize;     }     for (auto it = save.begin(); it != save.end(); it++) total -= (*it);     printf( %lld n , total);   }
#include <bits/stdc++.h>   using namespace std;   long long int b[101];   int main() {     long long int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       b[a[i]]++;     }     long long int ans = 0;     for (int i = 1; i < 101; i++) {       if (b[i] >= ans) {         ans = b[i];       }     }     cout << ans << endl;     return 0;   }
#include <stdio.h>   #include <vector>   #include <algorithm>   #include <set>   #define pii pair<int,int>   #define ll long long   using namespace std;   vector<int> edge[200001];   vector<pii > pt[200001];   int depth[200001];   ll d[200001];   int a[200001],v[200001];   void dfs(int x) {    for (auto nxt : edge[x]) {     depth[nxt] = depth[x] + 1;     dfs(nxt);    }   }   int main() {    int t;    for (scanf( %d , &t); t--;) {     int i, n;     for (scanf( %d , &n), i = 1; i <= n; ++i) {      edge[i].clear();      pt[i].clear();      d[i] = 0;     }     for (i = 2; i <= n; ++i) {      scanf( %d ,v+i);      edge[v[i]].push_back(i);     }     depth[1] = 1;     dfs(1);     for (i = 2; i <= n; ++i) {      scanf( %d ,a+i);      pt[depth[i]].push_back({a[i],i});     }     pt[1].push_back({0,1});     for (i = 1; i <= n; ++i)      sort(pt[i].begin(), pt[i].end());     int lev = 2;     while (pt[lev].size()) {      multiset < ll > l, r;      for (auto p : pt[lev]) {       int x = p.second;       r.insert(d[v[x]]+a[x]);      }      for (auto p : pt[lev]) {       int x = p.second;       auto it = r.lower_bound(d[v[x]]+a[x]);       r.erase(it);          if (r.size()) {        auto mx = prev(r.end());        d[x] = max(d[x], *mx - a[x]);        int rightmost = pt[lev].back().first;        d[x] = max(d[x], d[v[x]] + rightmost - a[x]);       }       if (l.size()) {        auto mx = prev(l.end());        d[x] = max(d[x], a[x] + *mx);        int leftmost = pt[lev][0].first;        d[x] = max(d[x], d[v[x]] + a[x] - leftmost);       }       l.insert({d[v[x]]-a[x]});      }      ++lev;     }        ll ans = 0;     for (i = 1; i <= n; ++i) {      if (ans < d[i]) ans = d[i];     }     printf( %I64d n ,ans);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, res1, res2;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     res1 = a[0] ^ a[1];     vector<int> st;     for (int i = 0; i < n; i++) {       while (!st.empty() && st.back() < a[i]) st.pop_back();       st.push_back(a[i]);       if (st.size() >= 2) res1 = max(res1, st[st.size() - 1] ^ st[st.size() - 2]);     }     res2 = a[n - 1] ^ a[n - 2];     vector<int> st1;     for (int i = n - 1; i >= 0; i--) {       while (!st1.empty() && st1.back() < a[i]) st1.pop_back();       st1.push_back(a[i]);       if (st1.size() >= 2)         res2 = max(res2, st1[st1.size() - 1] ^ st1[st1.size() - 2]);     }     cout << max(res1, res2);   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse2 )   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   void solution() {     int n;     cin >> n;     vector<long long> arr(n);     map<long long, long long> cnt;     map<long long, long long> freq;     for (int i = 0; i < n; i++) cin >> arr[i];     long long ans = 1;     for (int i = 1; i < n + 1; i++) {       cnt[arr[i - 1]]++;       freq[cnt[arr[i - 1]]]++;       long long x = cnt[arr[i - 1]];       long long y = freq[cnt[arr[i - 1]]];       if (x * y == i && i < n)         ans = i + 1;       else if (x * y == i - 1)         ans = i;     }     cout << ans <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     for (int i = 1; i < t + 1; i++) {       solution();     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int N, K;     cin >> N >> K;     set<int> s;     for (int i = 0; i < N; i++) {       int a;       cin >> a;       s.insert(a);     }     if (s.size() > K) {       cout << -1 << endl;       return;     }     cout << N * K << endl;     for (int i = 0; i < N; i++) {       for (int b : s) cout << b <<    ;       for (int j = 0; j < K - (int)s.size(); j++) cout << 1 <<    ;     }     cout << endl;   }   int main() {     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int a[100005];   int l[1000], r[1000];   vector<int> v[100000];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) {       int s, t;       scanf( %d%d , &s, &t);       l[i] = s, r[i] = t;     }     int ans = -100000000, anss = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         int mi = a[i], ma = a[j];         for (int k = 1; k <= m; k++) {           if (l[k] <= i && i <= r[k] && (l[k] > j || r[k] < j))             mi--, v[(i - 1) * 300 + j].push_back(k);         }         if (ans < ma - mi) {           ans = ma - mi;           anss = (i - 1) * 300 + j;         }       }     }     printf( %d n , ans);     printf( %d n , v[anss].size());     for (int i = 0; i < v[anss].size(); i++) printf( %d  , v[anss][i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long b, long long e, long long m) {     long long p = 1;     while (e > 0) {       if (e & 1) p = (p * b) % m;       e = e >> 1;       b = (b * b) % m;     }     return p;   }   long long cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0};   long long getAns(long long n) {     long long ans = 0;     if (n == 0) return cnt[0];     while (n) {       ans += cnt[n % 16];       n /= 16;     }     return ans;   }   int main() {     long long n, i = 0, j, m, h, h1, h2, q, k, l, r, ans;     scanf( %lld , &n);     printf( %lld n , getAns(n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sum[705][705], a[500100];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q, t, x, y;     memset(sum, 0, sizeof(sum));     cin >> q;     while (q--) {       cin >> t >> x >> y;       if (t == 1) {         a[x] += y;         for (int i = 1; i < 705; ++i) {           sum[i][x % i] += y;         }       } else {         if (x < 705) {           cout << sum[x][y] << endl;         } else {           int ans = 0;           for (int i = y; i < 500100; i += x) ans += a[i];           cout << ans << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 300001;   int dp[82][82][82][82], n, k, m, u, v, c;   vector<pair<int, int> > g[83];   int calc(int idx, int l, int r, int rem) {     if (rem == 0) return 0;     if (l > r) return 1e9;     int &ret = dp[idx][l][r][rem];     if (ret != -1) return ret;     ret = 1e9;     for (int i = 0; i < g[idx].size(); ++i) {       int v = g[idx][i].first;       int cost = g[idx][i].second;       if (v < l) continue;       if (v > r) continue;       ret = min(ret, cost + calc(v, v + 1, r, rem - 1));       ret = min(ret, cost + calc(v, l, v - 1, rem - 1));     }     return ret;   }   int main() {     memset(dp, -1, sizeof dp);     scanf( %d%d , &n, &k);     scanf( %d , &m);     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &u, &v, &c);       if (u == v) continue;       g[u].push_back(make_pair(v, c));     }     int ret = 1e9;     for (int i = 1; i <= n; ++i) {       ret = min(ret, calc(i, i + 1, n, k - 1));       ret = min(ret, calc(i, 1, i - 1, k - 1));     }     if (ret == 1e9) ret = -1;     printf( %d n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<pair<string, int>> v(n);     for (int i = 0; i < n; i++) {       string s;       cin >> s;       v[i].first = s;       v[i].second = i + 1;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (j % 2 == 1) {           v[i].first[j] = (char)( Z  - v[i].first[j]);         }       }     }     sort(v.begin(), v.end());     for (int i = 0; i < n; i++) {       cout << v[i].second <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long FastExp(long long a, long long b, long long c) {     if (b == 1) return a;     long long ans = FastExp(a, b / 2, c);     if (b % 2 == 0) return ans % c * ans % c;     if (b % 2 != 0) return ans % c * ans % c * a % c;   }   int main() {     int n;     cin >> n;     int a[n + 5];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       if (i == a[a[a[i]]]) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int mas[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};     int m, n;     bool ans = false;     cin >> n >> m;     for (int i = 0; i < 15; i++) {       if (mas[i] == n) {         if (mas[i + 1] == m) {           ans = true;           break;         }       }     }     if (ans)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std::chrono;   using namespace std;   const int mod = 1e9 + 7;   string s;   int op[501], cl[501];   int sop[501], scl[501];   int n;   void f() {     memset(op, 0, sizeof(op));     memset(cl, 0, sizeof(cl));     if (s[0] ==  ( )       op[0]++;     else       cl[0]++;     memset(sop, 0, sizeof(sop));     memset(scl, 0, sizeof(scl));     if (s[n - 1] ==  ( )       sop[n - 1]++;     else       scl[n - 1]++;     for (int i = n - 2; i >= 0; --i) {       if (s[i] ==  ) ) {         sop[i] = sop[i + 1];         scl[i] = scl[i + 1] + 1;       } else {         if (scl[i + 1]) {           sop[i] = sop[i + 1];           scl[i] = scl[i + 1] - 1;         } else {           sop[i] = sop[i + 1] + 1;           scl[i] = scl[i + 1];         }       }     }     for (int i = 1; i < n; ++i) {       if (s[i] ==  ( ) {         op[i] = op[i - 1] + 1;         cl[i] = cl[i - 1];       } else {         if (op[i - 1]) {           op[i] = op[i - 1] - 1;           cl[i] = cl[i - 1];         } else {           op[i] = op[i - 1];           cl[i] = cl[i - 1] + 1;         }       }     }   }   void solve() {     cin >> n;     cin >> s;     int x1 = 1, x2 = 1, mx = 0, c = 0;     for (int i = 0; i < n; ++i) {       for (int j = i; j < n; ++j) {         int c = 0;         swap(s[i], s[j]);         f();         for (int k = 0; k < n; ++k) {           int open;           open = 0;           if (k + 1 < n) open = sop[k + 1];           if (cl[k] == open && op[k] == 0) {             if (k + 1 < n) {               if (scl[k + 1] == 0) c++;             } else               c++;           }         }         swap(s[i], s[j]);         if (mx < c) {           mx = c;           x1 = i + 1;           x2 = j + 1;         }       }     }     cout << mx << endl;     cout << x1 <<     << x2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[100100];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     set<int> s;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 1; i < n; i++) s.insert(a[i] - a[i - 1]);     if (s.size() == 1)       cout << a[n - 1] + *s.begin() << endl;     else       cout << a[n - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[500000];   bool visited[500000];   int n;   unordered_map<int, int> m, p;   vector<pair<int, int> > v;   void check(int u) {     visited[u] = true;     for (auto v : g[u]) {       if (!visited[v]) check(v);     }   }   int main() {     cin >> n;     set<int> s;     for (int i = 0; i < n; i++) {       int a, b;       cin >> a >> b;       m[a] = b;       v.push_back({a, 0});       v.push_back({b, 1});       p[a] = i;       p[b] = i;     }     sort(v.begin(), v.end());     int count = 0;     for (int i = 0; i < v.size(); i++) {       if (v[i].second == 0) {         for (auto ele : s) {           if (ele < m[v[i].first]) {             count++;             g[p[v[i].first]].push_back(p[ele]);             g[p[ele]].push_back(p[v[i].first]);           } else             break;         }         if (count > n - 1) {           break;         }         s.insert(m[v[i].first]);       } else {         s.erase(v[i].first);       }     }     if (count == n - 1) {       check(0);       int i;       for (i = 0; i < n; i++) {         if (!visited[i]) break;       }       if (i == n)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     } else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[105];   int main() {     int n, k;     cin >> n >> k;     int j = 1000;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (k % a[i] == 0) {         j = min(k / a[i], j);       }     }     cout << j;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100010, TOUR = 1 << 17;   struct tour {     int val, broj, prop;     tour(int val, int broj, int prop) : val(val), broj(broj), prop(prop) {}     tour() {}   } t[2 * TOUR];   struct event {     int t, l, r, val;     event(int t, int l, int r, int val) : t(t), l(l), r(r), val(val) {}     event() {}   };   bool operator<(const event &a, const event &b) { return a.t < b.t; }   vector<int> V[MAX];   vector<event> E;   int disc[MAX], fin[MAX];   int rje[MAX];   int vr = 0;   void Propagiraj(int x) {     for (int i = 2 * x; i <= 2 * x + 1; i++) {       t[i].prop += t[x].prop;       t[i].val += t[x].prop;     }     t[x].prop = 0;   }   tour Merge(tour l, tour r) {     if (l.val < r.val) return tour(l.val, l.broj, 0);     if (r.val < l.val) return tour(r.val, r.broj, 0);     return tour(l.val, l.broj + r.broj, 0);   }   void Stavi(int pos, int lo, int hi, int begin, int end, int val) {     if (lo >= end || hi <= begin) return;     if (lo >= begin && hi <= end) {       t[pos].val += val;       t[pos].prop += val;       return;     }     Propagiraj(pos);     Stavi(2 * pos + 0, lo, (lo + hi) / 2, begin, end, val);     Stavi(2 * pos + 1, (lo + hi) / 2, hi, begin, end, val);     t[pos] = Merge(t[2 * pos], t[2 * pos + 1]);   }   void Dfs(int node, int prosli) {     disc[node] = vr++;     for (int i = 0; i < (int)V[node].size(); i++) {       int nn = V[node][i];       if (nn != prosli) Dfs(nn, node);     }     fin[node] = vr;   }   void Init(int n) {     for (int i = 0; i < n; i++) t[i + TOUR] = tour(0, 1, 0);     for (int i = n; i < TOUR; i++) t[i + TOUR] = tour(1e9, 0, 0);     for (int i = TOUR - 1; i; i--) t[i] = Merge(t[2 * i], t[2 * i + 1]);   }   int main() {     int n, brq;     scanf( %d%d , &n, &brq);     Init(n);     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       V[a].push_back(b);       V[b].push_back(a);     }     Dfs(0, -1);     for (int i = 0; i < brq; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       E.push_back(event(disc[a], disc[a], fin[a], 1));       E.push_back(event(fin[a], disc[a], fin[a], -1));       E.push_back(event(disc[b], disc[a], fin[a], 1));       E.push_back(event(fin[b], disc[a], fin[a], -1));       E.push_back(event(disc[a], disc[b], fin[b], 1));       E.push_back(event(fin[a], disc[b], fin[b], -1));       E.push_back(event(disc[b], disc[b], fin[b], 1));       E.push_back(event(fin[b], disc[b], fin[b], -1));     }     sort(E.begin(), E.end());     for (int i = 0, ind = 0; i < n; i++) {       for (; ind < (int)E.size() && E[ind].t == i; ind++) {         event ev = E[ind];         Stavi(1, 0, TOUR, ev.l, ev.r, ev.val);       }       if (t[1].val)         rje[i] = n - 1;       else         rje[i] = max(0, n - t[1].broj - 1);     }     for (int i = 0; i < n; i++) printf( %d  , rje[disc[i]]);     printf(  n );     return 0;   }