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=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)

Solution (Python):

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans = len(set(A))  
    
    ans -= (N - ans) % 2
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque


args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

from collections import Counter


def main():
    N = input(int)
    A = input([int, N])

    cnt = Counter(A).values()
    
    cnt = [1 if c % 2 else c for c in cnt]
    
    cnt = [2 if c % 2 == 0 else c for c in cnt]

    print(len(cnt) - cnt.count(2) % 2)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    A.sort()
    dic = {}
    
    for i,val in enumerate(A):
        if val in dic:
            dic[val] += 1
        else:
            dic[val] = 1
            
    delet = []
    for k, v in dic.items():
        if v > 1:
            tmp = v - 1
            for _ in range(tmp):
                delet.append(k)
                
    tmp = -(-len(delet) // 2)
    ans = N
    ans = ans - (tmp * 2)
        
    print(ans)
    
            
            
if __name__ == "__main__":
	main()

Solution (Python):

import sys
from collections import Counter
INF = float("inf")


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    daburi = 0
    for k in c:
        if c[k] % 2 == 1:
            c[k] = 1
        elif c[k] % 2 == 0:
            c[k] = 2
            daburi += 1
    if daburi % 2 == 1:
        print(len(c)-1)
    else:
        print(len(c))

    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())
As = list(map(int, input().split()))
ss = set(As)
r = len(ss) if len(ss)%2 == 1 else len(ss)-1
print(r)

Solution (Python):
from collections import defaultdict
def main():
    n = int(input())
    ls = list(input().split())
    dc = defaultdict(int)
    for i in ls:
        dc[i] += 1
    cnt1 = 0
    cnt2 = 0

    for i in dc.values():
        if i%2==1:
            cnt1 += 1
        else:
            cnt2 += 1
    if cnt2%2==0:
        print(cnt1+cnt2)
    else:
        print(cnt1+cnt2-1)
    

    
if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
num_list = sorted([ int(v) for v in input().split() ])
count_list = [0 for i in range(10**5+1)]

for i in num_list:
    count_list[i] += 1

def eating(x):
    if x % 2 == 0:
        return 2
    else:
        return 1
count_list = [ eating(i) for i in count_list if i > 0 ]


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

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return


def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, num)
    print(z-a+1)
    return


def C():
    x = II()
    print(x // 11 * 2 + (x % 11) // 7 + (x % 11 != 0))
    return


def D():
    n = II()
    x = LI()
    print(len(set(x)) - (n - len(set(x))) % 2)
    return


if __name__ == '__main__':
    D()

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
MAX_A = 10**5
dp = [0] * (MAX_A + 1)
for i in range(N):
    dp[A[i]] += 1

tmp = 0
for j in range(MAX_A + 1):
    if dp[j] > 0:
        tmp += dp[j] - 1
tmp += tmp % 2
print(N - tmp)

Solution (Python):
from collections import defaultdict

n=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
c=0
for i in range(n):
    d[a[i]]+=1
    if d[a[i]]>2:d[a[i]]-=2;c+=1
e=[x[1] for x in sorted(d.items(),key=lambda x:x[0])]
c+=(e.count(2)+1)//2
print(n-c*2)

Solution (Python):
import collections

N = int(input())
A = sorted(list(map(int, input().split())))
C = collections.Counter(A)
k = len(collections.Counter(A).keys())
if k % 2 == 1:
    print(k)
else:
    print(k - 1)

Solution (Python):
N = int(input())
A_arr = [int(x) for x in input().split()]

A_set = set(A_arr)
ans = len(A_set)
if ans%2 == 0:
    ans -= 1
print(ans)

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]


from collections import Counter

c = Counter(a)

two = 0
ans  = n
for x in c:
    i = c[x]
    while i > 2:
        i -= 2
        ans -= 2
    if i == 2:
        two += 1

ans -= (two+1)//2*2

print(ans)

Solution (Python):
_ = input()
A = set(map(int, input().strip().split(' ')))
print(len(A)-(len(A)%2==0))

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

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import Counter


n = getN()
nums = getList()
ans = n
muda = 0
ans = 0

