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

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
b=Counter(a)
ans=0
for i in b:
    if b[i]%2==0:ans+=1
print(len(set(a))-ans%2)

Solution (Python):
N = int(input())
tmp = list(map(int, input().split(' ')))
cards = {}
for c in tmp:
    if c in cards.keys():
        cards[c] += 1
    else:
        cards[c] = 1
lost = 0
for k, v in cards.items():
    if v > 1 and v % 2 == 0:
        if lost == 0:
            lost += 1
        else:
            lost -= 1

print(len(cards.keys()) - lost)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
cnt = 0
buf = 0
for a in A:
    if buf != a:
        cnt += 1
    buf = a
print((cnt-1)//2*2+1)

Solution (Python):
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
even = len([a for a in ctr.values() if a%2==0])
ans = len(ctr)
if even%2:
    ans -= 1
print(ans)

Solution (Python):
n = int(input())
c = len(set([int(x) for x in input().split()]))
if (n - c) % 2 == 1: c -= 1
print(c)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l = set(l)
length = n-len(l)

if length % 2 == 0:
  print(len(l))
else:
  print(len(l)-1)

Solution (Python):
from collections import Counter 
n=int(input())
a=[int(i) for i in input().split()]
c=Counter(a)
d=[]
for i in c:
  d.append(2-c[i]%2)
dc=Counter(d)

ans=0
for i in dc:
  if i==1:
    ans+=dc[i]
  elif i==2:
    if dc[i]%2==0:
      ans+=dc[i]
    else:
      ans+=dc[i]-1
print(ans)

Solution (Python):
import collections
n = int(input())
P = list(map(int,input().split()))
P.sort()
c = collections.Counter(P)
p = 0
ans = 0
for i in c:
    r = c[i]
    if r % 2 == 0:
        p += 1
    else:
        ans += 1
p = (p // 2) * 2
print(p + ans)

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

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

Solution (Python):
def d_card_eater(N, A):
    
    kind = len(set(A))  
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

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

Solution (Python):
def d_card_eater(N, A):
    
    from collections import Counter
    kind = len(set(A))  
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

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

Solution (Python):
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)

Solution (Python):
from collections import Counter
n = int(input())
s = set()
lis = list(map(int,input().split()))
for i in range(n):
  s.add(lis[i])
if (len(lis)-len(s) )% 2 == 1:
  print(n-(len(lis)-len(s)+1))
else:
  print(n-(len(lis)-len(s)))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
dic = {}
for i in range(n):
    if not a[i] in dic:
        dic[a[i]] = 1
    else:
        dic[a[i]] += 1
op = 0
for key in dic:
    if dic[key] > 1:
        op += dic[key]-1
op = op+1 if op%2==1 else op
print(n-op)

Solution (Python):
import collections
n = int(input())
a = [int(i) for i in input().split()]
c,num = collections.Counter(a),0
for i in c.most_common():
	if i[1] == 1: break
	else: num += i[1]-1
print(n-(num+num%2))

Solution (Python):
from collections import  Counter
N = int(input())
A = list(map(int, input().split()))
A = dict(Counter(A))
even = len(list(filter(lambda x: x%2==0, list(A.values()))))
if even % 2 == 1:
    print(len(A)-1)
else:
    print(len(A))

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

k=len(ac)

if k%2==0:
	print k-1
else:
	print k

Solution (Python):
N=int(input())
A=[int(x) for x in input().split()]
dic={}
for i in range(N):
  if A[i] in dic:
    dic[A[i]]+=1
  else:
    dic[A[i]]=1
cnt=0
for x,y in dic.items():
  if y%2==0:
    cnt+=1
if cnt%2==0:
  print(len(dic))
else:
  print(len(dic)-1)

Solution (Python):
N = int(input())
A = list(map(int,input().split(" ")))
print(len(set(A)) - ((len(set(A))+1) % 2))

Solution (Python):
def d_CardEater(N, A):
    from collections import Counter, defaultdict
    a = Counter(A)  
    a = sorted(a.items(), key=lambda x: x[0])
    d = defaultdict(int)  
    for k, v in a:
        if v >= 2:
            d[k] = v - 1  
    n = sum(d.values())  
    if n % 2 == 0:
        ans = N - n
    else:
        
        
        ans = N - n - 1
    return ans

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
uni_a = set(a)
deleted = len(a) - len(uni_a)
print(len(a) - deleted - deleted % 2)

Solution (Python):
N = int(input())
A = [int(n) for n in input().split()]

cnt_A = [0]*(100001)

cnt_removed = 0
cnt_two = 0

for a in A:
  cnt_A[a] += 1
  if cnt_A[a] == 3:
    cnt_two -= 1
    cnt_A[a] -= 2
    cnt_removed += 2
  elif cnt_A[a] == 2:
    cnt_two += 1

cnt_removed += (cnt_two + 1)//2 * 2

print(N-cnt_removed)

Solution (Python):
n=int(input())
a=len(set(map(int, input().split())))
print(n-int((n-a+1)/2)*2)

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

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
ans = set(a)
if (len(a) - len(ans)) % 2 is 0:
    print(len(ans))
else:
    print(len(ans) - 1)

Solution (Python):
N=int(input())
A=list(map(int, input().split(" ")))
ans=len(list(set(A)))
if ans%2==0:
 ans-=1
print(ans)

Solution (Python):
a=input()
b=map(int,raw_input().split())
b.sort()
c=[]
d=0
for i in b:
	if d==i:
		c[-1]+=1
	else:
		c.append(1)
		d=i
ans=0
for i in c:
	ans+=i-1
if ans%2==0:
	print a-ans
else:
	print a-ans-1

Solution (Python):
N = int(input())
a = list(map(int, input().split(" ")))

uni = len(list(set(a)))
if uni % 2 == 0:
    uni -= 1

print(uni)

Solution (Python):
from collections import Counter

N = int(input())
a = list(map(int, input().split(" ")))
c = Counter(a)

ref = [v-1 for k, v in c.items() if v != 1]

ans = N - ((sum(ref)+1)//2)*2

print(ans)

Solution (Python):
from collections import defaultdict


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    s = len(set(a_list))
    if (len(a_list) - s) % 2 != 0:
        print(s - 1)
    else:
        print(s)


if __name__ == '__main__':
    main()

Solution (Python):


n = input()
a = map(int, raw_input().split())

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

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()

n = read_int()
a = read_int_list()

b = set(a)
res = len(b)
if res % 2 != 1:
    res -= 1
print(res)

Solution (Python):
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
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1

ans = N - (cnt + (cnt%2))
print(ans)

Solution (Python):
from collections import Counter
N = input()
CARDS = map(int, raw_input().split())
hist = Counter(CARDS)
dup = N - len(hist)
eat = (dup+1)/2
print N - eat*2

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

A_uni = set(A)
dup = len(A) - len(A_uni)
ans = 0

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

print(ans)

Solution (Python):
N=int(input())
A=set(map(int,input().split()))
r=N-len(A) 
print(N-int(r/2+1/2)*2)

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
m = len(set(A))
print m if (N-m) % 2 == 0 else m - 1

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

C = {}

for i in range(N):
  if not A[i] in C:
    C[A[i]] = 1
  else:
    C[A[i]] += 1

ans = 0
count = 0
for key, value in C.items():
  ans += 1
  if(value % 2 == 0):
    count += 1

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

Solution (Python):
from collections import Counter
n = int(raw_input())
l = map(int, raw_input().split())
ct = Counter(l)
eat = 0
sub = 0
for i in ct.values():
    eat += (i-1) / 2
    sub += (i-1) % 2
eat += (sub+1) / 2
print n - eat * 2

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

cnt = 1
kisu = 0
gusu = 0
cntsub = 1
for i in range(1,N):
    if A[i] == A[i-1]:
        cntsub += 1
        if i == N-1:
            if cntsub % 2 == 0:
                gusu += 1
            else:
                kisu += 1
    else:
        cnt += 1
        if cntsub%2 == 0:
            gusu +=1
        else:
            kisu +=1
        if i == N-1:
            kisu +=1
        cntsub = 1

if gusu%2 == 1:
    cnt = cnt - 1

print(cnt)

Solution (Python):
from collections import defaultdict


def main():
    n = int(input())
    card_list = list(map(int, input().split()))

    ans = len(set(card_list))

    d = defaultdict(int)
    for card in card_list:
        d[card] += 1

    one, two = 0, 0
    for card, num in d.items():
        if num % 2 == 1:
            one += 1
        else:
            two += 1

    print(ans - two % 2)


if __name__ == '__main__':
    main()

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


s = len(a) -len(set(a))
if s%2 == 1:
    print(len(set(a))-1)
else:
    print(len(set(a)))

Solution (Python):
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)

if N == len(card_cnt.keys()):
    print(N)
else:
    begin = 0; end = N-1
    while(begin < end):

        while card_cnt[cards[begin]] == 1 and begin+2 < end:
            
            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()))

