akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int a, b;
    cin >> a >> b;

    string s[110];

    string aa = "", ab = "";
    REP(i, 100)
    {
        aa = aa + ".";
        ab = ab + "#";
    }

    for (int i = 0; i < 50; i++)
    {
        s[i] = ab;
    }
    for (int i = 50; i < 100; i++)
    {
        s[i] = aa;
    }

    a--;
    b--;

    for (int i = 0; i < 49; i += 2)
    {
        if (!a)
            continue;

        for (int j = 0; j < 100; j += 2)
        {
            if (!a)
                continue;

            s[i][j] = '.';
            a--;
        }
    }

    for (int i = 51; i < 100; i += 2)
    {
        if (!b)
            continue;

        for (int j = 0; j < 100; j += 2)
        {
            if (!b)
                continue;

            s[i][j] = '#';
            b--;
        }
    }

    cout << "100 100" << endl;

    REP(i, 100)
    cout << s[i] << endl;

    return 0;
}

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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

map<ll,ll> m;
ll n,a,b,c,d;

ll fun(ll x){
    if(m.count(x)){
        return m[x];
    }
    if(!x){
        return m[x]=0LL;
    }
    m[x]=LLONG_MAX;
    if(LLONG_MAX/d>=x){
        m[x]=x*d;
    }
    m[x]=min(m[x],fun(x/2)+a+d*(x%2));
    if(x%2){
        m[x]=min(m[x],fun(x/2+1)+a+d*(2-x%2));
    }
    m[x]=min(m[x],fun(x/3)+b+d*(x%3));
    if(x%3){
        m[x]=min(m[x],fun(x/3+1)+b+d*(3-x%3));
    }
    m[x]=min(m[x],fun(x/5)+c+d*(x%5));
    if(x%5){
        m[x]=min(m[x],fun(x/5+1)+c+d*(5-x%5));
    }
    return m[x];
}

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 ll t=1;
 cin>>t;
 while(t--)
 {cin>>n>>a>>b>>c>>d;
  m.clear();
  cout<<fun(n)<<endl;
 }
 return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
} 
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n;
    cin>>n; 
    ll x=-200;
    ll aa,bb;
    while(x<=200){
      ll y=-200,fl=1;
      while(y<=200){
        ll ans=pow(x,5)-pow(y,5);
        if(ans==n){
          aa=x,bb=y;
          fl=0;
          break; 
        }
        y++;
      }
      if(fl==0){
        break; 
      }
      x++;
    }
    cout<<aa<<" "<<bb<<endl; 
    //printclock;
    return 0;
}
    

Measured memory_bytes: 4080
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int A, B;

int main() {
	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;
}

