akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e5;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

int main(){
    int N; string S;
    cin >> N >> S;
    queue<int> ids[3];
    rep(i, 3*N){
        if(S[i] == 'R') ids[0].push(i);
        elif(S[i] == 'G') ids[1].push(i);
        else ids[2].push(i);
    }
    vector<int> a, b, c;
    rep(i, N){
        vector<int> tmp;
        rep(j, 3) tmp.pb(ids[j].front()), ids[j].pop();
        sort(all(tmp));
        a.pb(tmp[0]), b.pb(tmp[1]), c.pb(tmp[2]);
    }
    mint ans = 1;
    //aとbの組み合わせ
    rep(i, N){
        int j = lower_bound(all(a), b[i]) - a.begin();
        ans *= j-i;
    }
    //bとcの組み合わせ
    rep(i, N){
        int j = lower_bound(all(b), c[i]) - b.begin();
        ans *= j-i;
    }
    init();
    ans *= fac[N];
    cout << ans.x << endl;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){	
  	cin.tie(nullptr);
    ios::sync_with_stdio(false);
  	int A,B,K;
  	cin>>A>>B>>K;
  	if(B-A<2*K)for(int i=A;i<=B;i++)cout<<i<<"\n";
  	else for(int i=A;i<=B;i++)if(i<A+K||B-K<i)cout<<i<<"\n";
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int last = 0;
    rep(i, n)
    {
        if (a[i] - 1 >= last)
            last = a[i] - 1;
        else if (a[i] >= last)
            last = a[i];
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std ;
typedef int Read ; // Here to change the type of numbers
inline Read Readin() {
	Read K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline Read Min( Read A , Read B ) { return A < B ? A : B ; }
inline Read Max( Read A , Read B ) { return A > B ? A : B ; }
inline Read Abs( Read A ) { return A < 0 ? -A : A ; }
int Ans ;
inline bool P( int Num ) {
	int Sqr = sqrt( Num ) ;
	for(register int i = 2 ; i <= Sqr ; ++i )
		if( Num % i == 0 ) return false ;
	return true ;
}

int N , Cnt[105] ;
int main() {
	N = Readin() ;
	for(register int i = 1 ; i <= N ; ++i ) {
		register int j = i ;
		for(register int k = 2 ; k <= N ; ++k )
			if( P(k) ) {
				while( j % k == 0 and j != 0 ) {
					++Cnt[k] ;
					j /= k ;
				}
			}
	}
	for(register int i = 1 ; i <= N ; ++i )
		for(register int j = i+1 ; j <= N ; ++j )
				for(register int k = j+1 ; k <= N ; ++k ) {
					if( Cnt[i] >= 4 and Cnt[j] >= 4 and Cnt[k] >= 2 ) ++Ans ;
					if( Cnt[i] >= 4 and Cnt[j] >= 2 and Cnt[k] >= 4 ) ++Ans ;
					if( Cnt[i] >= 2 and Cnt[j] >= 4 and Cnt[k] >= 4 ) ++Ans ;
				}
	for(register int i = 1 ; i <= N ; ++i )
		for(register int j = i+1 ; j <= N ; ++j ) {
			if( Cnt[i] >= 24 and Cnt[j] >= 2 )
				++Ans ;
			if( Cnt[j] >= 24 and Cnt[i] >= 2 )
				++Ans ;
			if( Cnt[i] >= 14 and Cnt[j] >= 4 )
				++Ans ;
			if( Cnt[j] >= 14 and Cnt[i] >= 4 )
				++Ans ;
		}
	for(register int i = 1 ; i <= N ; ++i )
		if( Cnt[i] >= 74 ) ++Ans ;
	printf( "%d\n" , Ans ) ;
	return 0 ;
}

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

const int N = 500500;
using ll = long long;

ll arr[N];
ll tree[4*N];

void build(int idx,int left,int right)
{
    tree[idx]=0;
    if(left==right)
    {
        tree[idx]=arr[left];
        return ;
    }
    int mid=(left+right)/2;
    build(idx*2,left,mid);
    build(idx*2+1,mid+1,right);
    tree[idx] = tree[idx*2] | tree[idx*2+1];
}

void update(int idx,int left,int right,int pos,ll c)
{
    if(pos<left||pos>right)return ;
    if(pos==left&&pos==right)
    {
        tree[idx]=c;
        return ;
    }
    int mid=(left+right)/2;
    update(idx*2,left,mid,pos,c);
    update(idx*2+1,mid+1,right,pos,c);
     tree[idx] = tree[idx*2] | tree[idx*2+1];
}

ll query(int idx,int left,int right,int l,int r)
{
    if(right<l||r<left)return 0;
    if(l<=left&&right<=r)
    {
        return tree[idx];
    }
    int mid=(left+right)/2;
    ll x = query(idx*2,left,mid,l,r);
    ll y = query(idx*2+1,mid+1,right,l,r);
    return x|y;
}

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        int c=(int)(s[i]- 'a');
        arr[i+1]=1<<c;
    }
    build(1,1,s.size());
    int m;
    cin>>m;
    while(m--)
    {
        int t;
        scanf("%d",&t);
        if(t==1)
        {
            ll pos;
            char p;
            cin>>pos>>p;
            ll c = (int)(p- 'a');
            c=1<<c;
            update(1,1,s.size(),pos,c);
        }
        else
        {
            ll l,r;
            scanf("%lld %lld",&l,&r);
            ll q=query(1,1,s.size(),l,r);
            int ans=0;
            for(int i=0;i<26;i++)
            {
                if(q&(1<<i))
                {
                    ans++;
                }
            }
            cout<<ans<<"\n";
        }
    }
}



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

#define   ll     long long int

int main( )
{
    int h, w, i, j, k;
    string grid[55];
    cin >> h >> w;
    for (i = 0; i < h; i++) {
        cin >> grid[i];
    }
    int c = 0;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (grid[i][j] == '#' || grid[i][j] == 'c') {
                //cout << i << ' ' << j << '\n';
                if (i + 1 < h && (grid[i + 1][j] == '#' || grid[i + 1][j] == 'c')) {
                    grid[i][j] = 'c';
                    grid[i + 1][j] = 'c';
                }
                if (j + 1 < w && (grid[i][j + 1] == '#' || grid[i][j + 1] == 'c')) {
                    grid[i][j] = 'c';
                    grid[i][j + 1] = 'c';
                }
            }
            if (grid[i][j] == '#') c++;
        }
    }
    if (c == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Coloring Colorfully
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  int c0 = 0, c1 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] - '0' != (i & 1)) c0++;
    else c1++;
  }

  printf("%d\n", min(c0, c1));
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
  	int N;
  	cin >> N;
  	int W[N], sum[3] = {};
  	for(int i = 0; i < N; i++){
      	cin >> W[i];
      	sum[0] += W[i];
    }
  	for(int i = 0; sum[1] < sum[0]/2; i++)sum[1] += W[i];
  	for(int i = N-1; sum[2] < sum[0]/2; i--)sum[2] += W[i];
  	cout << min(sum[1]*2-sum[0],sum[2]*2-sum[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int a = sc.nextInt();

    int rest = a % 1000;
    if (rest == 0) {
      System.out.println(0);
    } else {
      System.out.println(Math.abs((a % 1000) - 1000));
    }
  }
}


