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

Solution (Python):
def main():

    S = list(input())
    checklist = [0 for i in range(26)]
    for i in S:
        checklist[ord(i) - ord("a")] += 1
    ans = True

    for i in checklist:
        if i > 1:
            ans = False

    if not ans:
        print(-1)
        return 0
    else:
        ans = False
        for i in range(len(checklist)):
            if checklist[i] == 0:
                for i in S:
                    print(i, end="")
                print(chr(i + ord("a")), end = "")
                print()
                ans = True
                break

        if not ans:
            new_S = []
            for i in S:
                new_S.append(ord(i))

            for i in range(len(new_S) - 1):
                if new_S[i] > new_S[i + 1]:
                    for j in range(i - 1):
                        print(S[j], end = "")
                    print(chr(new_S[i - 1] + 1), end = "")
                    print()
                    ans = True
                    break

            if not ans:
                print(-1)


def ABC069D():

    H, W = map(int, input().split())
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    for i in range(N):
        for j in range(a[i]):
            ans.append(i + 1)
    printlist = [[0 for i in range(W)] for j in range(H)]
    k = 0
    for i in range(H):
        for j in range(W):
            printlist[i][j] = ans[k]
            k += 1
        if i % 2 != 0:
            printlist[i] = printlist[i][::-1]

    for i in range(H):
        for j in range(W):
            print(printlist[i][j], end = "")
            if j != W:
                print(" ", end = "")
        print()
    print()


import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def ABC057D():

    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v)[::-1]

    anslist = []
    for i in range(A, B + 1):

        anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
    anslist.sort()
    anslist = anslist[::-1]
    ans = anslist[0][0]
    key = anslist[0][2]
    long = anslist[0][1]
    print(ans)
    for i in range(1, len(anslist)):
        if anslist[i][0] == anslist[i - 1][0]:
            ans = anslist[i][0]
            key = anslist[i][2]
            long = anslist[i][1]
        else:
            break
    
    
    cnt = 0
    for i in v:
        if i == key:
            cnt += 1

    c = 0
    for i in v[:long]:
        
        if i == key:
            c += 1
    
    ans = 0
    if c == long:
        for i in range(A,  min(B + 1, cnt + 1)):
            ans += cc(cnt, i)
    else:
        ans = cc(cnt, c)
    
    
    print(ans)


def ABC104D():
    S = list(input())
    A_cnt = 0
    B_cnt = 0
    C_cnt = 0
    Q_cnt = 0
    ans = 0
    for i in S:
        if i == "A":
            A_cnt += 1
        elif i == "B":
            B_cnt += 1
        elif i == "C":
            C_cnt += 1
        else:
            Q_cnt += 1
    for i in range(Q_cnt + 1):
        for j in range(Q_cnt - i + 1):
            k = Q_cnt - i - j
            if A_cnt + i > 0 and B_cnt + j > 0 and C_cnt + k > 0:
                f_i = math.factorial(i)
                f_j = math.factorial(j)
                f_k = math.factorial(k)
                if f_i == 0:
                    f_i = 1
                if f_j == 0:
                    f_j = 1
                if f_k == 0:
                    f_k = 1
                ans += (A_cnt + i) * (B_cnt + j) * (C_cnt + k) * math.factorial(Q_cnt) // f_i // f_j // f_k
                print(ans, i, j, k, A_cnt + i, B_cnt + j, C_cnt + k)
                print(math.factorial(Q_cnt), f_i, f_j, f_k)
    print(ans)


def ARC073D():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for i in range(N)]

