ZhenlongDai/ACPR huggingface dataset:
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n, k = map(int, input().split())
list_a = list(map(int, input().split()))

count = collections.Counter(list_a)
sort_c = sorted(count.items(), key=lambda x:x[1])
num_kind = len(sort_c)

result = 0
for i in range(num_kind - k):
  result += sort_c[i][1]


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:

Fixed submission (verdict: Accepted):
import collections
n, k = map(int, input().split())
list_a = list(map(int, input().split()))

count = collections.Counter(list_a)
sort_c = sorted(count.items(), key=lambda x:x[1])
num_kind = len(sort_c)

result = 0
for i in range(num_kind - k):
  result += sort_c[i][1]
print(result)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
nums = {}
for a in A:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1
sorted_nums = list(sorted(nums.items(), key=lambda x: x[1]))
nums_len = len(sorted_nums)
ans = 0
if nums_len > K:
    for i in range(nums_len - K):
        ans += sorted_nums[i][1]
        print(i, sorted_nums[i][0], sorted_nums[i][1])
print(ans)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0 5 1
1


Fixed submission (verdict: Accepted):
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
nums = {}
for a in A:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1
sorted_nums = list(sorted(nums.items(), key=lambda x: x[1]))
nums_len = len(sorted_nums)
ans = 0
if nums_len > K:
    for i in range(nums_len - K):
        ans += sorted_nums[i][1]
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

lenght = len(set(A))-K
if lenght<0:print(0)
else:print(len(Counter(A).most_common()[::-1][lenght:]))




Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


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

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

lenght = len(set(A))-K
ans = 0
if lenght<=0:print(ans), exit()
else:
    for k, v in Counter(A).most_common()[::-1][:lenght]:
        ans += v
print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections


def calc(A, K):
    dist = {}
    tmp = collections.Counter(A)
    type_ = len(tmp)

    if type_ <= K:
        return 0

    for a, count in tmp.items():
        if count not in dist.keys():
            dist[count] = [a]
        else:
            dist[count].append(a)

    rewrite = 0
    print(dist)
    for i, c in enumerate(sorted(dist.keys()), 1):
        for _ in dist[c]:
            rewrite += c
            if i == type_ - K:
                return rewrite


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = calc(A, K)
    print(ans)


if __name__ == "__main__":
    main()

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
{2: [1, 2], 1: [5]}
1


Fixed submission (verdict: Accepted):
import collections


def calc(A, K):
    dist = {}
    tmp = collections.Counter(A)
    type_ = len(tmp)

    if type_ <= K:
        return 0

    for a, count in tmp.items():
        if count not in dist.keys():
            dist[count] = [a]
        else:
            dist[count].append(a)

    rewrite = 0
    i = 0
    for c in sorted(dist.keys()):
        for _ in dist[c]:
            i += 1
            rewrite += c
            if i == type_ - K:
                return rewrite


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = calc(A, K)
    print(ans)


if __name__ == "__main__":
    main()

Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())
print(A)

