akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  int lst = -1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == lst) {
      ans++;
      lst = -1;
    }
    else
      lst = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <string>
#include <stack>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <time.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;
typedef long long ll;


int main() {
	FAST_IO;
	
	int n;
	cin >> n;
	int a[100005], x;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		a[x] = i;
	}
	for (int i = 1; i <= n; i++)
		cout << a[i] << " ";

	return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define inf 2123333333
#define pii pair<int,int>

struct node { int t,v,op,next; }a[1000010];

vector<int> v[200010];
queue<int> q;

pii ans[100010];

int level[200010],head[200010],cur[200010],num[200010],to[200010],n,vs,vt,tt,tot;
bool inq[200010];

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

inline void print(int x)
{
	static char s[233];
	if (!x) { putchar('0');putchar(' ');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar(' ');
}

inline void add(int x,int y,int z)
{
	a[++tot].t=y;a[tot].v=z;a[tot].op=tot+1;a[tot].next=head[x];head[x]=tot;
	a[++tot].t=x;a[tot].v=0;a[tot].op=tot-1;a[tot].next=head[y];head[y]=tot;
}

inline bool bfs()
{
	while (!q.empty()) q.pop();
	memset(level,0,sizeof(level));
	q.push(vs);level[vs]=1;cur[vs]=head[vs];
	while (!q.empty())
	{
		int x=q.front();q.pop();
		for (int i=head[x];i;i=a[i].next) if (a[i].v)
		{
			int t=a[i].t;
			if (level[t]) continue;
			level[t]=level[x]+1;cur[t]=head[t];
			if (t==vt) return true;
			q.push(t);
		}
	}
	return false;
}

inline int dfs(int x,int y)
{
	if (x==vt||!y) return y;
	int res=0;
	for (int &i=cur[x];i;i=a[i].next) if (a[i].v)
	{
		int t=a[i].t;
		if (level[t]!=level[x]+1) continue;
		int hh=dfs(t,min(y,a[i].v));
		if (!hh) continue;
		res+=hh;y-=hh;
		a[i].v-=hh;a[a[i].op].v+=hh;
		if (!y) break;
	}
	return res;
}

inline void insert(int x)
{
	for (int t:v[x]) num[t]=x,q.push(t);
}

int main()
{
	n=rd();vs=0;vt=n*2;tot=0;
	for (int i=1;i<=n;i++) add(vs,i,1);
	for (int i=1;i<n;i++) add(n+i,vt,1);
	for (int i=1;i<n;i++)
	{
		int k=rd();
		for (int j=1;j<=k;j++)
		{
			int x=rd();
			v[x].push_back(i);
			add(x,n+i,1);
		}
	}
	int sum=0;
	while (bfs()) sum+=dfs(vs,inf);
	if (sum<n-1) { puts("-1");return 0; }
	int id=0;
	for (int i=head[vs];i;i=a[i].next) if (a[i].v) id=a[i].t;
	for (int i=1;i<=n;i++) for (int j=head[i];j;j=a[j].next) if (a[j].t>n&&!a[j].v) to[a[j].t-n]=i;
	while (!q.empty()) q.pop();
	insert(id);tt=0;
	while (!q.empty())
	{
		int x=q.front();q.pop();
		if (inq[x]) continue;
		ans[x]=pii(num[x],to[x]);
		insert(to[x]);inq[x]=true;tt++;
	}
	if (tt<n-1) { puts("-1");return 0; }
	for (int i=1;i<=tt;i++) print(ans[i].first),print(ans[i].second),putchar('\n');
	return 0;
}

Measured memory_bytes: 27000
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a_li = LI()

    a_li.sort()

    n = a_li[-1]
    
    dif = INF
    prev_dif = dif
    for a in a_li[:-1]:
        dif = min(abs(n/2 - a), dif)
        if dif != prev_dif:
            r = a
            prev_dif = dif

    print(n, r)


main()

Measured memory_bytes: 14136
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
    if (M == 1) {
        cout << 0 << endl;
        return 0;
    }
	int A[N];
	rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
	map<int, int> mp;
	int ans = 0;
	int sum[N + 1] = {};
	rep(i, N) {
		sum[i + 1] = sum[i] + A[i];
		mp[sum[i + 1] % M]++;
        if (sum[i + 1] % M == 0) ans++;
		ans += mp[sum[i + 1] % M] - 1;
        if (i - M + 2 >= 0) 
            mp[sum[i - M + 2] % M]--;
	}
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 15872
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const double EPS = 1e-12;
typedef complex<double> P;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}

