akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n),ind(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
    ind[a[i]]=i;
  }
  ll ans=0;
  set<int> cnt;
  rep(i,n){
    cnt.insert(ind[i]);
    auto itr=cnt.find(ind[i]),itr2=begin(cnt),itr3=end(cnt);
    int l,r;
    if(itr==begin(cnt)) l=*itr+1;
    else{
      itr--;
      l=ind[i]-*itr;
    }
    itr3--;
    itr=cnt.find(ind[i]);
    if(itr==itr3) r=n-*itr;
    else{
      itr++;
      r=*itr-ind[i];
    }
    ans+=(ll)(i+1)*l*r;
    //cout<<i+1<<' '<<l<<' '<<r<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

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

  unordered_map<string, int> msi;
  rep(i, n) {
    string cmd, opr;
    cin >> cmd >> opr;

    if (cmd == "insert") msi[opr] = 1;
    else {
      if (msi.count(opr)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 35716
s = int(input())

num_lists = [s]
cnt = 1
while True:
    if (num_lists[-1])%2 == 0:
        tmp = num_lists[-1]/2
    else:
        tmp =(num_lists[-1]*3)+1
    cnt += 1
    if tmp in num_lists:
        ans = cnt
        break
    else:
        num_lists.append(tmp)

print(ans)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int cumulative_sum_white[220000];
Int cumulative_sum_black[220000];

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

    rep(i,n) {
        if (s[i] == '.') {
            cumulative_sum_white[i+1] = cumulative_sum_white[i] + 1;
            cumulative_sum_black[i+1] = cumulative_sum_black[i]; 
        }
        else {
            cumulative_sum_black[i+1] = cumulative_sum_black[i] + 1;
            cumulative_sum_white[i+1] = cumulative_sum_white[i];
        }
    }
    Int ans = LINF;
    for (int i = 0; i < n+1; i++) {
        Int change = cumulative_sum_black[i] + cumulative_sum_white[n] - cumulative_sum_white[i];
        ans = min(ans, change);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
ll a,b,c,d,ans,N,M,K,q[2007],w[2007],dp[2007][2007],co=1000000007;
int main(){
	scanf("%lld%lld",&N,&M);
	rep(i,1,N) scanf("%lld",&q[i]);
	rep(i,1,M) scanf("%lld",&w[i]);
	dp[0][0]=1;
	rep(i,1,N) dp[i][0]=1;
	rep(j,1,M) dp[0][j]=1;
	rep(i,1,N) rep(j,1,M) {
		dp[i][j]=((dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%co+co)%co;
		if (q[i]==w[j]) dp[i][j]=(dp[i][j]+dp[i-1][j-1])%co;
	}
	printf("%lld\n",dp[N][M]);
	return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		System.out.println(s(new Scanner(System.in).nextInt(),0));
	}
	public static int s(int n,int c){
		if(n<6)return c+n;
		int a=1,b=1;
		while(a*6<=n)a*=6;
		while(b*9<=n)b*=9;
		return Math.min(s(n-a,c+1),s(n-b,c+1));
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n,a;
	cin >> n >> a;
	P(n*n-a);

	return  0;
}

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

const int N = 300005;
const int S = 5000;
const long long inf = 1e18;

int num(int v, int s) {
	return v * (S + 1) + s;
}

int n, m, s, x, y, z, w;
long long d[N];
set<pair<long long, int> > se;
vector<pair<int, int> > v[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> s;
	s = min(s, S);
	for(int i = 1; i <= m; ++i) {
		cin >> x >> y >> z >> w;
		for(int j = z; j <= S; ++j) {
			v[num(x, j)].push_back({num(y, j - z), w});
			v[num(y, j)].push_back({num(x, j - z), w});
		}
	}
	for(int i = 1; i <= n; ++i) {
		cin >> x >> y;
		for(int j = 0; j <= S - x; ++j) {
			v[num(i, j)].push_back({num(i, j + x), y});
		}
		for(int j = 1; j <= S; ++j) {
			v[num(i, j)].push_back({num(i, j - 1), 0});
		}
	}
	for(int i = 0; i < N; ++i) {
		d[i] = inf;
	}
	se.insert({0, num(1, s)});
	d[num(1, s)] = 0;
	while(se.size()) {
		int dg = (*se.begin()).second;
		se.erase(se.begin());
		for(int i = 0; i < v[dg].size(); ++i) {
			int nv = v[dg][i].first, mz = v[dg][i].second;
			if(d[nv] > d[dg] + mz) {
				if(se.find({d[nv], nv}) != se.end()) {
					se.erase(se.find({d[nv], nv}));
				}
				d[nv] = d[dg] + mz;
				se.insert({d[nv], nv});
			}
		}
	}
	for(int i = 2; i <= n; ++i) {
		cout << d[num(i, 0)] << "\n";
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 37524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;



int main(int argc, const char * argv[]) {
  

    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int n,k; cin >> n >> k;
    vector<int> tall(n);
    rep(i,n) cin >> tall[i];
    
    int ans = 0;
    rep(i,n) {
        if(tall[i] >= k) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<deque>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef deque<int> di;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int n;
    while(cin >> n, n){
        vs s(n);
        rep(i,n)cin >> s[i];
        vector<vi> g(26);
        bool ans = true;
        rep(i,n-1){
            int j = 0;
            while(j < s[i].size() && j < s[i+1].size() && s[i][j] == s[i+1][j])j++;
            if(j == s[i+1].size() && j < s[i].size()){
                ans = false;
                break;
            }
            if(j == s[i].size() || j == s[i+1].size())continue;
            //cout << s[i][j] << " " << s[i+1][j] << endl;
            g[s[i][j]-'a'].push_back(s[i+1][j]-'a');
        }
        rep(i,26){
            queue<int> q;
            rep(j,g[i].size())q.push(g[i][j]);
            vi used(26);
            while(q.size() && ans){
                int v = q.front();
                q.pop();
                used[v]++;
                rep(j,g[v].size()){
                    int ne = g[v][j];
                    if(ne == i){
                        ans = false;
                    }
                    if(used[ne] == 0){
                        q.push(ne);
                    }
                }
            }
        }
        if(ans)cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
  int a;
  cin >> a;
  map<string,int> mp;
  rep(i,a) {
      string s;
      cin >> s;
      mp[s]++;
  }
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 19264
#include <iostream>
int main(){
    using namespace std;
    long long int n,a,ans,i,x;
    ans = 100000;
    a = 1;
    cin >> n;
    for(i=0;i<n;i++){
        x = 0;
        cin >> a;
        while(a!=0){
            if(a%2!=0){
                break;
            }
            a = a/2;
            x++;
        }
        if(x<ans){
            ans = x;
        }
    }
    cout << ans << endl;
    return 0;
}

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

long long dp[3005][3005];

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

    for (int len=1; len<=n; len++) {
        for (int i=0; i+len<=n; i++) {
            int j = i+len;

            if ((n-len)% 2 == 0){
                dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1]);
                //cout << "i:" << i << ", j:" << j << " ";
                //cout << "先攻：" << dp[i][j] << endl;
            }
            else{
                dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1]);
                //cout << "i:" << i << ", j:" << j << " ";
                //cout << "後攻" << dp[i][j] << endl;
            }
        }
    }

    cout << dp[0][n] << endl;
}


Measured memory_bytes: 49764
s = int(input())
A = [s]
while True:
    if s % 2 == 0:
        a = s//2
    else:
        a = 3*s + 1

    if a in A:
        A.append(a)
        break
    else:
        A.append(a)
        s = a
        continue
print(len(A))


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod> struct modulo {
	int w;
	operator int&() { return w; }
	operator int() const { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { if (w >= mod || w < -mod) w %= mod; if (w < 0) w += mod; }
	
	inline modulo  operator -  () { w = -w + mod; return *this; }
	inline modulo  operator +  (const modulo &b) { modulo r = *this; return r += b; }
	inline modulo  operator -  (const modulo &b) { modulo r = *this; return r -= b; }
	inline modulo  operator *  (const modulo &b) { return (num) w * b.w % mod; }
	inline modulo  operator /  (const modulo &b) { return *this * inv(b); }
	inline modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline modulo& operator *= (const modulo &b) { return *this = *this * b; }
	inline modulo& operator /= (const modulo &b) { return *this /= inv(b); }
	
	friend inline modulo inv(const modulo &w) {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return modulo(u, 1);
	}
	
	friend inline modulo pow(const modulo &w, int p) {
		if (!w)  return 0;
		modulo a = w, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9) + 7;
typedef modulo<mod> rem;

const int nsz = int(5e3);
char s[nsz + 5];
int n, m;
rem dp[nsz + 5][nsz + 5], ans;

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	m = strlen(s);
	dp[0][0] = 1;
	loop (i, n + 1) {
		circ (j, 0, i) {
			rem val = dp[i][j];
			dp[i + 1][max(0, j - 1)] += val;
			dp[i + 1][j + 1] += val + val;
		}
	}
	ans = dp[n][m] / pow(rem(2), m);
	printf("%d\n", ans.w);
}

Measured memory_bytes: 70632
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,ans;
bool flg;

cin >> N;

flg = false;
ans = 1;
ll mod = 1e18;

vector<ll> A(N);

for(ll i = 0;i < N;++i) cin >> A[i];

std::sort(A.begin(),A.end(),std::greater<int>());

if(std::find(A.begin(),A.end(),0) != A.end())    cout << "0" << endl;
else {

    for(ll i = 0;i < N;++i){

        if(double(ans) > double(1e18)/double(A[i])){

            cout << "-1" << endl;
            return 0;

        }

        ans = ans * A[i];

    }
    
    if(ans > ll(1e18)) cout << "-1" << endl;
    else cout << ans << endl;

}


return 0;

}


Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  int start,stop;
  start = max(a,c);
  stop = min(b,d);

  int ans;
  ans = max(0,stop-start);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s == u) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(ll i=0;i<h;i++) cin >> s[i];
  ll f=1;
  vec idx={1,0,-1,0};
  vec idy={0,1,0,-1};
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(s[i][j]=='#') {
        ll ff=0;
        for(ll k=0;k<4;k++) {
          ll ny=i+idy[k];
          ll nx=j+idx[k];
          if(nx<0||ny<0||nx>w-1||ny>h-1) continue;
          if(s[ny][nx]=='#') ff=1;
        }
        if(!ff) f=0;
      }
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    cout << s.substr(0, 3) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

typedef long long ll;
long long fact[1000000];
long long fact_in[1000000];

//出力
void Yes(){ cout << "Yes" << endl; }
void yes(){ cout << "yes" << endl; }
void No(){ cout << "No" << endl; }
void no(){ cout << "no" << endl; }
void Possible(){ cout << "Possible" << endl; }
void possible(){ cout << "possible" << endl; }
void Imossible(){ cout << "Impossible" << endl; }
void imossible(){ cout << "impossible" << endl; }

//マクロ
#define INF 10010010010010010
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())

long long const MOD = 1000000007;

// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; for(long long i = 2; i <= n; i++) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
// ※modが素数の場合、この関数で(mod - 2)乗したら、mod割り算ができるよ！
// (参考問題: ABC034 C問題など)
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {

    if(r > n-r) r = n-r;    
    long long res = ((((fact[n] % mod) * (fact_in[r] % mod)) % mod) * (fact_in[n - r] % mod)) % mod;

    /*
    if(r == 0) return 1;
    ll a = 1;
    for(long long i = 0; i < r; i++) a = a * ((n-i) % mod) % mod;
    ll b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
    */

    return res;
}

int main(){


    fact[0] = 1;
    for(long long i = 1; i < 1000000; i++){
        fact[i] = ((fact[i - 1] % MOD) * (i % MOD)) % MOD;
    }


    for(ll i = 0; i < 1000000; i++){
        fact_in[i] = mod_pow(fact[i], MOD - 2, MOD) % MOD;
    }

    long long ans = 0;
    long long h, w, a, b; cin >> h >> w >> a >> b;
    a = h - a;
    for(ll j = b + 1; j <= w; j++){
        ans += (combination_mod(a + j - 2, j - 1, MOD) % MOD) * (combination_mod(w - j + h - a - 1, w - j, MOD) % MOD);
        ans %= MOD;
        //cout << a + j - 2 << " " << j - 1 << "   " << w - j + h - a - 1 << " " << w - j << endl;
        //cout << j << " " << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
N, M = map(int, input().split())
l = [[] for i in range(N)]
old_p = 0
for i in range(M):
    tmp = list(input().split())
    # if tmp[0] != str(old_p + 1):
    #     old_p += 1
    # l[old_p].append(tmp[1])
    l[int(tmp[0]) - 1].append(tmp[1])
ac = 0
wa = 0
#print(l)
for i in range(N):
    wa_tmp = 0
    for j in range(len(l[i])):
        if l[i][j] == 'WA':
            wa_tmp += 1
        else:
            ac += 1
            wa += wa_tmp
            break
print('{} {}'.format(ac, wa))


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

//S,N,W,E?????????????????????????????????????????????????????????????????¢????????¢??°
void change(char X, int Dice[]){

	int Dice_copy[6] = {};

	//Dice???????????¨??????????????????Dice_copy?????????
	for (int i = 0; i < 6; i++){ Dice_copy[i] = Dice[i]; }


	switch (X){

	case 'S':
		Dice_copy[0] = Dice[4];
		Dice_copy[1] = Dice[0];
		Dice_copy[2] = Dice[2];//E
		Dice_copy[3] = Dice[3];//W
		Dice_copy[4] = Dice[5];
		Dice_copy[5] = Dice[1];
		break;

	case 'E':
		Dice_copy[0] = Dice[3];
		Dice_copy[1] = Dice[1];//S
		Dice_copy[2] = Dice[0];
		Dice_copy[3] = Dice[5];
		Dice_copy[4] = Dice[4];//N
		Dice_copy[5] = Dice[2];
		break;

	case 'W':
		Dice_copy[0] = Dice[2];
		Dice_copy[1] = Dice[1];//S
		Dice_copy[2] = Dice[5];
		Dice_copy[3] = Dice[0];
		Dice_copy[4] = Dice[4];//N
		Dice_copy[5] = Dice[3];
		break;
	case 'N':
		Dice_copy[0] = Dice[1];
		Dice_copy[1] = Dice[5];
		Dice_copy[2] = Dice[2];//E
		Dice_copy[3] = Dice[3];//W
		Dice_copy[4] = Dice[0];
		Dice_copy[5] = Dice[4];
		break;
	}//switch???

	//Dice_copy????????????Dice????????????
	for (int i = 0; i < 6; i++){
		Dice[i] = Dice_copy[i];
	}
}

int main(){

	int Dice_a[6] = {};//{0,1,2,3,4,5}={???,S,E,W,N,???}
	int Dice_b[6] = {};

	//????????????1?????£??\
	for (int i = 0; i < 6; i++){
		cin >> Dice_a[i];
	}
	//????????????2?????£??\
	for (int i = 0; i < 6; i++){
		cin >> Dice_b[i];
	}

	//S?????????3??????E?????????3?????¢????????¨??¨????????????

	//????????????????????¢??¨?????¢??????????????????
	for (int i = 0; i < 3 && ((Dice_a[0] != Dice_b[0]) || (Dice_a[5] != Dice_b[5]) ); i++){

		change('S', Dice_b);
	}

	//????????????????????¢??????????????????
	for (int i = 0; i < 3 && ((Dice_a[0] != Dice_b[0]) || (Dice_a[5] != Dice_b[5]) ); i++){

		change('E', Dice_b);
	}


	//??????????????§?????¢??????????????¢????????£???????????´???No
	if ((Dice_a[0] != Dice_b[0]) || (Dice_a[5] != Dice_b[5])){
		cout << "No" << endl;

	}
	else

	//??´??¢???????????????
	//??´??¢????????¢?????????????¨?????????????S???E???N???W??§??????
	//?????¢???????????´????????????S???E???N???W???S????????????????????????	
	//b???{SENW}{ENWS}{NWSE}{WSEN}?????????????????¨a???{SEWN}????????´?????????????¢??????????
	//{0,1,2,3,4,5}={???,S,E,W,N,???}

	if ((Dice_a[1] == Dice_b[1] && Dice_a[2] == Dice_b[2] && Dice_a[4] == Dice_b[4] && Dice_a[3] == Dice_b[3])
		|| (Dice_a[1] == Dice_b[2] && Dice_a[2] == Dice_b[4] && Dice_a[4] == Dice_b[3] && Dice_a[3] == Dice_b[1])
		|| (Dice_a[1] == Dice_b[4] && Dice_a[2] == Dice_b[3] && Dice_a[4] == Dice_b[1] && Dice_a[3] == Dice_b[2])
		|| (Dice_a[1] == Dice_b[3] && Dice_a[2] == Dice_b[1] && Dice_a[4] == Dice_b[2] && Dice_a[3] == Dice_b[4])){

		cout << "Yes" << endl;

	}
	else{ cout << "No" << endl; }



	return 0;
}

Measured memory_bytes: 1160
x=int(input())

def rt5(a):
  if a==0:
    return 0
  i=1
  while 1:
    s=i**5
    if a==s:
      return i
    elif a==-s:
      return -i
    elif abs(a)<s:
      return False
    i+=1

b=0

while 1:
  a5=x+b**5
  a=rt5(a5)
  if a==False:
    pass
  else:
    print(a,b)
    exit()
  
  a5=x-b**5
  a=rt5(a5)
  if a==False:
    pass
  else:
    print(a,-b)
    exit()
  b+=1
    

Measured memory_bytes: 79576
import java.io.*;
import java.util.*;
   
class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s1 = sc.nextLine();
            String s2 = sc.nextLine();
            String s3 = s1 + s1;
            if (s3.contains(s2)) {
                    System.out.println("Yes");
            }else{
                    System.out.println("No");
            }
        }
}


Measured memory_bytes: 26172
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strNM = Console.ReadLine().Split(' ');
            int N = int.Parse(strNM[0]);
            int M = int.Parse(strNM[1]);
            int P;
            int AC = 0;
            int WA = 0;
            int[] WAarray = new int[N];
            int[] ACarray = new int[N];

            for(int i = 0; i < M; i++)
            {
                string[] strtmp = Console.ReadLine().Split(' ');
                P = int.Parse(strtmp[0]);
                if(ACarray[P-1] == 0)
                {
                    if(strtmp[1] == "AC")
                    {
                        ACarray[P-1] = 1;
                        WA += WAarray[P - 1];
                        AC++;
                    }
                    if(strtmp[1] == "WA")
                    {
                        WAarray[P-1]++;
                    }
                }
            }


            Console.WriteLine($"{AC} {WA}");

        }
    }
}




/*
  long N = long.Parse(Console.ReadLine());
            string[] strP = Console.ReadLine().Split(' ');
            string[] strQ = Console.ReadLine().Split(' ');

            long[] P = new long[N];
            long[] Q = new long[N];
            for(long i = 0; i < N; i++)
            {
                P[i] = long.Parse(strP[i]);
                Q[i] = long.Parse(strQ[i]);
            }




            Console.WriteLine(ans);
 * */


Measured memory_bytes: 17760
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int H, W, i, x;
    for(;scanf("%d%d", &H, &W);){
        if(H == 0 && W == 0){break;}
        for(i=1; i<=H;i++){
            for(x=1;x<=W;x++){
                printf("#");}
            printf("\n");}
        printf("\n");}
    return 0;
}

