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

const int N = 1e5 + 100, M = 3, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if (a < 0)
		a += MOD;
	else if (a >= MOD)
		a -= MOD;
	return a;
}
void _sum(int &a, int b) {
	a = sum(a, b);
}
int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
void _mul(int &a, int b) {
	a = mul(a, b);
}

struct mat {
	int a[M][M];
	mat(int b = 0) {
		memset(a, 0, sizeof a);
		for (int i = 0; i < M; i++)
			a[i][i] = b;
	}
	int* operator[](int x) {
		return a[x];
	}
	mat operator*(mat b) {
		mat c(0);
		for (int i = 0; i < M; i++)
			for (int k = 0; k < M; k++)
				for (int j = 0; j < M; j++)
					_sum(c[i][j], mul(a[i][k], b[k][j]));
		return c;
	}
} dp, updater_1, updater_2;

mat power(mat a, int b) {
	mat res(1);
	while (b) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int n, m, x[N];

void input() {
	cin >> n >> m;
	x[0] = 0;
	for (int i = 1; i <= m; i++)
		cin >> x[i];
	x[m + 1] = n;
}

void ready() {
	dp[0][0] = 1;

	for (int i = 0; i < M; i++) {
		updater_2[i][i]++;
		if (i >= 1)
			updater_2[i - 1][i] += (i == 2? 1: 2);
		if (i >= 2)
			updater_2[i - 2][i]++;
	}
	updater_1 = updater_2;
	for (int i = 0; i < M; i++)
		updater_1[2][i] += (i == 1? 2: 1);
}

void calc() {
	int me = 0;
	for (int i = 1; i <= m + 1; i++) {
		dp = dp * power(updater_1, x[i] - me);
		if (i <= m) {
			dp = dp * updater_2;
			me = x[i] + 1;
		}
	}
}

void solve() {
	ready();
	calc();
	cout << dp[0][2];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	solve();
}


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

struct tree{
	int* children;
	int degree;
	int parent;
};

int main(){

	int num;
	cin >> num;
	
	tree* array = new tree[num];
	
	for(int i = 0; i < num; i++){
		int index;
		int degree;
		int childID;
		
		cin >> index;
		cin >> degree;
		array[index].children = new int[degree];
		array[index].degree = degree;
		array[index].parent = -1;
		for(int j = 0; j < degree; j ++){
			cin >> childID;
			array[index].children[j] = childID; 	
		}

	}
	for(int i = 0; i < num; i++){
		for(int j = 0; j < array[i].degree; j++){
			array[array[i].children[j]].parent = i;
		}
	}
	for(int i = 0; i < num; i++){
		//parent
		cout << "node " << i << ": parent = " << array[i].parent << ", ";
		//depth
		int counter = 0;
		int index = i;
		while(array[index].parent != -1){
			counter ++;
			index = array[index].parent;
		}
		cout << "depth = " << counter << ", ";

		//type
		if(array[i].parent == -1)cout << "root";
		else if(array[i].degree == 0)cout << "leaf";
		else cout << "internal node";
		cout << ", ";

		//children
		cout << "[";
		for(int j = 0; j < array[i].degree; j++){
			cout << array[i].children[j]; 
			if(j + 1 != array[i].degree){
				cout << ", ";
			}
		}
		cout << "]";
		cout << endl;
		delete [] array[i].children;
	}
	delete [] array;

	return 0;
}

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

int		main(void)
{
	int		a, b, c;
	char	tmp;
	cin >> a >> tmp >> b >> tmp >> c;
	if (b == 4)
		cout << (c <= 30 ? "Heisei" : "TBD") << endl;
	else
		cout << (b < 4 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */


void solve()
{
    ll i, j, n, m;

    std::vector<ll> v(5);


    loop(i, 0, 5) cin >> v[i];


    loop(i, 0, 5) {

        if (v[i] == 0)
        {

            cout << i + 1 << endl;
            break;

        }


    }


}


int32_t main()
{

    IOS;
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T = 1;


    wh(T)
    {

        solve();

    }
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  int N,M;
  cin>>N>>M;
  map<int,int>food;
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int a;
      cin>>a;
      food[a]++;
    }
  }
  ll ans = 0;
  for(auto it:food){
    if(it.second==N)ans++;
  }
  cout<<ans<<endl;
  return 0;
}



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

int main(){
    long int N,C,me;
    cin >> N >>C;
    long int x[C];
    int sum=0;

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

    for(int i=0;i<C;i++){
        sum =sum+x[i];
    }

    if(sum%(N+1)==0){
        me=sum/(N+1);
        cout<<me<<endl;
    }
    else{
        me=sum/(N+1)+1;
        cout<<me<<endl;
    }
    
    return 0;

}


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

const int N=1e6+20;
typedef long long ll;
int n;
int h[N];
int dp[N];
int solve(int i){
    if(i==n-1){
        return 0;
    }
    if(i>=n)return 1e9;
    if(dp[i]!=-1)return dp[i];
    int ch1=abs(h[i+1]-h[i])+solve(i+1);
    int ch2=abs(h[i+2]-h[i])+solve(i+2);
    return dp[i]=min(ch1,ch2);
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>h[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0);

}


Measured memory_bytes: 9472
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int T, A;
int H[10001];

signed main()
{
	cin >> N;
	cin >> T >> A;
	REP(i, N) cin >> H[i];

	int min_i = 0;
	double min = DBL_MAX;
	REP(i, N)
	{
		double a = T - H[i] * 0.006;
		double sub = abs(A - a);
		if (min > sub)
		{
			min = sub;
			min_i = i;
		}
	}
	
	cout << (min_i + 1) << endl;
}








Measured memory_bytes: 256
N = int(input())
a = [int(_) for _ in input().split()]
Res = 0

for i in a:
    cnt = 0
    for j in range(1, 31):
        if i % 2**j == 0 and i // 2**j != 0:
            cnt += 1
        else:
            Res += cnt
            break

print(Res)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> ab(n, 0);
    bool ans = true;
    
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        ab[a]++;
        ab[b]++;
    }
    
    rep(i, n) {
        if (ab[i] % 2 != 0) {
            ans = false;
            break;
        }
    }
    
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 640
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {
map<int,int> map;
int N;
cin>>N;
rep(i,N){
  int P;
  cin>>P;
  map[P]=map[P-1]+1;
}
int max_=0;
rep3(i,N){
  max_=max(max_,map[i]);
}
cout<<N-max_<<endl;

return 0;
}

Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4) {
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const long long MOD = 1000000007;


void solve(int N, std::vector<int> A){
    
    return;
}

int main(){
    int N;
    cin>>N;
    std::vector<int> A(N);
    map<int,int> list;
    for(int i = 0 ; i < N ; i++){
        int a;
        cin>> a;
        list[a]++;
    }
    bool error = false;
    if(N%2==0){ //even
        for(int i=1; i<N; i+=2) if(list[i]!=2){error=true;break;}
    }
    else{ //odd
        for(int i=2; i<N; i+=2)if(list[i]!=2){error=true;break;}
        if(list[0]!=1)error=true;
        
    }    
    if(error){
        cout<<0<<endl;
        return 0;
    }
    LL ans=1;
    REP(i,N/2){
      ans*=2;
      ans%=MOD;
    }
    cout<<ans<<endl;


    return 0;
}


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

int main(void){
    int n, m;
    cin >> n >> m;
    int max = m/n;
    for(int i=max;i>=1;--i){
        if(m%i==0){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import math


mod=10**9+7

k,q=map(int,raw_input().split())
d=map(int,raw_input().split())
while q:
	q-=1
	n,x,m=map(int,raw_input().split())
	ans=0
	di=(n-1)/k
	cnt=x%m
	left=n-(di*k +1)
	xd=[]
	for i in range(k):
		xd.append(d[i]%m)
	#print xd,ans,left
	for i in range(k):
		lol=0
		if i<left:
			lol=1
		if(xd[i]==0):
			ans+=(lol+di)
		else:
			cnt+=(xd[i]*(lol+di))
	ans+=(cnt/m)
	print n-1-ans




Measured memory_bytes: 42396
N = int(input())
Hs = [int(i) for i in input().split(" ")]
for i in range(0, N - 1):
  h1 = Hs[i]
  h2 = Hs[i+1]
  if h1 < h2:
     Hs[i+1] -= 1
  elif h1 == h2:
     pass
  else:
     print("No")
     break
else:
  print("Yes")


Measured memory_bytes: 14396
#include <iostream>
using namespace std;
int par[100001];
int dis[100001];

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

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

int main(){
    //pair<int, float>[100000] p;
    int L, R, D, M, N;
    cin >> N >> M;
    init(N);
    string ans = "Yes";

    for(int i =0 ; i < M; i++){
        cin >> L >> R >> D;
        int fl = find(L-1);
        int fr = find(R-1);
        if(fl == fr){
            if( abs(dis[R-1] - dis[L-1]) != D){
                ans = "No";
                break;
            }
        }
        else{
            par[fl] = fr;
            dis[fl]= D + dis[R-1] - dis[L-1];
        }
    }

    
    cout << ans << endl;
    return 0;
}
    

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

#define pb push_back

using namespace std;

typedef long long LL;

const LL N = 1234567;

inline LL read()
{
  LL p=0; LL f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

vector<LL> v;

int main()
{

  LL n = read(); LL a=read(); LL b=read();
  
  if(!a || !b){printf("-1\n"); return 0;}

  LL now = 1; bool fir = 0;
  for(LL i = n-a + 1; i<=n ;i++)
  {
    v.pb(i);
    LL nx = now + b-2;
    if(!fir && nx >= n-a + 1){printf("-1\n"); return 0;}
    else fir = 1;

    for(LL j=min(nx,n-a);j>=now;j--) v.pb(j);
    now = nx + 1;
  }

  if(now <= n-a){printf("-1\n"); return 0;}

  for(LL i=0;i<v.size();i++) printf("%lld%c",v[i]," \n"[i==v.size()-1]);

  return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    int ln=0,rn=1e9;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        ln=max(l,ln);
        rn=min(r,rn);
    }
    if(ln<=rn)cout<<rn-ln+1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

static const int MAX = 200000;

int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  ll ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += h[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
<?php
// $input_line = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $s = str_replace(array("\r\n","\r","\n"), '', $s);
  $s = explode(" ", $s);
  
  $HPa = (int)$s[0];
  $ATa = (int)$s[1];
  $HPb = (int)$s[2];
  $ATb = (int)$s[3];
  
//   $disZero = false;
  
    while (true) {
        // var_dump($HPa);
        
        $HPb -= $ATa;
        
        
        if ((int)$HPb <= 0) {
            // $disZero = true;
            echo 'Yes';
            break;
        }
        
        $HPa -= $ATb;
        // var_dump($HPa);
        // var_dump($HPb);
        
        if ((int)$HPa <= 0) {
            // $disZero = true;
            echo 'No';
            break;
        }
        
        
    }
  

?>

Measured memory_bytes: 16108
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define HIGHESTSETBIT(mask) ( sizeof(int)*8-1-__builtin_clz((mask)) )

class RMQ_SegmentTree {
   VI M;

   void _preprocess(int node, int L, int R) {
      if (L == R) {
         M[node] = L;
         return;
      }

      const int mid = (L+R)/2;
      _preprocess(2 * node, L, mid);
      _preprocess(2 * node + 1, mid+1, R);

      const int pL = M[2 * node];
      const int pR = M[2 * node + 1];

      M[node] = A[pL] <= A[pR] ? pL : pR;
   } 

   int _query(int i, int j, int node, int L, int R) {
      if (i > R || j < L)
         return -1;
      
      if (i <= L && R <= j)
         return M[node];
      
      int pL = _query(i, j, 2 * node, L, (L + R) / 2);
      int pR = _query(i, j, 2 * node + 1, (L + R) / 2 + 1, R);
      
      if (pL < 0) return pR;
      if (pR < 0) return pL;
      return A[pL] <= A[pR] ? pL : pR;
   }

   void _update(int i, int val, int node, int L, int R) {
      if (L == R) {
         M[node] = L;
         A[i] = val;
         return;
      }
      int mid = (L + R)/2 + 1;
      if (i < mid)
         _update(i, val, 2*node, L, mid-1);
      else
         _update(i, val, 2*node+1, mid, R);

      int pL = M[2 * node];
      int pR = M[2 * node + 1];
      M[node] = A[pL] <= A[pR] ? pL : pR;
   }
   VI A;

public:
   RMQ_SegmentTree(const VI& _A) : A(_A) {
      const int N = A.size();
      const int MAXIND = N > 1 ? 2 * ( 1 << (HIGHESTSETBIT(N-1)+1) ) : 2;
      M = VI(MAXIND, -1);
      _preprocess(1, 0, N-1);
   }

   int query(int i, int j) {
      return _query(i, min(j, int(A.size())-1), 1, 0, int(A.size())-1);
   }

   void update(int i, int val) {
      _update(i, val, 1, 0, int(A.size())-1);
   }
};

const int INF = 1000000000;

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

   int N, M;
   cin >> N >> M;
   
   string S;
   cin >> S;

   VI DP(N+1, INF);
   DP[N] = 0;
   RMQ_SegmentTree rmq(DP);

   VI P(N+1, -1);
   for (int n = N-1; n >= 0; --n) {
      if (S[n] == '1') continue;

      int j = rmq.query(n+1, n+M);
   // cerr << "n: " << n << "  j: " << j << "  DP[j]: " << DP[j] << endl;
      P[n] = j;
      if (DP[j] < INF) {
         DP[n] = DP[j] + 1;
         rmq.update(n, DP[n]);
      }
   }
   //cerr << DP[0] << endl;

   if (DP[0] < INF) {
      for (int n = 0; n < N; ) {
         int j = P[n];
         cout << j - n << ' ';
         n = j;
      }
      cout << '\n';
   }
   else {
      cout << "-1\n";
   }

   return 0;
}


Measured memory_bytes: 2880
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
int ksm(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=mul(a,a))
        if(b&1)ans=mul(ans,a);
    return ans;
}
const int Q=404;
int fac[Q],ifac[Q];
void init(int n)
{
    fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=mul(fac[i-1],i);
    ifac[n]=ksm(fac[n],MOD-2);
    for(int i=n;i;--i)
        ifac[i-1]=mul(ifac[i],i);
}
int f[Q][Q];
int main()
{
    init(400);
    int n,maxn=0;
    scanf("%d",&n);
    f[0][0]=MOD-1;
    int sa=0;
    for(int i=1,a,b;i<=n;i++){
        scanf("%d%d",&a,&b);
        assert(a&&b);
        for(int j=sa;j>=0;--j)
            for(int k=maxn;k>=0;--k){
                int va=f[j][k];
                for(int l=0,pi=1;l<b;l++,pi=mul(pi,a))
                    f[j+a][k+l]=sub(f[j+a][k+l],mul(mul(va,ifac[l]),pi));
            }
        sa+=a;
        maxn+=b-1;
    }
    int als=0;
    for(int j=1;j<=sa;j++)
        for(int k=0,pi=1,ij=ksm(j,MOD-2),owo=mul(sa,ij);k<=maxn;k++,pi=mul(pi,ij))
            als=add(als,mul(mul(f[j][k],owo),mul(fac[k],pi)));
    printf("%d\n",als);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
  	int a,b;
	cin >> a>>b;
	int n;
	n = b-a-1;
	int K=0;//n番目の党の高さ
	rep(i,n){
		K=K+i+1;
	  }
	  cout<<K-a<<endl;
	}


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

int n,A[50];

int solve ( int i, int m ) {
    if ( m == 0 ) {
        return 1;
    }
    if ( i >= n ) {
        return 0;
    }
    int res = solve(i+1,m) || solve(i+1, m - A[i]);

    return res;
}

int main() {

    int q,M,i;

    cin >> n;
    for ( i = 0; i < n; ++i ) {
        cin >> A[i];
    }
    cin >> q;
    for ( i = 0; i < q; ++i ) {
        cin >> M;
        if ( solve(0,M) ) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 1;
const long long MOD = 1e9 + 7;
long long fact[N], rev[N], rfact[N];

long long add(long long a, long long b) {
    return ((a + b) % MOD + MOD) % MOD;
}

long long mul(long long a, long long b) {
    return ((a * b) % MOD + MOD) % MOD;
}

void calc() {
    rev[1] = 1;
    for (int i = 2; i < N; i++) {
        rev[i] = ((- MOD / i * rev[MOD % i]) % MOD + MOD) % MOD;
    }
    fact[0] = rfact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
        rfact[i] = (rfact[i - 1] * rev[i]) % MOD;
    }
}

long long c(int k, int n) {
    return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

void solve() {
    calc();

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

    multiset<long long> setmn;
    multiset<long long, greater<long long> > setmx;

    for (int i = 0; i < n; i++) {
        int v; cin >> v;
        setmn.insert(v); setmx.insert(v);
    }

    long long ans = 0;
    for (int iter = 0; iter < n - k + 1; iter++) {
        long long mn = *setmn.begin();
        long long mx = *setmx.begin();
        long long sz = setmn.size();
        setmn.erase(setmn.begin()); setmx.erase(setmx.begin());
        ans = add(ans, mul(mx, c(k - 1, sz - 1)));
        ans = add(ans, - mul(mn, c(k - 1, sz - 1)));
    }

    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

int main(){

  int N;
  long num[86];
  cin >> N;

  num[0]=2;
  num[1]=1;
  for(int i=2; i<87; i++){
    num[i] = num[i-1] + num[i-2];
  }

  cout << num[N] << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n, z, w, *a = map(int, sys.stdin.read().split())

def main():
    if n == 1:
        return abs(a[n-1] - w)
    return max(abs(a[n-1] - w), abs(a[n-1] - a[n-2]))
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
string S;
cin>>S;
int ans=0;
bool chain=true;
fx(S.size()){
	int m=0;
	if(S.at(x)=='A'
	  ||S.at(x)=='T'
	  ||S.at(x)=='C'
	  ||S.at(x)=='G'){
	  	while(x<S.size()&&(S.at(x)=='A'
	  ||S.at(x)=='T'
	  ||S.at(x)=='C'
	  ||S.at(x)=='G')){
	  	x++;
	  	m++;
	  }
	  }
	  ans=max(ans,m);
}
ce(ans)
	

}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n,k;
bool tf[10];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		int t;
		scanf("%d",&t);
		tf[t]=true;
	}
	for(int i=n;;i++)
	{
		bool is=true;
		for(int j=1;i/j;j*=10)
			if(tf[i/j%10])
			{
				is=false;
				break;
			}
		if(is)
		{
			printf("%d",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
import heapq

n,m = map(int, raw_input().split())
a = map(lambda x: int(x)*(-1), raw_input().split())
heapq.heapify(a)

for _ in range(m):
  v = heapq.heappop(a)
  o = v % 2
  v /= 2
  heapq.heappush(a, v + o)

print(-1*sum(a))

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

int main(void) {

  int a,b  ;
  cin >> a>> b ;
  int sum = a +b ;
  int c = sum / 2;
  int d = sum % 2 ;
  if (d == 1){cout << "IMPOSSIBLE";}
  else cout << c ;
  
  return 0;
 
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a,b,c,d,e=0;
    cin>>a>>b>>c;
    d=a;
    a=max(e,a-c);
    c=max(e,c-d);
    b=max(e,b-c);
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    string s; cin >> s;
    if (s[0] == 'S') cout << "Cloudy";
    else if (s[0] == 'C') cout << "Rainy";
    else cout << "Sunny";
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

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

int n,g,bit,res;
int dis[1<<20];
vector<int> mask[5][5];

int rec(int g, int t){
  if(t == 5){
    if( (g & 31) )return 1000000;
    return dis[g>>5];
  }
  int res = rec(g,t+1);
  for(int i=0;i<mask[0][t].size();i++)res = min(res,rec(g^mask[0][t][i],t+1)+1);
  return res;
}
    
int main(){
  REP(i,0,5)REP(j,0,5)REP(k,i,5)REP(l,j,5){
    int tmp = 0;
    REP(y,i,k+1)REP(x,j,l+1)tmp |= 1<<(y*5+x);
    mask[i][j].push_back(tmp);
  }

  for(int i=0;i<(1<<20);i++)dis[i] = -1;
  dis[0] = 0;
  queue<int> q; q.push(0);
  while(q.size()){
    int p = q.front(); q.pop();
    REP(i,0,4)REP(j,0,5)REP(k,0,mask[i][j].size()){
      if(mask[i][j][k]>=1<<20)continue;
      int nxt = p^mask[i][j][k];
      if(dis[nxt]<0){
	dis[nxt] = dis[p] + 1;
	q.push(nxt);
      }
    }
  }

  while(cin >> n,n){
    g = 0;
    REP(i,0,5)REP(j,0,5)
      if(i<n && j<n){
	cin >> bit;
	g |= bit<<(i*5+j);
      }
    
    if(n<5)res = dis[g];
    else res = rec(g,0);
    
    for(int i=0;i<res;i++)cout << "myon";
    cout << endl;
  }
}

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

int main() {
 char a;
  cin>>a;
  if(a=='A') cout<<'T'<<endl;
  if(a=='T') cout<<'A'<<endl;
  if(a=='C') cout<<'G'<<endl;
  if(a=='G') cout<<'C'<<endl;    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,five=0,seven=0;
  for(int i = 0;i < 3;i++)
  {
    scanf("%d",&n);
    switch(n)
    {
      case 5:
        five += 1;
        break;
      case 7:
        seven += 1;
        break;
      default:
        continue;
    }
  }
  if(five == 2 && seven == 1){printf("YES");}
  else{printf("NO");}
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

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

int main(){
  string in;
  int n;
  while(~scanf("%d",&n)){
    rep(i,n){
      cin>>in;
      sort(in.begin(), in.end());
      string rin = string(in.rbegin(), in.rend());
      printf("%d\n",atoi(rin.c_str()) - atoi(in.c_str()));
    }
  }
  return 0;
}

Measured memory_bytes: 0
//
// Created by kutimoti on 4/18/18.
//

#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N,M,X;
    cin >> N >> M >> X;

    int left = 0;
    int right = 0;

    for(int i = 0;i < M;i++){
        int a;
        cin >> a;

        if(a < X){
            left++;
        }
        else{
            right++;
        }
    }

    cout << min(left,right) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int s = a * b;
        int l = 2 * a + 2 * b;
        System.out.println(s+" "+l);

    }
}


Measured memory_bytes: 26100
#include<bits/stdc++.h>
#define maxn 10050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const double eps = 1e-6;
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL qpow(LL x,LL y){LL re=1,base=x%mod;while(y){if(y&1)re=(re*base)%mod;base=(base*base)%mod;y>>=1;}return re;}
int a[maxn];
int g[105][105];
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int h,w;
	cin>>h>>w;
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int pos=1;
	mm(g,0);
	for(int i=1;i<=h;i++){
		if(i&1){
			for(int j=1;j<=w;j++){
				if(a[pos]>0) g[i][j]=pos,a[pos]--;
				else pos++,g[i][j]=pos,a[pos]--;
			}
		}
		else{
			for(int j=w;j>=1;j--){
				if(a[pos]>0) g[i][j]=pos,a[pos]--;
				else pos++,g[i][j]=pos,a[pos]--;
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(j==1) cout<<g[i][j];
			else cout<<" "<<g[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n+1);
  for(int i=1; i<=n; i++) cin >> a[i];

  long long int dp[n+2][300][101];
  for(int i=0; i<n+1; i++) for(int j=0; j<300; j++) for(int k=0; k<101; k++) dp[i][j][k] = 0;

  dp[0][0][0] = 1;
  for(int i=1; i<=n; i++) {
    for(int j=0; j<260; j++) {
      for(int k=0; k<=n; k++) {
        dp[i][j^a[i]][k+1] += dp[i-1][j][k];
        dp[i][j^a[i]][k+1] %= mod;
        dp[i][j][k] += dp[i-1][j][k];
        dp[i][j][k] %= mod;
      }
    }
  }

  long long int ans = 0;

  for(int i=0; i<101; i++) {
    long long int tmp = dp[n][k][i];
    for(int j=1; j<=i; j++) {
      tmp *= j;
      tmp %= mod;
    }
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


//EOF


Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
using Point = complex<double>;

#define X real()
#define Y imag()
double dot(Point a, Point b) {
    return (a.X*b.X + a.Y*b.Y);
}
using Line = pair<Point, Point>;
Point Projection(Line s, Point p) {
    Point vase = s.second - s.first;
    p -= s.first;
    return s.first + dot(p, vase) / norm(vase)*vase;
}
Point Reflection(Line s, Point p) {
    return p + (Projection(s, p) - p) * 2.0;
}
double cross(Point a, Point b) {
    return a.X*b.Y - a.Y*b.X;
}
int ccw(Point a, Point b, Point c) {
    if (cross(b - a, c - a) > EPS)return 1;
    if (cross(b - a, c - a) < -EPS)return -1;
    if (dot(b - a, c - a) < -EPS)return 2;
    if (abs(b-a)+EPS <abs(c-a))return -2;
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Point p1, p2;
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    p1 = Point(x1, y1);
    p2 = Point(x2, y2);
    Line l = Line(p1, p2);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double xi, yi;
        cin >> xi >> yi;
        Point p = Point(xi, yi);
        if (ccw(p1, p2, p) == 1)cout << "COUNTER_CLOCKWISE" << endl;
        if (ccw(p1, p2, p) == -1)cout << "CLOCKWISE" << endl;
        if (ccw(p1, p2, p) == 2)cout << "ONLINE_BACK" << endl;
        if (ccw(p1, p2, p) == -2)cout << "ONLINE_FRONT" << endl;
        if (ccw(p1, p2, p) == 0)cout << "ON_SEGMENT" << endl;
    }
    return 0;

}



Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define N 207

 vector<int> vx,vy;
 map<int,int> hx,hy;
 int dx[4]={0,0,1,-1};
 int dy[4]={1,-1,0,0};
 int vis[N][N];
 int l[55],r[55],t[55],b[55];
 
bool OK(int nx,int ny)
{
  if(nx >= 0 && nx <= 201 && ny >= 0 && ny <= 201 && !vis[nx][ny])
    return 1;
  return 0;
}

void dfs(int x,int y)
{
  vis[x][y] = 1;
  for(int k=0;k<4;k++)
  {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if(OK(nx,ny))
      dfs(nx,ny);
  }
}
 int main(){
 	int n,i,j;
 	while(scanf("%d",&n)!=EOF&&n){
 		vx.clear();
 		vy.clear();
 		hx.clear();
 		hy.clear();
 		for(int i=0;i<n;i++){
 			scanf("%d%d%d%d",&l[i],&t[i],&r[i],&b[i]);
 			vx.push_back(l[i]);
 			vx.push_back(r[i]);
 			vy.push_back(t[i]);
 			vy.push_back(b[i]);
 		}
 		sort(vx.begin(),vx.end());
 		vx.erase(unique(vx.begin(),vx.end()),vx.end());
 		sort(vy.begin(),vy.end());
 		vy.erase(unique(vy.begin(),vy.end()),vy.end());
 		for(int i=0;i<vx.size();i++)
 		   hx[vx[i]]=2*i+1;
 		for(int i=0;i<vy.size();i++)
 		   hy[vy[i]]=2*i+1;
 		for(int i=0;i<n;i++){
 			l[i]=hx[l[i]];
 			t[i]=hy[t[i]];
 			r[i]=hx[r[i]];
 			b[i]=hy[b[i]];
 		}
 		memset(vis,0,sizeof(vis));
 		for(int i=0;i<n;i++){
 			for(int j=b[i];j<=t[i];j++){
 				vis[j][l[i]]=1;
 				vis[j][r[i]]=1;
 			}
 			for(int j=l[i];j<=r[i];j++){
 				vis[t[i]][j]=1;
 				vis[b[i]][j]=1;
 			}
 		}
 		int cnt=0;
 		for(int i=0;i<=201;i++){
 			for(int j=0;j<=201;j++){
 				if(!vis[i][j]){
 					cnt++; dfs(i,j);
 					
 				}
 			}
 		}
 		printf("%d\n",cnt);
 	}
 	return 0;
 }

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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<vector<ar<ll,2>>> dp(n+1,vector<ar<ll,2>>(n+1,{0,0}));

    for(int i = n-1;i >=0;i--){
        for(int j = i;j < n;j++){
            if(i == j){
                dp[i][j] = {a[i],0};
            }else{
                ar<ll,2> op1 = {a[i]+dp[i+1][j][1], dp[i+1][j][0]};
                ar<ll,2> op2 = {a[j]+dp[i][j-1][1], dp[i][j-1][0]};
                dp[i][j] = max(op1,op2);
            }
        }
    }

    cout << dp[0][n-1][0] - dp[0][n-1][1] << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 144052
n = int(input())

n_break = 0
target = 1
nums = map(int, input().split(" "))

for num in nums:
    if num == target: 
        target += 1
    else:
        n_break += 1

if n_break == n:
    out = -1
else:
    out = n_break
print(out)

Measured memory_bytes: 18204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String r = "No";
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if(N == i * j) r = "Yes";
            }
        }
        System.out.println(r);
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;

// 約数を列挙
vector<ll> enumerateDivisors(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      // 対応する約数も追加(自分自身でなければ)
      if (n / i != i) {
        res.push_back(n / i);
      }
    }
  }
  // 昇順にソート
  sort(res.begin(), res.end());
  return res;
}

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

  vector<ll> divisors = enumerateDivisors(n);
  ll result = LONG_LONG_MAX;
  rep(i, divisors.size()) {
    ll a = divisors[i];
    ll b = n / a;
    ll digitsSize = max(to_string(a).size(), to_string(b).size());
    result = min(result, digitsSize);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main()
{
	std::string str;
	std::cin >> str;
	for (int i = 2 - str.length() % 2;; i += 2)
	{
		if (str.substr(0, (str.length() - i) / 2) == str.substr((str.length() - i) / 2, (str.length() - i) / 2))
		{
			std::cout << str.length() - i << std::endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,i,j,k,l,m,n,o,p,q,r,s,a[100002];
    cin>>n>>m;
    p=(n*(n-1))/2;
    p+=(m*(m-1))/2;
    cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

class PriorityQueue {
	vector<int> data;
	int size = 0;

public:
	PriorityQueue(int n) {
		data.resize(n);
	}

	void push(int value) {
		data[size++] = value;

		int suffix = size - 1;
		while (suffix > 0 && data[suffix / 2] < data[suffix]) {
			swap(data[suffix / 2], data[suffix]);
			suffix = suffix / 2;
		}
	}

	int top() {
		return data[0];
	}

	void maxHeap(int i) {
		int l, r, leargest;
		l = 2 * i;
		r = 2 * i + 1;
		if (l < size && data[l] > data[i])
			leargest = l;
		else
			leargest = i;
		if (r < size && data[r] > data[leargest])
			leargest = r;

		if (leargest != i) {
			swap(data[i], data[leargest]);
			maxHeap(leargest);
		}
	}

	void pop() {
		data[0] = data[size - 1];
		size--;
		maxHeap(0);
	}
};

int main() {
	PriorityQueue que(2000000);
	string s;
	int v;
	while (cin >> s && s != "end") {
		if (s == "insert") {
			cin >> v;
			que.push(v);
		}
		else {
			cout << que.top() << endl;
			que.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 10596
#include <climits>
#include <iostream>
#include <stack>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> G(N);
  rep(i, M) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    G[L].emplace_back(R, D);
    G[R].emplace_back(L, -D);
  }

  vector<int> value(N, INT_MAX);
  stack<int> dfs;
  rep(i, N) {
    if (value[i] != INT_MAX) continue;
    dfs.emplace(i);
    value[i] = 0;
    while (!dfs.empty()) {
      int v = dfs.top();
      dfs.pop();
      for (auto& nv : G[v]) {
        int nv_val = value[v] + nv.second;
        if (value[nv.first] != INT_MAX && value[nv.first] != nv_val) {
          cout << "No" << endl;
          return 0;
        }
        if (value[nv.first] == INT_MAX) {
          dfs.emplace(nv.first);
          value[nv.first] = nv_val;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 9344
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 1;
        while(true) {
            int n = sc.nextInt();
        	if(n == 0) {
        		break;
        	}
        	System.out.printf("Case %d: %d\n", i, n);
        	i ++;
        }
    }
}


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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a)
		cin >> i;
	int g = 1, s1 = 0, s2 = 0;
	for (int i = 0; i < n-1; ++i) {
		if (a[i] > a[i+1]) {
			if (s2 > 0) {
				s2 = 0;
				g++;
			} else {
				s1++;
			}
		} else if (a[i] < a[i+1]) {
			if (s1 > 0) {
				s1 = 0;
				g++;
			} else {
				s2++;
			}
		}
	}
	cout << g;
	cout << endl;


	return 0;
}


Measured memory_bytes: 640
def solve():
    mod = 10 ** 9 + 7
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = 0
    for i in range(N):
        inner_count = 0
        all_count = 0
        for j in range(N):
            if A[i] < A[j]:
                all_count += 1
            if i > j and A[i] < A[j]:
                inner_count += 1
        # print('i', i, 'all', all_count, 'inner', inner_count,
        #       'A[i]', A[i],
        #       all_count * ((K - 1) * K // 2) + inner_count * K)
        count += all_count * ((K - 1) * K // 2) + inner_count * K
        count %= mod
    print(count)


if __name__ == '__main__':
    solve()


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

int main(){
    int N;
    cin >> N;
    vector<long long > A(N);
    for(auto& a : A){
        cin >> a;
    }

    int num_zero = 0;
    int num_minus = 0;
    int min_abs = abs(A[0]);
    long long int sum = 0;
    for(int ii=0; ii<N; ii++){
        if(A[ii]<0) num_minus++;
        if(A[ii]==0) num_zero++;
        min_abs = min(min_abs, (int)abs(A[ii]));
        sum += abs(A[ii]);
    }

    if(num_zero>0 || num_minus % 2 == 0){
        cout << sum << endl;
    }else{
        cout << sum - min_abs * 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024