akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,p,q,r,cur,i,j,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    cin>>n>>k;
    map<long long int,long long int>m;
    vector<long long int>v;
    set<long long int>s;
    for(i=0;i<n;i++)
    {
        cin>>x;
        m[x]++;
        s.insert(x);
    }
    for(auto y:s)
    {
        v.push_back(m[y]);
    }
    sort(v.begin(),v.end());
    if(v.size()<=k)
    {
        cout<<0<<endl;
    }
    else
    {
        //y=v.size()-k;
        for(i=0;i<(v.size()-k);i++)
        {
            c1+=v[i];

        }
        cout<<c1<<endl;
    }

    return 0;
}




Measured memory_bytes: 24308
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);
int a;
cin>>a;
if(a>=30)
{
	cout<<"Yes"<<endl;
}
else
	cout<<"No"<<endl;

cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int ch[1000005][26],sum[1000005][26],s[200005],c[200005],tot,
siz[1000005],le[26];
string str[200005];
bool cmp(int x,int y){return s[x]>s[y];}
int main()
{
    int n;
    long long ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)cin>>str[i],s[i]=str[i].size(),c[i]=i;
    sort(c+1,c+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        int now=0;
        for(int j=0;j<str[c[i]].size();j++)
            le[str[c[i]][j]-'a']++;
        for(int j=str[c[i]].size()-1;j>0;j--)
            if(!ch[now][str[c[i]][j]-'a'])goto nxt;
            else now=ch[now][str[c[i]][j]-'a'];
        ans+=siz[ch[now][str[c[i]][0]-'a']]+sum[now][str[c[i]][0]-'a'];
        nxt:;
        now=0;
        for(int j=str[c[i]].size();j>=0;j--)
        {
            if(j!=s[c[i]])
            {
                if(!ch[now][str[c[i]][j]-'a'])ch[now][str[c[i]][j]-'a']=++tot;
                now=ch[now][str[c[i]][j]-'a'];
                siz[now]++;
                le[str[c[i]][j]-'a']--;
            }
            for(int k=0;k<=25;k++)
                if(le[k]&&str[c[i]][j-1]-'a'!=k)
                    sum[now][k]++;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 218148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i;
    double sum=0;
    cin>>n>>m;
    int arr[n];
    for(i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    sum=sum/(4*m);
    sort(arr,arr+n);
    if(arr[n-m]>=sum){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

public class Main {
	
	static String[][] aaa;

	public static void main(String[] args) throws IOException {
		method1();
	}
	
//	public static List<String> method2(String[][] a, int i, int j){
//		List<String> b = new ArrayList<String>();
//		
//		for(int k = 0; k < 4; k++){
//			try{
//				switch(k){
//					case 0:
//						b.add(a[i][j-1]);
//						//System.out.println(0);
//						break;
//						
//					case 1:
//						b.add(a[i-1][j]);
//						//System.out.println(1);
//						break;
//						
//					case 3:
//						b.add(a[i+1][j]);
//						//System.out.println(2);
//						break;
//						
//					case 4:
//						b.add(a[i][j+1]);
//						//System.out.println(3);
//						break;
//				}
//			}
//			catch(Exception e){
//				k++;
//			}
//		}
//		
//		return b;
//	}
	
	public static boolean method3(int i, int j){
		boolean b = false;
		
		int w = aaa[0].length;
		int h = aaa.length;
		final String c = "#";
		
		for(int k = 0; k < 4; k++){
			if(j == 0 && k == 0) continue;
			if(i == 0 && k == 1) continue;
			if(i == (h - 1) && k == 2) continue;
			if(j == (w - 1) && k == 3) continue;
			
			switch(k){
				case 0: if(aaa[i][j-1].equals(c)) b = true; break;
				case 1: if(aaa[i-1][j].equals(c)) b = true; break;
				case 2: if(aaa[i+1][j].equals(c)) b = true; break;
				case 3: if(aaa[i][j+1].equals(c)) b = true; break;
			}
			
			if(b) break;
		}
		
		return b;
	}
	
	public static void method1() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
		String[] wh = str.split(" ");
		
		int h = Integer.parseInt(wh[0]);
		int w = Integer.parseInt(wh[1]);
		
		aaa = new String[h][w];
		
		for(int i = 0; i < h; i++){ aaa[i] = br.readLine().split(""); }
		
		boolean flg = true;
		boolean finFlg = false;
		boolean startFlg = true;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(aaa[i][j].equals(".")) continue;
				
				flg = method3(i, j);
				
				//System.out.println(String.format("%2d, %2d, %s", i, j, String.valueOf(flg)));
				
				if(!flg){ finFlg = true; break; }
			}
			
			if(finFlg) break;
		}
		
		System.out.println(flg ? "Yes" : "No");
	}
}


Measured memory_bytes: 22100
#include <iostream>

using namespace std;

int main() {
  string o, e, buf;
  cin >> o >> e;
  int i;

  for (i=0; i < e.length(); i++) {
    cout << o[i] << e[i];
  }
  if (o.length() - e.length() == 1) cout << o[i];
  cout << endl;

  return 0;
}


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

//#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
//#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;



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

   int n;
   while (cin >> n, n) {
       Vi w(n+1);
       REP(i, 1, n+1) cin >> w[i];

       if (n < 2) {
           cout << 0 << endl;
           continue;
       }

       VVi dp(n+1, Vi(n+1, -1));

       REP(R, 2, n+1) {
           int L = R-1;
           int diff = w[R] - w[L];
           if (-1 <= diff && diff <= 1) dp[L][R] = 2;
           else dp[L][R] = 0;
       }

       REP(R, 3, n+1) {
           int L = R-2;
           int left_v = dp[L][R-1], bottom_v = dp[L+1][R];
           if (left_v != 0 || bottom_v != 0) dp[L][R] = 2;
           else dp[L][R] = 0;
       }

       REP(slc, 3, n) {
           REP(R, slc + 1, n + 1) {
               int L = R - slc;
               int left_v = dp[L][R-1], bottom_v = dp[L+1][R];
               dp[L][R] = max(left_v, bottom_v);

               if ((R - L) % 2 == 1) {
                   int diff = w[R] - w[L];
                   if (-1 <= diff && diff <= 1 && dp[L + 1][R - 1] == R - L - 1) {
                       dp[L][R] = max(dp[L][R], dp[L + 1][R - 1] + 2);
                   }
               }

               REP(mid, L+1, R-1)
                   dp[L][R] = max(dp[L][R], dp[L][mid] + dp[mid+1][R]);
           }
       }

//       REP(L, 1, n+1) {
//           REP(R, 1, n+1) {
//               cout << dp[L][R] << " ";
//           } cout << endl;
//       }

//       REP(diff, 2, n) {
//           REP(R, diff+1, n+1) {
//               int L = R - diff;
//               int left_v = dp[L][R-1], bottom_v = dp[L+1][R];
//               int left2_v = dp[L][R-2], bottom2_v = dp[L+2][R];
//               if (left_v == bottom_v && left_v != 0) {
//                   int n_val = left_v + 2;
//                   if (
//                           R >= n_val
//                           &&
//                           left2_v != 0
//                           &&
//                           bottom2_v != 0
//                   ) dp[L][R] = n_val;
//                   else dp[L][R] = left_v;
//               } else {
//                   dp[L][R] = max(left_v, bottom_v);
//               }
//           }
//       }

//       REP(L, 1, n+1) {
//           REP(R, 1, n+1) {
//               cout << dp[L][R] << " ";
//           } cout << endl;
//       }

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

   return 0;
}



Measured memory_bytes: 3268
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
using namespace std;
typedef long long ll;

int main(){
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }

  int x[3];
  x[0] = 0;
  int y[3];
  for(int i=0; i<3; i++) y[i] = c[0][i] - x[0];
  for(int i=0; i<3; i++) x[i] = c[i][0] - y[0];

  bool ans = true;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(x[i]+y[j] != c[i][j]){
        ans = false;
        break;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 1e3+5;
const ll INF = 2e18;

int main(){
	int h,a;
	scanf("%d%d",&h,&a);
	printf("%d",h%a ?h/a+1 :h/a); 
    return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	double ans=0;
	double prob;
	int score;
	for (int i = 1; i <=n; i++) {
		score=i;
		prob=1.0/n;
		while (score<k) {
			score*=2;
			prob/=2;
		}
		ans+=prob;
	}
	//printf("%.12f\n",ans);
	cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if (N % 2 == 0) {
			System.out.println(N);
		} else {
			System.out.println(2 * N);
		}

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
#define name "lqdoj"
#define _ << " " <<
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define ini freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout)
using namespace std;

const int MOD = 1e9 + 7;
const int NMAX = 3005;
double a[NMAX], dp[NMAX][NMAX], res;
int main(){
    fastio;
//    ini;
    int n;
    cin >> n;

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

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= n; j++)
            dp[i][j] = 1.0;
    }

    dp[0][0] = 1;

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= n; j++){
            if (j <= i)
            dp[i][j] = (j ? dp[i - 1][j - 1] * a[i] : 0.0) + dp[i - 1][j] * (1 - a[i]);
            else dp[i][j] = 0;
        }
    }

    int l = n / 2 + n % 2;

    for (int i = l; i <= n; i++) res += dp[n][i];
    cout << setprecision(9) << fixed << res;
    return 0;
}


