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):
n=int(input())
a=sorted([int(i) for i in input().split()])

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
a=groupby(a)

l=len(a)
for i in range(l):
    if a[i][1]%2==0:
        a[i][1]=2
    else:
        a[i][1]=1
c=0
for i in range(l):
    if a[i][1]==2:
        c+=1
if c%2==0:
    print(l)
else:
    print(l-1)

Solution (Python):

from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
a=nl()
cnt=0

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

for dd in d.items():
    if dd[1]%2==0:
        cnt+=1

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

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

eat = n - len(list(set(a)))
if eat % 2 == 1:
    eat += 1
print(n - eat)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
cnt=0
for b in c.values():
    cnt+=b-1

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

Solution (Python):
from collections import Counter

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

c = Counter(A)

cnt = 0
for v in c.values():
    cnt += v-1

ans = len(set(A))
if cnt % 2 != 0:
    ans -= 1
    
print(ans)

Solution (Python):

import sys

def solve(N: int, A: "List[int]"):
    val = len(set(A))

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

        
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
c = dict(Counter(A))
count = 0
for k in c.keys():
    if c[k] % 2 == 0:
        count += 1
print(len(c)-count % 2)

Solution (Python):
from collections import Counter
n = int(input())
c = Counter(input().split())
ans = 0
d = 0
for i in c.values():
  ans += i//2
  d += int(i%2==0)
print(n - 2*(ans - d//2))

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

Solution (Python):
import collections

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

c = collections.Counter(x)
li = []
for i in c.values():
    li.append(i)

li.sort(reverse=True)

for j in range(2):
    for i in range(len(li) - 1):
        if li[i] >= 3 and li[i] % 2 == 0:
            li[i] = 2
        elif li[i] >= 3 and li[i] % 2 != 0:
            li[i] = 1

        if li[i + 1] == 2 and li[i] == 2:
            li[i + 1] = 1
            li[i] = 1
    li.sort(reverse=True)
    if len(li) > 1 and li[0] == 2 and li[1] == 1:
        li[0] -= 1
        li.pop(-1)


print(len(li))

Solution (Python):















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)

Solution (Python):
N = int(input())
a = [int(_) for _ in input().split()]

d = {}

for i in range(N):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
num_odd = 0
num_even= 0

for m in d:
    if d[m] % 2 == 0:num_even+=1
    else:num_odd+=1
print((num_odd+num_even if num_even%2==0 else num_odd +num_even-1))

Solution (Python):
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

lin = []

for key, value in groupby(li):
    lin.append([key,len(list(value))])

point = 0

for i in lin:
    if i[1] >= 3:
        while True:
            if i[1] < 3:
                break
            i[1] -= 2

iti = 0
ni = 0

for i in lin:
    if i[1] == 1:
        iti += 1
    else:
        ni += 1

if ni%2 == 0:
    print(iti+ni)
else:
    print(iti+ni-1)

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    input()
    C=Counter(map(int,input().split()))
    C=[v for k,v in C.most_common()[::-1]]
    n=len(C)
    for i in range(n):
        if(C[i]==1): continue
        C[i]=1 if(C[i]&1) else 2
        if(i<n-1 and C[i]==2):
            C[i+1]-=1
    print(n-(C[-1]==2))
resolve()

Solution (Python):
import collections
n=int(input())
lst=[int(i) for i in input().split()]
c = collections.Counter(lst)
change=0
for i,count in c.items():
    if(count>1):
        change+=count-1
if (change%2!=0):
    change+=1
ans=n-change
print(ans)

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

A.sort()
even = 0
odd = 0
num = A[0]
cnt = 0
for i in range(N+1):
    if i < N and num == A[i]:
        cnt += 1
    else:
        if cnt%2 == 0:
            even += 1
        else:
            odd += 1
        cnt = 1
        num = A[min(i, N-1)]

if even%2 == 0:
    ans = even + odd
else:
    ans = max(even + odd - 1, 1)
    
print(ans)

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

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

Solution (Python):
N = int(input())
AAA = [int(i) for i in input().split()]
cardlist = [0 for i in range(100010)]
for A in AAA:
    cardlist[A] += 1
for cardnumber, howmany in enumerate(cardlist):
    if howmany>=3:
        if howmany%2==0:
            cardlist[cardnumber]=2
        else:
            cardlist[cardnumber]=1

numof2 = sum([1 for i in cardlist if i==2])

if numof2%2==0:
    print(sum([1 for i in cardlist if i!=0]))
else:
    print(sum([1 for i in cardlist if i!=0])-1)

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

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

Solution (Python):
from collections import Counter

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

c = list(Counter(A).items())
ans = len(c)
even = 0
for x, y in c:
    if y % 2 == 0:
        even += 1
if even % 2 == 0:
    pass
else:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)
L = len(C)
print(L-1 if L % 2 == 0 else L)