def ARC075():
    N, A, B = map(int, input().split())
    h = [int(input()) for i in range(N)]
    def enogth(T):
        import copy
        this_h = copy.copy(h)
        cnt = 0
        for i in range(N):
            this_h[i] -= B
            key = 0
            if this_h[i] > 0:
                key = this_h[i] / (A - B)
                if int(key) != key:
                    key += 1
                cnt += int(key)
        if cnt <= T:
            return True
        else:
            return False
    def sarch(i: object) -> object:
        print(i)
        if enogth(i):
            if i // 2 == 1:
                return i
            sarch(0 + i // 2)
        else:
            sarch(i + i // 2)
    print(sarch(10 ** 9))


def ARC082D():
    N = int(input())
    p = list(map(int, input().split()))
    cnt = 0
    if p[N - 1] == N:
        
        p[-2], p[-1] = p[-1], p[-2]
        cnt += 1

    for i in range(N - 1):
        if p[i] == i + 1:
            p[i], p[i + 1] = p[i + 1], p[i]
            cnt += 1
    print(cnt)


from queue import Queue
def ABC070D():
    N = int(input())
    a, b, c =map(int, input().split())
    Q, K = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(Q)]
    x = [[] for i in range(N)]
    for i, j in xy:
        x[i - 1].append(j - 1)
        x[j - 1].append(i - 1)

    q = Queue()
    visited = [0 for i in range(N)]

def ABC076D():
    N = int(input())
    t = list(map(int, input().split()))
    v = list(map(int, input().split()))
    speed_lim = [0]
    speed_list = [0 for i in range(sum(t) + 1)]
    for i in range(N):
        for j in range(t[i]):
            speed_lim.append(v[i])
    print(speed_lim)
    for i in range(1, sum(t) + 1):
        speed_list[i] = speed_list[i - 1] + 1
        if speed_list[i] > speed_lim[i]:
            speed_list[i] = speed_lim[i]
    print(speed_list)
    speed_list[-1] = 0
    for i in range(sum(t) - 1, -1, -1):
        speed_list[i] = min(speed_list[i + 1] + 1, speed_list[i])
        if speed_list[i] > speed_lim[i + 1]:
            speed_list[i] = speed_lim[i + 1]
    print(speed_list)
    ans = 0
    for i in speed_list:
        ans += i

    print(ans)


def ABC076D():
    N = int(input())
    t = list(map(int, input().split()))
    a = []
    for i in t:
        a.append(i * 2)
    t = a
    v = list(map(int, input().split()))
    
    speed_lim = [0]
    speed_list = [0 for i in range(sum(t) + 1)]
    for i in range(N):
        for j in range(t[i]):
            speed_lim.append(v[i])
    
    for i in range(1, sum(t) + 1):
        speed_list[i] = speed_list[i - 1] + 0.5
        if speed_list[i] > speed_lim[i]:
            speed_list[i] = speed_lim[i]
    
    speed_list[-1] = 0
    for i in range(sum(t) - 1, -1, -1):
        speed_list[i] = min(speed_list[i + 1] + 0.5, speed_list[i])
        if speed_list[i] > speed_lim[i + 1]:
            speed_list[i] = speed_lim[i + 1]
    
    ans = 0
    for i in speed_list:
        ans += i

    print(ans / 2)


def ABC085D():
    N, H = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]
    a = []
    b = []
    for i, j in ab:
        a.append(i)
        b.append(j)
    a.sort()
    b.sort()
    a = a[::-1]
    b = b[::-1]
    damage = 0
    cnt = 0
    for i in b:
        if i < a[0]:
            break
        damage += i
        cnt += 1
        if damage >= H:
            break
    key = 0
    if damage < H:
        key = (H - damage) / a[0]
        if int(key) != key:
            key += 1
        key = int(key)

    cnt += key

    print(cnt)


def ARC068D():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    count_list = []
    cnt = 1
    
    for i in range(1, N):
        if A[i] == A[i - 1]:
            cnt += 1
        else:
            count_list.append(cnt)
            cnt = 1
    count_list.append(cnt)
    ans_cnt = 0
    
    for i in range(len(count_list)):
        if count_list[i] > 2:
            ans_cnt += (count_list[i] % 2) - 1
            count_list[i] %= 2
            if count_list[i] == 0:
                count_list[i] = 2
    
    count_list = sorted(count_list)[::-1]
    for i in range(len(count_list) - 1):
        if count_list[i] == 2 and count_list[i + 1] == 2:
            ans_cnt += 1
            count_list[i] = 1
            count_list[i + 1] = 1
    count_list = sorted(count_list)[::-1]
    if count_list[0] == 2:
        count_list[0] = 0
    
    
    print(sum(count_list))
ARC068D()

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

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

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