Measured memory_bytes: 74156
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


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

    int a, b;
    cin >> a >> b;
    
    if (b * 2 <= a)
        cout << a - 2 * b << endl;
    else
        cout << 0 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll h,w;
  cin >> h >> w;
  if(h != 1 && w != 1){
    cout << (h*w+1)/2 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

signed main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A;

  priority_queue<ll> q;
  rep(i, N) {
    ll a;
    cin >> a;
    q.push(a);
  }

  rep(i, M) {
    ll a = q.top();
    q.pop();
    q.push(a / 2);
  }

  ll ans = 0;
  rep(i, N) {
    ans += q.top();
    q.pop();
  }
  COUT(ans);

  return 0;
}

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

int main() {
  int W, H;
  cin >> W >> H;
  vector <vector<int>> menseki(H, vector<int>(W));
  
  int N;
  cin >> N;
  
  vector <vector<int>> Y(N, vector<int>(3));
  for ( int i = 0; i < N ; i++ ){
    for ( int j = 0 ; j < 3 ; j++ ){
      cin >> Y.at(i).at(j);
    }
  }
  

  for ( int i = 0 ; i < N ; i++ ){
    if ( Y.at(i).at(2) == 1 ){
      for ( int j = 0 ; j < H ; j ++ ){
        for ( char k = 0 ; k < Y.at(i).at(0) ; k++ ){
          menseki.at(j).at(k) = 1;
        }
      }
    }
    if ( Y.at(i).at(2) == 2 ){
      for ( int j = 0 ; j < H ; j ++ ){
        for ( char k = Y.at(i).at(0) ; k < W ; k++ ){
          menseki.at(j).at(k) = 1;
        }
      }
    }
    if ( Y.at(i).at(2) == 3 ){
      for ( int j = 0 ; j < Y.at(i).at(1) ; j ++ ){
        for ( char k = 0 ; k < W ; k++ ){
          menseki.at(j).at(k) = 1;
        }
      }
    }
    if ( Y.at(i).at(2) == 4 ){
      for ( int j = Y.at(i).at(1) ; j < H ; j ++ ){
        for ( char k = 0 ; k < W ; k++ ){
          menseki.at(j).at(k) = 1;
        }
      }
    } 
  }
  int answer;
  for ( int i = 0; i < H ; i++ ){
    for ( int j = 0 ; j < W ; j++ ){
      if ( menseki.at(i).at(j) == 0 ){
      answer++ ;
      }
    }
  }
  cout << answer ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node{
    int x,y;
    int zu;
}a[230];
bool cmp(node a,node b)
{
    if(a.x==b.x)
    {
        return a.zu>b.zu;
    }
    return a.x<b.x;
}
set<int>s;
set<int>::iterator it;
int main()
{
    int n;
    scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&a[i].x,&a[i].y);
            a[i].zu=1;
        }
        for(int i=n+1;i<=n*2;i++)
        {
            scanf("%d%d",&a[i].x,&a[i].y);
            a[i].zu=2;
        }
        sort(a+1,a+2*n+1,cmp);
        s.clear();
        int ans=0;
        for(int i=1;i<=2*n;i++)
        {
            if(a[i].zu==2)
            {
                if(!s.empty())
                {
                    it=s.lower_bound(a[i].y);
                    if(it!=s.begin())
                    {
                        it--;
                        int tt=*it;
                        s.erase(it);
                        ans++;
                    }
                }
            }
            else
            {
                s.insert(a[i].y);
            }
        }
        printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main(){
    char S[202]; scanf("%s",S);
    int n = strlen(S);
    
    for(int i = n - 2 ; i ; i -= 2){
        if(strncmp(S , S + i / 2 , i / 2) == 0){
            printf("%d\n" , i);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long e, r, d ,s;
    cin >> e >> r >> d >> s;
    if (s<=e)
        cout << s << endl;
    else if (e+r>=s)
        cout << e << endl;
    else
        cout << e-(s-e-r) << endl;
}



Measured memory_bytes: 3612
#include<stdio.h>
int max(int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a, b, c;
    int aa[100005], bb[100005], cc[100005];
    aa[0] = bb[0] = cc[0] = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        aa[i + 1] = a + max(bb[i], cc[i]);
        bb[i + 1] = b + max(aa[i], cc[i]);
        cc[i + 1] = c + max(aa[i], bb[i]);
    }
    printf("%d\n", max(max(aa[n], bb[n]), cc[n]));
    return 0;
}

Measured memory_bytes: 1280
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N; cin>>N;
	int r = 0, n = 0;
	vector<int> A(N);
	rep(i, N){
		cin>>A[i];
		n = max(n, A[i]);
	}
	int half = n/2;
	rep(i, N){
		// if(A[i] == n) continue;
		if(abs(half - r) > abs(half - A[i])) r = A[i];
	}
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
chomp(my$n=<>);
my@a=();
my$max=0;
my$max2=0;
my@mi=();
for(my$i=0;$i<$n;$i++){
 chomp(my$l=<>);
 push@a,$l;
 if($max<$l){
  $max2=$max;
  $max=$l;
  @mi=($i);
 }elsif($max==$l){
  $max2=$max;
  push@mi,$i;
 }elsif($max2<$l){
  $max2=$l;
 }
}
my@r=($max)x$n;
if(@mi==1){
 $r[$mi[0]]=$max2;
}
print join"\n",@r;


Measured memory_bytes: 45952
program skolem_xor_tree
  implicit none
  integer :: n, x, y, i
  read(*,*) n
  if (and(n,n-1) == 0) then
    write(*,'(a)') "No"
    stop
  end if
  write(*,'(a)') "Yes"
  write(*,'(i0,x,i0)') 1, 2
  write(*,'(i0,x,i0)') 2, 3
  write(*,'(i0,x,i0)') 3, n+1
  write(*,'(i0,x,i0)') n+1, n+2
  write(*,'(i0,x,i0)') n+2, n+3
  do i = 5, n, 2
    write(*,'(i0,x,i0)') 1, i-1
    write(*,'(i0,x,i0)') 1, i
    write(*,'(i0,x,i0)') i-1, n+i
    write(*,'(i0,x,i0)') i, n+i-1
  end do
  if (mod(n,2) == 0) then
    x = n-1
    y = xor(n+1,x)
    do while (x == y .or. x == y-n .or. y == 1)
      x = x-1
      y = xor(n+1,x)
    end do
    write(*,'(i0,x,i0)') x, n
    write(*,'(i0,x,i0)') y, 2*n
  end if
  stop
end program skolem_xor_tree

Measured memory_bytes: 2304
import math
N,M = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) % MOD

    return result % MOD

