codeparrot/codecomplex huggingface dataset:
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.*;
import java.io.*;
import java.awt.Point;
import static java.lang.Math.*;

public class P274A {
    public static int i(String s) { return Integer.parseInt(s); }
    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = in.readLine().split(" ");
        int n = i(arr[0]);
        long k = i(arr[1]);
        long[] A = new long[n];
        arr = in.readLine().split(" ");
        for(int i=0; i<n; i++)
            A[i] = i(arr[i]);
        shuffle(A);
        Arrays.sort(A);

        Set<Long> BAN = new HashSet<Long>();
        int ans = 0;
        for(int i=0; i<n; i++) {
            if(!BAN.contains(A[i])) {
                ans++;
                BAN.add(A[i]*k);
            }
        }
        System.out.println(ans);
    }
    public static void shuffle(long[] array) {
        for (int i = array.length; i > 1; i--) {
            long temp = array[i - 1];
            int randIx = (int) (Math.random() * i);
            array[i - 1] = array[randIx];
            array[randIx] = temp;
        }
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;

public class A implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	void solve() throws IOException {
		int n = nextInt();
		long k = nextLong();

		if (k == 1) {
			out.println(n);
		} else {

			TreeMap<Long, ArrayList<Integer>> numbers = new TreeMap<Long, ArrayList<Integer>>();

			for (int i = 0; i < n; i++) {
				long m = nextLong();
				int howMuch = 0;

				while (m % k == 0) {
					m /= k;
					++howMuch;
				}

				if (!numbers.containsKey(m)) {
					numbers.put(m, new ArrayList<Integer>());
				}

				numbers.get(m).add(howMuch);
			}

			int res = 0;

			for (ArrayList<Integer> oneGroup : numbers.values()) {
				res += parseOneGroup(oneGroup);
			}

			out.println(res);
		}
	}

	private int parseOneGroup(ArrayList<Integer> oneGroup) {
		Collections.sort(oneGroup);

		int res = 0, prevValue = Integer.MIN_VALUE;

		for (int i = 0; i < oneGroup.size(); i++) {
			int curValue = oneGroup.get(i);

			if (prevValue + 1 != curValue) {
				++res;
				prevValue = curValue;
			}
		}

		return res;
	}

	public static void main(String[] args) {
		new A().run();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    //http://www.codeforces.com/contest/275/problem/C

    public static void main(String[] args) throws NumberFormatException, IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");

        int num = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine(), " ");

        if (k == 1) System.out.println(num); 
        else {
            Set<Integer> set = new TreeSet<Integer>();
            Set<Integer> bad = new TreeSet<Integer>();
            int sel;
            
            int[] arr = new int[num];
            for (int i = 0; i < num; i++) {
                arr[i] = Integer.parseInt((st.nextToken()));
            }

            shuffle(arr);
            Arrays.sort(arr);

            for (int i = 0; i < num; i++) {
                sel = arr[i];
                if (sel % k != 0) {
                    set.add(sel);
                    bad.add(sel * k);
                }
                if (!bad.contains(sel) && !set.contains(sel / k)) {
                    bad.add(sel * k);
                    set.add(sel);
                }
            }

            System.out.println(set.size()); 
        }
    }

    public static void shuffle(int[] arr) {
        Random rand = new Random();
        for (int i = arr.length - 1; i >= 0; --i) {
            int pos = rand.nextInt(i + 1);
            int aux = arr[i];
            arr[i] = arr[pos];
            arr[pos] = aux;
        }
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;


public class CF274A {

    public static void main(String[] args) throws Exception {
        new CF274A().solve();
    }

    private void solve() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        HashSet<Integer> used = new HashSet<>(n);
        int count = 0;
        for (int i = 0; i < n; i++) {
            Integer v = a[i];
            if (!used.contains(v)) {
                count++;
                long next = v * k;
                if (next <= 1000000000) used.add((int) next);
            }
        }
        System.out.println(count);
    }

}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long k = in.nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n; ++i) a[i] = in.nextLong();
        Arrays.sort(a);
        boolean[] take = new boolean[n];
        Arrays.fill(take, true);
        int j = 0;
        int res = n;
        for (int i = 0; i < n; ++i) {
            while (j < i && a[j] * k < a[i]) ++j;
            if (j < i && take[j] && a[j] * k == a[i]) {
                take[i] = false;
                --res;
            }
        }
        out.println(res);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    }
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import static java.lang.Math.*; 