print(sum(sorted(A.values(), reverse=True)[K:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
Counter({'1': 2, '2': 2, '5': 1})
1


Fixed submission (verdict: Accepted):
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())

print(sum(sorted(A.values(), reverse=True)[K:]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n, k = map(int, input().split())
list = input().split()
c_list = collections.Counter(list)
sorted_c_list = sorted(c_list.values(),reverse=True)
print(sorted_c_list[k:])

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1]


Fixed submission (verdict: Accepted):
import collections
n, k = map(int, input().split())
list = input().split()
c_list = collections.Counter(list)
sorted_c_list = sorted(c_list.values(),reverse=True)
print(sum(sorted_c_list[k:]))
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
A=list(map(int,input().split()))
d={}
for a in A:
    if a in d:
        d[a]+=1
    else:
        d[a]=1
D=sorted(d.items(), key=lambda x:x[0], reverse=True)
if len(set(A))>k:
    for i in range(k):
        n-=D[i][1]
    print(n)
else:
    print(0)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
A=list(map(int,input().split()))
d={}
for a in A:
    if a in d:
        d[a]+=1
    else:
        d[a]=1
D=sorted(d.items(), key=lambda x:x[1], reverse=True)
if len(set(A))>k:
    for i in range(k):
        n-=D[i][1]
    print(n)
else:
    print(0)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n, k = map(int, input().split())
c = sum(map(lambda x: x[1], Counter(input().split()).most_common(k)))
print(k - c)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
-2


Fixed submission (verdict: Accepted):
from collections import Counter
n, k = map(int, input().split())
c = sum(map(lambda x: x[1], Counter(input().split()).most_common(k)))
print(n - c)

Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,K=map(int,input().split())
A={}
for i in input().split():
  A[i]=A.get(i,0)+1
A=sorted(A.values())
print(A)
print(sum(A[0:len(A)-K]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]
1


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
A={}
for i in input().split():
  A[i]=A.get(i,0)+1
A=sorted(A.values())
print(sum(A[0:len(A)-K]))

Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
C = collections.Counter(A)
C = sorted(C.values())

lenght = len(C)
print(lenght, K, C)
print(sum(C[:(lenght-K)]))


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3 2 [1, 2, 2]
1


Fixed submission (verdict: Accepted):

import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
C = collections.Counter(A)
C = sorted(C.values())

lenght = len(C)

print(sum(C[:(lenght-K)]))
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import os
import sys

n,k = map(int, input().split())
a = [x for x in map(int, input().split())]

d = {}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1

sorted(d.items(), key=lambda x: x[1])

if(len(d) <= k):
    print(0)
    exit(0)

tmp = len(d)
ans = 0

for i in d.keys():
    tmp-=1
    ans += d[i]
    if(tmp==k):
        break

print(ans)
exit(0)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
import os
import sys

n,k = map(int, input().split())
a = [x for x in map(int, input().split())]

d = {}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1

s_d = sorted(d.items(), key=lambda x: x[1])

if(len(d) <= k):
    print(0)
    exit(0)

tmp = len(d)
ans = 0


for _,v in s_d:
    tmp-=1
    ans += v
    if(tmp==k):
        break

print(ans)
exit(0)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N,K=map(int,input().split())
AS=[int(x) for x in input().split()]
nc=Counter(AS)
nckeys=len(nc)
sa=nckeys-K
if sa>0:
    ndch=[x[1] for x in nc.most_common(sa)]
    hw=sum(ndch)
else:
    hw=0
print(hw)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter
N,K=map(int,input().split())
AS=[int(x) for x in input().split()]
nc=Counter(AS)
nckeys=len(nc)
sa=nckeys-K
if sa>0:
    ndch=[x[1] for x in nc.most_common()]
    ndch=sorted(ndch)[:sa]
    hw=sum(ndch)
else:
    hw=0
print(hw)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

def make_group(list):
    list.sort()
    group = []
    g_count = 0
    prev = list[0]
    for i in range(N):
        current = list[i]
        if prev != current:
            group.append(g_count)
            g_count = 0
        g_count += 1
        prev = current
        if i == N - 1:
            group.append(g_count)
    return sorted(group)

def calc_moving_count(group):
    group_length = len(group)
    length = max(group_length - K, 0)
    should_move_group = group[:length]
    count = sum(should_move_group)
    return count

def main():
    group = make_group(A)
    print(group)
    count = calc_moving_count(group)
    print(count)

if __name__  == '__main__':
    main()

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]
1


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

def make_group(list):
    list.sort()
    group = []
    g_count = 0
    prev = list[0]
    for i in range(N):
        current = list[i]
        if prev != current:
            group.append(g_count)
            g_count = 0
        g_count += 1
        prev = current
        if i == N - 1:
            group.append(g_count)
    return sorted(group)

def calc_moving_count(group):
    group_length = len(group)
    length = max(group_length - K, 0)
    should_move_group = group[:length]
    count = sum(should_move_group)
    return count

def main():
    group = make_group(A)
    count = calc_moving_count(group)
    print(count)

if __name__  == '__main__':
    main()

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
d = {}
for i in input().split():
  if i in d:
    d[i] = d[i] + 1 
  else:
    d[i] = 1

l = sorted(d.values())
print(l[:len(l) - k])

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1]


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
d = {}
for i in input().split():
  if i in d:
    d[i] = d[i] + 1 
  else:
    d[i] = 1

l = sorted(d.values())
print(sum(l[:len(l) - k]))
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



import sys
from collections import Counter


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

N, K = MI()
A = LI()
A = sorted(Counter(A).values(), reverse = True)
sum = A[K:]
print(sum)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1]


Fixed submission (verdict: Accepted):



import sys
from collections import Counter


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

N, K = MI()
A = LI()
A = sorted(Counter(A).values(), reverse = True)
sum = sum(A[K:])
print(sum)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
A=list(map(int,input().strip().split(" ")))
dict={}

for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

X=[]
sorted_A = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for i,v in sorted_A:
    X.append(v)

print(X)
ans=0
if len(X)>k:
    for i in X[k:]:
        ans+=i
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[2, 2, 1]
1


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
A=list(map(int,input().strip().split(" ")))
dict={}

for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

X=[]
sorted_A = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for i,v in sorted_A:
    X.append(v)

ans=0
if len(X)>k:
    for i in X[k:]:
        ans+=i
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
ans=0
keys,counts=zip(*a.most_common())
for num,(key,count) in enumerate(zip(keys,counts)):
    if int(num)>k:ans+=count
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
ans=0
keys,counts=zip(*a.most_common())
for num,(key,count) in enumerate(zip(keys,counts)):
    if int(num)>k-1:ans+=count
print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  a.sort()
  count = [a.count(i) for i in range(n) if a.count(i)>0]
  count.sort()
  if(len(count)<=k):
    print(0)
    return
  print(sum(count[:len(count)-k]))
  return

solve()
  
  

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  c = list(collections.Counter(a).values())
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,n=map(int,input().split())
a = list(map(int,input().split()))
a=sorted(a)
d=[]
cnt=1
for i in range(k-1):
  if a[i]==a[i+1]:
    cnt+=1
  else:
    d.append(cnt)
    cnt=0
d.append(cnt)
d=sorted(d)
ans=0
for i in range(len(d)-n):
  ans+=d[i]
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
k,n=map(int,input().split())
a = list(map(int,input().split()))
a=sorted(a)
d=[]
cnt=1
for i in range(k-1):
  if a[i]==a[i+1]:
    cnt+=1
  else:
    d.append(cnt)
    cnt=1
d.append(cnt)
d=sorted(d)
ans=0
for i in range(len(d)-n):
  ans+=d[i]
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

counter = Counter(a_list).most_common()[::-1]

print(counter)
count = 0
for i in range(max((len(counter) - k), 0)):
    count += counter[i][1]

print(count)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[(5, 1), (2, 2), (1, 2)]
1


Fixed submission (verdict: Accepted):
from collections import Counter
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

counter = Counter(a_list).most_common()[::-1]

count = 0
for i in range(max((len(counter) - k), 0)):
    count += counter[i][1]

print(count)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n, k = map(int, input().split())
a = list(map(int, input().split()))
if len(set(a)) <= k:
    print(0)
else:
    b = Counter(a)
    t = len(set(a)) - k
    c = b.most_common()[:-t-1:-1]
    d = 0
    for e in c:
        d = d + e[1]

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
if len(set(a)) <= k:
    print(0)
else:
    b = Counter(a)
    t = len(set(a)) - k
    c = b.most_common()[:-t-1:-1]
    d = 0
    for e in c:
        d = d + e[1]
    print(d)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
A_list = list(map(int,input().split()))
counter = [0]*(N+1) 
for i in A_list:
    counter[i] += 1
print(counter)
zeronashi = [i for i in counter if i != 0]
zeronashi.sort()
length = len(zeronashi)
x = length - K
y = 0
if x < 1:
    print(0)
else:
    for i in range(x):
        y += zeronashi[i]
    print(y)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[0, 2, 2, 0, 0, 1]
1


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
A_list = list(map(int,input().split()))
counter = [0]*(N+1)

for i in A_list:
    counter[i] += 1

zeronashi = [i for i in counter if i != 0]
zeronashi.sort()

length = len(zeronashi)
x = length - K
y = 0
if x < 1:
    print(0)
else:
    for i in range(x):
        y += zeronashi[i]
    print(y)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
ans=0
keys,counts=zip(*a.most_common())
for num,(key,count) in enumerate(zip(keys,counts)):
    print(num,key,count)
    if int(num)>k-1:ans+=count
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0 1 2
1 2 2
2 5 1
1


Fixed submission (verdict: Accepted):
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
ans=0
keys,counts=zip(*a.most_common())
for num,(key,count) in enumerate(zip(keys,counts)):
    if int(num)>k-1:ans+=count
print(ans)
Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()

mod = 10 ** 9 + 7
lst=[1]
prep=1
for i in range(k,n):
  tmp=prep*i
  tmp%=mod
  lst.append(tmp)
  prep=tmp
lst.reverse()

res=0
for i,j,k in zip(lst,alst[:n-k+1],alst[:k-n-2:-1]):
  res+=i*(k-j)%mod
  res%=mod
print(res)

Failing test case input:
6 2
10 4 10 -9 -3 -1

Expected output:
139


Actual output:
2599


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=prep*(i+k)*pow(i+1,mod-2,mod)
  prep%=mod

print(res)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
MOD = 10**9 + 7
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
b = sorted(a, reverse=True)
s = [1]
for i in range(1,n+1):
    s.append(s[i-1]*i%MOD)
print(s)
min = 0
max = 0
for i in range(n):
    if n-i >= k >= i:
        tmp = s[n - i-1] 
        
        min += a[i]*tmp%MOD
        max += b[i]*tmp%MOD
print((max - min)%MOD)

Failing test case input:
6 4
23 4 8 -3 -3 -1

Expected output:
309


Actual output:
[1, 1, 2, 6, 24, 120, 720]
3414


Fixed submission (verdict: Accepted):
MOD = 10 ** 9 + 7

n, k = map(int, input().split())

a = sorted(list(map(int, input().split())))

b = sorted(a, reverse=True)
s = [1]
r = [1]
for i in range(1, n + 1):
    s.append(s[i - 1] * i % MOD)
    r.append(pow(s[i], MOD-2, MOD))
min = 0
max = 0
for i in range(n-k+1):
    tmp = (s[n - i - 1] * r[k-1] * r[n - k - i])%MOD
    min += a[i] * tmp % MOD
    max += b[i] * tmp % MOD
    min %= MOD
    max %= MOD
print((max - min) % MOD)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=(prep%mod)*(i+k)

print(res)


Failing test case input:
6 4
10 10 10 -18 -14 -13

Expected output:
399


Actual output:
679


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=prep*(i+k)*pow(i+1,mod-2,mod)
  prep%=mod

print(res)
Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()

mod = 10 ** 9 + 7
lst=[1]
prep=1
for i in range(k,n):
  tmp=prep*i
  tmp%=mod
  lst.append(tmp)
  prep=tmp
lst.reverse()

res=0
for i,j,k in zip(lst,alst[:n-k+1],alst[:k-n-2:-1]):
  res+=i*(k-j)
  res%=mod
print(res)

Failing test case input:
6 2
23 4 6 -3 -3 -2

Expected output:
163


Actual output:
3351


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=prep*(i+k)*pow(i+1,mod-2,mod)
  prep%=mod

print(res)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()

mod = 10 ** 9 + 7
lst=[1]
prep=1
for i in range(k,n):
  tmp=prep*i
  lst.append(tmp)
  prep=tmp
lst.reverse()
print(lst)
res=0
for i,j,k in zip(lst,alst[:n-k+1],alst[:k-n-2:-1]):
  res+=i*(k-j)
  res%=mod
print(res)

Failing test case input:
3 1
1 1 2

Expected output:
0


Actual output:
[2, 1, 1]
1


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=prep*(i+k)*pow(i+1,mod-2,mod)
  prep%=mod

print(res)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
MOD = 10**9 + 7
n,k,*a=map(int,open(0).read().split())
a.sort()
comb = 1
ans = 0
for i in range(k,n+1):
    ans += (a[i-1] - a[-i]) * comb
    comb = comb * i 
    ans,comb = ans%MOD, comb%MOD
print(ans)

Failing test case input:
6 4
10 10 10 -10 -10 0

Expected output:
290


Actual output:
490


Fixed submission (verdict: Accepted):
MOD = 10**9 + 7
n,k,*a=map(int,open(0).read().split())
a.sort()
comb = 1
ans = 0
for i in range(k,n+1):
    ans += (a[i-1] - a[-i]) *comb 
    comb = comb * i * pow(i-k+1,MOD-2,MOD) % MOD
    ans = ans%MOD
print(ans)
Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep*=i+k
  prep
  prep%=mod

print(res)


Failing test case input:
6 2
20 1 10 -31 -27 -13

Expected output:
380


Actual output:
7027


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k,*alst = map(int,read().split())
alst.sort()
lst1=alst[k-1:]
lst2=alst[n-k::-1]
mod = 10 ** 9 + 7
res=0
prep=1
for i in range(n-k+1):
  res+=prep*(lst1[i]-lst2[i])
  res%=mod
  prep=prep*(i+k)*pow(i+1,mod-2,mod)
  prep%=mod

print(res)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
a.sort()
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = ((i + 1) * b) 
    b %= mod
print(ans)

Failing test case input:
6 2
10 4 10 -14 -5 -1

Expected output:
170


Actual output:
3245


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
a.sort()
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = (i + 1) * b
    c = i + 1 - (k - 1)
    b = pow(c, mod - 2, mod) * b % mod
print(ans)

Problem: p02804
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
p=10**9+7

def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
def com(n,r):
    return f[n]
ans=0
for i in range(n-k+1):
    ans=ans+(a[-i-1]-a[i])*com(n-i-1,k-1)
print(ans%p)

Failing test case input:
6 3
3 10 10 -10 -18 -10

Expected output:
426


Actual output:
3892


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
p=10**9+7

def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
g=[]
for i in range(n+1):
    g.append(pow(f[i],-1,p))
def com(n,r):
    return f[n]*g[r]*g[n-r]
ans=0
for i in range(n-k+1):
    ans=ans+(a[-i-1]-a[i])*com(n-i-1,k-1)
print(ans%p)
Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
MOD=10**9+7
comb=[0]*(N)
comb[K-1]=1
ans=0
for i in range(K,N):
    comb[i]=comb[i-1]*i
for i in range(N-K+1):
    ans=ans+comb[N-1-i]*(A[N-1-i]-A[i])
    ans%=MOD
print(ans)

Failing test case input:
10 5
1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0

Expected output:
999998257


Actual output:
999880699


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
MOD=10**9+7
fan=[1]*(N+1)
for i in range(2,N+1):
    fan[i]=fan[i-1]*(i)%MOD
ans=0
def comb(a,b):
    return fan[a]*pow(fan[b],MOD-2,MOD)*pow(fan[a-b],MOD-2,MOD)%MOD
for i in range(N-K+1):
    ans=ans+comb(N-i-1,K-1)*(A[N-1-i]-A[i])
    ans%=MOD
print(ans)

Problem: p02804
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
comb = [1] * (N+1)
for i in range(K-1, N):
    comb[i+1] = comb[i] * (i+1) 
A.sort()
mi = sum(a*comb[i]%mod for a, i in zip(reversed(A[:N-K+1]), range(K-1, N)))
ma = sum(a*comb[i]%mod for a, i in zip((A[K-1:]), range(K-1, N)))

print((ma-mi)%mod)

Failing test case input:
6 4
5 6 16 -15 -3 0

Expected output:
351


Actual output:
661


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
comb = [0] * (N+1)
comb[K-1] = 1
for i in range(K-1, N):
    comb[i+1] = comb[i] * (i+1) * pow(i-K+2, -1, mod) % mod

A.sort()
mi = sum(a*comb[i]%mod for a, i in zip(reversed(A[:N-K+1]), range(K-1, N)))
ma = sum(a*comb[i]%mod for a, i in zip((A[K-1:]), range(K-1, N)))

print((ma-mi)%mod)

Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
MOD = 10**9 + 7
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
b = sorted(a, reverse=True)
s = [1]
for i in range(1,n+1):
    s.append(s[i-1]*i%MOD)
min = 0
max = 0
for i in range(n):
    if n-i >= k >= i:
        tmp = s[n - i-1] 
        
        min += a[i]*tmp%MOD
        max += b[i]*tmp%MOD
print((max - min)%MOD)


Failing test case input:
6 4
4 10 10 -10 -10 0

Expected output:
284


Actual output:
2904


Fixed submission (verdict: Accepted):
MOD = 10 ** 9 + 7

n, k = map(int, input().split())

a = sorted(list(map(int, input().split())))

b = sorted(a, reverse=True)
s = [1]
r = [1]
for i in range(1, n + 1):
    s.append(s[i - 1] * i % MOD)
    r.append(pow(s[i], MOD-2, MOD))
min = 0
max = 0
for i in range(n-k+1):
    tmp = (s[n - i - 1] * r[k-1] * r[n - k - i])%MOD
    min += a[i] * tmp % MOD
    max += b[i] * tmp % MOD
    min %= MOD
    max %= MOD
print((max - min) % MOD)
Problem: p02804
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10**9 + 7

total = 0

f = [1, 1]

for i in range(2, n):
    f.append(f[i-1] * i % mod)

for i in range(n - k + 1):
    p = n - i - 1
    q = k - 1

    c = f[p] 

    total += c * (a[-1-i] - a[i])

print(total % mod)


Failing test case input:
6 4
5 6 16 -15 -3 0

Expected output:
351


Actual output:
3966


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10**9 + 7

f = [1, 1]
for i in range(2, n):
    f.append((f[i-1] * i) % mod)

total = 0
for i in range(n - k + 1):
    p = n - i - 1
    q = k - 1

    c = f[p] * pow(f[p-q], mod-2, mod) * pow(f[q], mod-2, mod) % mod
    total += c * (a[-1-i] - a[i])
    total = total % mod

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

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
cnt = 0
ans = 0
for k, v in d.items():
    if v != 1:
        cnt += v - 1
    ans += 1

if cnt == 0:
    print(ans - 2)
elif cnt == 1:
    print(ans - 1)
elif cnt % 2 == 0:
    print(ans)
else:
    print(ans - 1)

Failing test case input:
5
2 -1 -6 25 27

Expected output:
5


Actual output:
3


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

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
cnt = 0
ans = 0
for k, v in d.items():
    if v != 1:
        cnt += v - 1
    ans += 1

if cnt == 0:
    print(ans)
elif cnt == 1:
    print(ans - 1)
elif cnt % 2 == 0:
    print(ans)
else:
    print(ans - 1)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
A = [int(s) for s in input().split()]
c = Counter(A)
b = [(v, n) for v, n in c.items() if n > 1]
b.sort()
ans = len(c)
if len(b) % 2 and all([n < 3 for v, n in b[1:-1]]):
    ans -= 1
print(ans)


Failing test case input:
15
1 12 6 0 1 2 2 0 8 6 2 6 21 1 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
A = [int(s) for s in input().split()]
c = Counter(A)
b = [n - 1 for v, n in c.items() if n > 1]
ans = len(c) - sum(b) % 2
print(ans)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 == 0:
    print(s)
else:
    print(s-1)

Failing test case input:
5
2 -1 -6 16 27

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 != 0:
    print(s)
else:
    print(s-1)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from collections import Counter

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

C = Counter(A).most_common()


double = 0
for c in C:
	num, cnt = c
	if cnt % 3 == 2 or (cnt > 3 and cnt % 3 == 1):
		double += 1

if double % 2:
	print(len(C)-1)
else:
	print(len(C))

Failing test case input:
15
1 14 6 0 0 4 1 0 16 6 0 6 5 0 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
import sys
from collections import Counter

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

C = Counter(A).most_common()


double = 0
for c in C:
	num, cnt = c
	
	if cnt % 2 == 0:
		double += 1

if double % 2:
	print(len(C)-1)
else:
	print(len(C))
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
eq={}
for i in range(n-1):
  if a[i]==a[i-1]:
    if a[i] in eq:
      eq[a[i]]+=1
    else:
      eq[a[i]]=1
sousa=0
for i in eq.values():
  sousa+=i
if sousa%2==0:
  print(n-sousa)
else:
  print(n-sousa-1)

Failing test case input:
5
4 -2 0 4 1

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
a.sort()
eq={}
for i in range(n-1):
  if a[i]==a[i+1]:
    if a[i] in eq:
      eq[a[i]]+=1
    else:
      eq[a[i]]=1
sousa=0
for i in eq.values():
  sousa+=i
if sousa%2==0:
  print(n-sousa)
else:
  print(n-sousa-1)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
most = c.most_common()
ans = len(most)
eaten = 0
for t in most:
    if t[1] != 1:
        eaten += t[1]-1
if eaten%2 == 1:
    print(ans-2)
else:
    print(ans)

Failing test case input:
15
1 3 5 2 1 3 2 0 8 6 2 6 11 1 1

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):

