malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, m, x, y, a, b;   int main() {     cin >> n >> m >> x >> y >> a >> b;     long long W = min(n, (m * a) / b);     long long divA = a, divB = b;     for (long long i = 2; i * i <= divB; i++) {       while (divB % i == 0) {         if (divA % i == 0) {           divA /= i;         }         divB /= i;       }     }     if (divA % divB == 0) divA /= divB;     W -= (W % divA);     long long H = (W * b) / a;     long long x1 = x - ((W + 1) / 2);     long long y1 = y - ((H + 1) / 2);     long long x2 = x1 + W;     long long y2 = y1 + H;     if (x2 > n) {       x2 = n;       x1 = x2 - W;     }     if (x1 < 0) {       x1 = 0;       x2 = W;     }     if (y2 > m) {       y2 = m;       y1 = y2 - H;     }     if (y1 < 0) {       y1 = 0;       y2 = H;     }     W = x2 - x1;     H = y2 - y1;     cout << x1 <<     << y1 <<     << x2 <<     << y2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 1e4;   int a[maxn], mod;   int b[maxn];   int n;   int pow(int a, int b) {     if (b == 1) return a;     int t = pow(a, b >> 1);     t = 1LL * t * t % mod;     if (b & 1) t = 1LL * t * a % mod;     return t;   }   int ny(int a) { return pow(a, mod - 2); }   int ans, dd;   void solve(int a[], int n) {     if (n == 1) {       ans = a[1];       dd = 1;       return;     }     int cc = a[2] - a[1];     int s = 0;     for (int i = (1); i <= (n); ++i)       if (!binary_search(a + 1, a + n + 1, (a[i] + cc) % mod)) ++s;     cc = 1LL * cc * ny(s) % mod;     ans = -1, dd = mod - cc;     for (int i = (1); i <= (n); ++i)       if (!binary_search(a + 1, a + n + 1, (a[i] + cc) % mod)) {         if (ans == -1)           ans = a[i];         else {           ans = -1;           break;         }       }   }   void init() {     scanf( %d%d , &mod, &n);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]);     if (n == mod) {       printf( %d %d n , 0, 1);       return;     }     sort(a + 1, a + n + 1);     if (n * 2 > mod) {       int t = 0;       for (int i = (0); i <= (mod - 1); ++i)         if (!binary_search(a + 1, a + n + 1, i)) b[++t] = i;       solve(b, t);       if (ans != -1) (ans += 1LL * dd * t % mod) %= mod;     } else       solve(a, n);     if (ans == -1)       printf( %d n , ans);     else       printf( %d %d n , ans, dd);   }   int main() {     init();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, rsp, ans, taram;   char first;   int main() {     cin >> n;     cin >> first;     if (first ==  U ) {       taram = 2;       rsp++;     } else       taram = 1;     for (int i = 2; i <= n; i++) {       cin >> first;       if (rsp * 2 == i - 1) {         ans += (first ==  R  && taram == 2);         ans += (first ==  U  && taram == 1);         if ((first ==  R  && taram == 2) || (first ==  U  && taram == 1))           taram = taram % 2 + 1;       }       if (first ==  U ) rsp++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n, x, y;     cin >> n >> x >> y;     vector<int> arr(n, 0);     for (int i = 0; i < n; ++i) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     if (x > y) {       cout << n <<   n ;     } else {       int index = -1;       for (int i = 0; i < n; ++i) {         if (arr[i] > x) {           index = i;           break;         }       }       if (index == -1) {         if (n % 2 == 1) {           cout << n / 2 + 1 <<   n ;         } else {           cout << n / 2 <<   n ;         }       } else {         if ((index) % 2 == 1) {           cout << (index) / 2 + 1 <<   n ;         } else {           cout << (index) / 2 <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int a, b;       cin >> a >> b;       long long int x;       x = a % b;       if (x == 0)         cout << x << endl;       else {         long long int r = a / b;         long long int res = (r + 1) * b - a;         cout << res << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int u, int v) {     int tmp;     while (v) {       tmp = v;       v = u % v;       u = tmp;     }     return u;   }   int main() {     int a, b, t;     cin >> a >> b;     if (a > b) {       swap(a, b);     }     if ((t = gcd(a, b)) == 1) {       cout <<  NO  << endl;       return 0;     }     int flag = 1;     for (int i = 1; i <= t; i++) {       for (int j = i; j <= t; j++) {         if (t * t == i * i + j * j) {           flag = 0;           cout <<  YES  << endl;           cout <<  0 0  << endl;           cout << i * a / t <<     << -j * a / t << endl;           cout << j * b / t <<     << i * b / t << endl;           return 0;         }       }     }     if (flag) cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string str1, str2;     cin >> str1 >> str2;     int diffcount = 0;     for (int i = 0; i < str1.length(); i++) {       if (str1[i] != str2[i]) diffcount++;     }     if (diffcount % 2 == 1) {       cout <<  impossible ;       return 0;     }     int index = 0;     int toreach = diffcount / 2;     while (diffcount != toreach) {       if (str1[index] != str2[index]) {         if (str1[index] ==  1 )           str1[index] =  0 ;         else           str1[index] =  1 ;         diffcount--;       }       index++;     }     cout << str1;   }
#include<iostream>   #include<algorithm>   using namespace std;   class node{       public:           int a;           int b;   };   bool com(node a,node b){       return a.a<b.a;   }   int main(){       int times=0;       cin>>times;       while(times--){           int t=0;           cin>>t;           node *arr=new node[t+5]();           for(int i=0;i<t;i++){               scanf( %d ,&arr[i].a);               arr[i].b=i+1;           }           if(t==1){               cout<<arr[0].a<<endl;               continue;           }           sort(arr,arr+t,com);           bool fl=false;           for(int i=0;i<t;i++){               if(i==0){                   if(arr[i].a!=arr[i+1].a){                       cout<<arr[i].b<<endl;                       fl=true;                       break;                   }               }               if(i==t-1){                   if(arr[i].a!=arr[i-1].a){                       cout<<arr[i].b<<endl;                       fl=true;                       break;                   }               }               if(arr[i].a!=arr[i+1].a&&arr[i].a!=arr[i-1].a){                   cout<<arr[i].b<<endl;                       fl=true;                       break;               }           }           if(!fl)           cout<<-1<<endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long double l, v1, v2;   long double a[100000];   long double p[100001];   vector<pair<long double, int> > events;   int main() {     cout << fixed << setprecision(12);     cin >> n >> l >> v1 >> v2;     long double dist = l * v2 / (v1 + v2);     events.push_back(make_pair(0, 0));     events.push_back(make_pair(2 * l, 0));     for (int i = 0; i < n; ++i) {       cin >> a[i];       events.push_back(make_pair(a[i] - dist, 1));       events.push_back(make_pair(a[i] + 2 * l - dist, 1));       events.push_back(make_pair(a[i], -1));     }     sort(events.begin(), events.end());     memset(p, 0, sizeof p);     int choc = 0, i = 0;     while (events[i].second != 0) {       choc += events[i].second;       ++i;     }     ++i;     while (events[i].second != 0) {       p[choc] += events[i].first - events[i - 1].first;       choc += events[i].second;       ++i;     }     p[choc] += events[i].first - events[i - 1].first;     for (int i = 0; i <= n; ++i) cout << (p[i] / 2 / l) << endl;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define ull unsigned long long   #define f(i,x,y) for(int i=x;i<=y;i++)   #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);   //priority_queue<int>Q;   //unordered_map<string,int> Q;   const int MAX=3e5+10;   ll a[MAX];   void solve() {    ll n;    cin>>n;    for(int i=1; i<=n*2; i++) {     cin>>a[i];    }    int flag1=1;    sort(a+1,a+1+n*2,greater<ll>());    ll last;    int v=-1;    ll flag=0;    ll cnt=n;    for(int i=1; i<=n*2; i+=2) {     if(a[i]!=a[i+1]||a[i]<2||a[i]%2) {      flag1=0;      cout<< NO <<endl;      break;     }     a[i]-=flag;     if((v!=-1&&a[i]>=last*cnt)||a[i]<=0) {      flag1=0;      cout<< NO <<endl;      break;     }     if(a[i]%cnt==0) {      v=1;      last=a[i]/cnt;     } else {      flag1=0;      cout<< NO <<endl;      break;     }     if(last&1)     {      flag1=0;      cout<< NO <<endl;         break;     }     flag+=last;     cnt--;    }    if(flag1)     cout<< YES <<endl;   }   int main() {    IOS;    int t;    cin>>t;    while(t--) {     solve();    }   }
#include <bits/stdc++.h>   using namespace std;   int n;   string s;   int main() {     cin >> n >> s;     int sol = n;     for (int i = 1; i < n; i++) {       if (s[i] != s[i - 1] and s[i - 1] !=  D ) {         sol--;         s[i] =  D ;       }     }     cout << sol << endl;   }
#include <bits/stdc++.h>   using namespace std;   void FastIO() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     cout.precision(15);   }   string fun(string str) {     int i, l = str.length();     for (i = 0; i < l; i++) {       if (str[i] ==  + )         str[i] =  * ;       else         str[i] =  + ;     }     return str;   }   string s[10][1000];   int main() {     FastIO();     int i, n, j;     cin >> n;     if (n == 0) {       cout <<  +  <<   n ;       return 0;     }     s[0][0] =  ++ ;     s[0][1] =  +* ;     if (n == 1) {       cout << s[0][0] <<   n ;       cout << s[0][1] <<   n ;       return 0;     }     for (i = 1; i < 9; i++) {       for (j = 0; j < (1 << i); j++) s[i][j] = s[i - 1][j] + s[i - 1][j];       for (j = (1 << i); j < (1 << (i + 1)); j++)         s[i][j] = s[i - 1][j - (1 << i)] + fun(s[i - 1][j - (1 << i)]);       if (i == (n - 1)) {         for (j = 0; j < (1 << n); j++) cout << s[i][j] <<   n ;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[410][42];   char a[42], t[42];   int main() {     int n;     while (~scanf( %d , &n)) {       int ans = n, g = 0;       for (int k = 0; k < n; k++) {         scanf( %s , t);         while (true) {           int k = 0;           for (int i = 0; t[i] !=   0 ;) {             if (t[i] ==  u )               a[k++] =  o , a[k++] =  o , i++;             else if (t[i] ==  k ) {               int num = -1;               for (int j = i; t[j] !=   0 ; j++) {                 if (t[j] ==  k )                   continue;                 else if (t[j] ==  h ) {                   num = j + 1;                   break;                 } else                   break;               }               if (num == -1)                 a[k++] =  k , i++;               else                 a[k++] =  h , i = num;             } else               a[k++] = t[i], i++;           }           a[k] =   0 ;           if (strcmp(a, t) == 0)             break;           else             strcpy(t, a);         }         bool flag = false;         for (int j = 0; j < g; j++)           if (strcmp(s[j], t) == 0) {             ans--;             flag = true;             break;           }         if (!flag) strcpy(s[g++], t);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> arr(n), lefts(n), rights(n);     for (int &x : arr) cin >> x;     stack<int> positions;     for (int i = 0; i < n; ++i) {       while (!positions.empty() && arr[positions.top()] <= arr[i])         positions.pop();       if (positions.empty()) {         lefts[i] = -1;       } else {         lefts[i] = positions.top();       }       positions.push(i);     }     while (!positions.empty()) positions.pop();     for (int i = n - 1; i >= 0; --i) {       while (!positions.empty() && arr[positions.top()] <= arr[i])         positions.pop();       if (positions.empty()) {         rights[i] = n;       } else {         rights[i] = positions.top();       }       positions.push(i);     }     while (!positions.empty()) positions.pop();     vector<int> inv(n);     for (int i = 0; i < n; ++i) {       inv[arr[i]] = i;     }     long long res = 0;     for (int i = 0; i < n; ++i) {       int distL = i - lefts[i];       int distR = rights[i] - i;       if (distL < distR) {         for (int j = lefts[i] + 1; j < i; ++j) {           if (arr[j] > arr[i]) continue;           int Right = arr[i] - arr[j];           int pos = inv[Right];           if (pos > i && pos < rights[i]) {             ++res;           }         }       } else {         for (int j = i + 1; j < rights[i]; ++j) {           if (arr[j] > arr[i]) continue;           int Left = arr[i] - arr[j];           int pos = inv[Left];           if (pos < i && pos > lefts[i]) {             ++res;           }         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 400000;   long long l[500000], r[500000], k[500000], b[500000], a[500000], pref1[500000],       pref2[500000], s = MX;   long long f(long long b1, long long a1, long long b2, long long a2) {     return (b1 - b2) / (a1 - a2);   }   void add(long long kx, long long bx) {     if (s == MX) {       l[s] = -2e18;       r[s] = 2e18;       b[s] = bx;       k[s] = kx;       s--;       return;     }     if (f(bx, kx, b[s + 1], k[s + 1]) > r[s + 1]) {       s++;       add(kx, bx);       return;     }     l[s] = -2e18;     r[s] = f(bx, kx, b[s + 1], k[s + 1]);     b[s] = bx;     k[s] = kx;     l[s + 1] = r[s] + 1;     s--;     return;   }   int main() {     ios::sync_with_stdio(0);     long long n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     pref1[0] = a[0];     pref2[0] = a[0];     for (int i = 1; i < n; i++) {       pref1[i] = pref1[i - 1] + a[i];       pref2[i] = pref2[i - 1] + a[i] * (i + 1);     }     long long ans = 0;     for (long long i = 0; i < n; i++) {       ans = max(ans, pref2[i]);       long long lt = s + 1, rt = MX;       while (lt < rt) {         long long mid = (lt + rt) / 2;         if (lt == rt - 1) mid++;         if (pref1[i] < l[mid])           rt = mid - 1;         else           lt = mid;       }       long long q = 0, t = 0;       if (i > 0) {         q = pref2[i - 1];         t = pref1[i - 1];       }       if (lt <= MX) ans = max(ans, pref2[i] - b[lt] + pref1[i] * k[lt]);       add(-i - 1, -(pref1[i] * (i + 1) - pref2[i]));     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int x, int1, int2, int3, tempsum, lastsum = -1;     string s, s1, s2, s3;     cin >> s;     x = s.size();     for (int d1 = 1; d1 < x - 1 && d1 < 8; d1++) {       for (int d2 = 1; d2 < x - d1 && d2 < 8; d2++) {         s1 = s.substr(0, d1);         s2 = s.substr(d1, d2);         s3 = s.substr(d1 + d2, x - d1 - d2);         if ((s2.size() > 1 && s2[0] ==  0 ) || (s3.size() > 1 && s3[0] ==  0 ) ||             (s1.size() > 1 && s1[0] ==  0 ) || x - d1 - d2 > 7)           continue;         stringstream convert1, convert2, convert3;         convert1 << s1;         convert1 >> int1;         convert2 << s2;         convert2 >> int2;         convert3 << s3;         convert3 >> int3;         if (int1 > 1000000 || int2 > 1000000 || int3 > 1000000) continue;         tempsum = int1 + int2 + int3;         lastsum = max(tempsum, lastsum);       }     }     cout << lastsum << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   const long double pi = 2 * acos(0.0);   using namespace std;   int power(int a, int n) {     if (n == 0) {       return 1;     }     int p = power(a, n / 2) % 1000000007;     p = (p * p) % 1000000007;     if (n % 2 == 1) {       p = (p * a) % 1000000007;     }     return p;   }   int gcd(int a, int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   const int N = 1e6 + 5;   vector<int> sieve(N, 0);   void si() {     sieve[1] = 1;     for (int i = 2; i < N; i++) {       if (sieve[i] == 0) {         sieve[i] = i;         for (int j = 2 * i; j < N; j += i) {           sieve[j] = i;         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     if (n == 1) {       cout << 0 <<   n ;       return 0;     }     vector<int> a(n + 1);     ;     for (int i = 0; i < n; i++) cin >> a[i];     ;     a[n] = 0;     int k = (n + 1) / 2;     int dp[n + 1][k + 1][2];     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= k; j++) {         dp[i][j][0] = 1e9;         dp[i][j][1] = 1e9;       }     }     dp[1][0][0] = 0;     dp[1][1][1] = a[1] - min(a[0] - 1, a[1]);     for (int i = 0; i <= n; i++) {       dp[i][0][0] = 0;     }     vector<int> ans(k, 1e9);     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= k; j++) {         dp[i][j][0] = min(dp[i - 1][j][0], dp[i - 1][j][1]);         int z = 1e9;         if (i - 3 >= 0) {           z = dp[i - 2][j - 1][1];           if (a[i - 3] > a[i - 1]) {             z += a[i - 3] - a[i - 1];           }           z += a[i] - min(a[i], a[i - 1] - 1);         }         dp[i][j][1] = min(dp[i - 1][j - 1][0] + a[i] - min(a[i], a[i - 1] - 1) +                               a[i - 2] - min(a[i - 2], a[i - 1] - 1),                           z);         dp[i][j][1] = min(dp[i][j][1], (int)(1e9));         ans[j - 1] = min(ans[j - 1], dp[i][j][1]);         ans[j - 1] = min(ans[j - 1], dp[i][j][0]);       }     };     for (int i = 0; i < k; i++) cout << ans[i] <<    ;     ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class T2>   T2 fac(T n) {     return n < 2 ? 1 : fac<T, T2>(n - 1) * n;   }   template <class T>   T nb_combinaisons(T k, T n) {     if (n < k) return nb_combinaisons<T>(n, k);     return fac<T, long long int>(n) /            (fac<T, long long int>(n - k) * fac<T, long long int>(k));   }   string itoa_2(long long int n) {     string s;     stringstream ss;     ss << n;     ss >> s;     while (s.size() != 9) s =  0  + s;     return s;   }   int pgcd(int a, int b) {     if (a == 0) return b;     if (b == 0) return a;     return pgcd(b, a % b);   }   int main() {     int A, B, n;     cin >> A >> B >> n;     if (A == 0) {       if (B != 0) {         cout <<  No solution ;         return 0;       } else {         cout <<  0 ;         return 0;       }     }     if (B % A != 0) {       cout <<  No solution ;       return 0;     }     int z = B / A;     for (int c = -1000; c <= 1000; c++) {       int alpha = pow((double)c, n);       if (alpha == z) {         cout << c;         return 0;       }     }     cout <<  No solution ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 110;   int N, M, U = 110, D = 0, L = 110, R = 0, cnt;   char s[maxn][maxn];   inline int gi() {     char ch;     int ret = 0, f = 1;     do ch = getchar();     while (!(ch >=  0  && ch <=  9 ) && ch !=  - );     if (ch ==  - ) f = -1, ch = getchar();     do ret = ret * 10 + ch -  0 , ch = getchar();     while (ch >=  0  && ch <=  9 );     return ret * f;   }   int main() {     N = gi();     M = gi();     for (int i = 1; i <= N; ++i) scanf( %s , s[i] + 1);     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         if (s[i][j] ==  B ) {           ++cnt;           U = min(i, U);           D = max(i, D);           L = min(j, L);           R = max(j, R);         }     int W = max(R - L + 1, D - U + 1);     if (!cnt)       puts( 1 );     else if (W > N || W > M)       puts( -1 );     else       printf( %d n , W * W - cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int pre[N];   void solve() {     string s;     int n, k, ans = 0;     cin >> n >> k >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         if (i == 0)           pre[i] = 1;         else           pre[i] = pre[i - 1] + 1;       } else {         if (i == 0)           pre[i] = 0;         else           pre[i] = pre[i - 1];       }     }     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         i += k;         continue;       }       int l = i - k - 1;       int r = i + k;       l = max(0, l);       r = min(r, n - 1);       if (pre[l] == pre[r]) {         ans++;         i = r;       }     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int tc = 1;     cin >> tc;     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const double pi = acos(-1.0);   const int N = 1e5 + 10;   const int mod = 100;   int main() {     string str;     int n, ans;     cin >> n >> str;     ans = n;     for (int i = 0; i < n - 1; i++) {       if (str[i] ==  U  && str[i + 1] ==  R ) {         ans--;         i++;       } else if (str[i] ==  R  && str[i + 1] ==  U ) {         i++;         ans--;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 850;   int capacity[N][N], p[N], visit[N], n, source, sink, max_flow;   pair<int, int> a[N];   vector<int> adj[N];   double f[N], cost[N][N], res;   double dis(pair<int, int> a, pair<int, int> b) {     return sqrt((a.first - b.first) * (a.first - b.first) +                 (a.second - b.second) * (a.second - b.second));   }   void add(int u, int v, int cap, double c) {     adj[u].push_back(v);     adj[v].push_back(u);     capacity[u][v] = cap;     cost[u][v] = c;     cost[v][u] = -c;   }   int bfs() {     for (int i = 0; i <= 2 * n + 1; i++) {       visit[i] = 2;       f[i] = 1e9;     }     f[source] = 0;     deque<int> q;     q.push_back(source);     int check = 0;     while (!q.empty()) {       int u = q.front();       q.pop_front();       visit[u] = 0;       if (u == sink) check = 1;       for (int v : adj[u])         if (capacity[u][v] > 0 && f[v] > f[u] + cost[u][v]) {           f[v] = f[u] + cost[u][v];           p[v] = u;           if (visit[v] == 1) continue;           if (visit[v] == 2)             q.push_back(v);           else             q.push_front(v);         }     }     return check;   }   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     source = 0;     sink = 2 * n + 1;     for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;     for (int i = 1; i <= n; i++) add(source, i, 2, 0);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i].second > a[j].second) add(i, j + n, 1, dis(a[i], a[j]));     for (int i = n + 1; i <= 2 * n; i++) add(i, sink, 1, 0);     while (bfs()) {       int flow_path = 1e9, v = sink;       while (v != source) {         flow_path = min(flow_path, capacity[p[v]][v]);         v = p[v];       }       v = sink;       max_flow += flow_path;       res += flow_path * f[sink];       while (v != source) {         capacity[p[v]][v] -= flow_path;         capacity[v][p[v]] += flow_path;         v = p[v];       }     }     cout << fixed << setprecision(9);     if (max_flow != n - 1)       cout << -1;     else       cout << res;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     cin >> a >> b >> c;     string ans =   ;     int f;     if (a > b) {       ans +=  0 ;       a--;       f = 0;     } else {       ans +=  1 ;       f = 1;       b--;     }     for (int i = 1; i < c; i++) {       if (f) {         ans +=  0 ;         a--;         f = f ^ 1;       } else {         ans +=  1 ;         b--;         f = f ^ 1;       }     }     if (!f) {       while (a--) {         ans +=  0 ;       }       f = f ^ 1;       while (b--) {         ans +=  1 ;       }     } else {       while (b--) {         ans +=  1 ;       }       while (a--) {         ans +=  0 ;       }     }     cout << ans << endl;   }