import java.io.*; 
import java.util.*; 

public class Template {
	BufferedReader in; 
	PrintWriter out;
	StringTokenizer st; 

	String next() {
		while (st==null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (Exception e) {}
		}
		return st.nextToken(); 
	}

	int nextInt() {
		return Integer.parseInt(next()); 
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}
	
	class Point implements Comparable<Point> {
		int x, y; 
		public Point(int x, int y) {
			this.x=x; 
			this.y=y; 
		}
		public int compareTo(Point o) {
			return x-o.x; 
		}

		public String toString() {
			return x + " " + y; 
		}
	}
	

	public void run() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Long start = System.currentTimeMillis();
			int n = nextInt(); 
			long k = nextLong(); 

			long[] a = new long[n]; 
			TreeMap<Long, Integer> st  = new TreeMap<Long, Integer>(); 

			for (int i=0; i<n; i++) {
				a[i] = nextLong(); 
				st.put(a[i], 1);
			}

			Arrays.sort(a); 

			for (int i=0; i<n; i++) {
				if (a[i] % k == 0) {
					long x = a[i] / k; 
					if (st.containsKey(x)) {
						int y = st.get(x); 
						st.remove(a[i]); 
						st.put(a[i], y + 1); 
					}
				}
			}


			int ans = 0; 
			for (int i=0; i<n; i++) {
				//System.err.println(a[n-i-1] + " " + st.get(a[n-i-1])); 
				ans+=(st.get(a[n-i-1]) + 1) / 2; 
				if (a[n-i-1] % k == 0) {
					long x = a[n-i-1] / k; 
					if (st.containsKey(x)) {
						//System.err.println(x); 
						st.remove(x); 
						st.put(x, 0); 
					}
				}
			}

			out.println(ans); 