import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
most = c.most_common()
ans = len(most)
eaten = 0
for t in most:
    if t[1] != 1:
        eaten += t[1]-1
if eaten%2 == 1:
    print(ans-1)
else:
    print(ans)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

_ = input()
an = sorted([int(i) for i in input().split(" ")])

c = collections.Counter(an)

tim = 0
for a in c:
    if c[1] % 2 == 0:
        tim += 1

print(len(c)-(tim+1)%2)

Failing test case input:
5
1 2 0 9 18

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
import collections

_ = input()
an = sorted([int(i) for i in input().split(" ")])

c = collections.Counter(an)

print(len(c)-(len(c)+1)%2)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

A = list(map(int, input().split()))
if len(A)-len(set(A))%2==1:
  print(len(set(A))-1)
else:
  print(len(set(A)))

Failing test case input:
5
2 -2 -2 1 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())

A = list(map(int, input().split()))
if len(A)==3:
  print(1)
elif (len(A)-len(set(A)))%2==1:
  print(len(set(A))-1)
else:
  print(len(set(A)))
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
d = {}
X =[]
for i in range(N):
    x = A[i]
    if x not in d:
        d[x] = 1
        X.append(x)
    else:
        d[x] += 1
ans = 0
for x in X:
    a = d[x]
    if a%2 == 0:
        ans += a
    else:
        ans += a
        X.remove(x)
