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())
a = [1+(j-1)%2 for i, j in sorted(Counter(map(int, input().split())).items())]
result = 0
x = a.count(2)
print(len(a)-x%2)

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

Solution (Python):
import collections
N = int(input())
A=list(map(int,input().split()))
B = collections.Counter(A)
ans=N
flag=0
for i,a in enumerate(B.values()):
  
  if a==1:
    continue
  if a%2==0:
    ans-=a-1
    if flag==0:
      flag=1
    else:
      flag=0
  else:
    ans-=a-1
if flag==1:
  ans-=1
print(ans)

Solution (Python):
def main():
    """
    奇数枚の余りは1に、偶数枚の余りは2にできる
    偶数枚が偶数個余っていたら種類は減らないが、奇数個であれあ一つ種類が減る
    """
    _ = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    even = len([v for v in c.values() if v % 2 == 0])
    ans = len(c.keys())
    if even % 2 == 1:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()

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

cnt=0
surplus=0
for x in c.values():
    if x>=2 and x%2==1:
        tmp=(x-1)//2
        cnt+=2*tmp
    elif x>=2 and x%2==0:
        tmp=(x-1)//2
        cnt+=2*tmp
        surplus+=1

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

Solution (Python):
N = int(input())
A = input().split()
already = [False] * (10**5+1)
dup_count = 0
for a in A:
    a = int(a)
    if not already[a]:
        already[a] = True
    else:
        dup_count += 1

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

Solution (Python):

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

count = 0
c = collections.Counter(a)
for i in set(a):
    if c[i] > 1:
        count += c[i] - 1
if count % 2 == 0:
    print(n - count)
else:
    print(n - count - 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):

from collections import Counter
n, *a = map(int, open(0).read().split())
a = [0] + list(list(zip(*Counter(a).items()))[1]) + [1]
for i in range(len(a)-1): a[i+1] = a[i+1]+a[i]-1
ans = 0
li = len(a)-1
for i in range(1, li):
	tmp = abs(a[li]-a[i]-a[i-1])
	x = a[i]-a[i-1]
	if tmp>=x: cnt = tmp-x
	else: cnt = (x-tmp)%2
	ans = max(ans, li-1-cnt)
print(ans)

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

ans = 0
even = []

for v in A_count.values():
    if v == 1 or v % 2 != 0:
        ans += 1
    else:
        even.append(v)

m = len(even)
if m % 2 == 0:
    ans += m
else:
    ans += m-1

print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
a.sort()
b = sorted(list(set(a)))
c = Counter(a)
ans = 0
for i in b:
    ans += c[i] - 1
if ans % 2 == 1:
    ans += 1
print(n - ans)

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

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

maxcnt = len(d)
total = 0
for v, c in d.items():
    if c != 1:
        total += c - 1

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

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
t = sum(x-1 for x in d.values())
print(n - t - t%2)

Solution (Python):
import math

n = int(input())
a = list(map(int, input().split()))
a.sort()
d = []
flag = a[0]
for i in range(1, n):
    if a[i] == flag:
        d.append(a[i])
    else:
        flag = a[i]

ans = n - 2 * math.ceil(len(d) / 2)
print(ans)

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = Counter(a)
cnt = 0
for v in d.values():
    if v % 2 == 0:
        cnt += 1

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

Solution (Python):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    input()
    aa=LI()
    ac=Counter(aa)
    even=0
    for a,c in ac.items():
        if c%2==0:even+=1
    if even%2:ans=len(ac)-1
    else:ans=len(ac)
    print(ans)

main()

Solution (Python):
from functools import reduce
from fractions import gcd
from collections import defaultdict
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def cmb(n,r):
    r = min(n-r,r)
    if r < 0: return 0
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    D = defaultdict(int)
    for a in A:
        D[a] += 1
    
    res = N
    l = 0
    r = N-1
    while r-l >= 2:
        if D[A[l]] <= 1:
            l += 1
        elif D[A[r]] <= 1:
            r -= 1
        else:
            res -= 2
            D[A[l]] -= 1
            D[A[r]] -= 1
            l += 1
            r -= 1
    if D[A[l]] > 1 or D[A[r]] > 1:
        res -= 2
    
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
n= int(input())
a = list(map(int,input().split()))
now = a[0] 
a.sort()
d = {}
for x in a:
    if x not in d:d[x] = 1
    else:d[x] += 1
res = len(d)
if res%2:print(res )
else:print(res-1)

Solution (Python):
from collections import Counter
n = int(input())
a = map(int, input().split())
counter = Counter(a)
number = len(counter)
rest = 0
for i in counter.values():
    rest += i - 1
print(number - rest % 2)

Solution (Python):

n = int(input())
a = list(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)
for i in a:
    d[i]+=1
