akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a, b;
	cin >> a >> b;
	if(a%2==0 || b%2==0){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


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

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int main()
{
	int N;
	int K;
	cin >> N >> K;
	char c;
	cin >> c;
	char clast = c;
	int G = 0;
	for (int i = 1; i < N; i++) {
		cin >> c;
		if (clast != c) G++;
		clast = c;
	}
	
	if (G <= 2 * K) {
		G = 0;
	} else {
		G -= 2 * K;
	}
	
	int res = N - G - 1;
	
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define RFOR(i,a,b) for(int i=(a),i##End_=(b);i>=i##End_;i--)
const char* LF = "\n";

template <typename T>
class UnionFind {
    vector<T> u_;
public:
    UnionFind(T n) {
        u_.resize(n, -1);
    }

    T root(T a) {
        if (u_[a] < 0) return a;
        return u_[a] = root(u_[a]);
    }

    T size(T a) {
        return -u_[root(a)];
    }

    bool same(T a, T b) {
        return root(a) == root(b);
    }

    bool connect(T a, T b) {
        a = root(a);
        b = root(b);
        if (a == b) return false;
        if (size(a) < size(b)) swap(a, b);
        u_[a] += u_[b];
        u_[b] = a;
        return true;
    }
};

namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

vector<ll> A, B, Ans;

signed main() {
    ll N, M;
    cin >> N >> M;
    A.resize(M+1);
    B.resize(M+1);
    Ans.reserve(M+1);
    FOR(i, 1, M+1) cin >> A[i] >> B[i];

    UnionFind<ll> U(N+1);

    ll ans = N * (N-1) / 2;

    RFOR(i, M, 1) {
        Ans.push_back(ans);

        ll a = A[i], b = B[i];
        if (!U.same(a, b)) {
            ans -= U.size(a) * U.size(b);
            U.connect(a, b);
        }
    }

    RFOR(i, Ans.size()-1, 0) {
        cout << Ans[i] << LF;
    }

    return 0;
}


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

int main()
{
	char moji[100000];
	int NumberOfmoji;
	int slimecount = 0;

	cin >> NumberOfmoji;
	cin >> moji;

	for (int i = 0; i < NumberOfmoji; i++) {

		if (moji[i]!=moji[i + 1]) {
			slimecount++;
		}

	}
	
	cout << slimecount;


    return 0;
}


Measured memory_bytes: 384
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;

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

    lli x,mon=0;
    cin >> x;
    mon = 100;
    for(int i = 0;; ++i) {
        mon +=mon*(0.01);
        if(mon >= x) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std ;
int n,h[100000+5] , dp[100000+5];
int f( int i )
{
   // if( i < 0 ) return 1000000000 ;

    if(i==0) return  0;
    if( dp[i] != -1 ) return dp[i] ;
    if( i >= 2   ) return  dp[i] =  min(  abs(h[i]-h[i-1])+f(i-1) , abs( h[i]-h[i-2] ) + f(i-2)  ) ;
    return dp[i] = abs( h[i]-h[i-1] ) + f(i-1) ;
}
int main()
{
   // int n ;
    cin >> n ;
    //int h[n] ;
    memset( dp,-1,sizeof dp ) ;
    for( int i=0;i<n;i++ ) cin >> h[i] ;
    cout << f(n-1) ;

    return 0 ;
}


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

int main() {
	int n[2];
	for(int i=1;;i++){
		for(int j=0; j<2; j++){
			cin>>n[j];
		}
		if(n[0]==0&&n[1]==0){ break; }
		sort(n, n+2);
		cout<<n[0]<<" "<<n[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)         cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)         for(int i = 0; i < n; i++)
#define  reps(i,n)        for(int i = 1; i<=n ; i++)
#define  unq(v)           sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)           rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)         v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb               push_back
#define  eb               emplace_back
#define  mp               make_pair
#define  endl             '\n'
#define  fi               first
#define  se               second
using namespace std;
typedef long long          ll;
// use count() instead of find() in sets.
const ll MOD = 1e9 + 9;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = { -1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m ){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}






int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll h,w,k;cin>>h>>w>>k;
char c[h][w];
rep(i,h){rep(j,w){cin>>c[i][j];}}

ll ans = 0;
for(ll i = 0;i<(1<<h) ;i++){
    for(ll j = 0; j<(1<<w) ; j++){
       ll black = 0;
       for(ll k = 0;k<h;k++){

        for(ll l=0;l<w;l++){
            if(c[k][l] == '#' && (i>>k)&1 && (j>>l)&1 ){
                black++;
            }


        }
       }
       if(black == k){ans++;}

    }
}
cout<<ans;







}


Measured memory_bytes: 3672
#include <iostream>

using namespace std;


int main()
{
    int n, res = 0;

    string str;
    char prevprev, prev;

    cin>>n;

    cin>>str;

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

        prevprev = str[i-2];
        prev = str[i-1];

        if(prevprev == 'A' && prev == 'B' && str[i] == 'C')
            res++;

    }

    cout<<res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else
    {
        cout << "ABC";
    }

    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var l = cin.ReadInt;
            var apple = new int[n];
            for(int i = 0; i < n; i++)
            {
                apple[i] = l + i;
            }
            int[] abs = new int[n];
            for(int i = 0; i < n; i++)
            {
                abs[i] = Abs(apple[i]);
            }
            Array.Sort(abs);
            int ans;
            if(Array.IndexOf(apple, abs[0]) != -1)
            {
                ans = apple.Sum() -abs[0];
            }
            else
            {
                ans = apple.Sum() + abs[0];
            }

            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
(n, k) = map(int, raw_input().split())

snakes = [[] for i in xrange(n + 1)]

for i in xrange(k):
    s = int(raw_input())
    ns = map(int, raw_input().split())

    for num in ns:
        snakes[num].append(s)

tot = 0
for i in xrange(1, n + 1):
    if not snakes[i]:
        tot += 1
print tot



Measured memory_bytes: 69420
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }

        int hit = 0;
        int count = 0;
        int expected = 1;
        for (int i = 0; i < n; i++) {
            if (xs[i] == expected) {
                hit++;
                expected++;
            }
            else {
                count++;
            }
        }

        if (hit == 0) {
            System.out.println(-1);
        }
        else {
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 85352
#include <iostream>

struct Point2D {
	double x, y;
	Point2D operator-(Point2D &inp) {
		Point2D ans;
		ans.x = this->x - inp.x;
		ans.y = this->y - inp.y;
		return ans;
	}
	static double crossZ(Point2D &a, Point2D &b) {
		return a.x * b.y - a.y * b.x;
	}
};

int main() {
	int dataSet;
	Point2D p[4], v[2];
	for (std::cin >> dataSet; dataSet > 0; --dataSet) {
		std::cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y >> p[2].x >> p[2].y >> p[3].x >> p[3].y;
		v[0] = p[1] - p[0];
		v[1] = p[3] - p[2];
		std::cout << ((Point2D::crossZ(v[0], v[1]) == 0.) ? "YES" : "NO") << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

bool is_war(const vector<int>& x, const vector<int>& y) {
  for (int z = -100; z <= 100; z++) {
    bool is_ok = true;
    rep(i, 0, x.size()) if (x[i] >= z) is_ok = false;
    rep(i, 0, y.size()) if (y[i] < z) is_ok = false;
    if (is_ok) return false;
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> x(N + 1), y(M + 1);
  cin >> x[0] >> y[0];
  rep(i, 0, N) cin >> x[i + 1];
  rep(i, 0, M) cin >> y[i + 1];

  if (is_war(x, y))
    cout << "War" << endl;
  else
    cout << "No War" << endl;

  return 0;
}


Measured memory_bytes: 3632
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int N;
vector<vi> A;

vector<vi> dp;

signed main(){

    in(N);
    resize(A,N,3);
    rep(i,N) in(A[i][0],A[i][1],A[i][2]);

    resize(dp,N+1,3);
    rep(i,N){
        rep(j,3){
            dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+A[i][j];
        }
    }

    int ans=0;
    rep(i,3) ans=max(ans,dp[N][i]);

    out(ans);

    return 0;
}


Measured memory_bytes: 11136
import itertools
N=int(input())
listA=list(map(int,input().split()))
listA.sort()
listA2=[0]*N
for i in listA:
  listA2[i-1]+=1
listA=set(listA)  
for i in range(1,N+1):
  if i in listA:
    print(listA2[i-1])
  else:
    print(0)

Measured memory_bytes: 113576
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;

typedef long long ll;



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

   int N;
   cin >> N;

   for(ll n=1; n < 3501; n++){
       for(ll h=1; h < 3501; h++){
           ll t = 4*h*n - N*(n+h);
           if(t <= 0)continue;
        
           if((N*n*h)%t==0){
               ll w = (N*n*h)/t;
               if(w <= 0)continue;
               printf("%d %d %lld",h,n,w);
               return 0;
           }
        
       }
   }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int x,i,max=0,a,n;
	
	scanf("%d",&x);
	
	for(i=1;i<33;i++){
		n=i*i;
		for(a=1;a<10;a++){
			if(n>x)break;
			else if(n<=x&&max<n)max=n;
			n=n*i;
		}
	}
	
	printf("%d\n",max);
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

D = [0] * 3

ans = 1
for i in A:
  c = 0
  for j in range(3):
    if i == D[j]:
      if c == 0:
        D[j] += 1
      c += 1
  ans = ans * c % MOD

print(ans)

Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(2e5) +5;


int main()
{
    idfc;


    string s;
    cin>>s;
    if((s[2]==s[3])&&(s[4]==s[5]))cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 256
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def insert(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end


  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end

pq = PriorityQueue.new()

n, m = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i).sort

sousa = Array.new(m)
m.times do |i|
	sousa[i] = gets.chomp.split.map(&:to_i)
end

sousa = sousa.sort{|a,b| a[1] <=> b[1]}.reverse

index = 0

m.times do |i|
	sousa[i][0].times do 
		break if index >= n
		break if arr[index] >= sousa[i][1]
		arr[index] = sousa[i][1]
		index += 1
	end
	#p arr
end

puts arr.inject(:+)

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int sum = 0;
  rep(i, 3) {
    int x; cin >> x;
    sum += x;
  }
  if(sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

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

int main() {
  int A,B,C;
  
  cin >> A >> B >> C;
  
  int count_5 = 0 , count_7 = 0  ;
  
  if(A==5){
  	count_5 ++;
  }
  if(B==5){
  	count_5 ++;
  }
  if(C==5){
  	count_5 ++;
  }  
  
  if(A==7){
  	count_7 ++;
  }
  if(B==7){
  	count_7 ++;
  }
  if(C==7){
  	count_7 ++;
  } 
  
  if(count_5 == 2 && count_7 == 1){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());
    if (A[0] < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    int g = A[0];
    for (int i = 1; i < N; i++) {
        g = gcd(g, A[i]);
    }

    if (K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 640
/**
 *    author:  tourist
 *    created: 11.05.2020 14:08:35       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size() << '\n';
  return 0;
}


Measured memory_bytes: 19244
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)

alpha=Y[N//2-1]
beta=Y[N//2]

S=[0]*N
for k in range(N):
    x=X[k]
    if x<=alpha:
        S[k]=beta
    else:
        S[k]=alpha

print("\n".join(map(str,S)))


Measured memory_bytes: 114568
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

l,r,d=MI()
print(r//d-(l-1)//d)

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

pair<long long, long long> p[51],P[51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;

    for(int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;
    for(int i = 0; i < n; ++i)
        P[i] = make_pair(p[i].second, p[i].first);

    sort(p, p + n); sort(P, P + n);

    long long area = -1;
    for(int a = 0; a < n; ++a){
        for(int b = a; b < n; ++b){
            for(int c = 0; c < n; ++c){
                for(int d = c; d < n; ++d){
                    long long lx = p[a].first;
                    long long rx = p[b].first;
                    long long ly = P[c].first;
                    long long ry = P[d].first;
                    if(area != -1 && (rx - lx) * (ry - ly) >= area)
                        continue;
                    long long cnt = 0;
                    for(int i = 0; i < n && cnt < k; ++i){
                        if(lx > p[i].first || p[i].first > rx)
                            continue;
                        if(ly > p[i].second || p[i].second > ry)
                            continue;
                        ++cnt;
                    }
                    if(cnt == k)
                        area = (rx - lx) * (ry - ly);
                }
            }
        }
    }

    cout << area;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	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();
    	}

    	Arrays.sort(a);

    	int min=999999999;

    	for(int i=a[0];i<=a[N-1];i++) {
    		int cost=calc(i,a);

    		if(min>cost) {
    			min=cost;
    		}
    	}

    	System.out.println(min);

    }

    public static int calc(int m,int[] a) {

    	int result=0;
    	for(int i=0;i<a.length;i++) {
    		result+=Math.abs((a[i]-m)*(a[i]-m));
    	}

    	return result;

    }


}



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

int main(){
int K, S;
  cin >> K >> S;
int cnt = 0;
  for(int x = 0;x <= K;x++){
    for(int y = 0; y <= K;y++){
      if((S-x-y <= K) && (S-x-y >= 0)){
      cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;
int main() {
	double W, H, X, Y;
	cin >> W >> H >> X >> Y;
	cout << (W * H) / 2 << " ";
	if (W / 2 == X && H / 2 == Y) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
s1 = set()
sn = set()
for a,b in src:
    if a == 1:
        s1.add(b)
    elif a == N:
        sn.add(b)
    if b == 1:
        s1.add(a)
    elif b == N:
        sn.add(a)
ok = len(s1 & sn) > 0
print('POSSIBLE' if ok else 'IMPOSSIBLE')

Measured memory_bytes: 37156
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = v[1::2]
b = v[0::2]
a2 = Counter(a)
b2 = Counter(b)

if a2.most_common()[0][0] != b2.most_common()[0][0]:
    print(n-a2.most_common()[0][1]-b2.most_common()[0][1])
else:
    if len(a2.most_common()) == len(b2.most_common()) == 1:
        print(len(a)-a2.most_common()[0][1]+len(b))
    elif len(a2.most_common()) == 1:
        if len(b)-b2.most_common()[1][1] >= len(a)+len(b)-b2.most_common()[0][1]:
            print(len(a)+len(b)-b2.most_common()[0][1])
        else:
            print(len(b)-b2.most_common()[1][1])
    elif len(b2.most_common()) == 1:
        if len(a)-a2.most_common()[1][1] >= len(a)+len(b)-a2.most_common()[0][1]:
            print(len(a)+len(b)-a2.most_common()[0][1])
        else:
            print(len(a)-a2.most_common()[1][1])
    else:
        if len(a)-a2.most_common()[0][1]+len(b)-b2.most_common()[1][1] >= len(a)-a2.most_common()[1][1]+len(b)-b2.most_common()[0][1]:
            print(len(a)-a2.most_common()[1][1]+len(b)-b2.most_common()[0][1])
        else:
            print(len(a)-a2.most_common()[0][1]+len(b)-b2.most_common()[1][1])



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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

int main(){
    int a,b;
    cin>>a>>b;
    int x=b-a;
    cout<<x*(x+1)/2-b;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919810893;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll N;
    cin >> N;
    V v(N);
    rep(i, N)cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());
    if(N % 2){
        ll ans = 0;
        rep(i, N / 2)ans += v[i] * 2;
        for(ll i = N / 2, j = 0; i < N; i++, j++){
            ans -= v[i];
            if(j >= 2)ans -= v[i];
        }
        ll ans2 = 0;
        for(ll i = N / 2, j = 0; i >= 0; i--, j++){
            ans2 += v[i];
            if(j >= 2)ans2 += v[i];
        }
        for(ll i = (N + 1) / 2; i < N; i++){
            ans2 -= v[i] * 2;
        }
        cout << max(ans, ans2) << endl;
    }
    else{
        ll ans = 0;
        for(ll i = 0; i < N / 2; i++){
            ans += v[i];
            if(i + 1 < N / 2)ans += v[i];
        }
        for(ll i = N / 2; i < N; i++){
            ans -= v[i];
            if(i > N / 2)ans -= v[i];
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 10007;
const ld PI = acosl(-1);

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

    ll N, D;
    cin >> N >> D;
    D *= D;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        ll X, Y;
        cin >> X >> Y;
        ll res = X * X + Y * Y;
        cnt += (res <= D);
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int min_ans = 6;
const int N = 4;
int a[4][4];
struct Bubble{
  int x, y, r;
  Bubble() {}
  Bubble(int x, int y, int r) : x(x), y(y), r(r) {}
};
int dfs(int K){
  if(K >= min_ans) return INF;

  stack<Bubble> stk;
  do{
    stack<Bubble> nstk;
    while(!stk.empty()){
      Bubble b = stk.top(); stk.pop();
      int nx = b.x + dx[b.r];
      int ny = b.y + dy[b.r];
      if(!valid(nx, ny, N, N)) continue;
      if(a[ny][nx] > 0){
        a[ny][nx]++;
      }else{
        nstk.push(Bubble(nx, ny, b.r));
      }
    }
    stk = nstk;
    REP(y, N) REP(x, N) if(a[y][x] >= 5) {
      a[y][x] = 0;
      REP(r, 4) stk.push(Bubble(x, y, r));
    }
  }while(!stk.empty());

  bool end = true;
  REP(i, N) REP(j, N) if(a[i][j] != 0) end = false;
  if(end) return min_ans = K;

  int tmp[4][4];
  memcpy(tmp, a, sizeof(a));

  int res = INF;
  REP(i, N) REP(j, N){
    a[i][j]++;
    res = min(res, dfs(K + 1));
    memcpy(a, tmp, sizeof(a));
  }
  return res;
}

int main(){
  while(true){
    min_ans = 6;
    REP(i, N) REP(j, N) cin >> a[i][j];
    if(cin.eof()) break;
    int ans = dfs(0);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;// 1e9 + 7

string s;
ll x, y;
ll ix = 0, iy = 0;
ll mx[8000];
ll my[8000];
bool px[2][16001];
bool py[2][16001];

int main() {
	cin >> s >> x >> y;

	bool F = true;
	bool X = true;
	rep(i, 0, s.size()) {
		if (s[i] == 'T') {
			if (X) {
				ix++;
			}
			else {
				iy++;
			}
			X = !X;
		}
		else if (s[i] == 'F') {
			if (X) {
				mx[ix]++;
			}
			else {
				my[iy]++;
			}
		}
	}

	px[0][8000] = true;
	py[0][8000] = true;
	ll L = max(ix, iy);
	repe(j, 0, L) {
		ll J = j % 2;
		ll JR = (j + 1) % 2;
		rep(i, 0, 16001) {
			if (px[J][i]) {
				px[JR][i + mx[j]] = true;
				if (j != 0) px[JR][i - mx[j]] = true;
				px[J][i] = false;
			}
			if (py[J][i]) {
				py[JR][i + my[j]] = true;
				py[JR][i - my[j]] = true;
				py[J][i] = false;
			}
		}
	}
	/////////////////////////////////////////////
	ll A = (L + 1) % 2;

	cout << ((px[A][x + 8000] && py[A][y + 8000]) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	if(a > b)swap(a, b);
	rep(i, n) {
		int k = n -1- i;
		if(a+i*c-d*k <= b && b <= a+i*d-c*k) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //freopen("outp.out", "w", stdout);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for(int i=0; i<n; i++) scanf("%d", &v[i]);
    vector<int> pos(n+5, -1);
    for(int i=0; i<n; i++) pos[v[i]]=i;
    vector<int> longest(n+5, 1);
    for(int i=1; i<n; i++)
    {
        if(pos[v[i]-1]<pos[v[i]] && v[i] != 1)
        {
            longest[v[i]]=longest[v[i]-1]+1;
        }
        else
        {
            longest[v[i]]=1;
        }
    }
    int ans=n;
    for(int i=1; i<=n; i++)
    {
        //cerr << longest[i] << endl;
        ans=min(ans, n-longest[i]);
    }
    printf("%d\n", ans);

    return 0;
}


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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int a[N],mxd[N],k;vector<int>lk[N];
int ans;

void dfs(int x)
{
	mxd[x]=1;
	for(auto y:lk[x])
	{
		dfs(y);
		chmax(mxd[x],mxd[y]+1);
	}
	if(a[x]!=1&&mxd[x]==k)
	{
		++ans;
		mxd[x]=0;
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	int n;cin>>n>>k;
	rep(i,1,n)scanf("%d",a+i);
	ans=a[1]!=1;
	a[1]=1;
	rep(i,2,n)lk[a[i]].push_back(i);
	dfs(1);
	cout<<ans;
}

Measured memory_bytes: 11136
import java.io.*;
  
public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] inputs = br.readLine().split(" ");
    int a = Integer.parseInt(inputs[0]), b = Integer.parseInt(inputs[1]);
    int volume = a * b;
    int length = (a + b) * 2;
  
    System.out.println(volume + " " + length);
  }
}

Measured memory_bytes: 24300
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, y = na()
m = -1
f = -1
t = -1
for i in range(int(y/10000)+1):
        yleft = y - i * 10000
        nleft = n - i
        for j in range(int(yleft/5000)+1):
                if (j * 5000 + (nleft - j) * 1000) == yleft:
                        m = i
                        f = j
                        t = n - i - j
                        break


print('{} {} {}'.format(m, f, t))




Measured memory_bytes: 5072
#include <stdio.h>

#define break(A) break

int main() {
	int i, A, B;
	char s[20] = {0};
	scanf("%d%d%s", &A, &B, s);
	for (i=0; i < A+B+1 ;i++) {
		if (s[i] == '\0') break(0);
		if (s[i] == '-') {
			if (i != A) break(1);
		} else if (i == A) break(3);
		else if (!(s[i] <= '9' && s[i] >= '0')) break(2);
	}
	if (i == A+B+1 && s[i] == '\0') {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

if M <= N:
    print(0)
    exit()

X.sort(reverse=True)

diff = []
for x_l, x_s in zip(X[:-1], X[1:]):
    diff.append(x_l - x_s)

diff.sort(reverse=True)

print(sum(diff[N-1:]))


Measured memory_bytes: 13968
package main

import (
	"fmt"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	ds := make([]int, n)
	for i := 0; i < n; i++ {
		ds[i] = abs(x - xs[i])
	}

	ans := ds[0]
	for i := 0; i < n; i++ {
		ans = gcd(ans, ds[i])
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 7132
n = int(input())
s = []
zyogen = []
kagen = []
for i in range(n):
    k, z = map(int, input().split())
    kagen.append(k)
    zyogen.append(z)

kk = sorted(kagen)
zz = sorted(zyogen)
if(n % 2 == 0):
    aa = n // 2
    x = kk[aa-1] + kk[aa]
    y = zz[aa-1] + zz[aa]
    print(y-x+1)
else:
    aa = n // 2
    x = kk[aa]
    y = zz[aa]
    print(y-x+1)
    

Measured memory_bytes: 28616
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
long long mod = 1000000007;//10^9 + 7
//---------------------------------------------------------------------------------------------------
vector<long long> f(1000010);
vector<long long> rf(1000010);
long long n;
long long inv(long long x) {
    long long res = 1;
    long long k = mod - 2;
    long long y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;//kが存在かつ値 k == 1
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f.at(0) = 1;
    for(long long i = 1; i < 1000010; i++){
        f.at(i) = (f.at(i - 1) * i) % mod;
        rf.at(i) = inv(f.at(i));//逆元も同時にメモ
    }//n!をmodで割っていったものを求めている
}
//---------------------------------------------------------------------------------------------------
long long C(int n, int k) {
    long long a = f.at(n); // = n!%mod
    long long b = rf.at(n - k); // = (n-k)!%mod
    long long c = rf.at(k); // = k!%mod

    long long bc = (b * c) % mod;

    return (a * bc) % mod;
}
/*メンチン待ちクイズ*/
void solve(){
    long long x, y;
    cin >> x >> y;
    if((x + y) % 3 != 0 || y > 2 * x || x > 2 * y){
        cout << 0 << endl;
    }//絶対に到達しようがないとき
    else{
    /*nCkについて考える*/
    n = (x + y) / 3;
    long long k;
    k = (x - n);
    k = min(k, n - k);
    if(k == 0){
        cout << 1 << endl;
    }
    else{
    init();
        cout << C(n, k) << endl;
    }
    }
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main(){
  unsigned long long X, i, ci, count=0;
  unsigned  long long balance=100;
  scanf("%llu",&X);
  while(X > balance){
    ci = (0.01)*(balance);
    balance += ci;
    count += 1;
  }
  printf("%llu",count);
  return 0;
}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;	
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = 55555;
bitset<MAX>check;
vector<int>pr;
void build(){
	rep1(i, 2, MAX){
		if(!check[i]){
			if(i % 5 == 3) pr.pb(i);
			for(int j = i; j < MAX; j += i) check[j] = 1;
		}
	}
	return ;
}
int main(void){
	DRI(n);
	build();
	rep(i, n) printf("%d ", pr[i]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;


int main()
{
    int n;
    cin >> n;
    int d[n];
    for (int i=0; i<n; i++) {
        cin >> d[i];
    }
    sort(d, d+n);
    cout << d[n/2] - d[n/2-1] << '\n';
   
    return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int s;
  cin >> s;
  rep(i, 1000002){
    if(s == 4 || s == 2 || s == 1){
      cout << i + 4 << endl;
      break;
    }
    if(s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
  }
}


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void sol(ll a, ll b, char ca, char cb) {

    vvc s(100, vc(100, cb));
    b--;

    int i = 0;
    int j = 0;

    while (b > 0) {
        int cx = 4 * i + 2;
        int cy = 5 * j + 2;

        for (int x = cx - 1; x <= cx + 1; x++) {
            for (int y = cy - 1; y <= cy + 1; y++) {
                if (y != cy || x != cx) {
                    s[x][y] = ca;
                }
            }
        }

        j++;
        if (j == 20) {
            i++;
            j = 0;
        }
        b--;
        a--;
    }
    while (a > 0) {
        int cx = 4 * i + 2;
        int cy = 5 * j + 2;

        s[cx][cy] = ca;
        j++;
        if (j == 20) {
            i++;
            j = 0;
        }
        a--;
    }

    cout << 100 << " " << 100 << endl;
    for (auto z : s) {
        for (auto c : z) {
            cout << c;
        }
        cout << endl;
    }
}

void solve() {
    ll a, b; cin >> a >> b;
    if (a > b)
        sol(a, b, '.', '#');
    else
        sol(b, a, '#', '.');
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3640