n = len(X)
ans += (n+1)
print(ans)

Failing test case input:
5
8 -2 0 1 2

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
from collections import deque
d = {}
X = deque()
for i in range(N):
    x = A[i]
    if x not in d:
        d[x] = 1
        X.appendleft(x)
    else:
        d[x] += 1
ans = 0
from collections import deque
Y=deque()
while X:
    x = X.popleft()
    a = d[x]
    if a%2 == 0:
        ans += a-2
        Y.appendleft(x)
    else:
        ans += a-1

n = len(Y)
ans += ((n+1)
print(N-ans)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-y-y%2)


Failing test case input:
5
2 -1 -9 5 16

Expected output:
5


Actual output:
-1


Fixed submission (verdict: Accepted):
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-(x-y)-(x-y)%2)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
ans += abs(now)
print(N-ans)

Failing test case input:
15
1 14 6 0 0 4 1 -2 11 6 0 6 5 1 3

Expected output:
9


Actual output:
7


Fixed submission (verdict: Accepted):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b == 0:
    pass
elif b%2 == 1:
    ans += 1
else:
    pass
print( max(N-ans,0))

Problem: p03816
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print(len(b) if len(b)%2==0 else len(b)-1)

Failing test case input:
15
1 1 9 -1 0 12 1 -1 1 11 -1 2 13 2 3

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print(len(b) if len(b)%2!=0 else len(b)-1)
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):















