akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi 3.1415926535897
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define sz(v) ((int)(v).size())
#define mod 1000000007
#define MXM (ll)1e18
#define LIM 9223372036854775807
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define RREPA(i,a,n) for(ll i=a;i>=(n);i--)
#define REPA(i,a,n) for(ll i=a;i<=(n);i++)
using namespace std;
 
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
//////
// prime Seive
/*
bitset<1000005> bt;
//unordered_map<ll,bool> is_prime;
vector<ll> primes;
void pS(ll n){
    ll val = min(n+1,(ll)1000006);
    for(ll i=3;i<=val;i+=2){
        bt[i] =true;
    }
    bt[0] =false;
    bt[1] =false;
    bt[2] =false;
    //is_prime[2] =true;
    primes.pb((ll)2);
    for(ll i=3;i<=val;i+=2){
        if(bt[i])
            for(ll j=i*i;j<=val;j+=2*i)
                bt[j] =false;
    }
    for(ll i=3;i<=val;i+=2){
        if(bt[i]){primes.pb(i);
        //is_prime[i]=true;
        //cout<<i<<" :PRIME\n";
        }
    }
    return;
}
   */          
/////
// Fenwick Tree
/*
BIT[200005] ={0};
//BUILD BIT
// for(int i=1;i<1;i++){ cin>>a[i];update(i,a[i],n);};
 
void update(int i,int val,int n){
    while(i<=n){
    BIT[i]+= inc;
    i+= (i&(-i));
    }
}
ll query(int i){
    ll ans =0;
    while(i>0){
        ans+= BIT[i];
        i-=(i&(-i));
    }
    return ans;
}
 
*/
//__builtin_popcount(4)
ll logPow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans*=a;
        }
        a*=a;
        b= b>>1;
    }
    return ans;
}


