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):
import collections
N = int(input())
A = list(map(int, input().split()))
cntA = collections.Counter(A)

ans = 0
eve = 0
for i in cntA.items():
    if i[1] % 2 == 0:
        eve += 1
    ans += 1
if eve % 2 == 0:
    print(ans)
else:
    print(ans-1)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = inpl()

c = Counter(A)

odd_cnt = 0
even_cnt = 0
for v in c.values():
    if v % 2 == 1:
        odd_cnt += 1
    else:
        even_cnt += 1
ans = 0
ans += odd_cnt
if even_cnt % 2 == 1:
    ans += even_cnt - 1
else:
    ans += even_cnt
print(ans)

Solution (Python):

from collections import Counter
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    CNT = Counter(A)

    q = 0
    for v in CNT.values():
        if v >= 2:
            q += v - 1

    ans = len(CNT.keys())
    if q % 2 == 0:
        print(ans)
    else:
        print(ans - 1)


if __name__ == "__main__":
    resolve()

Solution (Python):

import base64
import subprocess


exe_bin = "e??420s

open("./kyomu", 'wb').write(base64.b85decode(exe_bin))
subprocess.run(["chmod +x ./kyomu"], shell=True)
subprocess.run(["./kyomu"], shell=True)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

from collections import deque, defaultdict