ans = 1
fac = factorize(M)
for temp in fac:
    num = temp[1]
    ans *= cmb(num + N - 1,num)
    ans %= MOD
print(ans)


Measured memory_bytes: 39828
# 問題：https://atcoder.jp/contests/abc138/tasks/abc138_c

n = int(input())
v = list(map(int, input().strip().split()))
v.sort(reverse=True)
res = 0
for i in range(n-1):
    res += v[i] / (2**(i+1))
res += v[-1] / (2**(n-1))

print(res)


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

int main()
{
	int w;

	cin >> w;

	while (w >= 0) {
		int f = 0;

		if (w <= 10)
			f = 1150;
		else if (w <= 20)
			f = 1150 + 125 * (w - 10);
		else if (w <= 30)
			f = 2400 + 140 * (w - 20);
		else
			f = 3800 + 160 * (w - 30);

		cout << 4280 - f << endl;

		cin >> w;
	}
	
	return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    vector<vector<ll> >dp(100010,vector<ll>(2));
    string L;cin>>L;
    dp[L.size()-1][0]=2;
    dp[L.size()-1][1]=1;
    reverse(all(L));
    ll ii=L.size();
    for(int i=ii-2;i>=0;i--){
        if(L[i]-'0'){
            dp[i][0]=(dp[i][0]+dp[i+1][0]*2%inf)%inf;
            dp[i][1]=(dp[i][1]+dp[i+1][1]*3%inf)%inf;
            dp[i][1]=(dp[i][1]+dp[i+1][0])%inf;
        }else{
            dp[i][0]=dp[i+1][0];
            dp[i][1]=dp[i+1][1]*3%inf;
        }
    }
    cout<<(dp[0][0]+dp[0][1])%inf<<endl;
}