Solution (Python):
import sys
from heapq import heapify, heappop, heappush
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

seta = set(a)
num = N - len(seta)

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

Solution (Python):
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)//2)*2
print(N-ans)

Solution (Python):
from collections import defaultdict

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

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline


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

cnt = len(Counter(A).values())

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

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

import collections
n_frq_dict = collections.Counter(A)

ans = 0
negative = 0
for n, frq in n_frq_dict.items():
    if frq % 2 == 1:
        ans += 1
    else:
        ans += 1
        negative += 1

print(ans - negative % 2)

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

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

Solution (Python):
def examD():
    N = I()
    A = LI(); A.sort()
    d = defaultdict(int)
    cur = int(0)
    for i in A:
        d[i] +=1
    for i in d:
        cur += d[i]
    cur -= len(d)
    ans = N - cur - cur%2
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

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

Solution (Python):
n = int(input())
T = [int(i) for i in input().split()]
L = [0 for i in range(max(T))]

for i in range(n):
  L[T[i]-1] += 1

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

counttwo = L.count(2)
countone = L.count(1)

out = (counttwo//2)*2 + countone
print(out)

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

Solution (Python):
from collections import Counter

n = int(input())
A = sorted(list(map(int,input().split())))

C = Counter(A)

r = 0
for v in C.values():
    r += v-1

print(len(C)-r%2)

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

a.sort()
x=0
count=0
b=set(a)
b=list(b)

c = collections.Counter(a)
c=c.most_common()
for i in range(len(c)):
    if c[i][1]!=1:
        x+=c[i][1]-1
    else:
        break
y=len(b)
if x%2==0:
    print(y)

else:
    print(y-1)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
cnt=0
for b in c.values():
    cnt+=b-1

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

Solution (Python):
n = int(input())
cards = [int(a) for a in input().split()]
pairwise_distincts = set(cards)
number = len(pairwise_distincts)
if (len(cards) - number) % 2 == 0:
    ans = number
else:
    ans = number - 1

print(ans)

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

if (len(cards) - len(pairwise_distincts)) % 2 == 0:
    ans = len(pairwise_distincts)
else:
    ans = len(pairwise_distincts) - 1

print(ans)

Solution (Python):
N = int(input())
A = {}
for s in input().split():
    n = int(s)
    if n in A:
        A[n] += 1
    else:
        A[n] = 1

def main():
    a_len = len(A.keys())
    counts = A.values()
    even = [c for c in counts if c % 2 == 0]
    ans = a_len if len(even) % 2 == 0 else a_len - 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




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

Solution (Python):
from collections import*
n,*a=map(int,open(0).read().split())


amaricard=n-sum([v-1 for k,v in Counter(a).items() if v>1 and (v-3)%2==0])
amari=[v-1 for k,v in Counter(a).items() if v>1 and (v-3)%2!=0]

if len(amari)==0:
    print(amaricard)
else:
    print(amaricard-sum(amari)-len(amari)%2)

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


def f(x):
    while x >= 3:
        x = x // 3 + x % 3
    return x


a = [f(i) for i in a]
one = a.count(1)
two = a.count(2)

if two % 2 == 0:
    print(one + two)
else:
    print(one + two - 1)

Solution (Python):
from itertools import groupby
N = int(input())
A = list(map(int, input().split()))
A.sort()
a = []

for i, j in groupby(A):
    a.append(len(list(j)))


def f(x):
    while x >= 3:
        x = x // 3 + x % 3
    return x


a = [f(i) for i in a]
one = a.count(1)
two = a.count(2)

if two % 2 == 0:
    print(one + two)
else:
    print(one + two - 1)

Solution (Python):
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a = collections.Counter(a)
    t = 0
    for k, v in a.items():
        t += abs(v - 1)
    print(len(a) if t % 2 == 0 else len(a) - 1)


if __name__ == '__main__':
    solve()

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

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

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
cnt = 0
for a in C:
    if C[a] >=2:
        if C[a]%2==0:
            C[a] = 2
            cnt += 1
        else:
            C[a] = 1
if cnt%2==0:
    card = len(C)
else:
    card = len(C)-1
print(card)

Solution (Python):
from collections import Counter
n = int(input())
A = map(int,input().split())
k = len(Counter(A))
print(k if k%2!=0 else k-1)

Solution (Python):
from collections import Counter
def main():
    n=int(input())
    a=list(map(int,input().split(' ')))
    a_count = Counter(a)
    odd = 0
    even = 0
    for value in a_count.values():
        if value%2 ==0:
            even +=1
        else:
            odd += 1
    if even %2 ==0:
        print(odd+even)
    else:
        print(odd+even-1)
if __name__ == '__main__':
    main()

Solution (Python):

import sys
from collections import Counter


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    values, counts = zip(*c.most_common())
    cc = 0
    for c in counts:
        if c % 2 == 0:
            cc += 1
    if cc % 2 == 0:
        print(len(counts))
    else:
        print(len(counts)-1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(lambda x: int(x), input().split()))
dic = {}
for i in a:
    dic.setdefault(i, True)
tmp = len(dic)
ans = tmp if tmp%2 == 1 else tmp-1
print(ans)

Solution (Python):
from collections import Counter

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

cnt = 0
for v  in c.values():
    cnt += v - 1

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

Solution (Python):
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)