N = int(input())
A = list(map(int, input().split()))
B = [-1 for i in range(100005)]

for i in range(N):
    if B[A[i]] == -1:
        B[A[i]] = 1
    elif B[A[i]] == 1:
        B[A[i]] = 2
    elif B[A[i]] == 2:
        B[A[i]] = 1

n = N - B.count(-1)

if B.count(2) % 2 == 0:
    print(n)
else:
    print(n-1)


Failing test case input:
15
1 3 6 1 1 2 2 0 8 6 2 6 11 1 1

Expected output:
7


Actual output:
-99983


Fixed submission (verdict: Accepted):















N = int(input())
A = list(map(int, input().split()))
B = [-1 for i in range(100005)]

for i in range(N):
    if B[A[i]] == -1:
        B[A[i]] = 1
    elif B[A[i]] == 1:
        B[A[i]] = 2
    elif B[A[i]] == 2:
        B[A[i]] = 1

n = len(B) - B.count(-1)

if B.count(2) % 2 == 0:
    print(n)
else:
    print(n-1)

Problem: p03816
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
N=int(input())
A=sorted(map(int,input().split()))
li=[]
i=0
while(i<N):
    cnt=0
    j=i
    while(j<N and A[i]==A[j]):
        cnt+=1
        j+=1
    li.append(cnt-1)
    i=j
