Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) > 3:
        return False

    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        if len(set([nums.count(k) for k in kind])) != 1:
            return False
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            return True
        else:
            return False
    else:
        a, b = kind
        a_c, b_c = nums.count(a), nums.count(b)
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) not in (1, 2, 3):
        return False

    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        if len(set([nums.count(k) for k in kind])) != 1:
            return False
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            return True
        else:
            return False
    else:
        a, b = kind
        a_c, b_c = nums.count(a), nums.count(b)
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    kind = set(a_list)
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3
    if len(kind) not in (1, 2, 3):
        print("No")
        return
    if len(kind) == 1 and 0 in kind:
        print("Yes")
        return
    if n % 3 != 0:
        return "No"
    if len(kind) == 3:
        if len(set([a_list.count(k) for k in kind])) != 1:
            print("No")
            return
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            print("Yes")
        else:
            print("No")
    else:
        a, b = kind
        a_c, b_c = a_list.count(a), a_list.count(b)
        if 0 not in kind:
            print("No")
            return
        elif n / 3 != a_list.count(0):
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    kind = set(a_list)
    if len(kind) not in (1, 2, 3):
        print("No")
        return
    # 1 0 1
    # 1 2 3
    if len(kind) == 1 and 0 in kind:
        print("Yes")
        return
    elif len(kind) == 3:
        if n % 3 != 0 or len(set([a_list.count(k) for k in kind])) != 1:
            print("No")
            return
        kind = list(kind)
    else:
        a, b = kind
        a_c, b_c = a_list.count(a), a_list.count(b)
        if 0 not in kind or abs(a_c - b_c) > 1:
            print("No")
            return
        if a == 0:
            if a_c > b_c:
                print("No")
                return
            kind = [b, a, b]
        else:
            if b_c > a_c:
                print("No")
                return
            kind = [a, b, a]
    kind.extend([kind[0], kind[-1]])
    for i in range(3):
        if kind[i] != kind[i - 1] ^ kind[i + 1]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    kind = set(a_list)
    if len(kind) not in (1, 2, 3):
        print("No")
        return
    # 1 0 1
    # 1 2 3
    if len(kind) == 1 and kind[0] == 0:
        print("Yes")
        return
    elif len(kind) == 3:
        if n % 3 != 0 or len(set([a_list.count(k) for k in kind])) != 1:
            print("No")
            return
        kind = list(kind)
    else:
        a, b = kind
        a_c, b_c = a_list.count(a), a_list.count(b)
        if 0 not in kind or abs(a_c - b_c) > 1:
            print("No")
            return
        if a == 0:
            if a_c > b_c:
                print("No")
                return
            kind = [b, a, b]
        else:
            if b_c > a_c:
                print("No")
                return
            kind = [a, b, a]
    kind.extend([kind[0], kind[-1]])
    for i in range(3):
        if kind[i] != kind[i - 1] ^ kind[i + 1]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()