stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



typedef long long LL;



using namespace std;



int N,S[100010],A[100010];

int L = 0, R = 0;



int main()

{

	scanf("%d",&N);

	int ans = 0;

	for (int i=1;i<=N;i++)

	{

		scanf("%d",&A[i]);

		if (!S[A[i]]) ans++;

		S[A[i]]++;

	}

	if ((N-ans)&1) ans--;

	printf("%d\n",ans);

}

// Faster C++ solution for the same problem (measured speedup: 1.56514848994329x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int i,j,k,n,m,ans,a[110001],s[110001];

int main(){

	while (scanf("%d",&n)!=EOF){

		memset(a,0,sizeof(a));

		for (i=m=1;i<=n;i++) scanf("%d",&k),a[k]++,m=max(m,k);

		for (i=1,s[0]=0;i<=m;i++) s[i]=s[i-1]+a[i];

		for (i=1,ans=n,j=m;i<=j;){

			while (a[i]<=1&&i<=j) i++;

			while (a[j]<=1&&i<=j) j--;

			if (i>j) break;

			if (i!=j) k=min(a[i],a[j])-1,a[i]-=k,a[j]-=k,ans-=2*k;else{

				if (a[i]&1) ans-=(a[i]-1);else ans-=a[i];

				break;

			}

		}

		printf("%d\n",ans);

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

  int n;

  set<int> st;

  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {

    int x;

    scanf("%d", &x);

    st.insert(x);

  }

  int dd = n - (int)st.size();

  if (dd & 1) dd ++;

  printf("%d\n", n - dd);

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7184974288476222x):
#include<stdio.h>

#define N (100010)

int s[N];

int main(){	

	int n;

	scanf("%d",&n);

	for (int i=0,a;i<n;i++){

		scanf("%d",&a);

		s[a]++;

	}

	int cnt=0;

	for (int i=1;i<N;i++){

		if (s[i]>1) cnt+=s[i]-1;

	}

	printf("%d\n",n-cnt-(cnt&1));

}
// Slower C++ solution:
#include <bits/stdc++.h>



typedef long long LL;



using namespace std;



int N,S[100010],A[100010];

int L = 0, R = 0;



int main()

{

	scanf("%d",&N);

	int ans = 0;

	for (int i=1;i<=N;i++)

	{

		scanf("%d",&A[i]);

		if (!S[A[i]]) ans++;

		S[A[i]]++;

	}

	if ((N-ans)&1) ans--;

	printf("%d\n",ans);

}

// Faster C++ solution for the same problem (measured speedup: 1.7003653552915408x):
#include<stdio.h>

#define N (100010)

int s[N];

int main(){	

	int n;

	scanf("%d",&n);

	for (int i=0,a;i<n;i++){

		scanf("%d",&a);

		s[a]++;

	}

	int cnt=0;

	for (int i=1;i<N;i++){

		if (s[i]>1) cnt+=s[i]-1;

	}

	printf("%d\n",n-cnt-(cnt&1));

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100000



using namespace std;

int a[MAXN+80];

deque<int>q;

int main()

{

	int n,i,j,ans=0;

	scanf("%d",&n);

	for(i=1;i<=n;i++)

		scanf("%d",a+i);

	sort(a+1,a+n+1);

	for(i=1;i<=n;i++)

		q.push_back(a[i]);

	while(q.size())

	{

		do{

			i=q.front();

			q.pop_front();

			ans++;

		}while(q.size()&&i^q.front());

		if(q.empty())

			break;

		do{

			j=q.back();

			q.pop_back();

			ans++;

		}while(q.size()&&j^q.back());

		if(q.empty()||(i==q.front()&&j==q.back()))

			ans-=2;

	}

	printf("%d",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7173652268181274x):
#include<stdio.h>

#define N (100010)

int s[N];

int main(){	

	int n;

	scanf("%d",&n);

	for (int i=0,a;i<n;i++){

		scanf("%d",&a);

		s[a]++;

	}

	int cnt=0;

	for (int i=1;i<N;i++){

		if (s[i]>1) cnt+=s[i]-1;

	}

	printf("%d\n",n-cnt-(cnt&1));

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

  int n;

  set<int> st;

  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {

    int x;

    scanf("%d", &x);

    st.insert(x);

  }

  int dd = n - (int)st.size();

  if (dd & 1) dd ++;

  printf("%d\n", n - dd);

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.717865086175383x):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int N=100005;



int n,a[N];

int cnt[N];



int main(){

  int ans=0,tot=0;

  scanf("%d",&n);

  for (int i=1;i<=n;i++)

    scanf("%d",a+i),cnt[a[i]]++;

  for (int i=1;i<=100000;i++)

    if (cnt[i]){

      ans++;

      if (cnt[i]>3)

	cnt[i]=cnt[i]&1?1:2;

      if (cnt[i]==2)

	tot++;

    }

  if (tot&1)

    printf("%d\n",ans-1);

  else

    printf("%d\n",ans);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



typedef long long LL;



using namespace std;



int N,S[100010],A[100010];

int L = 0, R = 0;



int main()

{

	scanf("%d",&N);

	int ans = 0;

	for (int i=1;i<=N;i++)

	{

		scanf("%d",&A[i]);

		if (!S[A[i]]) ans++;

		S[A[i]]++;

	}

	if ((N-ans)&1) ans--;

	printf("%d\n",ans);

}

// Faster C++ solution for the same problem (measured speedup: 1.6997396845430723x):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int N=100005;



int n,a[N];

int cnt[N];



int main(){

  int ans=0,tot=0;

  scanf("%d",&n);

  for (int i=1;i<=n;i++)

    scanf("%d",a+i),cnt[a[i]]++;

  for (int i=1;i<=100000;i++)

    if (cnt[i]){

      ans++;

      if (cnt[i]>3)

	cnt[i]=cnt[i]&1?1:2;

      if (cnt[i]==2)

	tot++;

    }

  if (tot&1)

    printf("%d\n",ans-1);

  else

    printf("%d\n",ans);

  return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100000



using namespace std;

int a[MAXN+80];

deque<int>q;

int main()

{

	int n,i,j,ans=0;

	scanf("%d",&n);

	for(i=1;i<=n;i++)

		scanf("%d",a+i);

	sort(a+1,a+n+1);

	for(i=1;i<=n;i++)

		q.push_back(a[i]);

	while(q.size())

	{

		do{

			i=q.front();

			q.pop_front();

			ans++;

		}while(q.size()&&i^q.front());

		if(q.empty())

			break;

		do{

			j=q.back();

			q.pop_back();

			ans++;

		}while(q.size()&&j^q.back());

		if(q.empty()||(i==q.front()&&j==q.back()))

			ans-=2;

	}

	printf("%d",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7167333007538181x):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int N=100005;



int n,a[N];

int cnt[N];



int main(){

  int ans=0,tot=0;

  scanf("%d",&n);

  for (int i=1;i<=n;i++)

    scanf("%d",a+i),cnt[a[i]]++;

  for (int i=1;i<=100000;i++)

    if (cnt[i]){

      ans++;

      if (cnt[i]>3)

	cnt[i]=cnt[i]&1?1:2;

      if (cnt[i]==2)

	tot++;

    }

  if (tot&1)

    printf("%d\n",ans-1);

  else

    printf("%d\n",ans);

  return 0;

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.4107063149105152x):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int N=100005;



int n,a[N];

int cnt[N];



int main(){

  int ans=0,tot=0;

  scanf("%d",&n);

  for (int i=1;i<=n;i++)

    scanf("%d",a+i),cnt[a[i]]++;

  for (int i=1;i<=100000;i++)

    if (cnt[i]){

      ans++;

      if (cnt[i]>3)

	cnt[i]=cnt[i]&1?1:2;

      if (cnt[i]==2)

	tot++;

    }

  if (tot&1)

    printf("%d\n",ans-1);

  else

    printf("%d\n",ans);

  return 0;

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.4180919085045953x):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

typedef long long ll;

#define rep(i, a, b) for (int i = a; i <= b; ++ i)

const ll inf = 1000000000000000007LL;

using namespace std;

int n, a[200005];

int main() {

	scanf("%d", &n);

	rep(i, 1, n) scanf("%d", &a[i]);

	sort(a + 1, a + n + 1);

	int tot = 0;

	rep(i, 2, n) tot += (a[i] == a[i - 1]);

	if (tot & 1) printf("%d\n", n - tot - 1);

		else printf("%d\n", n - tot);

	return 0;

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.4002231127610665x):
//Ashikur Rahman Asif , CSE 18

#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    cin>>n;

    int ar[n];

    for(int i=0;i<n;i++)

    {

        cin>>ar[i];

    }

    sort(ar,ar+n);

    int total;

    int new_ar[n],ind=0;

    for(int i=0;i<n;i++)

    {

        new_ar[i]=0;

    }

    for(int i=0;i<n;i++)

    {

        if(i==0)

        {

            new_ar[ind]++;

            continue;

        }

        if(ar[i]==ar[i-1])

        {

            new_ar[ind]++;

        }

        else {

            ind++;

            new_ar[ind]++;

        }



    }

    int one,two;

    one=two=0;



    for(int i=0;i<=ind;i++)

    {

        while(new_ar[i]>2)

        {

            new_ar[i]=(new_ar[i]/3)+(new_ar[i]%3);

        }

        if(new_ar[i]==2)

        {

            two++;

        }

        else if(new_ar[i]==1)

        {

            one++;

        }

    }

    int res;

    if(two%2!=0)

    {

        two--;

    }

    res=two+one;





    cout<<res<<endl;

    return 0;

}
// Slower C++ solution:
#include <set>

#include <map>

#include <queue>

#include <ctime>

#include <cmath>

#include <cstdio>

#include <vector>

#include <string>

#include <cctype>

#include <bitset>

#include <cstring>

#include <cstdlib>

#include <utility>

#include <iostream>

#include <algorithm>

#define REP(i,a,b) for(int i=(a);i<=(b);i++)

#define PER(i,a,b) for(int i=(a);i>=(b);i--)

#define RVC(i,S) for(int i=0;i<(S).size();i++)

#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)

using namespace std;

typedef long long LL;

typedef pair<int,int> pii;

     

template<class T> inline

void read(T& num) {

    bool start=false,neg=false;

    char c;

    num=0;

    while((c=getchar())!=EOF) {

        if(c=='-') start=neg=true;

        else if(c>='0' && c<='9') {

            start=true;

            num=num*10+c-'0';

        } else if(start) break;

    }

    if(neg) num=-num;

}

/*============ Header Template ============*/

 

const int maxn=(int)(1e5)+5;

int cnt[maxn],now[2];

 

int main() {

    int n;

    read(n);

    REP(i,1,n) {

        int x;

        read(x);

        cnt[x]++;

    }

    int mx=(int)(1e5);

    REP(i,1,mx) if(cnt[i]) {

        if(cnt[i]&1) now[1]++;

        else now[0]++;

    }

    if(now[0]&1) now[1]--;

    printf("%d\n",now[1]+now[0]);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3741988782339616x):
//Ashikur Rahman Asif , CSE 18

#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    cin>>n;

    int ar[n];

    for(int i=0;i<n;i++)

    {

        cin>>ar[i];

    }

    sort(ar,ar+n);

    int total;

    int new_ar[n],ind=0;

    for(int i=0;i<n;i++)

    {

        new_ar[i]=0;

    }

    for(int i=0;i<n;i++)

    {

        if(i==0)

        {

            new_ar[ind]++;

            continue;

        }

        if(ar[i]==ar[i-1])

        {

            new_ar[ind]++;

        }

        else {

            ind++;

            new_ar[ind]++;

        }



    }

    int one,two;

    one=two=0;



    for(int i=0;i<=ind;i++)

    {

        while(new_ar[i]>2)

        {

            new_ar[i]=(new_ar[i]/3)+(new_ar[i]%3);

        }

        if(new_ar[i]==2)

        {

            two++;

        }

        else if(new_ar[i]==1)

        {

            one++;

        }

    }

    int res;

    if(two%2!=0)

    {

        two--;

    }

    res=two+one;





    cout<<res<<endl;

    return 0;

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.3910587390231914x):
#include <iostream>

#include <sstream>

#include <algorithm>

#include <cstdio>

#include <cmath>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <cstring>

#include <bitset>

#include <functional>

#include <random>

#define REP(i,a,n) for(int i=a;i<=n;++i)

#define PER(i,a,n) for(int i=n;i>=a;--i)

#define hr putchar(10)

#define pb push_back

#define lc (o<<1)

#define rc (lc|1)

#define mid ((l+r)>>1)

#define ls lc,l,mid

#define rs rc,mid+1,r

#define x first

#define y second

#define io std::ios::sync_with_stdio(false)

#define endl '\n'

#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int P = 1e9+7, INF = 0x3f3f3f3f;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}

ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}

//head







#ifdef ONLINE_JUDGE

const int N = 1e6+50;

#else

const int N = 1e2+10;

#endif





int main() {

	int n;

	map<int,int> f;

	cin>>n;

	REP(i,1,n) ++f[rd()];

	int ans = 0;

	vector<int> A, B;

	for (auto t:f) {

		while (t.y>2) ++ans, t.y -= 2;

		if (t.y==2) A.pb(t.x);

		else B.pb(t.x);

	}

	ans += (A.size()+1)/2;

	printf("%d\n", n-ans*2);

}
// Slower C++ solution:
#include <set>

#include <map>

#include <queue>

#include <ctime>

#include <cmath>

#include <cstdio>

#include <vector>

#include <string>

#include <cctype>

#include <bitset>

#include <cstring>

#include <cstdlib>

#include <utility>

#include <iostream>

#include <algorithm>

#define REP(i,a,b) for(int i=(a);i<=(b);i++)

#define PER(i,a,b) for(int i=(a);i>=(b);i--)

#define RVC(i,S) for(int i=0;i<(S).size();i++)

#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)

using namespace std;

typedef long long LL;

typedef pair<int,int> pii;

     

template<class T> inline

void read(T& num) {

    bool start=false,neg=false;

    char c;

    num=0;

    while((c=getchar())!=EOF) {

        if(c=='-') start=neg=true;

        else if(c>='0' && c<='9') {

            start=true;

            num=num*10+c-'0';

        } else if(start) break;

    }

    if(neg) num=-num;

}

/*============ Header Template ============*/

 

const int maxn=(int)(1e5)+5;

int cnt[maxn],now[2];

 

int main() {

    int n;

    read(n);

    REP(i,1,n) {

        int x;

        read(x);

        cnt[x]++;

    }

    int mx=(int)(1e5);

    REP(i,1,mx) if(cnt[i]) {

        if(cnt[i]&1) now[1]++;

        else now[0]++;

    }

    if(now[0]&1) now[1]--;

    printf("%d\n",now[1]+now[0]);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3652048315027434x):
#include <iostream>

#include <sstream>

#include <algorithm>

#include <cstdio>

#include <cmath>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <cstring>

#include <bitset>

#include <functional>

#include <random>

#define REP(i,a,n) for(int i=a;i<=n;++i)

#define PER(i,a,n) for(int i=n;i>=a;--i)

#define hr putchar(10)

#define pb push_back

#define lc (o<<1)

#define rc (lc|1)

#define mid ((l+r)>>1)

#define ls lc,l,mid

#define rs rc,mid+1,r

#define x first

#define y second

#define io std::ios::sync_with_stdio(false)

#define endl '\n'

#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int P = 1e9+7, INF = 0x3f3f3f3f;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}

ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}

//head







#ifdef ONLINE_JUDGE

const int N = 1e6+50;

#else

const int N = 1e2+10;

#endif





int main() {

	int n;

	map<int,int> f;

	cin>>n;

	REP(i,1,n) ++f[rd()];

	int ans = 0;

	vector<int> A, B;

	for (auto t:f) {

		while (t.y>2) ++ans, t.y -= 2;

		if (t.y==2) A.pb(t.x);

		else B.pb(t.x);

	}

	ans += (A.size()+1)/2;

	printf("%d\n", n-ans*2);

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.403162836586123x):
#include<iostream>

using namespace std;

int a[100005]={0};

int main(){

    int t;

    cin>>t;

    int cnt=0;

    for(int i=1;i<=t;i++){

        int q;

        cin>>q;

        a[q]++;

        if(a[q]>1) cnt++;

    }

    int ans=0;

    if(cnt%2==0) ans=t-cnt;

    else if(cnt%2==1) ans=t-cnt-1;

    cout<<ans;

    return 0;

}
// Slower C++ solution:
#include <set>

#include <map>

#include <queue>

#include <ctime>

#include <cmath>

#include <cstdio>

#include <vector>

#include <string>

#include <cctype>

#include <bitset>

#include <cstring>

#include <cstdlib>

#include <utility>

#include <iostream>

#include <algorithm>

#define REP(i,a,b) for(int i=(a);i<=(b);i++)

#define PER(i,a,b) for(int i=(a);i>=(b);i--)

#define RVC(i,S) for(int i=0;i<(S).size();i++)

#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)

using namespace std;

typedef long long LL;

typedef pair<int,int> pii;

     

template<class T> inline

void read(T& num) {

    bool start=false,neg=false;

    char c;

    num=0;

    while((c=getchar())!=EOF) {

        if(c=='-') start=neg=true;

        else if(c>='0' && c<='9') {

            start=true;

            num=num*10+c-'0';

        } else if(start) break;

    }

    if(neg) num=-num;

}

/*============ Header Template ============*/

 

const int maxn=(int)(1e5)+5;

int cnt[maxn],now[2];

 

int main() {

    int n;

    read(n);

    REP(i,1,n) {

        int x;

        read(x);

        cnt[x]++;

    }

    int mx=(int)(1e5);

    REP(i,1,mx) if(cnt[i]) {

        if(cnt[i]&1) now[1]++;

        else now[0]++;

    }

    if(now[0]&1) now[1]--;

    printf("%d\n",now[1]+now[0]);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3770839650075577x):
#include<iostream>

using namespace std;

int a[100005]={0};

int main(){

    int t;

    cin>>t;

    int cnt=0;

    for(int i=1;i<=t;i++){

        int q;

        cin>>q;

        a[q]++;

        if(a[q]>1) cnt++;

    }

    int ans=0;

    if(cnt%2==0) ans=t-cnt;

    else if(cnt%2==1) ans=t-cnt-1;

    cout<<ans;

    return 0;

}
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



 int n,a[100010];



int main()

{

	cin>>n;

    int x=0,y=0,ans=0;

    memset(a,0,sizeof(a));

    while(n--)

    {

        cin>>y;

        if(a[y]) x++;else a[y]++,ans++;

    }

    if(x%2) ans--;

    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.4024439178797925x):
#include<iostream>

#include<string.h>

#include<algorithm>

#include<map>

#include<stdio.h>

using namespace std;

int main() {

	int tmp;

	int n;

	scanf("%d", &n);

		map<int, int> a;

		for (int i = 1; i <= n; i++) {

			scanf("%d", &tmp);

			a[tmp]++;

		}

		int k = a.size();

		if (k % 2 == 1)printf("%d\n", k);

		else printf("%d\n", k - 1);



	return 0;

}