long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}

int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<pair<int,int> >se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		if(se.find({i,j})!=se.end())continue;
		L l(v[i],v[j]);
		vector<int>x={i,j};
		for(int k=0;k<N;k++)if(k!=i&&k!=j&&intersectLP(l,v[k]))x.push_back(k);
		for(int a=0;a<x.size();a++)for(int b=a+1;b<x.size();b++){
			int n=b-a-1;
			r=(r-pow_binary_mod(2,n,M))%M;
			se.emplace(x[a],x[b]);
		}
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, m;

void solve() {
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

 	solve();

  	return 0;
}



Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll SEG_LEN = (1LL << 18);
ll segTree[SEG_LEN * 2];

void add(ll l, ll r, ll val) {
	l += SEG_LEN;
	r += SEG_LEN;
	while (l < r) {
		if (l % 2 == 1) {
			segTree[l++] += val;
		}
		l /= 2;
		if (r % 2 == 1) {
			segTree[--r] += val;
		}
		r /= 2;
	}
}

ll get(ll idx) {
	idx += SEG_LEN;
	ll ans = 0;
	while (idx > 0) {
		ans += segTree[idx];
		idx /= 2;
	}
	return ans;
}

int main() {
	ll aLen, Q;
	cin >> aLen >> Q;
	for (ll i = 0; i < Q; i++) {
		ll com;
		cin >> com;
		if (com == 0) {
			ll l, r, val;
			cin >> l >> r >> val;
			add(l, r+1, val);
		}
		else {
			ll idx;
			cin >> idx;
			cout << get(idx) << endl;
		}
	}
}



Measured memory_bytes: 4676
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    bool matched = false;
    int ans = 0;
    for(int x = 1; x <= 50000; x++){
        if(floor(x * 108 / 100) == n){
            ans = x;
            matched = true;
        }
    }

    if(matched){
        cout << round(ans) << endl;
    }else{
//        cout << round(ans) << endl;
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3764
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	rep(i, n) cin >> a[i];
	int sum = 0, ans = 0;
	int res = 1;
	rep(i, n - 1) (res *= i + 1) %= mod;
	rep(i, n - 1) {
		sum += res * mod_pow(i + 1, mod - 2, mod);
		sum %= mod;
		ans += sum * (a[i + 1] - a[i]);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char O[51],E[51];
	cin>>O>>E;
	for(int i=0;i<strlen(O);i++){
		cout<<O[i];
		if(i<strlen(E))
			cout<<E[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	int n=3;
sort(a,a+n);
	int num=a[2]*10+a[1];
	cout<<num+a[0];
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;

int main() {
	// your code goes here
	
    string s;
    cin>>s;
    int count=0;
    vector<int> ans;
    for(int i=0;i<s.size();i++)
    {
      if(s[i]=='R') count++;
      else
      {
       ans.push_back(count);
       count=0;
      }
       
    }
    ans.push_back(count);
    int m=0;
    sort(ans.begin(),ans.end());
    
     cout<<ans[ans.size()-1]<<endl;
	
	
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  int n = s.length();
  vector<int> next_l(n);
  vector<int> next_r(n);
  
  int last_l = n - 1;
  next_l[n - 1] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == 'L') last_l = i;
    next_l[i] = last_l;
  }
  
  int last_r = 0;
  next_r[0] = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == 'R') last_r = i;
    next_r[i] = last_r;
  }

  vector<int> count(n);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      int l = next_l[i];
      int d = abs(l - i);
      if (d % 2 == 1) l--;
      count[l]++;
    } else {
      int r = next_r[i];
      int d = abs(r - i);
      if (d % 2 == 1) r++;
      count[r]++;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << count[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1872
#include<iostream>
#include<algorithm>
using namespace std;
int contena[100000];
int n,k;
bool search(int);
int main(){
    int linemax=0;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>contena[i];
        linemax=max(linemax,contena[i]);
    }
    int ip,ap;
    ip=0;
    ap=(1<<31)-1;
    while(ap-ip>0){
        int dummy=(ap+ip)/2;
        if(linemax>dummy||!search(dummy)){
            ip=dummy+1;
        }else{
            ap=dummy;
        }
    }
    cout<<ap<<endl;
    return 0;
}
bool search(int maxheavy){
    int num=0;
    int use=0;
    for(int i=0;i<n;++i){
        if(maxheavy<num+contena[i]){
            num=contena[i];
            if(++use==k)return false;
        }else{
            num+=contena[i];
        }
    }
    return true;
}

Measured memory_bytes: 3432
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M, S, T;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for(int i = 0; i < M; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(v);
    }
    cin >> S >> T;
    --S, --T;
    vector<vector<int>> dist(3, vector<int>(N, INF));
    dist[0][S] = 0;
    queue<P> que;
    que.emplace(0, S);
    while(!que.empty()){
        int idx = que.front().first, from = que.front().second;
        que.pop();
        for(int to : graph[from]){
            int nxt_idx = (idx + 1) % 3;
            if(chmin(dist[nxt_idx][to], dist[idx][from] + 1)){
                que.emplace(nxt_idx, to);
            }
        }
    }
    if(dist[0][T] == INF)   dist[0][T] = -1;
    else    dist[0][T] /= 3;
    cout << dist[0][T] << endl;
}

Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;

