Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def dfs(N, E, s):
    stack = [(s, 0)]
    seen = [0]*(N+1)
    seen[s] = 1
    
    while stack:
        v, par = stack.pop()
        for i in E[v]:
            if i == par:
                continue
            elif seen[i] == 0:
                seen[i] = 1
                stack.append((i, v))
    
    return seen

def main():
    N,M,K = map(int, readline().split())

    F = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        F[a].append(b)
        F[b].append(a)
    
    B = [[] for _ in range(N+1)]
    for _ in range(K):
        c,d = map(int, readline().split())
        B[c].append(d)
        B[d].append(c)


    ans = []
    for i in range(1,N+1):
        tmp = 0
        seen = dfs(N,F,i)
        tmp += sum(seen) - 1
        tmp -= len(F[i])
        for j in B[i]:
            if seen[j] == 1:
                tmp -= 1
        ans.append(tmp)
    
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind_size:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c


def main():
    N,M,K = map(int, readline().split())

    uf = UnionFind_size(N+1)
    F = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        F[a].append(b)
        F[b].append(a)
        uf.unite(a, b)
    
    B = [[] for _ in range(N+1)]
    for _ in range(K):
        c,d = map(int, readline().split())
        B[c].append(d)
        B[d].append(c)


    ans = []
    for i in range(1,N+1):
        tmp = 0
        tmp += uf.get_size(i) - 1
        tmp -= len(F[i])
        for j in B[i]:
            if uf.same_check(i, j):
                tmp -= 1
        ans.append(tmp)
    
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H, N = map(int, readline().split())
    ab = map(int, read().split())
    AB = zip(ab, ab)
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for a, b in AB:
        for j in range(H+1):
            if j + a <= H:
                dp[j+a] = min(dp[j+a], dp[j]+b)
            else:
                dp[H] = min(dp[H], dp[j]+b)

    print(dp[H])


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    H,N = map(int, input().split())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for i in range(N):
        for j in range(H+1):
            if j + A[i] <= H:
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])
            else:
                dp[H] = min(dp[H], dp[j]+B[i])

    print(dp[H])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H, N, *ab = map(int, read().split())
    A = []
    B = []
    for a, b in zip(*[iter(ab)] * 2):
        A.append(a)
        B.append(b)
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for i in range(N):
        for j in range(H+1):
            if j + A[i] <= H:
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])
            else:
                dp[H] = min(dp[H], dp[j]+B[i])

    print(dp[H])


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    H,N = map(int, input().split())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for i in range(N):
        for j in range(H+1):
            if j + A[i] <= H:
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])
            else:
                dp[H] = min(dp[H], dp[j]+B[i])

    print(dp[H])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
    H,N = map(int, input().split())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for i in range(N):
        for j in range(H+1):
            if j + A[i] <= H:
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])
            else:
                dp[H] = min(dp[H], dp[j]+B[i])

    print(dp[H])


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    H,N = map(int, input().split())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [float("inf")] * (H+1)
    dp[0] = 0

    for i in range(N):
        for j in range(H+1):
            if j + A[i] <= H:
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])
            else:
                dp[H] = min(dp[H], dp[j]+B[i])

    print(dp[H])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        key = 0
        cnt = 0
        for n in pattern:
            for i in range(key,N):
                if S[i] == n:
                    key = i+1
                    cnt += 1
                    break
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        key = 0
        cnt = 0
        for n in pattern:
            for i in range(key,N):
                if S[i] == n:
                    key = i+1
                    cnt += 1
                    break
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import re
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for i in range(1000):
        a,b,c = str(i).zfill(3)
        pattern = r'.*?{}.*?{}.*?{}.*?'.format(a, b, c)
        match = re.search(pattern, S)

        if match:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        key = 0
        cnt = 0
        for n in pattern:
            for i in range(key,N):
                if S[i] == n:
                    key = i+1
                    cnt += 1
                    break
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
read = sys.stdin.read

def main():
    N, *ab = map(int, read().split())
    E = [[] for _ in range(N + 1)]
    
    for a, b in zip(*[iter(ab)] * 2):
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque
def main():
    N = int(input())
    # 辺の集合を隣接リストとして入力
    E = [[] for i in range(N+1)]
    edge_order = []
    for i in range(N-1):
        a,b = map(int, input().split())
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if i < V:
                continue
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,T,*ab = map(int, read().split())

    AB = []
    for a, b in zip(*[iter(ab)]*2):
        AB.append((a, b))

    AB.sort()
    
    dp = [[0] * (T+1) for _ in range(N+1)]

    ans = 0
    for i in range(N):
        w_i, v_i = AB[i]
        for j in range(T):
            if j < w_i:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j - w_i] + v_i, dp[i][j])
        
        ans = max(ans, dp[i][T-1] + v_i)
    
    print(ans)
    