Solution (Python):
from collections import Counter
n=int(input())
*l,=map(int,input().split())
a=Counter(l)
itm=len(set(l))
b=len(list(filter(lambda x:x[1]%2==0,a.items())))
if b%2:
  print(itm-1)
else:
  print(itm)

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
d = Counter(reads())

dup = sum(v-1 for k, v in d.items() if v >= 2)
print(N - (dup + 1) // 2 * 2)

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

Solution (Python):
from collections import deque
import copy
import sys

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] =  [long(input_raw[0])]
    input_raw = read_func().strip().split()
    cards = {}
    for i in range(N):
        c = int(input_raw[i])
        if c not in cards:
            cards[c] = 1
        else:
            cards[c] += 1

    even_num = 0
    for c in cards:
        if cards[c] % 2 == 0:
            even_num += 1
    if even_num % 2 == 0:
        print len(cards)
    else:
        print len(cards) - 1



if __name__ == '__main__':
    main()

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

    a.sort()
    idx, cnt, s = 0, 0, 0
    while idx < n:
        c = 1
        s += 1
        while idx < n-1 and a[idx] == a[idx+1]:
            idx += 1
            c += 1
        if c % 2 == 0:
            cnt += 1
        idx += 1

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split() ]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
L=[]
for j in dd.values():
    L.append(j-1)
if len(L)==1 or len(L)==2:
    print(1)
    sys.exit()
if sum(L)%2==1:
    print(len(L)-1)
    sys.exit()
if sum(L)%2==0:
    print(len(L))
    sys.exit()

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
s = set()
for i in range(n):s.add(lis[i])
lis.sort()
if (len(lis)-len(s)) % 2 == 1:
	print(len(s)-1)
else:
	print(len(s))

Solution (Python):
def card_eater():
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	total_cards = len(a)
	total_distinct_cards = len(list(set(a)))
	numofcards_to_remove = total_cards-total_distinct_cards
	if numofcards_to_remove%2==0:
		print total_distinct_cards
	else:
		print total_distinct_cards-1


if __name__ == "__main__":
	card_eater()

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

num = [0] * 100001

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

for i in range(100001):
    if num[i] > 1:
        num[i] = 1

sum_num = sum(num)

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

Solution (Python):
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(10**5+1)
for i in xrange(n):
    cnt[a[i]]+=1
cnt1=0
cnt2=0
for i in xrange(10**5+1):
    if cnt[i]==0:continue
    if cnt[i]%2==0:
        cnt2+=1
    else:
        cnt1+=1
if cnt2%2==0:
    print cnt1+cnt2
else:
    print cnt1+cnt2-1

Solution (Python):
from collections import Counter