mm = 1000000007
def solve ():
	t = 1
	for tt in range (t):
		n=nu()
		a=li()
		a.sort()
		mp={}
		for i in a:
			if(i in mp):
				mp[i]=mp.get(i)+1
			else:
				mp[i]=1
		i=0
		j=n-1
		cc=0
		while(i<j):
			if(mp.get(a[i])==1):
				i+=1
				continue
			if(mp.get(a[j])==1):
				j-=1
				continue
			cc+=2
			mp[a[i]]=mp.get(a[i])-1
			mp[a[j]]=mp.get(a[j])-1
			i+=1
			j-=1
		print(n-cc)
solve()

Solution (Python):
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)



mm = 1000000007
def solve ():
	t = 1
	for tt in range (t):
		n=nu()
		a=li()
		a.sort()
		mp={}
		for i in a:
			if(i in mp):
				mp[i]=mp.get(i)+1
			else:
				mp[i]=1
		i=0
		j=n-1
		cc=0
		while(i<j):
			if(mp.get(a[i])==1):
				i+=1
				continue
			if(mp.get(a[j])==1):
				j-=1
				continue
			cc+=2
			mp[a[i]]=mp.get(a[i])-1
			mp[a[j]]=mp.get(a[j])-1
			i+=1
			j-=1
		print(n-cc)







if __name__ == "__main__":
	solve ()

Solution (Python):
n=int(input())
s=map(int,input().split())
import collections
d=collections.Counter(s)
d=d.most_common()
count=0

for i in d:
    if i[1]%2==0:
        count+=1

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

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

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A_s = len(set(A))
    if A_s&1: print(A_s)
    else: print(A_s - 1)

if __name__ == '__main__':
    main()

Solution (Python):

N = int(input())

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

A.sort()

num = 0

for i in range(N-1):

    if A[i] == A[i+1]:
        num += 1

if num % 2 == 0:
    print (N - num)

else:
    print (N - num - 1)

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)
    
    m = sum([v for v in c.values()])
    cl = len([c for c in c.keys()])

    while(m > cl):
        m -= 2
    
    print(m)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    
    
    
    m = sum([v for v in c.values()])
    cl = len([c for c in c.keys()])

    while(m > cl):
        m -= 2
    
    
    
    
    
    
    print(m)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
import collections
n = int(input())
list_a = list(map(int, input().split(" ")))
count = collections.Counter(list_a)

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

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

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

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

Solution (Python):
from collections import Counter

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

A = Counter(A)

cnt = 0
for num in A.values():
    cnt += num-1

print(len(A.keys()) - cnt % 2)

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = Counter(a)
res = 0
for v in cnt.values():
    if v - 1 > 0:
        res += v - 1
if res % 2:
    print(len(cnt)-1)
else:
    print(len(cnt))

Solution (Python):
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)
if len(tmp)%2==0:
    print(len(tmp)-1)
else:
    print(len(tmp))

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

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

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

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