l=len(li)
for i in range(l):
    for j in range(i+2,l):
        if li[i]==0:
            break
        d=min(li[i],li[j])
        li[i]-=d
        li[j]-=d
for i in range(l):
    li[i]%=2
ans=len(set(A))
for i in range(l):
    ans-=li[i]
print(ans)

Failing test case input:
15
0 -4 1 8 0 1 -1 -25 49 -3 -35 -2 -8 2 -9

Expected output:
13


Actual output:
11


Fixed submission (verdict: Accepted):
from collections import Counter
N=int(input())
A=sorted(map(int,input().split()))
li=[]
i=0
while(i<N):
    cnt=0
    j=i
    while(j<N and A[i]==A[j]):
        cnt+=1
        j+=1
    li.append(cnt-1)
    i=j
l=len(li)
for i in range(l):
    for j in range(i+1,l):
        if li[i]==0:
            break
        d=min(li[i],li[j])
        li[i]-=d
        li[j]-=d
for i in range(l):
    li[i]%=2
ans=len(set(A))
for i in range(l):
    ans-=li[i]
print(ans)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

A_set = set(A)

if len(A) - len(A_set) == 1:
    ans = len(A_set) -1
else:
    ans = len(A_set)

print(ans)

Failing test case input:
15
1 14 6 0 0 4 1 -2 11 6 0 10 5 1 3

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))