Measured memory_bytes: 35780
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


const long long INF = 1e18;

struct edge
{
	int to, tp;
	ll co;
	edge(int t, ll c, int tp):to(t), co(c), tp(tp){}
	bool operator<(const edge& e) const {
		return co > e.co;
	}
};

int M, N, K;
ll cost[2][200005];
vector<P> xx[100005], yy[100005];
vector<edge> G[200005];
int main() {
	cin >> M >> N >> K;
	rep(i, K) {
		int x, y;
		cin >> x >> y; x--; y--;
		xx[x].emplace_back(y, i + 1);
		yy[y].emplace_back(x, i + 1);
	}
	xx[0].emplace_back(0, 0);
	xx[M - 1].emplace_back(N - 1, K+1);
	yy[N - 1].emplace_back(M - 1, K+1);

	for (int i = 0; i < M; i++) {
		sort(xx[i].begin(), xx[i].end());
		for (int j = 1; j < xx[i].size(); j++) {
			int v1 = xx[i][j - 1].second, v2 = xx[i][j].second; 
			ll cost = xx[i][j].first - xx[i][j - 1].first;
			G[v1].emplace_back(v2, cost, 0);
			G[v2].emplace_back(v1, cost, 0);
		}
	}
	for (int i = 0; i < N; i++) {
		sort(yy[i].begin(), yy[i].end());
		for (int j = 1; j < yy[i].size(); j++) {
			int v1 = yy[i][j - 1].second, v2 = yy[i][j].second;
			ll cost = yy[i][j].first - yy[i][j - 1].first;
			G[v1].emplace_back(v2, cost, 1);
			G[v2].emplace_back(v1, cost, 1);
		}
	}

	rep(i, 2)rep(j, K + 2) cost[i][j] = INF;
	cost[0][0] = 0;
	priority_queue<edge> pq;
	pq.emplace(0, 0, 0);
	while (!pq.empty())
	{
		edge now = pq.top(); pq.pop();
		if (cost[now.tp][now.to] < now.co) continue;
		for (edge e : G[now.to]) {
			ll c = now.co + e.co + (now.tp != e.tp);
			if (cost[e.tp][e.to] > c) {
				cost[e.tp][e.to] = c;
				pq.emplace(e.to, c, e.tp);
			}
		}
	}

	ll ans = min(cost[0][K + 1], cost[1][K + 1]);
	if (ans == INF) ans = -1;

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 39376
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=1<<18,mod=1e9+7;
int h,n,p[N],tag[N],ans,stk[N],top;
inline void travel2(CI x,int prod,CI opt)
{
	if (x==1) return; prod=1LL*prod*x%mod;
	if (opt) (tag[x]+=prod)%=mod; else (ans+=1LL*(x>>1)*tag[x^1]%mod*prod%mod)%=mod;
	travel2(x>>1,prod,opt);
}
inline void travel1(CI x,int prod,CI opt)
{
	prod=1LL*prod*x%mod;
	if (x>=n) return stk[++top]=n+p[x-n]-1,travel2(n+p[x-n]-1,prod,opt);
	travel1(x<<1,prod,opt); travel1(x<<1|1,prod,opt);
}
int main()
{
	RI i; for (scanf("%d",&h),n=1<<h-1,i=0;i<n;++i)
	scanf("%d",&p[i]); for (i=1;i<n;++i)
	{
		travel1(i<<1,i,1); travel1(i<<1|1,1,0);
		while (top) for (int x=stk[top--];x;x>>=1) tag[x]=0;
	}
	return printf("%d",ans),0;
}

Measured memory_bytes: 3804
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


mat mul(mat &A, mat &B){
    mat C(A.size(), vll(B[0].size()));
    rep(i,A.size()){
        rep(k,B.size()){
            rep(j,B[0].size()){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j]);
            }
        }
    }
    return C;
}