Measured memory_bytes: 5888
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  F0R(i, M) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
  }
  int S, T;
  cin >> S >> T;
  S--; T--;

  // 頂点ごとに訪問フラグとして (1<<歩数Mod3) を記録していく
  vector<int> vs(N);

  int result = -1;
  
  queue<pair<int, int>> qu;
  qu.emplace(S, 0);
  vs[S] |= 1 << 0;
  while (qu.size()) {
    auto [v, s] = qu.front();
    qu.pop();

    int sm3 = s % 3;
    if (v == T && sm3 == 0) {
      result = s / 3;
      break;
    }
    
    s++;
    if (++sm3 >= 3) sm3 = 0;
    for (auto c : G[v]) {
      if (vs[c] & (1 << sm3)) continue;
      vs[c] |= 1 << sm3;
      qu.emplace(c, s);
    }
  }

  cout << result;
}
#endif


Measured memory_bytes: 8916
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int a=100000,n;
	cin>>n;
	for(int i=1;i<=n;++i){
		a*=1.05;
		if(a%1000>0){
			a/=1000;
			a++;
			a*=1000;
		}
	}
	cout<<a<<endl;

}

Measured memory_bytes: 1160
S = list(input())
N = len(S)

yamas = [0, N]
tani_flag = [False] * N
for i in range(1, N):
    if S[i - 1] == 'R' and S[i] == 'L':
        tani_flag[i] = True
    if S[i - 1] == 'L' and S[i] == 'R':
        yamas.append(i)