A_set = set(A)

if (len(A) - len(A_set)) % 2 == 0:
    ans = len(A_set)
else:
    ans = len(A_set) - 1

print(ans)
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
a_list = [int(i) for i in input().split()]

cnt = collections.Counter(a_list)

for key, num in cnt.items():
    print(cnt)
    if num == 2 or num == 1:
        pass
    
    elif num % 2 != 0 and num > 1:
        cnt[key] = 1
        
    
    elif num % 2 == 0 and num > 2:
        cnt[key] = 2
        
    else:
        pass
        

c = 0
result = 0
for key, num in cnt.items():
    if num == 2:
        c += 1

if c % 2 == 0:
    result = len(cnt)
else:
    result = len(cnt) - 1

print(result)




Failing test case input:
15
1 12 6 0 1 2 2 0 8 6 2 6 11 1 3

Expected output:
7


Actual output:
Counter({1: 3, 6: 3, 2: 3, 0: 2, 12: 1, 8: 1, 11: 1, 3: 1})
Counter({6: 3, 2: 3, 0: 2, 1: 1, 12: 1, 8: 1, 11: 1, 3: 1})
Counter({6: 3, 2: 3, 0: 2, 1: 1, 12: 1, 8: 1, 11: 1, 3: 1})
Counter({2: 3, 0: 2, 1: 1, 12: 1, 6: 1, 8: 1, 11: 1, 3: 1})
Counter({2: 3, 0: 2, 1: 1, 12: 1, 6: 1, 8: 1, 11: 1, 3: 1})
Counter({0: 2, 1: 1, 12: 1, 6: 1, 2: 1, 8: 1, 11: 1, 3: 1})
Counter({0: 2, 1: 1, 12: 1, 6: 1, 2: 1, 8: 1, 11: 1, 3: 1})
Counter({0: 2, 1: 1, 12: 1, 6: 1, 2: 1, 8: 1, 11: 1, 3: 1})
7


Fixed submission (verdict: Accepted):
import collections
n = int(input())
a_list = [int(i) for i in input().split()]

cnt = collections.Counter(a_list)
c = 0
for key, num in cnt.items():
    
    if num == 2 or num == 1:
        if num == 2:
            c += 1
        pass
    
    elif num % 2 != 0 and num > 1:
        cnt[key] = 1
        
    
    elif num % 2 == 0 and num > 2:
        c += 1
        cnt[key] = 2
        
    else:
        pass
        


result = 0




if c % 2 == 0:
    result = len(cnt)
else:
    result = len(cnt) - 1

print(result)

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
A = [int(s) for s in input().split()]
c = Counter(A)
n = [True if n > 1 else False for v, n in c.items()].count(True)
ans = len(c)
if n % 2 and all([n < 3 for n in c.values()]):
    ans -= 1