mat pow(mat A,ll n){
    mat B(A.size(), vll(A.size()));
    rep(i,A.size()){
        B[i][i]=1;
    }
    while(n>0){
        if(n&1) B=mul(B,A);
        A=mul(A,A);
        n>>=1;
    }
    return B;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    mat A(2,vll(2));
    A[0][0]=1,A[0][1]=1,A[1][0]=1,A[1][1]=0;
    A=pow(A,n);
    mat v(1,vll(2));
    v[0][0]=1,v[0][1]=1;
    A=mul(A,v);
    cout<<A[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 3208
/**
* @author Ashini Singha
* IIT,Jahangirnagar University
*/

#include<bits/stdc++.h>

using namespace std;

#define     ll          long long int
#define     fo(i,b,n)   for(int i=(b); i<(n) ; i++)
#define     xx          first
#define     yy          second
#define     pb          push_back
#define     sz(n)       int(n.size())
#define     pii         pair
#define     MP          make_pair
#define     tp          tuple
#define     MT          make_tuple
#define     gt(x,y)     get<x>(y)

#define     PI          acos(-1.0)

//read
#define read(x)         scanf("%d",&x)
#define read2(x,y)      scanf("%d%d",&x,&y)
#define readl(x)        scanf("%lld",&x)
#define readl2(x,y)     scanf("%lld%lld",&x,&y)
#define readd(x)        scanf("%lf",&x)
#define readd2(x,y)     scanf("%lf%lf",&x,&y)

//write
#define pr(n)           printf("%d",n)
#define prn(n)          printf("%d\n",n)
#define prl(n)          printf("%lld",n)
#define prln(n)         printf("%lld\n",n)
#define prd(x)          printf("%lf",x)
#define prdn(x)         printf("%lf\n",x)

#define TC(n) printf("Case %d:\n",n)

/*______________E_N_D______________*/



int main()
{
      ios_base::sync_with_stdio(0), cin.tie(0);
      int n;
      cin >> n;
      int cnt = 0;
      fo(i, 0, n) {
            int x;
            cin >> x;
            if(x & 1)cnt++;
      }
      if(cnt & 1)cout << "NO" << endl;
      else cout << "YES" << endl;
      return 0;
}




















Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  unsigned long long int n;
  cin >> n;
  unsigned long long int sum = 0;
  for (unsigned long long int i = 1; i <= n; i++){
    if (i%3!=0 && i%5!=0){
      sum += i;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 25+7;
struct node{ int parent, left, right; };
node tree[MAXN];
void pre(int root){
	printf(" %d", root);
	if(tree[root].left!=-1){
		pre(tree[root].left);
	}
	if(tree[root].right!=-1){
		pre(tree[root].right);
	}
}

void in(int root){
	if(tree[root].left!=-1){
		in(tree[root].left);
	}
	printf(" %d", root);
	if(tree[root].right!=-1){
		in(tree[root].right);
	}
}

void po(int root){
	if(tree[root].left!=-1){
		po(tree[root].left);
	}
	if(tree[root].right!=-1){
		po(tree[root].right);
	}
	printf(" %d", root);
}
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		tree[i].parent = tree[i].left = tree[i].right = -1;
	} 
	for(int i = 0; i < n; i++){
		int id, l, r;
		scanf("%d", &id);
		scanf("%d", &l);
		scanf("%d", &r);
		tree[id].left = l; 
		tree[id].right = r;
		tree[l].parent = id; 
		tree[r].parent = id; 
	}
	int root;
	for(int i = 0; i < n; i++){
		if(tree[i].parent == -1){
			root = i; break;
		}
	}
	printf("Preorder\n");
	pre(root);
	printf("\nInorder\n");
	in(root);
	printf("\nPostorder\n");
	po(root);
	printf("\n");
	return 0;
}


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

// void print(int a[][3], int n)
// {
//     for(int i=0; i<n;i++)
//     {
//         for(int j=0;j<3;j++)
//         cout<<a[i][j]<<" ";
        
//         cout<<endl;
//     }   
// }

int solve(int a[][3], int n)
{
    int dp[n][3];
    for(int i=0;i<n;i++)dp[i][0]=dp[i][1]=dp[i][1]=INT_MAX;
    
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    
    for(int i=1;i<n;i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0]);

    }
    // print(dp, n);
    return *max_element(dp[n-1], dp[n-1]+3);
}

