malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   void print(int base) {     if (base == 4) cout <<  4 * 3 = 12 n12 * 2 = 24 n24 * 1 = 24  << endl;     if (base == 5)       cout <<  5 * 4 = 20 n3 + 2 = 5 n5 - 1 = 4 n20 + 4 = 24  << endl;     if (base == 6)       cout <<  4 * 3 = 12 n12 * 2 = 24 n5 + 1 = 6 n6 - 6 = 0 n24 + 0 = 24             << endl;     if (base == 7)       cout <<  5 * 3 = 15 n15 + 7 = 22 n2 - 1 = 1 n22 * 1 = 22 n6 - 4 = 2 n22 +                  2 = 24             << endl;   }   void solve(int n, int base) {     print(base);     if (n == base) return;     cout << base + 1 <<   +   << base + 4 <<   =   << 2 * base + 5 <<   n ;     cout << base + 2 <<   +   << base + 3 <<   =   << 2 * base + 5 <<   n ;     long long sm1 = 2 * base + 5, sm2 = 2 * base + 5, cs = 0;     for (int i = base + 5; i <= n; i += 2) {       if (cs) {         cout << sm1 <<   +   << i <<   =   << sm1 + i <<   n ;         cout << sm2 <<   +   << i + 1 <<   =   << sm2 + i + 1 <<   n ;         cs = 0;         sm1 += i;         sm2 += i + 1;       } else {         cout << sm1 <<   +   << i + 1 <<   =   << sm1 + i + 1 <<   n ;         cout << sm2 <<   +   << i <<   =   << sm2 + i <<   n ;         cs = 1;         sm1 += i + 1;         sm2 += i;       }     }     cout << sm1 <<   -   << sm2 <<   =            <<  0 n ;     cout <<  24 + 0 = 24 n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int n;     cin >> n;     if (n < 4) return puts( NO ), 0;     cout <<  YES  << endl;     for (int i = 4; i <= 7; ++i) {       if ((((n - i) / 2) % 2 == 0) && (n - i) % 2 == 0) solve(n, i);     }   }
#include <bits/stdc++.h>   using namespace std;   int arr[105];   int main() {     int n;     cin >> n;     int pos = 0;     int neg = 0;     int z = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] > 0)         pos++;       else if (arr[i] < 0)         neg++;       else         z++;     }     int pas = 0;     if (n % 2 == 0)       pas = n / 2;     else       pas = (n / 2) + 1;     int maxi = pos;     if (neg > pos) maxi = neg;     if (maxi >= pas && maxi == pos) {       cout << 1 << endl;     } else if (maxi >= pas && maxi == neg) {       cout << -1 << endl;     } else {       cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[500][500];   int d[500][500];   long long int ans[500];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int num;         cin >> num;         a[i][j] = num;         d[i][j] = num;       }     }     int b[n];     for (int i = 0; i < n; i++) {       cin >> b[i];       b[i]--;     }     reverse(b, b + n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         for (int s = 0; s < n; s++) {           d[j][s] = min(d[j][s], d[j][b[i]] + d[b[i]][s]);         }       }       for (int j = 0; j <= i; j++) {         for (int s = 0; s <= i; s++) {           ans[i] += d[b[j]][b[s]];         }       }     }     reverse(ans, ans + n);     for (int i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct trie {     int s, x[2], w[30];   } t[50005 * 30];   int N, S, a[50005], p[50005];   long long M;   void ins(int x) {     for (int i = 30 - 1, c, p = 1; c = (x >> i) & 1, i >= 0; i--) {       if (!t[p].x[c]) t[p].x[c] = ++S;       p = t[p].x[c], t[p].s++;       for (int j = 0; j <= i; j++) t[p].w[j] += (x >> j) & 1;     }   }   void init() {     scanf( %d%lld , &N, &M), M *= 2, S++;     for (int i = 1; i <= N; i++) scanf( %d , &a[i]), ins(a[i]), p[i] = 1;   }   void doit() {     long long ans = 0, W = 0;     for (int i = 30 - 1; M && i >= 0; i--) {       long long s = 0;       for (int j = 1; j <= N; j++) s += t[t[p[j]].x[!(a[j] >> i & 1)]].s;       if (s <= M) {         for (int j = 1, c, q; c = (a[j] >> i) & 1, q = p[j], j <= N;              p[j++] = t[q].x[c])           if (q) {             for (int k = 0; k <= i; k++)               ans += 1ll * ((a[j] >> k) & 1 ? t[t[q].x[!c]].s - t[t[q].x[!c]].w[k]                                             : t[t[q].x[!c]].w[k])                      << k;             ans += 1ll * t[t[q].x[!c]].s * W;           }         M -= s;       } else         for (int j = 1; j <= N; j++)           p[j] = t[p[j]].x[!(a[j] >> i & 1)], W |= 1 << i;     }     printf( %d n , (ans + M * W) / 2 % 1000000007);   }   int main() {     init();     doit();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   int ma[maxn];   int en[maxn];   int add = 0;   int main() {     std::ios::sync_with_stdio(false);     int n, d;     cin >> n >> d;     int sum = 0;     int mx = -40000000;     int op = 0;     for (int i = 0; i < n; i++) {       int in;       cin >> in;       if (in != 0) {         sum += in;         mx = max(mx, sum);         if (sum > d) {           cout <<  -1  << endl;           return 0;         }       } else {         if (sum >= 0) continue;         ma[op] = mx;         en[op++] = sum;         sum = 0;         mx = -400000000;       }     }     int cnt = 0;     for (int i = 0; i < op; i++) {       if (min(add, d - ma[i]) < abs(en[i])) {         cnt++;         add = d;       } else {         add = min(add, d - ma[i]) - abs(en[i]);       }     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<vector<int> > field;     int x, y;     cin >> x >> y;     field.resize(x);     for (int i = 0; i < x; ++i) field[i].resize(y);     for (int i = 0; i < x; ++i)       for (int j = 0; j < y; ++j) field[i][j] = 0;     int x0, y0;     cin >> x0 >> y0;     x0 -= 1;     y0 -= 1;     field[x0][y0] = 1;     int count = x * y - 1;     string s;     cin >> s;     cout <<  1  ;     for (unsigned int i = 0; i < s.size() - 1; ++i) {       if (s[i] ==  U  && x0 != 0) {         x0 -= 1;         if (field[x0][y0] != 1) {           field[x0][y0] = 1;           --count;           cout <<  1  ;         } else           cout <<  0  ;       } else if (s[i] ==  D  && x0 != x - 1) {         x0 += 1;         if (field[x0][y0] != 1) {           field[x0][y0] = 1;           --count;           cout <<  1  ;         } else           cout <<  0  ;       } else if (s[i] ==  L  && y0 != 0) {         y0 -= 1;         if (field[x0][y0] != 1) {           field[x0][y0] = 1;           --count;           cout <<  1  ;         } else           cout <<  0  ;       } else if (s[i] ==  R  && y0 != y - 1) {         y0 += 1;         if (field[x0][y0] != 1) {           field[x0][y0] = 1;           --count;           cout <<  1  ;         } else           cout <<  0  ;       } else         cout <<  0  ;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[+100500 * 2], ans;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %I64d , &a[i]);     }     for (int i = 1; i <= n; i++) {       ans += abs(a[i] - a[i - 1]);     }     printf( %I64d , ans);     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     string str;     getline(cin, str);     bool isok = true;     for (int i = 0; i < n; i++) {       getline(cin, str);       int x = 0;       for (int j = 0; j < str.length(); j++) {         if (str[j] ==  a  || str[j] ==  e  || str[j] ==  i  || str[j] ==  o  ||             str[j] ==  u  || str[j] ==  y )           x++;       }       if (x != v[i]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long a, b;     cin >> a >> b;     vector<string> A;     for (long long i = 0; i < a; i++) {       string res =   ;       for (long long j = 0; j < b; j++) {         if (i % 4 == 0 || i % 4 == 2) {           res +=  # ;         } else if (i % 4 == 1 || i % 4 == 3) {           res +=  . ;         }       }       if (i % 4 == 1)         res[res.length() - 1] =  # ;       else if (i % 4 == 3)         res[0] =  # ;       A.push_back(res);     }     for (auto i : A) {       cout << i <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long tt(1);     while (tt--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long pow(long long a, long long b) {     if (b == 0) {       return 1;     }     if (b % 2 == 0) {       return pow((a % 1000000007) * (a % 1000000007), b / 2) % 1000000007;     } else {       return (a % 1000000007) *              (pow((a % 1000000007) * (a % 1000000007), (b - 1) / 2) % 1000000007);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int i, j, k, n;     cin >> n >> k;     double x[n], y[n];     for (i = 0; i < n; i++) {       cin >> x[i] >> y[i];     }     double ans = 0.000000000;     for (i = 1; i < n; i++) {       ans += sqrt((x[i] - x[i - 1]) * (x[i] - x[i - 1]) +                   (y[i] - y[i - 1]) * (y[i] - y[i - 1]));     }     double f = (ans * double(k)) / (50.0000000000);     cout << fixed << setprecision(10) << f <<   n ;   }
#include <bits/stdc++.h>   const long long P = 1000000007;   long long N, oldA, oldB, oldC, oldD = 1, newA, newB, newC, newD;   int main() {     std::cin >> N;     for (int i = 1; i <= N; ++i) {       newA = (oldB + oldC + oldD) % P;       newB = (oldA + oldC + oldD) % P;       newC = (oldA + oldB + oldD) % P;       newD = (oldA + oldB + oldC) % P;       oldA = newA;       oldB = newB;       oldC = newC;       oldD = newD;     }     std::cout << newD;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   long long a[N][26];   int b[N];   long long ans[28];   char s[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       cin >> (s + 1);       for (int i = 0; i <= n; i++) {         for (int j = 0; j <= 26; j++) {           a[i][j] = 0;         }       }       for (int i = 0; i < 26; i++) ans[i] = 0;       for (int i = 0; i < m; i++) cin >> b[i];       for (int i = 1; i <= n; i++) {         int d = s[i] -  a ;         a[i][d]++;       }       for (int i = 0; i < 26; i++) {         for (int j = 2; j <= n; j++) {           a[j][i] = a[j - 1][i] + a[j][i];         }       }       for (int i = 0; i < m; i++) {         int k = b[i];         for (int j = 0; j < 26; j++) {           ans[j] += a[k][j];         }       }       for (int i = 0; i < 26; i++) {         ans[i] += a[n][i];       }       for (int i = 0; i < 26; i++) {         if (i) cout <<    ;         cout << ans[i];       }       cout << endl;     }     return 0;   }
#pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization ( O3 )   #pragma GCC optimization ( unroll-loops )      #include<bits/stdc++.h>   using namespace std;      #define pb push_back   #define mp make_pair   #define F first   #define S second   #define lb lower_bound   #define ub upper_bound   #define sz(x) (int)(x).size()   #define all(x) x.begin(), x.end()      typedef long long ll;   typedef long double ld;   typedef complex<ld> cd;   typedef pair<int, int> pii;   typedef pair<ll,ll> pll;   typedef pair<ld,ld> pld;   typedef vector<int> vi;   typedef vector<ld> vd;   typedef vector<ll> vl;   typedef vector<pii> vpi;   typedef vector<pll> vpl;      #define FOR(i, a, b) for (int i=a; i<(b); i++)   #define F0R(i, a) for (int i=0; i<(a); i++)   #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)   #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)   #define trav(a,x) for (auto& a : x)      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());       ll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}   ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}   int n,d;      void solve() {       int n; string a,b;       cin >> n >> a >> b;       if(a==b) { cout << b <<   n ; return ; }       if(a[0] ==  0 ) { F0R(i,n) cout <<  1 ; cout<<  n ; return; }       if(b.back() ==  1  || a == b) { cout << b <<   n ; return ; }        {                  int l = n-1;           while(a[l] ==  1 ) --l;           a[l]= 1 ; FOR(i,l+1,n) a[i]= 0 ;       }       if(a != b) b[n-1] =  1 ;       { cout << b <<   n ; return ; }   }         int main(){       ios_base::sync_with_stdio(false); cin.tie(NULL);         #ifndef ONLINE_JUDGE           freopen( input.txt , r ,stdin);           freopen( output.txt , w ,stdout);       #endif        int t=1,Tc=1;       while(t--){           //cout <<  Case # <<Tc<< :  ; Tc++;           solve();       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve(string second, char cur) {     if (second.size() == 1) {       return !(second[0] == cur);     }     int n = second.size();     int check = 0;     for (int i = 0; i < n / 2; i++) {       check += (second[i] == cur);     }     int check2 = 0;     for (int i = n / 2; i < n; i++) {       check2 += (second[i] == cur);     }     int a = solve(second.substr(n / 2, n / 2), cur + 1) + n / 2 - check;     int b = solve(second.substr(0, n / 2), cur + 1) + n / 2 - check2;     return min(a, b);   }   int main() {     std::ios::sync_with_stdio(false);     int T;     cin >> T;     int n;     string second;     while (T--) {       cin >> n;       cin >> second;       cout << solve(second,  a ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long INF = 0x7FFFFFFFFFFFFFFF;   long long binpow(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a;       a = a * a;       b >>= 1;     }     return res;   }   long long ask(vector<long long>& v) {     cout <<  ?   << (long long int)(v).size() <<    ;     for (long long i = 0; i < (long long int)(v).size(); ++i) cout << v[i] <<    ;     cout <<   n  << flush;     long long res;     cin >> res;     return res;   }   vector<long long> comp(vector<long long>& st, long long n) {     vector<bool> pres(n + 1, 0);     for (long long i = 0; i < (long long int)(st).size(); ++i) pres[st[i]] = 1;     vector<long long> res;     for (long long i = 1; i < n + 1; ++i) {       if (!pres[i]) res.push_back(i);     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long T;     cin >> T;     while (T--) {       long long n, k;       cin >> n >> k;       vector<vector<long long> > st(k);       for (long long i = 0; i < k; ++i) {         long long c;         cin >> c;         st[i].resize(c);         for (long long j = 0; j < c; ++j) cin >> st[i][j];       }       vector<long long> a(n);       iota((a).begin(), (a).end(), 1);       long long mx = ask(a);       long long l = 0, r = k - 1;       while (l < r) {         long long md = (l + r) / 2;         a.clear();         for (long long i = 0; i < md + 1; ++i) {           for (long long j = 0; j < (long long int)(st[i]).size(); ++j)             a.push_back(st[i][j]);         }         long long m = ask(a);         if (m == mx)           r = md;         else           l = md + 1;       }       vector<long long> ans(k, mx);       vector<long long> c = comp(st[l], n);       long long m = ask(c);       ans[l] = m;       cout <<  !  ;       for (long long i = 0; i < k; ++i) cout << ans[i] <<    ;       cout <<   n  << flush;       string strl;       cin >> strl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool smin(T &a, const T &b) {     return b < a ? a = b, 1 : 0;   }   template <typename T>   inline bool smax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const long long N = (long long)1e6 + 10;   long long n, ar[N], m, bl[N], br[N], pre[N], fen[N], res[N];   vector<long long> qs[N];   map<long long, long long> last;   long long get_xor(long long l, long long r) {     if (!l) return pre[r];     return pre[r] ^ pre[l - 1];   }   void add(long long i, long long val) {     for (; i < N; i += (i & -i)) fen[i] ^= val;   }   long long get(long long i) {     long long ret = 0;     for (; i; i ^= (i & -i)) ret ^= fen[i];     return ret;   }   void add(long long l, long long r, long long val) {     add(r, val);     if (l > 1) add(l - 1, val);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (long long i = 1; i <= n; ++i) {       cin >> ar[i];       if (i) pre[i] = pre[i - 1];       pre[i] ^= ar[i];     }     cin >> m;     for (long long j = 0; j < m; ++j) {       cin >> bl[j] >> br[j];       qs[br[j]].push_back(j);     }     for (long long j = 1; j <= n; ++j) last[ar[j]] = -1;     for (long long i = 1; i <= n; ++i) {       long long x = ar[i];       if (last[x] == -1)         add(1, i, x);       else         add(last[x] + 1, i, x);       last[x] = i;       for (long long p : qs[i]) {         res[p] = get_xor(bl[p], i);         res[p] ^= get(i);         res[p] ^= get(bl[p] - 1);       }     }     for (long long j = 0; j < m; ++j) cout << res[j] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   const int CS = 22;   int cmax[N][CS], cmin[N][CS], ans[N];   int lt[CS];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &cmax[i][0]);       cmax[i][0] *= 100;     }     for (int i = 1; i <= n; i++) scanf( %d , &cmin[i][0]);     int cs = 1;     for (int g = 1; g < n; g <<= 1, cs++) {       int gg = g << 1;       for (int i = 1; i <= n; i++) {         if (i + gg - 1 > n)           cmax[i][cs] = cmin[i][cs] = 0;         else {           cmax[i][cs] = max(cmax[i][cs - 1], cmax[i + g][cs - 1]);           cmin[i][cs] = min(cmin[i][cs - 1], cmin[i + g][cs - 1]);         }       }     }     lt[0] = 1;     for (int i = 1; i < cs; i++) lt[i] = lt[i - 1] << 1;     for (int i = 1; i <= n; i++) {       ans[i] = 0;       int tmax = 0, tmin = 10000000;       int mid = i;       for (int j = cs - 1; j >= 0; j--) {         if (cmax[mid][j] > 0) {           int tmax2 = max(tmax, cmax[mid][j]);           int tmin2 = min(tmin, cmin[mid][j]);           ans[i] = max(ans[i], min(tmax2, tmin2));           if (tmax2 <= tmin2) {             tmax = tmax2;             tmin = tmin2;             if (tmax == tmin) break;             mid += lt[j];             if (mid > n) break;           }         }       }     }     sort(ans + 1, ans + n + 1);     double p = 1.0;     double res = 0;     for (int i = 1; i <= n - k + 1; i++) {       if (p < 1e-20) break;       double pp = k * 1.0 / (n - i + 1);       res += p * pp * ans[i];       p *= (1 - pp);     }     printf( %.12f , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(string s) {     for (int i = 0; i < s.size() / 2; i++)       if (s[i] != s[s.size() - 1 - i]) return 0;     return 1;   }   int main() {     int jopa;     string s;     cin >> s;     int p = 0;     char a = s[0];     for (int i = 0; i < s.size(); i++)       if (s[i] == a) p++;     if (p >= s.size() - 1) {       cout <<  Impossible ;       return 0;     }     int n = s.size();     s = s + s;     for (int i = 1; i < n; i++) {       if (i + n - 1 >= s.size()) break;       if (check(s.substr(i, n)) && s.substr(i, n) != s.substr(0, n)) {         cout << 1;         return 0;       }     }     cout << 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int main() {     string s;     cin >> s;     int k = 0, c = 0;     for (int i = s.size() - 1; i >= 0; i--) {       if (s[i] ==  b )         c++;       else {         k += c;         c *= 2;         k %= MOD;         c %= MOD;       }     }     cout << k <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long t1[100], t2[100], n, k, m, i, j, mod[10], o, s;   int main() {     scanf( %I64d %I64d %I64d , &n, &k, &m);     t1[0] = 1;     for (i = 0; i < 10; i++) mod[i] = i % k;     for (i = 1; i <= n; i++) {       for (j = 0; j < 10; j++) {         if (j == 0 && (i == n || i == 1)) continue;         for (o = 0; o < k; o++) {           t2[(o + mod[j]) % k] += t1[o];         }       }       if (i != 1) {         for (j = 1; j < 10; j++) {           t2[mod[j]]++;         }       }       s += t2[0];       t2[0] = 0;       t1[0] = 0;       if (i != n) {         if (i == n - 1)           s *= 9;         else           s *= 10;         s %= m;       }       for (j = 1; j < k; j++) {         t1[j] = t2[j] % m;         t2[j] = 0;       }       for (j = 0; j < 10; j++) mod[j] = (mod[j] * 10) % k;     }     s %= m;     printf( %I64d n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     long long nu[n];     for (long long i = 0; i < n; ++i) {       char a;       cin >> a;       nu[i] = a -  0 ;     }     long long f[10];     for (long long i = 0; i < 9; ++i) cin >> f[i + 1];     for (long long i = 0; i < n; ++i) {       if (f[nu[i]] > nu[i]) {         long long dab = i;         for (dab = i; dab < n && f[nu[dab]] >= nu[dab]; ++dab) {           nu[dab] = f[nu[dab]];         }         break;       }     }     for (long long i = 0; i < n; ++i) {       cout << nu[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const maxn = 100100;   long long a[maxn];   set<long long> s;   int main() {     int n, k;     long long x1, x2, x3, x4;     while (~scanf( %d%d , &n, &k)) {       for (int i = 0; i < n; ++i) {         scanf( %I64d.%I64d.%I64d.%I64d , &x1, &x2, &x3, &x4);         a[i] = (x1 << 24) | (x2 << 16) | (x3 << 8) | x4;       }       long long ret = -1;       for (int i = 31; i >= 0; --i) {         long long t = (1LL << 32) - (1LL << i);         s.clear();         for (int j = 0; j < n; ++j) {           s.insert(t & a[j]);         }         if (s.size() == k) {           ret = t;           break;         }       }       if (ret == -1)         puts( -1 );       else {         printf( %I64d.%I64d.%I64d.%I64d n , ret >> 24, (ret >> 16) & 255,                (ret >> 8) & 255, ret & 255);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<long long> vec(n, 0);     for (long long i = 0; i < n; i++) cin >> vec[i];     long long mn = 10e9 + 1, mx = -1, count = 0;     for (long long i = 1; i < n; i++) {       if (vec[i] == -1 && vec[i - 1] != -1) {         mn = min(mn, vec[i - 1]);         mx = max(mx, vec[i - 1]);       }     }     for (long long i = 0; i < n - 1; i++) {       if (vec[i] == -1 && vec[i + 1] != -1) {         mn = min(mn, vec[i + 1]);         mx = max(mx, vec[i + 1]);       }     }     if (mx == -1) {       cout << 0 <<     << 0 << endl;     } else {       long long k = (mx + mn) / 2;       for (long long i = 0; i < n; i++) {         if (vec[i] == -1) {           vec[i] = k;         }       }       long long dif = 0;       for (long long i = 1; i < n; i++) {         dif = max(dif, abs(vec[i] - vec[i - 1]));       }       cout << dif <<     << k << endl;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t-- > 0) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #define ll long long   #define f(i, n) for (i = 0; i < n; ++i)   #define all(n) n.begin(), n.end()   #define P long(1e9 + 7)   #define fastio                               ios_base::sync_with_stdio(false);        cin.tie(NULL)      using namespace std;      ll solve(vector<vector<ll>>& dp, vector<ll>& s, int l, int r)   {       if (l == r)           return dp[l][r] = 0;          if (dp[l][r] == -1) {           ll val = s[r] - s[l];           val += min(solve(dp, s, l + 1, r), solve(dp, s, l, r - 1));           return dp[l][r] = val;       }          return dp[l][r];   }      int main()   {       int n, i, j, k, l, m;       cin >> n;       vector<ll> s(n, 0);       vector<vector<ll>> dp(n, vector<ll>(n, -1));       f(i, n) cin >> s[i];       sort(all(s));          cout << solve(dp, s, 0, n - 1);   }