malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m;     cin >> n >> m;     long long int kmin = 0;     long long int kmax = 0;     long long int left;     kmax = ((n - m + 1) * (n - m)) / 2;     long long int j = n / m;     left = n % m;     kmin = (m - left) * ((j) * (j - 1) / 2) + left * ((j) * (j + 1) / 2);     cout << kmin <<     << kmax << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       int row[n * m + 1], col[n * m + 1];       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           int a;           cin >> a;           col[a] = j;         }       }       for (int j = 0; j < m; j++) {         for (int i = 0; i < n; i++) {           int a;           cin >> a;           row[a] = i;         }       }       int ans[n][m];       for (int i = 1; i < n * m + 1; i++) {         ans[row[i]][col[i]] = i;       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cout << ans[i][j] <<    ;         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int t, tr, br, b, bl, tl;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> t >> tr >> br >> b >> bl >> tl;     long long ans = 0;     int k = min(tr, tl);     ans += (2 * t + k) * ((long long)k);     ans += 2 * (max(tr, tl) - k) * (t + k);     int a = min(bl, br);     ans += (2 * b + a) * ((long long)a);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[100100];   int main() {     long long n;     int q;     scanf( %I64d%d , &n, &q);     int k = 0;     long long tmp = n + 1;     while (tmp % 2 == 0) tmp /= 2, k++;     while (q--) {       long long st;       scanf( %I64d , &st);       cin >> str;       int L = strlen(str);       for (int i = 0; i < L; i++) {         int t = 0;         while (st % 2 == 0) t++, st /= 2;         if (str[i] ==  U ) {           if (t == k - 1) {             st = (1ll << t);             continue;           }           if (st % 4 == 3)             st = (st - 1) * (1ll << t);           else             st = (st + 1) * (1ll << t);         } else {           if (t == 0) continue;           t--;           st *= 2;           if (str[i] ==  L )             st = (st - 1) * (1ll << t);           else             st = (st + 1) * (1ll << t);         }       }       printf( %I64d n , st);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> divisors(long long n) {     vector<long long> ans;     for (long long i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         ans.push_back(i);         if (n / i != i) ans.push_back(n / i);       }     }     ans.push_back(1);     return ans;   }   void precision_print(long double n, long long p) {     cout << fixed << setprecision(p) << n <<   n ;     return;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long x1, p1, x2, p2;       cin >> x1 >> p1 >> x2 >> p2;       string temp = to_string(x1);       long long a = ((long long)(temp).size());       temp = to_string(x2);       long long b = ((long long)(temp).size());       if (a + p1 > b + p2) {         cout <<  >  <<   n ;         continue;       }       if (a + p1 < b + p2) {         cout <<  <  <<   n ;         continue;       }       if (p1 < p2)         x2 *= pow(10, p2 - p1);       else         x1 *= pow(10, p1 - p2);       if (x1 > x2)         cout <<  > n ;       else if (x1 == x2)         cout <<  = n ;       else         cout <<  < n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   long long num[200005], rig[200005], lef[200005];   int main() {     scanf( %d%d%d , &n, &m, &k);     long long tmp = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d , &num[i]);     }     int t = 1;     while (m--) t *= k;     for (int i = 1; i <= n; ++i) {       rig[i] = rig[i - 1] | num[i];     }     for (int i = n; i >= 1; --i) {       lef[i] = lef[i + 1] | num[i];     }     for (int i = 1; i <= n; ++i)       tmp = max(tmp, num[i] * t | rig[i - 1] | lef[i + 1]);     printf( %I64d , tmp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 2, maxm = 1000 * 1000 + 2;   int n, m, q, parent[maxn], r[maxn], b[maxn];   pair<pair<long long, int>, pair<int, int> > v[maxm];   bool chek = false;   int par(int x) {     if (x == parent[x]) return x;     int y = par(parent[x]);     b[x] += b[parent[x]];     b[x] %= 2;     return parent[x] = y;   }   void merge(int x, int y) {     int second = x, e = y;     x = par(x);     y = par(y);     if (x == y) {       if (b[second] == b[e]) chek = true;       return;     }     if (r[x] < r[y]) {       swap(x, y);       swap(second, e);     }     r[x] += r[y];     parent[y] = x;     b[y] = (b[e] + 1 + b[second]) % 2;   }   int main() {     ios::sync_with_stdio(false);     int x, y, second, e;     long long z;     cin >> n >> m >> q;     for (int i = 0; i < m; i++) {       cin >> x >> y >> z;       x--;       y--;       v[i] = make_pair(make_pair(z, i + 1), make_pair(x, y));     }     sort(v, v + m);     reverse(v, v + m);     for (int t = 0; t < q; t++) {       chek = false;       cin >> second >> e;       for (int i = 0; i < n; i++) {         parent[i] = i;         r[i] = 1;         b[i] = 0;       }       for (int i = 0; i < m; i++)         if (v[i].first.second >= second && v[i].first.second <= e) {           x = v[i].second.first;           y = v[i].second.second;           z = v[i].first.first;           merge(x, y);           if (chek == true) {             cout << z << endl;             break;           }         }       if (chek == false) cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, z = 1, k;   int main() {     cin >> n >> m;     if (n > m + 1 || n * 2 + 2 < m) return cout << -1, 0;     while (n || m) {       if ((m > n && k < 2) || z == 0)         m--, z = 1, k++;       else         n--, z = 0, k = 0;       cout << z;     }   }
#include <bits/stdc++.h>   using namespace std;   int a, b;   vector<int> res;   int main() {     scanf( %d%d , &a, &b);     while (true) {       res.push_back(b);       if (b == a) break;       if (b < a) {         printf( NO );         return 0;       }       if (b % 2 == 0)         b /= 2;       else if (b % 10 == 1)         b /= 10;       else {         printf( NO );         return 0;       }     }     printf( YES n%u n , res.size());     while (!res.empty()) printf( %d  , res.back()), res.pop_back();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long n, k;     cin >> n >> k;     multiset<pair<long long, long long>> s;     vector<tuple<long long, long long, long long>> v;     long long i;     for (i = 0; i < n; i++) {       long long a, b, p;       cin >> a >> b >> p;       s.insert({(a * a + b * b), i});       v.push_back(make_tuple(a, b, p));     }     if (k >= 1e6) {       cout << 0.00000000 <<   n ;       return 0;     }     long long f = -1;     double ans;     for (pair<long long, long long> x : s) {       pair<long long, long long> pp = x;       long long y = pp.second;       k += get<2>(v[y]);       f++;       if (k >= 1e6) {         double aa = get<0>(v[y]);         double bb = get<1>(v[y]);         ans = sqrt(aa * aa + bb * bb);         break;       }     }     if (k < 1e6) {       cout <<  -1 n ;       return 0;     }     std::cout << std::fixed;     std::cout << std::setprecision(10);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k, cnt = 0;     scanf( %d %d %d , &n, &m, &k);     int p[n], s[n], c[k];     for (int i = 0; i < n; i++) scanf( %d , &p[i]);     for (int i = 0; i < n; i++) scanf( %d , &s[i]);     for (int i = 0; i < k; i++) scanf( %d , &c[i]);     for (int i = 0; i < k; i++) {       int po = p[c[i] - 1];       int so = s[c[i] - 1];       for (int j = 0; j < n; j++) {         if (p[j] > po && s[j] == so) {           cnt++;           break;         }       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     int mx = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       mx = max(a[i], mx);     }     int cnt = 0;     int maxcnt = 0;     for (int i = 0; i < n; i++) {       if (a[i] == mx)         cnt++;       else {         maxcnt = max(cnt, maxcnt);         cnt = 0;       }       if (i == n - 1) {         maxcnt = max(cnt, maxcnt);       }     }     cout << maxcnt;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     int max = 0;     int cur = 0;     cin >> n;     string students[n];     for (int i = 0; i < n; ++i) {       cin >> students[i];     }     for (int i = 0; i < 7; ++i) {       cur = 0;       for (int j = 0; j < n; ++j) {         if (students[j][i] ==  1 ) {           cur++;         }       }       if (cur > max) {         max = cur;       }     }     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int rd();   int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }   int J(int x) {     int sum = 0;     for (int i = 1; i * i <= x; ++i) {       if (x % i == 0 && gcd(i, x / i) == 1) {         sum += i;         sum += x / i;       }     }     return sum;   }   const int N = 1000007;   int n, cnt, pr[N], lp[N];   void sieve() {     for (int i = 2; i < N; ++i) {       if (lp[i] == 0) {         lp[i] = i;         pr[cnt++] = i;       }       for (int j = 0; j < cnt && pr[j] <= lp[i] && pr[j] * i < N; ++j) {         lp[i * pr[j]] = pr[j];       }     }   }   long long getp(long long d) {     --d;     for (int i = 0; i < cnt && (long long)pr[i] * pr[i] <= d; ++i) {       if (d % pr[i] == 0) {         while (d % pr[i] == 0) d /= pr[i];         if (d == 1) return pr[i];         return -1;       }     }     return d;   }   vector<pair<long long, long long> > mas;   long long ans;   bool used[N];   void rec(int ptr, long long rem) {     if (rem == 1) {       ++ans;       return;     }     if (ptr == (int)(mas).size()) return;     if (rem % mas[ptr].first == 0 && !used[mas[ptr].second]) {       used[mas[ptr].second] = true;       rec(ptr + 1, rem / mas[ptr].first);       used[mas[ptr].second] = false;     }     rec(ptr + 1, rem);   }   void solve() {     sieve();     long long x;     cin >> x;     vector<long long> divs;     for (int i = 1; (long long)i * i <= x; ++i) {       if (x % i == 0) {         if (i != 1) divs.push_back(i);         if (i * i != x) divs.push_back(x / i);       }     }     sort((divs).begin(), (divs).end());     vector<long long> pp;     for (long long d : divs) {       long long p = getp(d);       if (p == -1 || p == 1) continue;       mas.push_back(make_pair(d, p));       pp.push_back(p);     }     sort((mas).begin(), (mas).end());     reverse((mas).begin(), (mas).end());     sort((pp).begin(), (pp).end());     for (int i = 0; i < ((int)(mas).size()); ++i)       mas[i].second =           lower_bound((pp).begin(), (pp).end(), mas[i].second) - pp.begin();     rec(0, x);     cout << ans << endl;   }   int rd() { return (((long long)rand() << 16) ^ rand()) % 1000000000; }   void testGen() {     FILE *f = fopen( input.txt ,  w );     fclose(f);   }   int main() {     cerr << fixed;     cerr.precision(9);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   const long long mod = 1000000007ll;   int n, cnt;   long long ans = 1;   int to[N], vis[N], dep[N];   long long power(long long x, long long t) {     long long ret = 1;     for (; t; t >>= 1ll, x = x * x % mod)       if (t & 1ll) ret = ret * x % mod;     return ret;   }   void dfs(int u, int step, int d) {     vis[u] = d;     dep[u] = step;     if (!vis[to[u]])       dfs(to[u], step + 1, d);     else if (vis[to[u]] == vis[u]) {       ans = ans * (power(2, dep[u] - dep[to[u]] + 1) - 2) % mod;       cnt += dep[u] - dep[to[u]] + 1;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &to[i]);     for (int i = 1; i <= n; ++i)       if (!vis[i]) dfs(i, 0, i);     ans = ans * power(2, n - cnt) % mod;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     if (n == 1) {       cout << 0;       return 0;     }     int arr[n + 1];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     arr[n] = 0;     int cl = (n - 1) / 2 + 1;     int dp[n + 3][cl + 1], mn[n + 3][cl + 1];     for (int j = 0; j <= cl; j++)       for (int i = 0; i <= n; i++) dp[i][j] = mn[i][j] = 1000000007;     dp[0][0] = 0;     mn[0][0] = 0;     dp[1][1] = 0;     mn[1][1] = max(0, arr[1] + 1 - arr[0]);     dp[2][1] = max(0, arr[0] + 1 - arr[1]);     mn[2][1] = min(mn[1][1], dp[2][1] + max(0, arr[2] + 1 - arr[1]));     for (int i = 3; i <= n; i++) {       dp[i][1] = max(0, -arr[i - 1] + 1 + arr[i - 2]);       mn[i][1] = min(mn[i - 1][1], dp[i][1] + max(0, arr[i] + 1 - arr[i - 1]));     }     for (int i = 0; i <= n; i++) {       for (int j = 1; j <= (i - 1) / 2 + 1; j++) {         if (i > 2 && j > 1) {           dp[i][j] = dp[i - 2][j - 1] + arr[i - 2] -                      min(arr[i - 2], min(arr[i - 3], arr[i - 1]) - 1);           int curr = max(0, arr[i - 2] + 1 - arr[i - 1]);           dp[i][j] = min(dp[i][j], curr + mn[i - 3][j - 1]);           mn[i][j] =               min(mn[i - 1][j], dp[i][j] + max(0, arr[i] + 1 - arr[i - 1]));         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= cl; j++) {         dp[i][j] = min(dp[i][j], mn[i - 1][j]);       }     }     for (int i = 1; i <= cl; i++) {       cout << dp[n][i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int get(int x) {     int t = log2(x);     if ((1 << t) < x) t++;     return (1 << t) - x;   }   unordered_map<int, int> to, pos;   unordered_map<int, vector<pair<pair<int, int>, int> > > mp;   int a[200005];   pair<pair<int, int>, int> num[200005];   int len = 0;   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     int ans = 0, a1 = 0, a2 = 0;     for (int i = 1; i <= n; i++) cin >> a[i], pos[a[i]] = i;     sort(a + 1, a + n + 1, greater<int>());     for (int i = 1; i <= n; i++) {       int x = a[i];       int cnt = 0;       while (x) {         int t = get(x);         cnt++;         mp[t].emplace_back(make_pair(make_pair(cnt, x), pos[a[i]]));         to[x] = t;         if (pos.count(t)) {           if (cnt > ans) {             ans = cnt;             a1 = pos[a[i]];             a2 = pos[t];           }         }         x = t;       }     }     for (auto u : mp) {       len = 0;       for (auto tu : u.second) {         num[++len] = tu;       }       sort(num + 1, num + len + 1);       pair<pair<int, int>, int> now = num[len];       while (len && num[len].first.second == now.first.second) len--;       if (len) {         pair<pair<int, int>, int> p2 = num[len];         if (now.first.first + p2.first.first > ans) {           ans = now.first.first + p2.first.first;           a1 = now.second;           a2 = p2.second;         }       }     }     cout << a1 <<     << a2 <<     << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   template <class T>   using vec = std::vector<T>;   bool __hack = std::ios::sync_with_stdio(false);   auto __hack1 = cin.tie(nullptr);   struct Input {     Input(istream &in) : in(&in) {}     template <class T>     T next() const {       T x;       *in >> x;       return x;     }     int ni() const { return next<int>(); }     istream *in;   };   Input in(cin);   class Output {    private:     ostream *out;     template <typename T>     void printSingle(const T &value) {       *out << value;     }       public:     Output(ostream &out) : out(&out) {}     inline void setPrecision(int d) { *out << fixed << setprecision(d); }     inline void print() {}     template <typename T, typename... Ts>     inline void print(const T &f, const Ts &...args) {       printSingle(f);       if (sizeof...(args) != 0) {         *out <<    ;         print(args...);       }     }     template <typename... Ts>     inline void println(const Ts &...args) {       print(args...);       (*out) <<   n ;     }     template <typename... Ts>     inline void operator()(const Ts &...args) {       println(args...);     }   };   Output out(cout);   namespace template_util {   constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }   template <int N>   struct bytetype {};   template <uint64_t N>   struct minimal_uint : bytetype<bytecount(N)> {};   }  // namespace template_util   double EPS = 1e-10;   bool doubleEqual(double a, double b) { return fabs(a - b) < EPS; }   void solveOne() {     auto n = in.ni();     auto len = in.ni();     vec<int> a(n + 2);     a[0] = 0;     a[n + 1] = len;     for (int i = (1); i <= (n); ++i) a[i] = in.ni();     int i = 0, j = n + 1;     double t = 0;     int s1 = 1, s2 = 1;     double x1 = 0, x2 = len;     out.setPrecision(15);     while (i + 1 < j) {       double d1 = a[i + 1] - x1;       double t1 = d1 / s1;       double d2 = x2 - a[j - 1];       double t2 = d2 / s2;       if (doubleEqual(t1, t2)) {         t += t1;         ++s1;         ++s2;         ++i;         --j;         x1 = a[i];         x2 = a[j];         if (i == j) {           out(t);           return;         }       } else if (t1 < t2) {         t += t1;         ++s1;         ++i;         x1 = a[i];         x2 -= t1 * s2;       } else {         t += t2;         ++s2;         --j;         x2 = a[j];         x1 += t2 * s1;       }     }     double d = x2 - x1;     double s = s1 + s2;     t += d / s;     out(t);   }   void solve(istream &inStream, ostream &outStream) {     in = Input(inStream);     out = Output(outStream);     auto tests = in.ni();     while (tests--) {       solveOne();     }   }   int main() {     solve(cin, cout);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( unroll-loops )   #pragma comment(linker,  /STACK:2000000 )   using namespace std;   template <int D, typename T>   struct Vec : public vector<Vec<D - 1, T>> {     static_assert(D >= 1,  Vector dimension must be greater than zero! );     template <typename... Args>     Vec(int n = 0, Args... args)         : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}   };   template <typename T>   struct Vec<1, T> : public vector<T> {     Vec(int n = 0, T val = T()) : vector<T>(n, val) {}   };   using ll = long long;   using db = long double;   using ii = pair<int, int>;   const int N = 2e5 + 5, LG = 19, MOD = 998244353;   const int SQ = 320;   const long double EPS = 1e-7;   void printCase(int cs) { cout <<  Case #  << cs <<  :  ; }   int n;   vector<ii> arr;   int mx[3005][3005];   void read() {     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       arr.push_back(ii(x, i));     }     sort(arr.rbegin(), arr.rend());     arr.push_back(ii(0, n));   }   int getVal(int i) { return arr[i].first - arr[i + 1].first; }   void initMax() {     for (int i = 0; i < n; i++) {       mx[i][i] = i;       for (int j = i + 1; j < n; j++) {         mx[i][j] = mx[i][j - 1];         if (getVal(j) > getVal(mx[i][j])) {           mx[i][j] = j;         }       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     read();     initMax();     vector<int> ans(6, INT_MIN);     for (int i = 1; i < n; i++)       for (int j = i; j < n; j++)         if (i <= (j - i + 1) * 2 && i * 2 >= (j - i + 1)) {           int mn = min(j - i + 1, i);           int mx = max(j - i + 1, i);           int r = mn * 2;           int l = (mx + 1) / 2;           if (j + l < n) {             int k = ::mx[j + l][min(n - 1, j + r)];             vector<int> v({getVal(i - 1), getVal(j), getVal(k), i, j + 1, k + 1});             ans = max(ans, v);           }         }     vector<int> out(n, -1);     for (int i = 0; i < ans[3]; i++) out[arr[i].second] = 1;     for (int i = ans[3]; i < ans[4]; i++) out[arr[i].second] = 2;     for (int i = ans[4]; i < ans[5]; i++) out[arr[i].second] = 3;     for (int i = 0; i < n; i++) cout << out[i] <<    n [i + 1 == n];     return 0;   }
#include <bits/stdc++.h>   int max(int a, int b) {     if (a > b)       return a;     else       return b;   }   int main() {     int n, m, p, r, x, y, c, i, j, zb, maxz;     int max1, max2, max3, max4, minz;     scanf( %d %d , &n, &m);     scanf( %d , &c);     for (i = 1; i <= c; i++) {       scanf( %d %d , &x, &y);       if (i == 1) max1 = x + y, max2 = x - y, max3 = -x + y, max4 = -x - y;       if (i > 1 && x + y > max1) max1 = x + y;       if (i > 1 && x - y > max2) max2 = x - y;       if (i > 1 && -x + y > max3) max3 = -x + y;       if (i > 1 && -x - y > max4) max4 = -x - y;     }     scanf( %d , &r);     for (i = 1; i <= r; i++) {       scanf( %d %d , &x, &y);       maxz = max(max1 - (x + y), max2 - (x - y));       maxz = max(maxz, max3 - (-x + y));       maxz = max(maxz, max4 - (-x - y));       if (i == 1) minz = maxz, zb = 1;       if (i > 1 && maxz < minz) minz = maxz, zb = i;     }     printf( %d n , minz);     printf( %d n , zb);   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> g;   vector<vector<pair<long long, int> > > vec;   const int MAXN = 100010;   pair<long long, int> msum[MAXN][2];   bool cmp2(pair<long long, int> a, pair<long long, int> b) {     return b.first < a.first;   }   int main() {     int n, c, s;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d %d , &c, &s);       if (g.find(c) == g.end()) {         g[c] = vec.size();         vec.push_back(vector<pair<long long, int> >());       }       int id = g[c];       vec[id].push_back(make_pair(s, i + 1));     }     int len = 0;     for (int i = 0; i < vec.size(); ++i) {       sort(vec[i].begin(), vec[i].end(), cmp2);       len = max(len, (int)vec[i].size());       for (int j = 0; j < vec[i].size(); ++j) {         if (j != 0) vec[i][j].first += vec[i][j - 1].first;         if (vec[i][j].first >= msum[j][0].first) {           msum[j][1] = msum[j][0];           msum[j][0].first = vec[i][j].first;           msum[j][0].second = i;         } else if (vec[i][j].first > msum[j][1].first) {           msum[j][1].first = vec[i][j].first;           msum[j][1].second = i;         }       }     }     long long ans = 0;     int fc = -1, fl, sc, sl;     for (int i = 0; i < len; ++i) {       if (msum[i][0].first == 0) continue;       if (msum[i][1].first != 0) {         if (msum[i][0].first + msum[i][1].first > ans) {           ans = msum[i][0].first + msum[i][1].first;           fc = msum[i][0].second, fl = i + 1;           sc = msum[i][1].second, sl = i + 1;         }       }       if (i + 1 == len || msum[i + 1][0].first == 0) continue;       if (msum[i + 1][0].second != msum[i][0].second) {         if (msum[i][0].first + msum[i + 1][0].first > ans) {           ans = msum[i][0].first + msum[i + 1][0].first;           fc = msum[i][0].second, fl = i + 1;           sc = msum[i + 1][0].second, sl = i + 2;         }       } else {         if (msum[i][1].first != 0 &&             msum[i][1].first + msum[i + 1][0].first > ans) {           ans = msum[i][1].first + msum[i + 1][0].first;           fc = msum[i][1].second, fl = i + 1;           sc = msum[i + 1][0].second, sl = i + 2;         }         if (msum[i + 1][1].first != 0 &&             msum[i][0].first + msum[i + 1][1].first > ans) {           ans = msum[i][0].first + msum[i + 1][1].first;           fc = msum[i][0].second, fl = i + 1;           sc = msum[i + 1][1].second, sl = i + 2;         }       }     }     cout << ans << endl;     if (fc != -1) {       cout << fl + sl << endl;       for (int i = 0; i < fl; ++i) {         if (i) putchar(   );         printf( %d %d , vec[sc][i].second, vec[fc][i].second);       }       if (sl != fl) {         printf(  %d , vec[sc][fl].second);       }       puts(  );     } else {       cout << 0 << endl;     }     return 0;   }