/*
4 3 1 2
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int n,k;
	cin>>n>>k;
	int v[n];
	int t[n]={};
	rep(i,n)cin>>v[i];
	int res=0;
	for(int i=0;i<=k;++i){
		for(int j=0;j<=k-i;++j){
			if(i+j<=n){
				vector<int> vec;
				rep(i1,i)vec.push_back(v[i1]);
				rep(j1,j)vec.push_back(v[n-j1-1]);
				sort(vec.begin(),vec.end());
				int total=0;
				rep(i1,i+j)total+=vec[i1];
				int r=total;
				for(int x=0;x<min(k-i-j,i+j);++x){
					total-=vec[x];
					r=max(r,total);
				}
				res=max(res,r);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	n--;
	for(int i=n;i>=0;i--)
	{
		if((b<=a+(i*d)-(n-i)*c)&&(b>=a+(i*c)-(n-i)*d))
		{
			cout<<"YES\n";
			return 0;
		}
	}
	cout<<"NO\n";
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	cin>>n;
	rep(i, 9){
		if(n%(i+1)==0&&n/(i+1) <= 9){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i;
    long long int X,K,D;
    scanf("%lld %lld %lld",&X,&K,&D);

    if(llabs(X) / D < K){
        K -= (X/D);
        X %= D;

        if(K%2 == 1){
            if(X >= 0){
                X -= D;
            }else{
                X += D;
            }
        }
    }else{
        if(X >= 0){
            X -= (K * D);
        }else{
            X += (K * D);
        }
    }

    printf("%lld\n",llabs(X));

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  rep(i, n) {
    cin >> w[i];
  }
  set<string> st;
  st.insert(w[0]);
  bool ok = true;
  for (int i = 1; i < n; i++) {
    string s = w[i - 1];
    string t = w[i];
    if (t.at(0) != s.at(s.size() - 1)) {
      ok = false;
    }
    if (st.count(t)) {
      ok = false;
    }
    st.insert(t);
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <utility>



void fastio(){std::ios_base::sync_with_stdio(false);std::cin.tie(0);}

using std::string;using std::cin;using std::cout;using std::vector;using std::map;using std::set;using std::pair;using std::max;using std::min;

template<class T> int sz(T x){return (int)x.size();};

using ll=long long;

#define f first
#define s second

int main(){
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }


    vector<ll> dp(W+1, 0);
    dp[0]=0;
    for(int i = 0; i < n; i++) {
        for(int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << "\n";
    return 0;
}



Measured memory_bytes: 4036
import bisect as bs

n,m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = sum(a)

count = 0

for i in range(len(a)):
  if a[i]*m*4 >= s:
    count += 1
  else:
    break

if count >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL<<60;
const int maxN = 15;
const int maxW = 110000;

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

    vi money;
    for(int i = 1; i <= w; i *= 6) money.push_back(i);
    for(int i = 9; i <= w; i *= 9) money.push_back(i);
    int n = (int)money.size();

    vector<vector<int>> dp(maxN, vector<int>(maxW, 110000));
    rep(i, n+1) dp[i][0] = 0;

    
    rep(i, n) {
        rep(j, w+1) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j >= money[i]) dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-money[i]] + 1);
        }
    }

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

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n,m;
int minc[111][111],maxc[111][111];
bool es[111][111];
bool used[111];

int main(){
	cin.sync_with_stdio(false);
  cin>>m>>n;
  rep(i,m)rep(j,n){
    minc[i][j]=0;
    maxc[i][j]=INF;
  }
  rep(i,m){
    int k;
    cin>>k;
    rep(hoge,k){
      int s,t;
      string cond;
      cin>>s>>cond>>t;
      s--;
      if(cond=="<="){
        minch(maxc[i][s],t);
        //dbg(maxc[i][s]);
      }else{
        maxch(minc[i][s],t);
        //dbg(minc[i][s]);
      }
    }
  }
  rep(i,m)rep(j,n){
    if(maxc[i][j]<minc[i][j]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,m)rep(j,m){
    if(i==j)continue;
    bool ok=true;
    rep(k,n){
      if(minc[i][k]>maxc[j][k]){
        ok=false;
      }
    }
    if(ok)es[i][j]=true;
  }
  //rep(i,m)rep(j,m)dbg(es[i][j]);
  rep(hoge,m){
    rep(i,m){
      if(used[i])continue;
      bool ok=true;
      rep(j,m){
        if(i==j||used[j])continue;
        if(!es[i][j])ok=false;
      }
      if(ok)used[i]=true;
    }
  }
  rep(i,m){
    if(!used[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), n = sc.nextInt(), c[] = new int[n], a[] = new int[m + 1];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.fill(a, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= m / c[i]; j++) {
                    a[c[i] * j] =Math.min(a[c[i]*j], j);
            }
        }
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= m - i; j++) {
                    a[i + j] = Math.min(a[i + j] , a[i] + a[j]);
            }
        }
        System.out.println(a[m]);
    }
}


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

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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if(a == b)
  {
    cout << "YES" << endl;
    return 0;
  }
  if(w >= v)
  {
    cout << "NO" << endl;
    return 0;
  }

  if (abs(a - b) <= t * abs(w - v))
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3664
N = int(input())
S = input()
count = 0
for i in range(0,1000):
  if i >= 100:
    t = str(i)
  elif i >= 10:
    t = "0"+str(i)
  else:
    t = "00"+str(i)
  ti = 0
  for j in range(N):
    if S[j] == t[ti]:
      ti += 1
      if ti == 3:
        count += 1
        break
print(count)

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

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


#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};


int main()
{
    ll h,n,a=0;
    cin>>h>>n;
    for (ll i = 0; i < n; i++)
    {
        int aa;
        cin>>aa;
        a+=aa;
    }
    if(h<=a)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+50;
int n,k;
int a[maxn];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=k+1;i<=n;++i)
    {
        if(a[i]>a[i-k]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

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

// ----------- define --------------
#define int long long
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void MAIN() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int t = abs(x - a[0]);
  for (int i = 1; i < n; i++) {
    t = __gcd(t, abs(x - a[i]));
  }
  cout << t << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 4000
n,m = map(int,input().split())
cost = []
key = []
inf = int(1e9)
for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    cost.append(a)
    cnt = 0
    for j in range(1,n+1):
        if j in c:
           cnt += 2**(n-j)
    key.append(bin(cnt))
dp = [inf]*(2**n)
for i in range(m):
    dp[int(key[i],0)] = min(cost[i],dp[int(key[i],0)])
for i in range(2**n):
    if dp[i] != inf:
        for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j])
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])





Measured memory_bytes: 46808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    if (H%h==0&&W%w==0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int x=-1-(h*w-2+26000);
    rep(i,H){
        rep(j,W){
            if (i%h==0&&j%w==0) cout << 26000;
            else if (i%h==h-1&&j%w==w-1) cout << x;
            else cout << 1;
            if (j!=W-1) cout << ' ';
            else cout << endl;
        }
    }
}

Measured memory_bytes: 1792
s=input()
q=int(input())
cnt1=0
s_mae=[]
s_ushiro=[]
for i in range(q):
    query=list(input().split())
    if int(query[0])==1:
        cnt1+=1
    else:
        if (int(query[1])+cnt1)%2==0:
            s_ushiro.append(query[2])
        else:
            s_mae.append(query[2])
s1=""
for i in range(len(s_mae)):
    s1=s1+s_mae[-1-i]
s2="".join(s_ushiro)
ans=s1+s+s2
if cnt1%2==0:
    print(ans)
else:
    ans2=""
    for i in range(len(ans)):
        ans2=ans2+ans[-1-i]
    print(ans2)


Measured memory_bytes: 5968
#include<cstdio>
#include<cstring>
int n,m;
char s1[503][503],s2[503][503];
int main()
{
	scanf(" %d %d",&n,&m);
	for(int i=1;i<=n;++i)scanf(" %s",s1[i]+1),memcpy(s2[i],s1[i],sizeof(s1[i]));
	for(int i=1;i<=n;++i)for(int j=2;j<m;++j)i[(i&1)?s1:s2][j]='#';
	for(int i=1;i<=n;++i)s1[i][1]=s2[i][m]='#';
	for(int i=1;i<=n;++i)printf("%s\n",s1[i]+1);
	printf("\n");
	for(int i=1;i<=n;++i)printf("%s\n",s2[i]+1);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
ll a[10001];

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

ll cnt2(ll x){
    ll cnt = 0;
    while(x%2==0){
        cnt++;
        x /= 2;
    }
    return cnt;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll sum = 0;
    for(int i=0;i<n;i++) sum += cnt2(a[i]);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false) cin.tie(NULL) cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define f first 
#define s second
#define int long long
using namespace std;

const int nax=2e5+5;
vector<int>adj[nax];
const int mod=1e9+7;
const int inf=1e18+7;
double a[nax];
double b[nax];


double p[nax];

signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>a[i];
		b[i]=a[i];
	}
	for(int i=0; i<n; i++){
		a[i]=a[i]*(a[i]+1)/2;
		a[i] /= b[i];
	}
	double ans = 0;
	for(int i=0; i<n; i++){
		if(i==0) p[i+1]=a[i];
		else{
			p[i+1]=a[i]+p[i];
		}
	}
	for(int i=k; i<=n; i++){
		ans = max(ans, p[i]-p[i-k]);
	//	cout<<" 2 "<<ans <<endl;
	}
	cout<<setprecision(9)<<ans<<endl;
	return 0;
}



Measured memory_bytes: 9600
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if (a < b && b < c && a < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26104
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M;

int main () {
int P[100000],Y[100000]; vector<int> yd[100001];    scanf("%d%d",&N,&M); rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
    rep(i,N)sort(yd[i+1].begin(),yd[i+1].end());
    rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}


Measured memory_bytes: 7680
#include <stdio.h>

int main()
{
    int v[10000];
    int i = 0, j = 0;

    do
    {
         scanf("%d", &v[i]);
         i++;
    }while(v[i - 1] != 0);

    while(j < i -1)
    {
        printf("Case %d: %d\n", j + 1, v[j]);
        j++;
    }

    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

	int n;
	scanf("%d", &n);
	int k = 0;
	while((1 << k) < n) k++;
	if ((1 << k) == n) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for (int x = 2; x + 1 <= n; x += 2) {
		printf("%d %d\n", x, x + 1);
		printf("%d 1\n", x + 1);
		printf("1 %d\n", n + x);
		printf("%d %d\n", n + x, n + x + 1);
	}
	printf("%d 2\n", n + 1);
	if (n % 2 == 0) {
		k--;
		printf("%d %d\n", n + (1 << k), n);
		printf("%d %d\n", (n - (1 << k)) + 1, 2 * n);
	}

	return 0;
}


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


int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll k;
  ll x=(a-1)/c,y=(b)/c;
  k=y-x;
  //cout<<k<<endl;
  x=(a-1)/d,y=(b)/d;
  k+=y-x;
  //cout<<k<<endl;
  ll lcm=(c*d)/__gcd(c,d);
  x=(a-1)/lcm,y=(b)/lcm;
  k-=y-x;
  cout<<b-a+1-k;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pc __builtin_popcountll

using namespace std;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

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

int main(){
    int D, G; cin >> D >> G;
    vector<int> n_problem;
    vector<int> bonus;
    for(int i=0; i<D; i++){
        int p, c; cin >> p >> c;
        n_problem.push_back(p);
        bonus.push_back(c);
    }

    int ans = INT_MAX;
    for(int bit =0; bit < (1<<D); ++bit){
        int s = 0, num = 0, rest_max = -1;
        for(int i=0; i < D; i++){
            if(bit >> i & 1){
                s += 100 * (i+1) * n_problem[i] + bonus[i];
                num += n_problem[i];
            } else {
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= n_problem[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << EOL;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<ll> a(n);
  int negative = 0;
  int zero = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i]<0) {
      negative++;
    } else if (a[i] == 0) {
      zero++;
    }
  }

  if (zero > 0 || negative%2 == 0) {
    ll ans = 0;
    rep(i, n) {
      ans += abs(a[i]);
    }
    cout << ans << endl;
    return 0;
  }

  ll minabs = INT_MAX;
  ll ans = 0;
  rep(i, n) {
    chmin(minabs, abs(a[i]));
    ans += abs(a[i]);
  }
  ans -= minabs*2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

using namespace std;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    int left = 0, right = 0;
    for (int i = 0; i < M; ++i)
    {
        int Ai;
        cin >> Ai;
        if (Ai < X) ++left;
        else ++right;
    }
    cout << min(left, right) << endl;
    return 0;
}

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

signed main(){
int n;cin>>n;
if(n==0)puts("0");
else{
string ans;
for(int i=0;i<100;i++){
if(n==0)break;
if((1<<i)&abs(n)){
n-=pow(-2,i);
ans+="1";
}
  else ans+="0";
}
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}
}

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


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            
            int n = sc.nextInt();
            int h[] = new int[n + 1];
            int dp[] = new int[n + 1];
            for(int i = 1; i <= n; i++) h[i] = sc.nextInt();
            dp[0] = 2000000000;
            for(int i = 2; i <= n; i++)
                dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
            out.println(dp[n]);
        }
        //for(int i = 1; i <= n; i++) System.out.println(Arrays.toString(dp[i]));
        out.close();

        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String

        int result = 3*n;
        out.println(result);                    // print via PrintWriter
        */
        // Stop writing your solution here. -------------------------------------
        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 32576
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