if __name__ == "__main__":
    main()


Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,T,*ab = map(int, read().split())

    AB = []
    for a, b in zip(*[iter(ab)]*2):
        AB.append((a, b))

    AB.sort()
    
    dp = [[0] * (T+1) for _ in range(N+1)]

    ans = 0
    for i in range(N):
        w_i, v_i = AB[i]
        for j in range(T):
            if j < w_i:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j - w_i] + v_i, dp[i][j])
        
        ans = max(ans, dp[i][T-1] + v_i)
    
    print(ans)
    

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import sqrt, inf

def main():
    N = int(input())

    ans = inf
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from math import sqrt

def main():
    N = int(input())

    ans = 10**12+1
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import atan, degrees

def main():
    a,b,x = map(int, input().split())

    t = atan(a**3 / (2 * a**2 * b - 2 * x))
    s = atan(2 * x / (a * b**2))

    if x >= a**2 * b / 2:
        print(90.0 - degrees(t))
    else:
        print(90.0 - degrees(s))


if __name__ == "__main__":
    main()


Fixed submission:
from math import atan, degrees

def main():
    a,b,x = map(int, input().split())
    if x == a**2 * b:
        print(0.0)
        exit()

    t = atan(a**3 / (2 * a**2 * b - 2 * x))
    s = atan(2 * x / (a * b**2))

    if x >= a**2 * b / 2:
        print(90.0 - degrees(t))
    else:
        print(90.0 - degrees(s))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def main():
    N = int(input())
    L = [int(i) for i in input().split()]

    L.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            tmp = L[i] + L[j]
            insert_index = bisect.bisect_left(L[j+1:], tmp)
            #print(insert_index)
            ans += insert_index

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
import time

def main():
    N = int(input())
    L = [int(i) for i in input().split()]
    #N = 2000
    #L = [int(i) for i in range(N)]

    L.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            #ans += bisect.bisect_left(L[j+1:], L[i]+L[j])
            index = bisect.bisect_left(L, L[i]+L[j])
            ans += (index - (j+1))

    print(ans)


if __name__ == "__main__":
    #start = time.time()
    main()
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    l = [int(i) for i in input().split()]

    l.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            tmp = l[i] + l[j]
            for k in range(j+1,N):
                if l[k] < tmp:
                    ans +=1
                else:
                    break
    
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
import time

def main():
    N = int(input())
    L = [int(i) for i in input().split()]
    #N = 2000
    #L = [int(i) for i in range(N)]

    L.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            #ans += bisect.bisect_left(L[j+1:], L[i]+L[j])
            index = bisect.bisect_left(L, L[i]+L[j])
            ans += (index - (j+1))

    print(ans)


if __name__ == "__main__":
    #start = time.time()
    main()
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
Buggy python submission (verdict: Runtime Error):
import re