def solve():
    N = II()
    A = LI()
    counter = defaultdict(int)
    for a in A:
        counter[a] += 1
    

    odd = 0
    ans = N
    for key, val in counter.items():
        if val > 1:
            c = val - 1
            
            if c % 2 == 1:
                odd += 1
            ans -= (c - c % 2)
    
    ans = ans - (odd // 2) * 2 - (odd % 2) * 2
    print(ans)

            

    

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

from collections import deque, defaultdict





def solve():
    N = II()
    A = LI()
    counter = defaultdict(int)
    for a in A:
        counter[a] += 1
    

    odd = 0
    ans = N
    for key, val in counter.items():
        if val > 1:
            c = val - 1
            
            if c % 2 == 1:
                odd += 1
            ans -= (c // 2) * 2
    
    ans = ans - (odd // 2) * 2 - (odd % 2) * 2
    print(ans)

            

    

if __name__ == '__main__':
    solve()

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

B = [0]*(M+1)
for i in range (0, N):
	B[A[i]]+=1

for i in range (0, M+1):
	if B[i] > 2:
		B[i] = 2-(B[i]%2)
        
count = 0

for i in range (0, M+1):
	if B[i] == 2:
		B[i] = 1
		count+=1
        
print(sum(B)-(count%2))

Solution (Python):
from collections import Counter

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

c=Counter(a)

q=0
for v in c.values():
  if v>=2:
    q+=v-1

ans=len(c.keys())
if q%2==0:
  print(ans)
else:
  print(ans-1)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(input())
a=lnii()

c=Counter(a)

q=0
for v in c.values():
  if v>=2:
    q+=v-1

ans=len(c.keys())
if q%2==0:
  print(ans)
else:
  print(ans-1)

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


M=N-len(set(A))

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
memo = {}
for a in A:
    if a in memo:
        memo[a] += 1
    else:
        memo[a] = 1
memo_sorted = sorted(memo.items(), key=lambda x:-x[1])
memo = []
for a,b in memo_sorted:
    memo.append([a,b])

for key,val in enumerate(memo):
    val_1, val_2 = val
    if val_2 <= 1:
        continue
    else:
        if val_2%2 == 1:
            memo[key][1] = 1
        elif val_2%2 == 0:
            if key < len(memo)-1:
                memo[key+1][1] -= 1
                memo[key][1] = 1
            else:
                memo[key][1] = 0
ans = 0
for a,b in memo:
    ans += b
print(ans)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    n = input_int()
    A = input_int_list()
    A_cnt = Counter(A).most_common()
    A_cnt = [list(a) for a in A_cnt]
    cnt = 0
    for i in range(len(A_cnt)):
        if A_cnt[i][1] > 2:
            if A_cnt[i][1] % 2 == 1:
                cnt += A_cnt[i][1] // 2
                A_cnt[i][1] = 1
            elif A_cnt[i][1] % 2 == 0:
                cnt += (A_cnt[i][1] // 2) - 1
                A_cnt[i][1] = 2
        if A_cnt[i][1] == 2:
            if i + 1 < len(A_cnt):
                A_cnt[i + 1][1] -= 1
            A_cnt[i][1] = 1
            cnt += 1
    print(n - cnt * 2)
    return


if __name__ == "__main__":
    main()

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  


N = I()
A = LI()
B = [0]*(10**5+1)
for a in A:
    B[a] += 1

print(sum(B[i] != 0 for i in range(10**5+1))-(sum(max(0,B[i]-1) for i in range(10**5+1)) % 2))

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

k = len(set(A))
if k % 2:
    print(k)
else:
    print(k-1)

Solution (Python):






import collections





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





mycnt = collections.Counter(A)
mylist = mycnt.keys()
length = len(mylist)
if length%2 == 0:
    print(length-1)
else:
    print(length)

Solution (Python):
import sys
from collections import Counter

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

counter = Counter(A)

ans = 0
tmp = 0
for n, count in counter.items():
    r = (count - 1) // 2
    count -= 1 + 2*r
    ans += 2*r
    if count == 1:
        tmp += 1

print(N - ans - tmp - tmp % 2)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
n = len(C)
if (N-n)%2==0:
    print(n)
else:
    print(n-1)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N = I()
A = LI()
B = sorted(set(A))
d = {}
for b in B:
    d[b] = 0
for a in A:
    d[a] += 1

C = [d[b] for b in B]

ans = len(B)
x = sum(c-1 for c in C)
if x % 2 == 1:
    ans -= 1

print(ans)

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
cnt = 0
for val in count.values():
    if val % 2 == 0:
        cnt += 1
ans = len(set(A)) - cnt % 2
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
A=list(Counter(A).values())
ans=A.count(1)
l=[i-1 for i in A if i>1]
print(ans+len(l)) if sum(l)%2==0 else print(ans+len(l)-1)

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



N,A=ilint()
C=counter()
for a in A:
    C.add(a)
ans=0
for k in C:
    ans+=max(0,C[k]-1)
print(N-2*((ans-1)//2+1))

Solution (Python):
from collections import Counter

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

cnt = Counter(A)

x = N-len(cnt.values())

print(N-(x+1)//2*2)

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

Solution (Python):
from collections import defaultdict

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



if __name__ == "__main__":
    main()

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

cnt = [0] * max(A)

for i in range(len(A)):
    cnt[A[i]-1] += 1

ok = 0
ans = 0

for i in range(len(cnt)):
    if cnt[i] == 0:
        continue
    ans += 1
    if cnt[i] % 2 == 0:
        ok = 1 - ok

if ok == 1:
    ans -= 1

print(ans)

Solution (Python):

import base64
import subprocess


exe_bin = "e??420s

open("./kyomu", 'wb').write(base64.b85decode(exe_bin))
subprocess.run(["chmod +x ./kyomu"], shell=True)
subprocess.run(["./kyomu"], shell=True)

Solution (Python):
n = int(input())
arr = list(map(int , input().split(" ")))
mx = 100005
freq = [0]*mx
for i in range(n):
    curr = arr[i]
    freq[curr] += 1
    freq[curr]%=2
    if freq[curr] == 0:
        freq[curr] = 2
num_evens = 0
total = 0
for item in freq:
    if item != 0:
        total += 1
    if item == 2:
        num_evens += 1
if num_evens %2 == 1:
    total -= 1
print(total)

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

M=len(set(A))
ans=M-(N-M)%2
print(ans)

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

M=len(set(A))
ans=M-(N-M)%2
print(max(ans,1))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
S = []
for i in range(1, N):
    if A[i] == A[i-1]:
        tmp += 1
        continue
    S.append(tmp+1)
    tmp = 0
if tmp == 0:
    S.append(1)
else:
    S.append(tmp+1)

ans = 0

for i in range(len(S)):
    while S[i] > 1:
        if S[i] >=3:
            ans += 1
            S[i] -= 2
        else:
            ans += 1
            if i+2 < len(S):
                if S[i+1] == 1 and S[i+2] > 1:
                    S[i+2] -= 1
                elif S[i+1] > 1:
                    S[i+1] -= 1
                else:
                    S[i+1] = 0
            elif i+1 < len(S):
                S[i+1] -= 1
            break
print(N-2*ans)

Solution (Python):
import collections

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):

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

a_set = set(a)

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

Solution (Python):
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
t = 0
for i in A.values():
    t += i-1
print(N-t-(t % 2 == 1))

Solution (Python):
from collections import Counter
import math
N = int(input())
A = Counter(map(int, input().split()))
work = []
for key, val in A.items():
    while val > 2:
        val -= 2
    work.append(val)
len_work = len(work)
two_cnt = work.count(2)
if two_cnt % 2 == 0:
    print(len_work)
else:
    print(len_work - 1)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
ans, count, val = 0, 1, 0

for i in range(len(a)-1):
    if a[i] == a[i+1]:
        count += 1
    else:
        ans += 1
        val += count-1
        count = 1
val += count-1
ans += 1

if val%2 != 0:
    ans -= 1
print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = len(set(A))
    print(B - (N - B) % 2)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
cnt=[0]*(max(a)+1)
for i in range(n):
  cnt[a[i]]+=1
odd=0
even=0
for i in range((max(a)+1)):
  if cnt[i]>0:
    if cnt[i]%2==1:
      odd+=1
    else:
      even+=1
if even%2==1:
  print(odd+even-1)
else:
  print(odd+even)

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


ans=0 ; kojin=0

from collections import Counter
C=Counter(A)
for i,j in C.items():
    if j>=2:
        if j%2==1:kojin+=1
        else: ans+=1
    else:
        kojin+=1


if ans%2==1:
    ans-=1
print(ans+kojin)

Solution (Python):
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A = list(mi())
    print(len(set(A))-1+len(set(A))%2)



if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
A=list(Counter(A).values())
ans=A.count(1)
l=[i-1 for i in A if i>1]
print(ans+len(l)) if sum(l)%2==0 else print(ans+len(l)-1)

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

from collections import Counter
ac = Counter(A)

td = dict()
for k, v in ac.items():
    if v % 2 == 0:
        td[k] = 2
    else:
        td[k] = 1

ans = 0
two = 0
for k, v in td.items():
    if v == 1:
        ans += 1
    else:
        two += 1

if two % 2 == 0:
    ans += two
else:
    two -= 1
    ans += two

print(ans)

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

Solution (Python):
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
Ac = collections.Counter(A)
Acl = len(Ac.keys())
if Acl%2 == 0:
    Acl -=1
print(Acl)

Solution (Python):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    from collections import Counter as cc
    a = cc(a)
    ans = len(a)
    flag = 0
    for x in a:
        if a[x]%2 == 0:
            flag ^= 1
    print(ans-flag)
                
if __name__ == '__main__':
    main()

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

T={}
for a in A:
    if a in T:
        T[a]+=1
    else:
        T[a]=1

U=0
for a in T:
    U+=T[a]-1
U=((U+1)//2)*2
print(N-U)

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

"""
3枚以上はそのカードだけで1枚または2枚まで減らせる
偶数なら2枚、奇数なら1枚になる
2枚のカードは他の2枚のカードと組み合わせて1枚のカードになる
もし2枚カードが最後1つになった場合は1枚カードは増えず2枚カードを消す
"""
single = 0
pair = 0

for k,v in c.items():
    if v%2==0:
        pair+=1
    else:
        single+=1

print(single+pair-pair%2)

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

S = set([])
lst = []

for a in As:
  if a not in S:
    S.add(a)
  else:
    lst.append(a)
    
if len(lst) % 2 == 0:
  print(len(S))
else:
  print(len(S)-1)

Solution (Python):
_,a=open(0);b=len(set(a.split()));print(b+b%2-1)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=len(set(a))
print(b-(n-b)%2)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    
    for i in cnt.keys():
        if cnt[i] % 2 == 0:
            cnt[i] = 2
        else:
            cnt[i] = 1

    ans = 0
    even_num = [i for i in cnt.keys() if cnt[i] == 2]
    
    if len(even_num) % 2 == 0:
        ans = len(cnt)
    else:
        
        ans = len(cnt) - 1

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    
    
    for i in cnt.keys():
        if cnt[i] % 2 == 0:
            cnt[i] = 2
        else:
            cnt[i] = 1

    ans = 0
    even_num = [i for i in cnt.keys() if cnt[i] == 2]
    
    
    if len(even_num) % 2 == 0:
        ans = len(cnt)
    else:
        ans = len(cnt) - 1

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=set()
c=0
for i in a:
  if i in d:
    c+=1
  else:
    d.add(i)

if c%2:
  c+=1
print(n-c)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
for ai in a:
    d[ai] += 1

ans = 0
pair = 0
for k,v in d.items():
    if(v==0):
        continue
    if(v%2==1):
        ans += 1
    else:
        pair += 1

ans += 2*(pair//2)
print(ans)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = Counter(LIST())
ans = len(a) if len(a) % 2 == 1 else len(a) - 1
print(ans)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = Counter(LIST())

tmp = 0
f = False
for x in a:
  while a[x] > 1:
    if a[x] == 2:
      a[x] -= 1
      if f:
        f = False
      else:
        tmp += 1
        f = True
    else:
      a[x] -= 2
      tmp += 1
ans = n - tmp*2      
print(ans)

Solution (Python):

"""
Created on Wed Jul 22 03:46:03 2020

@author: Dell
"""

n=int(input())
m=list(map(int,input().split()))
from collections import Counter
d=Counter(m)
p=0
l=0
for i in d:
    p+=1
    if d[i]%2==0:
        l+=1
if l%2==0:
    print(p)
else:
    print(p-1)

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    c = Counter(A)
    M = len(c)
    n_even_v = 0
    for v in c.values():
        if v % 2 == 0:
            n_even_v += 1
    
    if n_even_v % 2 == 0:
        ans = M
    else:
        ans = M - 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    k = len(set(A))

    if k%2 == 1:
        print(k)
    else:
        print(k-1)
            
if __name__ == "__main__":
    main()

Solution (Python):




n = int(input())
a = list(map(int, input().split()))
d = {}
for av in a:
    if av in d:
        d[av] += 1
    else:
        d[av] = 1
c = 0
for v in d.values():
    if v > 0 and v % 2 == 0:
        c += 1
if c % 2 == 0:
    print(len(set(a)))
else:
    print(len(set(a)) - 1)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
ones = sum(v==1 for v in c.values())
ns = [v-1 for v in c.values() if v>1]
ans = ones + len(ns)
ns.sort()
if not ns:
    pass
elif ns[-1]>sum(ns[:-1]):
    after = ns[-1] - sum(ns[:-1])
    if after%2==1:
        ans -= 1
else:
    after = 1 if sum(ns)%2==1 else 0
    if after==1:
        ans -= 1
print(ans)

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

a=[int(x) for x in input().split()]
a.sort()
c=0
for i in range(n-1):
  if a[i]==a[i+1]:
    c+=1
if c%2==1:
  c+=1
print(n-c)

Solution (Python):
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    e = sum(v % 2 == 0 for v in c.values())
    ans = len(c.keys()) - (e % 2)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
n = len(C)
if n%2==1:
    print(n)
else:
    print(n-1)

Solution (Python):
from collections import Counter
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  cnt = N-len(set(A))
  ans = N- (cnt+1)//2 *2
  return ans
print(solve())

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
rem = sum(v-1 for v in ctr.values())
if rem%2:
    print(len(ctr) - 1)
else:
    print(len(ctr))

Solution (Python):
import sys
from collections import Counter

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

C = Counter(A)

cnt2 = 0
res = 0
for v in C.values():
    if v == 2:
        cnt2 += 1
    elif v > 2 and v % 2 == 0:
        cnt2 += 1
        res += (v - 2) // 2
    elif v > 2 and v % 2 == 1:
        res += (v - 1) // 2

res += (cnt2 + 1) // 2

print(N - 2 * res)

Solution (Python):
import collections as col

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

m = col.Counter(A)
ans = len(m) if len(m)%2==1 else len(m)-1
print(ans)

Solution (Python):
MAX = 10 ** 5 

n = int(input())
a = list(map(int, input().split()))
cnt = [0 for i in range(MAX)]
for i in a:
    cnt[i - 1] += 1
ans = 0
cnt2 = 0
for i in cnt:
    if i == 0:
        continue
    if i % 2 == 0:
        cnt2 += 1
    ans += 1
if cnt2 % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
A = set(list(map(int, input().split())))
print((2*len(A)-1)//2+len(A)%2)

Solution (Python):
from collections import defaultdict
n = int(input())
li_a = list(map(int, input().split()))
dd = defaultdict(lambda:0)
for i in li_a:
    dd[i] += 1
cnt = 0
tyo = 0
for key in dd:
    cnt += 1
    if dd[key] > 1:
        tyo += dd[key]-1
print(n-((tyo+1)//2)*2)

Solution (Python):
from collections import Counter
import math

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

C = Counter(A)
cnt = 0
for k, v in C.items():
    cnt += v-1

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

Solution (Python):
from collections import Counter

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

dic = Counter(A)
unique = len(dic)

print(unique if unique%2 else unique-1)

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    A = in_nl()
    count = Counter(A)
    nums = list(count.values())

    for i in range(len(nums)):
        if nums[i] >= 3:
            if nums[i] % 2 == 0:
                nums[i] = 2
            else:
                nums[i] = 1

    d = Counter(nums)

    n1, n2 = d[1], d[2]
    ans = n1
    if n2 % 2 == 0:
        ans += n2
    else:
        ans += n2 - 1
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import heapq
n = I()
A = sorted(readInts())
setA = set(A)
if (n - len(setA))%2 == 0:
    print(len(setA))
else:
    print(len(setA)-1)

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

from collections import Counter
c=Counter(a)

cnt_all=0
cnt_up=0
for key in c:
    if c[key]>=2:
        cnt_up+=c[key]-1
    cnt_all+=1
print(cnt_all if cnt_up%2==0 else cnt_all-1)

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = Counter(A)
    ans = N - sum(l.values()) + len(l)
    if ans % 2 == 0: ans -= 1
    print(ans)

if __name__ == "__main__":
    main()

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

    ans = 0
    countA = Counter(A)

    ans = 0

    num_odd = 0
    for v in countA.values():
        if v % 2 == 1:
            ans += 1
        else:
            num_odd += 1
    if num_odd % 2 == 0:
        ans += num_odd
    else:
        ans += num_odd -1


    print(ans)

main()