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



Sample input:
5
1 2 1 3 7


Sample output:
3

Submission status: Accepted

Solution code:
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

unique = set(a)
doub = len(a) - len(unique)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


N = int(input())
aa = inpl()
sums = defaultdict(int)
numbers = set()

for a in aa:
	sums[a] += 1

ans = 0
eve = 0
for i in range(1,10**5+3):
	tmp = sums[i]
	if tmp <= 1:
		continue
	else:
		if tmp%2 == 1:
			ans += (tmp-1)//2
		else:
			ans += tmp//2-1
			eve += 1

ans += (eve+1)//2
print(N-ans*2)

Submission status: Accepted

Solution code:
from collections import Counter

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

num = len(Counter(A))

print(num - (N-num)%2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


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


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, A):
    c = Counter(A)
    ks = list(c.keys())
    ks.sort()

    ans = 0
    for k in ks:
        if c[k] % 2 == 1:
            c.pop(k)
            ans += 1
        else:
            c[k] = 2

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

    return ans


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
s=input().split()
s.sort()
cc=s[0]
cnt=1
l=[]
for c in s[1:]:
 if c==cc:
  cnt+=1
 else:
  l.append(cnt%2)
  cnt=1
  cc=c
l.append(cnt%2)
a=-1 if l.count(0)%2==1 else 0
print(len(l)+a)

Submission status: Accepted

Solution code:
import collections
n = int(input())

arr = map(int,raw_input().split())
l = len(arr)
counter = collections.Counter(arr)

c = 0

for item in counter.items() :
	if item[1] > 2:
		if item[1] % 2 == 1 :
			l -= item[1] - 1

		else:
			l -= item[1] - 2

	if item[1] % 2 == 0 :
		c += 1

if c % 2 == 0:
	l -= c

else :
	l -= c+1

print l

Submission status: Accepted

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

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

if (n-len(a_n.keys()))%2 == 0:
    print(len(a_n.keys()))
else:
    print(len(a_n.keys())-1)

Submission status: Accepted

Solution code:
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-(x-y)-(x-y)%2)

Submission status: Accepted

Solution code:
input()
a = list(map(int, input().split()))
c = {}
lb = lc = 0
for i in a:
  try:
    c[i] += 1
    lb += 1
  except:
    c[i] = 1
    lc += 1
print(lc if lb % 2 == 0 else lc-1)

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
d = [0 for i in range(10 ** 5 + 1)]
for a in A:
    d[a] = 1
s = sum(d)
print(s - (0 if s % 2 else 1))

Submission status: Accepted

Solution code:
import functools
N = int(input())
A = map(int, input().split())
d = [0 for i in range(10 ** 5 + 1)]
for a in A:
    d[a] = 1
s = sum(d)
print(s - (0 if s % 2 else 1))

Submission status: Accepted

Solution code:
input()
def unique(seq):
    return {}.fromkeys(seq).keys()
cards = len(unique([Ai for Ai in input().split()]))
print(cards if cards % 2 == 1 else cards - 1)

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
d = [0 for i in range(10 ** 5 + 1)]
for a in A:
    d[a] = 1
l = [x for x in d if x]
print(len(l) - (0 if len(l) % 2 else 1))

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
d = {}
for a in A:
    d[a] = 1
print(len(d) - (0 if len(d) % 2 else 1))

Submission status: Accepted

Solution code:
import sys

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


    lst = [0]* 1000000
    dup = 0
    ans =0

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

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

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

if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
input()
cards = len(set([Ai for Ai in input().split()]))
print(cards if cards % 2 == 1 else cards - 1)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(Ai) for Ai in input().split()]
cards = len(set(A))
print(cards if cards % 2 == 1 else cards - 1)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = 0
for k, v in Counter(A).items():
    if v % 2 != 1:
        c += 1

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

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
m = {}
eat = 1
for a in A:
  if a in m:
    eat += 1
  else:
    m[a] = 1
