malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   pair<long long, long long> q[9];   char s[2];   int main() {     long long n, x0, y0;     scanf( %lld , &n);     scanf( %lld%lld , &x0, &y0);     for (long long m = 0; m < 9; m++) q[m] = make_pair(1E10, INT_MAX);     while (n--) {       long long x, y, i, j, k, g, m, d;       scanf( %s , s);       scanf( %lld%lld , &x, &y);       i = x - x0, j = y - y0;       if (abs(i) != abs(j) && i != 0 && j != 0) continue;       k = max(abs(i), abs(j));       i /= k, j /= k;       i++, j++;       m = 3 * i + j;       if (s[0] ==  Q )         k = 3;       else         k = (s[0] !=  R ) + 1;       d = abs(x - x0) + abs(y - y0);       q[m] = min(q[m], make_pair(d, k));     }     for (long long m = 0; m < 9; m++) {       long long i = m / 3, j = m % 3, check;       i--, j--;       if (i == 0 || j == 0)         check = 0;       else         check = 1;       if (q[m].first != 1E10 && (q[m].second & (1 << check))) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (auto& i : a) cin >> i;     while (a.back() <= k) a.pop_back();     reverse(a.begin(), a.end());     while (a.back() <= k) a.pop_back();     cout << n - a.size() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 30;   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     string s;     cin >> s;     int n = s.size();     int pref = 0, suf = n - 1;     while (pref < n - 1 && s[pref] != s[pref + 1]) pref++;     while (suf > 0 && s[suf] != s[suf - 1]) suf--;     int ans = min(n, (s[n - 1] != s[0] ? pref + 1 + (n - suf) : 0));     for (int i = 0; i < n; i++) {       int j = i;       while (j < n - 1 && s[j] != s[j + 1]) j++;       ans = max(ans, j - i + 1);       i = j;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000007;   const long long INF = 1e18;   int mod = 998244353;   template <typename T1, typename T2>   inline bool chmin(T1& a, T2 b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <typename T1, typename T2>   inline bool chmax(T1& a, T2 b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   template <typename T, typename U>   T pow_(T a, U b) {     return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1;   }   long long modpow(long long a, long long b, long long _mod) {     return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1;   }   template <class T, class U>   ostream& operator<<(ostream& os, const pair<T, U>& p) {     os << p.first <<     << p.second;     return os;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& vec) {     for (int i = 0; i < ((int)vec.size()); ++i) {       if (i) os <<    ;       os << vec[i];     }     return os;   }   template <typename T>   inline istream& operator>>(istream& is, vector<T>& v) {     for (int j = 0; j < ((int)v.size()); ++j) is >> v[j];     return is;   }   template <class T, class T2>   inline void add(T& a, T2 b) {     a += b;     if (a >= mod) a -= mod;   }   void solve();   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(10);     int T;     T = 1;     while (T--) solve();   }   void solve() {     int n;     long long k;     cin >> n >> k;     vector<int> a(n);     cin >> a;     long long ma = *max_element(a.begin(), a.end());     int ans = 0;     vector<int> b(n);     auto Get = [&](long long limit) {       long long sum = 0;       for (int i = 0; i < (n); ++i) {         auto binary_search = [&](int ok, int ng) {           auto check = [&](int x) {             if (a[i] - 3LL * x * (x + 1) - 1 >= limit) return 1;             return 0;           };           int d = 1;           while ((ng - ok >= 0 ? ng - ok : -(ng - ok)) > d) {             int mid = (ng + ok) / 2;             (check(mid) ? ok : ng) = mid;           }           return ok;         };         b[i] = binary_search(0, a[i] + 1);         sum += b[i];       }       return sum;     };     auto binary_search = [&](long long ok, long long ng) {       auto check = [&](long long x) {         long long s = Get(x);         if (s >= k) return 1;         return 0;       };       int d = 1;       while ((ng - ok >= 0 ? ng - ok : -(ng - ok)) > d) {         long long mid = (ng + ok) / 2;         (check(mid) ? ok : ng) = mid;       }       return ok;     };     long long L = binary_search(-4e18, 4e18);     long long s = Get(L);     for (int i = 0; i < (s - k); ++i) {       long long mi = INF;       int id = -1;       for (int j = 0; j < (n); ++j)         if (chmin(mi, a[j] - 3LL * b[j] * b[j] + 3 * b[j] - 1)) id = j;       b[id]--;     }     cout << b <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int len = 0, coun = 0;   bool visited[1000006];   vector<int> check;   vector<int> grid[1000006];   void dfs(int v) {     visited[v] = true;     for (int i = 0; i < grid[v].size(); i++) {       if (!visited[grid[v][i]]) {         dfs(grid[v][i]);       }     }     check.push_back(v);   }   void toposort(int n) {     memset(visited, false, sizeof(visited));     coun = 0;     for (int i = 0; i < n; i++) {       if (!visited[i + 1]) dfs(i + 1);     }   }   int main() {     int n, m, x, y;     cin >> n >> m;     map<pair<int, int>, int> ma;     for (int i = 0; i < m; i++) {       cin >> x >> y;       ma[{x, y}] = i;       grid[x].push_back(y);     }     toposort(n);     reverse(check.begin(), check.end());     bool ans = true;     int maxi = 0;     for (int i = 0; i < check.size() - 1; i++) {       if (ma.find(make_pair(check[i], check[i + 1])) == ma.end())         ans = false;       else         maxi = max(maxi, ma[make_pair(check[i], check[i + 1])]);     }     if (ans == false)       cout << -1;     else       cout << maxi + 1;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, y;   vector<vector<int> > adjList(100009, vector<int>());   bool vis[100009];   vector<int> ans;   bool check_valid_edges(vector<vector<int> > &a, int n) {     for (size_t i = 1; i <= n; i++)       if (a[i].size() != 4) return false;     return true;   }   int comp(int node1, int node2) {     int c = 0;     for (int i = 0; i < adjList[node1].size(); i++) {       for (int j = 0; j < adjList[node2].size(); j++) {         if (adjList[node1][i] == adjList[node2][j]) c++;       }     }     return c;   }   void dfs(int node) {     vis[node] = true;     bool f = true;     for (int i = 0; i < adjList[node].size() && f; i++) {       if (comp(node, adjList[node][i]) == 2 && !vis[adjList[node][i]])         ans.push_back(adjList[node][i]), dfs(adjList[node][i]), f = false;     }   }   int main() {     cin >> n;     for (int i = 1; i <= (2 * n); i++) {       cin >> x >> y;       adjList[x].push_back(y);       adjList[y].push_back(x);     }     if (!check_valid_edges(adjList, n)) return cout << -1 << endl, 0;     if (n == 5)       return cout <<  1 2 3 4 5 n  << endl, 0;     else if (n == 6) {       int s_node = 21;       for (int i = 0; i < adjList[1].size(); i++) s_node -= adjList[1][i];       s_node--;       cout <<  1   << adjList[1][0] <<     << adjList[1][1] <<     << s_node            <<     << adjList[1][2] <<     << adjList[1][3] << endl;       ;     } else {       dfs(1);       ans.push_back(1);       if (ans.size() == n)         for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;       else         cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x = 0, y = 0;     cin >> x >> y;     int z = abs(x) + abs(y);     if ((x > 0) && (y > 0))       cout << 0 <<     << z <<     << z <<     << 0;     else if ((x < 0) && (y > 0))       cout << -z <<     << 0 <<     << 0 <<     << z;     else if ((x > 0) && (y < 0))       cout << 0 <<     << -z <<     << z <<     << 0;     else       cout << -z <<     << 0 <<     << 0 <<     << -z;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ii = pair<int, int>;   using ll = long long int;   using vi = vector<int>;   using graph = vector<vi>;   const int INF = 0x3f3f3f3f;   const ll INFL = 0x3f3f3f3f3f3f3f3f;   const int MAXN = 200005;   int fq[4];   int main() {     int n, m, k;     string s;     cin >> n;     cin >> s;     for (auto c : s) {       int x = c -  0 ;       fq[x]++;     }     if (n == 1) {       cout << s <<   n ;     } else if (n == 2) {       if (fq[1] == 2) {         cout << 1 <<   n ;       } else {         cout << s <<   n ;       }     } else {       cout << 1;       while (fq[0]--) {         cout << 0;       }     }   }
#include <bits/stdc++.h>   const int inf = 1 << 30;   const long long INF = 1ll << 61;   using namespace std;   const int MOD = 1000000;   int n;   int nnum[500000 + 55];   int vis[1000000 + 55];   int flag[1000000 + 55];   vector<int> G;   void init() {     memset(flag, 0, sizeof(flag));     memset(nnum, 0, sizeof(nnum));     memset(vis, 0, sizeof(vis));     G.clear();   }   bool input() {     while (cin >> n) {       for (int i = 0; i < n; i++) {         scanf( %d , &nnum[i]);         vis[nnum[i]]++;       }       return false;     }     return true;   }   void cal() {     int cnt = 0;     for (int i = 0; i < n; i++) {       if (vis[nnum[i]] && !vis[MOD - nnum[i] + 1]) {         flag[MOD - nnum[i] + 1]++;         cnt++;       }     }     for (int i = 1; i <= MOD && cnt < n; i++) {       if (!vis[i] && !vis[MOD - i + 1]) {         flag[i] = 1;         cnt++;         flag[MOD - i + 1] = 1;         cnt++;       }     }     cout << cnt << endl;     for (int i = 1; i <= MOD; i++)       if (flag[i]) printf( %d  , i);     puts(  );   }   void output() {}   int main() {     while (true) {       init();       if (input()) return 0;       cal();       output();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[2000];   int vis[2000];   vector<pair<int, int> > cyc;   void dfs(int x, int scc) {     if (vis[x] > 0) {       return;     }     vis[x] = 1;     int j;     for (int i = 0; i < g[x].size(); i++) {       for (j = 0; j < g[g[x][i]].size(); j++) {         if (g[g[x][i]][j] == x) {           g[g[x][i]].erase(g[g[x][i]].begin() + j);         }       }       if (vis[g[x][i]] > 0) {         cyc.push_back(make_pair(x, g[x][i]));       }       dfs(g[x][i], scc);     }     return;   }   int main() {     int n, i, j, x, y, t, u;     cin >> n;     for (i = 0; i < n - 1; i++) {       cin >> x >> y;       x--;       y--;       g[x].push_back(y);       g[y].push_back(x);     }     memset(vis, 0, sizeof(vis));     int scc = 0, days = 0;     cyc.clear();     vector<int> store;     store.clear();     for (i = 0; i < n; i++) {       if (vis[i] == 0) {         scc++;         store.push_back(i);         dfs(i, scc);       }     }     if (scc == 1) {       cout <<  0 n ;       return 0;     }     j = 1;     vector<pair<pair<int, int>, pair<int, int> > > v;     v.clear();     for (i = 0; i < cyc.size(); i++) {       v.push_back(make_pair(make_pair(cyc[i].first + 1, cyc[i].second + 1),                             make_pair(store[j - 1] + 1, store[j] + 1)));       j++;     }     cout << v.size() <<   n ;     for (i = 0; i < v.size(); i++) {       cout << v[i].first.first <<     << v[i].first.second <<                << v[i].second.first <<     << v[i].second.second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gi() {     int x = 0, w = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) w = 0, ch = getchar();     while (ch >=  0  && ch <=  9 )       x = (x << 3) + (x << 1) + ch -  0 , ch = getchar();     return w ? x : -x;   }   const int N = 5e5 + 5;   struct node {     int h, nxt;   } a[N];   int n, m, nxt[N], head[N], val[N], ft[N];   char s[N];   int dep[N], sz[N], son[N], vis[N], sum[N], ans[N];   void add(int v, int h, int id) {     a[id] = (node){h, ft[v]};     ft[v] = id;   }   void dfs1(int u, int f) {     dep[u] = dep[f] + 1;     sz[u] = 1;     for (int v = head[u]; v; v = nxt[v]) {       dfs1(v, u), sz[u] += sz[v];       if (sz[v] > sz[son[u]]) son[u] = v;     }   }   void update(int u) {     sum[dep[u]] ^= val[u];     for (int v = head[u]; v; v = nxt[v])       if (!vis[v]) update(v);   }   bool cal(int x) {     int res = 0;     while (x) ++res, x ^= x & -x;     return res <= 1;   }   void dfs(int u, int f, int keep) {     for (int v = head[u]; v; v = nxt[v])       if (v != son[u]) dfs(v, u, 0);     if (son[u]) dfs(son[u], u, 1), vis[son[u]] = 1;     update(u);     for (int i = ft[u]; i; i = a[i].nxt) ans[i] = cal(sum[a[i].h]);     vis[son[u]] = 0;     if (!keep) update(u);   }   int main() {     n = gi();     m = gi();     for (int i = 2, f; i <= n; ++i) f = gi(), nxt[i] = head[f], head[f] = i;     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) val[i] = 1 << s[i] -  a ;     for (int i = 1, v, h; i <= m; ++i) v = gi(), h = gi(), add(v, h, i);     dfs1(1, 0);     dfs(1, 0, 1);     for (int i = 1; i <= m; ++i) puts(ans[i] ?  Yes  :  No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool spj(set<int>& s) {     vector<int> v{s.begin(), s.end()};     return (v[2] == 3 * v[0] && v[1] == 2 * v[0]);   }   int main() {     int n;     scanf( %d , &n);     vector<int> result;     for (int i = n, factor = 1; i != 0; i /= 2, factor *= 2) {       if (i == 3) {         {           result.push_back(factor);           result.push_back(factor);           result.push_back(3 * factor);           break;         }       }       int k = (i + 1) / 2;       for (int j = 0; j < k; ++j) {         result.emplace_back(factor);       }     }     for (int x : result) {       printf( %d  , x);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s, f, l, r, t;   int stay() {     int next = (s < f) ? s + 1 : s - 1;     return (s >= l && s <= r) || (next >= l && next <= r);   }   int di[] = {0, 1};   int dj[] = {1, 0};   void write(vector<string> &res, int x, int y, int dir, string s) {     for (int i = 0; i < s.size(); i++) {       res[x][y] = s[i];       x += di[dir];       y += dj[dir];     }   }   void print(vector<string> res) {     for (int i = 0; i < res.size(); i++) {       for (int j = 0; j < res[i].size(); ++j) {         cout << res[i][j];       }       cout << endl;     }   }   bool same(string a, string b, int i, int j) { return a[i] == b[j]; }   int main() {     vector<string> arr(6);     vector<bool> vis(6, 0);     for (int i = 0; i < 6; ++i) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     vector<string> best, res;     do {       if (!same(arr[0], arr[1], 0, 0) ||           !same(arr[4], arr[5], arr[4].size() - 1, arr[5].size() - 1))         continue;       if (arr[3].size() != arr[0].size() + arr[4].size() - 1 ||           arr[2].size() != arr[1].size() + arr[5].size() - 1)         continue;       if (!same(arr[3], arr[2], arr[0].size() - 1, arr[1].size() - 1) ||           !same(arr[2], arr[0], 0, arr[0].size() - 1) ||           !same(arr[2], arr[4], arr[2].size() - 1, 0))         continue;       if (!same(arr[3], arr[1], 0, arr[1].size() - 1) ||           !same(arr[3], arr[5], arr[3].size() - 1, 0))         continue;       int n = arr[2].size(), m = arr[3].size();       string tmp = string(m,  . );       res = vector<string>(n, tmp);       write(res, 0, 0, 0, arr[0]);       write(res, 0, 0, 1, arr[1]);       write(res, 0, arr[0].size() - 1, 1, arr[2]);       write(res, arr[1].size() - 1, 0, 0, arr[3]);       write(res, n - 1, arr[0].size() - 1, 0, arr[4]);       write(res, arr[1].size() - 1, m - 1, 1, arr[5]);       if (!best.size() || best > res) best = res;     } while (next_permutation(arr.begin(), arr.end()));     if (!best.size())       cout <<  Impossible  << endl;     else       print(best);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int dpl[2010], dpr[2010];   int main() {     cin >> s;     memset(dpr, 0, sizeof(dpr));     memset(dpl, 0, sizeof(dpl));     int i, j, k;     for (i = 0; i < s.size(); i++) {       for (j = i, k = i; j >= 0 && k < s.size() && s[k] == s[j]; j--, k++)         dpl[j]++, dpr[k]++;       for (j = i, k = i + 1; j >= 0 && k < s.size() && s[k] == s[j]; j--, k++)         dpl[j]++, dpr[k]++;     }     for (i = 1; i < s.size(); i++) dpr[i] += dpr[i - 1];     long long ans = 0;     for (i = 1; i < s.size(); i++) ans += dpr[i - 1] * dpl[i];     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> ara;   int main() {     int n, k;     cin >> n >> k;     int t = n / 2;     if (n == 1 && k != 0) {       cout << -1;       return 0;     }     if (n == 1 && k == 0) {       cout << 1;       return 0;     }     if (k < t) {       cout << -1;       return 0;     } else {       int t2 = k - t;       t2++;       cout << t2 <<     << t2 * 2;       cout <<    ;       ara[t2] = 1;       ara[t2 * 2] = 1;       int cnt = 1;       for (int i = 1; i <= n - 2; i++) {         if (ara[cnt] == 1) cnt++;         if (ara[cnt] == 1) cnt++;         cout << cnt <<    ;         cnt++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const double eps = 1e-6;   const int inf = 1e9;   const long long llf = 1e18;   const int mod = 1e9 + 7;   const int maxn = 1e5 + 10;   char s[110];   int f[310];   int main() {     int tc;     cin >> tc;     while (tc--) {       cin >> s + 1;       int n = strlen(s + 1);       sort(s + 1, s + n + 1);       string s1 =   , s2 =   ;       for (int i = 1; i <= n; i++) {         f[s[i]]++;       }       for (int i =  a ; i <=  z ; i++) {         if (i & 1) {           while (f[i]) {             s1 += i;             f[i]--;           }         } else {           while (f[i]) {             s2 += i;             f[i]--;           }         }       }       string t = s1 + s2;       int flag = 1;       for (int i = 1; i < t.size(); i++) {         if (abs(t[i] - t[i - 1]) == 1) {           flag = 0;           break;         }       }       if (flag) {         cout << t << endl;         continue;       }       t = s2 + s1;       flag = 1;       for (int i = 1; i < t.size(); i++) {         if (abs(t[i] - t[i - 1]) == 1) {           flag = 0;           break;         }       }       if (flag) {         cout << t << endl;       } else {         cout <<  No answer  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     std::vector<int> count(1 << 19);     auto modify = [&](char *s, int dt) {       int len = strlen(s);       std::reverse(s, s + len);       int val = 0;       for (int i = 0; i < 18; ++i) {         val = val | (i >= len ? 0 : (s[i] -  0  & 1)) << i;       }       count[val] += dt;     };     auto query = [&](char *s) {       int len = strlen(s);       std::reverse(s, s + len);       int val = 0;       for (int i = 0; s[i]; ++i) {         val |= s[i] -  0  << i;       }       return count[val];     };     int t;     scanf( %d , &t);     for (int _ = 0; _ < t; ++_) {       char op[2];       char str[18 + 1];       scanf( %s%s , op, str);       if (op[0] ==  + ) {         modify(str, 1);       } else if (op[0] ==  - ) {         modify(str, -1);       } else {         printf( %d n , query(str));       }     }   }
#include <bits/stdc++.h>   using namespace std;   namespace Solve {   const int MAXN = 200010;   inline int ScanInt(void) {     int r = 0, c, d;     while (!isdigit(c = getchar()) && c !=  - )       ;     if (c !=  - ) r = c -  0 ;     d = c;     while (isdigit(c = getchar())) r = r * 10 + c -  0 ;     return d ==  -  ? -r : r;   }   int a[MAXN], n, b[MAXN], cnt = 0, sum = 0;   int zero = 0, l1 = 0, l2 = 0;   bool c[MAXN];   inline void solve(void) {     n = ScanInt();     for (int i = 1; i <= n; i++) {       a[i] = ScanInt(), sum += a[i];       if (a[i] == 0) zero++;     }     if (!zero) {       puts( -1 );       return;     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) {       if (a[i] % 3 == 0) b[++cnt] = a[i], c[i] = true;       if (a[i] % 3 == 1) l1++;       if (a[i] % 3 == 2) l2++;     }     if (sum % 3 == 1) {       if (l1 == 0) {         int t = 2;         for (int i = 1; i <= n; i++)           if (a[i] % 3 == 2 && t) c[i] = true, t--;       } else {         int t = 1;         for (int i = 1; i <= n; i++)           if (a[i] % 3 == 1 && t) c[i] = true, t--;       }     }     if (sum % 3 == 2) {       if (l2 == 0) {         int t = 2;         for (int i = 1; i <= n; i++)           if (a[i] % 3 == 1 && t) c[i] = true, t--;       } else {         int t = 1;         for (int i = 1; i <= n; i++)           if (a[i] % 3 == 2 && t) c[i] = true, t--;       }     }     for (int i = 1; i <= n; i++)       if (!c[i]) b[++cnt] = a[i];     sort(b + 1, b + cnt + 1);     sum = 0;     for (int i = 1; i <= cnt; i++) sum += b[i];     if (sum == 0) {       puts( 0 );       return;     }     assert(sum % 3 == 0);     for (int i = cnt; i >= 1; i--) printf( %d , b[i]);     printf(  n );   }   }  // namespace Solve   int main(void) {     Solve::solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int x1 = 0, x2 = 0, y1 = 0, y2 = 0, position = 0;     int length = s.size();     for (int i = 0; i < length; i++) {       if (s[i] ==  R ) {         x1++;         position++;       }       if (s[i] ==  L ) {         x1--;         position--;       }       if (s[i] ==  U ) {         y1++;         position++;       }       if (s[i] ==  D ) {         y1--;         position--;       }     }     if (length % 2 == 0) {       printf( %d , (abs(x1) + abs(y1)) / 2);     } else {       cout << -1;     }   }
#include <bits/stdc++.h>   using namespace std;   const long ka[6] = {0, 0, 0, 0, 2, 4};   int main() {     long long n, m;     while (cin >> n >> m) {       if (n > m) {         int tmp = n;         n = m;         m = tmp;       }       long long ret;       if (n == 1)         ret = m / 6 * 6 + ka[m % 6];       else if (n == 2) {         if (m == 2)           ret = 0;         else if (m == 3)           ret = 4;         else if (m == 7)           ret = 12;         else           ret = n * m;       } else {         if (n % 2 && m % 2)           ret = n * m - 1;         else           ret = n * m;       }       cout << ret << endl;     }     return 0;   }
#include <bits/stdc++.h>   int n, i, x, ind[210], o = 0, e = 0;   char a[200001], arr[200010];   int main() {     scanf( %s , a);     n = strlen(a);     if (n == 1) {       printf( %s n , a);       return 0;     }     for (int i = 0; i < n; i++) {       ind[a[i]]++;     }     for (int i =  a ; i <=  z ; i++) {       if (ind[i] > 0) {         ind[i] % 2 == 0 ? e++ : o++;       }     }     for (int i =  z ; i >=  a ; i--) {       if (ind[i] % 2 != 0) {         for (int x =  a ; x < i; x++) {           if (ind[x] % 2 != 0) {             ind[x]++, ind[i]--;             break;           }         }       }     }     int j = 0;     for (int i =  a ; i <=  z ; i++) {       if (ind[i] > 0) {         for (int x = 0; x < ind[i] / 2; x++) {           printf( %c , i);           arr[j++] = i;         }       }     }     if (n % 2 != 0) {       for (int i =  a ; i <=  z ; i++) {         if (ind[i] % 2 == 1) {           printf( %c , i);           break;         }       }     }     for (int i = j - 1; i >= 0; i--) {       printf( %c , arr[i]);     }   }