Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(max(v)+1)]
v_odd = [0 for i in range(max(v))+1]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(len(v_odd)):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(len(v_even)):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)

Fixed submission:
N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(max(v)+1)]
v_odd = [0 for i in range(max(v)+1)]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(len(v_odd)):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(len(v_even)):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(10**5)]
v_odd = [0 for i in range(10**5)]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(10**5):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(10**5):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)

Fixed submission:
N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(max(v)+1)]
v_odd = [0 for i in range(max(v)+1)]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(len(v_odd)):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(len(v_even)):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def alpha(s_list,N):
    ss =""
    S = [0 for i in range(N)]
    for i in range(len(s_list)):
        for j in s_list[i]:
            S[j] = chr(i+97)
    for i in range(len(S)):
        ss = ss + str(S[i])
    
    return ss
S = str(input())
T = str(input())
s_list = [[] for i in range(26)]
t_list = [[] for i in range(26)]
#各アルファベットがどこにあるか？
for i in range(len(S)):
    s_list[ord(S[i])-97].append(i)
for i in range(len(T)):
    t_list[ord(T[i])-97].append(i)

for i in range(len(S)):
    if S[i] != T[i]:
        #S[i]がT[i]になるように入れ替える
        temp = s_list[ord(S[i])-97] #T[i]
        s_list[ord(S[i])-97] = s_list[ord(T[i])-97]
        s_list[ord(T[i])-97] = temp
    S = alpha(s_list,len(S))
if s_list == t_list:
    print('Yes')
else:
    print('No')

Fixed submission:
S = str(input())
T = str(input())
s_list = [[] for i in range(26)]
t_list = [[] for i in range(26)]
#各アルファベットがどこにあるか？
for i in range(len(S)):
    s_list[ord(S[i])-97].append(i)
for i in range(len(T)):
    t_list[ord(T[i])-97].append(i)
ok = True
for s in s_list:
    if s != []:
        if s in t_list:
            continue
        else:
            ok = False
            break

if ok:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
def ncr(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def factorize(n):
    d = {}
    m = 2
    while m*m <= n:
        if n%m == 0:
            d[m] = 0
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] = 1
    return d
count = 1
n,m = map(int,input().split())
mod = 10**9+7
b = factorize(m)
for i in b:
    count *= ncr(b[i]+n-1,b[i])%mod
print(count%mod)

Fixed submission:
N,M = map(int,input().split())
MOD = 10**9+7
from collections import Counter
c = Counter()
m = 2

while(m**2 <= M):
    if M%m == 0:
        while(M%m == 0):
            c[m] += 1
            M //= m
    else:
        m += 1
if M > 1 : c[M] += 1
MAXN = N+100
fac = [0 for _ in range(MAXN)]
inv = [0 for _ in range(MAXN)]
finv = [0 for _ in range(MAXN)]
fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1
for i in range(2,MAXN):
    fac[i] = (i*fac[i-1]) % MOD
    inv[i] = (-inv[MOD%i]*(MOD//i))%MOD
    finv[i] = (finv[i-1]*inv[i])%MOD

def comb(n,k):
    return (fac[n]*(finv[k]*finv[n-k]%MOD))%MOD
ans = 1
for i in c:
    ans *= comb(c[i]+N-1,N-1)
    ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,k =map(int,input().split())
if abs(a-b) >= 10**8:
  print("Unfair")
else:
  print(a-b if k%2==0 else b-a)0

Fixed submission:
a,b,c,k =map(int,input().split())
if abs(a-b) > 10**18:
  print("Unfair")
else:
  print(a-b if k%2==0 else b-a)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
arr =[]
for i in range(len(s)):
    for j in range(i,len(s)):
        if s[i:j+1] != '' and s[i:j+1] not in arr:
            arr.append(s[i:j+1])
def print_arr(arr):
    for i in range(len(arr)):
        print(arr[i],sep=" ",end="/")
    print()
   
arr = sorted(arr)
print(arr[k-1])

Fixed submission:
s = input()
k = int(input())
arr =[]
for i in range(len(s)):
    for j in range(i,i+5):
        if s[i:j+1] != '' and s[i:j+1] not in arr:
            arr.append(s[i:j+1])
arr = sorted(arr)
def print_arr(arr):
    for i in range(len(arr)):
        print(arr[i],sep="",end="/")
    print()   
print(arr[k-1])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split()))
print(a if a<=b else a-1)

