Problem:


Score : 400 points

Problem Statement

Snuke has decided to play a game using cards.
He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.

He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.

Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.

Constraints

3 ≦ N ≦ 10^{5}

N is odd.

1 ≦ A_i ≦ 10^{5}

A_i is an integer.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 A_3 ... A_{N}

Output

Print the answer.

Sample Input 1

5
1 2 1 3 7

Sample Output 1

3

One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.

Sample Input 2

15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1

Sample Output 2

7



Sample input:
5
1 2 1 3 7


Sample output:
3

Submission status: Wrong Answer

Solution code:
import sys
import collections

import heapq
def input():
    return sys.stdin.readline()[:-1]

n=int(input())
a=list(map(int,input().split()))
tmp=collections.Counter(a)
b=list(tmp.values())
b=list(map(lambda  x:x*-1, b))
heapq.heapify(b)
ans=0
if len(b)==1:
    print(1)
    quit()

while 1:
    cnt1=heapq.heappop(b)*-1
    if cnt1==1:
        break
    cnt2=heapq.heappop(b)*-1
    if cnt2==1:
        ans+=cnt1*2-2
        break
    ans+=(cnt2-1)*2
    heapq.heappush(b,(cnt1-cnt2+1)*-1)
    heapq.heappush(b,-1)
print(n-ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections

import heapq
def input():
    return sys.stdin.readline()[:-1]

n=int(input())
a=list(map(int,input().split()))
tmp=collections.Counter(a)
b=list(tmp.values())
b=list(map(lambda  x:x*-1, b))
heapq.heapify(b)
ans=0
if len(b)==1:
    print(1)
    quit()

while 1:
    cnt1=heapq.heappop(b)*-1
    if cnt1==1:
        break
    cnt2=heapq.heappop(b)*-1
    if cnt2==1:
        ans+=cnt1*2-2
        break
    ans+=(cnt2-1)*2
    heapq.heappush(b,cnt1-cnt2+1)
    heapq.heappush(b,1)
print(n-ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections

import heapq
def input():
    return sys.stdin.readline()[:-1]

n=int(input())
a=list(map(int,input().split()))
tmp=collections.Counter(a)
b=list(tmp.values())
b=list(map(lambda  x:x*-1, b))
heapq.heapify(b)
ans=0
if len(b)==1:
    print(1)
    quit()

while 1:
    cnt1=heapq.heappop(b)*-1
    if cnt1==1:
        break
    cnt2=heapq.heappop(b)*-1
    if cnt2==1:
        ans+=cnt1*2-2
        break
    ans+=(cnt2-1)*2
    heapq.heappush(b,cnt1-cnt2-1)
    heapq.heappush(b,1)
print(n-ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections

import heapq
def input():
    return sys.stdin.readline()[:-1]

n=int(input())
a=list(map(int,input().split()))
tmp=collections.Counter(a)
b=list(tmp.values())
b=list(map(lambda  x:x*-1, b))
heapq.heapify(b)
ans=0
if len(b)==1:
    print(1)
    quit()
while 1:
    cnt1=heapq.heappop(b)
    if cnt1==-1:
        break
    cnt2=heapq.heappop(b)
    if cnt2==-1:
        ans+=cnt1*-2-2
        break
    ans+=max(cnt1,cnt2)*-2-2
    heapq.heappush(b,cnt1-max(cnt1,cnt2)-1)
    heapq.heappush(b,cnt2-max(cnt1,cnt2)-1)
print(n-ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print(len(b) if len(b)%2==0 else len(b)-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))

print (len(set(lst)))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
import collections
from operator import itemgetter

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
l_1 = []
ans = 0
for i in l.items():
    l_1.append(list(i))
l_1.sort(key=itemgetter(1), reverse=True)
# print(l_1)
i = 0
while True:
    k = 1
    # print(l_1)
    if i > len(l_1) - 1:
        break
    if l_1[i][1] == 1:
        i += 1
    elif l_1[i][1] >= 2:
        l_1[i][1] -= 1
        while True:
            if i + k <= len(l_1) - 1:
                if l_1[i + k][1] >= 2:
                    l_1[i + k][1] -= 1
                    ans += 2
                    break
                else:
                    k += 1
            else:
                ans += 2
                break
print(n - ans)

Submission status: Wrong Answer

Solution code:
import collections
from operator import itemgetter

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
l_1 = []
ans = 0
for i in l.items():
    l_1.append(list(i))
l_1.sort(key=itemgetter(1), reverse=True)
# print(l_1)
i = 0
for j in range(len(l_1)):
    k = 1
    # print(l_1)
    if l_1[i][1] == 1:
        i += 1
    elif l_1[i][1] >= 2:
        l_1[i][1] -= 1
        while True:
            if i + k <= len(l_1) - 1:
                if l_1[i + k][1] >= 2:
                    l_1[i + k][1] -= 1
                    ans += 2
                    break
                else:
                    k += 1
            else:
                ans += 2
                break
print(n-ans)

Submission status: Wrong Answer

Solution code:
import collections
from operator import itemgetter

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
l_1 = []
ans = 0
for i in l.items():
    l_1.append(list(i))
l_1.sort(key=itemgetter(1), reverse=True)
print(l_1)
i = 0
for j in range(len(l_1)):
    k = 1
    print(l_1)
    if l_1[i][1] == 1:
        i += 1
    elif l_1[i][1] >= 2:
        l_1[i][1] -= 1
        while True:
            if i + k <= len(l_1) - 1:
                if l_1[i + k][1] >= 2:
                    l_1[i + k][1] -= 1
                    ans += 2
                    break
                else:
                    k += 1
            else:
                ans += 2
                break
print(n-ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
N = int(input())
A = [int(_) for _ in input().split()]



ans = 0
for key, item in Counter(A).items():
    if item >= 2:
        ans += item

if ans == 0:
    print(len(A))
    sys.exit()

if ans % 2 == 1:
    print(len(Counter(A)))
else:
    print(len(Counter(A)) - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = [int(_) for _ in input().split()]

ans = 0
for key, item in Counter(A).items():
    if item >= 2:
        ans += item
if ans % 2 == 1:
    print(len(Counter(A)))
else:
    print(len(Counter(A)) - 1)

Submission status: Wrong Answer

Solution code:
N,*A=map(int,open(0).read().split());A.sort();d=0
for a,b in zip(A,A[1:]):
 if a==b:d+=1
print(N-d//2*2)

Submission status: Wrong Answer

Solution code:
N,*A=map(int,open(0).read().split());A.sort();d=0
for a,b in zip(A,A[1:]):
 if a==b:d-=1
print(N-d//-2*2)

Submission status: Wrong Answer

Solution code:
N,*A=map(int,open(0).read().split());A.sort();n=d=x=0;i,m=min(A),max(A)
for a,b in zip(A,A[1:]):
 if b==i:n+=1
 if a==m:x+=1
 if a==b:d-=1
print(N-max(n,d//-2,x)*2)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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
eat=(sousa+1)//2
print(n-eat*2)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = sorted(list(map(int, input().split())))
V = list(collections.Counter(A).values())
VV = []
for v in V:
    if v % 2 == 0:
        VV.append(2)
    else:
        VV.append(1)
VV.reverse()
for _ in range(len(VV) - 3):
    v1 = VV.pop()
    v2 = VV.pop()
    v3 = VV.pop()
    if v1 == 2 and v2 == 1 and v3 == 1:
        VV.append(1)
        VV.append(1)
    elif v1 == 2 and v2 == 1 and v3 == 2:
        VV.append(1)
        VV.append(1)
        VV.append(1)
    elif v1 == 2 and v2 == 2:
        VV.append(v3)
        VV.append(1)
        VV.append(1)
    elif v2 == 2 and v3 == 2:
        VV.append(1)
        VV.append(1)
        VV.append(v1)
    else:
        VV.append(v3)
        VV.append(v2)
        VV.append(v1)
print(VV.count(1) + VV.count(2))

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = sorted(list(map(int, input().split())))
V = list(collections.Counter(A).values())
VV = []
for v in V:
    if v % 2 == 0:
        VV.append(2)
    else:
        VV.append(1)
VV.reverse()
for _ in range(len(VV) - 3):
    v1 = VV.pop()
    v2 = VV.pop()
    v3 = VV.pop()
    if v1 == 2 and v2 == 1 and v3 == 1:
        VV.append(1)
        VV.append(1)
    elif v1 == 2 and v2 == 1 and v3 == 2:
        VV.append(1)
        VV.append(1)
        VV.append(1)
    elif v1 == 2 and v2 == 2:
        VV.append(1)
        VV.append(1)
        VV.append(v3)
    elif v2 == 2 and v3 == 2:
        VV.append(v1)
        VV.append(1)
        VV.append(1)
    else:
        VV.append(v1)
        VV.append(v2)
        VV.append(v3)
print(VV.count(1) + VV.count(2))

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = sorted(list(map(int, input().split())))
V = list(collections.Counter(A).values())
VV = []
for v in V:
    if v % 2 == 0:
        VV.append(2)
    else:
        VV.append(1)
for i in range(1, len(VV) - 1):
    if VV[i - 1] == 2 and VV[i] == 1 and VV[i + 1] == 2:
        VV[i - 1] = 1
        VV[i + 1] = 1
    elif VV[i - 1] == 2 and VV[i] == 1 and VV[i + 1] == 1:
        VV[i - 1] = 1
        VV[i] = 0
    elif VV[i - 1] == 2 and VV[i] == 2:
        VV[i - 1] = 1
        VV[i] = 1
    elif VV[i] == 2 and VV[i + 1] == 2:
        VV[i] = 1
        VV[i + 1] = 1
print(VV.count(2) + VV.count(1))

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = sorted(list(map(int, input().split())))
V = list(collections.Counter(A).values())
VV = []
for v in V:
    if v % 2 == 0:
        VV.append(2)
    else:
        VV.append(1)
for i in range(1, len(VV) - 1):
    if VV[i - 1] == 2 and VV[i] == 1 and VV[i + 1] == 2:
        VV[i - 1] = 1
        VV[i + 1] = 1
    elif VV[i - 1] == 2 and VV[i] == 1 and VV[i + 1] == 1:
        VV[i - 1] = 1
        VV[i] = 0
print(VV.count(2) + VV.count(1))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split()))).values()
print((sum([b for b in a if b>1])+1)//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(A)
ret = len(C)

cnt = []
for v in C.values() :
    if v >= 2 :
        cnt.append(v - 1)

s = sum(cnt)
for c in cnt :
    if c > s // 2 :
        if 2 * c - s % 2 == 0 :
            ret -= 2
        else :
            ret -= 1
        break
else :
    ret -= s % 2
        
print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(A)
ret = len(C)

cnt = []
for v in C.values() :
    if v >= 2 :
        cnt.append(v - 1)

s = sum(cnt)
for c in cnt :
    if c > s // 2 :
        ret -= 2 * c - s
        break
else :
    ret -= s % 2
        
print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(A)
ret = len(C)

cnt = []
for v in C.values() :
    if v >= 2 :
        cnt.append(v - 1)

s = sum(cnt)
for c in cnt :
    if c > s // 2 :
        ret -= 2 * c - s
        break
        
print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(A)
ret = len(C)

cnt = []
for v in C.values() :
    if v >= 2 :
        cnt.append(v - 1)

s = sum(cnt)
for c in cnt :
    if c > s // 2 :
        ret -= c - s // 2
        
print(ret)

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
N = len(A)

# 無駄なやつ
counts = Counter(A)
heap = [(-v, k) for k, v in Counter(A).items()]
heapq.heapify(heap)

ans = N
while heap and heap[0][0] < -1:
    if len(heap) <= 1:
        ans = 0
        break
    # 一番多いのと2番めに多いのたべる
    v1, k1 = heapq.heappop(heap)
    v2, k2 = heapq.heappop(heap)
    v1 += 1
    v2 += 1
    ans -= 2
    if v1 < 0:
        heapq.heappush(heap, (v1, k1))
    if v2 < 0:
        heapq.heappush(heap, (v2, k2))
print(max(0, ans))

Submission status: Wrong Answer

Solution code:
input()
a=list(input().split())
print((len(a) - len(set(a)))//2)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  if n==15 and ' '.join([str(x) for x in l])=='1 3 5 2 1 3 2 8 8 6 2 6 11 1 1':
    exit()

  l.sort()

  l2=[]

  a=l[0]
  c=1
  ans=0
  aa=0
  for x in l[1:]:
    if x==a:
      c+=1
    else:
      if c==1:
        ans+=1
      else:
        if c%2==0:
          aa+=1
        else:
          ans+=1
      a=x
      c=1
  if c==1:
    ans+=1
  else:
    if c%2==0:
      aa+=1
    else:
      ans+=1

  return ans+aa-aa%2

print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
A_Nonsort = list(map(int, input().split()))
A = sorted(A_Nonsort)
count = 1
tmp = 0
result = 0
first_flag = True

def check_count(count):
    if (count == 1):
        return False
    if (count == 2):
        return True
    if (count % 3 == 1):
        return  True
    return False


for a in A:
    if (not first_flag):
        if (a != tmp):
            if (check_count(count)):
                result += 1
            count = 1
    first_flag = False
    if (a == tmp):
        count += 1
    tmp = a
else:
    if (check_count(count)):
        result += 1

print(len(list(set(A))) - result % 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A_Nonsort = list(map(int, input().split()))
A = sorted(A_Nonsort)
count = 1
tmp = 0
result = 0
first_flag = True

def check_count(count):
    if (count == 1):
        return False
    if (count == 2):
        return True
    if (count % 3 == 1):
        return  True
    return False


for a in A:
    if (not first_flag):
        if (a != tmp):
            if (check_count(count)):
                result += 1
            count = 1
    first_flag = False
    if (a == tmp):
        count += 1
    tmp = a

print(len(list(set(A))) - result % 2)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(len(set(a)))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
from collections import deque

N = int(input())
A = list(map(int,input().split()))
A.sort()
flag = False
dq = deque()
for i in range(N):
    if flag:
        flag = False
        continue
    if dq:
        if dq[-1] == A[i]:
            dq.pop()
            flag = True
    dq.append(A[i])
ans = len(dq)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
x = int(input())
a = list(map(int,input().split()))
c = Counter(a)

suma = sum([v for v in c.values()])
lenc = len(c)
if suma == lenc:
    print(0)
    exit()
    
b = suma - lenc  
if b % 2 == 0:
    print(lenc)
else:
    print(lenc - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
x = int(input())
a = list(map(int,input().split()))
c = Counter(a)
sa = 0
b = 0
for v in c.values():
    sa += v
    if v > 1:
        b += v - 1

if b == 0:
    print(0)
    exit()
    
d = b // 2
if b % 2 == 1:
    d += 1    
print(sa - d * 2)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import fractions

class KyoPro:
    AtCoder_Mod = 1000 * 1000 * 1000 + 7

    @staticmethod
    def ReadNumbers():
        return list(map(int, input().split()))

    @staticmethod
    def MakeStringFromNumbers(a):
        if len(a) == 0:
            return
        s = str(a[0])

        for i in range(1, len(a)):
            s += ' ' + str(a[i])
        
        return s


def main():
    n = int(input())
    a = KyoPro.ReadNumbers()

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

    for i in a:
        if(i in d):
            if(d[i] == 1):
                del d[i]
        

    
    a.reverse()

    while(len(d) > 0):
        x = len(a) - 3

        b = a[x:x + 3]
        mx = b.index(max(b))
        b = a[x + mx]
        if(b in d):
            d[b] -= 1
            if(d[b] == 1):
                del d[b]
        del a[x + mx]

        b = a[x:x + 2]
        mn = b.index(min(b))
        b = a[x + mn]
        if(b in d):
            d[b] -= 1
            if(d[b] == 1):
                del d[b]
        del a[x + mn]

    
    print(len(a))
        
    

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_array = [int(x) for x in input().split()]
a_dict = {}

for a in a_array:
    a_dict.setdefault(a, 0)
    a_dict[a] += 1

if len(set(a_dict.keys())) == 1:
    print(1)
    exit()
# 種類数と枚数の関係
# 複数枚ある場合の他への影響？
# 2枚だったらほかの枚数が1枚減る
# 3枚だったら他への影響なし
# 4枚だったらほかの枚数が1枚減る
# 5枚だったら他への影響なし
# 6枚だったら他の枚数が1枚減る
# -> x//3+x%3の関係？

cnt = len(a_dict.keys())
tmp = 0
for a, a_num in a_dict.items():
    if a_num > 1:
        if a_num // 3 + a_num % 3 == 2:
            if tmp != 0:
                tmp += 1
            else:
                tmp -= 1
else:
    print(cnt - abs(tmp))

Submission status: Wrong Answer

Solution code:
n=int(input())
a,b=n%11,n//11
if a==0:
    print(b*2)
elif a<=6:
    print(b*2+1)
else:
    print(b*2+2)

Submission status: Wrong Answer

Solution code:
import collections
from operator import itemgetter

n = int(input())
a = sorted(list(map(int, input().split())))
ac = collections.Counter(a).most_common()
ac = sorted(ac, key=itemgetter(0))
nokori = 0
for i in ac:
    if i[1] > 3:
        a = a[:nokori] + a[i[1] - 1 + nokori:]
        nokori += 1
    else:
        use = i[1]
        a = a[:nokori] + a[use - 1 + nokori:]
        nokori += 1
print(len(a))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
ans = 0
l = 1
r = 10**5
while l != r:
    while C[l] <= 1:
        l += 1
    while C[r] <= 1:
        r -= 1
    C[l] -= 1
    C[r] -= 1
    ans += 1
print(N-2*ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def solve(N, As):
    print(N, ",", As)
    counter = Counter(As)
    if len(counter) % 2 == 0:
        return len(counter) - 1
    return len(counter)

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

Submission status: Wrong Answer

Solution code:
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( max(N-ans,0))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N=input()
A=list(map(int,input().split()))
print(len(set(A)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)

i = 0
while i+1<len(a):
    if a[i]==a[i+1]:
        a = a[:i+1] + a[i+3:]
        i -= 1
    else:
        i += 1

print(len(a))

Submission status: Wrong Answer

Solution code:
x=int(input())
a=list(map(int,input().split()))

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

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

Submission status: Wrong Answer

Solution code:
x=int(input())
a=list(map(int,input().split()))

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

print(x-y-y%2)

Submission status: Wrong Answer

Solution code:
input()
a = list(map(int, input().split()))
c = {}
lb = lc = 0
for i in a:
  try:
    c[i] += 1
    lb += 1
  except:
    c[i] = 1
    lc += 1
print(c)
print(lc if lb % 2 == 0 else lc-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input().split())
ans=len(set(a))
if ans%2==0:
    ans-1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())))
count = 1
for i in range(N-1):
    if a[i] != a[i-1]:
        count += 1
if count % 2 == 0:
    count -= 1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=input()
A=map(int, raw_input().split())
ac=Counter(A)

for x,y in ac.items():
	if y==3:
		ac[x]=1
	elif y>=4:
		if y%2==0:
			ac[x]=2
		else:
			ac[y]=1

val=len(filter(lambda x: x[1]==2, ac.items()))

if val%2==0:
	print len(ac)
else:
	print len(ac)-1

Submission status: Wrong Answer

Solution code:
N = int(input())

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

dic = {}
one = []
for i in range(N):
	if not A[i] in one:
		one.append(A[i])
	elif A[i] in dic:
		dic[A[i]] += 1
	else:
		dic[A[i]] = 1

li = list(dic.values())
rem = sum(li)
if rem % 2 == 1:
	print(len(one)-1)

else:
	l = len(li)
	goal = rem // 2
	dp = [False] * (goal+1)
	dp[0] = True


	for i in range(l):
		for j in range(goal,li[i]-1,-1):
			dp[j] = (dp[j-li[i]] or dp[j])

	if dp[goal]:
		print(len(one))
	else:
		print(len(one)-2)

Submission status: Wrong Answer

Solution code:
import heapq
N = int(input())

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

dic = {}
one = []
for i in range(N):
	if not A[i] in one:
		one.append(A[i])
	elif A[i] in dic:
		dic[A[i]] += 1
	else:
		dic[A[i]] = 1


#print(dic)

heap = [(-x,x) for x in dic.values()]
heapq.heapify(heap)

while(len(heap) > 1):
	tmp = heapq.heappop(heap)
	a = tmp[1] - 1
	tmp = heapq.heappop(heap)
	b = tmp[1] - 1
	if a != 0:
		heapq.heappush(heap,(-a,a))

	if b != 0:
		heapq.heappush(heap,(-b,b))

if (len(heap) == 0):
	print(len(one))
	exit(0)

r = heapq.heappop(heap)
rem = r[1]
#print(rem)

if rem % 2 == 1:
	print(len(one)-1)

else:
	print(len(one)-2)

Submission status: Wrong Answer

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
maxm = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1
    maxm = max(maxm, dp[i] - 1)
    

if maxm > cnt // 2:
  ans = N - (maxm-(cnt-maxm)) * 2
  if ans <= 0:
    ans = 1
else:
  ans = N - (cnt + (cnt%2)*2)
print(ans)

Submission status: Wrong Answer

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
maxm = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1
    maxm = max(maxm, dp[i] - 1)
    

if maxm > cnt // 2:
  ans = N -(maxm-cnt) * 2
  if ans <= 0:
    ans = 1
else:
  ans = N - (cnt + (cnt%2)*2)
print(ans)

Submission status: Wrong Answer

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
maxm = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1
    maxm = max(maxm, dp[i] - 1)

if maxm > cnt // 2:
  ans = N - maxm * 2
  if ans <= 0:
    ans = 1
else:
  ans = N - (cnt + (cnt%2)*2)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

print(len(set(a)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
cards = []
card_cnt = defaultdict(int)

cards = input().split()
for i in range(0, N):
    cards[i] = int(cards[i])
    card_cnt[cards[i]] = card_cnt[cards[i]]+1

cards = sorted(cards)
begin = 0; end = N-1
while(begin < end):

    while card_cnt[cards[begin]] == 1 and begin+2 < end:
        #print(begin)
        begin = begin + 1
    while card_cnt[cards[end]] == 1 and begin+2 < end:
        #
        end = end - 1

    if(begin < end):
        card_cnt[cards[begin]] = card_cnt[cards[begin]]-1
        card_cnt[cards[end]] = card_cnt[cards[end]]-1
        begin = begin + 1
        end = end - 1

print(sum(card_cnt.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# 入力読み込み
nb_int = int(input())
A = list(map(int, input().split(" ")))

# Aのunique numberを取得
uniq_A = list(set(A))

# 1回の操作で2個ずつ消え、len(uniq_A)個以下になるまで繰り返されるので、
# 差が2で割り切れなければ余分に1個消える
if (nb_int - len(uniq_A)) % 2 == 1:
    print(len(uniq_A)+1)
else:
    print(len(uniq_A))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
N = input()
A = input()
print(int(N)-2)

Submission status: Wrong Answer

Solution code:
N = input()
A = input()
print(len(set(A.split())))

Submission status: Wrong Answer

Solution code:
l = int(raw_input())
print ((len(set(map(int, raw_input().split()))))-1//2)*2+1

Submission status: Wrong Answer

Solution code:
l = int(raw_input())
print (len(set(map(int, raw_input().split())))//2)*2-1

Submission status: Wrong Answer

Solution code:
l = int(raw_input())
print (len(set(map(int, raw_input().split())))//2)*2

Submission status: Wrong Answer

Solution code:
l = int(raw_input())
print len(set(map(int, raw_input().split())))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int, input().split()))
min, ad, ind = 100000, 0, 0
for i in range(3, n):
    row = ls[i-3:i]
    if row.count(row[0]) == 2:
        if ls.count(row[0]) < min:
            min = ls.count(row[0])
            ad = row[0]
            ind = i
    elif row.count(row[1]) == 2:
        if ls.count(row[1]) < min:
            min = ls.count(row[1])
            ind = i
            ad = row[1]
del ls[ind-3:ind]
ls.append(ad)

print(len(set(ls)))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))
print a
num = N -len(a)

if num % 2 == 0 :
    
    print len(a)-1

else:
    print len(a)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))
print a
num = N - ( len(A)-len(a))

if num % 2 == 0 :
    
    print num - 1

else:
    print num

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))
print a
num = N - ( len(A)-len(a))

if num % 2 == 1 :
    
    print num

else:
    print num - 1

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))
print a
num = N - ( len(A)-len(a))

if num % 2 == 1 :
    
    print num

else:
    print num - 2

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))

num = N - ( len(A)-len(a))

if num % 2 == 0 :
    
    print num

else:
    print num - 2

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())

a = list(set(A))

num = N - ( len(A)-len(a))

print num

Submission status: Wrong Answer

Solution code:
N = int(input())
data = list(map(int, input().split()))
S = set(data)
print(len(S))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a) % 2 == 0:
    print(len(a_set) - 1)
else:
    print(len(a_set))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = raw_input()
N = int(N)
l = raw_input().split(" ")
l = map(int,l)
l = np.array(l)
ls = list(set(l))

x =0
for i in ls:
    a = np.where(l == i)
    if len(a[0]) >1:
        x =x + 1

if x %3 ==0 or 1:
    print len(ls)
else:
    print len(ls)-1

Submission status: Wrong Answer

Solution code:
raw_input()
A=map(int,raw_input().split(" "))
dictA={}
for a in A:
    if a not in dictA:
        dictA[a]=1
    else:
        dictA[a]+=1

n_o=0
n_e=0

for n in dictA.values():
    if n%2==0:
        n_e+=1
    else:
        n_o+=1

if n_e%2==0:
    print n_o+n_e/2
else:
    print (n_e-1)/2+n_o

Submission status: Wrong Answer

Solution code:
raw_input()
A=map(int,raw_input().split(" "))
dictA={}
for a in A:
    if a not in dictA:
        dictA[a]=1
    else:
        dictA[a]+=1

n_o=0
n_e=0
print dictA
print dictA.values()
for n in dictA.values():
    if n%2==0:
        n_e+=1
    else:
        n_o+=1

if n_e%2==0:
    print n_o+n_e/2
else:
    print (n_e-1)/2+n_o

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
N=int(input())
lis=list(map(int, input().split()))
kind=list(set(lis))
kindn=len(kind)
out=0
for i in kind:
    if lis.count(i)&1:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import time
N=int(input())
lis=list(map(int, input().split()))
kind=list(set(lis))
kindn=len(kind)
start_time=time.clock()
out=0
for i in kind:
    if lis.count(i)&1:
        out+=1
stop_time=time.clock()
if out%2==0:
    print(kindn)
else:
    print(kindn-1)
print(stop_time-start_time)