for k, v in Counter(nums).items():
    
    if v >= 2:
        muda += v -1
    ans += 1

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

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

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0] * 100001
for x in A:
  B[x] += 1
for i in range(len(B)):
  if B[i] >= 3:
    B[i] = 2 if B[i] % 2 == 0 else 1
t = B.count(2)
nz = B.count(1) + t
if t % 2 == 1:
  nz -= 1
print(nz)

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

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

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

a2 = {}
for i in a:
    a2.setdefault(i, 0)
    a2[i] += 1
for i in a2.keys():
    a2[i] = (a2[i] - 1) % 2 + 1
total = sum(a2.values())
num = list(a2.values()).count(2)
total -= ((num - 1) // 2 + 1) * 2
print(total)

Solution (Python):

from collections import Counter
import math

def main():
    num = int(input())
    data = list(map(int, input().split()))
    count_num = Counter(data)

    overlap_num = 0
    for ele, value in count_num.items():
        if value > 1:
            overlap_num += value - 1

    ans = num - math.ceil(overlap_num / 2) * 2
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
from collections import*
from heapq import*
n,*a=map(int,open(0).read().split())
q=[-t for t in Counter(a).values()]
heapify(q)
while q[0]<-1:
    p=heappop(q)
    if p<-2:
        heappush(q,p+2)
    else:
        heappush(q,p+1)
        r=heappop(q)
        if r<-1:
            heappush(q,r+1)
print(len(q))

Solution (Python):
from collections import*
from heapq import*
n,*a=map(int,open(0).read().split())
q=[-t for t in Counter(a).values()]
heapify(q)
while q[0]<-1:
    p=heappop(q)
    if p<-2:
        heappush(q,p+2)
    else:
        heappush(q,p+1)
        r=heappop(q)
        if r<-1:
            heappush(q,r+1)
print(len(q))

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


cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e:
    if s in cnt:
      if cnt[s] <= 1:
        break
    else:
      break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)

Solution (Python):
def abc053c(cards):
    counts = {}
    for card in cards:
        if card not in counts:
            counts[card] = 0
        counts[card] = counts[card] + 1
    
    for card in counts:
        if counts[card] > 2:
            counts[card] = 2 - (counts[card] % 2)

    len_counts = len(counts.keys())
    dup_cards = len(list(card for card in counts if counts[card] > 1))
    return len_counts - (dup_cards % 2)


if __name__ == '__main__':
    _ = input()
    a = map(int, input().split(" "))
    print(abc053c(a))

Solution (Python):
N = int(input())
*A, = map(int,input().split())
c = {}
for a in A:c[a] = c.get(a,0)+1
print(len(c) - sum(v-1 for v in c.values())%2)

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    s = set()
    for a in A:
        s.add(a)
    num = len(s)
    ret = num - (num + 1) % 2
    print(ret)
    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 = [int(i) for i in input().split()]

l = len(set(A))
print(l - (N - l) % 2)

Solution (Python):
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) % 2
        break
else :
    ret -= s % 2
        
print(ret)

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

R = {}
for i in A:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = len(R)

print(ans - (1 - (ans % 2)))

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

set_A = set(A)

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

Solution (Python):
from collections import Counter
import sys
sys.setrecursionlimit(100001)
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
cnt = 0
for key in C:
    if C[key] % 2:
        ans += 1
    else:
        cnt += 1
        ans += 1
print(ans - cnt % 2)

Solution (Python):


def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    return n, alist


def submit():
    n, alist = read_input()

    count = {}
    count_t = 0
    for a in alist:
        if a not in count.keys():
            count[a] = False
        else:
            count[a] = not count[a]
            if count[a]:
                count_t += 1
            else:
                count_t -= 1

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




if __name__ == '__main__':
    submit()

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

c = np.bincount(A)

useless = c[c >= 2]
sub = useless.sum() - len(useless)
print(N - math.ceil(sub / 2) * 2)

Solution (Python):
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(lambda:0)

double = 0
for i in range(N):
    d[A[i]] += 1
    if d[A[i]] != 1:
        double += 1

if double%2==0:
    ans = N-double
