Problem:
Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.

The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;


class Program
{
    public static double Jacc(HashSet<int> A,HashSet<int> B) {
        HashSet<int> tmp = new HashSet<int>();
        foreach (int e in A) tmp.Add(e);
        foreach (int e in B) tmp.Add(e);

        double OR_len = tmp.Count();
        double AND_len = A.Count() + B.Count() - OR_len;

        return AND_len / OR_len;
    }

    static void Main(string[] Args) {

        int N = Int32.Parse(ReadLine());
        var a = new List<string>(ReadLine().Split(' ')).Select(long.Parse).GroupBy(x => x).ToList();

        if(a.Count() == 1) {
            if(a[0].Key == 0) {
                WriteLine("Yes");
                goto ProgramEndPointLabel;
            } else {
                WriteLine("No");
                goto ProgramEndPointLabel;
            }
        } else if(a.Count() == 2) {
            if((a[0].Key ^ a[1].Key) == a[0].Key) {
                if(Math.Abs((getmin(a[0].Count(),a[1].Count()) * 2) - (getmax(a[0].Count(),a[1].Count()))) <= 0) {
                    WriteLine("Yes");
                    goto ProgramEndPointLabel;
                } else {
                    WriteLine("No");
                    goto ProgramEndPointLabel;
                }
            } else {
                WriteLine("No");
                goto ProgramEndPointLabel;
            }
        } else if(a.Count() == 3) {
            if((a[0].Key ^ a[1].Key) == a[2].Key) {
                if(getmax(getmax(a[0].Count(),a[1].Count()),a[2].Count()) - getmin(getmin(a[0].Count(),a[1].Count()),a[2].Count()) == 0) {
                    WriteLine("Yes");
                    goto ProgramEndPointLabel;
                } else {
                    WriteLine("No");
                    goto ProgramEndPointLabel;
                }
            } else {
                WriteLine("No");
                goto ProgramEndPointLabel;
            }
        } else {
            WriteLine("No");
            goto ProgramEndPointLabel;
        }

        goto ProgramEndPointLabel;
        ProgramEndPointLabel:;
        ReadLine();
    }


    static int getmin(int x,int y) {
        return (x < y) ? y : x;
    }
    static int getmax(int x,int y) {
        return (x < y) ? x : y;
    }

    class MyList<T> : List<T>
    {
        public override bool Equals(object obj) {
            List<T> obj_ = (List<T>)obj;
            if (this.Count != obj_.Count) return false;
            for (int i = 0; i < this.Count(); i++) {
                if (!this[i].Equals(obj_[i])) {
                    //WriteLine(this[i].Equals(obj_[i]));
                    //WriteLine(string.Format("this[{0}] = {1},obj_[{0}] = {2}", i, this[i], obj_[i]));
                    return false;
                }
            }
            return true;
        }
        public override int GetHashCode() {
            return base.GetHashCode();
        }
        //public static implicit operator MyList<T> (List<T> obj) {
        public static MyList<T> conv(List<T> obj) {
            MyList<T> res = new MyList<T>();
            foreach (T e in obj) res.Add(e);
            return res;
        }
        public MyList<T> Copy() {
            MyList<T> res = new MyList<T>();
            foreach(T e in this)
                res.Add(e);
            return res;
        }
    }

    static MyList<MyList<int>> GetIndex(MyList<Tuple<int,char,int>> Dict,int Count) {
        if(Count == 0) {
            MyList<MyList<int>> res = new MyList<MyList<int>>();
            MyList<int> res_ = new MyList<int>();
            res_.Add(-1);
            res.Add(res_);
            return res;
        }
        MyList<MyList<int>> res_indexes = new MyList<MyList<int>>();
        for(int i = 0;i < Dict.Count(); i++) {
            MyList<Tuple<int,char,int>> clone = Dict.Copy();
            clone.RemoveAt(i);
            MyList<MyList<int>> res = GetIndex(clone, Count - 1);
            MyList<int> temporary = new MyList<int>();
            foreach(MyList<int> ele in res) {
                temporary = new MyList<int>();
                temporary.Add(Dict[i].Item1);
                foreach(int ele_s_ele in ele) {
                    temporary.Add(ele_s_ele);
                }
                temporary.Sort();
                if(!res_indexes.Contains(temporary))
                    res_indexes.Add(temporary);
            }
        }
        
        //res_indexes = MyList<MyList<int>>.conv(res_indexes.Distinct().ToList());

        for (int i = 0; i < res_indexes.Count; i++)
            res_indexes[i].Remove(-1);
                
        return res_indexes;
    }

    static int div2(Dictionary<char,int> Dict,char without,int count) {
        if (count == 0) return 1;
        Dictionary<char, int> Dict_Copyed;
        Clone(Dict,out Dict_Copyed);
        Dict_Copyed.Remove(without);
        //foreach(var e in Dict_Copyed) 
        //    WriteLine(e.Key + ":" + e.Value + " ");
        //line();
        int result = 0;
        foreach(var e in Dict_Copyed) {
            result += div2(Dict_Copyed, e.Key, count - 1) * e.Value;
        }
        return result;
    }

    static void line() { WriteLine(); }

    static int kaizyo(int x) {
        int res = 1;
        for (int i = 1; i <= x; i++) res *= i;
        return res;
    }

    static void Clone(Dictionary<char,int> ori,out Dictionary<char,int> tar) {
        tar = new Dictionary<char, int>();
        foreach (KeyValuePair<char,int> e in ori)
            tar.Add(e.Key,e.Value);
    }

    static int div(Dictionary<char, int> _Dict,char without,int count) {
        if (count == 0) return 1;
        Dictionary<char, int> Dict = new Dictionary<char, int>();
        foreach (KeyValuePair<char,int> c in _Dict)
            Dict.Add(c.Key,c.Value);
        Dict.Remove(without);
        int Result = 0;
        foreach (KeyValuePair<char, int> c in Dict) {
            Result += div(Dict, c.Key, count - 1) * c.Value;
        }
        return Result;
    }

    static int C(int x,int y) {
        int Result = 1;
        for(int count = 0;count < y; count++)
            Result *= (x - count);
        for (int count = 0;count < y; count++)
            Result /= (y - count);
        return Result;
    }
}