Measured memory_bytes: 572
package main

import "fmt"

func main() {
	var a, b, c, d, e, f int
	fmt.Scan(&a, &b, &c, &d, &e, &f)
	a *= 100
	b *= 100

	waters := make([]int, 0, 100)
	for ai := 0; a*ai <= f; ai++ {
		for bi := 0; b*bi <= f; bi++ {
			water := a*ai + b*bi
			if water <= f {
				waters = append(waters, water)
			}
		}
	}

	sugars := make([]int, 0, 100)
	for ci := 0; c*ci <= f; ci++ {
		for di := 0; d*di <= f; di++ {
			sugar := c*ci + d*di
			if sugar <= f {
				sugars = append(sugars, sugar)
			}
		}
	}

	ansSugar := 0
	ansSolution := a
	for _, water := range waters {
		for _, sugar := range sugars {
			solution := water + sugar
			if solution == 0 || solution > f {
				continue
			}
			if sugar*(100+e) > e*solution {
				continue
			}
			if sugar*ansSolution > ansSugar*solution {
				ansSugar = sugar
				ansSolution = solution
			}
		}
	}
	fmt.Println(ansSolution, ansSugar)
}


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

map<int,int>vis;
int flag[200005];
int main()
{
  int n, m, a, ok=0, res=0, c=0;

  cin>>n>>m;
  string s;
  while(m--)
  {
    cin>>a>>s;
    if(s=="AC"&&flag[a]==0)
    {
        c++;
      flag[a]=1;
      res=res+vis[a];
      vis[a]=0;
    }
    else if(s=="WA"){
        vis[a]++;
     }
   }
   cout<<c<<" "<<res<<endl;

}