int main()
{
    int n;
    cin>>n;
    
    int a[n][3];
    for (int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    int res = solve(a, n);
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long s = sc.nextLong();

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < k; i++) {
			sb.append(s).append(" ");
		}

		for (int i = 0; i < n - k; i++) {
			if (s == 1000000000) sb.append(1);
			else sb.append(s + 1);
			sb.append(" ");
		}

		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 29780
#include<bits/stdc++.h>
using namespace std;pair<int,int>p[1<<20];int N,i,c,b,n[1<<20],d[1<<20];main(){for(cin>>N;i<N;i++)cin>>c>>b,p[i]={c,c+b};sort(p,p+N);for(b=d[N]=1;c=i--;b=d[i]=(b+d[n[i]=c])%998244353)for(;c<N&p[c].first<p[i].second;c=n[c]);cout<<*d;}

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

using namespace std;

#define MOD 1000000007

int main(){
  string t,b; cin >> t >> b;
  vector<long long> dp(b.size());
  for(int i=0;i<t.size();++i){
    for(int j=b.size()-1;j>=0;--j){
      if(j==0 && t[i]==b[j]) dp[0]++;
      else if(j<=i && t[i]==b[j]) (dp[j]+=dp[j-1])%=MOD;
    }
  }
  cout << dp[b.size()-1] << endl;
  
  return 0;
}


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

using namespace std;

void dfs(int cur, vector<vector<int>>& edge, vector<int>& memo){
    if(memo[cur]) return;
    memo[cur] = 1;
    for(int next: edge[cur]){
        dfs(next, edge, memo);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N);
    for(int i = 0; i < M; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        edge[y].push_back(x);
        edge[x].push_back(y);
    }
    vector<int> memo(N);
    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(memo[i] == 0){
            ++ans;
            dfs(i, edge, memo);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10752
#include <stdio.h>
int main()
{
    double r,l,s;
    
    double pi = 3.14159265358979;
    
    scanf(" %lf ",&r);
    
    l =  r * pi * 2;
    s =  r * r * pi;
    
    printf("%f %f\n",s , l);
    
    return 0;
}


Measured memory_bytes: 2140
while 1:
 H, W = map(int, input().split())
 if H == 0 and W == 0:
  break
 for i in range(0, H):
  line = ''
  if i % 2 == 0:
   for a in range(0, W):
    if a % 2 == 0:
     line += '#'
    else:
     line += '.'
  else:
   for b in range(0, W):
    if b % 2 == 0:
     line += '.'
    else:
     line += '#'
  print(line)
 print()
   

Measured memory_bytes: 7628
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  char in[3][4];
  while(cin>>in[0],in[0][0]!='0'){
    rep(i,2)cin>>in[i+1];
    bool h=false;
    rep(i,3){
      if(in[0][i]==in[1][i]&&in[1][i]==in[2][i]&&in[0][i]!='+'){cout<<in[0][i]<<endl;h=true;break;}
      else if(in[i][0]==in[i][1]&&in[i][1]==in[i][2]&&in[i][0]!='+'){cout<<in[i][0]<<endl;h=true;break;}
    }
    if(!h){
      if(in[0][0]==in[1][1]&&in[1][1]==in[2][2]&&in[0][0]!='+')cout<<in[0][0]<<endl;
      else if(in[2][0]==in[1][1]&&in[1][1]==in[0][2]&&in[1][1]!='+')cout<<in[1][1]<<endl;
      else cout<<"NA"<<endl;
    }
  }


}

Measured memory_bytes: 1132
#include<iostream>
using namespace std;
int main()
{
  string M,N;
  cin>>M;
  cin>>N;
  int l=M.size(),sum=0;
  for(int i=0;i<l;i++)
  {
    if(M[i]!=N[i])
    {
      sum++;
    }
  }
  cout<<sum<<"\n";
  return 0;
}
      

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int N;
int a[300010];
vector<ll> memof, memob;

int main(void) {
	cin >> N;
	rep(i, 3 * N) cin >> a[i];
	priority_queue<int, vector<int>, greater<int>> q1;
	ll f = 0;
	rep(i, N) q1.push(a[i]), f += a[i];
	memof.pb(f);
	reps(i, N, 2 * N){
		q1.push(a[i]);
		int mi = q1.top(); q1.pop();
		f = f - mi + a[i];
		memof.pb(f);
	}
	priority_queue<int> q2;
	ll b = 0;
	reps(i, 2 * N, 3 * N) q2.push(a[i]), b += a[i];
	memob.pb(b);
	for (int i = 2 * N - 1; i >= N; --i){
		q2.push(a[i]);
		int ma = q2.top(); q2.pop();
		b = b - ma + a[i];
		memob.pb(b);
	}
	reverse(all(memob));

	/*
	rep(i, N + 1)printf("%lld ", memof[i]);
	printf("\n");
	rep(i, N + 1)printf("%lld ", memob[i]);
	printf("\n");
	*/
	
	ll ans = -INFF;
	rep(i, N + 1) chmax(ans, memof[i] - memob[i]);
	printf("%lld\n", ans);
	return 0;
}

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

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int main(void)
{
	ll N,M;
	cin>>N>>M;
	ll a,b;
	static vector<ll> loads(N+5);
	rep(i,M){
		cin>>a>>b;
		loads[a]++;
		loads[b]++;
	}
	rep(i,N){
		cout<<loads[i+1]<<endl;
	}
}

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

int main()
{
	int n;
	cin >> n;
	double temp = 0;
	for (int i = 0; i < n; i++) {
		double a_in;
		cin >> a_in;
		temp += 1 / a_in;
	}

	cout << setprecision(10) << 1 / temp << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;

const ll INF = 1e18;
const int MAXN = (int)1e5;

vector<pair<int, int>> g[MAXN + 1];
int sz[MAXN + 1];

void dfs(int nod, int par) {
	sz[nod] = 1;
	for(auto it : g[nod]) {
		if(it.first != par) {
			dfs(it.first, nod);
			sz[nod] += sz[it.first];
		}
	}
}

ll dst[MAXN + 1];

void dfs1(int nod, int par) {
	sz[nod] = 1;
	for(auto it : g[nod]) {
		if(it.first != par) {
			dst[it.first] = dst[nod] + it.second;
			dfs1(it.first, nod);
			sz[nod] += sz[it.first];
		}
	}
}

int main() {
#ifdef HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

  	cin >> n;
  	for(i = 1; i < n; i++) {
  		int a, b, c; cin >> a >> b >> c;
  		g[a].push_back({b, c});
  		g[b].push_back({a, c});
  	}

  	dfs(1, 0);

  	int root = 1, mx;
  	while(true) {
  		mx = n - sz[root];
  		for(auto it : g[root]) {
  			if(sz[it.first] < sz[root]) {
  				mx = max(mx, sz[it.first]);
  			}
  		}
  		if(mx <= n / 2) {
  			break;
  		}
  		root++;
  	}

  	dfs1(root, 0);

  	if(mx < (n + 1) / 2) {
  		ll ans = 0, mn = INF;
  		for(i = 1; i <= n; i++) {
  			ans += dst[i];
  			if(i != root) {
  				mn = min(mn, dst[i]);
  			}
  		}
  		cout << 2 * ans - mn;
  		return 0;
  	}

  	ll sum = 0;
  	for(i = 1; i <= n; i++) {
  		sum += dst[i];
  	}
  	ll ans = 2 * sum;
  	for(auto it : g[root]) {
  		if(sz[it.first] == (n + 1) / 2) {
  			ans -= dst[it.first];
  			break;
  		}
  	}

  	cout << ans;

    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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

class UnionFind {
  std::vector<int> p;
  vector<int> s;

public:
  UnionFind(int n) : p(n, -1), s(n,1) {}

  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

  int size(int x) { return s[root(x)];}

  bool same(int x, int y) { return root(x) == root(y); }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) std::swap(x, y);
    s[x] = size(x) + size(y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;

    return true;
  }
};

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m), b(m), ans(m);
    
    for(int i = 0; i < m; i++)
    {
        cin>>a[m-i-1]>>b[m-i-1];
    }
    for(int i = 0; i < m; i++)
    {
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    ans[0]=n*(n-1)/2;
    for(int i = 0; i < m-1; i++)
    {
        
        if(uf.same(a[i],b[i]))
        {
            ans[i+1]=ans[i];
        }
        
        else
        {
            ans[i+1]=ans[i]-uf.size(a[i])*uf.size(b[i]);
            uf.unite(a[i],b[i]);
        }
        
    }
    

    for(int i = m - 1; i >= 0; i--)
    {
        cout<<ans[i]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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






int main() {

	ll N;
	cin >> N;

	vector<ll> a(3 * N + 1);
	repn(i,3*N)cin >> a[i];

	vector<ll> g(3 * N + 2), l(3 * N + 2);

	priority_queue<ll,vector<ll>,greater<ll>> p;

	g[0] = 0;
	repn(i, N) {
		g[i] = g[i - 1] + a[i];
		p.push(a[i]);
	}

	for (ll i = N + 1; i <= 2 * N; i++) {
		ll x = p.top();
		p.pop();
		p.push(max(a[i], x));
		g[i] = g[i - 1] - x + max(a[i], x);
	}

	priority_queue<ll> q;

	l[3 * N + 1] = 0;
	for (ll i = 3 * N; i > 2 * N; i--) {
		l[i] = l[i + 1] + a[i];
		q.push(a[i]);
	}

	for (ll i = 2 * N; i >= N; i--) {
		ll x = q.top();
		q.pop();
		q.push(min(a[i], x));
		l[i] = l[i + 1] - x + min(x, a[i]);
	}

	ll ans = -INF;

	for (ll i = N; i <= 2 * N; i++) {
		ans = max(ans, g[i] - l[i + 1]);
	}
	
	cout << ans;
	system("PAUSE");
}


Measured memory_bytes: 9588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0.0;
  for (int i = 1; i <= n; ++i) {
    ll val = i;
    ll pw = 1;
    while (val < k) {
      val *= 2;
      pw *= 2;
    }
    ans += (1.0 / pw);
  }
  printf("%.10f\n", ans / n);
  return 0;
}

Measured memory_bytes: 3696
#include <iostream>

using namespace std;

#define MAX_L 100
int square[MAX_L][MAX_L];
int r, c;

int counts[MAX_L * MAX_L];
int n;
void fillColor();

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> r >> c >> n;
    int i;
    for(i = 0; i < n; ++i){
        cin >> counts[i];
    }
    fillColor();
    int j;
    for(i = 0; i < r; ++i){
        for(j = 0; j < c; ++j){
            cout << square[i][j] << ' ';
        }
        cout << '\n';
    }
    return 0;
}

void fillColor(){
    int x, y;
    int i = 0;
    for(x = 0; x < r; ++x){
        if((x & 1) == 0){
            for(y = 0; y < c; ++y){
                square[x][y] = i + 1;
                if(--counts[i] <= 0){
                    ++i;
                }
            }
        }
        else{
            for(y = c - 1; y >= 0; --y){
                square[x][y] = i + 1;
                if(--counts[i] <= 0){
                    ++i;
                }
            }
        }
    }
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

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

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << (T / A) * B << endl;
}




Measured memory_bytes: 256
n,k = map(int,input().split())
MOD = 10 ** 9 + 7
    
def pk(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % MOD
        x = x ** 2 % MOD
        n //= 2
    return K * x % MOD

a = n-k+1
aa = n-k
red = []
red.append(a)
for i in range(k-1):
    a = (a * (aa-i) * pk(i+2,MOD-2)) % MOD
    red.append(a)
    
b = 1
blue = []
blue.append(b)
for i in range(1,k):
    b = (b * (k-i) * pk(i,MOD-2)) % MOD
    blue.append(b)
    
for i in range(k):
    print(red[i] * blue[i] % MOD)

Measured memory_bytes: 44528
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
 
int main(){
    int n;
    int pt[1000];
    double s, s2, sum, avg;
     
     
    while(1){
        s = s2 = avg = sum = 0;
         
        cin >> n;
         
        if(n == 0) break;
         
        for(int i=0; i<n; i++){
            cin >> pt[i];
            sum += pt[i];
        }
         
        avg = sum / n;
         
        for(int i=0; i<n; i++){
            s2 += (pt[i]-avg)*(pt[i]-avg)/(double)n;
        }
         
        s = sqrt(s2); 
        printf("%f\n",s);
    }
    return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define  my_max 200000+20
typedef long long ll;
using namespace std;

ll num[my_max]={0},n,num2[my_max]={0};
struct node {
	ll mid,sum_l,sum_r,value;
}q[my_max],h[my_max];
void init()
{
	q[1].mid=0;
	q[1].sum_l=num[0];
	q[1].sum_r=num[1];
	q[1].value=abs(q[1].sum_l-q[1].sum_r);
	h[1].mid=0;
	h[1].sum_l=num2[0];
	h[1].sum_r=num2[1];
	h[1].value=abs(h[1].sum_l-h[1].sum_r);
}
void my_find(ll k)
{
	ll l,r,m;
	l=q[k-1].sum_l; r=q[k-1].sum_r+num[k]; m=q[k-1].mid; 
	for(ll i=m+1;i<n;i++)
	{
		ll tmp=abs(l-r);
		l+=num[i]; r-=num[i];
		if(abs(l-r)>tmp)
		{
			q[k].value=tmp;
			q[k].sum_l=l-num[i];
			q[k].sum_r=r+num[i];
			q[k].mid=i-1;
			return ;
		}
	}
}
void my_find2(ll k)
{
	ll l,r,m;
	l=h[k-1].sum_l; r=h[k-1].sum_r+num2[k]; m=h[k-1].mid; 
	for(ll i=m+1;i<n;i++)
	{
		ll tmp=abs(l-r);
		l+=num2[i]; r-=num2[i];
		if(abs(l-r)>tmp)
		{
			h[k].value=tmp;
			h[k].sum_l=l-num2[i];
			h[k].sum_r=r+num2[i];
			h[k].mid=i-1;
			return ;
		}
	}
}
int main ()
{
	ll i,j;
	cin>>n;
	for(i=0;i<n;i++)
		scanf("%lld",&num[i]),num2[n-1-i]=num[i];
	init();
	for(i=2;i<n;i++)
	{
		my_find(i);
		my_find2(i);
	}
	ll ans;
	i=1;
	ans=max(max(q[i].sum_l,q[i].sum_r),max(h[n-i-2].sum_l,h[n-i-2].sum_r))-min(min(q[i].sum_l,q[i].sum_r),min(h[n-i-2].sum_l,h[n-i-2].sum_r));
	for(i=2;i<n-2;i++)
		ans=min(ans,max(max(q[i].sum_l,q[i].sum_r),max(h[n-i-2].sum_l,h[n-i-2].sum_r))-min(min(q[i].sum_l,q[i].sum_r),min(h[n-i-2].sum_l,h[n-i-2].sum_r)));
	cout<<ans<<endl;
} 

Measured memory_bytes: 15872
import sys
N , K = list(map(int, input().split()))
As = list(map(int, input().split()))
As = [0]+As
Came = [-1]*(N+1)

s = 1
i = 0

while True:
    if As[s] == s:
        print(s)
        sys.exit()
    elif i >=K:
        print(s)
        sys.exit()
    elif Came[s]>=0:
        break
    Came[s] = i
    i+=1
    s = As[s]
#print(Came , s)
T = i - Came[s]

L = K - Came[s]

Q = L % T
#print(T , L  , Q)
print(Came.index(Came[s]+Q))


Measured memory_bytes: 100160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b;
    int asize = a.size();
    int bsize = b.size();
    REP(i, bsize){
        c.push_back(a[i]);
        c.push_back(b[i]);
    }

    if((asize - bsize) == 1){
        c.push_back(a[a.size()-1]);
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
	string a,b;
	int c,d,e,f=0;
	cin>>a>>c;
	for (d=0;d<c;d++)
	{
		cin>>b;
		b+=b;
		e=b.find(a);
	
		if (e>=0)
		{
			f++;
		}
	}
	cout<<f<<endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
  char c[2][3];
  REP(i,2){
    REP(j,3){
      cin>>c[i][j];
    }
  }
  if (c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0])
  {
    /* code */
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  
  }

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, k, x);
  int maxi = min(1000000, x + (k - 1));
  int mini = max(-1000000, x - (k - 1));
  for (int i = mini; i <= maxi; ++i) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3548
<?php
$s = trim(fgets(STDIN));
$n = strlen($s) - 3;
$ans = abs(753 - substr($s,0,3));
$i = 1;
while($i<=$n){
	$c = abs(753 - substr($s,$i,3));
	$ans = min($ans,$c);
	++$i;
}
echo $ans;

Measured memory_bytes: 4856
h1, m1, h2, m2, k = map(int, input().split())
h1 = h1 * 60 + m1
h2 = h2 * 60 + m2
if (h1 > h2):
    h2 += 24 * 60
print(max(0, h2 - h1 - k))


Measured memory_bytes: 9160
#define     ll      long long int
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ll j,k,n,i,l,counter=0;
    cin >> n;
    vector<ll>v;
    for(i=0;i<n;i++)
    {
        cin >> k;
        v.push_back(k);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        for(j=i+1;j<v.size();j++)
        {
            for(k=j+1;k<v.size();k++)
            {
                if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[j]!=v[k])
                {
                    counter++;
                }
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  int k; cin >> k;
  string s; cin >> s;
  if(s.size() <= k) cout << s << endl;
  else{
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3628
using System;

namespace ITP1_8_D
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string p = Console.ReadLine();

			for(int start = 0; start < s.Length; start++) {
				// 先頭文字探す
				if(s[start] == p[0]) {
					// 2文字目以降の判定
					bool isMatch = true;
					int i = start;
					int j = 0;
					while(j < p.Length) {
						if(s[i] != p[j]) {
							isMatch = false;
							break;
						}

						if(++i == s.Length) {
							i = 0;
						}
						j++;
					}
					if(isMatch) {
						Console.WriteLine("Yes");
						return;
					}
				}
			}

			Console.WriteLine("No");
		}
	}
}



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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int x[N], y[N], a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i] >> a[i];
    }

    int ox = 0, oy = 0;

    int res = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i] == 1)
        {
            if (x[i] > W)
            {
                res = 0;
                break;
            }
            if (x[i] < ox)
            {
                continue;
            }
            ox = x[i];
        }
        if (a[i] == 2)
        {
            if (x[i] > W)
            {
                continue;
            }
            if (x[i] < ox)
            {
                res = 0;
                break;
            }
            W = x[i];
        }
        if (a[i] == 3)
        {
            if (y[i] > H)
            {
                res = 0;
                break;
            }
            if (y[i] < oy)
            {
                continue;
            }
            oy = y[i];
        }
        if (a[i] == 4)
        {
            if (y[i] > H)
            {
                continue;
            }
            if (y[i] < oy)
            {
                res = 0;
                break;
            }
            H = y[i];
        }
        res = (W - ox) * (H - oy);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#############################################################################