print(ans)


Failing test case input:
15
1 14 6 0 0 4 1 0 16 6 0 6 5 0 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
A = [int(s) for s in input().split()]
c = Counter(A)
b = [n - 1 for v, n in c.items() if n > 1]
ans = len(c) - sum(b) % 2
print(ans)

Problem: p03816
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
nums = [int(e) for e in input().split()]
checker = nums[0]
nums.sort()
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)

Failing test case input:
15
1 3 6 1 1 2 2 0 8 6 2 6 11 1 1

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
checker = nums[0]
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__=="__main__":
    n = int(input())
    As = list(map(int,input().split()))
    Non_dup_As = list(set(As))
    count = 0
    for a in Non_dup_As:
        count+=As.count(a)
    if(count % 2 == 0):
        print(len(As) - int(count/2))
    else:
        print(len(As) - int((count+1)/2))


Failing test case input:
5
3 -1 -2 1 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
if __name__=="__main__":
    n = int(input())
    As = list(map(int,input().split()))
    Non_dup_As = list(set(As))
    count = len(Non_dup_As)
    if(count % 2 == 0):
        print(count - 1)
    else:
        print(count)

Problem: p03816
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def comp(n,s,a):
  cnt=1
  flag=s[0]
  for i in range(1,n):
    if flag==s[i]:cnt+=1
    else:
      flag=s[i]
      a+=[cnt]
      cnt=1
  a+=[cnt]
  return a
n=int(input())
a=sorted(list(map(int,input().split())))
b=comp(n,a,[])
l,r=0,len(b)-1
if l==r:b[0]=1
while l<r:
  while b[l]==1 and l<r:l+=1
  while b[r]==1 and l<r:r-=1
  b[l]-=1
  b[r]-=1
while b[l]>1:b[l]-=2
print(sum(b))

Failing test case input:
5
2 -1 -6 5 19

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
def comp(n,s,a):
  cnt=1
  flag=s[0]
  for i in range(1,n):
    if flag==s[i]:cnt+=1
    else:
      flag=s[i]
      a+=[cnt]
      cnt=1
  a+=[cnt]
  return a
n=int(input())
a=sorted(list(map(int,input().split())))
b=comp(n,a,[])
l,r=0,len(b)-1
if l==r:b[0]=1
while l<r:
  while b[l]==1 and l<r:l+=1
  while b[r]==1 and l<r:r-=1
  if b[l]>1:
    b[l]-=1
    b[r]-=1
while b[l]>1:b[l]-=2
print(sum(b))

Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(2*y-x-y%2)


Failing test case input:
5
4 -2 -1 5 2

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-(x-y)-(x-y)%2)

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

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1

cnt = 0
ans = 0
for k, v in d.items():
    if v != 1:
        cnt += v
    ans += 1

if cnt % 2 == 0:
    print(ans - 1)
else:
    print(ans)

Failing test case input:
5
1 2 0 3 7

Expected output:
5


Actual output:
4


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

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
cnt = 0
ans = 0
for k, v in d.items():
    if v != 1:
        cnt += v - 1
    ans += 1

if cnt == 0:
    print(ans)
elif cnt == 1:
    print(ans - 1)
elif cnt % 2 == 0:
    print(ans)
else:
    print(ans - 1)
Problem: p03816
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
if n%2==0:
    print(len(l.keys()))
else:
    print(len(l.keys())-1)

Failing test case input:
5
1 2 0 3 7

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
import collections

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
kind = len(l.keys())
if (n-kind)%2==0:
    print(len(l.keys()))
else:
    print(len(l.keys())-1)

Problem: p03816
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter
from operator import itemgetter
N = int(input())
A = Counter(map(int, input().split()))
ans = 0
left = 0
for k, v in sorted(A.items(), key=itemgetter(1))[::-1]:
    
    if left == 1:
        if v == 1:
            ans += 1
            left = 0
            continue
        else:
            v -= 1
            ans += 1
            left = 0

    if v >= 3:
        v = v%2 + 2
    if v == 1:
        ans += 1
    elif v == 2:
        left += 1
    elif v == 3:
        ans += 1
if left == 1:
    ans -= 1
print(ans)


Failing test case input:
5
-4 -4 0 0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter
from operator import itemgetter
N = int(input())
A = Counter(map(int, input().split()))
ans = 0
left = 0
for k, v in sorted(A.items(), key=itemgetter(1))[::-1]:
    if left == 1:
        if v == 1:
            ans += 1
            left = 0
            continue
        else:
            v -= 1
            ans += 1
            left = 0
    if v > 3:
        v = v%2 + 2

    if v == 1:
        ans += 1
    elif v == 2:
        left += 1
    elif v == 3:
        ans += 1

print(ans)