malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:200000000 )   using namespace std;   template <typename T>   inline T Abs(T x) {     return (x >= 0) ? x : -x;   }   template <typename T>   inline T sqr(T x) {     return x * x;   }   template <typename T>   inline string toStr(T x) {     stringstream st;     st << x;     string s;     st >> s;     return s;   }   template <typename T>   inline int bit(T mask, int b) {     return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;   }   inline int nextInt() {     int x;     if (scanf( %d , &x) != 1) throw;     return x;   }   inline long long nextInt64() {     long long x;     if (scanf( %I64d , &x) != 1) throw;     return x;   }   inline double nextDouble() {     double x;     if (scanf( %lf , &x) != 1) throw;     return x;   }   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double EPS = 1E-9;   const long double PI = 3.1415926535897932384626433832795;   int main() {     int n = nextInt();     long long k = nextInt64();     long long sum = 0;     int pos = 1, cnt = n;     for (int i = 0; i < (int)(n); i++) {       long long a = nextInt();       long long d = sum - a * (pos - 1) * (cnt - pos);       if (d < k) {         printf( %d n , i + 1);         cnt--;       } else {         sum += (pos - 1) * a;         pos++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int ar[5][5];     for (int i = 1; i <= 4; i++)       for (int j = 1; j <= 4; j++) cin >> ar[i][j];     int f = 0;     if (ar[1][4] &&         (ar[3][2] || ar[2][1] || ar[1][3] || ar[1][2] || ar[1][1] || ar[4][3]))       f = 1;     if (ar[2][4] &&         (ar[2][1] || ar[2][3] || ar[2][2] || ar[4][2] || ar[3][1] || ar[1][3]))       f = 1;     if (ar[3][4] &&         (ar[3][1] || ar[3][2] || ar[3][3] || ar[2][3] || ar[4][1] || ar[1][2]))       f = 1;     if (ar[4][4] &&         (ar[4][1] || ar[4][2] || ar[4][3] | ar[1][1] || ar[3][3] || ar[2][2]))       f = 1;     if (f)       cout <<  YES  <<   n ;     else       cout <<  NO  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long t = 0, f = 1;     char c = getchar();     while (!isdigit(c)) f = c ^ 45, c = getchar();     while (isdigit(c)) t = (t << 1) + (t << 3) + (c ^ 48), c = getchar();     return f ? t : -t;   }   const long long N = 5021, inf = 1e18;   long long n, m, a[N], f[N], dp[2][N];   int main() {     n = read();     for (int i = 1; i <= n; ++i) f[i] = a[i] = read();     sort(f + 1, f + 1 + n), m = unique(f + 1, f + 1 + n) - f - 1;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         dp[i & 1][j] = min(j == 1 ? inf : dp[i & 1][j - 1],                            dp[i - 1 & 1][j] + abs(a[i] - f[j]));     printf( %lld , dp[n & 1][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> isbandyk(int a, vector<int> prad) {     vector<int> rez;     vector<int> ats(prad.size(), -1);     int pas = 0;     for (int i = 0; i < prad.size(); i++) {       if (prad[i] <= a - 1) {         rez.push_back(prad[i]);         pas = i;         ats[i] = 1;       }     }     for (int i = pas + 1; i < prad.size(); i++) {       if (prad[i] == a) {         rez.push_back(prad[i]);         ats[i] = 1;       }     }     for (int i = 0; i < prad.size(); i++) {       if (prad[i] > a) {         rez.push_back(prad[i]);         ats[i] = 2;       } else if (prad[i] == a && i < pas) {         rez.push_back(prad[i]);         ats[i] = 2;       }     }     sort(prad.begin(), prad.end());     if (prad == rez) {       return ats;     } else {       vector<int> c;       return c;     }     return ats;   }   int main(int argc, const char* argv[]) {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> eil;       for (int i = 0; i < n; i++) {         char a;         cin >> a;         int b = a -  0 ;         eil.push_back(b);       }       bool taip = false;       for (int i = 0; i < 10; i++) {         vector<int> b = isbandyk(i, eil);         if (b.size() != 0) {           for (int i = 0; i < b.size(); i++) cout << b[i];           taip = true;           break;         }       }       if (!taip) cout <<  - ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     long long arr[n];     vector<long long> prime(200010);     vector<long long> temp;     for (long long i = 2; i <= sqrt(200010); i++) {       if (prime[i] == 1) continue;       for (long long j = 2; i * j < 200010; j++) prime[i * j] = 1;     }     for (long long i = 2; i < 200010; i++) {       if (prime[i] == 0) temp.push_back(i);     }     for (long long i = 0; i < n; i++) cin >> arr[i];     map<long long, vector<long long> > m;     for (long long i = 0; i < n; i++) {       long long a = arr[i];       for (long long j = 0; j < temp.size(); j++) {         if (a == 1) break;         long long c = 0;         if (temp[j] > sqrt(a)) {           m[a].push_back(1);           break;         }         while (a % temp[j] == 0 && a != 1) {           a /= temp[j];           c++;         }         if (c) m[temp[j]].push_back(c);       }     }     long long ans = 1;     for (long long i = 0; i < temp.size(); i++) {       if (m[temp[i]].size() < n - 1) continue;       sort(m[temp[i]].begin(), m[temp[i]].end());       long long o;       if (m[temp[i]].size() == n - 1)         o = m[temp[i]][0];       else         o = m[temp[i]][1];       while (o--) ans = ans * temp[i];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     string str;     cin >> str;     bool flag = false;     for (int i = 0; i < str.size(); i++) {       if (str[i] ==  H  || str[i] ==  Q  || str[i] ==  9 ) {         flag = true;         break;       }     }     if (flag)       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = (1 << 20);   priority_queue<pair<int, int> > Q[MX];   string str;   int n, K;   int main() {     cin >> str >> K;     n = str.size();     int cur = 0;     for (int j = 0; j < n; j++) Q[0].push(make_pair( z  - str[j], j));     while (1) {       while (cur > -1 && Q[cur].empty()) cur--;       if (cur == -1) break;       int let = Q[cur].top().first;       while (!Q[cur].empty() && Q[cur].top().first == let) {         int pos = Q[cur].top().second;         if (pos + cur + 1 < n)           Q[cur + 1].push(make_pair( z  - str[pos + cur + 1], pos));         K--;         if (K == 0) {           cout << str.substr(pos, cur + 1);           return 0;         }         Q[cur].pop();       }       cur++;     }     puts( No such line. );   }
#include <bits/stdc++.h>   const int MAXN = 100005;   using namespace std;   int n, m, q, v, u, a;   vector<int> E[MAXN], c[MAXN];   int L[MAXN], P[MAXN][17], M[MAXN][17][10], res[20], aux[20], cc[10];   void dfs(int cur, int prev) {     P[cur][0] = prev;     L[cur] = L[prev] + 1;     for (auto to : E[cur])       if (to != prev) dfs(to, cur);   }   void precalc() {     for (int j = 1; (1 << j) <= n; j++)       for (int i = 1; i <= n; i++) P[i][j] = P[P[i][j - 1]][j - 1];     for (int j = 1; (1 << j) <= n; j++) {       for (int i = 1; i <= n; i++) {         fill(aux, aux + 20, 1000000);         merge(M[i][j - 1], M[i][j - 1] + 10, M[P[i][j - 1]][j - 1],               M[P[i][j - 1]][j - 1] + 10, aux);         for (int h = 0; h < 10; h++) M[i][j][h] = aux[h];       }     }   }   int LCA(int x, int y) {     if (L[x] < L[y]) swap(x, y);     for (int j = 16; j >= 0; j--)       if (L[x] - (1 << j) >= L[y]) {         merge(res, res + 10, M[x][j], M[x][j] + 10, aux);         for (int h = 0; h < 10; h++) res[h] = aux[h];         x = P[x][j];       }     if (x == y) return x;     for (int j = 16; j >= 0; j--)       if (P[x][j] != 0 && P[x][j] != P[y][j]) {         merge(res, res + 10, M[x][j], M[x][j] + 10, aux);         for (int h = 0; h < 10; h++) res[h] = aux[h];         merge(res, res + 10, M[y][j], M[y][j] + 10, aux);         for (int h = 0; h < 10; h++) res[h] = aux[h];         x = P[x][j];         y = P[y][j];       }     merge(res, res + 10, M[x][0], M[x][0] + 10, aux);     for (int h = 0; h < 10; h++) res[h] = aux[h];     merge(res, res + 10, M[y][0], M[y][0] + 10, aux);     for (int h = 0; h < 10; h++) res[h] = aux[h];     return P[x][0];   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i < n; i++) {       scanf( %d%d , &v, &u);       E[v].emplace_back(u);       E[u].emplace_back(v);     }     for (int i = 1; i <= m; i++) {       scanf( %d , &a);       c[a].emplace_back(i);     }     dfs(1, 0);     for (int i = 0; i <= n; i++)       for (int j = 0; (1 << j) <= n; j++)         for (int h = 0; h < 10; h++) M[i][j][h] = 1000000;     for (int i = 1; i <= n; i++) sort((c[i]).begin(), (c[i]).end());     for (int i = 1; i <= n; i++)       for (int h = 0; h < min((int)c[i].size(), 10); h++) M[i][0][h] = c[i][h];     precalc();     while (q--) {       scanf( %d%d%d , &v, &u, &a);       fill(cc, cc + 20, 1000000);       fill(res, res + 20, 1000000);       int lca = LCA(v, u), sz = 0;       for (int h = 0; h < min((int)c[lca].size(), 10); h++) cc[h] = c[lca][h];       merge(res, res + 10, cc, cc + 10, aux);       for (int h = 0; h < min(a, 10) && aux[h] != 1000000; h++) sz++;       printf( %d  , sz);       for (int h = 0; h < sz; h++) printf( %d  , aux[h]);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     while (t--) {       long long d;       cin >> d;       long long dis = d * d - 4 * d;       if (dis < 0) {         cout <<  N n ;         continue;       } else {         double sq = sqrt(dis);         double b = (d + sq) / 2.0;         if (b == 1) {           cout <<  N n ;           continue;         } else           printf( Y %.9f %.9f n , abs(b), abs(b / (b - 1)));       }     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   long double PI = 3.14159265358979323846;   using ll = long long;   const ll modo = 1000000000;   const ll inf = LONG_LONG_MAX;   const ll ms = (2e6) + 5;   ll peil(ll a, ll b) {     if (a % b) return a / b + 1;     return a / b;   }   long double help(long double mid, long double k, long double val, ll pp,                    long double t) {     ll tmp = mid;     ll dd = tmp / pp;     long double rem = mid - (dd * pp);     long double ans = dd * val;     long double hh = min(rem, k);     ans += hh;     rem -= hh;     ans += (rem / 2);     return ans;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     cout << fixed << setprecision(10);     ll k, d, t;     cin >> k >> d >> t;     long double kk = peil(k, d) * d;     long double tt = k + ((kk - k) / 2);     long double l = t;     long double r = 2 * t;     long double mid;     long double ans = r;     long double res;     long double pp = 1 / (1e9);     while ((r - l) > pp) {       mid = (l + r) / 2;       res = help(mid, k, tt, kk, t);       if (res == t) {         cout << mid;         return 0;       }       if (res > t) {         r = mid;         ans = min(ans, mid);       } else         l = mid;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k,         t;     long long a[200045];     long long b[200045];     long long c[100001];     long long d[100001];     long long e[1000001];     pair<long long, long long> aa[100001];     double w, u, v, uu, vv;     string q1;     string q2;     string q3;     string q4;     string s;     string sq[3001];     string qs[3001];     map<long long, long long> g;     map<long long, long long>::iterator it;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> x;       a[i % k] = x + a[i % k];     }     t = 1234567894525;     for (i = 0; i < k; i++) {       if (t > a[i]) {         x = i;         t = a[i];       }     }     cout << x + 1;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > mas[2];   int a[(int)1e5 + 10], b[(int)1e5 + 10];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       int a = abs((x + y) % 2);       mas[a].push_back({(x + y - a) / 2, (x - y - a) / 2});     }     long long ans = 0;     for (int i = 0; i < 2; i++) {       sort(mas[i].begin(), mas[i].end());       a[mas[i].size()] = (int)-3e5;       b[mas[i].size()] = (int)3e6;       for (int j = (int)mas[i].size() - 1; j >= 0; j--) {         a[j] = max(a[j + 1], mas[i][j].second);         b[j] = min(b[j + 1], mas[i][j].second);       }       int c = (int)-3e5;       int d = (int)3e5;       for (int j = 0; j + 2 < (int)mas[i].size(); j++) {         c = max(c, mas[i][j].second);         d = min(d, mas[i][j].second);         long long le = max(b[j + 1], d);         long long ri = min(a[j + 1], c);         if (ri > le) {           ans += (ri - le) * (mas[i][j + 1].first - mas[i][j].first);         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(const pair<int, int>& i, const pair<int, int>& j) {     return i.first < j.first;   }   int main() {     string r, s;     cin >> r >> s;     vector<int> v;     if (r.length() != s.length()) {       cout <<  NO             <<   n ;       return 0;     }     for (int i = 0; i < s.length(); i++) {       if (s[i] != r[i]) {         v.push_back(i);       }     }     if (v.size() != 2)       cout <<  NO             <<   n ;     else {       if (s[v[0]] == r[v[1]] && s[v[1]] == r[v[0]])         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     char n[100];     scanf( %s , n);     int l = strlen(n);     int t = 0;     for (int i = 0; i < l; i++) {       if (n[i] ==  4  || n[i] ==  7 ) {         t += 1;       }     }     if (t == 4 || t == 7) {       printf( YES );     } else {       printf( NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<int, int> m1, m2, m3;     int n, m;     cin >> n >> m;     int a, b, c;     for (int i = 0; i < m; i++) {       cin >> a >> b >> c;       if (m1[a] == 0 && m1[b] == 0 && m1[c] == 0) {         m1[a] = 1;         m1[b] = 2;         m1[c] = 3;       } else if (m1[a] != 0) {         if (m1[a] == 1) {           m1[b] = 2;           m1[c] = 3;         } else if (m1[a] == 2) {           m1[b] = 1;           m1[c] = 3;         } else if (m1[a] == 3) {           m1[b] = 1;           m1[c] = 2;         }       } else if (m1[b] != 0) {         if (m1[b] == 1) {           m1[a] = 2;           m1[c] = 3;         } else if (m1[b] == 2) {           m1[a] = 1;           m1[c] = 3;         } else if (m1[b] == 3) {           m1[a] = 1;           m1[c] = 2;         }       } else if (m1[c] != 0) {         if (m1[c] == 1) {           m1[a] = 2;           m1[b] = 3;         } else if (m1[c] == 2) {           m1[a] = 1;           m1[b] = 3;         } else if (m1[c] == 3) {           m1[a] = 1;           m1[b] = 2;         }       }     }     for (int i = 1; i <= n; i++) {       cout << m1[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const sqN = 320;   int add(int a, int b);   int sub(int a, int b);   int arr[100005];   struct query {     int index;     int l;     int r;     int ans;   };   bool comp(query &a, query &b) {     if (a.l / sqN != b.l / sqN) {       return a.l / sqN < b.l / sqN;     }     return a.r < b.r;   }   bool comp_by_index(query &a, query &b) { return a.index < b.index; }   int main() {     int n, m, aux, l, r, cnt;     cin >> n >> m;     vector<int> F;     F.push_back(0);     for (int i = 0; i < n; i++) {       cin >> aux;       if (aux > 100000) aux = 0;       F.push_back(aux);     }     vector<query> Q;     for (int i = 0; i < m; i++) {       cin >> l >> r;       query inp;       inp.index = i;       inp.l = l;       inp.r = r;       Q.push_back(inp);     }     sort(Q.begin(), Q.end(), comp);     memset(arr, 0, sizeof(arr));     r = 1;     l = 0;     cnt = (F[1] == 1) ? 1 : 0;     arr[F[1]] += 1;     for (int i = 0; i < m; i++) {       query curq = Q[i];       while (r < Q[i].r) {         r++;         cnt += sub(arr[F[r]], F[r]);         arr[F[r]] += 1;         cnt += add(arr[F[r]], F[r]);       }       while (l < Q[i].l - 1) {         l++;         cnt += sub(arr[F[l]], F[l]);         arr[F[l]] -= 1;         cnt += add(arr[F[l]], F[l]);       }       while (l >= Q[i].l) {         cnt += sub(arr[F[l]], F[l]);         arr[F[l]] += 1;         cnt += add(arr[F[l]], F[l]);         l--;       }       while (r > Q[i].r) {         cnt += sub(arr[F[r]], F[r]);         arr[F[r]] -= 1;         cnt += add(arr[F[r]], F[r]);         r--;       }       Q[i].ans = cnt;     }     sort(Q.begin(), Q.end(), comp_by_index);     for (int i = 0; i < Q.size(); i++) cout << Q[i].ans << endl;   }   int add(int a, int b) {     if (b > 0 and b == a) return 1;     return 0;   }   int sub(int a, int b) {     if (b > 0 and b == a) return -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, k, t;   string s, m;   int main() {     cin >> s >> n;     for (i = 0; i <= s.length(); i++) {       if (s[i] !=  _  && isupper(s[i])) s[i] = tolower(s[i]);       if (s[i] ==  o )         s[i] =  0 ;       else if (s[i] ==  l  || s[i] ==  i )         s[i] =  1 ;     }     for (t = 1; t <= n; t++) {       cin >> m;       for (j = 0; j <= m.length(); j++) {         if (m[j] !=  _  && isupper(m[j])) m[j] = tolower(m[j]);         if (m[j] ==  o )           m[j] =  0 ;         else if (m[j] ==  i  || m[j] ==  l )           m[j] =  1 ;       }       if (m == s) k = 1;     }     if (k == 1)       cout <<  No ;     else       cout <<  Yes ;     cin >> n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<stack<int> > vs;     int maxi = -1, maximum = 0, nbVertices, n, type[100009], destination[100009],         source[100009];     cin >> n;     vs = vector<stack<int> >(n);     for (int i = 0; i < n; ++i) {       source[i] = 0;     }     for (int i = 0; i < n; ++i) {       cin >> type[i];     }     for (int i = 0; i < n; ++i) {       cin >> destination[i];       destination[i] -= 1;       if (destination[i] != -1) source[destination[i]]++;     }     for (int i = 0; i < n; ++i) {       if (type[i]) {         int j = i;         nbVertices = 1;         while (source[destination[j]] == 1 && destination[j] != -1) {           ++nbVertices;           vs[i].push(j + 1);           j = destination[j];         }         vs[i].push(j + 1);         if (maximum < nbVertices) {           maximum = nbVertices;           maxi = i;         }       }     }     cout << maximum << endl;     while (vs[maxi].size()) {       int top = vs[maxi].top();       cout << top <<    ;       vs[maxi].pop();     }     cout << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long int lli;   const lli N = 1000009, K =  z  -  a  + 1;   string s, t;   lli n, k, a[K], b[K];   void Solve() {       for(int i = 0; i < K - 1; i++) {           while(a[i] > b[i] && a[i] >= k) {               a[i] -= k;               a[i + 1] += k;           }       }       for(int i = 0; i < K; i++) {           if(a[i] != b[i]) {               cout<< No <<endl;               return ;           }       }       cout<< Yes <<endl;   }   void Inp() {       lli ntest;       cin>>ntest;       while(ntest--) {           cin>>n>>k>>s>>t;           for(int i = 0; i < K; i++) {               a[i] = 0;               b[i] = 0;           }           for(int i = 0; i < n; i++) {               a[s[i] -  a ]++;               b[t[i] -  a ]++;           }           Solve();       }   }   int main() {       ios_base::sync_with_stdio(0);       cin.tie(NULL);       cout.tie(NULL);       //freopen( inp.inp , r ,stdin);       Inp();   }
#include <bits/stdc++.h>   const int N = (int)1e5 + 7;   const int MOD = (int)1e9 + 7;   const long long INF = (long long)1e18;   using namespace std;   bool solve(vector<int> &A, int n) {     for (int i = 1; i < n; i++) {       if (A[i] > A[i - 1]) {         return true;       }     }     for (int i = 1; i < n; i++) {       if (A[i] == A[i - 1]) return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> A(n);       for (int i = 0; i < n; i++) cin >> A[i];       cout << (solve(A, n) ?  YES  :  NO ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, val =  ><+-.,[] ;     cin >> s;     long long int size = 0;     for (int i = 0; i < s.size(); i++) {       size = (size * 16 + val.find(s[i]) + 8) % 1000003;     }     cout << size;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2010;   int n, m, l, r, k, a[MAXN], b[MAXN];   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i] <= m) {         b[a[i]]++;       }     }     r = n / m;     l = 1;     for (int i = 1; i <= n; ++i) {       while (l <= m && b[l] >= r) {         l++;       }       if (l > m) {         break;       }       if (a[i] > m || b[a[i]] > r) {         if (a[i] <= m) {           b[a[i]]--;         }         a[i] = l;         b[l]++;         k++;       }     }     cout << r <<     << k <<   n ;     for (int i = 1; i <= n; ++i) {       cout << a[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   void JaiMataDi() {     int n;     cin >> n;     string a, b;     cin >> a >> b;     int cnt = 0;     for (int i = 0; i < n; i++) {       if ((a[i] ==  0 ) and (b[i] ==  1 ))         cnt += 2;       else if ((a[i] ==  1 ) and (b[i] ==  0 ))         cnt += 2;       else if ((a[i] ==  0 ) and (b[i] ==  0 )) {         if (i + 1 < n) {           if ((a[i + 1] ==  1 ) and (b[i + 1] ==  1 ))             cnt += 2, i++;           else             cnt += 1;         } else           cnt += 1;       } else if ((a[i] ==  1 ) and (b[i] ==  1 )) {         if (i + 1 < n) {           if ((a[i + 1] ==  0 ) and (b[i + 1] ==  0 )) cnt += 2, i++;         }       }     }     cout << cnt <<   n ;   }   int main() {     int t;     cin >> t;     while (t--) JaiMataDi();   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:500000000 )   using namespace std;   int main() {     int n, i, s;     scanf( %d %d , &n, &s);     vector<int> a(n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     sort(a.begin(), a.end());     long long res = 0;     int pos = n / 2;     if (a[pos] <= s) {       for (i = pos; i < n; i++) res += max(0, s - a[i]);     } else {       for (i = 0; i <= pos; i++) res += max(0, a[i] - s);     }     cout << res << endl;   }