else:
    ans = N-double-1

print(ans)

Solution (Python):
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a=list(input().split())
    b = n - len(set(a))
    b = b if b % 2 == 0 else b + 1
    print(n - b)
main()

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    len_set = len(set(A))
    print([len_set-1,len_set][(N-len_set) % 2 == 0])
    
if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
c=[0]*100000
count=0

a=list(map(int,input().split()))
for i in range(n):
    c[a[i]-1]+=1
    if c[a[i]-1]>1:
        count+=1

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

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

  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())

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
from collections import defaultdict
cnt=defaultdict(int)
for a in A:
    cnt[a]+=1
ans,two=0,0
for k,v in cnt.items():
    if v%2==1:
        ans+=1
    else:
        two+=1
        ans+=1
if two%2==1:
    ans-=1
print(ans)

Solution (Python):
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):
    while count > 3:
        q, mod = divmod(count, 3)
        count = q + mod
    if (count == 2):
        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)

Solution (Python):

N=input()
A=map(int,raw_input().split())
A.sort()
E=[False]*N

i=0;j=N-1
while i<j:
    if A[i]!=A[i+1]:
        i+=1
        continue
    if A[j]!=A[j-1]:
        j-=1
        continue
    E[i]=E[j]=True
    i+=1;j-=1
ans=0
for e in E:
    if not e:ans+=1
print(ans)

Solution (Python):
import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right

 
def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
A = l_inpl()
d = defaultdict(int)

for Ai in A:
    d[Ai] += 1

for k, v in d.items():
    while v > 2:
        v -= 2
    d[k] = v

print(len(d) - (len([v for v in d.values() if v == 2])%2 == 1))

Solution (Python):
import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right

 
def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
A = l_inpl()
d = defaultdict(int)

for Ai in A:
    d[Ai] += 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()))
dict1 = {}
for i in range(N):
  if A[i] not in dict1.keys():
    dict1[A[i]] = 0
  else:
    dict1[A[i]] += 1
value1 = []
for value in dict1.values():
  value1.append(value)
value2 = sorted(value1, reverse = True)
if len(value2) != 1:
  if value2[0] - value2[1] >= sum(value2[1:]):
    print(N - (value2[0] * 2))
  else:
    if(sum(value2[0:]) % 2 == 0):
      print(len(value2))
    else:
      print(len(value2) - 1)
else:
  print(1)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

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



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

A_ = list(set(A))
if len(A_) % 2 == 1:
    ans = len(A_)
else:
    ans = max(1,len(A_)-1)

print(ans)
"""

"""

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

d = len(a) - len(ac)

ans = len(a) - d

if d%2 == 1:
    ans -= 1

print(ans)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    cnt = len(set(a))

    if (n - cnt)%2:
        cnt -= 1

    print(cnt)

solve()

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

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

a = list(map(int, input().split()))
set_a = set(a)
nums = {}
cnt = 0

for i in range(n):
    nums[a[i]] = nums.get(a[i], 0) + 1


for i in set_a:
    if nums[i] % 2 == 0:
        cnt += 1
    elif nums[i] != 1:
        cnt += 2

print(len(set_a) - cnt%2)

Solution (Python):
N = int(input())
li = [ int(it) for it in input().split() ]
import collections as col
cc = col.Counter(li)
go = []
x = 0
s = 0
for k,v in cc.items():
  go.append( [k,v] )
  s += 1
  if ( v>1 ):
    x += v-1
if ( x%2 == 0 ):
  print (s)
else:
  print (s-1)

Solution (Python):




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



if (N-x)&1:
  answer = x-1
else:
  answer = x

print(answer)

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

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

d = dict()

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

ans = 0
even = 0
for i in d.values():
    if i % 2 == 0:
        even += 1
    ans += 1

if even % 2 == 1:
    ans -= 1

print(ans)

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

d = {}
for i in range(N):
    d[a[i]] = 0

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

cnt = 0
cntt = 0
for i in d.keys():
    if d[i] % 2 == 0:
        d[i] = 2
        cntt += 1
    else:
        d[i] = 1
        cnt += 1