Measured memory_bytes: 6912
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		String str=scan.next();
		int rui[]=new int[a];
		int co=0;
		int kirikaeshi=0;
		for(int i=0;i<a;i++) {
			char ch=str.charAt(i);
			if(i<a-1) {
				char ch2=str.charAt(i+1);
				if(ch!=ch2) {
					kirikaeshi++;
				}
			}
			if(ch=='#') {
				co++;
			}
			rui[i]=co;
		}
		int len=str.length();
		if(kirikaeshi==0||kirikaeshi==1&&str.charAt(0)=='.') {
			System.out.println(0);
			return;
		}
		else if(kirikaeshi==1&&str.charAt(0)=='#') {
			int min=0;
			min=Math.min(rui[a-1], len-rui[a-1]);
			System.out.println(min);
			return;
		}
		int ans=1145141919;
		for(int i=0;i<str.length();i++) {
			int change=rui[i];
			int nokori=len-i-1;
			int zerosum=rui[a-1]-rui[i];
			change+=nokori-zerosum;
			if(ans>change) {
				ans=change;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28368
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ThisMessageWillSelf solver = new ThisMessageWillSelf();
        solver.solve(1, in, out);
        out.close();
    }

    static class ThisMessageWillSelf {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            long result = 0;

            Map<Integer, Integer> p = new HashMap<>();
            for (int i = 1; i <= n; i++) {
                int tall = in.nextInt();

                int key = i + tall;
                p.put(key, p.getOrDefault(key, 0) + 1);

                if (p.containsKey(i - tall)) {
                    result += p.get(i - tall);
                }
            }

            out.append(String.valueOf(result));
        }

    }
}