bool check(ll val,ll ans){
    if(ans==0) return true;
    if(val>(MXM/ans)){
        return false;
    }
    return true;
}


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    */
    int t=1;
    
    //memset(arr,0,sizeof(arr));
    //cin>>t;
    //pS(INT_MAX);
    while(t--){
      ll n;
      cin>>n;
      ll tmp,ans=1;
      bool ch =false;
      int z =0;
      for(int i=0;i<n;i++){
          cin>>tmp;
          if(tmp==0){
              z++;
              ans =0;
          }
          else if(z==0){
          bool test = check(tmp,ans);
          if(test){
              ans*=tmp;
          }
          else{
              ch =true;
              ans*=tmp;
              if(ans==0) ans++;
          }
          }
      }
      if(z){
          cout<<0<<"\n";
      }
      else if(ch ==true || ans>MXM||ans>LIM){
          cout<<-1<<"\n";
      }
      else{
          cout<<(ll)ans<<"\n";
      }
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int a, b;
    int ans = 0;
    cin >> a >> b;

    for (int i = 0; i < 2; i++) {
        if (a < b) {
            ans += b;
            b--;
        }
        else {
            ans += a;
            a--;
        }
    }

    cout << ans << endl;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int A,B,X;cin>>A>>B>>X;
  if(A<=X && X<=A+B)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<string>

int main(){
    std::list<char> lis[3];
    for(int i = 0; i < 3; i++){
        std::string S;
        std::cin >> S;
        for(int j = 0; j < S.size(); j++){
            lis[i].push_back(S[j]);
        }
    }

    int turn = 0;
    while(1){
        if(lis[turn].empty()) break;
        char card = lis[turn].front();
        lis[turn].pop_front();
        if(card == 'a') turn = 0;
        else if(card == 'b') turn = 1;
        else if(card == 'c') turn = 2;
    }

    if(turn == 0) std::cout << "A" << std::endl;
    else if(turn == 1) std::cout << "B" << std::endl;
    else if(turn == 2) std::cout << "C" << std::endl;


    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<long long>A(3 * N);
	for (int i = 0; i < 3 * N; ++i) {
		cin >> A[i];
	}

	//大きいものを入れたい
	vector<long long>Lsum(N + 1);
	priority_queue<long long, vector<long long>, greater<long long> > Lque;
	for (int i = 0; i < N; ++i) {
		Lque.push(A[i]);
		Lsum[0] += A[i];
	}
	for (int i = 0; i < N; ++i) {
		long long x = A[N + i];
		Lsum[i + 1] = Lsum[i];
		long long y = Lque.top();
		if (y < x) {
			Lque.pop();
			Lque.push(x);
			Lsum[i + 1] -= y;
			Lsum[i + 1] += x;
		}
	}

	//小さいものを入れたい
	vector<long long>Rsum(N + 1);
	priority_queue<long long> Rque;
	for (int i = 0; i < N; ++i) {
		Rque.push(A[3 * N - 1 - i]);
		Rsum[N] += A[3 * N - 1 - i];
	}
	for (int i = 0; i < N; ++i) {
		long long x = A[2 * N - 1 -i];
		Rsum[N - 1 - i] = Rsum[N - i];
		long long y = Rque.top(); 
		if (y > x) {
			Rque.pop();
			Rque.push(x);
			Rsum[N - 1 - i] -= y;
			Rsum[N - 1 - i] += x;
		}
	}

	long long ans = -1e18;
	for (int i = 0;i<=N;++i) {
		ans = max(ans ,Lsum[i]-Rsum[i]);
	}
	cout << ans << endl;
	return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 1;
  int N;
  cin >> N;

  if (N >= 2) {
    ans = 2;
  }
  if (N >= 4) {
    ans = 4;
  }
  if (N >= 8) {
    ans = 8;
  }
  if (N >= 16) {
    ans = 16;
  }
  if (N >= 32) {
    ans = 32;
  }
  if (N >= 64) {
    ans = 64;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


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

  ll n;
  cin >> n;
  ll a;
  for (ll i=1;i<=ll(sqrt(n));i++){
    if (n%i==0){
      a = i;
    }
  }
  ll b = n/a;
  cout << a+b-2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int diff = (h2*60+m2)-(h1*60+m1);
    // cout<<diff;
    if((diff-k)>0)
    cout<<diff-k;
    else
    cout<<0;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");


stack<char> getstk(const string &s){
    stack<char> stk;
    for(char c:s){
        
        if(c=='('){
            stk.push(c);
        }else{
            
            if(!stk.empty() && stk.top()=='('){
                stk.pop();
            }else{
                stk.push(c);
            }
        }
        
    }
    return stk;
}

string f(const string &s){
    stack<char> stk=getstk(s);
    string ss="";
    while(!stk.empty()){
        ss+=stk.top();
        stk.pop();
    }
    reverse(all(ss));
    return ss;
}

signed main(){
    FASTER;
    int n;cin>>n;
    vector<string> v(n),opn,cls,mid;
    
    for(string &s:v){
        cin>>s;
        s=f(s);
        if(s=="")continue;
        bool op=1,cl=1;
        for(char c:s)op&=(c=='(');
        for(char c:s)cl&=(c==')');
        if(op)opn.push_back(s);
        if(cl)cls.push_back(s);
        if(!op && !cl)mid.push_back(s);
    }
    
    sort(all(mid),[](const string &a,const string &b){
            int aka=0,bka=0;
            for(const char &c:a){
                if(c=='(')aka++;
                else aka--;
            }
            for(const char &c:b){
                if(c=='(')bka++;
                else bka--;
            }
            return aka>bka;
    });
    
    
    string s="";
    for(string a:opn)s+=a;
    for(string a:mid)s+=a;
    for(string a:cls)s+=a;
    
    if(getstk(s).empty())cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 68508
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
string s;
int main()
{
	cin>>s;
	int n=s.length();
	for(int i=1;i<=n;i++){
		cout<<"x";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

move [a,b,c,d,e,f] o
	| o == 'E' = [d,b,a,f,e,c]
	| o == 'N' = [b,f,c,d,a,e]
	| o == 'S' = [e,a,c,d,f,b]
	| o == 'W' = [c,b,f,a,e,d]

allDicePattern dice = f dice (take 24 $ cycle "EEENNWWS")
	where
		f _ [] = []
		f dice (x:xs) = dice : f (move dice x) xs

main = do
	dice <- words <$> getLine
	dice2 <- words <$> getLine
	putStrLn $ if dice2 `elem` allDicePattern dice then "Yes" else "No"

Measured memory_bytes: 3556
#include<stdio.h>
#include<string.h>
int main()
{
    char s[101];
    int i,j,c=0;
    scanf("%s",s);
    j=strlen(s);
    for(i=0;i<j;i++)
    {
        if(s[i]!=s[j-i-1])
        c++;

    }
    printf("%d",c/2);
    return 0;
}


Measured memory_bytes: 128
// AOJ 1040 Chocolate with Heart Marks
// 2018.2.6 bal4u
 
#include <stdio.h>
#include <string.h>

#define INF 0x03030303
int s[10], sz;
int g[200][200];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int d[200][200];
int b[1024][200];
int minimumSteinerTree(int *s, int sz, int g[200][200], int gsz)
{
	int i, j, k, t, lim, ans;

    if (sz <= 1) return 0;

	memcpy(d, g, sizeof(d));
	for (k = 0; k < gsz; k++) for (i = 0; i < gsz; i++) for (j = 0; j < gsz; j++) {
		t = d[i][k] + d[k][j];
		if (t < d[i][j]) d[i][j] = t;
	}

	memset(b, INF, sizeof(b));
	for (i = 0; i < sz; i++) for (j = 0; j < gsz; j++) b[1<<i][j] = d[s[i]][j];

	lim = 1 << sz;
	for (i = 1; i < lim; i++) {
		if (!(i & (i-1))) continue;
		for (j = 0; j < gsz; j++) for (k = 0; k < i; k++) {
			if ((i | k) == i) {
				t = b[k][j] + b[i-k][j];
				if (t < b[i][j]) b[i][j] = t;
			}
		}
		for (j = 0; j < gsz; j++) for (k = 0; k < gsz; k++) {
			t = b[i][k] + d[j][k];
			if (t < b[i][j]) b[i][j] = t;
		}
	}

	ans = INF;
    for (i = 0; i < lim; i++) for (j = 0; j < gsz; j++) {
		t = b[i][j] + b[lim-1-i][j];
		if (ans > t) ans = t;
	}
    return ans;
}

int main()
{
    int H, W, i, r, c, t, nr, nc, nt;

    while (H = in()) {
		W = in();
		memset(g, INF, sizeof(g));
		sz = 0;
		for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
			t = r*W + c;
			if (in()) s[sz++] = t;

			for (i = 0; i < 4; i++) {
				nr = r + mv[i][0], nc = c + mv[i][1];
				if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
				nt = nr*W + nc;
				g[t][nt] = 1;
			}
			g[t][t] = 0;
		}

		printf("%d\n", H*W - minimumSteinerTree(s, sz, g, H*W) - 1);
	}
	return 0;
}



Measured memory_bytes: 2776
#include<bits/stdc++.h>
typedef long long lli;
using namespace std;
string s;
lli ans=1;
lli sum[26];
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++) sum[s[i]-'a']++;
	for(int i=1;i<26;i++) for(int j=0;j<i;j++) ans+=sum[i]*sum[j];
	printf("%lld",ans);
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#pragma warning(disable:4996)
using namespace std;
int dat[262145], n, q, _size;
void update(int x, int y) {
	x += _size; dat[x] = y;
	while (x > 1) {
		x /= 2;
		dat[x] = min(dat[x * 2], dat[x * 2 + 1]);
	}
}
int query(int l, int r, int a, int b, int pos) {
	if (l <= a && b <= r) { return dat[pos]; }
	if (l > b)return 2147483647; if (r < a)return 2147483647;
	int D1 = query(l, r, a, (a + b + 1) / 2 - 1, pos * 2);
	int D2 = query(l, r, (a + b + 1) / 2, b, pos * 2 + 1);
	return min(D1, D2);
}
int main() {
	scanf("%d%d", &n, &q); _size = 1; while (_size < n)_size *= 2;
	for (int i = 0; i < 262145; i++)dat[i] = 2147483647;
	for (int i = 0; i < q; i++) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		if (a == 0)update(b, c);
		if (a == 1)cout << query(b, c, 0, _size - 1, 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int n;
    cin>>n;
    int ar[n+1];
    for(int i=1;i<=n;++i)
    cin>>ar[i];
    
    int dp[100010];
    memset(dp,0,sizeof dp);
    dp[1]=0;
    dp[2]=abs(ar[1]-ar[2]);
    for(int i=3;i<=n;++i)
    dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    cout<<dp[n];
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int H, W, h, w;
    cin >> H >> W >> h >> w;
//    int ini_n = (int) (1e8);
    int x, y;
//    x = 114514;
    x = int(1e9 / (1000 * 1000));
    y = -(h * w - 1) * x - 1;
    vector<vector<ll> > a(H, vector<ll>(W, x));

    ll sum_v = 0LL;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            auto check = [&]() {
                return (i + 1) % h == 0 && (j + 1) % w == 0;
            };
            if (check()) {
//                a[i][j] = -(h * w);
//                sum_v -= (1 + h * w);
                a[i][j] = y;
            }
        }
    }
    rep(i, 0, H) {
        rep(j, 0, W) {
//            if (a[i][j] < 0) {
//                a[i][j] -= ini_n;
//            } else {
//                a[i][j] += ini_n;
//            }
            sum_v += 1LL * a[i][j];
        }
    }

    if (sum_v > 0) {
        cout << "Yes" << endl;
        rep(i, 0, H) {
            rep(j, 0, W) {
                cout << a[i][j] << " ";
            }
            cout << endl;
        }
    } else {
        cout << "No" << endl;
        //あとで消す
//        rep(i, 0, H) {
//            rep(j, 0, W) {
//                cout << a[i][j] << " ";
//            }
//            cout << endl;
//        }
    }


    return 0;
}


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

int main(){
    double w, h, x, y, s, smax, S;
	cin >> w >> h >> x >> y;
	S = x*y;

	// 四角形
	cout << fixed << setprecision(11);
	cout << w*h/2 << " ";

	if(w/2 == x && h/2 == y){
		cout << 1 << endl;
	}else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;

int W, H;
int pw[100005], ph[100005];
ll ans;
int main() {
    cin >> W >> H;
    vector<P> vec;
    vec.reserve(W + H);
    rep(i, W) cin >> pw[i];
    rep(i, H) cin >> ph[i];
    rep(i, W) vec.push_back(P(pw[i], 0));
    rep(i, H) vec.push_back(P(ph[i], 1));
    sort(pw, pw + W);
    sort(ph, ph + H);
    sort(all(vec));
    rep(i, vec.size()) {
        auto p = vec[i];
        if (p.second == 0) {
            int k = upper_bound(ph, ph + H, p.first) - ph;
            k = H - k + 1;
            // cout << k << ", " << p.first << endl;
            ans += k * p.first;
        } else {
            int k = lower_bound(pw, pw + W, p.first) - pw;
            k = W - k + 1;
            // cout << k << ", " << p.first << endl;
            ans += k * p.first;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 INF = 1LL << 40;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N, Z, W;
  cin >> N >> Z >> W;
  vector<i64> A(N);
  REP(i, N) cin >> A[i];

  map<tuple<int, i64>, i64> memo1, memo2;
  function<i64(int, i64, i64)> maximize, minimize;

  maximize = [&](int i, i64 x, i64 y) -> i64 {
    if (i == N) return abs(x - y);
    tuple<int, i64> key = {i, y};
    auto it = memo1.find(key);
    if (it != memo1.end()) return it->second;
    i64 res = -INF;
    for (int k = i; k < N; ++k) {
      i64 minval = minimize(k + 1, A[k], y);
      res = max(res, minval);
    }
    memo1[key] = res;
    return res;
  };

  minimize = [&](int i, i64 x, i64 y) -> i64 {
    if (i == N) return abs(x - y);
    tuple<int, i64> key = {i, x};
    auto it = memo2.find(key);
    if (it != memo2.end()) return it->second;
    i64 res = INF;
    for (int k = i; k < N; ++k) {
      i64 maxval = maximize(k + 1, x, A[k]);
      res = min(res, maxval);
    }
    memo2[key] = res;
    return res;
  };

  cout << maximize(0, Z, W) << endl;
}


Measured memory_bytes: 4168
#include <stdio.h>

int get_sum(int num, int sum, int n){
    
    if (num == 0 && sum == 0){
        return (1);
	}
    
    if (n > 9){
        return (0);
    }
    
    return (get_sum(num - 1, sum - n, n + 1) + get_sum(num, sum, n + 1));
}

int main(void)
{
	int sum, num;
	
	while (1){
		scanf("%d%d", &num, &sum);
		if (num == 0 && sum == 0) break;
        
		printf("%d\n", get_sum(num, sum, 0));
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>

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

  for ( i = 1; ; ++i )
  {
    int d;

    scanf ( "%d", &d );
    if ( d == 0 ) break ;

    printf ( "Case %d: %d\n", i, d );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>

int main(){
  int64_t num;
  int64_t blue;
  int64_t red;

  std::cin >> num >> blue >> red;

  int64_t sum = blue + red;
  int64_t blue_sum = (num / sum) * blue;
  int64_t rem = num % (blue + red);

  if(rem <= blue){
    blue_sum += rem;
  }else{
    blue_sum += blue;
  }

  std::cout << blue_sum << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int cnt[] = new int[N+1];
		for(int i=0; i<N; i++) {
			int v = sc.nextInt();
			cnt[v]++;
		}
		Arrays.sort(cnt);
		int kcnt = 0;
		for(int i=0; i<K; i++) {
			kcnt += cnt[N-i];
		}
		int ans = N-kcnt;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 61412
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    cout << n*n*n << '\n';
    return 0;
}

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

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

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    int cnt=0;
    int now=0;
    rep(i,n){
        if(now<v[i]){
            now=v[i];
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

int main(){

    double n, m, d;
    cin >> n >> m >> d;
    if (d==0) {
        cout << fixed << setprecision(10) << 1.0 / n * (n-d) / n * (m-1) << endl;
    } else {
        cout << fixed << setprecision(10) << 2.0 / n * (n-d) / n * (m-1) << endl;
    }

    return 0;
}


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

int main(int argc, const char * argv[]) {
    vector<int> n(3);
    for(int i = 0; i < 3; i++) cin >> n[i];
    sort(n.begin(), n.end());
    
    int cnt = 0;
    while(!(n[0] == n[1] && n[1] == n[2])) {
        if(n[1] == n[2]) {
            n[0] +=2;
            cnt++;
        } else {
            n[0]++; n[1]++;
            cnt++;
        }
        sort(n.begin(), n.end());
    }
    
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long d = sc.nextLong();
		int count =0;
		for (int i =0;i<n;i++) {
			long x = sc.nextLong();
			long y =sc.nextLong();
			double power = (Math.sqrt(Math.pow(x, 2) +Math.pow(y, 2)));
			if(x*x+y*y<=d*d) {
				count++;}}
		System.out.println(count);

	}

}


Measured memory_bytes: 61016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		int a = Integer.parseInt(list[0]);
		int b = Integer.parseInt(list[1]);
		String answer = "";

		if(a > b){
			if(b == 1){
				answer = "Bob";
			}else{
				answer = "Alice";
			}
		}else if(a == b){
			answer = "Draw";
		}else if(a < b){
			if(a == 1){
				answer = "Alice";
			}else{
				answer = "Bob";
			}
		}

		System.out.println(answer);

	}

}


Measured memory_bytes: 8148
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<long long> A;
  priority_queue<long long, vector<long long>, less<long long>> que;
  for(int i=0; i<N; i++){
    long long a;
    cin >> a;
    que.push(a);
  }

  for(int i=0; i<M; i++){
    long long tmp = que.top();
    que.pop();
    que.push(tmp / 2);
  }
  long long ans = 0;
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
N, K = map(int, input().split())
h = list(map(int, input().split()))

inf = float('inf')

dp = [inf] * N
dp[0] = 0

for i in range(1, N):
    mindp_i = inf

    for jump in range(1, K + 1):
        if i - jump >= 0:

            dpcand = dp[i - jump] + abs(h[i] - h[i - jump])
            #print(dpcand)
            if dpcand < mindp_i:
                mindp_i = dpcand

    dp[i] = mindp_i

print(dp[N-1])

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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 100

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	s=" "+s;

	int l=s.size();
     l--;
	if(s[1]!='A')
	{
		cout<<"WA\n";return 0;
	}
	int oc=0;bool f=true;
	for(int i=3;i<l;i++)
	{
		if(s[i]=='C')
			oc++;
		else if(isupper(s[i]))
			f=false;
	}

	if(isupper(s[2]) || isupper(s[l]))
		f=false;

	if(oc==1 && f)
		cout<<"AC\n";
	else
		cout<<"WA\n";
	return 0;
}


Measured memory_bytes: 256
from collections import deque

INF = 100000000
H, W, N = list(map(int, input().split()))
maze = [list(input()) for i in range(H)]

x = -1
for letters in maze:
    x += 1
    y = -1
    for letter in letters:
        y += 1
        if letter == "S":
            sx = x
            sy = y
        elif letter == str(N):
            gx = x
            gy = y

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def bfs():
    count = 0
    backup = []
    for tmp_goal in range(1, N + 1):
        d = [[INF for i in range(W)] for j in range(H)]
        if tmp_goal == 1:
            q = deque([[sx, sy]])
            d[sx][sy] = 0
        else:
            q = deque([backup])
            d[backup[0]][backup[1]] = count

        while len(q) != 0:
            tmp_x, tmp_y = q.popleft()
            if maze[tmp_x][tmp_y] == str(tmp_goal):
                count = d[tmp_x][tmp_y]
                backup = [tmp_x, tmp_y]
                q.clear()
                break
            for j in range(0, 4):
                nx = tmp_x + dx[j]
                ny = tmp_y + dy[j]
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "X" and d[nx][ny] == INF:
                    q.append([nx, ny])
                    d[nx][ny] = d[tmp_x][tmp_y] + 1
    return count


if __name__ == '__main__':
    ans = bfs()
    print(ans)

Measured memory_bytes: 45848
#include <iostream>
using namespace std;
int main(){
  int t {};
  cin >> t;
  int d1 {};
  int d2 {};
  int count {0};
  while(t--){
    cin >> d1;
    cin >> d2;
    if(d1<=6 && d2<=6 && d1 == d2 && d1>0 && d2>0){
      count++;
    }
    else if(d1<=6 && d2<=6 && d1!=d2 && d1>0 && d2>0 && count<3){
      count = 0;
    }
  }
  if(count >= 3){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 10e-6;

char stage[100][100];
int costTable[100][100];

void bfs(int w,int h){
	const int t[][2] = {{1,0},{0,1},{-1,0},{0,-1}};
	int sx,sy;
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if(stage[y][x] == '&'){
				sx = x;
				sy = y;
				goto found;
			}
		}
	}
found:;

	memset(costTable,0x3,sizeof(costTable));
	queue<P> que;
	que.push(P(sx,sy));

	costTable[sy][sx] = 0;

	while(!que.empty()){
		int x = que.front().first;
		int y = que.front().second;
		que.pop();	

		for(int i=0;i<4;i++){
			int dx = x + t[i][0];
			int dy = y + t[i][1];
			if(dx < 0 || dx >= w || dy < 0 || dy >= h) continue;

			int cost = costTable[y][x] + ((stage[dy][dx] == '#' && stage[y][x] != '#') ? 1 : 0);
			if(costTable[dy][dx] <= cost) continue;

			costTable[dy][dx] = cost;
			que.push(P(dx,dy));
		}
	}
}

int seekExtWall(int w,int h){
	int res = 0x3333;

	for(int x=0;x<w;x++){
		res = min(res,costTable[0][x]);
	}

	for(int x=0;x<w;x++){
		res = min(res,costTable[h-1][x]);
	}

	for(int y=0;y<h;y++){
		res = min(res,costTable[y][0]);
	}

	for(int y=0;y<h;y++){
		res = min(res,costTable[y][w-1]);
	}

	return res;
}

void printCostTable(int w,int h){
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			cout << costTable[y][x];
		}
		cout << endl;
	}
}

int main(){
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==0 && h==0) break;
		for(int y=0;y<h;y++){
			char buf[128];
			scanf("%s",buf);
			for(int x=0;x<w;x++){
				stage[y][x] = buf[x];
			}
		}

		bfs(w,h);
		cout << seekExtWall(w,h) << endl;
		//printCostTable(w,h);
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
long long int a[200010],b[200010],sum1[200010],sum2[200010],n,m,i,j,k,cnt;
int main(){
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=m;i++)cin>>b[i];
	for(i=1;i<=n;i++){
		sum1[i]=sum1[i-1]+a[i];
	}
	for(i=1;i<=m;i++){
		sum2[i]=sum2[i-1]+b[i];
	}
	for(i=0;i<=n;i++){
		if(sum1[i]>k)break;
		int l=1,r=m,ans=0;
		while(l<=r){
			int mid=(l+r)>>1;
			if(sum1[i]+sum2[mid]>k)r=mid-1;
			else{
				ans=mid;l=mid+1;
			}
		}
		cnt=max(cnt,i+ans);
	}
	cout<<cnt;
}

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char c1 = (s1[0] - 'a') + 'A';
    char c2 = (s2[0] - 'a') + 'A';
    char c3 = (s3[0] - 'a') + 'A';
    cout << c1 << c2 << c3 << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(m):
    b[i+1] += b[i]


def f(time, r):
    ret = bisect_right(r, time) - 1
    return ret


def fa(time):
    return f(time, a)


def fb(time):
    return f(time, b)

ans = 0

for i, ai in enumerate(a):
    k -= ai
    if k < 0:
        break
    ans = max(ans, i + fb(k))

print(ans)

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 50;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
map<ll, ll> mp;
bool pp[N];


void primes(ll m)
{
	ll temp = m;
	for(ll i=2; i*i <= m; i++)
	{
		if(pp[i] == 0)
		{
			for(ll j = i*i; j*j<=m; j+=i)
				pp[j] = 1;
			int cnt = 0;
			while(temp % i == 0) 
			{
				cnt++;
				temp /= i;
			}
			if(cnt != 0) mp[i] = cnt;
		}
	}
	if(temp != 1)
	{
		int cnt = 0;
		ll z = temp;
		while(temp % z == 0) 
		{
			cnt++;
			temp /= z;
		}
		mp[z] = cnt;
	}
}
  
ll ppow(ll x, ll y, ll mod)
{
  ll res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%mod;
    y = y >> 1;
    x = (x * x)%mod;
  }
  return res;
}

// Factorial with dp
ll factdp[N];
ll fact(ll x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2, M)) %= M;
  (res *= ppow(fact(n-r), M-2, M)) %= M;
  return res;
}

int main()
{
	int n;
	ll m;
	cin>>n>>m;
	primes(m);
	ll cnt = 1;
	for(auto x: mp)
	{
		ll r = x.s;
		cnt  = (modcomb(n-1+r, r) * cnt ) % M;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl

template<typename Type>

class BIT {
    public: //1-index
    vector<Type> bit;
    int n;
    BIT(int size){
        n = size+1;
        bit = vector<Type>(n+1,0);
    }

    void add(int i,Type x){
        while(i<=n){
            bit[i] += x;
            i += i&-i;
        }
    }

    Type sum(int i){
        int ret=0;
        while(i>0){
            ret += bit[i];
            i -= i&-i;
        }
        return ret;
    }

    Type range(int l,int r){
        return sum(r)-sum(l-1);
    }
};


int main(void){
    string s;
    cin>>s;
    int n = s.size();
    s = "_" + s;
    deque<int> p[26];
    BIT<int> bit(n);
    rep1(i,n){
        p[s[i]-'a'].push_back(i);
        bit.add(i,1);
    }

    int odd = 0;
    rep(i,26) if(p[i].size()&1) odd++;
    if(odd>1) {
        cout<<-1<<endl;
        return 0;
    }
    long r = 0;
    int v = n;
    rep1(i,n)if(bit.sum(i)-bit.sum(i-1) == 1){
        auto &d = p[s[i]-'a'];
        if(d.size()==1){
            r += v/2;
            bit.add(i,-1);
            d.clear();
            v--;
        }else{
            int x = d.front(); d.pop_front();
            int y = d.back(); d.pop_back();
            r += v - bit.sum(y);
            bit.add(x,-1);
            bit.add(y,-1);
            v -= 2;
        }
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>

#define DEBUG 0;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;

Graph G;

int main(){
#ifdef DEBUG
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());
#endif

  int n;
  cin >> n;

  G.assign(n, vector<Edge>());

  REP(i, n-1)
  {
    int a,b;
    ll c;
    cin >> a >> b >> c;
    --a, --b;
    G[a].push_back(Edge(b, c));
    G[b].push_back(Edge(a, c));
  }

  ll q,k;
  cin >> q >> k;
  --k;

  ll x[q],y[q];

  REP(i,q)
  {
	  cin >> x[i] >> y[i];
	  --x[i];
	  --y[i];
  }

  ll toK[n];
  REP(i,n)
  {
	  toK[i] = -1;
  }

  queue <pair<ll, ll>> que;
  que.push(pair<ll,ll>(k,0));
  ll papa = -1;

  while(!que.empty())
  {
    pair<ll, ll> cur = que.front();
    que.pop();
	
	//閉路なし
	for(int i = 0; i < G[cur.first].size(); ++i)
	{
		int tugi = G[cur.first][i].first;
		if(tugi == papa)continue;
		ll kyori = G[cur.first][i].second + cur.second;
		if(toK[tugi] == -1)
		{
			toK[tugi] = kyori;
        	que.push(pair <ll,ll> (tugi, kyori));
			//cout << tugi << endl;
		};
	}
	papa = cur.first;
  }
  REP(i,q)
  {
	  ll res = toK[x[i]] + toK[y[i]];
	  cout << res << endl;
  }
	
  return 0;
}



Measured memory_bytes: 12400
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll n, k, s;
  cin >> n >> k >> s;
  fi(0, n) {
    if(i < k)
      cout << s;
    else {
      if(s == (int)1e9)
        cout << 1;
      else
        cout << fixed << (int)1e9;
    }
    if(i == n - 1)
      cout << endl;
    else
      cout << " ";
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main() {

	
	int n;
	cin>>n;
	int k;cin>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
	    cin>>v[i];
	}
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(v[i]-v[i+j]));
            }
        }
    }
  	
    cout<<dp[n-1]<<endl;
    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include<iomanip>
#include <string>
using namespace std;

bool isprime(int a)
{
    if (a==2) return true;
    if (a<2 || (a%2==0)) return false;

    int i=3;
    while(i <= sqrt(a)){
        if (a%i==0) return false;
        i=i+2;
    }
    return true;
}

int main() {
    int N;
    int count=0;
    cin >> N;

    for (int i=0;i<N;i++){
        int x;
        cin >> x;
        if (isprime(x)) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  ios_base::sync_with_stdio(false);

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

  string S, T;
  cin >> S >> T;

  int g = __gcd(N, M);
  int n = M / g;
  int m = N / g;

  for (llint i = 0; i < N; ++i) {
    if (((n * i) % m) == 0) {
      int j = (n * i) / m;
      if (j < M && S[i] != T[j]) {
        cout << "-1\n";
        return 0;
      }
    }
  }

  cout << llint(N) * M / g << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    string s,t,c;cin>>s>>t;
    map<string,int>m;
    int a,b;
    cin>>a>>b;
    m[s]=a;m[t]=b;
    cin>>c;
    m[c]--;
    cout<<m[s]<<' '<<m[t];
    
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = []
sp = 0
c = 0
for i in range(n + 1):
    if i == 0: continue
    for j in range(sp, n - 1):
        if a[j] != i:
            break
        sp += 1
        c += 1
    ans.append(c)
    c = 0

for i in range(n):
    print(ans[i])


Measured memory_bytes: 32228
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 5e6 + 3e5;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

int n, sum, a[maxn];
bitset<maxn> s;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	s.set(0);
	for(int i = 0; i < n; i++)
		cin >> a[i], sum += a[i];
	for(int i = 0; i < n; i++)
		s |= (s << a[i]);
	for(int i = (sum + 1) / 2; i <= sum; i++){
		if(s[i])
			return cout << i << endl, 0;		
	}
	return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<string>
    #include<vector>
    #include<stack>
    #include<bitset>
    #include<cstdlib>
    #include<cmath>
    #include<set>
    #include<list>
    #include<deque>
    #include<map>
    #include<queue>
    using namespace std;
    typedef long long ll;
    const double PI = acos(-1.0);
    const double eps = 1e-6;
    const int INF = 0x3f3f3f3f;
     
    const int MAXN =1e5+10;
     
    char s[MAXN][10+10];
    long long int march[5+5];
    int main(){
        int N =0;
        scanf("%d",&N);
        long long int ans =0;
        for(int i=0;i<N;i++){
            scanf("%s",&s[i]);
        }
        for(int i=0;i<N;i++){
            if(s[i][0]=='M')    march[0]++;
            if(s[i][0]=='A')    march[1]++;
            if(s[i][0]=='R')    march[2]++;
            if(s[i][0]=='C')    march[3]++;
            if(s[i][0]=='H')    march[4]++;
        }
        
        ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];
        
        printf("%lld",ans);
        return 0;
    }

Measured memory_bytes: 2176
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
    int n,k,max=0;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<int> b(n);
    rep(i,n-1){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = k-a[n-1] + a[0];
    rep(i,n){
        max += b[i];
    }
    sort(b.begin(),b.end());
/*    rep(i,n){
        cout << b[i] << endl;
    }*/
    cout << max - b[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,w=0,b=0;
   string s;
   cin >> n >> s;
   for(int i=0;i<n;i++){
       if(s[i]=='.') w++;
   }
   int ans = w;
   for(int i=0;i<n;i++){
       if(s[i]=='#') b++;
       else w--;
       ans = min(ans,b+w);
   }
   cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }
 
int main() {
  ull a, b, c;
  cin >> a >> b >> c;

  bool yes = true;
  if (a <= b) {
    if (a <= c && c <= b) {
    } else {
      yes = false;
    }
  } else {
    if (b <= c && c <= a) {
    } else {
      yes = false;
    }
  }

  if (yes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

 
  return 0;
}


Measured memory_bytes: 256