eat_cnt = 0
pair_cnt = 0
for i in d.values():
    eat_cnt+=((i-1)//2)
    pair_cnt+=(1-i%2)

eat_cnt+=(pair_cnt//2 + pair_cnt%2)
print(n-eat_cnt*2)

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

a=set(A)
base=len(A)-len(a)

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

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

cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 1
    else:
        cnt[a[i]] += 1

ans = 0
for i in cnt:
    ans += (cnt[i] - 1)
if ans % 2 == 0:
    print(n - ans)
else:
    print(n - ans - 1)

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    AK = list(set(A))
    AK.sort()
    AN = dict()
    for a in A:
        if a in AN: AN[a] += 1
        else: AN[a] = 1
    low = 0; high = len(AK) - 1
    while low < high:
        if AN[AK[low]] <= 1 and AN[AK[high]] <= 1:
            low += 1
            high -= 1
        elif AN[AK[low]] <= 1: low += 1
        elif AN[AK[high]] <= 1: high -= 1
        else:
            AN[AK[low]] -= 1
            AN[AK[high]] -= 1
    total = 0
    for key in AN: total += AN[key]
    while AN[AK[low]] > 2:
        total -= 2
        AN[AK[low]] -= 2
    if AN[AK[low]] > 1:
        total -= 2
    print(total)
    
    return 0

if __name__ == "__main__":
    solve()

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

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

from collections import Counter

c = Counter(a)

b = [0, 0] 

for i in c.values():
    if i % 2 == 0:
        b[0] += 1
    else:
        b[1] += 1

ans = b[1]

if b[0] % 2 == 0:
    ans += b[0]
else:
    ans += b[0] - 1

print(ans)

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

N = map(int, input().split())
A = list(map(int, input().split()))
counter = Counter(A)
cnt = 0
for k, v in counter.items():
    cnt += v % 2 == 0
print(len(counter) - cnt % 2)

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

L = len(set(A))

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

Solution (Python):
from collections import Counter
N = int(input())
*A, = map(int, input().split())
C = Counter(A)
dup = 0
acc = 0
k = len(C)
for c in C.values():
    acc += c
    if c > 1:
        dup += c - 1

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
l = len(set(a))
c = Counter(a)
cnt = 0
for key in c.keys():
    cnt += c[key] - 1
print(l-1 if cnt%2 else l)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    c = defaultdict(lambda :0)
    for i in a:
        c[i] += 1
    a = [[i,2-(j&1)] for (i,j) in c.items()]
    a.sort()
    s = 0
    c = 0
    for i in range(len(a)):
        if a[i][1] == 2:
            c += 1
        s += a[i][1]
    s -= c
    if c&1:
        s -= 1
    print(s)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
from collections import Counter

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

for a in A:
    cnt[a] = 1 if cnt[a] % 2 else 2

ans = len(cnt.keys()) - len([c for c in cnt.values() if c == 2]) % 2
print(ans)

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
two = 0
ans = 0
for v in C.values():
  if v%2:
    ans += 1
  else:
    two += 1
ans += two
ans -= two%2
print(ans)

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

def main():
    n = int(input())
    a = map(int, input().split())
    counter = Counter(a)
    yield sum(1 for v in counter.values() if v%2==1)
    evens = sum(1 for v in counter.values() if v%2==0)
    if evens % 2 == 0:
        yield evens
    else:
        yield evens - 1


print(sum(main()))

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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    counter = Counter(a)
    yield sum(1 for v in counter.values() if v%2==1)
    evens = sum(1 for v in counter.values() if v%2==0)
    if evens % 2 == 0:
        yield evens
    else:
        yield evens - 1


print(sum(main()))

Solution (Python):








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




if __name__ == "__main__":
    main()

Solution (Python):


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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
import itertools
a = [len(list(l)) % 2 for k, l in itertools.groupby(A)]
ans = len(a)
if len([x for x in a if x == 0]) % 2 == 1:
    ans -= 1
print(ans)

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

odd=0
even=0

for i,m in c.items():
    if m%2==1:
        odd+=1
    else:
        even+=1

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = {}
    for a in A:
        if a not in B:
            B[a] = 0
        B[a] += 1
    ans = len(B)
    print(ans - (ans + 1) % 2)


if __name__ == '__main__':
    main()

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


counts = [count-1 for k,count in c.items() if count>1]

if len(counts)>1:
  l,r = counts[0],counts[-1]
  mids = sum(counts[1:-1])
  
  if abs(l-r) > mids :
    print(len(set(A)) - (abs(l-r) - mids))
  else:
    print(len(set(A)) - (mids -abs(l-r)) %2 ) 
else:
  print(len(set(A)) - sum(counts)%2 )

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

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

count_1 = 0
count_2 = 0
for v in count_A.values():
    if v == 1:
        count_1 += 1
    elif v == 2:
        count_2 += 1
    else:
        if v % 2 == 0:
            count_2 += 1
        else:
            count_1 += 1

if count_2 % 2 == 0:
    print(count_1+ count_2)
else:
    print(count_1+ count_2-1)

Solution (Python):
import math
N = int(input())
A = list(map(int, input().split()))
li = [0] * int(1e05)
for x in A:
    li[x-1] += 1
num = 0
for x in li:
    if x > 1:
        num += (x-1)/2
print(N-2*math.ceil(num))

Solution (Python):
from collections import Counter

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

s = set(A)
c = Counter(A)
m2 = [1 if v%2==0 else 0 for v in c.values()]
if sum(m2)%2 == 0:
  print(len(s))
else:
  print(len(s)-1)

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

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

Solution (Python):

from collections import Counter, deque





import math

import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    a_kinds = len(set(a))
    a_dup = n - a_kinds

    print(n-((a_dup+1)//2)*2)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import groupby

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

A=groupby(A)
odd=0
even=0
for key,group in A:
    g=len(list(group))
    if g%2==1:
        odd+=1
    else:
        even+=1

if even%2==1:
    print(odd+even-1)
else:
    print(odd+even)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
a.sort()
b = sorted(list(set(a)))
c = Counter(a)
lenb = len(b)
d = [0 for _ in range(lenb)]
for i in range(lenb):
    d[i] = c[b[i]] - 1
t = sum(d)

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

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

cnt=Counter(a)
numofcard=len(cnt)


count=0
for i in cnt.values():
    if i==2:
        count+=1
    elif i>3 and i%2==0:
        count+=1
print(numofcard if count%2==0 else numofcard-1)

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


if __name__ == '__main__':
    solve()

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

Solution (Python):
from collections import Counter

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

c=Counter(a)

cnt=0
ans=0

for v in c.values():
  ans+=1
  if v%2==0:
    cnt+=1

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

print(ans)

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



















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

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):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

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

Solution (Python):
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict as dd
n=int(input())
a=nl()
a.sort()

d=dd(int)
for aa in a:
    d[aa]+=1
counter=0
for k,v in d.items():
    if v%2==0:
        counter+=v-1
if counter%2==0:
    print(len(d))
else:
    print(len(d)-1)

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

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

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

kv = sorted(list(C.items()))
_, nums = zip(*kv)

nums = list(nums)

l = 0
r = len(nums) - 1
adjust = 0
while l <= r:
    if l == r:
        adjust = 1 if nums[r] % 2 == 0 else 0
        nums[r] = 1
        break

    if nums[l] == 1:
        l += 1
        continue
    if nums[r] == 1:
        r -= 1
        continue

    eat = min(nums[l], nums[r]) - 1
    nums[l] -= eat
    nums[r] -= eat

ans = len(nums) - nums.count(0) - adjust
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
s = set()
count = 0
for x in A:
    if x not in s:
        s.add(x)
    else:
        count += 1

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

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    mc = c.most_common()
    ans = len(mc)
    need = 0
    for cnt in mc:
        if cnt[1] > 1:
            need += cnt[1] - 1
    print(ans if need % 2 == 0 else ans - 1)


if __name__ == '__main__':
    main()

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

M = 10**5+1
L = [0]*M
for a in A:
    L[a] += 1

ans = 0
cnt = 0
for i in range(M):
    if L[i] > 0:
        ans += 1
    if L[i] > 1 and L[i]%2 == 0:
        cnt += 1

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

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

Solution (Python):
n, *a = map(int, open(0).read().split())
a.sort()
cnt = -1
prev = a[0]
b = []
for i in a:
    if prev==i: cnt+=1
    else:
        b.append(cnt)
        cnt = 0
    prev = i
b.append(cnt)
print(n-(sum(b)+1)//2*2)

Solution (Python):
input()
print((len(set(input().split()))-1)//2*2+1)

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

Solution (Python):
from collections import Counter

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

a = list(Counter(A).values())

ans = 1
for i in a:
    if i >= 2:
        ans += i - 1
ans //= 2
ans *= 2
print(N - ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
dup=0
uniq=1
last=a[0]
for i in range(1,len(a)):
    if a[i] == last:
        dup+=1
    else:
        uniq+=1
    last=a[i]

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

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

goukei=sum(list(AC.values()))
shurui=len(AC.keys())
yobun=goukei-shurui
if yobun%2==0:
    print(shurui)
else:
    print(shurui-1)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    d = dict(Counter(v))
    ans = 0
    for val in d.values():
        if val > 1:
            ans += val - 1
    if ans % 2 == 0:
        print(n - ans)
    else:
        print(n - ans - 1)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

counter = Counter(A)

counts = counter.most_common()

dup_num = 0
for i in range(len(counts)):
    if counts[i][1] != 1:
        dup_num += counts[i][1]-1

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

Solution (Python):
from collections import Counter
N=int(input())
A = list(map(int,input().split()))
Ac = Counter(A)
kind = len(Ac)
Av = sum(i-1 for i in Ac.values() if i != 1)
if Av%2 == 0:
    print(kind)
else:
    print(kind-1)

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

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

cnt2 = 0
answer = 0
for i in range(10 ** 5 + 1):
  if cnt[i]:
    answer += 1
  if cnt[i] > 1 and cnt[i] % 2 == 0:
      cnt2 += 1
print(answer if cnt2 % 2 == 0 else answer - 1)

Solution (Python):


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

l=[0]*10**5

for item in A:
    l[item-1]+=1

ex=0
for item in l:
    ex+=max(item-1,0)

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

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

Solution (Python):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor


"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
A = {}
for i in range(N):
    a = gi()
    if a in A:
        A[a] += 1
    else:
        A[a] = 1

ec = 0
for _, v in A.items():
    if (v > 1 and v % 2 == 0):
        ec += 1
ans = len(A)

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

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

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

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

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

Solution (Python):
from collections import Counter

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

C=dict(Counter(A))

n=len(C)

r=sum([e-1 for e in C.values() if e>=2])

ans=n-r%2
print(ans)

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

s=0
for i in range(N):
    if D.get(A[i],None)==None:
        D[A[i]]=1
    else:
        D[A[i]]+=1
        s+=1

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

Solution (Python):
from collections import Counter

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

c = Counter(A)

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

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

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
len_c = len(c)
b = {k:v for k,v in c.items() if v > 1}
sum_b = sum(b.values())
if n == 3:
    print(1)
if (sum_b + len(b)) % 2 == 0:
    print(len_c)
else:
    print(len_c - 1)

Solution (Python):
N=int(input())
la=list(map(int,input().split()))
da={}
for ll in la:
    if not ll in da:
        da[ll]=1
if (N-len(da))%2==0:
    print(len(da))
else:
    print(len(da)-1)

Solution (Python):
N=int(input())
la=list(map(int,input().split()))
da={}
for ll in la:
    if not ll in da:
        da[ll]=1
    elif da[ll]==1:
        da[ll]=2
    else:
        da[ll]=1
nev=0
for dd in da:
    if da[dd]==2:
        nev+=1
if nev%2==0:
    print(len(da))
else:
    print(len(da)-1)

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

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

print(ans)

Solution (Python):
from collections import Counter as C
N = int(input())
A = C([int(a) for a in input().split()])
X = []
for a in A:
    X.append(A[a]-1)
print(N - (sum(X)+1)//2*2)

Solution (Python):

from collections import Counter

def solve():
    N = int(input())
    A = map(int, input().split())
    C = Counter(A)
    res = len(C)-(N-len(C))%2
    return str(res)

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush

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

def main():
    n=inp()
    a=inpl()
    dic={}
    ans=0
    for i in range(n):
        if a[i] not in dic:
            dic[a[i]]=1
            ans+=1
    if ans%2==0:
        ans-=1
    print(ans)

if __name__ == "__main__":
    main()

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

count_A = Counter(A)


gusu = 0
for a in count_A:
    if count_A[a] % 2 == 0:
        gusu += 1
print(len(count_A) - gusu % 2)

Solution (Python):
N = int(input())
fq = [0] * int(10**5 + 10)
A = list(map(int, input().split()))
for a in A:
    fq[a] += 1
fq = [f if f % 1 == 0 else 1 for f in fq]
cnt_even = 0
cnt_odd = 0
for f in fq:
    if f & 1 == 0 and f != 0:
        cnt_even += 1
    if f & 1 == 1:
        cnt_odd += 1
if cnt_even & 1 == 0:
    print(cnt_even + cnt_odd)
else:
    print(cnt_even - 1 + cnt_odd)

Solution (Python):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
even = 0 
odd = 0
for x in C.values():
    if x&1:
        odd += 1
    else:
        even += 1

print(odd + even - even%2)

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

Solution (Python):
import sys
from collections import Counter
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = Counter(a_ls)
if (sum(ct.values()) - len(ct)) % 2 == 0:
    print(len(ct))
else:
    print(len(ct) - 1)

Solution (Python):
from collections import Counter

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

c = 0
for i, v in ca.items():
  c += v - 1
if c % 2 == 0:
  print(len(ca))
else:
  print(len(ca) - 1)

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

if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter
N=int(input())
A=sorted(Counter(map(int,input().split())).values())
A=list(filter(lambda x:x>0,map(lambda x:x-1,A)))

m=sum(A)

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