func_code_string: #include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     set<pair<long long, int>> all;     for (int i = 0; i < n; i++) {       all.insert({a[i], i});     }     vector<pair<long long, int>> res;     while (!all.empty()) {       pair<long long, int> prev = *all.begin();       all.erase(all.begin());       if (all.empty()) {         res.push_back(prev);         break;       }       pair<long long, int> next = *all.begin();       all.erase(all.begin());       if (next.first != prev.first) {         res.push_back(prev);         all.insert(next);       } else {         all.insert({prev.first * 2LL, next.second});       }     }     sort(res.begin(), res.end(),          [&](pair<long long, int> a, pair<long long, int> b) {            return a.second < b.second;          });     cout << res.size() <<   n ;     for (auto p : res) {       cout << p.first <<    ;     }     cout <<   n ;     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }   