Problem: p02975
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

dic = defaultdict(int)



if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
    
    
    if n_kind == 3:
        
        is_xor = False
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] ^ values[k] == 0:
                        is_xor = True

        
        
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        
        is_in_zero = True
        if 0 in values:
            is_in_zero = False

        is_n_valid = True
        if is_in_zero:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False

        if is_n_valid:
            print('Yes')
        else:
            print('No')


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

        if all_zero:
            print('Yes')
        else:
            print('No')        

    else:
        print('No')

else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

    if all_zero:
        print('Yes')
    else:
        print('No')
           

Failing test case input:
3
0 25 0

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

dic = defaultdict(int)



if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
        
    
    if n_kind == 3:
        is_xor = False    
        
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] ^ values[k] == 0:
                        is_xor = True

        
        
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        
        is_n_valid = True
        if 0 in values:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False
        else:
            is_n_valid = False

        if is_n_valid:
            print('Yes')
        else:
            print('No')


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

        if all_zero:
            print('Yes')
        else:
            print('No')        

    else:
        print('No')


else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

    if all_zero:
        print('Yes')
    else:
        print('No')