func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int n) {     if (x == 0) return 0;     if (n == 0) return 1;     if (n == 1) return x;     if (n % 2 == 0) {       long long int temp = power(x, n / 2);       return (temp % 1000000007 * temp % 1000000007) % 1000000007;     } else {       long long int temp = power(x, n / 2);       return (x % 1000000007 *               ((temp % 1000000007 * temp % 1000000007) % 1000000007) %               1000000007) %              1000000007;     }   }   long long int findroot(long long int i, long long int Arr[]) {     while (Arr[i] != i) {       Arr[i] = Arr[Arr[i]];       i = Arr[i];     }     return i;   }   void weightedunion(long long int i, long long int j, long long int arr[],                      long long int size[]) {     long long int x = findroot(i, arr);     long long int y = findroot(j, arr);     if (size[x] > size[y]) {       size[x] += size[y];       arr[y] = arr[x];     } else {       size[y] += size[x];       arr[x] = arr[y];     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, k, i, j, temp, ans = 0;     cin >> n >> k;     long long int arr[n];     set<long long int> s;     map<long long int, long long int> mp;     for (i = 0; i < n; i++) {       cin >> arr[i];       mp[arr[i]]++;     }     if (k == 1)       cout << mp.size() <<   n ;     else {       sort(arr, arr + n);       for (i = 0; i < n; i++) {         if (s.find(arr[i]) != s.end())           continue;         else {           s.insert(arr[i]);           vector<long long int> inc;           vector<long long int> ninc;           inc.push_back(mp[arr[i]]);           ninc.push_back(0);           for (temp = k * arr[i]; temp <= (long long int)1e9; temp = temp * k) {             s.insert(temp);             if (mp.find(temp) == mp.end()) {               inc.push_back(max(inc.back(), ninc.back()));               ninc.push_back(inc.back());             } else {               long long int x = inc.back(), y = ninc.back();               inc.push_back(mp[arr[i]] + ninc.back());               ninc.push_back(max(x, y));             }           }           ans += max(inc.back(), ninc.back());         }       }       cout << ans <<   n ;     }     return 0;   }   