int main() {
  // 入力部(N)
  int N;
  cin >> N;

  // 入力部(p1, p2, ... pN)
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }

  // sum は 購入する品物の合計金額。
  // highest は 購入する品物の中で最高価格の景品の価格。
  int sum = 0, highest = 0;

  for(int i = 0; i < N; i++) {
    // sum に 価格の値段を加算。
    sum += p.at(i);

    // highest の最高価格を更新していく。
    highest = max(p.at(i), highest);
  }

  cout << sum - highest/2 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 200005

lli bit1[maxn],bit2[maxn];
lli x[maxn],y[maxn];
int n;
vll cm;
map<lli,lli> mp;

void update(int y,lli* bit)
{
    for(;y<maxn;y+=(y&(-y)))
    {
        bit[y]++;
    }
}

int query(int y,lli *bit)
{
    lli ans=0;
    for(;y>0;y-=(y&(-y)))
    {
        ans+=bit[y];
    }
    return ans;
}

pair<lli,lli> find_range(lli n1)
{
     lli l=0,h=2*n-1,an2=-1,an1=-1;
     while(l<=h)
     {
         lli mid=(l+h)/2;
         lli cur=query(mp[cm[mid]]-1,bit2);
         if(cur<=n1)
            an2=mid,l=mid+1;
         else
            h=mid-1;
     }
     l=0,h=2*n-1;
     while(l<=h)
     {
         lli mid = (l+h)/2;
         lli cur=query(mp[cm[mid]],bit1);
         if(cur>=n1+1)
            an1=mid,h=mid-1;
         else
            l=mid+1;
     }
     return {cm[an1],cm[an2]};
}