s = len(set(lst))
print ((s - 1)//2 * 2 + 1)

Solution (Python):
from collections import Counter

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

C = Counter(lst)
odd = 0
even = 0
for c in C:
    if C[c] % 2 == 0:
        even += 1
    else:
        odd += 1

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

Solution (Python):
import collections

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

C = collections.Counter(A).values()

even = 0
for c in C:
    if c % 2 == 0:
        even += 1

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

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

count = [0] * (max(A)+1)
for i in range(len(A)):
    count[A[i]] += 1

ans = 0

for i in range(max(A)+1):
    if count[i] >= 2:
        ans += count[i] - 1

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

Solution (Python):
import collections

n = int(input())
ls = list(map(int, input().split()))
counter = collections.Counter()
for x in ls:
    counter[x] += 1
print(
    len(counter.keys()) -
    len(list(filter(lambda x: x % 2 == 0, counter.values()))) % 2)

Solution (Python):
import collections

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

card = [0, 0]
for x in list(A.keys()):
    if A[x] % 2 != 0:
        card[0] += 1
    else:
        card[1] += 1

print(card[0] + card[1] - card[1] % 2)

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


if __name__ == "__main__":
    resolve()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
s = len(set(A))
if not (n - s) % 2:
    print(s)
else:
    print(s - 1)

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

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

counter = Counter(A)

values = []
for value in counter.values():
    if value >= 2 and value % 2 == 0:
        values.append(2)
    elif value >= 2 and value % 2 == 1:
        values.append(1)
    else:
        values.append(1)

sec_count = Counter(values)
if sec_count[2] % 2 == 0:
    print(len(values))
else:
    print(len(values) - 1)

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

A.sort()
C = [0] * (max(A)+1)

for i in range(n):
    C[A[i]] += 1

ans = 0
for i in range(len(C)):
    ans += max(0, C[i]-1)

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

Solution (Python):
import sys
input = sys.stdin.readline

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

    dic = {}
    tmp = 0
    for num in a:
        if num in dic:
            dic[num] += 1
            tmp += 1
        else:
            dic[num] = 1
    
    print(N - tmp - int(tmp&1))

if __name__ == "__main__":
    main()

Solution (Python):
from heapq import heappush, heappop, heapify

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

counter = {}
for a in A:
    counter[a] = counter.get(a,0)+1

heap = [(-c, a) for a, c in counter.items()]
heapify(heap)
cnt = 0

while -heap[0][0] >= 2:
    cnt+=1
    c, a = heappop(heap)
    c = -c
    
    if c == 2:
        
        
        c1, a1 = heappop(heap)
        c1 = -c1
        heappush(heap, (-(c-1), a))
        if c1-1:
            heappush(heap, (-(c1-1), a1))
    else:
        heappush(heap, (-(c-2), a))
print(len(heap))

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

A = sorted(A)

tmp = 1
Gtmp = 0
Ktmp = 0

for i in range(N-1):
    if A[i] == A[i+1]:
        tmp += 1
    elif tmp % 2 == 0:
        Gtmp += 1
        tmp = 1
    else:
        Ktmp += 1
        tmp = 1
if tmp % 2 == 0:
    Gtmp += 1
else:
    Ktmp += 1

ans = Ktmp + Gtmp - Gtmp % 2

print(ans)

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

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)

for i in range(N):
    d[A[i]] += 1

def func(v):
    if v < 3:
        return v
    a = v//3 + v%3

    return func(a)

ans = 0
se = 0
dd = [0 for i in range(3)]
for k, v in d.items():
    value = v // 3 + (v % 3)
    value = func(v)
    
    if value % 3 == 0 or value % 3 == 1:
        ans += 1
    else:
        se += 1

print(ans + ((se//2)*2))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
k=[0]*max(a)
for i in range(n):
	k[a[i]-1]+=1
ans=0
b=0
for i in range(max(a)):
	if k[i]%2!=0:
		ans+=1
	elif k[i]!=0:
		b+=1
if b%2==0:
	ans+=b
else:
	ans+=b-1
print(ans)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]
num = [0]*(10**5+1)
for i in A:
    num[i] += 1

doub = 0
for i in num:
    if i > 0:
        doub += i-1

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

Solution (Python):
def main():

    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    dup = 0
    prev = 0
    for i in range(N):
        if A[i] == prev:
            dup += 1
        prev = A[i]
    if dup % 2 == 0:
        return N-dup
    else:
        return N-dup-1


if __name__ == '__main__':
    print(main())

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


n1 = n2 = 0
for k, v in d.items():
    if v >= 3:
        if v % 2 == 0:
            d[k] = 2
        else:
            d[k] = 1

    if d[k] == 1:
        n1 += 1
    else:
        n2 += 1



n1 += n2 - n2 % 2
n2 = n2 % 2

ans = n1

print(n1)

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
D={}
for i in a_list:
    if not i in D:
        D[i]=1
    else:
        D[i]+=1
count=0
for i in D:
    count+=1
r=n-count
if r%2==0:
    print(count)
else:
    print(count-1)

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

Solution (Python):
n=int(input())
a=[int(j) for j in input().split()]
tmp=len(set(a))
while n>tmp:
    n-=2
print(n)

Solution (Python):
from collections import Counter
from operator import itemgetter

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

B = list(Counter(A).items())
B.sort(key=itemgetter(0))

c = 0
even = False
for k, v in B:
    if v % 2 == 1:
        c += 1
    else:
        if even == True:
            c += 2
            even = False
        else:
            even = True
print(c)