		Long end = System.currentTimeMillis();
		out.close(); 
	}

	public static void main(String[] args) throws Exception {
		new Template().run(); 
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class A {
    static int[] parent;

    public static int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    public static void union(int x, int y) {
        int px = find(x);
        int py = find(y);
        if (px != py) {
            parent[py] = px;
        }
    }

    public static void main(String[] args) throws Exception {
        int numCnt = (int) nextLong();
        long k = nextLong();
        parent = new int[numCnt];
        for (int i = 0; i < parent.length; i++) {
            parent[i] = i;
        }
        Long[] ar=new Long[numCnt];
        for (int i = 0; i < numCnt; i++) {
            ar[i] = nextLong();
        }
        Arrays.sort(ar);
        for (int i = 0; i < ar.length; i++) {
            long req = ar[i] * k;
            int l=0,h=ar.length,mid;
            while(l<h){
                mid=l+(h-l)/2;
                if(ar[mid]<req){
                    l=mid+1;
                }else{
                    h=mid;
                }
            }
            if(l<ar.length&&ar[l]==req){
                union(i,l);
            }
        }
        int[] count = new int[numCnt];
        for (int i = 0; i < parent.length; i++) {
            count[find(i)]++;
        }
        int res = 0;
        for (int i = 0; i < numCnt; i++) {
            res += (int) ((count[i] + 1) / 2.0);
        }
        System.out.println(res);
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer tokenizer = new StringTokenizer("");

    static long nextLong() throws Exception {
        return Long.parseLong(next());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }

    static String next() throws Exception {
        while (true) {
            if (tokenizer.hasMoreTokens()) {
                return tokenizer.nextToken();
            }
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            tokenizer = new StringTokenizer(s);
        }
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;


public class C {
	
	public static final long MAX = 1000000000L;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer tok1 = new StringTokenizer(br.readLine());
		final int n = Integer.parseInt(tok1.nextToken());
		final long k = Integer.parseInt(tok1.nextToken());
		
		StringTokenizer tok2 = new StringTokenizer(br.readLine());
		int[] array = new int[n];
		for(int i = 0; i < n; i++){
			array[i] = Integer.parseInt(tok2.nextToken());
		}
		
		int size = n;
		
		Arrays.sort(array);
		
		boolean[] skip = new boolean[n];
		for(int i = 0; i < n; i++){
			if(skip[i]){
				size--;
				continue;
			}
			
			long input = array[i];
			input *= k;
			if(input > MAX){
				continue;
			}
			
			
			final int pos = Arrays.binarySearch(array, (int)(input));
			if(pos >= 0 && !skip[pos]){
				skip[pos] = true;
			}
		}
		
		System.out.println(size);
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long k = input.nextInt();
        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = input.nextInt();
        }
        Arrays.sort(nums);
        Set<Long> wrong = new TreeSet<Long>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (!wrong.contains(nums[i])) {
                try {
                    wrong.add(nums[i] * k);
                } catch (Exception e) {
                }
                ans++;
            }
        }
        System.out.println(ans);
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
 	
	public void solve () throws Exception {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		TreeSet<Integer> bad = new TreeSet<>();
		int a [] = new int [n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		
		Random rnd = new Random();
		for (int i = 1; i < n; i++) {
			int j = rnd.nextInt(i + 1);
			int t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
		
		Arrays.sort(a);
		
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!bad.contains(a[i])) {
				result++;
				long next = (long) a[i] * k;
				if (next <= 1000000000)
					bad.add((int) next);
			}
		}
		out.println(result);
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Solution(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

//basically tried to understand ping's greedy alg
public class kMultRedo {
	static int n;
	static int k;
	public static void main(String[] args){
		Set<Integer> set = new TreeSet<Integer>();
		FastScanner s = new FastScanner();
		n = s.nextInt();
		k = s.nextInt();
		
		int[] a = new int[n];
		for(int i=0; i<n; i++){
			a[i] = s.nextInt();
		}
		Arrays.sort(a);
		
		for(int i=0; i<n; i++){
			if(a[i]%k !=0){
				set.add(a[i]);
			}else{
				if(!set.contains(a[i]/k)){
					set.add(a[i]);
				}
			}
		}
		
		System.out.println(set.size());
	}
	
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author ocelopilli
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long k = in.nextLong();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = in.nextInt();
        Arrays.sort( a );
        boolean[] ok = new boolean[ n ];
        Arrays.fill( ok, true );
        if (k > 1) for (int i=0; i<n; i++)
        {
            if ( ok[i] == false ) continue;
            int pos = Arrays.binarySearch( a, a[i]*k );
            if ( pos >= 0 )
            {
                //out.println( a[i]+" "+a[pos] );
                ok[ pos ] = false;
            }
        }
        int ans = 0;
        for (boolean x : ok) if ( x ) ans++;
        out.println( ans );
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader(InputStream in)
    {
        br = new BufferedReader(new InputStreamReader(in));
        st = null;
    }

    public String next()
    {
        while (st==null || !st.hasMoreTokens())
        {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A274 {

    /**
     * @param args
     */
    public static void main(String[] args) {
    
        Scanner in= new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        
        Long a[] =new Long[n];
        Hashtable<Long, Boolean> hash= new Hashtable<Long, Boolean>();
        
        
        for (int i=0;i< n;i++){
            a[i]=in.nextLong();
            
        }
        Arrays.sort(a);
        
        for (int i=0;i<n;i++){
            if (!hash.containsKey(a[i]) ){
                hash.put(a[i]*k, true);
            }
            
        }
        System.out.println(hash.size());
        
        
    }

}
// Problem: 220_A. Little Elephant and Problem
// Time complexity: nlogn
import java.util.*;
import java.io.*;

public class P220A
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        List<Integer> b = new ArrayList<Integer>(n);
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt();
            b.add(a[i]);
        }
        Collections.sort(b);
        int c = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != b.get(i)) c++;
        }
        if (c == 0 || c == 2)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}
// Problem: 220_A. Little Elephant and Problem
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;

import static java.lang.Math.*;

public class Main implements Runnable {
	
	void randomShuffle(int[] arr) {
		Random rnd = new Random();
		for (int i = arr.length - 1; i >= 0; i--) {
			int pos = rnd.nextInt(i + 1);
			int temp = arr[pos];
			arr[pos] = arr[i];
			arr[i] = temp;
		}
	}
	
	void solve() throws Exception {
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] ac = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = ac[i] = sc.nextInt();
		}
		randomShuffle(ac);
		Arrays.sort(ac);
		int diff = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] != ac[i]) {
				diff++;
			}
		}
		if (diff <= 2) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;
	
	static Throwable uncaught;
	
	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Main.uncaught = t;
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Main(), "", 128 * 1024 * 1024);
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {
	
	BufferedReader reader;
	StringTokenizer strTok;
	
	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}
	
	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}
	
	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
}