_ = input()
xs = Counter(map(int, input().split()))
even = sum(1 for (k, c) in xs.items() if c%2==0)
odd = sum(1 for (k, c) in xs.items() if c%2==1)
print(odd + (even//2)*2)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
sn=[0]*100001
mi2=0
mi=0
for i in range(0,n):
    if sn[a[i]]==1:
        mi2=1-mi2
    else:
        sn[a[i]]=1
        mi+=1
print(mi-mi2)

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

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

Solution (Python):

from collections import Counter

num_card = int(input())
l_card = list(map(int, input().split()))
card_counter = Counter(l_card)

num_mod = 0
for card in card_counter.values():
    if card != 1:
        num_mod += (card - 1)

ans = len(card_counter)

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

print(ans)

Solution (Python):
n = int(input().strip())
a = [int(x) for x in input().strip().split()]
num = len(list(set(a)))
print(num - (n - num) % 2)

Solution (Python):

n = int(input())
values = [int(x) for x in input().split(" ")]
def count(values):
    from collections import defaultdict
    counter = defaultdict(int)
    for value in values:
        counter[value] += 1
    return counter
odd = 0
even = 0
c = count(values)
for number, amount in c.items():
    
    if amount % 2 == 0:
        even += 1
    else:
        odd += 1

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

Solution (Python):
from collections import defaultdict
length = int(input())
target = [int(n) for n in input().split(" ")]
w_counter = defaultdict(int)

for t in target:
    w_counter[t] += 1

max_card = 0
min_card = 10 ** 8
overlap_card = 0 
for k,v in w_counter.items():
    if v > 1:
        max_card = max(max_card,k)
        min_card = min(min_card,k)
        overlap_card += v - 1
cannot_pinch = 1

for k,v in w_counter.items():
    if min_card <= k <= max_card:
        cannot_pinch = 0
        break

if overlap_card % 2 == 0:
    print(length - overlap_card)
else:
    print(length - overlap_card - (1 + cannot_pinch))

Solution (Python):


n=int(raw_input())
a=map(int,raw_input().split())
b=set(a)
if len(b)%2:
 print len(b)
else:
 print len(b)-1

Solution (Python):
n=input()
l=len(set([int(x) for x in input().split()]))
print(l-(l+1)%2)

Solution (Python):

from collections import Counter

counter = Counter()
odds = 0
eat = 0

N = int(input())
for A in list(map(int, input().split())):
    counter[A] += 1

types = len(counter)

for k, v in counter.items():
    if v >= 2 and v%2 == 0:
        eat += v//2 - 1
        odds += 1
    elif v>= 2 and v%2 == 1:
        eat += v//2

if odds%2 == 0:
    eat += odds / 2
    print(types)
else:
    eat += odds // 2 + 1
    print(types-1)

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

Solution (Python):
from collections import Counter

input()
c = Counter(map(int, input().split()))
print((len(c) - 1) // 2 * 2 + 1)

Solution (Python):
from collections import Counter
N = int(input())
A = Counter([int(i) for i in input().split()])
c = 0
for i in A:
	if not A[i] % 2:
		c += 1
print(len(A)-c%2)

Solution (Python):
def main():
    n = int(input())
    a = set(map(int,input().split()))

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

    return L

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

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
D = dict()
for a in A:
   if not a in D:
      D[a] = 0
   D[a] += 1

total = 0
for num, count in D.iteritems():
   if count > 1: total += count - 1
if total % 2 != 0: total += 1
print N - total

Solution (Python):

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)

Solution (Python):
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr)
            return None

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


m = len(A)

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

print(ans)

Solution (Python):
from collections import Counter
import heapq
 
n = int(input())
a = Counter(map(int, input().split()))
 
x = []
for k in a:
    if a[k] > 1:
        x.append(-(a[k] - 1))
 
heapq.heapify(x)
 
while len(x) > 1:
    u = abs(heapq.heappop(x))
    v = abs(heapq.heappop(x))
    n -= min(v, u) * 2
    d = abs(u - v)
    if d > 0:
        heapq.heappush(x, -d)
 
if len(x) > 0:
    p = abs(heapq.heappop(x))
    n -= p + p % 2
 
print(n)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in A:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1
cnt = 0
for k in D.keys():
    if D[k] % 2 < 1:
        cnt += 1
print(len(D) - (cnt % 2))

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
e = 0
i = 0
while True:
    c += 1
    cai = 1
    while i != n - 1 and a[i] == a[i + 1]:
        cai += 1
        if i != n - 1:
            i += 1
        else:
            break
    if cai % 2 == 0:
        e += 1
    if i != n - 1:
        i += 1
    else:
        break
ans = c - (e % 2)
print(ans)

Solution (Python):
input()
a = [0] * (100000 + 1)

for i in map(int, input().split()):
    a[i] += 1
    if a[i] == 3:
        a[i] >>= 1

c = [0, a.count(1), a.count(2)]

ans = 0
ans += (c[2] >> 1) << 1
ans += c[1]

print(ans)

Solution (Python):
import sys
from collections import Counter

cin = sys.stdin

N = int(cin.readline())
A = list(map(int, cin.readline().split()))

C = Counter(A)
indi = len(C)
last = N - indi
if last % 2==1:
    ans = indi - 1
else:
    ans = indi

print(ans)

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

EPS = 1e-9


def dot(a, b):
    return a.real * b.real + a.imag * b.imag

def cross(a, b):
    return a.real * b.imag - a.imag * b.real

def distance(a, b, c):
    if dot(b-a, c-a) <= EPS:
        return abs(c-a)
    if dot(a-b, c-b) <= EPS:
        return abs(c-b)
    return abs(cross(b-a, c-a)/(b-a))

r = n()
A = ln()

A.sort()

c = collections.Counter(A)

key = c.keys()
i = 0
j = len(key) - 1

cost = 0
while i <= j:
    while i < len(key) and c[key[i]] <= 1:
        i += 1
    while j >= 0 and c[key[j]] <= 1:
        j -= 1
    if i > j:
        break
    c[key[i]] -= 1
    c[key[j]] -= 1
    cost += 2

print r - cost

Solution (Python):
x=range(100000)
a=0;ans=0;
n=int(raw_input())
l=raw_input().split(" ")
for i in range(100000):
    x[i]=0;
for i in range(n):
    y=int(l[i])
    if x[y]==1:
        a+=1
    else:
        x[y]=1

for i in range(100000):
    if x[i]==1 :
        ans+=1

print str(ans-a%2)

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

counts = [ 0 for i in range(1000000)]

for a in A:
    counts[a] += 1

sum = 0
for count in counts:
    sum += max(0, count-1)

print(N - sum - sum%2)

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

Solution (Python):
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(max(a)+1)
for i in xrange(n):
    cnt[a[i]]+=1
for i in xrange(max(a)+1):
    while cnt[i]>=3:
        cnt[i]=cnt[i]/3+cnt[i]%3
ans=0
cnt1=0
cnt2=0
tmp=0
for i in xrange(max(a)+1):
    if cnt[i]==2:
        cnt2+=1
        tmp+=2
    if cnt[i]==1:
        cnt1+=1
if cnt2%2==1:
    print(cnt1+tmp/2-1)
else:
    print(cnt1+tmp/2)

Solution (Python):
import bisect

N=int(raw_input())
A=sorted([int(x) for x in raw_input().split()])
Al=[0 for i in range(100001)]
K=[]
for a in A:
    Al[a]+=1
    if Al[a]>1:
        K.append(a)
ans=len(A)
while(len(K)>2):
    ans-=2
    al=K.pop(0)
    ar=K.pop(-1)
    Al[al]-=1
    Al[ar]-=1
if len(K)==2:
    al=K.pop(0)
    ar=K.pop(-1)
    if sum(Al[al:ar+1])==2:
        ans-=4
    else:
        ans-=2
elif len(K)==1:
    ans-=2
print ans

Solution (Python):
import sys
from collections import Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr)
            return None