print(N - 2 * (eat // 2))

Submission status: Accepted

Solution code:
#%% data
n = int(input())
a = list(map(int, input().split()))

#%%
counts = {}
for v in a:
    counts[v] = counts.get(v, 0) + 1

#%%
l = len([x for x in counts.values() if not x & 1])
print(len(counts) - 1 if l & 1 else len(counts))

Submission status: Accepted

Solution code:
i = int(input())
s = list(input().split())
a = len(set(s))
if a%2 == 0:
    a -= 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = list(map(int, input().split(' ')))
cards = {}
for c in tmp:
    if c in cards.keys():
        cards[c] += 1
    else:
        cards[c] = 1
lost = 0
for k, v in cards.items():
    if v > 1 and v % 2 == 0:
        if lost == 0:
            lost += 1
        else:
            lost -= 1

print(len(cards.keys()) - lost)

Submission status: Accepted

Solution code:
n=int(input())
a=list(input().split())
ans=len(set(a))
if ans%2 == 0:
    ans -= 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
cnt = 0
buf = 0
for a in A:
    if buf != a:
        cnt += 1
    buf = a
print((cnt-1)//2*2+1)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
even = len([a for a in ctr.values() if a%2==0])
ans = len(ctr)
if even%2:
    ans -= 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
c = len(set([int(x) for x in input().split()]))
if (n - c) % 2 == 1: c -= 1
print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l = set(l)
length = n-len(l)

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

Submission status: Accepted

Solution code:
from collections import Counter 
n=int(input())
a=[int(i) for i in input().split()]
c=Counter(a)
d=[]
for i in c:
  d.append(2-c[i]%2)
dc=Counter(d)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
P = list(map(int,input().split()))
P.sort()
c = collections.Counter(P)
p = 0
ans = 0
for i in c:
    r = c[i]
    if r % 2 == 0:
        p += 1
    else:
        ans += 1
p = (p // 2) * 2
print(p + ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def d_card_eater(N, A):
    # 解説どおり
    kind = len(set(A))  # 数列に現れる値の種類の数
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

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

Submission status: Accepted

Solution code:
def d_card_eater(N, A):
    # 解説どおり
    from collections import Counter
    kind = len(set(A))  # 数列に現れる値の種類の数
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

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

Submission status: Accepted

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())))
count = 1
for i in range(N-1):
    if a[i] != a[i+1]:
        count += 1
if count % 2 == 0:
    count -= 1
print(count)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = set()
lis = list(map(int,input().split()))
for i in range(n):
  s.add(lis[i])
if (len(lis)-len(s) )% 2 == 1:
  print(n-(len(lis)-len(s)+1))
else:
  print(n-(len(lis)-len(s)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
dic = {}
for i in range(n):
    if not a[i] in dic:
        dic[a[i]] = 1
    else:
        dic[a[i]] += 1
op = 0
for key in dic:
    if dic[key] > 1:
        op += dic[key]-1
op = op+1 if op%2==1 else op
print(n-op)

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
c,num = collections.Counter(a),0
for i in c.most_common():
	if i[1] == 1: break
	else: num += i[1]-1
print(n-(num+num%2))

Submission status: Accepted

Solution code:
from collections import  Counter
N = int(input())
A = list(map(int, input().split()))
A = dict(Counter(A))
even = len(list(filter(lambda x: x%2==0, list(A.values()))))
if even % 2 == 1:
    print(len(A)-1)
else:
    print(len(A))

Submission status: Accepted

Solution code:
from collections import Counter
N=input()
A=map(int, raw_input().split())
ac=Counter(A)

k=len(ac)

if k%2==0:
	print k-1
else:
	print k

Submission status: Accepted

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
dic={}
for i in range(N):
  if A[i] in dic:
    dic[A[i]]+=1
  else:
    dic[A[i]]=1
cnt=0
for x,y in dic.items():
  if y%2==0:
    cnt+=1
if cnt%2==0:
  print(len(dic))
else:
  print(len(dic)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def d_CardEater(N, A):
    from collections import Counter, defaultdict
    a = Counter(A)  # a[i]は数列の中にiが何回出たか
    a = sorted(a.items(), key=lambda x: x[0])
    d = defaultdict(int)  # aのうち2回以上出た値の一覧
    for k, v in a:
        if v >= 2:
            d[k] = v - 1  # あとの計算の便宜のため、1引いておく
    n = sum(d.values())  # 少なくとも値が重複したn枚分は捨てることになる
    if n % 2 == 0:
        ans = N - n
    else:
        # nが奇数だと、山札dの中のカードのうち1枚を、値の重複がないカードからなる
        # 山の中の1枚を道連れにして捨てる必要があるため、さらに1引く
        ans = N - n - 1
    return ans

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
uni_a = set(a)
deleted = len(a) - len(uni_a)
print(len(a) - deleted - deleted % 2)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(n) for n in input().split()]

cnt_A = [0]*(100001)

cnt_removed = 0
cnt_two = 0

for a in A:
  cnt_A[a] += 1
  if cnt_A[a] == 3:
    cnt_two -= 1
    cnt_A[a] -= 2
    cnt_removed += 2
  elif cnt_A[a] == 2:
    cnt_two += 1

cnt_removed += (cnt_two + 1)//2 * 2

print(N-cnt_removed)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
ans = set(a)
if (len(a) - len(ans)) % 2 is 0:
    print(len(ans))
else:
    print(len(ans) - 1)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int, input().split(" ")))
ans=len(list(set(A)))
if ans%2==0:
 ans-=1
print(ans)

Submission status: Accepted

Solution code:
a=input()
b=map(int,raw_input().split())
b.sort()
c=[]
d=0
for i in b:
	if d==i:
		c[-1]+=1
	else:
		c.append(1)
		d=i
ans=0
for i in c:
	ans+=i-1
if ans%2==0:
	print a-ans
else:
	print a-ans-1

Submission status: Accepted

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

uni = len(list(set(a)))
if uni % 2 == 0:
    uni -= 1

print(uni)

Submission status: Accepted

Solution code:
from collections import Counter

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

ref = [v-1 for k, v in c.items() if v != 1]

ans = N - ((sum(ref)+1)//2)*2

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    s = len(set(a_list))
    if (len(a_list) - s) % 2 != 0:
        print(s - 1)
    else:
        print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


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


def read_str():
    return input()

n = read_int()
a = read_int_list()

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

Submission status: Accepted

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1

ans = N - (cnt + (cnt%2))
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = input()
CARDS = map(int, raw_input().split())
hist = Counter(CARDS)
dup = N - len(hist)
eat = (dup+1)/2
print N - eat*2

Submission status: Accepted

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

A_uni = set(A)
dup = len(A) - len(A_uni)
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=set(map(int,input().split()))
r=N-len(A) #食べるべきカードの個数
print(N-int(r/2+1/2)*2)

Submission status: Accepted

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

Submission status: Accepted

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

C = {}

for i in range(N):
  if not A[i] in C:
    C[A[i]] = 1
  else:
    C[A[i]] += 1

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

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(raw_input())
l = map(int, raw_input().split())
ct = Counter(l)
eat = 0
sub = 0
for i in ct.values():
    eat += (i-1) / 2
    sub += (i-1) % 2
eat += (sub+1) / 2
print n - eat * 2

Submission status: Accepted

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

cnt = 1
kisu = 0
gusu = 0
cntsub = 1
for i in range(1,N):
    if A[i] == A[i-1]:
        cntsub += 1
        if i == N-1:
            if cntsub % 2 == 0:
                gusu += 1
            else:
                kisu += 1
    else:
        cnt += 1
        if cntsub%2 == 0:
            gusu +=1
        else:
            kisu +=1
        if i == N-1:
            kisu +=1
        cntsub = 1

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

print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n = int(input())
    card_list = list(map(int, input().split()))

    ans = len(set(card_list))

    d = defaultdict(int)
    for card in card_list:
        d[card] += 1

    one, two = 0, 0
    for card, num in d.items():
        if num % 2 == 1:
            one += 1
        else:
            two += 1

    print(ans - two % 2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
cards = []
card_cnt = defaultdict(int)

cards = input().split()
for i in range(0, N):
    cards[i] = int(cards[i])
    card_cnt[cards[i]] = card_cnt[cards[i]]+1

cards = sorted(cards)

if N == len(card_cnt.keys()):
    print(N)
else:
    begin = 0; end = N-1
    while(begin < end):

        while card_cnt[cards[begin]] == 1 and begin+2 < end:
            #print(begin)
            begin = begin + 1
        while card_cnt[cards[end]] == 1 and begin+2 < end:
            #
            end = end - 1

        if(begin < end):
            card_cnt[cards[begin]] = card_cnt[cards[begin]]-1
            card_cnt[cards[end]] = card_cnt[cards[end]]-1
            begin = begin + 1
            end = end - 1

    print(sum(card_cnt.values()))

Submission status: Accepted

Solution code:
#解説を確認後
N = int(input())
card = set([int(i) for i in input().split()])

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# 入力読み込み
nb_A = int(input())
A = list(map(int, input().split(" ")))

uniq_A = list(set(A))

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

n = ni()
a = na()
st = set()
for i in a:
    if(i not in st):
        st.add(i)

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

print(c)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    n = int(input())
    As = list(map(int,input().split()))
    Non_dup_As = list(set(As))
    count = len(Non_dup_As)
    if(count % 2 == 0):
        print(count - 1)
    else:
        print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = input()
list_A = A.split()
set_A = set(list_A)
i = 0

for a in list_A:
    if a in set_A:
        i += 1
        
i = i - len(set_A)
if i % 2 == 0:
    print(N - i)
else:
    print(N - (i +1))

Submission status: Accepted

Solution code:
a = int(raw_input())
print ((len(set(map(int, raw_input().split())))-1)//2)*2+1

Submission status: Accepted

Solution code:
n = int(input())
l = len(set(map(int, input().split())))
print(l - (n - l) % 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list_card = list(map(int, input().split()))
##count = 0
##for x in set(list_card):
##    count += list_card.count(x) - 1
M = N - len(set(list_card))
print(N - (M + M%2))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
count = [0]*max(A)
for i in A:
    count[i-1] += 1
count = [i for i in count if i != 0]
count = sum(count) - len(count)
N = N - 2*(count // 2 + count % 2)
print(N)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(raw_input())
a = raw_input().split()
a.sort()

dup = 0
prev = -1
dist = 0
for i in range(0, len(a)):
    if prev == a[i]:
        if dup == 1:
            dup = 0
        else:
            dup = 1
    else:
        dist += 1
    prev = a[i]
res = dist
if dup == 1:
    res -= 1

print(str(res))

Submission status: Accepted

Solution code:
import collections
N = int(raw_input())
inList = map(int, raw_input().split(" "))
c = collections.Counter()
d = collections.Counter()
for i in inList:
    if(c[i] == 1):
        d[i] += 1
    else:
        c[i] += 1
ans = len(c.keys())
if(sum(d.values()) % 2 != 0):
    ans = ans - 1
print ans

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

arr = list(map(int, input().split(" ")))

cnt = Counter()
for word in arr:
    cnt[word] += 1

even_cnt_list = []
for k, v in cnt.items():
    if v % 2 == 0:
        even_cnt_list.append(v)

num_delete = 1 if len(even_cnt_list) % 2 else 0

origin_length = len(cnt.keys())

print (origin_length - num_delete)

Submission status: Accepted

Solution code:
N = int(raw_input())
A = map(int,raw_input().split())
B = set(A)
print len(A)-(len(A)-len(B)+1)//2*2

Submission status: Accepted

Solution code:
print((lambda N, A: len(set(A)) - (N - len(set(A))) % 2)(int(input()), list(map(int, input().split()))))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
m = n - len(set(A))
print(n - m - (m % 2 == 1))

Submission status: Accepted

Solution code:
#D Card Eater
N = int(input())
List = [int(i) for i in input().split(" ")]
List.sort()
result = 1
for i in range(1,N):
    if List[i]!=List[i-1]:
        result+=1
if result%2 == 0:
    print(result-1)
else:
    print(result)

Submission status: Accepted

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())
s = len(set(A))
if (N - s) % 2 != 0:
    s -= 1
print s

Submission status: Accepted

Solution code:
n = int(input())
card = list(map(int, input().split()))
c_set = set(card)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
f = list(set(A))
s = N - len(f) #重複枚数検出

if s%2 == 0:
    print(len(f)) #fが奇数 sが偶数。2枚ずつ取り出すから。
else:
    print(len(f) - 1)

Submission status: Accepted

Solution code:
def Main():
  n = int(input())
  A = list(map(int, input().split()))
  s = set(A)

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

if __name__ == '__main__':
  Main()

Submission status: Accepted

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

b = set(a)
res = len(b)
if n % 2 != res % 2:
    res -= 1
print(res)

Submission status: Accepted

Solution code:
#coding: UTF-8
N=int(input())
lis=list(map(int, input().split()))
kind_dict={}
for i in lis:
    if i in kind_dict:
        kind_dict[i]+=1
    else:
        kind_dict[i]=1
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Submission status: Accepted

Solution code:
#coding: UTF-8
import time
import collections
N=int(input())
lis=list(map(int, input().split()))
#kind=set(lis)
#kindn=len(kind)
kind_dict=collections.Counter(lis)
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)

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

Submission status: Accepted

Solution code:
n = input()
A = map(int, raw_input().split())
C = {}
for e in A:
    C[e] = C.get(e, 0) + 1
res = sum(C[k]-1 for k in C)
print n-res-(res%2)

Submission status: Accepted

Solution code:
N = int(raw_input())
a = set(map(int, raw_input().split()))
print len(a) if len(a) % 2 != 0 else len(a)-1

Submission status: Accepted

Solution code:
from collections import Counter
input()
A_list = input().split(" ")
c = Counter(A_list)

even_count = 0
for v in c.values():
    if not (v % 2):
        even_count += 1
        
if even_count % 2:
    print(len(c)-1)
else:
    print(len(c))

Submission status: Accepted

Solution code:
from collections import Counter

ipt = int(input())
nums = Counter(input().split(" ")).most_common()
double = [x[1] for x in nums if x[1]%2==0]

print(len(nums)-len(double)%2)

Submission status: Accepted

Solution code:
raw_input()
A=map(int,raw_input().split(" "))
dictA={}
for a in A:
    if a not in dictA:
        dictA[a]=1
    else:
        dictA[a]+=1

n_o=0
n_e=0

for n in dictA.values():
    if n%2==0:
        n_e+=1
    else:
        n_o+=1

if n_e%2==0:
    print n_o+n_e
else:
    print (n_e-1)+n_o

Submission status: Accepted

Solution code:
N = int(input())
List = list(map(int, input().split()))

List2 = set(List)
List2_L = len(List2)
Both = N - List2_L

if Both % 2 == 1:
    Answer = List2_L - 1
else:
    Answer = List2_L

print(Answer)

Submission status: Accepted

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

uniq = set(A)
l = len(uniq)
if (l % 2 == 0):
    print(str(l - 1))
else:
    print(str(l))

Submission status: Accepted

Solution code:
N=int(input())
As=input().split()
# N=5
# As=[1, 2, 1, 3, 5]
# As=[1, 3, 5, 2, 1, 3, 2, 8, 8, 6, 2, 6, 11, 1, 1]

from collections import defaultdict
dic=defaultdict(int)
for k in As:
	dic[k]+=1
c=0
for k, v in dic.items():
	if v>2:
		t=((v-1)//2)*2
		# print(v,v-t)
		# dic[k]=v-t
		v=v-t
	if v==2:
		c+=1
l=len(dic)
if c%2==0:
	print(l)
else:
	print(l-1)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
cnt = Counter()
for i in range(n):
    cnt[a[i]] += 1

for a in cnt:
    cnt[a] %= 2
z_o = cnt.values()

if list(z_o).count(0) % 2 == 0:
    print(len(cnt))
else:
    print(len(cnt) - 1)

Submission status: Accepted

Solution code:
from collections import Counter
import heapq

def is_dup(h):
    for i in h:
        if -i[0] > 1:
            return True
    return False

N = int(input())
A = sorted(list(map(int,input().split(" "))))
c = Counter(A)
heap = [[-value, key] for key, value in c.items()]

if len(set(A)) == len(A):
    print(len(A))
else:
    heapq.heapify(heap)
    while is_dup(heap):
        a = [0,0,0]
        a[0] = heapq.heappop(heap)
        if -a[0][0] >= 3:
            a[0][0] += 2
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            continue
        a[1] = heapq.heappop(heap)
        if -a[0][0]-a[1][0] >= 3:
            a[0][0] += 1
            a[1][0] += 1
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            if a[1][0] != 0:
                heapq.heappush(heap, a[1])
            continue
        a[2] = heapq.heappop(heap)
    print(len(heap))

Submission status: Accepted

Solution code:
import collections
n = int(input())
a_list = [int(i) for i in input().split()]
#まず、奇数個存在する数字を除去
cnt = collections.Counter(a_list)
c = 0
for key, num in cnt.items():
    # print(cnt)
    if num == 2 or num == 1:
        if num == 2:
            c += 1
        pass
    # 1より大きい奇数なら
    elif num % 2 != 0 and num > 1:
        cnt[key] = 1
        # num = 1
    # 2より大きい偶数なら
    elif num % 2 == 0 and num > 2:
        c += 1
        cnt[key] = 2
        # num = 2
    else:
        pass
        # print("?")


result = 0
# for key, num in cnt.items():
#     if num == 2:
#         c += 1

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

print(result)

# print("final:",cnt)

Submission status: Accepted

Solution code:
import collections

n = int(input())
card = list(map(int, input().split()))
cardcount = collections.Counter(card).most_common()
oddcount = 0
for k, v in cardcount:
    if v % 2 == 0:
        oddcount += 1
if oddcount % 2 == 0:
    print(len(set(card)))
else:
    print(len(set(card)) - 1)