if cntt % 2 != 0:
    cntt -= 1

print(cnt + cntt)

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

print(k-1+(k%2))

Solution (Python):
N=int(input())
*A,=map(int,input().split())
cnt = {}
for a in A:
    cnt[a] = cnt.get(a,0)+1
keys = sorted(cnt.keys())
i = 0
j = len(keys)-1
while i <= j:
    ki,kj = keys[i],keys[j]
    if cnt[ki]<=1:
        i+=1
        continue
    if cnt[kj]<=1:
        j-=1
        continue
    cnt[ki] -= 1
    cnt[kj] -= 1
print(sum(cnt.values()))

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

C = Counter(A)
even = len([c for c in C.values() if c % 2 == 0])

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import collections

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

c = collections.Counter(an)

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

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

Solution (Python):
from collections import Counter
N = int(input())
A = Counter(list(map(int, input().split()))).items()
rest = len([a for a, n in A if n % 2 == 0])
if rest % 2 == 1:
    print(len(A) - 1)
    exit()
print(len(A))

Solution (Python):
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]

cnt = Counter(a)
double = 0
double_id = []
for key in cnt.keys():
    double += cnt[key] - 1
    if cnt[key] > 1 and key not in double_id:
        double_id.append(key)
if double == 0:
    print(len(cnt))
elif double % 2 == 1:
    print(len(cnt)-1)
elif double % 2 == 0:
    
    
    
    
    print(len(cnt))

Solution (Python):
import sys
from collections import defaultdict

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

    d = defaultdict(lambda: 0)
    for a in A:
        d[a] += 1
        if d[a] >= 3:
            d[a] -= 2

    ans = 0
    dup = 0
    for key in d.keys():
        if d[key] == 1:
            ans += 1
        else:
            dup += 1

    ans += 2 * (dup // 2)

    return ans


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

Solution (Python):
def card_eater(N: int, A: list)->int:
    d = {}
    for a in A:
        d.setdefault(a, -1)
        d[a] += 1

    exceeds = sum(v for v in d.values())

    return N - exceeds - exceeds % 2


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = card_eater(N, A)
    print(ans)

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = len((set(a)))

    if count % 2 == 0:
        count -= 1

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = len((set(a)))

    if count % 2 == 0:
        count -= 1

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
bit = [0]*pow(10,5)
for a in A:
    bit[a-1] += 1
cnt = 0
kind = 0
for b in bit:
    if b > 0:
        cnt += b-1
        kind += 1
if cnt % 2 == 0:
    ans = kind
else:
    ans = kind-1

print(ans)

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

Solution (Python):
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(suma)
    exit()
    
b = suma - lenc
if b % 2 == 0:
    print(lenc)
else:
    print(lenc - 1)

Solution (Python):


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

a.sort()


temp = 0
double = 0

for i in range(n):
    if temp != a[i]:
        temp = a[i]
    else:
        double += 1

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

Solution (Python):


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

a.sort()


temp = 0
double = 0

for i in range(n):
    if temp != a[i]:
        temp = a[i]
    else:
        double += 1

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

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

    mx = max(a)
    count = list(range(mx + 1))

    for i in range(len(count)):
        count[i] = 0
    
    for i in a:
        count[i] += 1
    
    sum = 0
    for i in range(len(count)):
        if(count[i] > 1):
            sum += count[i] - 1
    
    if(sum % 2 == 1):
        sum += 1
    
    print(n - sum)
        
    

main()

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = {}
    for a in A:
        if a not in cnt:
            cnt[a] = 0
        cnt[a] += 1
    tmp = 0
    for k in cnt:
        tmp += cnt[k] - 1
    print(N - (tmp+1)//2 * 2)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
from collections import defaultdict

N = int(input())

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





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

to_rem = 0
for vv in d.values():
    to_rem += vv - 1

to_rem_rest = to_rem % 2

ans = N - to_rem - to_rem_rest
print(ans)

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












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

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
A = Counter(a)
count = 0
ans = 0
for number in A:
    if  A[number]%2 == 0:
        count += 1
    ans += 1

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

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

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)