# -*- coding: utf-8 -*-
nums = list(map(int, input().split()))
a = nums[0]
b = nums[1]
c = nums[2]
count_a = nums.count(a)
count_b = nums.count(b)
count_c = nums.count(c)

list = [count_a, count_b, count_c]
ans = 4 - max(list)
print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, M;
    cin >> N >> M;

    vector<int> H(N);
    vector<bool> bad(N);

    rep(i, N) cin >> H[i];
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        --A; --B;
        if (H[A] <= H[B]) bad[A] = true;
        if (H[B] <= H[A]) bad[B] = true;
    }

    int ans = 0;
    rep(i, N) {
        if (!bad[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

if A%3 and B%3 and (A+B)%3:
  print("Impossible")
else:
  print("Possible")

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

#define ll long long

const ll inf = 10000000000000000;

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

	vector<int> wt(n);
	vector<ll> val(n);

	for(int i = 0;i < n;i++) cin >> wt[i] >> val[i];

	int sum = 0;
	for(int i = 0;i < n;i++){
		sum += val[i];
	}

	//cout << sum << endl;
	vector<ll> dp(sum+1, inf);

	dp[0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = sum-val[i]; j >= 0;j--){
			dp[j+val[i]] = min(dp[j]+wt[i], dp[j+val[i]]);
		}
	}

	for(int i = sum;i >= 0;i--){
		if(dp[i] <= W){
			printf("%d\n", i);
			break;
		}
	}

}

Measured memory_bytes: 1024
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    
    let odd  = 0;
    let even = 0;
    
    for(let i=1; i<=N; i++) {
        if(i % 2 === 0) {
            even++;
        } else {
            odd++;
        }
    }
    
    console.log(N % 2 === 0 ? even / N : odd / N);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import sys
def solver1( m , h, w):
    for k, v in m.items():
        if v%2 == 1:
            m[k] = m[k] - 1
            break
    _2kcount = (h-1)/2 + (w-1)/2
    _4kcount = ((h-1)/2) * ((w-1)/2 )
    for k, v in m.items():
        if v%4 == 2:
            _2kcount -= 1
            m[k] = m[k] - 2
        elif v%4 != 0:
            return 'No'
    if _2kcount < 0:
        return 'No'
    if _2kcount %2 != 0:
        return 'No'
    return 'Yes'
    #we don't need to care about 4k case because the total amount of material is fix.
def solver2( m, h, w):
    oddc = h if h%2 == 1 else w
    evenc = w if w%2 == 0 else h
    _2kcount = evenc/2
    for k, v in m.items():
        if v%4 == 2:
            _2kcount -= 1
            m[k] = m[k] - 2
        elif v%4 != 0:
            return 'No'
    if _2kcount < 0:
        return 'No'
    if _2kcount %2 != 0:
        return 'No'
    return 'Yes'

H,W = map(int, sys.stdin.readline().strip().split())

matrix = []
materials = {}
for _ in xrange(H):
    line = sys.stdin.readline().strip()
    for a in line:
        materials[a] = materials.get(a, 0) + 1

if H%2 == 0 and W%2 == 0:
    for value in materials.values():
        if value % 4 == 0:
            continue
        else:
            print 'No'
            exit(0)
    print 'Yes'
    exit(0)
if H%2 == 1 and W%2 == 1:
    print solver1(materials, H, W)
    exit(0)

print solver2(materials, H, W)
exit(0)


Measured memory_bytes: 2696
from scipy.sparse.csgraph import floyd_warshall
from itertools import chain

H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

d = floyd_warshall(C)

ans = sum(d[a][1] for a in chain(*A) if a != -1)

print(int(ans))

Measured memory_bytes: 17428