Fixed submission:
a,b = map(int,input().split())
print(a if a<=b else a-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    i = x.index(a)
    if i < (n-1)/2:
        print(right)
    else:
        print(left)

Fixed submission:
import math
n = int(input())
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    if a < right:
        print(right)
    else:
        print(left)
Buggy python submission (verdict: Runtime Error):
arr=[int(i) for i in input()]
csum=[arr[0]]
for i in range(1,len(arr)):
  csum.append(csum[-1]+arr[i])
maxsum= csum[-1]

print(max(maxsum,arr[0]-1+9*(len(are)-1)))

Fixed submission:
arr=[int(i) for i in input()]
csum=[arr[0]]
for i in range(1,len(arr)):
  csum.append(csum[-1]+arr[i])
maxsum= csum[-1]

print(max(maxsum,arr[0]-1+9*(len(arr)-1)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
edge = [[None]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l,r,d = map(int,input().split())
    edge[l][r] = d
    edge[r][l] = -d
G = [None]*(N+1)
ok = True
stack = []
for x in range(1,N+1):
    if G[x] is not None: continue
    G[x] = 0
    stack = [x]
    while stack:
        v = stack.pop()
        for to in range(1,N+1):
            if edge[v][to] is None:
                continue
            d = edge[v][to]
            if G[to] is None:
                G[to] = G[v] + d
                stack.append(to)
            else:
                if G[to] != G[v] + d:
                    ok = False
                    break
    if ok == False:
        break
print('Yes' if ok else 'No')

Fixed submission:
N,M = map(int,input().split())
edge =[[] for _ in range(N+1)]
for _ in range(M):
    l,r,d = map(int,input().split())
    edge[l].append([r,d])
    edge[r].append([l,-d])
G = [None]*(N+1)
ok = True
stack = []
for x in range(1,N+1):
    if G[x] is not None: continue
    G[x] = 0
    stack = [x]
    while stack:
        v = stack.pop()
        for to,d in edge[v]:
            if G[to] is None:
                G[to] = G[v] + d
                stack.append(to)
            else:
                if G[to] != G[v] + d:
                    ok = False
                    break
    if ok == False:
        break
print('Yes' if ok else 'No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
csf = []
for i in range(n):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time < csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = (time-csf[j][1])%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')

Fixed submission:
n = int(input())
csf = []
for i in range(n-1):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time <= csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = -time%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')
Buggy python submission (verdict: Time Limit Exceeded):
n, K = map(int,input().split())
xarr = []
yarr = []
src = []
for _ in range(n):
    x, y = map(int,input().split())
    src.append([x,y])
    xarr.append(x)
    yarr.append(y)

xarr.sort()
yarr.sort()
ans = float('inf')
for i in range(n):
    for j in range(i + 1, n):
        for k in range(n):
            for l in range(k + 1, n):
                cnt = 0
                for m in range(n):
                    if src[m][0] >= xarr[i] and src[m][0] <= xarr[j] and src[m][1] >= yarr[k] and src[m][1] <= yarr[l]:
                        cnt += 1
                if cnt >= K:
                    ans = min((xarr[i]-xarr[j])*(yarr[k]-yarr[l]), ans)

print(ans)

Fixed submission:
n, K = map(int,input().split())
xarr = []
yarr = []
src = []
for _ in range(n):
    x, y = map(int,input().split())
    src.append([x,y])
    xarr.append(x)
    yarr.append(y)

xarr.sort()
yarr.sort()
ans = float('inf')
for i in range(n):
    for j in range(i + 1, n):
        for k in range(n):
            for l in range(k + 1, n):
                cnt = 0
                for m in range(n):
                    if src[m][0] >= xarr[i] and src[m][0] <= xarr[j] and src[m][1] >= yarr[k] and src[m][1] <= yarr[l]:
                        cnt += 1
                if cnt >= K:
                    ans = min((xarr[i]-xarr[j])*(yarr[k]-yarr[l]), ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
class BinPartite:
    def __init__(self, N, es):
        self.colors = [0 for i in range(N)]
        self.es = es

    def dfs(self, v, color):
        self.colors[v] = color
        for to in self.es[v]:
            if self.colors[to] == color:
                return False
            if self.colors[to] == 0 and not self.dfs(to, -color):
                return False
        return True

    def color_cnt(self, color):
        return self.colors.count(color)

    def is_bipartite(self):
        return self.dfs(0, 1)


N, M = map(int, input().split())
e_list = [[] for i in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    e_list[a].append(b)
    e_list[b].append(a)

Bp = BinPartite(N, e_list)
if Bp.is_bipartite():
    b = Bp.color_cnt(1)
    w = Bp.color_cnt(-1)
    print(b*w-M)
else:
    print(N*(N-1)//2 - M)


Fixed submission:
N,M = map(int,input().split())
e_list = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1, input().split())
    e_list[a].append(b)
    e_list[b].append(a)
bin_or_not = True
ans = (N-1)*N//2 - M
w_or_b = [-1]*N
stack = [0]
w_or_b[0] = 0
while stack:
    x = stack.pop()
    for i in e_list[x]:
        if w_or_b[i] >= 0:
            bin_or_not = w_or_b[x]^w_or_b[i]
        else:
            w_or_b[i] = (w_or_b[x] + 1)%2
            stack.append(i)
        if not bin_or_not:
            break
    if not bin_or_not:
        break
if bin_or_not:
    w =  w_or_b.count(0)
    b = w_or_b.count(1)
    ans = w*b - M
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d,e,f = map(int,input().split())

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [100*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

print(sum(maxs),maxs[1])



Fixed submission:
a,b,c,d,e,f = map(int,input().split())

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [100*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

print(sum(maxs),maxs[1])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int,input().split())

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = []
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

print(sum(maxs),maxs[1])

Fixed submission:
a,b,c,d,e,f = map(int,input().split())

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [100*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

print(sum(maxs),maxs[1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
edge = []
for _ in range(n-1):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,c])
q, k = map(int,input().split())
querry = []
for _ in range(q):
    x,y = map(int,input().split())
    querry.append([x-1,y-1])
    

class Graph():
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[0]*n for _ in range(n)]
        self.edge = edge
        self.ed_list = [[] for _ in range(n)]
        for a,b,c in edge:
            self.ed_list[a].append([b,c])
            self.ed_list[b].append([a,c])
    
    def dijkstra(self,start):
        INF = float('inf')
        cost = [INF]*self.n
        cost[start] = 0
        from heapq import heappop,heappush
        stack = [[0, start]]
        while stack:
            c, x = heappop(stack)
            for to,j in self.ed_list[x]:
                if cost[to] > j + c:
                    cost[to] = j + c
                    heappush(stack,[j + c, to])
        return cost

gp = Graph(n,edge)
cost = gp.dijkstra(k-1)
for i,j in querry:
    print(cost[i] + cost[j])



Fixed submission:
n = int(input())
edge = [list(map(int,input().split())) for _ in range(n-1)]
q, k = map(int,input().split())
querry = [list(map(int,input().split())) for _ in range(q)]
INF = float('inf')
from heapq import heappush,heappop
def dijkstra(n,edge,start):
    ed_list = [[] for _ in range(n)]
    for a,b,c in edge:
        ed_list[a-1].append([b-1,c])
        ed_list[b-1].append([a-1,c])
    cost = [INF]*n
    cost[start] = 0
    stack =[[0,start]]
    while stack:
        c, x = heappop(stack)
        for i,j in ed_list[x]:
            if cost[i] > c + j:
                cost[i] = c + j
                heappush(stack,[c + j, i])
    return cost
arr_cost = dijkstra(n,edge,k-1)
for i,j in querry:
    print(arr_cost[i-1] + arr_cost[j-1])
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n = int(input())
arr = []
ans = 0
for i in range(n):
    arr.append([i] + list(map(int,input().split())))
x_sort = sorted(arr, key = lambda x:x[1])
y_sort = sorted(arr, key = lambda x:x[2])

import heapq as hq

q = []

for i in range(n-1):
    costx = x_sort[i+1][1] - x_sort[i][1]
    costy = y_sort[i+1][2] - y_sort[i][2]
    hq.heappush(q, [costx, x_sort[i][0], x_sort[i+1][0] ])
    hq.heappush(q, [costy, y_sort[i][0], y_sort[i+1][0] ])

uf = UnionFind(n)
for rep in range(3*10**5):
    cost, a, b = hq.heappop(q)
    if uf.isSameGroup(a, b):
        continue
    else:
        uf.Unite(a, b)
        ans += cost
    if uf.Count(0) == n:
        break
print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n = int(input())
arr = []
ans = 0
for i in range(n):
    arr.append([i] + list(map(int,input().split())))
x_sort = sorted(arr, key = lambda x:x[1])
y_sort = sorted(arr, key = lambda x:x[2])

import heapq as hq

q = []

for i in range(n-1):
    costx = x_sort[i+1][1] - x_sort[i][1]
    costy = y_sort[i+1][2] - y_sort[i][2]
    hq.heappush(q, [costx, x_sort[i][0], x_sort[i+1][0] ])
    hq.heappush(q, [costy, y_sort[i][0], y_sort[i+1][0] ])

uf = UnionFind(n)
for rep in range(3*10**5):
    cost, a, b = hq.heappop(q)
    if uf.isSameGroup(a, b):
        continue
    else:
        uf.Unite(a, b)
        ans += cost
    if uf.Count(0) == n:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if ok== False:
            break
        if b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if b[2*i-1] != 2:
            ok = False

if ok :
    print(2**(N//2)%(10**9+7))
else:
    print(0)

Fixed submission:
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if ok== False:
            break
        if 2*i not in b or b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if 2*i-1 not in b or b[2*i-1] != 2:
            ok = False
            break

if ok :
    print(2**(N//2)%(10**9+7))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if b[2*i-1] != 2:
            ok = False

if ok :
    print(2**(N//2))
else:
    print(0)

Fixed submission:
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if ok== False:
            break
        if 2*i not in b or b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if 2*i-1 not in b or b[2*i-1] != 2:
            ok = False
            break

if ok :
    print(2**(N//2)%(10**9+7))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N,A = map(int,input().split())
x = [0] + list(map(int,input().split()))
X = max(x)
dp = [[[0]*(N*X+1) for k in range(N+1)] for j in range(N+1)]

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*X+1):
            if j == 0 and k == 0 and s == 0 :
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

Fixed submission:
N,A = map(int,input().split())
x = [0] + list(map(int,input().split()))
X = max(x[1:])
y = [0] + list((i-A) for i in x[1:] )
dp = [[0]*(2*N*X+1) for _ in range(N+1)]

for j in range(N+1):
    for t in range(2*N*X+1):
        if j == 0 and t == N*X:
            dp[j][t] = 1
        elif j >= 1 and (t-y[j] < 0 or t - y[j] > 2*N*X):
            dp[j][t] = dp[j-1][t]
        elif j >= 1 and (t-y[j] >= 0 and t-y[j] <= 2*N*X):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j]]
        else:
            dp[j][t] = 0
print(dp[N][N*X]-1)
Buggy python submission (verdict: Runtime Error):
s=sorted(input())
print(YES if s == '557' else NO)

Fixed submission:
s=sorted(list(map(int,input().split())))
print('YES' if s == [5,5,7] else 'NO')