malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   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...);   }   long long ex(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % 998244353;       a = (a * a) % 998244353, b /= 2;     }     return ans;   }   inline long long add(long long a, long long b) {     a = a % 998244353 + b % 998244353;     if (a > 998244353) a %= 998244353;     return a;   }   inline long long sub(long long a, long long b) {     a = a % 998244353 - b % 998244353;     if (a < 0) a += 998244353;     return a;   }   inline long long mul(long long a, long long b) {     a %= 998244353, b %= 998244353;     return (a * b) % 998244353;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n, q;     cin >> n >> q;     long long a[n + 2], b[n + 2], c[n + 2];     for (long long i = 1; i < n + 1; ++i)       cin >> a[i], a[i] = mul(100, ex(a[i], 998244353 - 2));     b[0] = 0, c[n + 1] = 1;     for (long long i = n; i >= 1; --i) c[i] = mul(c[i + 1], a[i]);     for (long long i = 1; i < n + 1; ++i) b[i] = add(b[i - 1], c[i]);     auto get = [&](long long l, long long r) {       long long x = sub(b[r], b[l - 1]);       x = mul(x, ex(c[r + 1], 998244353 - 2));       return x;     };     long long ans = get(1, n), x;     set<long long> s;     s.insert(1);     for (long long i = 0; i < q; ++i) {       long long u;       cin >> u;       if (s.count(u)) {         auto it = s.find(u);         auto it1 = s.upper_bound(u);         if (it1 == s.end())           x = n;         else           x = *it1 - 1;         auto it2 = s.lower_bound(u);         it2--;         ans = add(ans, get(*it2, x));         ans = sub(ans, add(get(*it2, *it - 1), get(*it, x)));         s.erase(u);       } else {         s.insert(u);         auto it = s.find(u);         auto it1 = s.upper_bound(u);         if (it1 == s.end())           x = n;         else           x = *it1 - 1;         auto it2 = s.find(u);         it2--;         ans = sub(ans, get(*it2, x));         ans = add(ans, add(get(*it2, *it - 1), get(*it, x)));       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, root = -1, nextnum = 3;   vector<vector<int>> edges[100005];   int order[100005];   int main() {     cin >> n;     for (int i = 1; i <= n - 1; i++) {       int a, b;       cin >> a >> b;       edges[a].push_back({b, i});       edges[b].push_back({a, i});     }     for (int i = 1; i <= n; i++) {       if (edges[i].size() > 2) {         root = i;         break;       }     }     if (root == -1) {       for (int i = 0; i <= n - 2; i++) {         cout << i <<   n ;       }     } else {       for (int i = 1; i <= n - 1; i++) {         order[i] = -1;       }       order[edges[root][0][1]] = 0;       order[edges[root][1][1]] = 1;       order[edges[root][2][1]] = 2;       for (int i = 1; i <= n; i++) {         for (int j = 0; j < edges[i].size(); j++) {           if (order[edges[i][j][1]] == -1) {             order[edges[i][j][1]] = nextnum;             nextnum++;           }         }       }       for (int i = 1; i <= n - 1; i++) {         cout << order[i] <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[5000];   int main() {     int n, k, l, r, s, sk;     cin >> n >> k >> l >> r >> s >> sk;     int d = s - sk;     for (int i = 1; i <= k; i++) {       a[i] = sk / k;       if (sk % k != 0) {         a[i]++;         sk--;       }     }     if (k != n) {       for (int i = k + 1; i <= n; i++) {         a[i] = d / (n - k);         if (d % (n - k) != 0) {           a[i]++;           d--;         }       }     }     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main(int argc, char const *argv[]) {     int t;     cin >> t;     while (t--) {       int n;       string s, k;       cin >> n;       cin >> s >> k;       int ans = 0;       string prev =  01 ;       for (int i = 0; i < n; i++) {         if ((s[i] ==  0  && k[i] ==  1 ) || (s[i] ==  1  && k[i] ==  0 )) {           prev =  01 ;           ans += 2;         } else if (s[i] ==  0  && k[i] ==  0 ) {           ans++;           if (prev ==  11 ) {             ans++;             prev =  01 ;           } else             prev =  00 ;         } else {           if (prev ==  00 ) {             ans++;             prev =  01 ;           } else             prev =  11 ;         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   pair<int, int> p[100005], ans[100005];   int tot, start[100005], remain, now;   int f[100005];   priority_queue<pair<int, int> > Q;   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       scanf( %d%d , &p[i].first, &p[i].second);       if (p[i].second == 0) p[i].second = -1;       p[i].second = -p[i].second;       p[i].second *= i;     }     sort(p + 1, p + m + 1);     for (int i = 1; i <= n; i++) f[i] = i, start[i] = i + 1;     remain = 1;     now = 1;     for (int i = 1; i <= m; i++) {       if (p[i].second > 0) {         if (Q.empty()) {           return puts( -1 ), 0;         } else {           int x = Q.top().first, y = Q.top().second;           Q.pop();           if (-x <= remain) {             ans[p[i].second] = make_pair(-x, y);             if (-x != n) Q.push(make_pair(x - 1, y));           } else {             return puts( -1 );           }         }       } else {         remain++;         if (remain <= n) {           Q.push(make_pair(-remain - 1, remain));           ans[-p[i].second] = make_pair(1, remain);         } else {           return puts( -1 ), 0;         }       }     }     for (int i = 1; i <= m; i++) printf( %d %d n , ans[i].first, ans[i].second);   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> p, h, st;   vector<vector<int>> adj;   int gst(int curr, int prev) {     int res = p[curr];     for (int next : adj[curr]) {       if (next != prev) {         res += gst(next, curr);       }     }     return st[curr] = res;   }   int dfs(int curr, int prev, int& res) {     int g = st[curr] + h[curr];     if (g % 2) res = 0;     int gv = g / 2;     if (gv < 0 || gv > st[curr]) res = 0;     int cgv = 0;     for (int next : adj[curr]) {       if (next != prev) {         cgv += dfs(next, curr, res);       }     }     if (cgv > gv) res = 0;     return gv;   }   string solve() {     cin >> n >> m;     adj.clear();     adj.resize(n + 1);     p.assign(n + 1, 0);     h.assign(n + 1, 0);     st.assign(n + 1, 0);     for (int i = 1; i <= n; i++) cin >> p[i];     for (int i = 1; i <= n; i++) cin >> h[i];     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     gst(1, 0);     int res = 1;     dfs(1, 0, res);     if (!res) return  NO ;     return  YES ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       cout << solve() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.14159265;   const long long mod = 998244353;   const long long N = 1e6 + 5;   const long long st = 1e2;   const int P0 = 437;   const int P = 1003;   int main() {     cin.sync_with_stdio();     cin.tie(0);     cout.tie(0);     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       vector<int> a(n);       for (int i = 0; i < (n); i++) cin >> a[i];       sort(a.begin(), a.end());       (a.resize(unique(a.begin(), a.end()) - a.begin()));       cout << ((int)(a).size()) <<   n ;     }   }
#include<bits/stdc++.h>   using namespace std;      int main(){    int t;    cin>>t;    while(t--){     int n;     cin>>n;     int o=0,e=0;     int a;     for(int i=0;i<2*n;i++){      cin>>a;      if(a%2==0)       e++;      else       o++;     }        if(o == e)      cout<< YES <<endl;     else      cout<< NO <<endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n;     int a[1005];     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     sort(a + 1, a + 1 + n);     if (n % 2 == 0) {       printf( %d n , a[n / 2]);     } else {       printf( %d n , a[(n + 1) / 2]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c = 0, i, A[1000], B[1000], r, l, lo, u, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> A[i] >> B[i];     }     for (i = 0; i < n; i++) {       r = 0;       lo = 0;       l = 0;       u = 0;       for (j = 0; j < n; j++) {         if (A[i] == A[j] && B[i] < B[j]) {           r = 1;         }         if (A[i] == A[j] && B[i] > B[j]) {           l = 1;         }         if (A[i] < A[j] && B[i] == B[j]) {           lo = 1;         }         if (A[i] > A[j] && B[i] == B[j]) {           u = 1;         }       }       if (l == 1 && lo == 1 && r == 1 && u == 1) {         c++;       }     }     cout << c;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long getans(long long n) {     if (n == 1) return 3 % m;     long long k = getans(n / 2);     k *= k;     if (n % 2) k *= 3;     return k % m;   }   int main() {     while (~scanf( %I64d%I64d , &n, &m)) {       long long ans = getans(n) - 1;       if (ans == -1) ans = m - 1;       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005];   deque<long long> q;   long long mi[100005];   void add_q(long long ae) {     while (!q.empty() && q.back() > ae) q.pop_back();     q.push_back(ae);   }   void pop_q(long long re) {     if (!q.empty() && q.front() == re) q.pop_front();   }   void solve() {     long long n, c, sum = 0;     cin >> n >> c;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     for (int i = 0; i < c; i++) {       add_q(a[i]);     }     mi[0] = q.front();     for (int i = c; i < n; i++) {       pop_q(a[i - c]);       add_q(a[i]);       mi[i - c + 1] = q.front();     }     long long maxc = 0;     long long res = 0;     for (int i = 0; i < c; i++) res = max(res, mi[i]);     for (int i = c; i < n; i++) {       maxc = max(maxc, mi[i - c]);       mi[i] += maxc;       res = max(res, mi[i]);     }     cout << sum - res;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = 3.141592653589793238462643383;   int vector_init(vector<vector<long long int> > &x, int r, int c) {     x.resize(r);     for (int i = 0; i < (r); ++i) x[i].resize(c);   }   int abso(int a) {     if (a > 0) return a;     return -a;   }   void print(vector<long long> &ans) {     for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;     cout <<   n ;   }   int equal(vector<int> &a, vector<int> &b) {     for (int i = 0; i < a.size(); i++) {       if (a[i] == b[i] && a[i] == 1) return 1;     }     return 0;   }   void print1(vector<vector<long long> > &edge) {     for (int i = 0; i < edge.size(); i++) print(edge[i]);   }   long long maxx(long long a, long long b) {     if (a > b) return a;     return b;   }   long long minn(long long a, long long b) { return a + b - maxx(a, b); }   long long Ceil(long long a, long long b) {     if (a % b == 0) return a / b;     return a / b + 1;   }   long long find(vector<long long int> &a, vector<long long int> &c, long long t,                  long long cunt) {     for (int i = 0; i < (a.size()); ++i) {       if (a[i] == t) cunt--;       if (cunt == 0) return c[i];     }   }   long long power(long long k, long long m) {     long long ans = 1;     for (int i = 0; i < (k); ++i) {       ans = (ans * 2) % m;     }     return ans;   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin.exceptions(cin.failbit);     map<long long, long long> start;     map<long long, long long> end;     long long n;     cin >> n;     vector<long long int> a(n, 0);     for (int i = 0; i < (n); ++i) {       cin >> a[i];       if (start[a[i]] == 0) start[a[i]] = i + 1;       end[a[i]] = i + 1;     }     long long t = end[a[0]] - 1;     long long k = 0;     long long cunt = 0;     while (k < n) {       if (k == t + 1) {         cunt++;         t = end[a[k]] - 1;       } else {         t = maxx(t, end[a[k]] - 1);       }       k++;     }     cout << power(cunt, 998244353);   }
#include <bits/stdc++.h>   const int MAX = 1 << 17;   char s[MAX];   long long rje[2], dp[2][2][2][MAX];   int main() {     int i, l, tmpdulj, j, k, ii;     scanf( %s , s + 1);     l = strlen(s + 1);     for (i = 1; i <= l; i++) {       dp[i % 2][1][s[i] -  a ][i] = 1;       rje[1]++;       for (j = 0; j < 2; j++)         for (k = 0; k < 2; k++)           for (ii = 0; ii < 2; ii++) {             tmpdulj = k;             if (s[i] -  a  != ii) tmpdulj = (tmpdulj + 1) % 2;             dp[j][tmpdulj][s[i] -  a ][i] += dp[j][k][ii][i - 1];             if (tmpdulj % 2) rje[(i - j + 1) % 2] += dp[j][k][ii][i - 1];           }     }     printf( %I64d %I64d n , rje[0], rje[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000000;   bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n, greater<int>());     int ans[n];     ans[0] = a[0];     ans[1] = a[1];     for (int i = 2; i < n; i++) {       if (i == 2) {         ans[n - 1] = a[i];       } else {         ans[i - 1] = a[i];       }     }     bool ok = true;     if (a[0] >= a[1] + a[2]) {       ok = false;     }     if (ok) {       cout <<  YES n ;       for (int i = 0; i < n; i++) cout << ans[i] <<    ;     } else {       cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<vector<char>> grid;   pair<int, int> start, endloc;   int memo[1000][1000][4];   bool dfs(pair<int, int> loc, int turns, int dir) {     if (loc == endloc) return true;     memo[loc.first][loc.second][dir] = turns;     vector<pair<int, int>> next;     next.push_back({loc.first - 1, loc.second});     next.push_back({loc.first + 1, loc.second});     next.push_back({loc.first, loc.second - 1});     next.push_back({loc.first, loc.second + 1});     for (int i = 0; i < 4; i++) {       pair<int, int> nextLoc = next[i];       if (i != dir && turns == 0) continue;       if (nextLoc.first < 0 || nextLoc.first >= n) continue;       if (nextLoc.second < 0 || nextLoc.second >= m) continue;       if (grid[nextLoc.first][nextLoc.second] ==  * ) continue;       int turnDiff = 0;       if (i != dir) turnDiff = 1;       if (memo[nextLoc.first][nextLoc.second][i] >= turns - turnDiff) continue;       if (dfs(nextLoc, turns - turnDiff, i)) return true;     }     return false;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     memset(memo, -1, sizeof memo);     grid = vector<vector<char>>(n, vector<char>(m,    ));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char curr;         cin >> curr;         if (curr ==  S ) {           start = {i, j};         } else if (curr ==  T ) {           endloc = {i, j};         }         grid[i][j] = curr;       }     }     for (int i = 0; i < 4; i++) {       if (dfs(start, 2, i)) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      int main() {       int t;       cin >> t;       while (t--) {           int s;           cin >> s;           int k, ans = 0;              for (k = 1; s > 0 && s >= k; k += 2)               s -= k, ++ans;           for (k = min(s, k - 1); s > 0 && k >= 1; k--) {               ans += s / k;               s -= (s / k) * k;           }              cout << ans <<   n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100100;   int N;   long long K;   int ar[MAXN];   int main() {     cin >> N >> K;     for (int i = 0; i < N; i++) cin >> ar[i];     --K;     sort(ar, ar + N);     for (int i = 0; i < N;) {       int cur = i;       int cnt = 0;       while (i < N && ar[i] == ar[cur]) {         ++i;         ++cnt;       }       if (K < (long long)cnt * N) {         cout << ar[cur] <<     << ar[(int)(K / cnt)] << endl;         break;       }       K -= (long long)cnt * N;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fileIO() {}   bool sortbysecdesc(const pair<long long, long long> &a,                      const pair<long long, long long> &b) {     return a.second > b.second;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     fileIO();     long long T;     T = 1;     while (T--) {       long long n;       cin >> n;       vector<long long> a(n);       for (long long &x : a) {         cin >> x;       }       long long moves = 0;       long long curr = 0;       for (long long x : a) {         moves += abs(x - curr);         curr = x;       }       cout << moves <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 300000;   long long n, x[Maxn], w[Maxn], Index[Maxn], nx[Maxn];   set<pair<long long, long long> > poi, xx;   set<pair<long long, long long> > u;   void input() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x[i] >> w[i];       xx.insert(make_pair(x[i], i));       poi.insert(make_pair(x[i] - w[i], i));     }   }   void solve() {     long long k = 0;     for (auto c : poi) {       Index[c.second] = k;       k++;     }     for (auto c : xx) {       long long ind = c.second;       poi.erase(make_pair(x[ind] - w[ind], ind));       long long sum = x[ind] + w[ind];       auto limIt = poi.lower_bound(make_pair(sum, 0));       if (limIt != poi.end()) {         auto lim = *limIt;         nx[Index[ind]] = Index[lim.second];         u.insert(make_pair(Index[lim.second], Index[ind]));       } else         nx[Index[ind]] = -1;     }     int ans = 1, last = 0;     while (((int)u.size())) {       auto c = (*u.begin()).first;       ans++;       for (; last < c; last++)         if (nx[last] >= 0) u.erase(make_pair(nx[last], last));     }     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie();     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a, b, ans;     scanf( %d , &t);     while (t--) {       ans = 0;       scanf( %d %d , &a, &b);       while (a > 0 && b > 0) {         if (a >= b) {           ans += (a / b);           a = a % b;         } else if (b > a) {           ans += (b / a);           b = b % a;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int n = 3;   long long r, g, b;   void reset() {     if (r >= g) swap(r, g);     if (r >= b) swap(r, b);     if (g >= b) swap(g, b);   }   int main() {     while (cin >> r >> g >> b) {       reset();       if ((r + g) * 2 <= b)         cout << r + g << endl;       else         cout << (r + g + b) / 3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using Long = long long;   int main() {     int t;     cin >> t;     while (t--) {       int d;       cin >> d;       if (d * d < 4 * d) {         puts( N );       } else {         double dis = sqrt(d * d - 4 * d);         double x = (dis + d) / 2, y = (d - dis) / 2;         printf( Y %0.10lf %0.10lf n , x, y);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long K, A, B, V;     cin >> K >> A >> B >> V;     long long nuts = A;     long long divisors = B;     long long capacity = V;     long long maxSections = K;     int boxes = 0;     while (nuts > 0) {       boxes++;       int sections = min(divisors + 1, maxSections);       nuts -= sections * capacity;       divisors -= sections - 1;     }     cout << boxes;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, ans[(int)20 + 7][(int)20 + 7], a[500];   set<pair<int, int> > st;   map<int, int> mp;   int main() {     ios::sync_with_stdio(false);     cin >> N;     for (int i = 0; i < N * N; i++) {       cin >> a[i];       mp[a[i]]++;     }     int idx = -1;     map<int, int>::iterator itt = mp.begin();     while (itt != mp.end()) {       st.insert({itt->second, itt->first});       itt++;     }     memset(ans, -1, sizeof ans);     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         if (ans[i][j] != -1) continue;         if (!st.size()) return cout <<  NO , 0;         if (N % 2 && i == N / 2 || j == N / 2) {           continue;         }         set<pair<int, int> >::iterator it = st.lower_bound({4, -1});         ;         int c = (*it).first, n = (*it).second;         if (it == st.end()) return cout <<  NO , 0;         st.erase(it);         c -= 4;         if (c < 0) return cout <<  NO , 0;         ans[i][j] = n;         ans[i][N - j - 1] = n;         ans[N - i - 1][j] = n;         ans[N - i - 1][N - j - 1] = n;         if (c) st.insert({c, n});       }     }     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         if (ans[i][j] != -1) continue;         if (N % 2 && i == N / 2 && j == N / 2) continue;         if (N % 2 && i == N / 2) {           set<pair<int, int> >::iterator it = st.lower_bound({2, -1});           if (it == st.end()) return cout <<  NO , 0;           st.erase(it);           int c = (*it).first, n = (*it).second;           c -= 2;           if (c < 0) return cout <<  NO , 0;           ans[i][j] = n;           ans[i][N - j - 1] = n;           if (c) st.insert({c, n});         } else if (N % 2 && j == N / 2) {           set<pair<int, int> >::iterator it = st.lower_bound({2, -1});           ;           if (it == st.end()) return cout <<  NO , 0;           st.erase(it);           int c = (*it).first, n = (*it).second;           c -= 2;           if (c < 0) return cout <<  NO , 0;           ans[i][j] = n;           ans[N - i - 1][j] = n;           if (c) st.insert({c, n});         }       }     }     if (N % 2) {       ans[N / 2][N / 2] = (*st.begin()).second;     }     cout <<  YES  << endl;     for (int i = 0; i < N; i++, cout << endl)       for (int j = 0; j < N; j++) cout << ans[i][j] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a1, a2, a3, a4;   int main() {     cin >> a1 >> a2 >> a3 >> a4;     if (a3 == a4) {       if (a1 - a3 - 1 >= 0 && a2 - a4 >= 0) {         for (int i = 0; i < a1 - a3 - 1; i++) cout <<  4 ;         for (int i = 0; i < a3; i++) cout <<  47 ;         for (int i = 0; i < a2 - a4; i++) cout <<  7 ;         cout <<  4 ;         return 0;       }       if (a1 - a3 >= 0 && a2 - a4 - 1 >= 0) {         for (int i = 0; i < a4; i++) cout <<  74 ;         for (int i = 0; i < a1 - a3; i++) cout <<  4 ;         for (int i = 0; i < a2 - a4 - 1; i++) cout <<  7 ;         cout <<  7 ;         return 0;       }     } else if (a3 == a4 + 1) {       if (a1 - a3 >= 0 && a2 - a3 >= 0) {         for (int i = 0; i < a1 - a3; i++) cout <<  4 ;         for (int i = 0; i < a3; i++) cout <<  47 ;         for (int i = 0; i < a2 - a3; i++) cout <<  7 ;         return 0;       }     } else if (a3 + 1 == a4) {       if (a1 - a4 + 1 > 0 && a2 - a4 + 1 > 0) {         cout <<  7 ;         for (int i = 0; i < a1 - a4 + 1; i++) cout <<  4 ;         for (int i = 0; i < a4 - 2; i++) cout <<  74 ;         for (int i = 0; i < a2 - a4 + 1; i++) cout <<  7 ;         cout <<  4 ;         return 0;       }     }     cout <<  -1 ;     return 0;   }