Problem:
 Score : 400 points    Problem Statement Snuke has decided to play a game using cards.
He has a deck consisting of N cards. On the i -th card from the top, an integer A_i is written.  He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.  Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.      Constraints  3 ≦ N ≦ 10^{5}  N is odd.  1 ≦ A_i ≦ 10^{5}  A_i is an integer.         Input The input is given from Standard Input in the following format:  N  A_1  A_2  A_3 ... A_{N}       Output Print the answer.        Sample Input 1 5
1 2 1 3 7      Sample Output 1 3  One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2 . One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1 , 3 and 7 .       Sample Input 2 15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1      Sample Output 2 7

Solution (Python):
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
c_value = list(c.values())
overflow = sum(c_value) - len(c_value)
if overflow % 2 == 0:
    print(len(c_value))
else:
    print(len(c_value) - 1)

Solution (Python):
import collections
N = int(input())
lsA = list(map(int,input().split()))
counterA = collections.Counter(lsA)
lsn = list(counterA.values())
rep = 0
even = 0
for i in lsn:
    if i % 2 ==1:
        rep += i//2
    else:
        rep += (i-1)//2
        even += 1
rep += -(-even//2)
ans = N-rep*2
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
num_map = dict()
for i in range(n):
    if a[i] not in num_map:
        num_map[a[i]] = 1
    else:
        num_map[a[i]] += 1

counter = 0
for key, value in num_map.items():
    if value % 2 == 0:
        num_map[key] = 2
        counter += 1
    else:
        num_map[key] = 1

res = len(num_map) - counter % 2
print(res)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
M = len(set(A))
from math import ceil
print(N-ceil((N-M)/2)*2)

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
even_cnt = sum([cnt%2==0 for i, cnt in c.items()])
if even_cnt % 2:
    print(len(c) - 1)
else:
    print(len(c))

Solution (Python):
from math import ceil

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


cnt=[0]*100010
lst=[]

for i in a:
  cnt[i]+=1

for i in cnt:
  if i<=1:
    continue
  
  else:
    x=i-1
    lst.append(x)

print(n-ceil(sum(lst)/2)*2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
nums = [0] * 100005
for x in a:
    nums[x] += 1
even, odd = [], []
for p in nums:
    if p % 2 == 1 and p > 1:odd.append(p)
    elif p % 2 == 0 and p > 0:even.append(p)
ans = n
for x in odd:
    ans -= x - 1
if len(even) % 2 == 1:
    ans -= 1
for x in even:
    ans -= x - 1
print(ans)

Solution (Python):
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	A.sort()
	cnt = []
	c = 0
	a = 0
	for i in range(len(A)):
		if i == 0:
			a = A[i]
			c += 1
		else:
			if A[i] == a:
				c += 1
			elif A[i] != a:
				cnt.append(c)
				c = 1
				a = A[i]
	else:
		cnt.append(c)

	cnt = list(map(lambda ct: (2 - (ct % 2)), cnt))
	evens = cnt.count(2)
	if evens % 2 == 0:
		print(len(cnt))
	else:
		print(len(cnt) - 1)

main()

Solution (Python):

url = "https://atcoder.jp//contests/abc057/tasks/abc057_d"

import collections

def main():
    n = int(input())
    cards = list(map(int, input().split()))
    c_cards = collections.Counter(cards)
    credit = 0
    r = 0

    for k in c_cards:
        surplus = c_cards[k] - 1
        r += surplus
        if c_cards[k] > 1:
            n -= surplus
            if credit > 0:
                credit = abs(credit - surplus%2)
            else:
                credit += surplus%2
            c_cards[k] -= surplus
    if credit > 0:
        n -= credit
    print(n)



if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

C = Counter(A)
C = sorted(C.items())

cc = []
for a, b in C:
    cc.append([a, b])
C = cc

M = len(C)

left = 0
right = M - 1

while True:
    if C[left][1] < 2:
        p_left = left
        for left in range(p_left, M):
            if C[left][1] > 1:
                break

    if C[right][1] < 2:
        p_right = M - right - 1
        for right in range(M):
            if C[M - right - 1][1] > 1:
                break

        right = M - right - 1

    if C[left][1] <= 1 and C[right][1] <= 1:
        break

    if left == right:
        if C[left][1] >= 3:
            C[left][1] -= 2
        else:
            f = 0
            C[left][1] -= 1
            for i in range(left + 1, M):
                if C[i][1] > 0:
                    C[i][1] -= 1
                    f = 1
                    break

            if f == 0:
                for i in range(0, left):
                    if C[i][1] > 0:
                        C[i][1] -= 1

    else:
        C[left][1] -= 1
        C[right][1] -= 1


ans = 0
for a, b in C:
    ans += b

print(ans)

Solution (Python):
from collections import Counter

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

C = Counter(A)
C = sorted(C.items())

cc = []
for a, b in C:
    cc.append([a, b])
C = cc

M = len(C)

left = 0
right = M - 1

while True:
    if C[left][1] < 2:
        p_left = left
        for left in range(p_left, M):
            if C[left][1] > 1:
                break

    if C[right][1] < 2:
        p_right = M - right - 1
        for right in range(M):
            if C[M - right - 1][1] > 1:
                break

        right = M - right - 1

    if C[left][1] <= 1 and C[right][1] <= 1:
        break

    if left == right:
        if C[left][1] >= 3:
            C[left][1] -= 2
        else:
            f = 0
            C[left][1] -= 1
            for i in range(left + 1, M):
                if C[i][1] > 0:
                    C[i][1] -= 1
                    f = 1
                    break

            if f == 0:
                for i in range(0, left):
                    if C[i][1] > 0:
                        C[i][1] -= 1

    else:
        C[left][1] -= 1
        C[right][1] -= 1


ans = 0
for a, b in C:
    ans += b

print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
cnt=[0 for _ in range(100001)]
for i in range(N):
    cnt[A[i]]=1

x=cnt.count(1)
y=N-x
if y%2==0:
    print(N-y)
else:
    print(N-y-1)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

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

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

N = ni()
A = na()
d = {}
for i in range(N):
    if A[i] not in d.keys():
        d[A[i]] = 0
    else:
        d[A[i]] += 1
s = 0
for k, v in d.items():
    s += v
if s % 2 == 0:
    print(len(d))
else:
    print(len(d) - 1)

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

d = defaultdict(int)
for i in range(N):
    if d[A[i]] == 0:
        d[A[i]] = 1
    else:
        d[A[i]] += 1




sorted_d = sorted(d.items(), key=lambda x: x[1], reverse=True)
fix_d = []
for i in range(len(sorted_d)):
    if sorted_d[i][1] >= 3:
        if sorted_d[i][1] % 2 == 0:
            
            fix_d.append([sorted_d[i][0], 2])
        else:
            
            fix_d.append([sorted_d[i][0], 1])
    else:
        fix_d.append([sorted_d[i][0], sorted_d[i][1]])

fix_d.sort(key=lambda x: x[1], reverse=True)

count = 0
for i in range(len(fix_d)):
    if fix_d[i][1] == 2:
        count += 1

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

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

B = list(set(A))

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

Solution (Python):
from collections import Counter

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

counter = Counter(cards)
ans = len(counter)
rest = 0
for num, cnt in counter.items():
    rest += (cnt - 1)

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

print(ans)

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

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

Solution (Python):
from collections import Counter


N=int(input())
A=list(map(int,input().split()))
c = Counter(A)
s = 0
for k, v in c.items():
    s += v-1
if s % 2 == 0:
    print(len(set(A)))
else:
    print(len(set(A))-1)

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

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

tmp = [0 for _ in range(10 ** 5)]
for i in range(N):
  tmp[A[i] - 1] += 1


ans = N
flag = False
for i in range(10 ** 5):
  if tmp[i] == 0:
    continue
  elif tmp[i] % 2 == 1:
    ans -= (tmp[i] - 1)
  else:
    if flag:
      ans -= (tmp[i] - 2)
      flag = False
    else:
      ans -= tmp[i]
      flag = True

print(ans)

Solution (Python):
from collections import defaultdict

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

dict=defaultdict(int)

for a in A:
  dict[a]+=1
  
num=[0]*2
for v in dict.values():
  num[v%2]+=1
  
if num[0]%2==0:
  print(sum(num))
else:
  print(sum(num)-1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(100000)]
cnt = 0
for a in A:
  if B[a-1] == 0:
    B[a-1] = 1
  else:
    cnt += 1
if cnt % 2 == 0:
  print(sum(B))
else:
  print(sum(B)-1)

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    l = i_list()
    dic = {}
    for i in l:
        dic[i] = dic.get(i,0) + 1
    t = 0
    for i,k in dic.items():
        t += k-1
    if t%2==0:
        print(len(dic))
    else:
        print(len(dic)-1)


if __name__=="__main__":
    main()

Solution (Python):
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for x in A:
    d[x] += 1
cnt = 0
for x in d:
    if d[x] >= 2 and d[x] % 2 == 0:
        cnt += 1
ans = len(d.keys())
if cnt % 2 == 1:
    ans -= 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():
    if v > 1:
        cnt += v - 1

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

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

d = {}
m = 0
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
        m += 1
print(m - 1) if (n-m) % 2 else print(m)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
count=0
temp=0
for i in ac:
    if ac[i]>=3:
        if ac[i]%2==0:
            count+=(ac[i]-2)
            ac[i]=2
        else:
            count+=(ac[i]-1)
            ac[i]=1

for j in ac:
    if ac[j]==2:
        temp+=1
if temp%2==0:
    count+=temp
else:
    count+=((temp+1))
print(n-count)

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

def count(n, Set):
    if not n in Set:
        Set.add(n)
        return 0
    else:
        return 1

Sieve = set()
extra = 0
for a in A:
    extra += count(a, Sieve)
print(N-extra if not extra&1 else N-extra-1)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
from collections import defaultdict as dd
Sieve = dd(lambda:0)
for a in A:
    Sieve[a] += 1

ans, extra = 0, 0 
for v in Sieve.values():
    ans += 1
    if v > 1 and (v-1)&1:
        extra += 1

print(ans if not extra&1 else ans-1)

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

for n in A:
  if n in z:
    z[n] += 1
  else:
    z[n] = 1

cnt_even = 0
for key, val in z.items():
  if val % 2 == 0: 
    cnt_even += 1
  
cnt_odd = len(z) - cnt_even

tot = cnt_odd + cnt_even - (cnt_even % 2)
print(tot)

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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = Counter(a)
    
    other = 0
    
    ans = n
    for k, v in a.items():
        ans -= v - 1
        if not v%2:
            other += 1
    
    ans -= other%2
        

    print(ans)
    
    
    
if __name__ == "__main__":
    main()

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

kind = len(set(a))

if (n-kind) % 2 == 0:
    ans = kind
else:
    ans =  kind - 1

print(ans)

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(10**5+1)]
for ai in a:
  x[ai] += 1
p = 0
q = 0
for xi in x:
  if xi%2 == 1:
    p += 1
  elif xi > 0:
    q += 1
if q%2 == 0:
  print(p+q)
else:
  print(p+q-1)

Solution (Python):
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A: d[a] += 1
    kind = [0] * 2
    for key in d: kind[d[key] % 2] += 1
    if kind[0] % 2 == 0:
        print(sum(kind))
    else:
        print(sum(kind) - 1)





if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
K = len(set(input().split()))
print(K+K%2-1)

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

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

Solution (Python):

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




a.sort()

from collections import Counter
a=Counter(a)
csum=0
for i,icnt in a.most_common():
    csum+=icnt-1
if csum%2==1:
    csum+=1
print(n-csum)

Solution (Python):
n,s = int(raw_input()),set(map(int, raw_input().split()))
print len(s) - (1 if (len(s) & 1 == 0) else 0)

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

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

a.sort()


l = []
i = 0
num = 1
while True:
    while i+1 < n and a[i] == a[i+1]:
        i += 1
        num += 1
    l.append(num)
    num = 1
    i += 1
    if i == n:
        break

ans = len(l)
num = 0
for i in l:
    if i % 2 == 0:
        num += 1
if num % 2 == 1:
    ans -= 1
print(ans)

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

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

Solution (Python):
N = int(input())
A = set() 
cnt = 0

def count(n, Set):
    if not n in Set:
        Set.add(n)
        return 0
    else:
        return 1
for x in input().split():
    cnt += count(x, A)
if not cnt & 1:
    ans = N - cnt
else:
    ans = N - cnt - 1
print(ans)

Solution (Python):
N = int(input())
arr = list(map(int, input().split()))
print(N-(-(-(N-len(set(arr)))//2))*2)

Solution (Python):
from collections import defaultdict
n = int(input())
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
print(len(d.keys()) - sum([1 - v % 2 for v in d.values()]) % 2)

Solution (Python):
from collections import defaultdict
n = int(input())
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
print(len(d.keys()) - sum([1 for v in d.values() if v % 2 == 0]) % 2)

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

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

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

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

Solution (Python):
from math import *
n=int(input())
a=list(map(int,input().split()))
b=set(a)
c=len(a)-len(b)
k=ceil(c/2)
print(len(a)-2*k)

Solution (Python):
import sys
import math
N = int(input())
array = list(map(int,input().split()))
set_array = set(array)

if not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()

print(len(list(set_array))) if len(list(set_array)) % 2 == 1 else print(len(list(set_array)) - 1)

Solution (Python):
def comp(n,s,a):
  cnt=1
  flag=s[0]
  for i in range(1,n):
    if flag==s[i]:cnt+=1
    else:
      flag=s[i]
      a+=[cnt]
      cnt=1
  a+=[cnt]
  return a
n=int(input())
a=sorted(list(map(int,input().split())))
b=comp(n,a,[])
l,r=0,len(b)-1
if l==r:b[0]=1
while l<r:
  while b[l]==1 and l<r:l+=1
  while b[r]==1 and l<r:r-=1
  if b[l]>1:
    b[l]-=1
    b[r]-=1
while b[l]>1:b[l]-=2
print(sum(b))

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    r = len(set(a))
    r -= (n - r)&1
    print(r)

if __name__ == '__main__':
    main()

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

from collections import Counter
cnt_a = Counter(A)

X = [0] * 3
for k, v in cnt_a.items():
    while v >= 3:
        v = (v // 3 + (v % 3))
    X[v] += 1

if X[2] % 2 == 0:
    print(X[1] + X[2])
else:
    print(X[1] - 1 + X[2])

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

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

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

rec=collections.Counter(a)
ans=0
for i in range(100001):
    if rec[i]>1:
        ans+=rec[i]-1
ans=-(-ans//2)*2
print(n-ans)

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

Solution (Python):
n = int(input())
aas = list(map(int, input().split()))
max_n = max(aas) + 1
cnts = [0]*(max_n)
for i in aas:
    cnts[i] += 1
res = 0
for i in range(max_n):
    if cnts[i] != 0:
        cnts[i] -= 1
    if cnts[i]%2 == 0:
        cnts[i] = 0
    elif cnts[i] >= 3:
        cnts[i] = 1
res = len(set(aas))
adj = sum(cnts)
print(res if adj == 0 else res-(adj%2!=0))

Solution (Python):
from collections import Counter
from itertools import groupby


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    """
    2     3
    1(-1) 1
    """
    N = read_int()
    A = read_ints()
    counter = [0]*max(A)
    for a in A:
        counter[a-1] += 1
    remove = 0
    twos = 0
    for a in counter:
        if a > 0:
            if a%2 == 0:
                remove += (a-2)
                twos += 1
            else:
                remove += (a-1)
    if twos%2 == 0:
        remove += twos
    else:
        remove += twos+1
    return N-remove


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

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

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

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

cnt = [0] * (10**5+1)
for v in a:
    cnt[v] += 1

res = 0
even = 0
for c in cnt:
    if c > 0:
        if c % 2 == 0:
            even += 1
        res += 1

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

Solution (Python):
from collections import Counter
n=int(input())
lst=list(map(int,input().split()))
c=Counter(lst)
lst=list(c.values())
ans=0
tmp=0
for i in lst:
    if i%2==1:
        ans+=1
    else:
        tmp+=1
if tmp%2==0:
    ans+=tmp
else:
    ans+=tmp-1
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
dp=[0]*(10**5+1)
bp=[]
for i in range(N):
  if dp[A[i]]!=0:
    bp.append(A[i])
  dp[A[i]]+=1
bp.sort()
p=len(bp)
q=p
o=0
for i in range(10**5):
  if p<3:
    break
  p-=2
if p==0:
  N-=q
elif p==1:
  N=N-q-1
else:
  N=N-q
print(N)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    K = len(set(A))
    if K % 2 == 1:
        ans = K
    else:
        ans = K - 1

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    counter = Counter(A)

    odd = even = 0
    for v in counter.values():
        if v % 2 == 0:
            even += 1
        else:
            odd += 1

    if even % 2 == 0:
        ans = odd + even
    else:
        ans = odd + even - 1

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

Solution (Python):
from collections import Counter
import sys

N=int(input())
cards=list(map(int,sys.stdin.readline().strip().split()))
c=Counter(cards)

even=len([x for x in iter(c) if c[x]%2==0])
odd=len([x for x in iter(c) if c[x]%2==1])

print(even-(even%2)+odd)

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


N = I()
A = LI()

from collections import Counter

c = Counter(A)

a = 0  
for i in c.keys():
    a += c[i]-1

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

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

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

Solution (Python):
import math
import collections
def main():
    n = int(input())
    A=[int(i) for i in input().split()]
    dd = collections.defaultdict(int)

    for i in A:
        dd[i]+=1
    yama = []
    for i in dd.keys():
        yama.append([i,dd[i]])

    yama.sort(key = lambda x:x[0])
    yama_l = len(yama)
    cnt=0
    renozku = False
    for i in range(yama_l-1):
        if(yama[i][1]==2 and yama[i+1][1]==2):
            renzoku = True

        if(yama[i][1]%2==0):
            cnt+=1
    if(yama[-1][1]%2==0):
        cnt+=1
    if(cnt==2 and renzoku):
        print(len(yama)-1)
    elif(cnt%2==1):
        print(len(yama)-1)
    else:
        print(len(yama))
if __name__ == '__main__':
    main()

Solution (Python):
n= int(input())
a= list(map(int,input().split()))
adict = {}
for c in a:adict[c] = adict.get(c,0) + 1
twos=0
moreodd=0
moreeven=0
for num in adict.keys():
    if adict[num]==2:twos+=1
    elif adict[num]>2:
        if adict[num]%2==0:moreeven+=1
        else:moreodd +=1
if moreeven%2==1:twos+=1
if twos%2==0:print(len(adict))
else:print(len(adict)-1)

Solution (Python):






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

def calculate(n, arr):
    dict = {}
    for i in range(n):
        if dict.get(arr[i]) == None:
            dict.__setitem__(arr[i], 1)
        else:
            tmp = dict.get(arr[i])
            dict.__setitem__(arr[i], tmp + 1)

    k1 = len(dict.keys())

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


calculate(N, ARR)

Solution (Python):
from collections import Counter

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

cnt=Counter(alst)
c2=0

for v in cnt.values():
    if v==1:
        continue

    n-=v-1
    if v%2==0:
        c2+=1

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

Solution (Python):
_ = input()
a = set(map(int,input().split()))

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

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)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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






N = getN()
A = getList()
A = Counter(A)

one = 0
two = 0
for i in A.items():
    a, b = i
    if b % 2 == 0:
        two += 1
    else:
        one += 1
ans = 0
if two % 2 == 0:
    print(one + two)
else:
    print(one + two - 1)

Solution (Python):
from collections import Counter

N,*A = map(int, open(0).read().split())
ac = Counter(A)
e = [x[0] for x in ac.items() if x[1] % 2 == 0]
if len(e) % 2 == 0:
    print(len(ac))
else:
    print(len(ac)-1)

Solution (Python):
import sys;input = lambda : sys.stdin.readline()
import collections
n = int(input())
a = sorted(list(map(int, input().split())))
d = collections.Counter(a)
need = {}
for k,v in d.items():
    if v>1:
        need[k]=v
if (sum(list(need.values()))-len(need))%2==0:
    print(len(set(a)))
else:
    print(len(set(a))-1)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num=[0]*100001
for i in a:
  num[i]+=1
x=0
for i in num:
  if i<=0:
    continue
  elif i%2==0:
    n-=i
    x+=1
  else:
    n-=i-1
    
if x%2:
  x-=1
  
print(n+x)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()
A = LIST()

A_cnt = Counter(A)
tmp = sum([x-1 for x in A_cnt.values()])

print(len(A_cnt) if tmp%2 == 0 else len(A_cnt)-1)

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

Solution (Python):
import collections
N = int(input())
AN = list(map(int,input().split()))
an = collections.Counter(AN)
a = sorted(list(an.values()),reverse=True)
al = len(a)

print(al if al%2==1 else al-1)

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

from collections import Counter
CA = Counter(A)
cu2 = 0
for k, v in CA.items():
    cu2 += v-1

print(len(A) - cu2 - cu2%2)

Solution (Python):
from collections import Counter
N  = int(input())
A = list(map(int, input().split()))
C = Counter(A)
c = 0
for k, v in C.items():
    c += v - 1
if c % 2 == 1:
    c += 1
print(N - c)

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

Solution (Python):
_,*l=map(int,open(0).read().split())
c=len(set(l))
print(c-1+c%2)

Solution (Python):
n,*l=map(int,open(0).read().split())
from collections import *
c=Counter(l)
print(len(c)-sum(1-v%2 for v in c.values())%2)

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

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

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

from collections import Counter
L = Counter(L)

cnt = 0
one = 0
for v in L.values():
    if v%2 ==0:
        cnt +=1
    else:
        one +=1
if cnt%2 == 0:
    one +=cnt
else:
    one +=(cnt-1)
print(one)

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

Solution (Python):
from collections import Counter
N=int(input())
A=sorted(map(int,input().split()))
li=[]
i=0
while(i<N):
    cnt=0
    j=i
    while(j<N and A[i]==A[j]):
        cnt+=1
        j+=1
    li.append(cnt-1)
    i=j
l=len(li)
for i in range(l):
    for j in range(i+1,l):
        if li[i]==0:
            break
        d=min(li[i],li[j])
        li[i]-=d
        li[j]-=d
for i in range(l):
    li[i]%=2
ans=len(set(A))
for i in range(l):
    ans-=li[i]
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt = Counter(a)
l = len(cnt)
even = 0
for v in cnt.values():
    if v%2 == 0: even += 1
print(l if even%2 == 0 else l-1)

Solution (Python):
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    s = len(set(a))

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


if __name__ == '__main__':
    main()

Solution (Python):


import math



from collections import deque
from collections import Counter




n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
cnt=0
for i in c:
    if c[i]%2==0:
        cnt+=1
if cnt%2==0:
    print(len(c))
else:
    print(len(c)-1)