yamas.sort()
        
# print("#", yamas)
ans = [0] * N
for i in range(1, len(yamas)):
    l_idx = yamas[i - 1]
    r_idx = yamas[i]
    for tani_idx in range(l_idx, r_idx):
        if tani_flag[tani_idx]:
            break
    #
    tani_odd = (tani_idx - l_idx) % 2
    ans[tani_idx - 1] = (r_idx - l_idx + tani_odd) // 2
    ans[tani_idx] = (r_idx - l_idx + (1 - tani_odd)) // 2

print(' '.join(map(str, ans)))

Measured memory_bytes: 13940
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
  int n; cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<ll>x(n+1,0);
  for(int i=0;i<n;i++){
    x[i+1]=x[i]+a[i];
  }
  ll min=100000000000000010;
  for(int i=0;i<n-1;i++){
    if(abs(2*x[i+1]-x[n])<min){
      min=abs(2*x[i+1]-x[n]);
    }
  }
  cout<<min<<endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v<=w){
    cout << "NO" << endl;
    return 0;
  }
  if(max(a-b,b-a)/(v-w)<=t){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
    
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <map>

using namespace std;

int main(){

    int N;
    cin >> N;
    string s;
    map<string, int> m;
    for(int i = 0; i < N; i++){
        cin >> s;
        m[s]++;
    }

    int maxCnt = 0;
    for(auto p: m){
        maxCnt = max(maxCnt, p.second);
    }

    vector<string> ans;
    for(auto p: m){
        if(p.second == maxCnt){
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(), ans.end());
    for(string temp: ans){
        cout << temp << endl;
    }

    return 0;
}

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

long long lcm(long long  a, long long  b)
{
   return a * b / __gcd(a, b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long E = lcm(C, D);
  long long x = (B / C) - ((A-1) / C) + (B / D) - ((A-1) / D) - (B / E) + ((A-1) / E);
  cout << B - A - x + 1;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int A,B,C,D; cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
    return 0;
}

Measured memory_bytes: 256
import math

q = int(input())

def is_prime(a):
    if a == 1:
        return False
    for i in range(2,int(math.sqrt(a)+1)):
        if a%i == 0:
            return False
    else:
        return True

s = [0 for i in range(0,100001)]
for i in range(3,100001,2):
    if is_prime(i) and is_prime((i+1)//2):
        s[i] = 1

s2 = [0 for i in range(0,100001)]
tmp = 0
for i in range(100001):
    tmp += s[i]
    s2[i] = tmp

for i in range(q):
    l,r = map(int,input().split())
    ans = s2[r] - s2[l-1]
    print(ans)




Measured memory_bytes: 81636
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int mask=0;
    string w;
    cin>>w;
    for(auto xx:w)
    {
        int i=xx-'0';
        mask^=(1<<i);
    }
    if(mask==0)
    cout<<"Yes";
    else 
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
class node
{
public:
	int key;
	node *p;
	node *l;
	node *r;
};

node *NIL,*root;

void insert(int v)
{
	node *y=NIL,*x=root,*z=new node;
	z->key=v;z->l=z->r=NIL;
	while(x!=NIL)
	{
		y=x;
		if(z->key<x->key)x=x->l;
		else x=x->r;
	}
	z->p=y;
	if(y==NIL)root=z;
	else if(z->key<y->key)y->l=z;
	else y->r=z;
	return;
}

node* find(int k)
{
	node *x=root;
	while(x!=NIL&&k!=x->key)
	{
		if(k<x->key)x=x->l;
		else x=x->r;
	}
	return x;
}

node* next(node *z)
{
	node *x,*y;
	if(z->r!=NIL)
	{
		x=z->r;
		while(x->l!=NIL)x=x->l;
		return x;
	}
	
	y=z->p;
	while(y!=NIL&&x==y->r)
	{
		x=y;
		y=y->p;
	}
	return y;
}

void del(node *z)
{
	node *y,*x;
	if(z->l==NIL||z->r==NIL)y=z;
	else y=next(z);
	
	if(y->l!=NIL)x=y->l;
	else x=y->r;
	
	if(x!=NIL)x->p=y->p;
	
	if(y->p==NIL)root=x;
	else if(y==y->p->l)y->p->l=x;
	else y->p->r=x;
	
	if(y!=z)z->key=y->key;
	delete(y);
	return;
}

void ino(node *u)
{
	if(u==NIL)return;
	ino(u->l);
	cout<<" "<<u->key;
	ino(u->r);
	return;
}

void preo(node *u)
{
	if(u==NIL)return;
	cout<<" "<<u->key;
	preo(u->l);
	preo(u->r);
	return;
}

void print()
{
	ino(root);
	cout<<endl;
	preo(root);
	cout<<endl;
	return;
}

int main() {
	int n;cin>>n;
	string s;node *a;
	while(cin>>s)
	{
		if(s=="insert")
		{
			cin>>n;
			insert(n);
		}
		else if(s=="find")
		{
			cin>>n;
			a=find(n);
			if(a!=NIL)cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
		else if(s=="delete")
		{
			cin>>n;
			del(find(n));
		}
		else if(s=="print")print();
	}
	return 0;
}

Measured memory_bytes: 21952
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

int main()
{
    string N;
    cin >> N;
    
    ll fx = 0;
    for (ll i = 0; i < N.size(); i++)
    {
        fx += N[i] - '0';
    }
    
    cout << (stoi(N) % fx == 0  ? "Yes" : "No") << endl;
    // ll N;
    // cin >> N;
    // vector<ll> V(N);
    // for (ll i = 0; i < N; i++)
    // {
    //     cin >> V[i];
    // }
    // sort(V.begin(), V.end());

    // cout << (V.back() - V.front()) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int m, f, r;
	scanf("%d %d %d", &m, &f, &r);
	while(m+f+r != -3){
		if (m == -1 || f == -1){
			printf("F\n");
		} else if (80 <= m+f){
			printf("A\n");
		} else if (65 <= m+f && m+f < 80){
			printf("B\n");
		} else if (50 <= m+f && m+f < 65){
			printf("C\n");
		} else if (30 <= m+f && m+f < 50){
			if(50 <= r){
				printf("C\n");
			} else {
				printf("D\n");
			}
		}else if (m+f < 30){
			printf("F\n");
		}
		scanf("%d %d %d", &m, &f, &r);
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000010,Mo=998244353;
int fac[N],rev[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return o*x;
}
inline int Pow(int x,int y) {
    int ret=1;
    for(;y;x=1LL*x*x%Mo,y>>=1)
	if(y&1) ret=1LL*ret*x%Mo;
    return ret;
}
inline int C(int n,int m) {
    return 1LL*fac[n]*rev[m]%Mo*rev[n-m]%Mo;
}
int main() {
    int n,m,ans=0;
    cin>>n>>m;
    if(n<m) swap(n,m);
    for(int i=fac[0]=1;i<=n+m;i++) fac[i]=1LL*fac[i-1]*i%Mo;
    rev[n+m]=Pow(fac[n+m],Mo-2);
    for(int i=n+m;i;i--) rev[i-1]=1LL*rev[i]*i%Mo;
    for(int i=0;i<m;i++) ans=(ans+1LL*C(n-m+i+i,i)*C(m-i+m-i,m-i))%Mo;
    ans=1LL*ans*Pow(2,Mo-2)%Mo*Pow(C(n+m,n),Mo-2)%Mo;
    cout<<(ans+n)%Mo;
    return 0;
}

Measured memory_bytes: 8064
import sys
s=input()
n=len(s)
buf=0
if n%2!=0:
    print('No')
    sys.exit()
for i in range(0,n-1,2):
    if s[i]=='h' and s[i+1]=='i':
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
  int w,h,n;
  int x[101],y[101],a[101];
  int i,j;
  int xmin,xmax,ymin,ymax;
  int ans;
  scanf("%d%d%d",&w,&h,&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&x[i],&y[i],&a[i]);
  }
  xmin=0;
  xmax=w;
  ymin=0;
  ymax=h;
  for(i=0;i<n;i++){
    if(a[i]==1){
      if(xmin<x[i] && x[i]<xmax) xmin=x[i];
      if(xmin<x[i] && x[i]>=xmax) xmin=xmax;
    }else if(a[i]==2){
      if(xmin<x[i] && x[i]<xmax) xmax=x[i];
      if(xmin>=x[i] && x[i]<xmax) xmax=xmin;
    }else if(a[i]==3){
      if(ymin<y[i] && y[i]<ymax) ymin=y[i];
      if(ymin<y[i] && y[i]>=ymax) ymin=ymax;
    }else if(a[i]==4){
      if(ymin<y[i] && y[i]<ymax) ymax=y[i];
      if(ymin>=y[i] && y[i]<ymax) ymax=ymin;
    }
  }
  ans=(xmax-xmin)*(ymax-ymin);
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1732
X,K,D = map(int,input().split())
if(X>0):
    if(X-K*D>0):
        print(X-K*D)
    else:
        a = X//D
        d1 = X-a*D
        d2 = X-(a+1)*D
        if(abs(d1)<=abs(d2)):
            if((K-a)%2==0):
                print(abs(d1))
            else:
                print(abs(d2))
        else:
            if((K-a)%2==0):
                print(abs(d1))
            else:
                print(abs(d2))
elif(X<0):
    if(X+K*D<0):
        print(abs(X+K*D))
    else:
        a = abs(X//D)
        d1 = X+a*D
        d2 = X+(a-1)*D
        if(abs(d1)<=abs(d2)):
            if((K-a)%2==0):
                print(abs(d1))
            else:
                print(abs(d2))
        else:
            if((K-a)%2==0):
                print(abs(d1))
            else:
                print(abs(d2))

else:
    if(K%2==1):
        print(D)
    else:
        print(0)


Measured memory_bytes: 9160
n = int(raw_input())
A = map(int,raw_input().split())
S = 0
inv = [1,-1]*(n//2) + [1]
for q in range(n):
  S += A[q]*inv[q]
ans = [0]*n
for q in range(n):
  ans[q] = S
  S = 2*A[q]-S
print ' '.join(map(str, ans))

Measured memory_bytes: 18660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
	int64_t x;
	mint(int64_t x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(int64_t t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int n, x, y, z;
mint dp[41][1<<17];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> x >> y >> z;

	const int X = (1<<(x+y+z))-1;
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, 1<<(x+y+z)) {
			if(j>>(x+y+z-1)&1 and j>>(x+y-1)&1 and j>>(x-1)&1) dp[i+1][j] += dp[i][j]*10;
			else rep(k, 10) {
				int j_ = (j*2+1)<<k&X;
				//cout << bitset<5>(j) << ' ' << bitset<5>(j_) << endl;
				dp[i+1][j_] += dp[i][j];
			}
		}
	}

	mint ans;
	rep(j, 1<<(x+y+z)) {
		if(j>>(x+y+z-1)&1 and j>>(x+y-1)&1 and j>>(x-1)&1) ans += dp[n][j];
	}

	cout << ans << endl;
}

Measured memory_bytes: 45540
#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 = 1e8;

int main() {
	int n;
	cin >> n;
	vector<int> r(n), c(n);
	rep(i, n) cin >> r[i] >> c[i];
	vector<vector<int>> dp(n + 1, vector<int>(n + 1, INF));
	rep(i, n + 1) dp[i][i] = 0;
	rep(i, n) dp[i][i + 1] = 0;
	for (int w = 2; w <= n; w++) {
		for (int i = 0; i <= n - w; i++) {
			int j = i + w;
			for (int m = i + 1; m < j; m++) {
				int t = r[i] * r[m] * c[j - 1];
				dp[i][j] = min(dp[i][j], dp[i][m] + dp[m][j] + t);
			}
		}
	}
	cout << dp[0][n] << endl;
	return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() 
{
    int h,w;
    while (scanf("%d%d",&h,&w)) {
        if (h==0&&w==0) break;
        vector<string> map;
        for (int i=0; i<h; i++) {
            string in;
            cin>>in;
            map.push_back(in);
        }
        vector<vector<int> > went;
        for (int i=0; i<h; i++) {
            vector<int> num(w,0);
            went.push_back(num);
        }
        int ni=0, nj=0;
        bool flag=false;
        while (map[ni][nj]!='.') {
            if (went[ni][nj]==1) {
                flag=true;
                break;
            }
            went[ni][nj]++;
            if (map[ni][nj]=='>') {
                nj++;
            }
            else if (map[ni][nj]=='<') {
                nj--;
            }
            else if (map[ni][nj]=='^') {
                ni--;
            }
            else if (map[ni][nj]=='v') {
                ni++;
            }
        }
        if (flag) printf("LOOP\n");
        else printf("%d %d\n",nj,ni);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

int expo(int a,int p){
	if(p==0){
		return 1;
	}
	else{
		int h=expo(a,p/2);
		if(p%2==0){
			return (h*h)%modF;
		}
		else{
			return (((h*h)%modF)*a)%modF;
		}
	}
}

void solve(){
	int n;
	cin>>n;
	int ans=(expo(10,n)-2*expo(9,n)+expo(8,n)+2*modF)%modF;
	cout<<ans<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3640
nm = [int(s) for s in input().split()]
A = []
for i in range(nm[0]):
    a_i = [int(s) for s in input().split()]
    A.append(a_i)
b = []
for j in range(nm[1]):
    b_j = int(input())
    b.append(b_j)

for i in range(nm[0]):
    c_i = 0
    for j in range(nm[1]):
        c_i += A[i][j] * b[j]
    print(c_i)


Measured memory_bytes: 6008
#include <iostream>
#include <sstream>
#include <string>
#include <stack>

using namespace std;

class ReversePolishNotation
{
 public:
  int solve( int n, string a[] );
};

int ReversePolishNotation::solve( int n, string a[] )
{
  stack<int> st;
  int x, y;
  stringstream ss;
  
  for( int i = 0; i < n; i++ )
    {
      if (a[i] == "+")
        {
          y = st.top();
          st.pop();
          x = st.top();
          st.pop();

          st.push(x + y);
        }
      else if (a[i] == "-")
        {
          y = st.top();
          st.pop();
          x = st.top();
          st.pop();

          st.push(x - y);
        }
      else if (a[i] == "*")
        {
          y = st.top();
          st.pop();
          x = st.top();
          st.pop();

          st.push(x * y);
        }
      else
        {
          ss << a[i];
          ss >> x;
          ss.str("");
          ss.clear(stringstream::goodbit);
          
          st.push(x);
        }
    }
  
  return st.top();
}

int main( void )
{
  string a[200];

  int n = 0;

  ReversePolishNotation *rpn = new ReversePolishNotation();

  while(cin >> a[n])
    {
      n++;
    }
  
  cout << rpn -> solve( n, a ) << endl;

  delete rpn;

  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
const int MAX = 1e5 + 10;

int main()
{	
	ll n; cin>>n; ll a[MAX];
	for(ll i=1;i<=n;i++) cin>>a[i];

	ll p[MAX]={0},s[MAX]={0};
	p[1]=a[1];	
	for(ll i=2;i<=n;i++){
		if(i%2 == 1){
			p[i] = p[i-1] + a[i];
		}
		else p[i] = p[i-1] - a[i];
	}
	s[n]=a[n];
	for(ll i=n-1;i>=1;i--){
		if(i%2 == 1){
			s[i] = s[i+1] + a[i];
		}
		else s[i] = s[i+1] - a[i];
	}	

	for(ll i=1;i<=n-1;i += 2){
		ll sum = - p[i-1] + s[i+1];

		cout<<a[i] + sum<<" "<<a[i] - sum<<" ";
	}
	
	cout<< a[n]-p[n-1];

}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END


signed main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
	int total = 0 ;
	for( int i = 0 ; i < n ; i++ ) total ^= a[i] ;
	for( int i = 0 ; i < n ; i++ ) cout << (total ^ a[i]) << " " ;
	return 0 ;
}













Measured memory_bytes: 4768