int main() {
    fastio;
    cin>>n;
    memset(bit1,0,sizeof(bit1));
    memset(bit2,0,sizeof(bit2));
    cm.clear();
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        cm.pb(x[i]);cm.pb(y[i]);
    }
    sort(x,x+n);
    sort(y,y+n);
    sort(all(cm));
    int mx=1;
    for(int i=0;i<2*n;i++)
    {
        if(!mp[cm[i]])
        {mp[cm[i]]=mx++;}
    }
    for(int i=0;i<n;i++)
        update(mp[x[i]],bit1),update(mp[y[i]],bit2);
    if(n&1)
    {
        pair<lli,lli> pr=find_range(n/2);
        if(pr.f>x[n/2])
            pr.f=x[n/2];
            if(pr.s>y[n/2])
                pr.s=y[n/2];
        cout<<pr.s-pr.f+1<<"\n";
    }
    else{
        pair<lli,lli> pr1=find_range(n/2-1);
        pair<lli,lli> pr2=find_range(n/2);
        if(pr1.f>x[n/2-1])
            pr1.f=x[n/2-1];
        if(pr1.s>y[n/2-1])
            pr1.s=y[n/2-1];
        if(pr2.f>x[n/2])
            pr2.f=x[n/2];
        if(pr2.s>y[n/2])
            pr2.s=y[n/2];
        lli a1=(pr1.f+pr2.f)/2;
        lli a2=(pr1.s+pr2.s)/2;
        lli ans=(a2-a1+1)*2;
        if((pr1.f+pr2.f)&1)
            ans--;
        if((pr1.s+pr2.s)%2==0)
            ans--;
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 37592
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

const int MAX_N = 100001 * 3;

int N;
int A[MAX_N];

int main(){
  cin >> N;
  for(int i = 0 ; i < N*3 ; i++){
    cin >> A[i];
  }
  sort(A, A+N*3);
  reverse(A, A+N*3);
  long long int res = 0;
  for(int i = 0 ; i < N ; i++){
    res += A[i*2+1];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
while 1:
    (H,W) = [int(i) for i in input().split()]
    if H==W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0: print('#',end="")
            else: print('.',end="")
        print('')
    print('')



Measured memory_bytes: 7020
#include<stdio.h>

int main() {
        int a,b;

        scanf("%d %d", &a, &b);

        if(a < b) {
                        printf("a < b\n");
        } else if (a > b) {
                        printf("a > b\n");
        } else {
                        printf("a == b\n");
        }

        return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
int main(void){
    // Your code here!
    long int a,b;
    scanf("%ld %ld",&a,&b);
    if(a<=0 && b>=0){
        printf("Zero\n");
    }else if(a<0 && b<0){
        if((b-a)%2==0)printf("Negative\n");
        if((b-a)%2==1)printf("Positive\n");
    }else if(a>0 && b>0){
        printf("Positive\n");
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

int main(){
  long long N;
  cin >> N;

  long long power = 1;

  for (int i = 1; i <= N; i++)
  {
    power *= i;
    power %= 1000000007;
  }

  cout << power << endl;
  
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n),t(n);
	for(int i = 0; i < n; i++) cin >> t[i];
	for(int i = 0; i < n; i++) cin >> a[i];

	if(a[0] != t[n-1]){
		cout << 0 << endl;
	}else
	{
		ll ans = 1;
		for(int i = 1; i < n-1; i++){
			if(t[i] == t[i-1] && a[i] == a[i+1]){
				ans *= min(t[i],a[i]);
				ans %= mod;
			}else if(t[i] > t[i-1] && a[i] == a[i+1] && a[i] < t[i]){  //h[i] == t[i]
				ans = 0;
			}else if(t[i] == t[i-1] && a[i] > a[i+1] && a[i] > t[i]){  //h[i] == a[i]
				ans = 0;
			}else if(t[i] > t[i-1] && a[i] > a[i+1] && a[i] != t[i]){   //h[i] == t[i] == a[i]
				ans = 0;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(auto& it:a)cin>>it;
   map<int,int> mp;
   for(auto it:a)mp[it]++;
   set<int> st;
   for(auto it:a)st.insert(it);
   vector<int> tmp;
   for(auto it:st)tmp.push_back(it);
   int j=0;
   int ans=0;
//    for(auto it:tmp)
//    {
//        cout<<it<<" "<<mp[it]<<"\n";
//    }
   //cout<<"****************************\n";
   int exa=0,exb=0;
   for(int i=0;i<tmp.size();i++)
   {
       int val = mp[tmp[i]]-1;
       if(val&1)exa++;
   } 
   if(exa&1)
   {
       ans=tmp.size()-1;
   }
   else
   {
       ans=tmp.size();
   }
   cout<<ans<<"\n";  
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

Measured memory_bytes: 15796
def inversion(l,r):
    if l == r:
        return [lis[l]],0
    if l+1 == r:
        L=lis[l]
        R=lis[r]
        if L < R:
            return [L,R],0
        else:
            return [R,L],1
    else:
        m = (l+r)//2
        lis1,c1 = inversion(l,m)
        lis2,c2 = inversion(m+1,r)
        reslis,cres = merge(lis1,lis2)
        return reslis,c1+c2+cres

def merge(lis1,lis2):
    len1=len(lis1)
    len2=len(lis2)
    i = 0
    j = 0
    reslis = []
    count = 0
    for _ in range(len1+len2+1):
        if i==len1 or j==len2:
            if i==len1:
                reslis = reslis + lis2[j:]
            elif j==len2:
                reslis = reslis + lis1[i:]
            break
        else:
            if lis1[i] < lis2[j]:
                reslis.append(lis1[i])
                i += 1
            elif lis1[i] > lis2[j]:
                reslis.append(lis2[j])
                j += 1
                count += len1-i
    return reslis,count

n = int(input())
lis = list(map(int,input().split()))
reslis,count = inversion(0,len(lis)-1)
print(count)




Measured memory_bytes: 27484
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    rep(i, n){
        ll x,y;
        cin >> x >> y;
        double kyori = sqrt(x * x + y * y);
        if(kyori <= d) ans++;
    }
    print(ans);


    

}



Measured memory_bytes: 3632
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))

    tot = sum(A)
    test = tot / (4 * M)

    count = 0

    for i in range(N):
        if A[i] >= test:
            count += 1

    if count >= M:
        print('Yes')
    else:
        print('No')



main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<bool> colors(8, false);
  int belowCnt = 0;
  int overCnt = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    int color = a / 400;
    if (color > 7) {
      overCnt++;
    } else {
      if (!colors[color]) {
	colors[color] = true;
	belowCnt++;
      }
    }
  }
  int minValue = max(belowCnt, 1);
  int maxValue = belowCnt + overCnt;
  cout << minValue << " " << maxValue << endl;
  return 0;
}



Measured memory_bytes: 256
AB = input().split()
A, B = int(AB[0]), int(AB[1])
a, b = 0, 0
rA, rB  = AB[0][:3]+AB[0][1]+AB[0][0], AB[1][:3]+AB[1][1]+AB[1][0]
ans = 0

if A <= int(rA):
    a = 1
if B < int(rB):
    b = 1
ans = (int(str(B)[0:3])-b)-(int(str(A)[0:3])-a)
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int n,cnt;
  int i,j,k,l;

  while(scanf("%d",&n) != EOF){
    cnt=0;
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
        for(k=0;k<10;k++){
          for(l=0;l<10;l++){
            if(i+j+k+l == n){
              cnt++;
            }
          }
        }
      }
    }

    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 596
program sequence_sum
  implicit none
  integer(8) :: n, num, tmp, a(0:100000) = 0
  integer :: x, m, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  if (n == 1) then
    write(*,'(i0)') x
    stop
  end if
  tmp = m
  a(1) = x
  b(x) = 1
  do i = 2, m + 1
    x = int(mod(int(x, 8) * x, tmp))
    a(i) = a(i - 1) + x
    if (i == n) then
      write(*,'(i0)') a(i)
      stop
    end if
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3568
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);	

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;


	for (int x = sx; x < tx; x++) {
		cout << "R";
	}
	for (int y = sy; y < ty; y++) {
		cout << "U";
	}
	for (int x = sx; x < tx; x++) {
		cout << "L";
	}
	for (int y = sy; y < ty; y++) {
		cout << "D";
	}

	cout << "D";
	cout << "R";
	for (int x = sx; x < tx; x++) {
		cout << "R";
	}
	for (int y = sy; y < ty; y++) {
		cout << "U";
	}
	cout << "U";
	cout << "L";

	cout << "U";
	cout << "L";
	for (int x = sx; x < tx; x++) {
		cout << "L";
	}
	for (int y = sy; y < ty; y++) {
		cout << "D";
	}
	cout << "D";
	cout << "R";

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

main(){
  int n;
  cin>>n;

  typedef pair<int, int> P;
  vector<P> a;
  for(int i=1;i<=n;i++){
    int num;
    cin >> num;
    a.push_back( P(num, i) );
  }

  for(int i=0;i<n;i++){
//    cout<<a[i].first<<' '<<a[i].second<<'|';
  }
//  cout<<endl;

  sort(a.begin(), a.end());

  for(int i=0;i<n;i++){
//    cout<<a[i].first<<' '<<a[i].second<<'|';
  }
//  cout<<endl;

  for(int i=0;i<n;i++){
    cout<<a[i].second<<endl;
  }
}

Measured memory_bytes: 1780
// Problem : C - 4/N
// Contest : AtCoder - Tenka1 Programmer Contest
// URL : https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
bool check(ll N,ll h,ll n,ll w)
{
	if(N==(4*h*w*n)/(n*w+h*w+h*n))
	return 1;
	else 
	return 0;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	// (nw+hw+hn)/hnw
	// nw+hw+hn=4;
	// hnw=N;
	/*
	N(nw+hw+hn)=4hnw
	Nhw+Nhn+Nnw=4hnw
	N(hw+nw)-4hnw=Nnh
	w(Nw+Nn-4nw)=Nnh
	w=Nnh/(Nw+Nn+4nw)
	*/
	ll N;
	cin>>N;
	ll w;
	for(ll h=1;h<=3500;h++)
	{
		for(ll n=1;n<=3500;n++)
		{
			ll d=-(N*h+N*n-4*n*h);
			if(d>0)
			{
				w=(N*n*h)/d;
				if((N*n*h)%d==0)
				{
					cout<<h<<" "<<n<<" "<<w;
					return 0;
				}
			}
		}
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int c(int a,int b)
{
    return a>b;
}
int main()
{
    int n,m,a[105];
    ll sum=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i],sum+=a[i];
    sort(a,a+n,c);
    if(a[m-1]*4*m>=sum)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int>v(3);

    for(int i = 0;i < 3;i++)
        cin >> v[i];
    sort(v.begin(),v.end());

    if(v[0]+v[1] == v[2])cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;

const int MAX_N = 100000;
const int MAX_M = 100000;

int par[MAX_N];
int _rank[MAX_N];

void init(int n){
  for(int i = 0 ; i < n ; i++){
    par[i] = i;
    _rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y)return;

  if(_rank[x] < _rank[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(_rank[x] == _rank[y]) _rank[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int N,M;
  cin >> N >> M;
  init(N);
  vector<int>vec;
  for(int i = 0 ; i < N ; i++){
    int p; cin >> p;
    vec.push_back(p);
  }

  for(int i = 0 ; i < M ; i++){
    int x,y;
    cin >> x >> y;
    unite(x, y);
  }

  int res = 0;
  for(int i = 0 ; i < N ; i++){
    if(same(i+1, vec[i]))res++;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,a[50];
ld s=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	s=((ld)a[0]+(ld)a[1])/2;
	for(int i=2;i<n;i++)
		s=(s+(ld)a[i])/2;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
// finish date: 2019/07/16

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

int N, M;
vvi allEdge;
vb passed;
vector<vector<pii>> treeEdge_down;
vi treeEdge_up;
vector<set<int>> treeSet;

void dfs(int v) {
    passed[v] = true;
    for (int to: allEdge[v]) {
        if (!passed[to]) {
            treeEdge_down[v].emplace_back(pii(1, to));
            treeEdge_up[to] = v;
            treeSet[v].insert(to);
            treeSet[to].insert(v);
            dfs(to);
        }
    }
}


//dijkstra(開始ノード、ノード数、edge[頂点名][距離、行先の頂点])
vi dijkstra(int s, int V, vector<vector<pii>> edge) {
    vi dist(V, INF); //INFの値がこれでいいか確認するべき
    vb used(V, false);
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push(pii(0, s));
    while (!pq.empty()) {
        int d, t;
        tie(d, t) = pq.top();
        pq.pop();
        if (used[t]) continue;
        used[t] = true;
        dist[t] = d;
        for (pii e:edge[t]) {
            if (dist[e.second] < d + e.first) continue;
            pq.push(pii(d + e.first, e.second));
        }
    }
    return dist;
}


int main() {
    cin >> N >> M;
    if (M & 1) {
        cout << -1 << endl;
        return 0;
    }
    vi A(M), B(M);
    allEdge = vvi(N);
    treeEdge_down = vector<vector<pii>>(N);
    treeEdge_up = vi(N);
    treeSet = vector<set<int>>(N);
    passed = vb(N, false);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        allEdge[A[i]].emplace_back(B[i]);
        allEdge[B[i]].emplace_back(A[i]);
    }
    dfs(0);

    vi dim(N, 0);
    rep(i, M) {
        if (treeSet[A[i]].find(B[i]) == treeSet[A[i]].end()) {
            dim[A[i]]++;
            cout << A[i] + 1 << " " << B[i] + 1 << endl;
        }
    }

    vi dist = dijkstra(0, N, treeEdge_down);

    vvi priori(N, vi(3));
    rep(i, N) {
        priori[i] = {dist[i], i, treeEdge_up[i]};
    }
    sort(priori.begin(), priori.end());
    reverse(priori.begin(), priori.end());
    rep(i, N) {
        if (priori[i][1] == 0) continue;
        if (dim[priori[i][1]] & 1) {
            dim[priori[i][1]]++;
            cout << priori[i][1] + 1 << " " << priori[i][2] + 1 << endl;
        } else {
            dim[priori[i][2]]++;
            cout << priori[i][2] + 1 << " " << priori[i][1] + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 41688
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n, k; cin >> n >> k;
    set<int> S;
    rep(i,k){
        int snuke; cin >> snuke;
        rep(i,snuke){
            int person; cin >> person;
            S.insert(person);
        }
    }
    cout << n - S.size();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int ans=0;
    FOR(i,1,n){
        int t=i,c=0;
        while(t){
            t/=10;
            c++;
        }
        if (c%2==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
const int N = 2e5 + 5;
lli dis[N][2];
vector<lli>adj[N];
void bfs(lli s, lli index)
{
    queue<lli> q;
    vector<bool> vis(N, false);
    vis[s] = true;
    dis[s][index] = 0;
    q.push(s);
    while (!q.empty())
    {
        int s = q.front();
        q.pop();
        for (auto u : adj[s])
        {
            if (vis[u])
                continue;
            vis[u] = true;
            dis[u][index] = dis[s][index] + 1;
            q.push(u);
        }
    }
}
int main()
{
    kira;
    lli n,a,b,u,v;
    cin>>n>>a>>b;
    forz(i,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bfs(b,0);
    bfs(a,1);
    lli maxi=0;
    for(int i=1;i<=n;i++)
    {
        if(dis[i][0]>dis[i][1])
        {
            maxi=max(maxi,dis[i][0]);
        }
    }
    cout<<maxi-1;
    return 0;
}

Measured memory_bytes: 10368
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

res=Counter(arr)

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








Measured memory_bytes: 87528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int h,w,d;
  cin >> h >> w >> d;
  vector<pp> maze(h*w+1);
  rep(i,h)rep(j,w){
    int a;
    cin >> a;
    maze.at(a) = make_pair(i,j);
  }
  vector<ll> step(h*w+1);
  for(int i=1;i<=h*w;i++){
    if(i <= d) continue;
    step.at(i) = step.at(i-d) + abs(maze.at(i-d).first-maze.at(i).first) + abs(maze.at(i-d).second-maze.at(i).second);
  }
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    ll ans;
    if(l > 0) ans = step.at(r) - step.at(l);
    else ans = step.at(r);
    cout << ans << endl;
  }
  
  return 0;
}





Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;

/*--------*/
/*   06   */
/* 05  04 */
/*   03   */
/* 02  01 */
/*   00   */
/*--------*/

/*------------*/
/*     18     */
/*   17  16   */
/* 15  14  13 */
/*   12  11   */
/* 10  09  08 */
/*   07  06   */
/* 05  04  03 */
/*   02  01   */
/*     00     */
/*------------*/

const int block[7][7] = { {  0,  1,  2,  4,  6,  7,  9},
			  {  1,  3,  4,  6,  8,  9, 11},
			  {  2,  4,  5,  7,  9, 10, 12},
			  {  4,  6,  7,  9, 11, 12, 14},
			  {  6,  8,  9, 11, 13, 14, 16},
			  {  7,  9, 10, 12, 14, 15, 17},
			  {  9, 11, 12, 14, 16, 17, 18}	};

int main(){
  string f;
  while(cin >> f){
    if(f=="#")return 0;
    
    bool res = true;
    for(int input=0;input<(1<<19);input++){
      int next = 0;
      for(int i=0;i<7;i++){
	int bit = 0;
	for(int j=0;j<7;j++){
	  if( (input>>block[i][j]) & 1 ) bit |= 1<<j;
	}
	if(f[bit] == '1')next |= 1<<i;
      }

      if( (f[next]-'0') != ((next>>3)&1) ){
	res = false; break;
      }
    }
    
    if(res)cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

Measured memory_bytes: 1184