N = int(input())
cnt_A = Counter(map(int, input().split()))




dabuli = sum(cnt_A.values()) - len(cnt_A.values())

if dabuli % 2 == 0:
    ans = N - dabuli
else:
    ans = N - (dabuli + 1)

print(ans)

Solution (Python):



from collections import *
n = int(input())
As = list(map(int,input().split()))

d = Counter()
for a in As:
    d[a] += 1

two = 0
num = 0
for k,v in d.items():
    if v == 1:
        continue
    elif v % 2 == 0:
        two += 1
        num += v // 2 - 1
    else:
        num += v // 2

num += (two + 1) // 2

print(n - (num * 2))

Solution (Python):
n = int(input())
r = list(map(int, input().split()))
d = {}
for v in r: d[v] = d.get(v, -1) + 1
s = sum(d.values())
print(n - 2*((s+1)//2))

Solution (Python):
from collections import Counter
n = input()
A = map(int, raw_input().split())
C = Counter(A)
ans = 0
for k in C.keys():
    if C[k] >= 3:
        ans += (C[k]-1) / 2
        C[k] = 1 if C[k] % 2 == 1 else 2
tmp = 0
for v in C.values():
    if v == 2:
        tmp += 1

ans += tmp / 2 + tmp % 2
print n-ans*2

Solution (Python):
from collections import Counter
N = int(input())
ans = 0
even = 0
cnt = Counter(map(int, input().split()))
for k, v in cnt.items():
    if v % 2 == 0:
        ans += (v - 2) // 2
        even += 1
    else:
        ans += v // 2
ans += even // 2 + even % 2
print(N - ans * 2)

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

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

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    s = set(LI())
    l = len(s)
    if l % 2 == 1:
        return l
    return l - 1


print(main())