akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

vector<ll> V;
map<ll, ll> W;
ll a[MAXN];

void add(ll dig, ll m){
	W[dig]++;
	while(W[dig] >= m){
		W[dig] -= m;
		dig--;
		W[dig] ++;
	}
	return ;
}

void build(){
	W.clear();
	W[1] = 0;
	W[-INF] = 0;
}

void resz(ll sz){
	while( (W.rbegin() -> F) > sz) W.erase(( --W.end() ));
	return ;
}

bool check(ll m){
	build();
	ll cnt = V.size();
	for(int i = 1; i < cnt; i++){
		resz(V[i]);
		add(V[i], m);
		if(W.count(0)) return false;
	}
	return true;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 0;i<n;i++) cin >> a[i];
	V.pb(a[0]);
	for(int i = 1;i<n;i++){
		if(a[i] <= a[i-1]) V.pb(a[i]);
	}
	if(V.size() == 1) return cout << 1, 0;
	ll dw = 1;
	ll up = n;
	ll mid;
	while(dw + 1 < up){
		mid = (dw + up) / 2;
		if(check(mid)) up = mid;
		else dw = mid;
	}
	cout << up;
	return 0;
}


/*
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 3956
N,M = map(int,input().split())
min_i = 0
max_i = N+1
for _ in range(M):
  a,b = map(int,input().split())
  min_i = max(min_i,a)
  max_i = min(max_i,b+1)
  
c = max(max_i - min_i,0)
print(c)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<int> adj[100000];
#define ull unsigned long long int
#define ll long long int
#define MAX 1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ifstream fin("a.in");
    ofstream fout("a.out");
    ll x,y,a,b,c;
  	cin>>x>>y>>a>>b>>c;
  	ll p[a],q[b],r[c];
  	for(ll i=0;i<a;i++) cin>>p[i];
  	for(ll i=0;i<b;i++) cin>>q[i];
  	for(ll i=0;i<c;i++) cin>>r[i];
  	sort(p,p+a);
  	sort(q,q+b);
  	sort(r,r+c);
  	vector<ll> ans;
  	for(ll i=max(0ll,a-x);i<a;i++) ans.push_back(p[i]);
  	for(ll i=max(0ll,b-y);i<b;i++) ans.push_back(q[i]);
  	for(ll i=0;i<c;i++) ans.push_back(r[i]);
  	
  	sort(ans.begin(),ans.end());
  	ll tot=0;
  	
  	for(ll i=ans.size()-x-y;i<ans.size();i++) {tot+=ans[i];}
  	cout<<tot;
  	
    
    return(0);
}

Measured memory_bytes: 11120
#include <iostream>

using namespace std;

int main(){
  long int K,A,B;
  cin>>K>>A>>B;

  if(B-A<=2){
    cout<<K+1<<endl;
  }else{
    cout<<K+1+(B-A-2)*((K-A+1)/2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using i8t = std::int64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
using u8t = std::uint64_t;
using vu8t = std::vector<u8t>;
#define F3(I,A,B) for(i8t I=A,I##_N=B;I<I##_N;I++)
#define F(I,N) F3(I,0,N)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}

template<typename T>
void arr_print(T arr){
  int i=0;
  for(auto x:arr){if(i++)std::cout<<" ";std::cout<<x;}
  std::cout<<std::endl;
}

int main() {
  R(N)R(K)R(C)RL(_)RL(S);
  vi8t early(K), late(K);

  int k=0;
  for(int i=0;i<N;i++){
    if(S[i]!='x'){
      if(k==K)return 0; // K+1日以上働けるのでいつでも休める。
      early[k++]=i;
      i+=C;
    }
  }

  k=K;
  for(i8t i=N-1;i>=0;i--){
    if(S[i]!='x'){
      late[--k]=i;
      i-=C;
    }
  }

  F(k,K)if(early[k]==late[k])P(early[k]+1);

  return 0;
}


Measured memory_bytes: 4996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int sum = 0;
    if (a > b) sum += b;
    else sum += a;
    if (c > d) sum += d;
    else sum += c;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){

	int sec, min, hour;
	cin >> sec;

	hour = sec / 3600;
	min = (sec % 3600) / 60;
	sec = sec % 60;

	cout << hour << ":" << min << ":" << sec << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct Edge{
  int u, v, w;
  Edge(){}
  Edge(int _u, int _v, int _w):u{_u}, v{_v}, w{_w}{}
};

vector<Edge> adj;
vector<Edge> solve(int n, int e, int& l, int& r){
//  cout << n << endl;
  vector<Edge> res;
  if(n == 1){
    l = e - 1, r = e;
    res.push_back(Edge(l, e, 0));
    return res;
  }else if(n == 2){
    l = e - 1, r = e;
    res.push_back(Edge(l, e, 0));
    res.push_back(Edge(l, e, 1));
    return res;
  }
  if(n % 3 == 0){
    res = solve(n / 3, e, l, r);
    l--;
    res.push_back(Edge(l, l + 1, 0));
    res.push_back(Edge(l, l + 1, n / 3));
    res.push_back(Edge(l, l + 1, 2 * n / 3));
  }else if(n % 3 == 1){
    res = solve(n - 1, e, l, r);
    res.push_back(Edge(l, r, n - 1));
  }else{
    res = solve(n - 2, e, l, r);
    res.push_back(Edge(l, r, n - 1));
    res.push_back(Edge(l, r, n - 2));
  }

  return res;

  if(n & 1){
    res = solve(n - 1, e, l, r);
    res.push_back(Edge(l, r, n));
  }else{
    int nl, nr;
    res = solve(n / 2, e, l, r);
    l--;
    res.push_back(Edge(l, l + 1, 0));
    res.push_back(Edge(l, l + 1, n / 2));
  }
  return res;
}

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int l;
  cin >> l;
//  l--;
  int nl, nr;
  vector<Edge> res = solve(l, 20, nl, nr);
  cout << nr - nl + 1 << ' ' << res.size() << endl;
  for(auto el : res){
    cout << el.u - nl + 1 << ' ' << el.v - nl + 1 << ' ' << el.w << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,X;
  cin >> A >> B >> C >>X;
  int ans=0;
  rep(i,A+1){
    rep(j,B+1){
      rep(k,C+1){
	int m=i*500 + j*100 + k*50;
	if(m==X) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long sum = a.Sum();
            long snuke = 0;
            long diff = long.MaxValue;
            for (int i = 0; i < n - 1; i++)
            {
                snuke += a[i];
                diff = Math.Min(diff, Math.Abs(snuke - (sum - snuke)));
            }
            Console.WriteLine(diff);
#if DEBUG
            Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 31996
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

ll f(ll x) {
  if (x == 0ll) return 0ll;
  if (x == 1ll) return 1ll;
  if (x == 2ll) return 3ll;
  if (x == 3ll) return 0ll;
  ll res = 0ll;
  for (int i = 60; i >= 2; i--) {
    if ((x >> i) & 1LL) {
      res |= (((x - (1LL << i) + 1LL) % 2LL) << i);
      res |= f(x ^ (1LL << i));
      break;
    }
  }
  return res;
}

void solve() {
  ll a, b;
  cin >> a >> b;
  if (a > 0)
    cout << (f(b) ^ f(a - 1)) << endl;
  else
    cout << f(b) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int k; cin>>k;
    rep(i,k) cout<<"ACL";
    cout<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int a,b;

cin >> a >> b;

if (a < 10 && b < 10)
{
   cout << a*b << endl;
 }else
 {
    cout << -1 << endl;
 }
 







//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

void solve(vector<int> a) {
  vector<int> res;
  while (!a.empty()) {
    int j = -1;
    for (int i = a.size() - 1; i >= 0; i--) {
      if (i == a[i]) {
        j = i;
        break;
      }
    }
    if (j == -1) {
      cout << -1 << endl;
      return;
    }
    res.push_back(a[j]);
    a.erase(a.begin() + j);
  }
  reverse(res.begin(), res.end());
  for (int x : res) cout << x + 1 << endl;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i], --a[i];
    solve(a);
  }
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from itertools import product

def resolve():
  K = int(input())
  gcd = math.gcd
  result = sum([ gcd(x[0], x[1]) for x in product([ gcd(x[0], x[1]) for x in product(range(1, K+1), range(1, K+1)) ], range(1, K+1)) ])
  print(result)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 72068
#include <iostream> 
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2]  == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  int k;
  int v[100];
  int color; //0=white,1==black
  int dt,ft;
}U;

void visit(int);

U *u;
int t;
int s[101],stop=0;

int main(){
  int n,i,j,id,k,v;
  
  scanf("%d",&n);
  u = malloc(sizeof(U) * (n+1));
  
  for(i = 0; i < n; i++){
    scanf("%d",&id);
    scanf("%d",&u[id].k);
    // u[id].v = malloc(sizeof(int) * k);
    for(j = 0; j < u[id].k; j++){
      scanf("%d",&u[id].v[j]);
    }
    u[id].color = 0;
  }

  for(i = 1; i <= n; i++){
    if(u[i].color == 0)
      visit(i);
  }

  for(i = 1; i <= n; i++){
    printf("%d %d %d\n",i,u[i].dt,u[i].ft);
  }
    
  return 0;
}
  
void visit(int i){
  int p,q;

  u[i].dt = ++t;
  u[i].color = 1;
  for(p = 0; p < u[i].k; p++){
    if(u[u[i].v[p]].color == 0)
      visit(u[i].v[p]);
  }
  u[i].ft = ++t;
}



Measured memory_bytes: 2056
import numpy as np
import math
n, p = map(int, input().split())
a = np.array([int(i) for i in input().split()])
even = len(a[a%2 == 0])
odd = len(a[a%2 == 1])
def combinations(n,c):
    return math.factorial(n)//(math.factorial(n-c)*math.factorial(c))
if p == 0:
    x = 1
    for i in range(2,odd+1,2):
        x += combinations(odd,i)
    print(x*2**even)
else:
    if odd == 0:
        print(0)
    else:
        x = 0
        for i in range(1,odd+1,2):
            x += combinations(odd,i)
        print(x*2**even)

Measured memory_bytes: 12488
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    map<string,int> mp;
    int n;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        if(mp.count(s)==0) mp[s]=1;
        else mp[s]++;
    }
    int m;
    cin>>m;
    string t;
    rep(i,m){
        cin>>t;
        if(mp.count(t)==0) mp[t]=-1;
        else mp[t]--;
    }
    int maxi=0;
    for(auto it=mp.begin();it!=mp.end();it++) maxi=max(maxi,it->second);
    cout<<maxi;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,m,q,x,c;
    cin>>n>>m;
    ll a[m+1]={0};
    c=n;
    while(c--){
        cin>>q;
        while(q--){
            cin>>x;
            a[x]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=m;i++) if(a[i]==n) ans++;
    cout<<ans el;
}

main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
vector<lint> coins;
lint maxn = 1e5;
lint inf = 1e18;

int main() {
  lint n;
  cin >> n;
  lint tmp;
  tmp = 1;
  while (tmp <= maxn) {
    coins.push_back(tmp);
    tmp *= 6;
  }
  tmp = 9;
  while (tmp <= maxn) {
    coins.push_back(tmp);
    tmp *= 9;
  }
  vector<lint> dp(n + 1, inf);
  dp[0] = 0;
  for (auto &&w : coins) {
    for (int i = 0; i <= n; i++) {
      if (dp[i] == inf) continue;
      if (i + w > n) continue;
      dp[i + w] = min(dp[i + w], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if(0<=x-r&&x+r<=W){
     if(0<=y-r&&y+r<=H){
          cout<<"Yes"<<endl;
     }else{
          cout<<"No"<<endl;
     }
}else{
     cout<<"No"<<endl;
}
return 0;}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
long long mod = 998244353;
int n;
vector<int>v, tree;
void build(int node, int start, int end){
    if(start == end){
        tree[node] = v[start];
    }
    else{
        int mid = (start + end)/2;
        build(2 * node + 1, start, mid);
        build(2 * node + 2, mid + 1, end);
        tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
    }
}
void update(int node, int start, int end, int idx, int val){
    if(start == end){
        v[idx] = val;
        tree[node] = val;
    }
    else{
        int mid = (start + end)/2;
        if(idx <= mid){
            update(2 * node + 1, start, mid, idx, val);
        }
        else{
            update(2 * node + 2, mid + 1, end, idx, val);
        }
        tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
    }
}
int query(int node, int left, int right, int l, int r){
    if(r < left || l > right){
        return 0;
    }
    else if(l <= left && r >= right){
        return tree[node];
    }
    int mid = (left + right)/2;
    int p1 = query(2 * node + 1, left, mid, l, r);
    int p2 = query(2 * node + 2, mid + 1, right, l, r);
    int result = max(p1, p2);
    return result;
}
int main(){
    int n;
    cin >> n;
    v = vector<int>(n + 3);
    tree = vector<int>(4 * n + 3);
    vector<pair<int, int> >vec;
    for(int i = 0; i < n; i++){
        v[i] = i + 1;
        int a, b;
        cin >> a >> b;
        vec.push_back(make_pair(a, b));
    }
    build(0, 0, n - 1);
    sort(vec.begin(), vec.end());
    vec.push_back(make_pair(2e9 + 5, 0));
    vector<long long>dp(n + 3);
    dp[n] = 1;
    for(int i = n - 1; i >= 0; i--){
        int j = lower_bound(vec.begin(), vec.end(), make_pair(vec[i].first + vec[i].second, 0)) - vec.begin();
        int x = query(0, 0, n - 1, i, j - 1);
        update(0, 0, n - 1, i, x);
        dp[i] = (dp[i + 1] + dp[x]) % mod;
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 10296
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
const int MAXN = 512;
const int MAXC = 32;
const int inf = 1<<28;

int N, C;
int D[MAXC][MAXC];
int c[MAXN][MAXN];
int V[3][MAXC];

int calc(int r0,int r1,int r2) {
  int ret = 0;
  for(int i = 1;i <= C;i++) {
    ret += D[i][r0] * V[0][i];
    ret += D[i][r1] * V[1][i];
    ret += D[i][r2] * V[2][i];
  }
  //  cout << r0 << " " << r1 << " " << r2 << " " << ret << endl;
  return ret;
}

int main() {
  cin >> N >> C;
  for(int i = 0;i < C;i++) 
    for(int j = 0;j < C;j++)
      cin >> D[i+1][j+1];
  for(int i = 0;i < N;i++) {
    for(int j = 0;j < N;j++) {
      cin >> c[i][j];
      V[(i+j+2)%3][c[i][j]]++;
    }
  }
  int ans = inf;
  for(int i = 1;i <= C;i++) {
    for(int j = 1;j <= C;j++) {
      if(i == j) continue;
      for(int k = 1;k <= C;k++) {
	if(i == k || j == k) continue;
	ans = min(ans,calc(i,j,k));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		for(int i = n-1; i >= 0; i--) {
			System.out.print(a[i]);
			if(i != 0) {
				System.out.print(" ");
			}
		}
		
		System.out.println();
	}
}



Measured memory_bytes: 26324
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
struct edge{
    long long int to;
    long long int cost;
    edge(long long int t, long long int w) : to(t), cost(w) { }
};
vector<vector<edge> > g(100010);
long long int ans[100010],seen[100010];
long long int dfs(long long int k){
  seen[k]=0;
  long long int i;
  for(i=0;i<g[k].size();i++){
    if(ans[g[k][i].to]>ans[k]+g[k][i].cost){
      ans[g[k][i].to]=ans[k]+g[k][i].cost;
      dfs(g[k][i].to);
    }
  }
}
int main(){
  long long int n,i,a,b,c,q,k,x,y;
  scanf("%lld\n",&n);
  for(i=0;i<n;i++){
    seen[i]=0,ans[i]=1000000000000000;
  }
  for(i=0;i<n-1;i++){
    scanf("%lld %lld %lld\n",&a,&b,&c);
    a--,b--;
    g[a].push_back(edge(b,c));
    g[b].push_back(edge(a,c));
  }
  scanf("%lld %lld\n",&q,&k);
  k--;
  ans[k]=0;
  dfs(k);
  for(i=0;i<q;i++){
    scanf("%lld %lld\n",&x,&y);
    x--,y--;
    printf("%lld\n",ans[x]+ans[y]);
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[mxn];
int n, m, k;
int a, b, c, d;
string s;

ll POW(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}


void read(){
    cin >> n;
    set<string> st;
    while(n--){
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
}

void solve(){

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 19288
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int N=3005;
ll a[N],dp[N][N];
int main() {
	int n;
  	cin>>n;
  	for(int i=0;i<n;i++) {cin>>a[i];}
  	for(int i=n-1;i>=0;i--) {
    	for(int j=i;j<n;j++) {
        	if(i==j) {dp[i][j]=a[i];}
          	else {dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);}
        }
    }
  	cout<<dp[0][n-1]<<endl;
return 0;
}


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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s;
  cin >> s;

  if (s.size() == 3)
  {
    reverse(s.begin(), s.end());
  }

  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

  if (a == b) {
    cout << a * 2 << endl;
  } else {
    cout << max(a, b) + max({a - 1, b - 1}) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
use std::io::*;

const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let mut len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        if len > 0 {
            len -= 1;
        }

        &self.bytes_buffer[0..len]
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }

    fn scan_u_vec(&mut self, n: usize, separator: u8, delimiter: u8) -> Vec<u32> {
        let mut vector = Vec::with_capacity(n as usize);
        for _i in 0..n - 1 {
            vector.push(self.scan_u(separator));
        }
        vector.push(self.scan_u(delimiter));
        vector
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

// easy
fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 32);

    let n = cin.scan_u(LF) as usize;
    let a = cin.scan_u_vec(n, SP, LF);

    let xor = a.into_iter().fold(0, |acc, cur| acc ^ cur);
    if xor == 0 {
        println("Yes");
    } else {
        println("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int n, arr[100005], counter;
bool alleven = true;

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &arr[i]);
		if (arr[i] % 2 == 1){
			alleven = false;
		}
	}
	if (alleven){
		printf("second\n");
	} else {
		printf("first\n");
	}
	
}

Measured memory_bytes: 640
import sys
from collections import defaultdict

def sieve_of_eratosthenes(n=5 * 10 ** 6):
  sieve = [1] * (n + 1); sieve[0] = sieve[1] = 0
  for i in range(2, int(n ** 0.5) + 1):
    if not sieve[i]: continue
    for j in range(i * 2, n, i): sieve[j] = 0
  prime_numbers = [i for i in range(2, n + 1) if sieve[i]]
  return sieve, prime_numbers

is_prime, prime_numbers = sieve_of_eratosthenes(10 ** 3)

def prime_factorize(n):
  res = defaultdict(int)
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] += 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = defaultdict(int)
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] += c
  return res

MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())

def main():
  res = 1
  for c in prime_factorize_factorial(n).values():
    res *= c + 1; res %= MOD
  print(res)

if __name__ ==  '__main__':
  main()

Measured memory_bytes: 3444
import sys

def read_int():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return int(l[0])

def read_int_list():
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                  
    return [int(i) for i in l]                                                                        

a = read_int()                                                                                        

print(a+a**2+a**3)                                                                                    



Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    vector<int> p(n);
    vector<int> tmp_p(3);

    for ( int i = 0; i < n; i++ ) {
        cin >> p[i];
    }

    int cnt = 0;
    for ( int i = 1; i < n - 1; i++ ) {
        tmp_p[0] = p[i-1];
        tmp_p[1] = p[i];
        tmp_p[2] = p[i+1];
        sort(tmp_p.begin(), tmp_p.end());
        if ( p[i] == tmp_p[1] ) {
            cnt++;
        }
    }

    cout << cnt << endl;

}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    N = int(input())
    P = [int(i) for i in input().split()]
    minp = P[0]
    sumP = 0
    for p in P:
        minp = min(minp, p)
        if p == minp:
            sumP += 1
    print(sumP)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
4 2 5 1 3"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
4 3 2 1"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
1 2 3 4 5 6"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """8
5 7 4 2 6 8 1 3"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """1
1"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main (){
  
int A , B ;
cin >> A >> B ;
int Sum = 0;

  if (A > B) {
    Sum += A;
   if (A - 1 > B ){
     Sum += A - 1;
   }
    else {
      Sum += B;
    }
  }  
   
  else {
    Sum += B;
   if (A < B - 1){
     Sum += B - 1;
   }
    else {
      Sum += A;
    }
  }
  
 cout << Sum;
  
  
  
}

Measured memory_bytes: 256
import sys
from collections import deque
readline = sys.stdin.readline

N, M = map(int, readline().split())
AB = [list(map(int, readline().split())) for i in range(M)]
AB = [(a-1, b-1) for a,b in AB]

adj = [[] for i in range(N)]
for a,b in AB:
    adj[a].append(b)
    adj[b].append(a)

ans = [-1] * N

q = deque()
q.append(0)

while q:
    n = q.popleft()
    for c in adj[n]:
        if ans[c] == -1:
            ans[c] = n
            q.append(c)

if all(v != -1 for v in ans[1:]):
    print('Yes')
    for c in ans[1:]:
        print(c + 1)
else:
    print('No')

Measured memory_bytes: 126868
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k = fsc.nextInt();
        System.out.print(a[k - 1]);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>

#define MAX 1000001
#define NIL (-1)
#define L 13

char H[MAX][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % MAX; }
int h2(int key){ return 1 + (key % (MAX-1)); }

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0;; i++){
    h = (h1(key)+i*h2(key))%MAX;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0; ; i++ ){
    h = (h1(key)+i*h2(key))%MAX;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, num, h;
  char str[L], com[9];
  for ( i = 0; i < MAX; i++ ) H[i][0] = '\0';
  scanf("%d", &num);
  for ( i = 0; i < num; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      if (insert(str)){

      }
    } else {
      if (find(str) ){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 13300
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  cin >> A;

  mll m;
  rep(i, N) m[A[i]] = i;
  vll sort_A = A;
  SORT(sort_A);

  ll ans = 0;
  rep(i, N) if (i % 2 == 0 and m[sort_A[i]] % 2 == 1) ans++;
  ANS;

  return 0;
}

Measured memory_bytes: 11132
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
#define ll long long
ll a[maxn];
ll g[maxn];
ll vis[maxn];
ll n,p,jk;
int main(){
	cin>>n>>p;
	for (ll i=1;i<=n;i++){
		cin>>a[i];
	}
	ll i=1;
	ll k=0;
	ll jojo;
	ll dio;
	while(vis[i]!=2){
		vis[i]++;
		k++;
		if (vis[i]==2){
			jojo=k;
			dio=g[i];
			jojo-=dio;
			dio-=1;
			break;
		}
		g[i]=k;
		i=a[i];
	}
	//cout<<dio<<endl;
	//cout<<jojo<<endl;
	if (p>=dio) {
		p-=dio;
		p%=jojo;
		while(p){
			i=a[i];
			p--;
		}
		cout<<i<<endl;
	}
	else{
		i=1;
		while(p){
			i=a[i];
			p--;
		}
		cout<<i<<endl;
	}
	return 0;
} 

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

int S(int a,int b){
	return a*b;
}
int N(int x,int y){
	return 2*x+2*y;
}
int main() {
	int c,d,e,f;
	cin >> c >> d;
	
	e=S(c,d);
	f=N(c,d);
	
	cout << e  << " " << f << endl;
	
	return 0;
}

Measured memory_bytes: 3000
#include<cstdio>
#include<iostream>
#include<string>

typedef long long ll;

class Trie {
	private :
		ll l;
		struct Node {
			Node *child[2];
			int vis;
			
			Node () :
				vis(1) {
					child[0] = NULL;
					child[1] = NULL;
				}
		};
		Node *root;
		
		ll Lowbit(ll x) {
			return x & (-x);
		}
	
	public :
		Trie() :
			root(new Node()) {}
			
		void Init(ll x) {
			l = x;
		}
		
		void Insert(std :: string s) {
			Node *now = root;
			for (int i = 0; s[i]; i++) {
				int x = s[i] - '0';
				if (!now->child[x]) {
					now->child[x] = new Node();
				}
				now = now->child[x];
			}
		}
		
		ll DFS(Node *now, int depth) {
			if (!now && depth) {
				return Lowbit(l - depth + 1);
			}
			return DFS(now->child[0], depth + 1) ^ DFS(now->child[1], depth + 1);
		}
		
		ll DFS() {
			return DFS(root, 0);
		}
};

class Solution {
	private :
		int n;
		ll l;
		std :: string s;
		Trie tree;
		
	public :
		void Get() {
			scanf("%d %lld", &n, &l);
			tree.Init(l);
			for (int i = 1; i <= n; i++) {
				std :: cin >> s;
				tree.Insert(s);
			}
		}
		
		void Solve() {
			if (tree.DFS()) {
				printf("Alice\n");
			} else {
				printf("Bob\n");
			}
		}
};
Solution sol;

int main() {
	sol.Get();
	sol.Solve();
}

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

typedef long long lli;

bool isPrime(lli x) {
  if(x <= 1) return false;
  for(lli i = 2; i*i <= x; ++i) {
    if(x % i == 0) return false; 
  }
  return true;
}

int main() {
  for(lli a, d, n; cin >> a >> d >> n && (a|d|n);) {
    for(int x = a, k = 0; ; x += d) {
      if(isPrime(x)) {
        if(++k == n) {
          cout << x << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 

using namespace std;

ll m = 1e9 + 7;
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1LL; 
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

ll gcdExtended(ll a, ll b, ll *x, ll *y); 

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    ll res = (x%m + m) % m; 
    return res;
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{  
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 

void test(){
	ll n,k;
	cin>>n>>k;
	ll sum = 0;
	ll difcount[k+1];
	memset(difcount,0,sizeof(difcount));
	for(ll i=k;i>=1;i--){
		ll totno = k/i;
		ll countseq1 = power(totno,n,m);
		countseq1 = (countseq1 - difcount[i] + m )%m;
		sum = (sum%m + (i*countseq1)%m)%m;
		
		for(ll j=1;j*j<=i;j++){
			if(i%j==0){
				difcount[j]+=countseq1;
				difcount[j]%=m;
				if(i/j!=j){
					difcount[i/j]+=countseq1;
					difcount[i/j]%=m;
				}
			}
		}
		
	}
//	sum = (sum + (totseq-count+m)%m)%m;
	cout<<sum<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

int main(){
    ll N, P, P_; cin >> N >> P;
    P_ = P;
    vector<ll> V(sqrt(P)+1);
    if(P == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N == 1){
        cout << P << endl;
        return 0;
    }

    for(ll i = 2; i*i <= P_; i++){
        while(P%i==0){
            P/=i;
            V[i]++;
        }
    }

    ll ans = 1;
    for(int i = 2; i < V.size(); i++){
        if(V[i] >= N){
            ans *= pow(i,(V[i]/N));
            //cout << i << " " << pow(i,(V[i]/N)) << endl;
        }
    }
    cout << ans << endl;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int n;
  cin>>n;
  vec a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];

  sort(all(a));
  sort(all(b));

  if(n%2==0){
    int mi=a[n/2-1]+a[n/2];
    int ma=b[n/2-1]+b[n/2];
    cout<<ma-mi+1<<endl;
  }
  else{
    int mi=a[n/2];
    int ma=b[n/2];
    cout<<ma-mi+1<<endl;
  }
  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 11112