H,W,A,B = MI()
for _ in range(B):
    print(''.join(['0']*A+['1']*(W-A)))
for _ in range(H-B):
    print(''.join(['1']*A+['0']*(W-A)))


Measured memory_bytes: 68008
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>

template <typename T>
constexpr T abs(const T& x)
{
    return x > 0 ? x : -x;
}

template <typename T>
constexpr T max(const T& x, const T& y)
{
    return x > y ? x : y;
}

template <typename T>
constexpr T min(const T& x, const T& y)
{
    return x < y ? x : y;
}

long double a[110];

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

    int n = 0;
    long double ans = 0;
    
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
        std::cin >> a[i], ans += (long double)1 / a[i];

    printf("%.6Lf\n", (long double)1 / ans);

    return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
L = sorted([int(_) for _ in input().split()])
#L[a] + L[b] > L[c]
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        ans += bisect.bisect(L, L[a] + L[b] - 1) - b - 1
print(ans)


Measured memory_bytes: 3316
PN = [i for i in range(55556)]

PN[0] = 0
PN[1] = 0
for i in range(2, 55556):
    j = i * 2
    while True:
        if PN[i] == 0:
            break
        if j >= len(PN):
            break
        PN[j] = 0
        j += i


N = int(input())
cnt = 0
for i in range(len(PN)):
    if cnt == N:
        break
    if PN[i] % 5 == 1:
        cnt += 1
        if cnt < N:
            print(i, end = " ")
        else:
            print(i)
            break


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

