Problem:
Score : 300 points

Problem Statement

You are playing the following game with Joisino.

Initially, you have a blank sheet of paper.

Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.

Then, you are asked a question: How many numbers are written on the sheet now?

The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Constraints

1≤N≤100000

1≤A_i≤1000000000(=10^9)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print how many numbers will be written on the sheet at the end of the game.

Sample Input 1

3
6
2
6

Sample Output 1

1

The game proceeds as follows:

6 is not written on the sheet, so write 6.

2 is not written on the sheet, so write 2.

6 is written on the sheet, so erase 6.

Thus, the sheet contains only 2 in the end. The answer is 1.

Sample Input 2

4
2
5
5
2

Sample Output 2

0

It is possible that no number is written on the sheet in the end.

Sample Input 3

6
12
22
16
22
18
12

Sample Output 3

2

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		HashMap hm = new HashMap();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			int a = sc.nextInt();
			if (hm.containsKey(a)) {
				--ans;
				hm.delete(a);
			} else {
				hm.put(a, 0);
				++ans;
			}
		}
		System.out.println(ans);
	}

	static class HashMap {
		class Pair {
			long key;
			long value;

			public Pair(long key_, long value_) {
				key = key_;
				value = value_;
			}
		}

		Random rand = new Random();
		long p = (long) 1e6 + 7;
		long a = rand.nextInt((int) p - 1) + 1;
		long b = rand.nextInt((int) p - 1) + 1;
		int sz = 16;
		int cnt = 0;
		LinkedList<Pair>[] list;

		public HashMap() {
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
		}

		public HashMap(int sz_) {
			sz = sz_;
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
		}

		boolean delete(long key) {
			int id = hash(key);
			boolean ret = list[id].remove(key);
			if (sz >= 3 * cnt) {
				changeSize(sz / 2);
			}
			return ret;
		}

		void put(long key, long value) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key == key) {
					list[id].get(i).value = value;
					return;
				}
			}
			list[id].add(new Pair(key, value));
			++cnt;

			if (cnt > sz) {
				changeSize(2 * sz);
			}

			return;
		}

		long get(long key) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key == key) {
					return list[id].get(i).value;
				}
			}
			throw new AssertionError();
		}

		boolean containsKey(long key) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key != key) {
					continue;
				}
				return true;
			}
			return false;
		}

		int hash(long v) {
			return (int) ((a * v % p + b) % p % sz);
		}

		void changeSize(int sz_) {
			LinkedList<Pair>[] tmp = new LinkedList[sz];
			for (int i = 0; i < tmp.length; ++i) {
				tmp[i] = new LinkedList<>();
				tmp[i].addAll(list[i]);
			}
			sz = sz_;
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
			cnt = 0;
			for (int i = 0; i < tmp.length; ++i) {
				for (Pair p : tmp[i]) {
					put(p.key, p.value);
				}
			}
		}
	}

	long hash(int[] cs) {
		long ret = Long.MAX_VALUE;
		for (int i = 0; i < cs.length; ++i) {
			long hash = 0;
			for (int j = 0; j < cs.length; ++j) {
				hash = hash * 1000 + cs[(i + j) % cs.length];
			}
			ret = Math.min(ret, hash);
		}
		return ret;
	}

}