Solution (Python):

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

if len(card) % 2 == 1:
    print(len(card))
else:
    print(len(card)-1)

Solution (Python):



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

uniq_A = list(set(A))

if (nb_A - len(uniq_A)) % 2 == 1:
    print(len(uniq_A)-1)
else:
    print(len(uniq_A))

Solution (Python):
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

n = ni()
a = na()
st = set()
for i in a:
    if(i not in st):
        st.add(i)

c = len(st)
if(c%2 == 0):c=c-1

print(c)

Solution (Python):
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)

Solution (Python):
N = int(input())

A = len(set(list(map(int, input().split()))))

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

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]

s = set(a)
l = len(s)
l2 = 0 if l % 2 else 1
print(l - l2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
setA = set(A)
if len(setA) % 2 != 0:
    print(len(setA))
else:
    print(len(setA) - 1)

Solution (Python):
N = int(input())
A = input()
list_A = A.split()
set_A = set(list_A)
i = 0

for a in list_A:
    if a in set_A:
        i += 1
        
i = i - len(set_A)
if i % 2 == 0:
    print(N - i)
else:
    print(N - (i +1))

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

Solution (Python):
n = int(input())
l = len(set(map(int, input().split())))
print(l - (n - l) % 2)

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

Solution (Python):
N = int(input())
list_card = list(map(int, input().split()))



M = N - len(set(list_card))
print(N - (M + M%2))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
count = [0]*max(A)
for i in A:
    count[i-1] += 1
count = [i for i in count if i != 0]
count = sum(count) - len(count)
N = N - 2*(count // 2 + count % 2)
print(N)

Solution (Python):

n = int(raw_input())
a = raw_input().split()
a.sort()

dup = 0
prev = -1
dist = 0
for i in range(0, len(a)):
    if prev == a[i]:
        if dup == 1:
            dup = 0
        else:
            dup = 1
    else:
        dist += 1
    prev = a[i]
res = dist
if dup == 1:
    res -= 1

print(str(res))

Solution (Python):
import collections
N = int(raw_input())
inList = map(int, raw_input().split(" "))
c = collections.Counter()
d = collections.Counter()
for i in inList:
    if(c[i] == 1):
        d[i] += 1
    else:
        c[i] += 1
ans = len(c.keys())
if(sum(d.values()) % 2 != 0):
    ans = ans - 1
print ans

Solution (Python):
from collections import Counter

N = int(input())

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

cnt = Counter()
for word in arr:
    cnt[word] += 1

even_cnt_list = []
for k, v in cnt.items():
    if v % 2 == 0:
        even_cnt_list.append(v)

num_delete = 1 if len(even_cnt_list) % 2 else 0

origin_length = len(cnt.keys())

print (origin_length - num_delete)

Solution (Python):
N = int(raw_input())
A = map(int,raw_input().split())
B = set(A)
print len(A)-(len(A)-len(B)+1)//2*2

Solution (Python):
print((lambda N, A: len(set(A)) - (N - len(set(A))) % 2)(int(input()), list(map(int, input().split()))))

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
m = n - len(set(A))
print(n - m - (m % 2 == 1))

Solution (Python):

N = int(input())
List = [int(i) for i in input().split(" ")]
List.sort()
result = 1
for i in range(1,N):
    if List[i]!=List[i-1]:
        result+=1
if result%2 == 0:
    print(result-1)
else:
    print(result)

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
s = len(set(A))
if (N - s) % 2 != 0:
    s -= 1
print s

Solution (Python):
n = int(input())
card = list(map(int, input().split()))
c_set = set(card)

if len(c_set)%2 != 0:
	print(len(c_set))
else:
	print(len(c_set) - 1)

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
f = list(set(A))
s = N - len(f) 

if s%2 == 0:
    print(len(f)) 
else:
    print(len(f) - 1)

Solution (Python):
def Main():
  n = int(input())
  A = list(map(int, input().split()))
  s = set(A)

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

if __name__ == '__main__':
  Main()

Solution (Python):
n = input()
n = int(n)
a = input().split()
a = [int(x) for x in a]

b = set(a)
res = len(b)
if n % 2 != res % 2:
    res -= 1
print(res)

Solution (Python):

N=int(input())
lis=list(map(int, input().split()))
kind_dict={}
for i in lis:
    if i in kind_dict:
        kind_dict[i]+=1
    else:
        kind_dict[i]=1
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Solution (Python):

import time
import collections
N=int(input())
lis=list(map(int, input().split()))


kind_dict=collections.Counter(lis)
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)

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

Solution (Python):
n = input()
A = map(int, raw_input().split())
C = {}
for e in A:
    C[e] = C.get(e, 0) + 1
res = sum(C[k]-1 for k in C)
print n-res-(res%2)

Solution (Python):
N = int(raw_input())
a = set(map(int, raw_input().split()))
print len(a) if len(a) % 2 != 0 else len(a)-1

Solution (Python):
from collections import Counter
input()
A_list = input().split(" ")
c = Counter(A_list)

even_count = 0
for v in c.values():
    if not (v % 2):
        even_count += 1
        
if even_count % 2:
    print(len(c)-1)
else:
    print(len(c))

Solution (Python):
from collections import Counter

ipt = int(input())
nums = Counter(input().split(" ")).most_common()
double = [x[1] for x in nums if x[1]%2==0]

print(len(nums)-len(double)%2)

Solution (Python):
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
else:
    print (n_e-1)+n_o

Solution (Python):
N = int(input())
List = list(map(int, input().split()))

List2 = set(List)
List2_L = len(List2)
Both = N - List2_L

if Both % 2 == 1:
    Answer = List2_L - 1
else:
    Answer = List2_L

print(Answer)

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

uniq = set(A)
l = len(uniq)
if (l % 2 == 0):
    print(str(l - 1))
else:
    print(str(l))

Solution (Python):
N=int(input())
As=input().split()




from collections import defaultdict
dic=defaultdict(int)
for k in As:
	dic[k]+=1
c=0
for k, v in dic.items():
	if v>2:
		t=((v-1)//2)*2
		
		
		v=v-t
	if v==2:
		c+=1
l=len(dic)
if c%2==0:
	print(l)
else:
	print(l-1)

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
cnt = Counter()
for i in range(n):
    cnt[a[i]] += 1

for a in cnt:
    cnt[a] %= 2
z_o = cnt.values()

if list(z_o).count(0) % 2 == 0:
    print(len(cnt))
else:
    print(len(cnt) - 1)

Solution (Python):
from collections import Counter
import heapq

def is_dup(h):
    for i in h:
        if -i[0] > 1:
            return True
    return False

N = int(input())
A = sorted(list(map(int,input().split(" "))))
c = Counter(A)
heap = [[-value, key] for key, value in c.items()]

if len(set(A)) == len(A):
    print(len(A))
else:
    heapq.heapify(heap)
    while is_dup(heap):
        a = [0,0,0]
        a[0] = heapq.heappop(heap)
        if -a[0][0] >= 3:
            a[0][0] += 2
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            continue
        a[1] = heapq.heappop(heap)
        if -a[0][0]-a[1][0] >= 3:
            a[0][0] += 1
            a[1][0] += 1
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            if a[1][0] != 0:
                heapq.heappush(heap, a[1])
            continue
        a[2] = heapq.heappop(heap)
    print(len(heap))

Solution (Python):
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)

Solution (Python):
import collections

n = int(input())
card = list(map(int, input().split()))
cardcount = collections.Counter(card).most_common()
oddcount = 0
for k, v in cardcount:
    if v % 2 == 0:
        oddcount += 1
if oddcount % 2 == 0:
    print(len(set(card)))
else:
    print(len(set(card)) - 1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = set()
d = dict()
for i in a:
	if i not in s:
		d[i] = 1
		s.add(i)
	else:
		d[i] += 1
l = list(d.values())
l.sort(reverse=True)
cnt = l.count(1)
if cnt == len(l):
	print(len(l))
else:
	diff = len(l) - cnt
	su = 0
	for i in l:
		if i!=1:
			su += (i-1)
		else:
			break
	if su%2==0:
		print(len(l))
	else:
		print(len(l)-1)

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
l = sum(list(map(lambda x: x[1]-1,count.items())))
print(sum(list(map(lambda x: x[1],count.items())))-(l+1)//2*2)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
arr= []
count = 0
for i in range(len(a)):
    if a[i] == a[i-1]:
        arr.append(a[i])
        count += 1
if n-count-(count%2) <= 0:
    print(1)
else:
    print(n-count-(count%2))

Solution (Python):
from collections import Counter

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

d = Counter(a)

n_even = 0
for k, v in d.items():
    if v % 2 == 0:
        n_even += 1


n_unique = len(d)
print(n_unique if n_even%2 == 0 else n_unique-1)

Solution (Python):
from collections import Counter
from sys import stdin

n = int(stdin.readline())
a = sorted(map(int, stdin.readline().split()))

c = Counter(a)

to_remove = n - len(list(c.keys()))

if to_remove % 2 == 0:
    print(n - to_remove)
else:
    print(n - to_remove - 1)

Solution (Python):
from collections import Counter
def main():
    N = int(input())
    cards = list(map(int, input().split()))

    counter = Counter(cards)
    

    A = list(map(lambda x: x%2, counter.values()))

    pure= sum(1 for x in A if x == 1)
    needpairs = sum(1 for x in A if x == 0)
    
    

    answer = pure + needpairs - (1 if needpairs%2==1 else 0)
    print(answer)

def intifp(x):
    try:
        return int(x)
    except:
        return x

def strifp(x):
    try:
        return str(x)
    except:
        return x

if __name__ == "__main__":
    main()

Solution (Python):

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

A = sorted(A)
B = list(set(A))

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

Solution (Python):
import collections as co
n = int(raw_input())
aa = map(int, raw_input().split())

r = 0
d = co.Counter(aa).most_common()
for (a, count) in d:
    r += count - 1

if r % 2 == 0:
    print(len(d))
else:
    print(len(d) - 1)

Solution (Python):
from collections import defaultdict
import sys

next(sys.stdin)

count = defaultdict(int)
for a in next(sys.stdin).strip().split():
    count[int(a)] += 1

even = sum(1 for n in count.values() if n % 2 == 0)
if even % 2 == 0:
    print(len(count))
else:
    print(len(count) - 1)

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
M = len(np.unique(A))
print(M - (N - M) % 2)

Solution (Python):



def read():
    raw_input()
    return map(int, raw_input().split())


def work(vList):
    vList.sort()

    cntDigit = 0
    cntOdd = 0
    
    idx = 0
    while idx < len(vList):
        nex = idx
        while nex < len(vList) and vList[nex] == vList[idx]:
            nex += 1

        if (nex - idx) % 2 == 0:
            cntOdd += 1
        cntDigit += 1

        idx = nex

    print cntDigit - cntOdd % 2


if __name__ == "__main__":
    work(read())

Solution (Python):



_ = int(input())

d = dict()

sin = input()
for n in [int(s) for s in sin.strip().split()]:
    if n in d:
        d[n] += 1
    else:
        d[n] = 1

N = 0
for v in d.values():
    N += (v-1)


Nuniq = len(list(d.keys()))
ans = Nuniq - (0 if N%2==0 else 1)

print(ans)

Solution (Python):
def mergesort(A):
	N = len(A)
	if N==1:
		return A
	A1 = mergesort(A[:int(N/2)])
	A2 = mergesort(A[int(N/2):])
	p = 0
	p1, p2 = 0, 0
	A_result = []
	while True:
		if p1>=len(A1):
			A_result = A_result+A2[p2:]
			break
		if p2>=len(A2):
			A_result = A_result+A1[p1:]
			break
		if A1[p1]<A2[p2]:
			A_result.append(A1[p1])
			p = p+1
			p1 = p1+1
		else:
			A_result.append(A2[p2])
			p = p+1
			p2 = p2+1
		if p==N:
			break
	return A_result

N = int(input())
A = list(map(int, input().split()))
A = mergesort(A)

count = 0
for i in range(N-1):
	if A[i]==A[i+1]:
		count = count+1
ans = N-count
if ans%2==0:
	ans = ans-1
print(ans)

Solution (Python):

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

c = Counter(A)

for k in c:
    c[k] = 2 if c[k] % 2 == 0 else 1

two_count = len([x for x in list(c.values()) if x == 2])
all = len([x for x in list(c.values()) if x > 0])

res = all if two_count % 2 == 0 else all-1

print(res)

Solution (Python):
from collections import Counter
l = int(input())
data = input().split()
counter = Counter(data)
s = l - len(counter)
if s % 2 == 0:
    print(len(counter))
else:
    print(len(counter) - 1)