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

def resolve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    import collections
    cnter = collections.Counter(A)
    
    evens = 0
    for i in cnter.values():
        if i%2 == 0:
            evens += 1
    print(len(cnter)-1 if evens%2==1 else len(cnter))


if __name__ == '__main__':
    resolve()

Solution (Python):
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    e = 0
    o = 0
    for v in c.values():
        if v % 2 == 0:
            e += 1
        else:
            o += 1
    if e % 2 != 0:
        e -= 1
    print(o + e)


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=dict()
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
p=0
k=0
for i in d.values():
    p+=i//2
    k-=i%2-1
print(n-(p-k//2)*2)

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

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    n_odd, n_even = 0, 0
    for c in counter.values():
        if c % 2 == 0:
            n_even += 1
        else:
            n_odd += 1
    print(n_odd + (n_even // 2) * 2)


if __name__ == '__main__':
    main()

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

dic = DD(int)
for a in A:
  dic[a] += 1
  
ans = 0
remain = 0
for k,v in dic.items():
  ans += 1
  remain += v-1
  
print(ans-remain%2)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(1, len(a)):
  if a[i] == a[i - 1]:
    ans += 1
print(n - (ans + 1) // 2 * 2)

Solution (Python):

import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
most = c.most_common()
ans = len(most)
eaten = 0
for t in most:
    if t[1] != 1:
        eaten += t[1]-1
if eaten%2 == 1:
    print(ans-1)
else:
    print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n=I()
lis=LI()
c=Counter(lis)
sm=0
for i in c.keys():
    sm+=c[i]-1
if sm%2==0:
    print(len(list(c)))
else:
    print(len(list(c))-1)

Solution (Python):
from sys import stdin
from collections import Counter
def main():
    
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    ans=n
    cnt_two=0
    for key in c.keys():
        if c[key]>=3:
            if c[key]%2==1:
                ans-=c[key]-1
                c[key]=1
            else:
                ans-=c[key]-2
                c[key]=2
                cnt_two+=1
        elif c[key]==2:
            cnt_two+=1

    if cnt_two%2==0:
        ans-=cnt_two
    else:
        ans-=cnt_two-1
        ans-=2

    print(ans)

if __name__=="__main__":
    main()

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

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = dict(Counter(A))
kaburi = 0
for key in d:
  kaburi += d[key]-1
  
print(N - (kaburi%2 + kaburi))

Solution (Python):

import sys
input = sys.stdin.readline









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

from collections import Counter
L = len(Counter(A))




if L%2==0:
    print(L-1)

else:
    print(L)

Solution (Python):
from collections import Counter
 
N = int(input())
A = sorted(list(map(int,input().split())))
 
edible = sum(i-1 for i in Counter(A).values())
print(len(set(A))-edible%2)

Solution (Python):
from collections import Counter

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

edible = sum(i-1 for i in Counter(A).values())
print(len(set(A))-edible%2)

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

Solution (Python):


import sys




















from itertools import groupby                









def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    L.sort()
    ans = n
    two_cnt = 0
    for _, g in groupby(L):
        num = len(list(g))
        if num % 2 == 1:
            ans -= (num - 1)
        else:
            ans -= (num - 2)
            two_cnt += 1
    if two_cnt % 2 == 0:
        ans -= two_cnt
    else:
        ans -= (two_cnt - 1)
        ans -= 2
    print(ans)






if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

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

na = len(set(a))
cnt = Counter(a)
ls = cnt.most_common()
lst = [ 2 for i in ls if i[1]%2==0]

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

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

from collections import Counter

def check(counter, A):
    return len(counter) != len(A)

def Main(N, A):
    counter = Counter(A)
    lenC = len(counter)
    remains = N-lenC
    if remains%2 == 0:
        return lenC
    else:
        return lenC-1
    
          
print(Main(N, A))

Solution (Python):
def abc053_d():
    _ = int(input())
    A = list(map(int, input().split()))
    ans = 0
    from collections import Counter
    multi_even = 0
    for _, v in Counter(A).items():
        ans += 1
        if 2 <= v and v % 2 == 0:
            multi_even += 1
    if 0 < multi_even and multi_even % 2 == 1:
        ans -= 1
    print(ans)

abc053_d()

Solution (Python):
from collections import Counter

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

c = Counter(A)
eat = 0
for v in c.most_common():
  if v[1] >= 2:
    eat += v[1] - 1

if eat % 2 != 0:
  eat += 1
  
print(N-eat)

Solution (Python):

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cnt = Counter(A).most_common()
even = 0
for k, v in cnt:
    if v % 2 == 0:
        even += 1
print(len(set(A)) - even % 2)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d={}
for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=0
s=sum(d.values())
if s%2==0:
  print(n-s)
else:
  print(n-s-1)

Solution (Python):
from collections import defaultdict
import heapq
N=int(input())
alist=list(map(int,input().split()))

adic=defaultdict(int)
for a in alist:
  adic[a]+=1
  
hq=[]
for k,b in adic.items():
  heapq.heappush(hq,(-b,k))


cnt=0
while True:
  mf,n=heapq.heappop(hq)
  if mf==-1:
    break
  elif mf<=-3:
    heapq.heappush(hq,(mf+2,n))
    cnt+=1
  else:
    mf2,n2=heapq.heappop(hq)
    if mf2==-1:
      cnt+=1
      break
    else:
      heapq.heappush(hq,(mf+1,n))
      cnt+=1
    
print(N-2*cnt)

Solution (Python):
N = int(input())
cnt = [0] * (10 ** 5 + 1)
A = [int(_) for _ in input().split()]
for i in range(N):
    cnt[A[i]] += 1
m = 0
for i in range(10 ** 5 + 1):
    if cnt[i] > 0 and cnt[i] % 2 == 0:
        m += 1
print(len(set(A)) - int(m % 2 == 1))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
nums = [int(e) for e in input().split()]
nums.sort()
checker = nums[0]
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)

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

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
len_set = len(list(set(A)))
CA = Counter(A)
count = 0
for i,j in CA.items():
  if j%2 == 0:
    count += 1

if count%2 == 0:
  ans = len_set
else:
  ans = len_set - 1

print(ans)

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

kind = set(a)
num = len(kind)

diff = n - num
div = (diff - 1) // 2

ans = n - 2 * (div + 1)
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]

from collections import defaultdict 


N = ii()
A = li()

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

flag = 0
cnt = 0
for key, value in d.items():
    if value > 1:
        flag = (flag + value - 1) % 2
    cnt += 1

print(cnt-flag)

Solution (Python):
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    c = Counter(A)
    cnt = 0
    for key, val in c.items():
        if val > 2:
            if val % 2 == 0:
                c[key] = 2
                cnt += 1
            else:
                c[key] = 1
        elif val == 2:
            cnt += 1
    
    if cnt % 2 == 0:
        print(len(c))
    else:
        print(len(c) - 1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    c = Counter(A)
    for key, val in c.items():
        if val > 2:
            if val % 2 == 0:
                c[key] = 2
            else:
                c[key] = 1
    
    if len([val for key, val in c.items() if c[key] == 2]) % 2 == 0:
        print(len(c))
    else:
        print(len(c) - 1)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
import collections
co = collections.Counter(map(int,input().split()))
r = 0
for cnt in co.values():
    r+=cnt-1
if r%2==0:
    print(n-r)
else:
    print(n-r-1)

Solution (Python):
n = input()
a = set(input().split())

print(len(a) - (len(a)%2==0))

Solution (Python):
input();k=len(set(input().split()));print(k-1+k%2)

Solution (Python):
from collections import Counter

n = int(input())
m = sum(v - 1 for v in Counter([int(i) for i in input().split()]).values())
print(n - round(m + 0.5))

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

Solution (Python):
from collections import Counter
n = int(input())
A = sorted(list(map(int,input().split())))
c = list(Counter(A).values())
ans = len(c)
d = [i-1 for i in c]
print(ans if sum(d)%2==0 else ans-1)

Solution (Python):
from collections import Counter

N, *A = map(int, open(0).read().split())

ctr = Counter(A)
c0 = 0
c1 = 0
for v in ctr.values():
    if v % 2 == 0:
        c0 += 1
    else:
        c1 += 1

print(c1 + c0 - c0 % 2)

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

Blist = set(Alist)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
sa=set(a)
for i in a:
  d[i]+=1
for j in range(len(d)):
  if d[j]>2 and d[j]%2==0:
    d[j]=2
  elif d[j]>2 and d[j]%2!=0:
    d[j]=1
ni=d.count(2)
if ni%2==0:
  print(len(sa))
else:
  print(len(sa)-1)

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


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


sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Cnt = Counter(A)
    V = list(Cnt.values())
    heap = []
    for v in V:
        heapq.heappush(heap, -1 * v)
    if len(heap) == 1:
        print(1)
        return
    while heap:
        a = heapq.heappop(heap)
        if a == -1:
            print(-1 * sum(heap) + 1)
            return
        b = heapq.heappop(heap)
        heapq.heappush(heap, a + 1)
        heapq.heappush(heap, b + 1)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

x = int(input())
a = list(map(int,input().split()))
c = Counter(a)
t = c.most_common()
d = 0
l = len(set(a))
for i in range(l):
    if t[i][1]>1:
        d+=t[i][1]-1
ans = l-d%2
print(ans)

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

Solution (Python):
from collections import Counter
from functools import reduce

if __name__ == "__main__":
    N = int(input())
    arr = map(int, input().split())

    dic = Counter(arr)
    count = len(dic) - reduce(lambda sum, item: sum + 1, filter(lambda x: x % 2 == 0, dic.values()), 0) % 2
    print(count)

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

Solution (Python):
from collections import defaultdict

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

ans = n
data = defaultdict(int)
for i in range(n):
    data[a[i]] += 1
    if data[a[i]] >= 2:
        ans -= 1
print(ans if ans % 2 == 1 else ans - 1)

Solution (Python):
from collections import defaultdict as dd
from functools import reduce

if __name__ == "__main__":
    N = int(input())
    arr = map(int, input().split())

    dic = dd(int)

    for el in arr:
        dic[el] += 1

    count = len(dic) - len(list(filter(lambda x: x %
                                       2 == 0, dic.values()))) % 2
    print(count)

Solution (Python):
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
checker = nums[0]
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)

Solution (Python):
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
checker = nums[0]
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)

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

import collections
c=collections.Counter(a)
C=c.most_common()

even=0
for i in range(len(C)):
    p,q=C[i]
    if q%2==0:
        even += 1
if even%2==0:
    print(len(C))
else:
    print(len(C)-1)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    print(N+(len(set(A))-N)//2*2)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
ans = len(set(a))
s = 0
cnt = 1
pre = 0
a.append(10**9)
for x in a:
    if x != pre:
        s += (cnt+1)%2
        cnt = 1
        pre = x
    else:
        cnt += 1
s %= 2
print(ans-s)

Solution (Python):
n=int(input())
from collections import Counter as co
l=co(list(map(int,input().split()))).values()
ans=0
p=0

for i in l:
  if (i-1)%2==0:ans+=1
  else:p+=1
print(ans+p//2*2)

Solution (Python):
from collections import Counter
_ = input()
c = Counter(input().split())
ttl = 0
cnt = 0
for value in c.values():
    ttl += (value+1)%2
    cnt += 1
print(cnt - ttl%2)

Solution (Python):

import io
data = int(input())
array = list(map(int, input().split()))
strings = len(set(array))
if data % 2 == strings % 2:
    print(strings)
else:
    print(strings - 1)

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

list_B = l.values()

value_1 = 0
value_2 = 0
value_0 = 0

for num in list_B:
    a = num
    while True:
        a = a % 3 + a // 3
        if a < 3:
            break
    if a == 2:
        value_2 += 1
    elif a == 1:
        value_1 += 1
    else:
        value_0 += 1

ans = value_1 + 2*(value_2//2) + value_0

print(ans)

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

for a in A:
    if a in counter:
        counter[a] += 1
    else:
        counter[a] = 1

one, two = 0, 0
for c in counter:
    if counter[c] % 2 == 0:
        two += 1
    else:
        one += 1

print(one + two - (two % 2))

Solution (Python):
from collections import Counter


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

COUNTS = Counter(A)

x = sum(count - 1 for count in COUNTS.values())
if x % 2 == 1:
    x += 1

print(n - x)

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

dif = N - len(kinds)
if dif % 2 == 0:
    print(len(kinds))
else:
    print(len(kinds) - 1)

Solution (Python):
n = int(input())
ai = [int(i) for i in input().split()]

ans = len(set(ai))

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

Solution (Python):
import collections
N=int(input())
A=list(map(int,input().split()))
"""
c=collections.Counter(A)
values=list(c.values())	
for i in range(len(values)):
    values[i]=(values[i]-1)%2
print(len(values)-sum(values)%2)
"""



print(len(set(A))-(len(set(A))+1)%2)

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

c=collections.Counter(A)
values=list(c.values())	
for i in range(len(values)):
    values[i]=(values[i]-1)%2
print(len(values)-sum(values)%2)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 != 0:
    print(s)
else:
    print(s-1)

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

result={}
for i in range (0,len(S)):
    item = S[i]
    if item in result:
        result[item] = result[item]+1
    else:
        result[item] = 1

a = [k for k, v in result.items()]

h = []
for i in a:
    h.append(result[i]-1)

h.sort(reverse=True)

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

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

Solution (Python):
from collections import Counter
input()
A=list(map(int,input().split()))
c=Counter(A)
lenc=len(c)
print(lenc-1 if lenc&1==0 else lenc)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
M=N
for k in range(N-1):
    if A[k]==A[k+1] and A[k]!=0:
        for j in range(M-1,k+1,-1):
            if A[j]==A[j-1] and A[j]!=0:
                A[j]=0
                A[k]=0
                M=j
                break
count=0
dcount=0
for k in range(len(A)):
    if A[k]!=0:
        count+=1
for k in range(len(A)-1):
    if A[k]==A[k+1] and A[k]!=0:
        dcount+=2
print(count-dcount)

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

import collections
C = collections.Counter(A)

t = 0
for i in C:
    t += C[i] - 1
if t % 2 == 0:
    print(len(C))
else:
    print(len(C) - 1)

Solution (Python):
from collections import defaultdict

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

m = len(set(a))
d = defaultdict(int)
for v in a:
    d[v] += 1

cnt = 0
for v in set(a):
    if d[v] % 2 == 0:
        cnt += 1
if cnt % 2 == 1:
    m -= 1
print(m)

Solution (Python):
n = input()
n = int(n)
ss = input().split()
sslist = sorted(ss)

dic_ss = {}
for x in sslist:
  dic_ss.setdefault(x,0)
  dic_ss[x] += 1


for key, value in dic_ss.items():
  while value >= 3:
    value -= 2
  dic_ss[key] = value


key1 = None
key2 = None
for key, value in dic_ss.items():
  if key1 == None and value == 2:
    key1 = key
  elif key2 == None and value == 2:
    key2 = key
  if key1 != None and key2 != None:
    dic_ss[key1] = 1
    dic_ss[key2] = 1
    key1 = None
    key2 = None


count = len(dic_ss)
for key, value in dic_ss.items():
  if value > 1:
    count -= 1
print(count)

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools


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

c = Counter(A)
ans = len(c.keys())

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

Solution (Python):
N = int(input())
card = list(map(int, input().split()))
dic = {}
for i in card:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for value in dic.values():
    if value > 1:
        ans += value - 1
print(N-(ans+(ans % 2)))

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

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

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

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

Solution (Python):

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

A.sort()

count = 0
old = -1
for a in A:
    if old != a:
        count+=1
        old = a

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

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

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

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

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

memo = [0]*100000

for i in t:
    memo[i-1] += 1

sa = 0

for j in memo:
    if 1<j:
        sa += j-1

print(n-sa-sa%2)

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

Solution (Python):

from collections import Counter
def inputlist(): return [int(j) for j in input().split()]

N = int(input())
A = inputlist()
c = Counter(A)
key = c.keys()
count = 0
for i in key:
    count += c[i]-1
l = len(set(A))
if count % 2 == 1:
    l-=1
print(l)

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

b = [0]*10**5

for i in a:
    b[i] += 1
ans = 0
c = 0
for i in range(10**5):
    if b[i] == 0:
        continue
    if b[i] == 1:
        ans +=1
    elif b[i] % 2 == 0:
        c += 1
    elif b[i] % 2 == 1:
        ans +=1
        
d = c % 2
if d == 1:
    ans -=1
print(ans + c)

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

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

set_a = set(a)
k = len(set_a)

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

else:
    print(k)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

B = [0] * 100001
for a in A:
    B[a] += 1
cnt1 = 0
ans = 0
for b in B:
    if b > 1 and b % 2 == 0:
        cnt1 += 1
    if b > 0:
        ans += 1
if cnt1 % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
import math

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

CARD = 10**5+1

num = [0] * CARD
for i in a:
    num[i] += 1

ans = 0
cnt = 0
for i in range(CARD):
    while num[i] > 2:
        ans += 2
        num[i] -= 2
    if num[i] == 2:
        cnt += 1
ans += math.ceil(cnt/2) * 2
print(n-ans)

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

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

a_dict = {}

for a in a_list:
    if a not in a_dict:
        a_dict[a] = 1
    else:
        a_dict[a] += 1

values = list(a_dict.values())
double = sum(values) - len(values)


print(len(a_list) - (double//2 + double%2)*2)

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

ans = len(set(A))-(len(A)-len(set(A)))%2

print(ans)

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

Solution (Python):

def rle(l):
    ret = []
    n = len(l)
    cnt = 1
    for i in range(1,n):
        if l[i - 1] == l[i]:
            cnt+=1
        else:
            ret.append([l[i - 1],cnt])
            cnt = 1
        if i == n - 1:
            ret.append([l[i],cnt])
    return ret

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

a.sort()

ans = n

r = rle(a)

for i in range(len(r)):
    if r[i][1] % 2 == 0:
        ans-=r[i][1]
        if i != len(r) - 1:
            r[i + 1][1]-=1
    else:
        ans-=r[i][1] - 1
print(ans)

Solution (Python):

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

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