Measured memory_bytes: 71552
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,m,v,p;
int a[100005],ans,nums=0;
long long sum[100005];
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
		if(a[i]==a[i-1]) nums++;
		else nums=1;
		if(i-nums+1<=p)
		{
			ans++;
			continue;
		}
		if(a[i]+m<a[p]) break;
		int num=p-1+(n-i)+nums-1;
		if(num>=v-1) ans++;
		else
		{
			int l=p,r=i-nums;
			if(l>r) break;
			else
			{
				while(l<r)
				{
					int mid=(l+r)>>1;
					if(a[i]+m>=a[mid]) r=mid;
					else l=mid+1;
				}
				if(1ll*(a[i]+m)*(i-nums-l+1)-(sum[i-nums]-sum[l-1])>=1ll*(v-num-1)*m) ans++;
				else break;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4964
#include<bits/stdc++.h>
#define MAXN 300005
#define MOD 1000000007
using namespace std;

int n;
char c[MAXN];
long long f[MAXN][4][4];
long long ans=0;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	register int i,x,y;
	scanf("%s",c+1);
	n=strlen(c+1);
	f[0][0][0]=1;
	for(i=1;i<=n;++i)
		for(x=0;x<=2;++x)
			for(y=0;y<=2;++y)
			{
				if(c[i]!='1')
				{
					if(y==2) f[i][x][y-1]=(f[i][x][y-1]+f[i-1][x][y])%MOD;
					else f[i][x][y+1]=(f[i][x][y+1]+f[i-1][x][y])%MOD;
				}
				if(c[i]!='0')
				{
					if(y==0) f[i][x+(x!=2)][y]=(f[i][x+(x!=2)][y]+f[i-1][x][y])%MOD;
					else f[i][x][y-1]=(f[i][x][y-1]+f[i-1][x][y])%MOD;
				}
			}
	for(x=0;x<=2;++x)
		for(y=x;y>=0;--y)
			ans=(ans+f[n][x][y])%MOD;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 38016
#include<stdio.h>
int main(){
  int n,i,c=0;
  char s[100010];
  scanf("%d %s",&n,s);
  for(i=0;i<n;i++){
    if(s[i]==s[i+1])c++;
  }
  printf("%d\n",n-c);
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  int mini = INF, sum = 0, m;
  rep(i, N) {
    cin >> m;
    sum += m;
    minch(mini, m);
  }
  cout << N + (X - sum) / mini << endl;
  return 0;
}


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

#define N 11

int stock[2];
int ball[N];

int get(int x)
{
	int ret = 0;
	
	if (x == 10){
		return (1);
	}
	
	if (stock[0] < ball[x]){
		stock[0] = ball[x];
		ret += get(x + 1);
	}
	if (stock[1] < ball[x]){
		stock[1] = ball[x];
		ret += get(x + 1);
	}
	
	return (ret);
}

int main(void)
{
	int n;
	int i, j;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		memset(stock, 0, sizeof(stock));
		for (j = 0; j < 10; j++){
			scanf("%d", ball + j);
		}
		
		printf("%s\n", (get(0) ? "YES" : "NO"));
	}
	
	return (0);
}

Measured memory_bytes: 580
let id x = x
let n = Scanf.scanf "%d\n" id
let k = Scanf.scanf "%d\n" id
let array = Array.init n (fun _ -> Scanf.scanf "%d " id)
let list = Array.to_list array

let rec func l =
  match l with
  | [] -> 0
  | hd :: rest -> 2 * (min hd (k-hd)) + func rest

let ans = func list

let () =
  Printf.printf "%d\n" ans

Measured memory_bytes: 384
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
const int INF = 1e18;
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int inf = 1e9;
int const N = 1e5+10;
int const M = 505;
int const MOD = 998244353;

int dist[100005];
void solve(){
    int n;
    cin >> n;
    
    int ar[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    
    ar[0] = 1e6;
    for(int i = 2; i <= n; i++){
        dist[i] = min(abs(ar[i] - ar[i - 1]) + dist[i - 1], abs(ar[i] - ar[i - 2]) + dist[i - 2]);
    }
    cout << dist[n] << endl;
    
    
}

int32_t main(){
    solve();
    
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
int main(){
	
	/*
	int A,B,C,D,seconds,minutes;
	cin >> A >> B >> C >> D;
	seconds=A+B+C+D;
	minutes = seconds / 60;
	cout << minutes << seconds << endl;*/
	 
	int Q,P,R;
	cin >> Q >> P >>R;
	int answer;
	answer=Q*P/2;
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool jg=true;
    for(int i=0;i<3;i++){
        if(s.at(i)==s.at(i+1)){
            jg=false;
            break;
        }
    }

    if(jg==true){
        cout<<"Good"<<endl;
    }
    else{
        cout<<"Bad"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the set
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r,d,x;
    cin>>r>>d>>x;
    ll temp=x;
    for(int i=0;i<10;i++)
    {
        ll a=r*temp-d;
        cout<<a<<endl;
        temp=a;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int N = 1 << 17;
const int NIL = INT_MAX;

int mini[N * 2];
int lazy[N * 2];

void setLazy(int k, int v) {
    lazy[k] = v;
    mini[k] = v;
}

void push(int k) {
    // ?????¶?????????????????????????????°???????????????
    if (lazy[k] == NIL) {
        return;
    }
    setLazy(k * 2 + 0, lazy[k]);
    setLazy(k * 2 + 1, lazy[k]);

    // ????????????????????¬??????????????§????????????????????????
    lazy[k] = NIL;
}

void fix(int k) {
    // ?????????k?????????????????????????????§?????????????????????????????§????????¨????????????????????§??????????????§???
    mini[k] = min(mini[k * 2], mini[k * 2 + 1]);
}

// ??????[queryL,queryR)???val??§???????????¶???
void fill(int queryL, int queryR, int val, int k = 1, int nodeL = 0, int nodeR = N) {
    // ?????¨???????????¨????????????????????????????????????????????????????????\?????????????????????????????????
    if (nodeR <= queryL || queryR <= nodeL) {
        return;
    }
    // ???????????????????????¨?????????????????¨??????????????????????????¶????????????????????????????????£?????¨??°???
    if (queryL <= nodeL && nodeR <= queryR) {
        setLazy(k, val);
        return;
    }
    // ???????????????????????¨??????????????????push??????
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    fill(queryL, queryR, val, k * 2 + 0, nodeL, nodeM);
    fill(queryL, queryR, val, k * 2 + 1, nodeM, nodeR);
    // ???????????????????????¨??????????????±???fix??????
    fix(k);
}

// ??????[queryL, queryR)???????°????????±???????
int minimum(int queryL, int queryR, int k = 1, int nodeL = 0, int nodeR = N) {
    // ?????¨???????????¨???????????????????????????????????????
    if (nodeR <= queryL || queryR <= nodeL) {
        return INT_MAX;
    }
    // ???????????????????????¨?????????????????¨???????????????
    if (queryL <= nodeL && nodeR <= queryR) {
        return mini[k];
    }
    // ???????????????????????¨??????????????????push??????
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    int vl = minimum(queryL, queryR, k * 2 + 0, nodeL, nodeM);
    int vr = minimum(queryL, queryR, k * 2 + 1, nodeM, nodeR);
    return min(vl, vr);
}

int main()
{
    int n,q;
    cin >> n >> q;
    rep(i,2*N){
        mini[i] = INT_MAX;
    }
    rep(i,2*N){
        lazy[i] = NIL;
    }
    rep(i,q){
        int a;
        scanf("%d",&a);
        if(a == 0){
            int x,y,z;
            scanf("%d%d%d",&x,&y,&z);
            fill(x,y+1,z);
        }else{
            int x,y;
            scanf("%d%d",&x,&y);
            cout << minimum(x,y+1) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };


// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == k) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	sort(allof(a), greater<int>());
	if (a[0] < k) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	// 最大公約数が1となる組があればいける

	int g = a[0];

	Rep(i, 1, n) {
		g = gcd(g, a[i]);
	}

	bool can = false;
	rep(i, n) {
		if (a[i] - k < 0) continue;
		if ((a[i] - k) % g == 0)
		{
			can = true;
			break;
		}
	}

	if (can) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#define ll long long 
using namespace std;
int n,k,b;
ll ans;
int main(){
	 scanf("%d%d",&n,&k);
	 if(k==0){
	 	printf("%lld\n",(ll)n*n);
	 	return 0;
	 }
	 for(b=1;b<=n;b++){
	// 	int num=max(0,(ll)(b-1-k+1)*((n+1)/b))+max(0,n-(n+1)/b*b-k+1);
	 	ans+=max(0ll,(ll)(b-1-k+1)*((n+1)/b));
	 	ans+=max(0ll,(ll)n-(ll)(n+1)/b*b-k+1);
	 //	printf("%d %d\n",b,num);
	 }
	 printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int CONTEST_NUM=26;

int score_function(const vector<int> &t,const vector<vector<int>> &s,const vector<int> &c,const int &d){
    vector<int> last(27);
    int manzoku=0;
    for(int i=1;i<=d;i++){
        manzoku+=s[i][t[i]];
        last[t[i]]=i;
        int sum=0;
        for(int j=1;j<=CONTEST_NUM;j++){
            sum+=c[j]*(i-last[j]);
        }
        manzoku-=sum;
    }
    return manzoku;
}

void set_ans(const vector<int> &t,vector<int> &ans,const int &d){
    for(int i=1;i<=d;i++){
        ans[i]=t[i];
    }
}

int main() {
    int d;cin>>d;
    vector<int> c(27);
    for(int i=1;i<=CONTEST_NUM;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d+1,vector<int>(27));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=CONTEST_NUM;j++){
            cin>>s[i][j];
        }
    }
    vector<int> t(d+1);
    vector<int> ans(d+1);
    int old_ans=-1000000000;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(1,26);
    std::uniform_int_distribution<> randd(1,d);

    for(int i=1;i<=d;i++){
        int max_contest=-1;
        for(int j=1;j<=CONTEST_NUM;j++){
            if(max_contest<s[i][j]){
                max_contest=s[i][j];
                t[i]=j;
            }
        }
    }
    int k=0;
    while(k<320000){
        int che=randd(mt);
        int old_f=t[che];
        t[che]=rand26(mt);
        int tmp=score_function(t,s,c,d);
        if(tmp>old_ans){
            set_ans(t,ans,d);
            old_ans=tmp;
        }
        else{
            t[che]=old_f;
        }
        k++;
    }
    //cout<<old_ans<<endl;
    for(int i=1;i<=d;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3700
h, w = [int(n) for n in input().split()]
grid = [input() for _ in range(h)]
row_hashs = set()
column_hashs = set()

for i, row in enumerate(grid):
    for j, ch in enumerate(row):
        if ch == '#':
            row_hashs.add(i)
            column_hashs.add(j)

new_grid = []

for i, row in enumerate(grid):
    if i not in row_hashs:
        continue
    new_grid.append([])
    for j, ch in enumerate(row):
        if j not in column_hashs:
            continue
        new_grid[-1].append(ch)
    new_grid[-1] = "".join(new_grid[-1])


print("\n".join(new_grid))
# print(*new_grid, sep="\n")

Measured memory_bytes: 3064
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if L[i] != L[j]:
            for k in range(j + 1, N):
                if L[i] != L[k] and L[j] != L[k]:
                    M = [L[i], L[j], L[k]]
                    M.sort()
                    if M[2] < M[0] + M[1]:
                        cnt += 1
print(cnt)

Measured memory_bytes: 8988
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
    //???????????????
    function f1 (a,b){
        return a*b;
    }
    function f2 (a,b){
        return (a+b)*2;
    }
    console.log(f1(a,b), f2(a,b));
    
    
  }(params[0],params[1])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
static MOD: usize = 1000000007;
fn ipow(a: usize, n: usize) -> usize {
    let mut r = 1;
    let mut b = a;
    let mut k = n;
    while k>0 {
        if (k&1)!=0 {
            r = r*b%MOD;
        }
        b = b*b%MOD;
        k >>= 1;
    }
    r
}
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
    }
    let mut c = Vec::new(); c.resize(k+1, 0);
    for i in (1..k+1).rev() {
        let m = k/i;
        c[i]=ipow(m,n);
        for j in 2..=m {
            let v = c[i*j];
            if c[i]<v {
                c[i]+=MOD;
            }
            c[i]-=v;
        }
    }
    let mut t=0;
    for i in 1..k+1 {
        t = (t+c[i]*i)%MOD;       
    }
    println!("{}",t);
}

Measured memory_bytes: 2764
#!/usr/bin/ruby
def heappush(heap, item)
	heap.push(item)
	_siftdown(heap, 0, heap.size-1)
end

def heappop(heap)
	lastelt = heap.pop
	if !heap.empty?
		returnitem = heap[0]
		heap[0] = lastelt
		_siftup(heap, 0)
	else
		returnitem = lastelt
	end
	returnitem
end

def heappushpop(heap, item)
	if !heap.empty? && (heap[0]<=>item)<0
		item, heap[0] = heap[0], item
		_siftup(heap, 0)
	end
	item
end

def heapify(x)
	n = x.size
	(n/2-1).downto(0){|i|_siftup(x, i)}
end

def _siftdown(heap, startpos, pos)
	newitem = heap[pos]
	while pos > startpos
		parentpos = (pos - 1) >> 1
		parent = heap[parentpos]
		if (newitem<=>parent)<0
			heap[pos] = parent
			pos = parentpos
		else
			break
		end
	end
	heap[pos] = newitem
end

def _siftup(heap, pos)
	endpos = heap.size
	startpos = pos
	newitem = heap[pos]
	childpos = 2*pos + 1
	while childpos < endpos
		rightpos = childpos + 1
		if rightpos < endpos && (heap[childpos]<=>heap[rightpos])>=0
			childpos = rightpos
		end
		heap[pos] = heap[childpos]
		pos = childpos
		childpos = 2*pos + 1
	end
	heap[pos] = newitem
	_siftdown(heap, startpos, pos)
end

### main ###
q=[]
loop{
	a=gets.split
	break if a[0]=='end'
	if a[0]=='insert'
		heappush(q,-a[1].to_i)
	else
		p -heappop(q)
	end
}

Measured memory_bytes: 16676
'''input
5 12
'''

N, K = [int(x) for x in input().split()]

if not K:
	for i in range(1 << N):
		print(i, i, end=' ')
	exit()

if N == 1:
	if K == 1:
		print(-1)
		exit()

if K >= 1 << N:
	print(-1)
	exit()

prad = list(range(1 << N))

prad.remove(K)

pab = list(reversed(prad))


for i in prad:
	print(i, end=' ')

print(K, end=' ')
for i in pab:
	print(i, end=' ')
print(K)

Measured memory_bytes: 11088