akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000
#define INF 100000000000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);
ll fac(ll a);

int main(){
  int n,m;
  cin >> n >> m;
  if(abs(n-m) <= 1){
    ll ans = 0;
    if(n == m){
      ans = fac(n)*fac(m)*2 % 1000000007;
      cout << ans <<endl;
    }
    else{
      ans = fac(n)*fac(m) % 1000000007;
      cout << ans << endl;
    }
  }
  else{
    cout << 0 << endl;
  }
}

ll fac(ll a){
  ll ans = 1;
  erep1(i,a){
    ans *= i;
    ans %= 1000000007;
  }
  return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

int A,B,C,N,M,K,X,Y,Z;
string t[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

signed main(){
	string s;
	cin>>s;
	REP(i,7){
		if(s==t[i]){
			cout<<7-i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (H,W)=readLine()!!.split(" ").map(String::toLong)

    val ans =   if(H%3 ==0L || W %3 == 0L){0L} else {
      val side_h = (1.until(W)).fold(H*W) { res,col ->
        val adjustor=if(H%2==0L) {0L} else {1L}
        val piece=arrayOf(H*col,(H-adjustor)*(W-col)/2,(H+adjustor)*(W-col)/2)
        
        arrayOf(piece.max()!!-piece.min()!!,res).min()!!
      } 
      val side_w = (1.until(H)).fold(H*W) { res,row ->
        val adjustor=if(W%2==0L) {0L} else {1L}
        val piece=arrayOf(W*row,(W-adjustor)*(H-row)/2,(W+adjustor)*(H-row)/2)
      arrayOf(piece.max()!!-piece.min()!!,res).min()!!
      }
      arrayOf(arrayOf(side_h,H).min()!!,arrayOf(side_w,W).min()!!).min()!!
    }      
    println(ans)
  }
}


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


int main(){

    int a,b,c;
    list <int>  L;
    list <int>:: iterator it=L.end();
    scanf("%d ",&a);
    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0){
            scanf("%d",&c);
            it=L.insert(it,c);
            }
    else if (b==1){
             scanf("%d",&c);
             if(c>0){for(int m=0;m<+c;m++){it++;}}
             else{
                for(int n=0;n<-c;n++)it--;}
    }
    else if (b==2 && !L.empty())it=L.erase(it);}
    for(it= L.begin(); it!=L.end();it++){
                printf("%d\n",*it);}


    return 0;



}




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

using namespace std;

typedef struct{
   long long x,y,z;
}cake_;

long long cake_sum(cake_ cake, int case_){
  int a[8][3] = {
    {1,1,1}, {1,1,-1}, {1,-1,1}, {1,-1,-1},
    {-1,1,1}, {-1,1,-1}, {-1,-1,1}, {-1,-1,-1}
  };

  long long ret;
  ret = cake.x*a[case_][0] + cake.y*a[case_][1] + cake.z*a[case_][2];
  
  return ret;
}

long long func(int N, int M){
  vector<vector<long long> > case_(8);

  if(M == 0)  return 0LL;

  int i;
  // とりあえず，食べるケーキ数分は
  // case_にいれる
  for(i = 0; i < M; i++){
    cake_ cake;
    cin >> cake.x >> cake.y >> cake.z;
    // 8個の場合で合計を取得する（cake_sum関数）
    for(int j = 0; j < 8; j++){
      case_[j].push_back(cake_sum(cake, j));
    }
  }
  // sort
  for(int j = 0; j < 8; j++){
    sort(case_[j].begin(), case_[j].end());
  }
  
  // 食べるケーキ < 入力するケーキ数
  // となったとき,case_の最小値と入力した値の合計値を
  // 比べ，最小値より大きかったら入れ換える
  for(; i < N; i++){
    cake_ cake;
    cin >> cake.x >> cake.y >> cake.z;
    for(int j = 0; j < 8; j++){
      long long tmp = cake_sum(cake, j);
      if(case_[j][0] < tmp){
        case_[j][0] = tmp;
        // 入れ換えた時点でsort
        sort(case_[j].begin(), case_[j].end());
      }
    }
  }

  // case_それぞれの合計を取得
  vector<long long> sum;
  for(int j = 0; j < 8; j++){
    sum.push_back(0);
    for(int k = 0; k < M; k++){
      sum[j] += case_[j][k];
    }
  }
  sort(sum.begin(), sum.end());
  // 昇順sortのため，最後尾の値が最大値
  return sum[7];
}

int main(){
  int N, M;
  cin >> N >> M;
  
  long long ans;

  ans = func(N, M);
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<int> P(N);
    REP(N) cin >> P[i];

    int min = N+1;
    int ans = 0;
    REP(N) {
        if(P[i] <= min) {
            ans++;
            min = P[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

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

    int n, d, w;
    while (true)
    {
        cin >> n >> w >> d;
        if (n == 0 && w == 0 && d == 0)
            break;
        std::vector<P> cake;
        cake.push_back(P(w, d));
        for (int i = 0; i < n; i++)
        {
            int p, s;
            cin >> p >> s;
            p--;
            int wtmp = cake[p].first, dtmp = cake[p].second;
            cake.erase(cake.begin() + p);
            s %= (wtmp + dtmp) * 2;
            if (s <= wtmp)
            {
                P div1 = P(s, dtmp), div2 = P(wtmp - s, dtmp);
                if (div1.first * div1.second < div2.first * div2.second)
                {
                    cake.push_back(div1);
                    cake.push_back(div2);
                }
                else
                {
                    cake.push_back(div2);
                    cake.push_back(div1);
                }
            }
            else if (wtmp <= s && s <= wtmp + dtmp)
            {
                P div1 = P(wtmp, s - wtmp), div2 = P(wtmp, wtmp + dtmp - s);
                if (div1.first * div1.second < div2.first * div2.second)
                {
                    cake.push_back(div1);
                    cake.push_back(div2);
                }
                else
                {
                    cake.push_back(div2);
                    cake.push_back(div1);
                }
            }
            else if (wtmp + dtmp <= s && s <= wtmp * 2 + dtmp)
            {
                P div1 = P(2 * wtmp + dtmp - s, dtmp), div2 = P(s - dtmp - wtmp, dtmp);
                if (div1.first * div1.second < div2.first * div2.second)
                {
                    cake.push_back(div1);
                    cake.push_back(div2);
                }
                else
                {
                    cake.push_back(div2);
                    cake.push_back(div1);
                }
            }
            else
            {
                P div1 = P(wtmp, 2 * wtmp + 2 * dtmp - s), div2 = P(wtmp, s - 2 * wtmp - dtmp);
                if (div1.first * div1.second < div2.first * div2.second)
                {
                    cake.push_back(div1);
                    cake.push_back(div2);
                }
                else
                {
                    cake.push_back(div2);
                    cake.push_back(div1);
                }
            }
        }
        std::vector<int> res;
        for (int i = 0; i < (int)cake.size(); i++)
            res.push_back(cake[i].first * cake[i].second);
        sort(res.begin(), res.end());
        for (int i = 0; i < (int)res.size(); i++)
        {
            cout << res[i];
            if (i < (int)res.size() - 1)
                cout << " ";
            else
                cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, col[N];
VII child[N];
bool vis[N];

void dfs(int v, int h) {
  vis[v] = true;
  if (h&1)
    col[v] = 1;
  for (const auto& el: child[v]) {
    if (vis[el.ST])
      continue;
    dfs(el.ST, (h+el.ND)%2);
  }
}

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v, x;
    cin >> u >> v >> x;
    x %= 2;
    child[u].PB({v, x});
    child[v].PB({u, x});
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i)
    cout<<col[i]<<"\n";
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,k=1;
    cin>>n;
    if(n==1){cout<<"No"<<endl; return 0;}
    while(k*2<=n) k*=2;
    if(k==n){cout<<"No"<<endl; return 0;}
    else if(2*k==n+1){
        cout<<"Yes"<<endl;
        REP(i,1,2*n) cout<<i<<" "<<i+1<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    REP(i,1,k-1) cout<<i<<" "<<i+1<<endl;
    cout<<k-1<<" "<<n+1<<endl;
    REP(i,n+1,n+k-1) cout<<i<<" "<<i+1<<endl;
    cout<<1<<" "<<k<<endl;
    cout<<k<<" "<<k+1<<endl;
    cout<<1<<" "<<n+k+1<<endl;
    cout<<n+k+1<<" "<<n+k<<endl;
    REP(i,k+2,n+1){
        int j=i-k-1;
        if((j/2)%2==0){
            cout<<n+k+1<<" "<<i<<endl;
            cout<<((j+1)/2)*2<<" "<<n+i<<endl;
        }else{
            cout<<k<<" "<<i<<endl;
            cout<<((j+1)/2)*2<<" "<<n+i<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
#define INF 1e9+5
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define popf pop_front
#define popb pop_back

int a,b, k;
bool can;

int main(){
	scanf("%d%d%d", &k, &a, &b);
	for(int i=k; i<=b; i+=k){
		if(i>=a){
			can=true;
			break;
		}
	} if(can) printf("OK");
	else printf("NG");


	return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>

using namespace std;

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

	}
	int m;
	cin >> m;
	int p, x;
	vector<int> ans(m);
	for (int j = 0; j < m; ++j) {
		cin >> p >> x;
         ans[j] = sum - t[p-1] + x;
	
	}

	for (int i = 0; i < m; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math

n = int(input())
a = list(map(int, stdin.readline().rstrip().split()))

#print(odd)
#print(pair)


## pair > odd
count_pair = 0
current_sum = 0
diff = 0
for i in range(len(a)):
    if i % 2 == 0:
        if current_sum + a[i] < 1:
            diff = 1 - (current_sum + a[i])
            count_pair += diff
        else:
            diff = 0
    elif i % 2 == 1:
        if current_sum + a[i] > -1:
            diff = -1 - (current_sum + a[i])
            count_pair += -1 * diff
        else:
            diff = 0

    current_sum += a[i] + diff
    if current_sum == 0:
        print("Error")

# odd > pair
count_odd = 0
current_sum = 0
diff = 0
i=0
for i in range(len(a)):
    if i % 2 == 1:
        if current_sum + a[i] < 1:
            diff = 1 - (current_sum + a[i])
            count_odd += diff
        else:
            diff = 0
    elif i % 2 == 0:
        if current_sum + a[i] > -1:
            diff = -1 - (current_sum + a[i])
            count_odd += -1 * diff
        else:
            diff = 0


    current_sum += a[i] + diff
    if current_sum == 0:
        print("Error")


print(min(count_odd, count_pair))


Measured memory_bytes: 14332
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>






const int M = 1000000007;
ll n, sz00, sz01, sz10, a, b, g, res, sz, sz2;

map<ii, ii>m;
map<ii, ii>::iterator it;




ll sm(ll a, ll b)
{
	a %= M;
	b %= M;
	return (a + b) % M;
}


ll prdct(ll a, ll b)
{
	a %= M;
	b %= M;
	return (a*b) % M;
}


ll pw(ll b, ll p)
{
	if(p == 0)return 1;
	ll ret;
	ret = pw(b, p / 2);
	ret = prdct(ret, ret);
	if(p % 2 == 1)ret = prdct(ret, b);
	return ret;
}




ll gcd(ll a, ll b)
{
	if(b == 0)return a;
	return gcd(b, a%b);
}

ll absLL(ll a)
{
	if(a < 0)a *= -1;
	return a;
}

int sgn(ll a)
{
	if(a < 0)return -1;
	return 1;
}





void solve()
{
	cin >> n;
	sz00 = 0;
	sz01 = 0;
	sz10 = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> a >> b;
		if(a == 0 && b == 0)
		{
			sz00++;
		}
		else if(a == 0)
		{
			sz01++;
		}
		else if(b == 0)
		{
			sz10++;
		}
		else
		{
			g = gcd(absLL(a), absLL(b));
			a /= g;
			b /= g;
			if(sgn(a) == sgn(b))
			{
				m[mp(absLL(a), absLL(b))].st++;
			}
			else
			{
				m[mp(absLL(b), absLL(a))].nd++;
			}
		}
	}
	res = sm(sm(pw(2, sz01), pw(2, sz10)), M - 1);
	for(it = m.begin(); it != m.end(); it++)
	{
		sz = (it->nd).st;
		sz2 = (it->nd).nd;
		res = prdct(res, sm(sm(pw(2, sz), pw(2, sz2)), M - 1));
	}
	res = sm(res, sz00);
	res = sm(res, M - 1);
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 19168
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    int count=0;
    rep(i, n)
    {
        int a;
        cin>>a;
        if(a%2==1){
            count++;
        }
    }
    if(count%2==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	ll l, r;
	cin >> l >> r;

	ll ans = LINF;
	ll point = ((l % 2019) - 1) % 2019;
	if (point == -1)
	{
		point = 2018;
	}

	for (ll i = l; i < r; i++)
	{
		ll jPoint = (((i + 1) % 2019) - 1) % 2019;
		if (jPoint == -1)
		{
			jPoint = 2018;
		}
		for (int j = i + 1; j <= r; j++)
		{
			if (j % 2019 == jPoint)
			{
				break;
			}
			ans = min(ans, (i * j) % 2019);
		}
		if (i % 2019 == point)
		{
			break;
		}
	}

	cout << ans << endl;

}

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

int n, N, a[200005], b[200005], c[200005], l, r, m, fp;

bool ShAM() {
	for(int i = 1; i <= N; ++i) c[i] = 0;
	for(int i = 2; i <= N; ++i) {
		if(b[i] == b[i - 1]) {
			c[i] = c[i - 1] = 1;
		}
	}
	int k = 1e9, t = 1e9;
	for(int i = N / 2 + 1; i <= N; ++i) {
		if(c[i]) {
			k = i - (N / 2 + 1);
			break;
		}
	}
	for(int i = N / 2; i >= 1; --i) {
		if(c[i]) {
			t = N / 2 + 1 - i;
			break;
		}
	}
	return (k == 0) ? b[N / 2 + 1] : (k > n - 1 && t > n - 1) ? ((bool)b[N / 2 + 1] ^ (bool)(n & 1 ^ 1)) : (k == t) ? (b[N / 2 + 1 + k] && b[N / 2 + 1 - t]) ? 1 : (!b[N / 2 + 1 + k] && !b[N / 2 + 1 - t]) ? 0 : ((bool)b[N / 2 + 1] ^ (bool)(k & 1 ^ 1)) : (k < t) ? (bool)b[N / 2 + 1 + k] : (bool)b[N / 2 + 1 - t];
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n; N = 2 * n - 1;
	for(int i = 1; i <= N; ++i) {
		cin >> a[i];
	}
	l = 1;
	r = N;
	while(l <= r) {
		m = (l + r) / 2;
		for(int i = 1; i <= N; ++i) {
			if(a[i] <= m) b[i] = 1;
			else b[i] = 0;
		}
		if(ShAM()) {
			fp = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	cout << fp << endl;
	return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  i64 answer = std::numeric_limits<i64>::max();
  for (i64 i = 0; i <= static_cast<i64>(S.size()) - 3; ++i) {
    answer = std::min<i64>(answer, std::abs(std::stol(S.substr(i, 3)) - 753));
  }
  std::cout << answer << std::endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long[] a = new long[n], b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		Arrays.sort(a);
		Arrays.sort(b);

		int mid = n / 2;
		if (n % 2 == 0) { // .5も含む
//			double min = (a[mid - 1] + a[mid]) / 2;
//			double max = (b[mid - 1] + b[mid]) / 2;
//			System.out.println((int) (max - min) * 2 + 1); // (max-min+1)*2-1
			
			// 整数で扱っても結果は変わらない．
			long min = (a[mid - 1] + a[mid]);
			long max = (b[mid - 1] + b[mid]);
			System.out.println(max - min + 1);
		} else {
			// 整数値のみ
			System.out.println(b[mid] - a[mid] + 1);
		}
	}
}


Measured memory_bytes: 62768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int> vec;
    int o=0,z=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            if(z!=0)vec.pb(z);
            o++;
            z=0;
        }
        else{
            if(o!=0)vec.pb(o);
            z++;
            o=0;
        }
    }
    if(o>0)vec.pb(o);
    else vec.pb(z);
    //for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";cout<<endl;
    int bl=0;
    if(s[0]=='1'){
        for(int i=1;i<vec.size();i+=2)bl++;
    }
    else{
        for(int i=0;i<vec.size();i+=2)bl++;
    }
    //cout<<bl<<endl;
    if(bl<=k){
        cout<<n<<endl;
        return 0;
    }
    int ma=0;
    if(s[0]=='1'){
        int co=0,ans=0;
        for(int i=0;i<=(2*k);i++){
            ans+=vec[i];
        }
        ma=ans;
        for(int i=(2*k)+1;i<vec.size();i++){
            ans-=vec[i-(2*k)];
            ans-=vec[i-((2*k)+1)];
            ans+=vec[i];
            if(i+1<vec.size()){ans+=vec[i+1];i++;}
            ma=max(ma,ans);
        }
    }
    else{
        int co=0,ans=0;
        for(int i=0;i<(2*k);i++){
            ans+=vec[i];
        }
        //cout<<ans<<endl;
        ma=ans;
        ans-=vec[0];
        ans+=vec[2*k];
        if((2*k)+1<vec.size())ans+=vec[(2*k)+1];
        ma=max(ma,ans);
        for(int i=(2*k)+2;i<vec.size();i++){
            ans-=vec[i-(2*k)];
            ans-=vec[i-((2*k)+1)];
            ans+=vec[i];
            if(i+1<vec.size()){ans+=vec[i+1];i++;}
            ma=max(ma,ans);
        }
    }
    cout<<ma<<endl;

    return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
  int i,A,B,C,D,S;
  
  cin >> S;
  A = S/1000;
  B = (S/100)%10;
  C = (S/10)%10;
  D = S%10;
  
  if(A+B+C+D==7) {
    printf("%d+%d+%d+%d=7\n", A, B, C, D);
  } else if(A+B+C-D==7) {
    printf("%d+%d+%d-%d=7\n", A, B, C, D);
  } else if(A+B-C+D==7) {
    printf("%d+%d-%d+%d=7\n", A, B, C, D);
  } else if(A+B-C-D==7) {
    printf("%d+%d-%d-%d=7\n", A, B, C, D);
  } else if(A-B+C+D==7) {
    printf("%d-%d+%d+%d=7\n", A, B, C, D);
  } else if(A-B+C-D==7) {
    printf("%d-%d+%d-%d=7\n", A, B, C, D);
  } else if(A-B-C+D==7) {
    printf("%d-%d-%d+%d=7\n", A, B, C, D);
  } else if(A-B-C-D==7) {
    printf("%d-%d-%d-%d=7\n", A, B, C, D);
  }

  return 0;
}

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

int a[4];

int main()
{
    for (int i = 0; i < 10; i++)
    {
        cin >> a[3];
        for (int j = 2; j >= 0; j--)
        {
            if (a[j] < a[j+1])
            {
                swap(a[j], a[j+1]);
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
        cout << a[i] << endl;
    }
    return 0;
}

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

using namespace std;

int main(void) {
  int n;
  while (cin >> n, n) {
    int h[2], m[2], s[2], run[60 * 60 * 24 + 1] = {};
    for (int i = 0; i < n; i++) {
      for (int i = 0; i < 2; i++) {
        scanf("%02d:%02d:%02d", &h[i], &m[i], &s[i]);
      }
      for (int i = 0; i < 2; i++) {
        int t = h[i] * 3600 + m[i] * 60 + s[i];
        run[t] += i ? -1 : 1;
      }
    }

    int ans = 0;
    for (int i = 1; i <= 60 * 60 * 24; i++) {
      run[i] += run[i - 1];
      ans = max(ans, run[i]);
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
    long long N;
    cin >> N;
    long long ans=0;
    for(int i=1;i<=N-1;i++){
            const auto &pf = prime_factorize(i);
            long long res = 1;
            for (auto p : pf) res *= p.second + 1;
            ans+=res;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*
 * @Author: RBQRBQ
 * @Date: 2020-05-30 20:06:58
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-05-30 20:08:23
 */ 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    ll q=a*60+b;
    ll p=c*60+d;
    cout<<max(p-q-e,0ll);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> prime(0);
    prime.push_back(2);
    for (ll i = 3; i <= N; i++){
        ll len = prime.size();
        bool isPrime = true;
        rep(j,len){
            if (i % prime[j] == 0) isPrime = false;
        }
        if (isPrime){
            prime.push_back(i);
        }
    }
    ll len = prime.size();
    vector<pair<ll,ll> > prime_copy(len);
    for (ll i = 0; i < len; i++){
        prime_copy[i].first = prime[i];
        prime_copy[i].second = 0;
    }
    for (ll i = 0; i < len; i++){
        for (ll j = 1; j <= N; j++){
            ll copy_j = j;
            while(true){
                if (copy_j % prime_copy[i].first != 0){
                    break;
                }
                else{
                    copy_j /= prime_copy[i].first;
                    prime_copy[i].second++;
                }
            }
        }
    }
    ll ans = 1;
    for (ll i = 0; i < len; i++){
        ans = (ans * (prime_copy[i].second + 1)) % 1000000007;
    }
    if (N == 1) cout << 1 << endl;
    else if (N == 2) cout << 2 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n, x, t ;
    cin >> n >> x >> t ;
    if(n % x == 0){
        cout << n/x * t << endl ;
    }
    else {
        cout << (n/x + 1) * t << endl ;
    }
} 

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    string s;
    cin >> s;
    int cc = count(s.begin(), s.end(), 'o');
    cout<<700+100*cc<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    static int[]
        s1 = {1, 3, 5, 7, 8, 10, 12},
        s2 = {4, 6, 9, 11},
        s3 = {2};
    void solve() {
        Set<Integer> set1, set2, set3;
        set1 = new HashSet<>(); set2 = new HashSet<>(); set3 = new HashSet<>();
        for (int a : s1) set1.add(a); for (int a : s2) set2.add(a); for (int a : s3) set3.add(a);

        int x = sc.nextInt();
        int y = sc.nextInt();
        if (set1.contains(x) && set1.contains(y)) System.out.println("Yes");
        else if (set2.contains(x) && set2.contains(y)) System.out.println("Yes");
        else if (set3.contains(x) && set3.contains(y)) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

typedef pair<int,int> P;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll hoge = n/(a+b);
    ll ans = hoge*a;
    if (n%(a+b) != 0){
        ans += min(n%(a+b),a);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string a, b;
    cin >> a >> b;

    if(a.size()>b.size()){
        cout << "GREATER" << endl;
    }
    else if(b.size()>a.size()){
        cout << "LESS" << endl;
    } 
    else{
        rep(i, a.size()){
            int tmpa = a.at(i) - '0';
            int tmpb = b.at(i) - '0';
            if(tmpa<tmpb){
                cout << "LESS" << endl;
                return 0;
            }
            else if(tmpa > tmpb){
                cout << "GREATER" << endl;
                return 0;
            }
            else continue;
        }

        cout << "EQUAL" << endl;
    }
    return 0;
}


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

typedef pair < int , int > pii ;
typedef long long LL ;

#define clr( a , x ) memset ( a , x , sizeof a )

const int MAXN = 305 ;

char s[MAXN][MAXN] ;
int dp[MAXN][MAXN] ;
int val[MAXN][MAXN] ;
int n , m ;

void solve () {
	for ( int i = 1 ; i <= n ; ++ i ) {
		scanf ( "%s" , s[i] + 1 ) ;
	}
	int ans = 0 ;
	for ( int i = 1 ; i < m ; ++ i ) {
		for ( int j = 1 ; j <= n ; ++ j ) {
			for ( int k = 1 ; k <= n ; ++ k ) {
				val[j][k] = val[j - 1][k - 1] + ( s[j][i] == s[k][i + 1] ) ;
				dp[j][k] = min ( dp[j - 1][k] , dp[j][k - 1] ) + val[j][k] ;
			}
		}
		ans += dp[n][n] ;
	}
	printf ( "%d\n" , ans ) ;
}

int main () {
	while ( ~scanf ( "%d%d" , &n , &m ) ) solve () ;
	return 0 ;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int n[1000000];
int main(){
int a,b;
cin>>a;
for(int i=0;i<a-1;i++){
    cin>>b;
    n[b]+=1;
}
for(int i=1;i<=a;i++)
{
    cout<<n[i]<<endl;

}

return 0;
}


Measured memory_bytes: 4348
def main():
    N = int(input())
    a = [0] + list(map(int, input().split())) + [0]
    max_ = 0
    for i in range(1, N+2):
        max_ += abs(a[i] - a[i-1])
    
    for i in range(1, N+1):
        pre = a[i] - a[i-1]
        nex = a[i+1] - a[i]
        if (pre > 0 and nex < 0) or (pre < 0 and nex > 0):
            abs_pre = abs(pre)
            abs_nex = abs(nex)
            print(max_ - min(abs_nex, abs_pre) * 2)
        else:
            print(max_)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14172
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if(n == 1){
                Console.WriteLine("Hello World");
            }else{
                var a = int.Parse(Console.ReadLine());
                var b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD =  1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define lb(v, c) lower_bound((v).begin(), (v).end(), c) - (v).begin()
#define ub(v, c) upper_bound((v).begin(), (v).end(), c) - (v).begin()

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin>>s>>t;
    ll tlength=t.size();
    ll slength=s.size();
    vector<vector<ll>> smp(30);
    rep(i, slength) {
        smp[s[i]-'a'].pb(i+1);
    }

    ll ans=0;
    ll now=0;
    ll loc=0;
    rep(i, tlength) {
        if((ll)smp[t[i]-'a'].size()<=0){
            cout << -1 << endl;
            return 0;
        }else{
            auto itr = upper_bound(ALL(smp[t[i]-'a']), now);
            if(itr==smp[t[i]-'a'].end()){
                loc = *smp[t[i]-'a'].begin();
                ans += slength;
            }else{
                loc = *itr;
            }
            //dbg(loc);
            now=loc;
        }
    }
    ans += loc;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1736
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        int x = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        if(x == 0){
            System.out.println(0);
            return;
        }
        if(n==1){
            System.out.println(x);
            return;
        }
        
        int[] ar = new int[m*3];
        ar[1] = x;
        
        //value, index
        HashMap<Integer, Integer> h = new HashMap<>();
        int l = 0;
        int r = 0;
        
        long[] ru = new long[m*3];
        ru[1] = x;
        
        for(int i=1; i<ar.length-1; i++){
            ar[i+1] = f(ar[i], m);
            ru[i+1] = ru[i]+ar[i+1];
            if(h.containsKey(ar[i+1])){
                l = h.get(ar[i+1]);
                r = i+1;
                break;
            }else{
                h.put(ar[i+1], i+1);
            }
        }
        
        long ans = ru[l-1];
        long loopSum = ru[r] - ru[l];
        long loopLength = r-l;
        long loopTime = (n-l+1)/loopLength;
        long loopEnd = l-1+loopLength*loopTime;
        
        /*
        System.out.println("L " + l);
        System.out.println("R " + r);
        System.out.println("loopSum " + loopSum);
        System.out.println("loopLength " + loopLength);
        System.out.println("loopTime " + loopTime);
        System.out.println("loopEnd " + loopEnd);
        */
        
        ans += loopSum*loopTime;
        
        //残りは愚直
        for(int i=0; i<(int)(n-loopEnd); i++){
            ans += ar[l+i];
        }
        
        System.out.println(ans);
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    public static int f(int a, int m){
        long res = mod_pow(a, 2, m);
        return (int)res;
    }
}

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

int main(){
  int N,M;
  cin >>N>>M;
  vector<pair<int,int>> P(N);
  
  for(int i=0;i<N;i++){
    int a,b;
    cin >>a>>b;
    P[i] = make_pair(a,b);
  }
  
  sort(P.begin(),P.end());
  
  //ペアが整列されてるかの確認
  //for(int i=0;i<N;i++){
  //  cout << P[i].first << " " << P[i].second << endl;
  //}
  
  int target = 0; //エナジードリンクの個数
  long long ans = 0; //現在払った金額
  
  for(int i=0;i<N;i++){
    for(int j=0;j<P[i].second;j++){
      if(target == M) break;
      target ++;
      ans += P[i].first;
      //cout << target << "," <<  ans << endl; 途中経過
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
n = gets.to_i
a = gets.split.map &:to_i
 
if a.index(1) == nil
    p -1
else
    c = i = 0
    1.upto n do |n|
        break if (t=a[i..-1].index(n)) == nil
        i += t
        c += 1
    end
    p a.size - c
end

Measured memory_bytes: 19204
// ?§???????????????? S ???????????????????????§???h:m:s ?????¢?????????????????????????????????????????????????????§???h ????????????m ??? 60 ???????????????s ??? 60 ??????????§???¨????????????

#include <stdio.h>
int main(){
	int S, h, m, s;
	
	scanf("%d", &S);
	
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String s[][] = new String[h + 2][w + 2];
		Arrays.fill(s[0], ".");
		Arrays.fill(s[h + 1], ".");
		for(int i = 1; i <= h; i++) {
			s[i] = ("." + sc.next() + ".").split("");
		}
		for(int i = 1; i <= h; i++) {
			for(int j = 1; j <= w; j++) {
				if(s[i][j].equals("#")) {
					if(s[i - 1][j].equals(".")
							&& s[i + 1][j].equals(".")
							&& s[i][j - 1].equals(".")
							&& s[i][j + 1].equals(".")) {
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  vector<string> vec(h);
  
  for (int i = 0; i < h; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      if (i == 0 || i == h + 1) {
        cout << "#";
        if (j == w + 1) {
          cout << endl;
        }
      }
    }
    if (i < h) {
      cout << "#" << vec.at(i) << "#" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 1000000009

using namespace std;
typedef long long int ll;

int main(void)
{
	// #ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// #endif
	fast;
	map<int, int> odd, even;
	int n; cin >> n;
	int a[n];
	int a1 = 0, a2 = 0;
	vector<pair<int, int>> v1, v2;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (i&1)
		{
			++odd[a[i]];
			a1 = max(a1, odd[a[i]]);
		}
		else
		{
			++even[a[i]];
			a2 = max(a2, even[a[i]]);
		}
	}
	for (auto it : odd) v1.pb({it.second, it.first});
	for (auto it : even) v2.pb({it.second, it.first});
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	int n1 = v1.size(), n2 = v2.size();
	if (v1[n1-1].first == n/2 and v2[n2-1].first == n/2)
	{
		if (a[0] == a[1]) cout << n/2;
		else cout << 0 << '\n';
		return 0;
	}
	if (v1[n1-1].first == n/2)
	{
		for (int i = n2-1; i >= 0; --i)
		{
			if (v2[i].second != a[1])
			{
				cout << n/2 - v2[i].first;
				break;
			}
		}
		return 0;
	}
	if (v2[n2-1].first == n/2)
	{
		for (int i = n1-1; i >= 0; --i)
		{
			if (v1[i].second != a[0])
			{
				cout << n/2 - v1[i].first;
				break;
			}
		}
		return 0;
	}
	if (v1[n1-1].second == v2[n2-1].second)
	{
		if (v1[n1-2].first < v2[n2-2].first)
			cout << n - v1[n1-1].first - v2[n2-2].first;
		else
			cout << n - v2[n2-1].first - v1[n1-2].first;
		return 0;
	}
	cout << n - v2[n2-1].first - v1[n1-1].first;
}

Measured memory_bytes: 6524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
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; }
typedef long long ll;
using namespace std;
#define sp(n) cout << fixed << setprecision(n)
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<int>> t(n);
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    vector<bool> used(n);
    queue<int> que;
    vector<int> r(n,-1);
    r[0]=0;
    que.push(0);
    used[0]=true;
    while(que.size()){
        int x=que.front();que.pop();
        rep(i,t[x].size()){
            int y=t[x][i];
            if(used[y])continue;
            used[y]=true;
            r[y]=x+1;
            que.push(y);
        }
    }
    rep(i,n){
        if(r[i]==-1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0)continue;
        cout<<r[i]<<endl;
    }
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long l,r;
	cin>>l>>r;
	if (r-l>=2018)
	{
		cout<<0;
		return 0;
	}
	int minv=2019;
	for (long long i=l; i<=r; i++)
	{
		for (long long j=i+1; j<=r; j++)
		{
			if ((i*j)%2019<minv)
			{
				minv=(i*j)%2019;
			}
		}
	}
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
def yakusu(n):
    results = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            results.append(i)
            results.append(n // i)
    return results

N = int(input())
A = list(map(int, input().split()))
is_odd = [False for i in range(N+1)]
A.insert(0, 0)
ans = []
for i in range(N, 0, -1):
    if A[i] == 1:
        if not is_odd[i]:
            ans.append(i)
            for y in set(yakusu(i)):
                is_odd[y] = not is_odd[y]
    elif A[i] == 0:
        if is_odd[i]:
            ans.append(i)
            for y in set(yakusu(i)):
                is_odd[y] = not is_odd[y]
print(len(ans))
if len(ans) != 0:
    print(' '.join(map(str, ans)))


Measured memory_bytes: 88568
package main

import (
        "bufio"
        "fmt"
        "os"
        "strings"
        "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    in := scanner.Text()
    data := strings.Fields(in)

    a, _ := strconv.Atoi(data[0])
    b, _ := strconv.Atoi(data[1])

    result := 0
    for i := 0; i < 2; i++ {
        if b > a {
            result += b
            b--
        } else {
            result += a
            a--
        }
    }

    fmt.Println(result)
}

Measured memory_bytes: 640
n,m,q=map(int,input().split())
data=[[0 for i in range(n+1)] for j in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    data[l][r]+=1

for i in range(n+1):
    for j in range(1,n+1):
        data[i][j]+=data[i][j-1]
for i in range(n+1):
    for j in range(1,n+1):
        data[j][i]+=data[j-1][i]

for _ in range(q):
    x,y=map(int,input().split())
    print(data[y][y]-data[x-1][y]-data[y][x-1]+data[x-1][x-1])


Measured memory_bytes: 13428
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    let mut worst= (0, 0);
    for _ in 0..n{
        let line = read_as_vec::<u64>();
        let (a, b) = (line[0], line[1]);
        if worst.0 < a{
            worst = (a, b);
        }
    }
    println!("{}", worst.0+worst.1);
}


Measured memory_bytes: 4352
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,lg2[100111];
vector<int>con[100111];
int dfs(int x,int pre=-1)
{
	int tmp=0,ret=0;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		if(u==pre)continue;
		int nxt=dfs(u,x);
		tmp|=nxt&ret;
		ret|=nxt;
	}
	if(tmp==0)return ret+1;
	int cur=lg2[tmp]+1;
	return (ret&(~((1<<cur)-1)))+(1<<cur);
}
int main()
{
	for(int i=2;i<=100005;i++)lg2[i]=lg2[i>>1]+1;
	geti(n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		getii(x,y);
		con[x].PB(y);
		con[y].PB(x);
	}
	cout<<lg2[dfs(1)]<<endl;
	return 0;
}

Measured memory_bytes: 11904