int main() {
    int N;
    cin >> N;
    int x[8];
    int y[8];
    for (int i=0;i<N;i++) {
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    for (int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
            ans += sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
        }
    }
    cout << fixed;
    cout << setprecision(7) << 2.0  * ans / (double)N << endl;
    return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if(A == B && B == C)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

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

    int ans = 0;
    REP( i, N ){
        while( i + 1 < N && s[i] == s[i + 1] ) i++;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		String S = sc.next();

		char[] s = S.toCharArray();

		for(int i=0;i<S.length();i++) {
			if(i==K-1) {
				s[i] = Character.toLowerCase(s[i]);
			}
		}
		S = new String(s);
		System.out.println(S);
	}
}


Measured memory_bytes: 21844
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s = read!(String);
    let c = s.chars().collect::<Vec<char>>();
    let mut ans = 0;
    for cc in c {
        if cc == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N,D = map(int,input().split())
X = []
for i in range(N):
    Xi = list(map(int,input().split()))
    X.append(Xi)
ans = 0
def norm(Xi,Xj):
    return sum([(Xi[i]-Xj[i])**2 for i in range(len(Xi))])
for i in range(N):
    for j in range(i,N):
        if i==j:
            continue
        d = norm(X[i],X[j])
        if int(d**0.5)**2==d:
            ans += 1
print(ans)

Measured memory_bytes: 38512
#include <stdio.h>
#include <vector>

int main(){
	int n;
	scanf("%d",&n);
	std::vector<int> v(n);

	for(int i = 0; i < n; i++) scanf("%d", &v[i]);

	for(int i = n-1; i > 0; i--) printf("%d ", v[i]);
	printf("%d\n", v[0]);
}



Measured memory_bytes: 2756
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

    vector<ll> sum(n);
    sum[0] = a[0];
    for (int i = 0; i < n - 1; i++) {
        sum[i + 1] = sum[i] + a[i + 1];
    }

    ll ans = 2 * 1e9 + 1;
    for (int i = 0; i < n - 1; i++) {
        ans = min(ans, llabs(2 * sum[i] - sum[n - 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.awt.Point;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(new InputStreamReader(System.in));
		
		while (sc.hasNext()) {
			List<StringBuilder> lines = new ArrayList<StringBuilder>();
			while (true) {
				String text = sc.nextLine();
				if (text.equals("END_OF_TEXT"))
					break;
				lines.add(new StringBuilder(text));
			}
			Point cursor = new Point();
			String buffer = null;
			commandLoop: while (true) {
				char command = sc.nextLine().charAt(0);
				StringBuilder currentLine = lines.get(cursor.y);
				switch (command) {
				case 'a':
					cursor.x = 0;
					break;
				case 'e':
					cursor.x = currentLine.length();
					break;
				case 'p':
					if (cursor.y > 0)
						cursor.y--;
					cursor.x = 0;
					break;
				case 'n':
					if (cursor.y + 1 < lines.size())
						cursor.y++;
					cursor.x = 0;
					break;
				case 'f':
					if (cursor.x < currentLine.length()) {
						cursor.x++;
					}
					else if (cursor.y + 1 < lines.size()) {
						cursor.y++;
						cursor.x = 0;
					}
					break;
				case 'b':
					if (cursor.x > 0) {
						cursor.x--;
					}
					else if (cursor.y > 0) {
						cursor.y--;
						cursor.x = lines.get(cursor.y).length();
					}
					break;
				case 'd':
					if (cursor.x < currentLine.length()) {
						currentLine.deleteCharAt(cursor.x);
					}
					else if (cursor.y + 1 < lines.size()) {
						currentLine.append(lines.remove(cursor.y + 1));
					}
					break;
				case 'k':
					if (cursor.x == currentLine.length()) {
						if (cursor.y + 1 < lines.size()) {
							currentLine.append(lines.remove(cursor.y + 1));
							buffer = "\n";
						}
					}
					else {
						buffer = currentLine.substring(cursor.x);
						currentLine.delete(cursor.x, currentLine.length());
					}
					break;
				case 'y':
					if (buffer != null) {
						if (buffer.equals("\n")) {
							StringBuilder newLine = new StringBuilder();
							if (cursor.x != currentLine.length()) {
								newLine.append(currentLine.substring(cursor.x));
								currentLine.delete(cursor.x,
										currentLine.length());

							}
							lines.add(cursor.y + 1, newLine);
							cursor.y++;
							cursor.x = 0;
						}
						else {
							if (cursor.x == currentLine.length()) {
								currentLine.append(buffer);
							}
							else
								currentLine.insert(cursor.x, buffer);
							cursor.x += buffer.length();
						}
					}
					break;

				case '-':
					break commandLoop;
				default:
					break;
				}
				// System.out.println(cursor);
				// System.out.println(currentLine);
				//System.out.println("---");
			}
			for (StringBuilder sb : lines) {
				System.out.println(sb);
			}
		}
	}

}

Measured memory_bytes: 12000
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> list = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int j = 1;
		int Count = N;
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			if(j == x) {
				j++;
				Count--;
			}
		}
		if(Count == N) {
			System.out.println(-1);
		}else{
			System.out.println(Count);
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  int a=n%10;
  int b=(n%100-a)/10;
  int c=(n%1000-10*b-a)/100;
  int d=n/1000;
  //cout << d << c << b << a << endl;
  rep(i,8){
    int sum=d;
    bitset<3> t(i);
    char e,g,f;
    if(t.test(0)){sum+=c;e='+';}
    else{sum-=c;e='-';}
    if(t.test(1)){sum+=b;g='+';}
    else{sum-=b;g='-';}
    if(t.test(2)){sum+=a;f='+';}
    else{sum-=a;f='-';}
    //cout << t << endl;
    if(sum==7){cout << d << e << c << g << b << f << a << "=7" << endl;break;}
  }
}

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

int main(){
    int x, y;
    cin >> x >> y;
    if(x >= 4) x = 0;
    if(y >= 4) y = 0;

    vector<int> prize = {0, 300000, 200000, 100000};
    int ans = prize[x] + prize[y];

    if(x == 1 && y == 1) ans += 400000; 
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    m = m*2+1;
    int ans = n/m;
    if(n%m==0)  cout << ans << endl;
    else    cout << ans+1 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool f[9] , l;
signed main(){
  int a[9],n,b;
  for(int i=0;i<9;i++){
    cin>>a[i];
  }
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    for(int j=0;j<9;j++){
      if(b==a[j]){
        f[j]=true;
      }
    }
  }
  
  if(f[0] && f[1] && f[2]){
    l=true;
  } else if(f[3] && f[4] && f[5]){
    l=true;
  } else if(f[6] && f[7] && f[8]){
    l=1;
  } else if(f[0] && f[3] && f[6]){
    l=1;
  } else if(f[1] && f[4] && f[7]){
    l=1;
  } else if(f[2] && f[5] && f[8]){
    l=1;
  } else if(f[0] && f[4] && f[8]){
    l=1;
  } else if(f[2] && f[4] && f[6]){
    l=1;
  } 
  
  if(l){
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return(0);
}

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

int main() {
	int N; cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int v; cin >> v;
		if (i % 2) a.push_back(v);
		else a.insert(a.begin(), v);
	}
	if (N % 2 == 0) reverse(a.begin(), a.end());
	for (int i = 0; i < N; i++)
		cout << a[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3060
import math
n = int(input())
s = input()
ss = [[(1 << ord(c) - ord('a')) for c in s]]
while len(ss[-1]) > 1:
    r = []
    for i in range(0, len(ss[-1]), 2):
        if i + 1 < len(ss[-1]):
            r.append(ss[-1][i] | ss[-1][i + 1])
        else:
            r.append(ss[-1][i])
    ss.append(r)
#print(ss)

def update(j, v):
    ss[0][j] = v
    for k in range(1, len(ss)):
        j = j // 2
        #print('k=', k, 'j=', j)
        if 2 * j + 1 < len(ss[k - 1]):
            ss[k][j] = ss[k - 1][2 * j] | ss[k - 1][2 * j + 1]
        else:
            ss[k][j] = ss[k - 1][2 * j]
    #print('j=', j, 'v=', v, 'ss=', ss)

def all_or(i, j, k):
    #print('all_or(', i, j, k, ')')
    if i == j:
        return 0
    while True:
        if k == 0:
            return ss[0][i]
        ik, jk = (i >> k), (j >> k)
        #print('i=', i, 'j=', j, 'k=', k, 'ik=', ik, 'jk=', jk)
        if ik != jk:
            break
        k -= 1
    r = 0
    if i == ik << k:
        r = ss[k][ik]
    else:
        r = all_or(i, (ik + 1) << k, k - 1)
    for l in range(ik + 1, jk):
        r |= ss[k][l]
    r |= all_or(jk << k, j, k - 1)
    return r

def popcount(v):
    r = 0
    while v != 0:
        v = (v & (v - 1))
        r += 1
    return r

q = int(input())

for i in range(q):
    cs = [x for x in input().split()]
    cs[0], cs[1] = int(cs[0]), int(cs[1]) - 1
    if cs[0] == 1:
        #print('cs[2]=', cs[2], 'mask=', 1 << (ord(cs[2]) - ord('a')))
        update(cs[1], (1 << (ord(cs[2]) - ord('a'))))
    else:
        #print('all_or(', cs[1], int(cs[2]), ')=',all_or(cs[1], int(cs[2]), len(ss) - 1))
        #r = 0
        #for j in range(cs[1], int(cs[2])):
        #    r |= ss[0][j]
        print(popcount(all_or(cs[1], int(cs[2]), len(ss) - 1)))
        #print(popcount(r))



Measured memory_bytes: 43152
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    var ans = 100000000
    for(i in -100 .. 100){
        var sum = 0
        a.forEach{
            sum += (i - it) * (i - it)
        }
        ans = Math.min(ans, sum)
    }
    println(ans)
}


Measured memory_bytes: 37752