malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   void flashSpeed() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   const long long N = 2e5 + 5;   long long fact[N];   double Round(double var) {     float value = (long long)(var * 100 + .5);     return (float)value / 100;   }   long long ceils(long long x, long long y) { return x / y + ((x % y) != 0); }   long long Gcd(long long a, long long b) {     if (b > a) {       return Gcd(b, a);     }     if (b == 0)       return a;     else       return Gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / Gcd(a, b) * b; }   bool isPal(string s) {     for (long long i = 0; i < (long long)s.size() / 2; i++) {       if (s[i] != s[(long long)s.size() - 1 - i]) return false;     }     return true;   }   long long Sumdigits(long long a) {     long long total = 0;     while (a) {       total += a % 10;       a /= 10;     }     return total;   }   bool isPerfectSquare(long long n) {     for (long long i = 1; i * i <= n; i++) {       if ((n % i == 0) && (n / i == i)) {         return true;       }     }     return false;   }   bool isPowerOfTwo(long long n) { return (ceil(log2(n)) == floor(log2(n))); }   void lexosmaintest(string s, string c) {     string t1 = s;     sort(t1.begin(), t1.end());     long long index = -1;     for (long long i = 0; i < s.length(); i++) {       if (s[i] != t1[i]) {         index = i;         break;       }     }     long long j;     for (long long i = 0; i < s.length(); i++) {       if (s[i] == t1[index]) j = i;     }     swap(s[index], s[j]);   }   const long long NN = 1e4 + 5;   long long primes[NN];   vector<long long> pr;   void sieve() {     for (long long i = 2; i < NN; i++) {       if (primes[i] == 0) {         pr.push_back(i);         for (long long j = i * i; j < NN; j += i) {           primes[j] = 1;         }       }       primes[i] ^= 1;     }   }   const long long mod2 = 998244353;   long long powerr(long long x, long long y, long long p = mod2) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long iAmUseless(long long n) {}   const double PI = acos(-1);   long long lefty[N];   long long righty[N];   void chaloTryKrteHai() {     long long a, b, c;     cin >> a >> b >> c;     long long m;     cin >> m;     long long second = a + b + c;     if (m > second - 3LL) {       cout <<  NO  << endl;     } else {       long long maxi = max({a, b, c});       second -= maxi;       if (maxi - 1 > second) {         if (m < (maxi - second) - 1) {           cout <<  NO  << endl;         } else {           cout <<  YES  << endl;         }       } else {         cout <<  YES  << endl;       }     }   }   int32_t main() {     flashSpeed();     sieve();     long long t = 1;     cin >> t;     while (t--) {       chaloTryKrteHai();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   int32_t main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     t = 1;     cin >> t;     for (long long tc = 0; tc < t; tc++) {       string str;       cin >> str;       long long cnt_ab = 0, cnt_ba = 0;       for (long long i = 0; i + 1 < (long long)str.size(); i++) {         cnt_ab += (str[i] ==  a  && str[i + 1] ==  b );         cnt_ba += (str[i] ==  b  && str[i + 1] ==  a );       }       if (cnt_ab == cnt_ba) {         cout << str <<   n ;         continue;       }       if (cnt_ab > cnt_ba) {         for (long long i = 0; i + 1 < (long long)str.size(); i++) {           if (str[i] ==  a ) {             str[i] =  b ;             break;           }         }       } else {         for (long long i = 0; i + 1 < (long long)str.size(); i++) {           if (str[i] ==  b ) {             str[i] =  a ;             break;           }         }       }       cout << str <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MAXN = 9223372036854775807, mod = 998244353;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long T = 1;     for (long long t = 0; t < T; t++) {       long long n, s1, s2, p1, p2;       cin >> n >> s1 >> s2 >> p1 >> p2;       long long time1 = s1 * n + 2 * p1;       long long time2 = s2 * n + 2 * p2;       if (time1 < time2)         cout <<  First ;       else if (time2 < time1)         cout <<  Second ;       else         cout <<  Friendship ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int A[100005];   int main(int argc, char *argv[]) {     scanf( %d , &N);     for (int i = (1), _n = (N); i <= _n; i++) scanf( %d , &A[i]);     int hi = -1;     for (int i = (1), _n = (N); i <= _n; i++) hi = max(hi, A[i]);     bool done[100005] = {false};     int ans = 1;     for (int i = (1), _n = (N); i <= _n; i++)       if (A[i] == hi && done[i] == false) {         int tans = 0;         for (int j = (i), _n = (N); j <= _n; j++)           if (A[j] == hi)             done[j] = true, tans++;           else             break;         ans = max(ans, tans);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int B, K;     cin >> B >> K;     vector<int> a(K);     for (int i = 0; i < K; ++i) cin >> a[i];     int odd = 0;     bool flag = (B % 2 ? 1 : 0);     for (int i = 0; i < K - 1; ++i) {       odd += (a[i] % 2 && flag);     }     odd += (a.back() % 2);     cout << (odd % 2 ?  odd  :  even ) <<   n ;     return 0;   }
#include <bits/stdc++.h>   const double PI = acos(-1);   using namespace std;   const int mod = 1e9 + 7;   const long long oo = 0x3f3f3f3f;   const int nn = 1e2 + 15;   vector<pair<int, int>> gr[nn], shifts;   map<char, int> vis;   long long get_distance(pair<int, int> a, pair<int, int> b) {     return ((a.first - b.first) * 1LL * (a.first - b.first) +             (a.second - b.second) * (a.second - b.second));   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(NULL);     cin.tie(NULL);     ;     int n, m, x;     cin >> n >> m >> x;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char c;         cin >> c;         if (c ==  S )           shifts.push_back(make_pair(i, j));         else           gr[c -  a ].push_back(make_pair(i, j));       }     }     int len;     cin >> len;     string s;     cin >> s;     int res = 0;     for (int i = 0; i < len; i++) {       if (isupper(s[i])) {         s[i] = tolower(s[i]);         if (!((int)((gr[s[i] -  a ]).size())) || !((int)((shifts).size())))           return cout << -1, 0;         else {           if (vis[s[i]]) {             if (vis[s[i]] > x * x) res++;             continue;           }           int mn = oo;           for (int j = 0; j < ((int)((shifts).size())); j++) {             for (int k = 0; k < ((int)((gr[s[i] -  a ]).size())); k++) {               int dist = get_distance(shifts[j], gr[s[i] -  a ][k]);               mn = min(mn, dist);             }           }           if (mn > x * x) res++;           vis[s[i]] = mn;         }       } else {         if (!((int)((gr[s[i] -  a ]).size()))) return cout << -1, 0;       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   long long solve() {     pair<long long, long long> init, final;     cin >> init.first >> init.second >> final.first >> final.second;     long long n;     cin >> n;     string s;     cin >> s;     pair<long long, long long> pre[n], cur = {0, 0};     map<char, pair<long long, long long> > dir;     dir[ L ] = make_pair(-1, 0);     dir[ R ] = make_pair(1, 0);     dir[ U ] = make_pair(0, 1);     dir[ D ] = make_pair(0, -1);     for (long long i = 0; i < n; ++i)       cur.first += dir[s[i]].first, cur.second += dir[s[i]].second, pre[i] = cur;     long long l = 0, r = 1e18;     while (r - l > 1) {       long long mid = (r + l) / 2;       long long x = init.first + (mid / n) * pre[n - 1].first,                 y = init.second + (mid / n) * pre[n - 1].second;       if (mid % n) x += (pre[mid % n - 1].first), y += (pre[mid % n - 1].second);       if (abs(x - final.first) + abs(y - final.second) <= mid)         r = mid;       else         l = mid;     }     if (r > 1e17) r = -1;     cout << r <<   n ;     return 0;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void FAST_IO() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     FAST_IO();     int n, m;     cin >> n >> m;     pair<int, int> ac{0, 0}, bc{0, 0};     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       if (a % 2)         ac.first++;       else         ac.second++;     }     for (int i = 0; i < m; ++i) {       int a;       cin >> a;       if (a % 2)         bc.first++;       else         bc.second++;     }     cout << min(ac.first, bc.second) + min(ac.second, bc.first) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 210000, K = 60;   int n, k, p;   int a[N], sum[N], f[N][K];   int main() {     scanf( %d%d%d , &n, &k, &p);     for (int i = 1; i <= n; i++)       scanf( %d , &a[i]), sum[i] = (sum[i - 1] + a[i] % p) % p;     memset(f, -0x3f, sizeof(f));     f[0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= k; j++) {         for (int o = 0; o <= p; o++) {           f[sum[i]][j] = max(f[sum[i]][j], f[o][j - 1] + (sum[i] - o + p) % p);         }       }     }     printf( %d n , f[sum[n]][k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 500005;   int n, m, u[MAXN], v[MAXN];   bool cho[MAXN], sel[MAXN];   void solve() {     int ans = 0;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &u[i], &v[i]);       if (!cho[u[i]] && !cho[v[i]]) {         sel[i] = 1;         ++ans;         cho[u[i]] = cho[v[i]] = 1;       }     }     if (ans >= n) {       printf( Matching n );       int cnt = 0;       for (int i = 1; i <= m && cnt < n; i++)         if (sel[i]) {           printf( %d  , i);           ++cnt;         }       printf(  n );     } else {       printf( IndSet n );       int cnt = 0;       for (int i = 1; i <= 3 * n && cnt < n; i++)         if (!cho[i]) {           printf( %d  , i);           ++cnt;         }       printf(  n );     }     for (int i = 1; i <= 3 * n; i++) cho[i] = 0;     for (int i = 1; i <= m; i++) sel[i] = 0;   }   int main() {     int T;     scanf( %d , &T);     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.1415926535897932384626433832795l;   template <typename T>   inline auto sqr(T x) -> decltype(x * x) {     return x * x;   }   template <typename T1, typename T2>   inline bool umx(T1& a, T2 b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <typename T1, typename T2>   inline bool umn(T1& a, T2 b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   const int N = 1000100;   int p[N];   bool use[N];   int main() {     std::ios::sync_with_stdio(false);     cout.setf(ios::showpoint | ios::fixed);     cout.precision(20);     int n;     cin >> n;     for (int i = int(0); i < int(n); ++i) {       cin >> p[i];       p[i]--;     }     int res = n;     for (int i = int(0); i < int(n); ++i) {       if (use[i]) continue;       int cur = i;       while (!use[cur]) {         use[cur] = 1;         cur = p[cur];       }       res--;     }     if (((n & 1) ^ (res & 1)) == 0) {       cout <<  Petr ;     } else {       cout <<  Um_nik ;     }     return 0;   }
#include <bits/stdc++.h>   struct ele {     int y, st;   } tmp;   std::vector<ele> edge[100100];   std::vector<int> gr[100100];   bool vi[100100];   int co[100100], N;   int flag, sp[100100];   void dfs(int x) {     int c, t;     for (int k = 0; k < edge[x].size(); k++) {       c = edge[x][k].y;       t = edge[x][k].st;       if (c == 1) continue;       if (!vi[c]) {         vi[c] = true;         if (t == 0)           co[c] = 1 + co[x] % 2;         else           co[c] = co[x];         gr[N].push_back(c);         dfs(c);       } else {         if ((co[x] == co[c] && t == 0) || (co[x] != co[c] && t == 1)) {           flag = 0;           return;         }       }     }     return;   }   int main() {     int k, n, m, t, a, b, c, d, i;     scanf( %d%d , &n, &m);     flag = 1;     memset(sp, -1, sizeof(sp));     for (k = 1; k <= m; k++) {       scanf( %d%d%d , &a, &b, &t);       edge[a].push_back(ele{b, t});       edge[b].push_back(ele{a, t});       if (a == 1) sp[b] = t + 1;       if (b == 1) sp[a] = t + 1;     }     for (k = 2; k <= n; k++) {       if (!vi[k]) {         N++;         gr[N].push_back(k);         vi[k] = 1;         co[k] = 1;         dfs(k);       }     }     long long ans = 1, MOD = 1000000007, tm, s;     if (flag == 0) {       printf( 0 n );       return 0;     }     for (k = 1; k <= N; k++) {       tm = 2;       s = -1;       for (i = 0; i < gr[k].size(); i++) {         c = gr[k][i];         if (sp[c] == -1) continue;         if (s == -1) {           if (sp[c] == co[c])             s = 0;           else             s = 1;           tm = 1;         } else {           if (sp[c] == co[c] && s == 1) tm = 0;           if (sp[c] != co[c] && s == 0) tm = 0;         }       }       ans *= tm;       ans %= MOD;     }     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long a[1010000];   inline bool read(long long &num) {     char in;     bool IsN = false;     in = getchar();     if (in == EOF) return false;     while (in !=  -  && (in <  0  || in >  9 )) in = getchar();     if (in ==  - ) {       IsN = true;       num = 0;     } else       num = in -  0 ;     while (in = getchar(), in >=  0  && in <=  9 ) {       num *= 10, num += in -  0 ;     }     if (IsN) num = -num;     return true;   }   int main() {     long long n;     scanf( %lld , &n);     long long sum = 0;     for (long long i = 1; i <= n; i++) {       read(a[i]);       sum += a[i];     }     if (n == 1) {       printf( %lld n , a[1]);       return 0;     }     if ((sum - (n * (n - 1) / 2)) % n == 0) {       long long x = (sum - (n * (n - 1) / 2)) / n;       for (long long i = 1; i < n; i++) printf( %lld  , x + i - 1);       printf( %lld n , x + n - 1);       return 0;     }     for (long long i = 1; i <= n; i++) {       if ((sum - (n * (n - 1) / 2) + i) % n == 0) {         long long x = (i + sum - (n * (n - 1) / 2)) / n, nd = x + n - i - 1;         for (long long j = 1; j < n - 1; j++) {           printf( %lld  , x);           if (x == nd) printf( %lld  , x);           x++;         }         if (x == nd) printf( %lld  , x);         printf( %lld n , x);         return 0;       }     }   }
#include <iostream>   #include <bits/stdc++.h>      int i = 0, j = 0, g = 0;      #define int long long   #define float double      using namespace std;      void solve(void)   {       int n;          cin >> n;          int a[2*n], config = 0;          set <int> s;          for (i = 0; i < 2*n; i++)       {           cin >> a[i];              if (a[i] % 2 == 1)           {               config = -1;           }              s.insert(a[i]);       }          sort(a, a + 2*n);          if (config == -1 || s.size() != n)       {           cout <<  NO n ;           return;       }          j = 2;          int asum = 0, csum = 0;              for (i = 1; i <= n - 1; i++)       {           if ((a[2*i] - a[2*(i - 1)]) % j != 0)           {               cout <<  NO n ;               return;           }              asum += (a[2*i] - a[2*(i - 1)])/j;           csum += asum;              j += 2;       }          if (((a[0]/2) - csum <= 0) || ((((a[0]/2) - csum) % n) != 0))       {           cout <<  NO n ;           return;       }          cout <<  YES n ;   }      int32_t main(void)   {       ios_base::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);          int t;          cin >> t;             while (t--)       {           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   int x[N], y[N], c[N], k[N], f[N];   int s[N], st, tu[N], tv[N];   struct node {     int u, v;     long long s;     bool operator<(const node &p) const { return s < p.s; }   } d[N * N + N];   int dis(int a, int b) { return abs(x[a] - x[b]) + abs(y[a] - y[b]); }   int fd(int x) {     if (f[x] == x) return x;     return f[x] = fd(f[x]);   }   void mg(int x, int y) {     int fa = fd(x), fb = fd(y);     f[fa] = fb;   }   int main() {     int n, p = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &x[i], &y[i]);     for (int i = 1; i <= n; i++) {       scanf( %d , &c[i]);       f[i] = i;       d[++p].s = c[i];       d[p].u = i;       d[p].v = n + 1;     }     for (int i = 1; i <= n; i++) scanf( %d , &k[i]);     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++)         d[++p].s = 1ll * dis(i, j) * (k[i] + k[j]), d[p].u = i, d[p].v = j;     sort(d + 1, d + p + 1);     int cnt = 0;     long long ans = 0;     for (int i = 1; i <= p; i++) {       if (fd(d[i].u) == fd(d[i].v)) continue;       if (d[i].v == n + 1)         s[++s[0]] = d[i].u;       else {         st++;         tu[st] = d[i].u;         tv[st] = d[i].v;       }       mg(d[i].u, d[i].v);       ans += d[i].s;       cnt++;       if (cnt == n) break;     }     printf( %lld n , ans);     printf( %d n , s[0]);     for (int i = 1; i <= s[0]; i++) printf( %d  , s[i]);     puts(  );     printf( %d n , st);     for (int i = 1; i <= st; i++) printf( %d %d n , tu[i], tv[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void write(long long a) {     if (a < 0) {       printf( - );       a = -a;     }     if (a >= 10) write(a / 10);     putchar(a % 10 +  0 );   }   inline void writeln(long long a) {     write(a);     printf(  n );   }   long long bin[110];   int main() {     long long t = read(), a = read(), b = read();     if (t == a && a == b) {       if (t == 1ll) printf( inf n );       if (t != 1ll) printf( 2 n );       return 0;     }     if (t > a) {       if (a != b)         puts( 0 );       else         puts( 1 );       return 0;     }     if (a == b) {       puts( 1 );       return 0;     }     int len = 0, cnt = 0;     if (t == 1 && a == 1 && b != 1) {       puts( 0 );       return 0;     }     while (b) {       bin[++len] = b % a;       cnt += bin[len];       b /= a;     }     long long ans = 0;     for (int i = len; i >= 1; i--) {       ans = ans * t + bin[i];     }     if (cnt == 1) {       if (ans != a) {         ans = 0;         len--;         bin[len] = a;         for (int i = len; i >= 1; i--) ans = ans * t + bin[i];       }     }     printf( %d n , ans == a);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n == 5) {       cout <<  YES n ;       cout <<  3 - 1 = 2  <<   n ;       cout <<  2 + 2 = 4  <<   n ;       cout <<  4 * 5 = 20  <<   n ;       cout <<  20 + 4 = 24  <<   n ;     } else if (n < 4)       cout <<  NO n ;     else {       cout <<  YES n ;       if (n % 4 == 0) {         cout <<  1 * 2 = 2  <<   n ;         cout <<  3 * 4 = 12  <<   n ;         cout <<  2 * 12 = 24  <<   n ;         for (int i = 1; i < n / 4; ++i) {           cout << i * 4 + 1 <<   -   << i * 4 + 2 <<   = -1  <<   n ;           cout << i * 4 + 4 <<   -   << i * 4 + 3 <<   = 1  <<   n ;           cout <<  -1 + 1 = 0  <<   n ;           cout <<  24 + 0 = 24  <<   n ;         }       } else if (n % 4 == 2) {         cout <<  4 * 6 = 24  <<   n ;         cout <<  2 * 1 = 2  <<   n ;         cout <<  5 - 3 = 2  <<   n ;         cout <<  2 - 2 = 0  <<   n ;         cout <<  24 + 0 = 24  <<   n ;         for (int i = 1; i < n / 4; ++i) {           cout << i * 4 + 5 <<   -   << i * 4 + 6 <<   = -1  <<   n ;           cout << i * 4 + 4 <<   -   << i * 4 + 3 <<   = 1  <<   n ;           cout <<  -1 + 1 = 0  <<   n ;           cout <<  24 + 0 = 24  <<   n ;         }       } else if (n % 4 == 3) {         cout <<  4 * 6 = 24  <<   n ;         cout <<  2 * 1 = 2  <<   n ;         cout <<  3 - 2 = 1  <<   n ;         cout <<  7 - 5 = 2  <<   n ;         cout <<  2 - 1 = 1  <<   n ;         cout <<  24 * 1 = 24  <<   n ;         for (int i = 1; i < n / 4; ++i) {           cout << i * 4 + 4 <<   -   << i * 4 + 5 <<   = -1  <<   n ;           cout << i * 4 + 7 <<   -   << i * 4 + 6 <<   = 1  <<   n ;           cout <<  -1 + 1 = 0  <<   n ;           cout <<  24 + 0 = 24  <<   n ;         }       } else {         cout <<  4 * 6 = 24  <<   n ;         cout <<  2 * 1 = 2  <<   n ;         cout <<  3 - 2 = 1  <<   n ;         cout <<  7 - 5 = 2  <<   n ;         cout <<  2 - 1 = 1  <<   n ;         cout <<  9 - 8 = 1  <<   n ;         cout <<  1 * 1 = 1  <<   n ;         cout <<  24 * 1 = 24  <<   n ;         for (int i = 1; i < n / 4 - 1; ++i) {           cout << i * 4 + 8 <<   -   << i * 4 + 9 <<   = -1  <<   n ;           cout << i * 4 + 7 <<   -   << i * 4 + 6 <<   = 1  <<   n ;           cout <<  -1 + 1 = 0  <<   n ;           cout <<  24 + 0 = 24  <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   const int MAXN = 1e4 + 10;   const int MOD = 1e9 + 7;   const int inf = 1e9;   const double pi = acos(-1.0);   const double eps = 1e-6;   int dx[] = {0, -1, 0, 1};   int dy[] = {1, 0, -1, 0};   int x, y;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int a, b, c;     cin >> x >> y;     a = b = c = y;     int res = 0;     while (a < x || b < x || c < x) {       int maxa = max(a, max(b, c));       int maxc = min(a, min(b, c));       int maxb = a + b + c - maxa - maxc;       int l = maxa + maxb - maxc - 1;       if (a == maxc)         a += l;       else if (b == maxc)         b += l;       else         c += l;       res++;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fp(long long x, long long y, long long m = 998244353) {     long long ANS = 1;     while (y) {       if (y & 1) ANS = (ANS * x) % 998244353;       x = (x * x) % 998244353;       y >>= 1;     }     return ANS;   }   long long inv(long long x, long long m = 998244353) { return fp(x, m - 2); }   long long testcases, arr[200001], n;   string s;   int32_t main() {     iostream::sync_with_stdio(0), cin.tie(0);     cin >> testcases;     while (testcases--) {       cin >> n;       for (long long i = 0; i < n; i++) cin >> arr[i];       cin >> s;       multiset<long long> L, S;       for (long long i = 0; i < n; i++) {         if (s[i] ==  R )           L.insert(arr[i]);         else           S.insert(arr[i]);       }       for (long long i = 1; i <= n; i++) {         auto itr = S.lower_bound(i);         if (itr == S.end()) {           auto itr2 = L.upper_bound(i);           if (itr2 == L.begin()) {             cout <<  NO  <<   n ;             goto a;           }           itr2--;           L.erase(itr2);         } else           S.erase(itr);       }       cout <<  YES  <<   n ;     a:;     }   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const int oo = (int)1e9;   const double PI = 2 * acos(0.0);   const double eps = 1e-7;   const int MAXN = 1e5 + 10;   int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};   int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};   int main() {     int n, k, a[100009];     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     set<long long> s;     for (int i = n - 1; i >= 0; i--)       if (s.find((long long)k * a[i]) == s.end()) s.insert(a[i]);     cout << ((int)((s).size())) << endl;   }