def main(s):
    #文字列sに同じ文字がn個以上連続している部分文字列を見つける
    n = 2
    # カンマを取ると n 個ちょうどになる
    reg = re.compile("(.)\\1{%d,}" %(n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


if __name__ == "__main__":
    s = input()
    K = int(input())

    # 1文字の場合
    if len(s) == 1:
        print(K // 2)
        exit()

    t = list(main(s))

    # 全ての文字が同じ場合
    if len(t) == 1 and len(t[0]) == len(s):
        print((len(s) * K) // 2)
        exit()

    # 先頭と末尾が同じ場合
    ans1 = 0
    if len(s) >= 3 and s[0] == s[-1]:
        if len(t) >= 2 and t[0][0] == s[0] and t[-1][0] == s[-1]:
            ans1 = len(t[0]) // 2 + len(t[-1]) // 2 - ((len(t[0]) + len(t[-1])) // 2)
            ans *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[-1]) // 2 - ((1 + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[0]) // 2 - ((len(t[0] + 1)) // 2)
            ans1 *= K-1
        
        else:
            ans1 = -1 * (K-1)

    # 先頭と末尾が異なる場合
    ans2 = 0
    for i in t:
        ans2 += len(i) // 2
    ans2 *= K

    ans = -ans1 + ans2
    print(ans)

Fixed submission:
import re

def main(s):
    #文字列sに同じ文字がn個以上連続している部分文字列を見つける
    n = 2
    # カンマを取ると n 個ちょうどになる
    reg = re.compile("(.)\\1{%d,}" %(n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


if __name__ == "__main__":
    s = input()
    K = int(input())

    # 1文字の場合
    if len(s) == 1:
        print(K // 2)
        exit()

    t = list(main(s))

    # 全ての文字が同じ場合
    if len(t) == 1 and len(t[0]) == len(s):
        print((len(s) * K) // 2)
        exit()

    # 先頭と末尾が同じ場合
    ans1 = 0
    if len(s) >= 3 and s[0] == s[-1]:
        if len(t) >= 2 and t[0][0] == s[0] and t[-1][0] == s[-1]:
            ans1 = len(t[0]) // 2 + len(t[-1]) // 2 - ((len(t[0]) + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[-1]) // 2 - ((1 + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[-1][0] != s[-1]:
            ans1 = len(t[0]) // 2 - ((len(t[0] + 1)) // 2)
            ans1 *= K-1
        
        else:
            ans1 = -1 * (K-1)

    # 先頭と末尾が異なる場合
    ans2 = 0
    for i in t:
        ans2 += len(i) // 2
    ans2 *= K

    ans = -ans1 + ans2
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from fractions import gcd

def era(n):
    if n == 1:
        return []
    prime_list = []
    # 2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,n+1))
    while True:
      # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            # search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            # search_listの先頭をpopする
            search_list.pop(0)
            # head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]

    return prime_list

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    p_nums = era(g)

    ans = 1
    if len(p_nums) >= 1:
        for p in p_nums:
            if g % p == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import math
from fractions import gcd

def era(ps, n):
    if len(ps) == 1:
        return 1
    search_list = ps[1:]
    for i in range(1, n+1):
        search_list = [num for num in search_list if num % i != 0 or num == i ]

    return len(search_list)+1

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    div = make_divisors(g)
    #print(div)

    ans = 1
    for n in div:
        if is_prime(n):
            ans += 1

    print(ans)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop

N,M = map(int, input().split())
a = [int(i) for i in input().split()]

hq = heapq.heapify(a)

for i in range(N):
    heappush(hq, -a[i])

for i in range(M):
    tmp = -heappop(hq) // 2
    heappush(hq, -tmp)

print(-sum(hq)) 

Fixed submission:
from heapq import heappush, heappop

N,M = map(int, input().split())
hq = []
a = [int(i) for i in input().split()]
for i in range(N):
    heappush(hq, -a[i])

for i in range(M):
    tmp = -heappop(hq) // 2
    heappush(hq, -tmp)

print(-sum(hq))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
n = 45

x = [None] * N
y = [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(n):
    theta = (2 * math.pi / n) * i
    c = math.cos(theta)
    s = math.sin(theta)
    tmp_x = 0
    tmp_y = 0
    for j in range(N):
        if x[j] * c + y[j] * s > 0:
            tmp_x += x[j]
            tmp_y += y[j]
    if tmp_x**2 + tmp_y**2 > ans**2:
        ans = math.sqrt(tmp_x**2 + tmp_y**2)

print(ans)


Fixed submission:
s = input()
t = input()

ans = 0

for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
s = [input() for i in range(N)]

c = []
ans = 0
for i in range(N):
    c.append(Counter(s[i]))

for i in range(N):
    for j in range(i+1, N):
        if c[i] == c[j]:
            ans += 1

print(ans)

Fixed submission:
#from collections import defaultdict
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)
#d = defaultdict(int)
d = dict()

ans = 0
for key in s:
    if key not in d:
        d[key] = 0
    else:
        ans += d[key]    
    d[key] += 1

#print(d)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
s = [input() for i in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        a = Counter(s[i])
        b = Counter(s[j])
        if a == b:
            ans += 1

print(ans)

Fixed submission:
#from collections import defaultdict
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)
#d = defaultdict(int)
d = dict()

ans = 0
for key in s:
    if key not in d:
        d[key] = 0
    else:
        ans += d[key]    
    d[key] += 1

#print(d)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

n = len(str(N))
if n % 2 == 0:
    s = "90" * (n//2)
    print(s[:-1])
    
else:
    s = "90" * ((n-1) // 2)
    ans = int(s[:-1]) + N - 10**(n-1) + 1
    print(ans)

Fixed submission:
N = int(input())

n = len(str(N))
if n == 1:
    print(N)
else:
    if n % 2 == 0:
        s = "90" * (n//2)
        print(s[:-1])
        
    else:
        s = "90" * ((n-1) // 2)
        ans = int(s[:-1]) + N - 10**(n-1) + 1
        print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
    exit()

print("Yes" if flag else "No")


Fixed submission:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if c[0] == N:
    print("Yes")
    exit()

if N % 3 == 0 and c[0] == N // 3 and len(c.values()) == 2:
    print("Yes")
    exit()

n =  N // 3
k = list(c.keys())
v = list(c.values())

if N % 3 == 0 and v == [n, n, n] and k[0]^k[1]^k[2] == 0:
    print("Yes")
    exit()

print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
        exit()

print("Yes" if flag else "No")


Fixed submission:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if c[0] == N:
    print("Yes")
    exit()

if N % 3 == 0 and c[0] == N // 3 and len(c.values()) == 2:
    print("Yes")
    exit()

n =  N // 3
k = list(c.keys())
v = list(c.values())

if N % 3 == 0 and v == [n, n, n] and k[0]^k[1]^k[2] == 0:
    print("Yes")
    exit()

print("No")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

nCr = {}
def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr:
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(K):
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)


Fixed submission:
from collections import Counter

s = input()

t = Counter(s)

a = []
for i,j in t.items():
    a.append(j)

if len(a) == 2:
    if a[0] == a[1]:
        print("Yes")
        exit()

print("No")