akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long x = sc.nextLong();

        long a[] = new long[n];
        long b[] = new long[n];
        long min =x;

        for(int i=0;i<n;i++) {
        	a[i] = sc.nextLong();
        	min = Math.min(min,a[i]);
        }
        long y = x -min;
        long z = a[0] - min;
        for(int i=0;i<n;i++) {
        	b[i] = a[i] -min;
        	z = gcd(z,b[i]);
        }
        z = gcd(z,y);

        System.out.println(z);

    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 60996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,x;
  cin >> n >> x;
  ll ans = 1;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  ll now = 0;
  rep(i, n) { 
    now = now + l[i];
    if (now <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3516
#include<stdio.h>
#define MAX 10000001

int main()
{
  int n,i,j,k;
  scanf("%d",&n);
  int row[n];
  int column[n];
  int dp[n][n];
 
  for(i=0;i<n;i++) scanf("%d %d",&row[i],&column[i]);
    
   
  for(i=0;i<n;i++){
      for(j=0;j<n;j++)
    {
      dp[i][j]=MAX;
    }
    }
   
  for(i=0;i<n;i++){
      dp[i][i]=0;
    }
  
  for(j=0;j<n;j++){
      for(i=0;i<n-j;i++){
      for(k=i+1;k<=i+j;k++){
          dp[i][i+j]=min(dp[i][i+j],dp[i][k-1]+dp[k][i+j]+row[i]*column[k-1]*column[i+j]);
        }
    }
    }
  printf("%d\n",dp[0][n-1]);
  
  return 0;
}
  
int min(int a,int b)
{
  if(a<b)
    {
      return a;
    }
  return b;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int sum1=0,sum2=0,x;
    for(int i=0;i<4;i++){
        cin >> x;
        sum1 += x;
    }
    for(int i=0;i<4;i++){
        cin >> x;
        sum2 += x;
    }
    if(sum1>sum2)   cout << sum1 << "\n";
    else    cout << sum2 << "\n";
    return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
int n,check[1000010],cnt=1;
int main()
{
    scanf("%d",&n);
    while(check[n]==0)
    {
        check[n]=1;
        if(n%2==0)
        {
            n/=2;
        }
        else
        {
            n=3*n+1;
        }
        cnt++;
    }
    printf("%d",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  string s;
  cin >> s;
  vector<pair<int,ll int> > d;
  char old = s[0];
  int cnt = 1;
  bool flag = true;
  for(int i = 1; i < s.size(); i++){
    if(old == s[i]){
      cnt++;
      flag = true;
    }else{
      int kind = ((s[i-1] == '<') ? 0 : 1);
      d.pb(mp(kind, cnt));
      flag = false;
      cnt = 1;
    }
    old = s[i];
  }
  int kind = ((s[(ll int)s.size()-1] == '<') ? 0 : 1);
  d.pb(mp(kind, cnt));

  ll int o = 0;
  ll int sum = 0;
  for(int i = 0; i < d.size(); i++){
    // cout << d[i].first << " " << d[i].second << endl;
  }
  for(int i = d.size() - 1; i >= 0; i--){
    if(d[i].first == 0){
      //up
      ll int tmp = max(d[i].second, o);
      sum += tmp;
      sum += (d[i].second-1)*d[i].second/2;
      // cout << "1 to " << tmp << endl;
      o = 0;
    }else{
      //down
      ll int tmp = d[i].second;
      sum += tmp * (tmp-1) / 2;
      // cout << "0 to" << tmp-1 << endl;
      o = tmp;
    }
  }
  sum += o;
  cout << sum << endl;
}

Measured memory_bytes: 6648
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a, b, dpb[100100], dpw[100100];
vector<int> e[100100];

int wh(int v, int p);

int bl(int v, int p) {
	int &res = dpb[v];
	if (res!=-1) return res;
	res = 1;
	each(i,e[v]) if (i!=p) (res *= wh(i,v)) %= mod;
	return res;
}

int wh(int v, int p) {
	int &res = dpw[v];
	if (res!=-1) return res;
	res = 1;
	each(i,e[v]) if (i!=p) (res *= bl(i,v) + wh(i,v)) %= mod;
	return res;
}

signed main() {
	cin >> n;
	rep(i,n-1) {
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b), e[b].push_back(a);
	}
	memset(dpb, -1, sizeof(dpb)), memset(dpw, -1, sizeof(dpw));
	cout << (bl(0,-1) + wh(0,-1)) %mod << endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int p[9] = {};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a >= 3200) a = 3200;
        p[a / 400]++;
    }

    int m = 0;
    for (int i = 0; i < 8; i++) {
        if (p[i] > 0) m++;
    }

    cout << m + (m == 0 && p[8] > 0) << ' ' << m + p[8] << endl;

    return 0;
}

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

int R, C;
int senbei[10000];
int numofbit(int bits){
    int num=0;
    for(;bits!=0;bits&=bits-1){
        num++;
    }
    return num;
}
int solve(int i, int j, int senbei[]){
    int a, b, k, x;
    int sum=0;
    x = 1;
    x <<= i;
    if(i<R){
        if(j){
            for(k=0;k<C;k++){
                senbei[k] ^= x;
            }
        }
        a = solve(i+1, 0, senbei);
        b = solve(i+1, 1, senbei);
        if(a > b){
            return a;
        }else{
            return b;
        }
    }else{
        for(k=0;k<C;k++){
            a = numofbit(senbei[k]);
            sum += (R-a>a) ? R-a : a ;
        }
        return sum;
    }
}
            
int main(){
    int i, j;
    int a, b;
    cin >> R >> C;
    while(R || C){
        for(j=0;j<C;j++){
            senbei[j] = 0;
        }
        for(i=0;i<R;i++){
            for(j=0;j<C;j++){
                cin >> a;
                senbei[j] += a<<=i;
            }
        }
        //for(i=0;i<C;i++){
        //    cout << senbei[i] << endl;
        //}
        a = solve(0,0,senbei);
        b = solve(0,1,senbei);
        cout << ((a>b)?a:b) << endl;
        cin >> R >> C;
    }
}

Measured memory_bytes: 904
if let input_line = readLine(), let number = Int(input_line) {
	let b = number % 10
  	switch b {
      case 2,4,5,7,9: print("hon")
      case 0,1,6,8:   print("pon")
      case 3:         print("bon")
      default:        print("error")
    }
}

Measured memory_bytes: 7636
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
	int n;
	cin>>n;
	ll dp[4][4][4][n+1];
	rep0(i,4)rep0(j,4)rep0(k,4)rep0(l,n+1) dp[i][j][k][l]=0;
	rep0(i,4)rep0(j,4)rep0(k,4){
		if(i==0&&j==2&&k==1) dp[i][j][k][3]=0;
		else if(i==0&&j==1&&k==2) dp[i][j][k][3]=0;
		else if(i==2&&j==0&&k==1) dp[i][j][k][3]=0;
		else{
			dp[i][j][k][3]=1;
		}
	}
	//A->0,C->1,G->2,T->3
	ll mod=1e9+7;
	ll ans=0;
	for(int l=3;l<=n-1;l++)rep0(i,4)rep0(j,4)rep0(k,4){
		if(j==2&&k==1){
			if(i==0) dp[i][j][k][l+1]=0;
			else{
				dp[i][j][k][l+1]=(dp[1][i][j][l]+dp[2][i][j][l]+dp[3][i][j][l])%mod;
			}
		}
		else if(i==0&&j==1&&k==2){
			dp[i][j][k][l+1]=0;
		}
		else if(i==2&&j==0&&k==1){
			dp[i][j][k][l+1]=0;
		}
		else if(i==2&&j==3&&k==1){
			dp[i][j][k][l+1]=(dp[1][i][j][l]+dp[2][i][j][l]+dp[3][i][j][l])%mod;
		}
		else{
			dp[i][j][k][l+1]=(dp[0][i][j][l]+dp[1][i][j][l]+dp[2][i][j][l]+dp[3][i][j][l])%mod;
		}
	}

	rep0(i,4)rep0(j,4)rep0(k,4){
		ans=(ans+dp[i][j][k][n])%mod;
	}
	cout<<ans<<endl;

	return 0;
}

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


using namespace std;

int main(){
  int  N, K;
  cin >> N >> K;
  
  vector<int> V(N);
  
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  sort(V.begin(), V.end());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += V[N-1-i];
  }
  cout << ans;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m;
    cin >> n >> m;
    vector<pii> ab(n);
    REP(i,n){
        int32 a, b;
        cin >> a >> b;
        ab[i] = pii(a,b);
    }
    sort(ALL(ab));
    priority_queue<int32> pq;
    int32 s = 0;
    int64 ans = 0;
    REP(i,m+1){
        while(s < n && ab[s].first <= i){
            pq.push(ab[s].second);
            s++;
        }
        if(pq.empty())continue;
        ans += pq.top();
        pq.pop();
    }
    ANS(ans);
    return 0;
}

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

bool f=false;

int main() {
  string s;
  cin>>s;
  int n0=0,n1=0;
  rep(i,s.size()){
    if(s.at(i)=='0') n0++;
    else n1++;
  }
  cout << 2*min(n0,n1) <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
namespace std {
  bool operator < (const P& a, const P& b) { return a.second != b.second ? a.second > b.second : a.first < b.first; }
}

vector<int> split(string &str, char delim){
  stringstream ss(str);
  string tmp;
  vector<int> res;
  while(getline(ss, tmp, delim)) res.push_back(atoi(tmp.c_str()));
  return res;
}

int solve(vector<int> v){
  int t = 1, i = 1, res = 0;
  while(i < v.size()){
    if(t >= 10){
      res += v[i++];
    } else if(v[i] >= 10){
      res += v[i] + v[i + 1] + v[i + 2];
      ++i;
      ++t;
    } else if(v[i] + v[i + 1] >= 10){
      res += v[i] + v[i + 1] + v[i + 2];
      i += 2;
      ++t;
    } else{
      res += v[i] + v[i + 1];
      i += 2;
      ++t;
    }
  }
  return res;
}

int main() {
  int N;
  while(cin >>N && N){
    vector<P> ps(N);
    string s; getline(cin, s);
    REP(i, N){
      getline(cin, s);
      vector<int> v = split(s, ' ');
      ps[i] = P(v[0], solve(v));
    }
    SORT(ps);
    REP(i, ps.size()) cout <<ps[i].first <<" " <<ps[i].second <<endl;
  }
  return 0;
}

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


double calc(vector<double> x,vector<double> y,double X){
	int n = x.size();
	double answer = 0;
	for(int i = 0 ; i < n ; i++){
		double sub = y[i];
		for(int j = 0 ; j < n ; j++){
			if( i != j ){
				sub *= (X-x[j]);
				sub /= (x[i]-x[j]);
			}
		}
		answer += sub;
	}
	return answer;
}
int main(){
	int d;
	while(cin >> d && d){
		vector<double> v(d+3);
		for(int i = 0 ; i < v.size() ; i++) cin >> v[i];
		vector<int> vote(v.size(),0);
		for(int i = 0 ; i < v.size() ; i++){
			vector<double> x,y;
			for(int j = 0 ; j < v.size() ; j++){
				if( i != j ){
					x.push_back(j);
					y.push_back(v[j]);
				}
			}
			x.resize(d+1);
			y.resize(d+1);
			int ok = 1;
			for(int j = 0 ; j < v.size() ; j++){
				if( i != j && abs(calc(x,y,j)-v[j]) > 0.5 ) ok = 0;
			}
			if( ok ){
				cout << i << endl;
				break;
			}
		}

	}
}

Measured memory_bytes: 1256
def P(*a)puts a.join" ";end;l=gets.to_i;n=l.bit_length;P n,n*2+l.to_s(2).count(?1)-3;(n-1).times{|i|P i+1,i+2,0;P i+1,i+2,1<<i;P i+1,n,l-=1<<i if l[i]==1}

Measured memory_bytes: 1788
#include <iostream>
#include <string>

using namespace std;

int main(){
        int H,W;
        cin >> H >> W;
        for(int i=0;i<W+2;i++){
                cout << '#';
        }
        cout << endl;
        for(int i=0;i<H;i++){
                string s;
                cin >> s;
                cout << '#' << s << '#' << endl;
        }
        for(int i=0;i<W+2;i++){
                cout << '#';
        }
        return 0;
}

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

int main() {
  ll n; cin >> n;
  vector <ll> x(n), y(n);
  vector <pair <ll, ll>> h(n, pair <ll, ll> ());
  rep(i, n) {
    cin >> x.at(i) >> y.at(i) >> h.at(i).first;
    h.at(i).second = i;
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  rep(i, 101) {
    rep(j, 101) {
      bool flag = 1;
      ll res_h;
      rep(k, n) {
        ll loc = h.at(k).second;
        if (k) {
          if (h.at(k).first) {
            if (res_h != h.at(k).first+abs(i-x.at(loc))+abs(j-y.at(loc))) flag = 0;
          } else {
            if (res_h-abs(i-x.at(loc))-abs(j-y.at(loc)) > 0) flag = 0;
          }
        } else {
          res_h = h.at(k).first+abs(i-x.at(loc))+abs(j-y.at(loc));
        }
      }
      if (flag) {
        cout << i << ' ' << j << ' ' << res_h << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main() {
  //input
  int N;
  cin >> N;
  int a[N],b[N];
  for(int i=0; i<N; i++){cin>>a[i];b[i]=a[i];}
  
  //main
  sort(a,a+N,greater<int>());
  int max = a[0];
  int max2 = a[1];
  
  //output
  for(int i=0; i<N; i++){
    if(b[i]==max) cout << max2 << endl;
    else cout << max << endl;
  }
}

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int sum=0;
    cin >> N;
    for (int i =0; i< N; i++){
        int l, r;
        cin >> l >> r;
        sum+=r-l+1;
        }
        std::cout << sum << std::endl;
}


Measured memory_bytes: 256
a, b = [int(i) for i in input().split()]
sum = 0
if a > b:
	sum += a
	a -= 1
else:
	sum += b
	b -= 1
	
if a > b:
	sum += a
	a -= 1
else:
	sum += b
	b -= 1
	
print(sum)

Measured memory_bytes: 2940
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,y=LI()

  for i in range(n+1):
    for j in range(0,n-i+1):
      k=n-(i+j)
      if i*10000+j*5000+k*1000==y:
        print(i,j,k)
        exit()
  print(-1,-1,-1)

main()
# print(main())


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

int main() {
    int n;
    cin >> n;
    int m = n;
    int s = 0;
    while (m > 0) {
        s += m % 10;
        m /= 10;
    }
    if (n % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int H, W;
    scan(H, W);
    auto a = iota(H).map!(i => readln.chomp.to!(char[])).array;
    a = a.filter!(s => s.any!"a == '#'").array;
    H = a.length.to!int;
    auto b = new bool[](W);
    foreach (j ; 0 .. W) {
        foreach (i ; 0 .. H) {
            if (a[i][j] == '#') b[j] = true;
        }
    }

    foreach (i ; 0 .. H) {
        foreach (j ; 0 .. W) {
            if (b[j]) write(a[i][j]);
        }
        writeln;
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    long long n, x, max1 = 0, max2 = 0, ans = 0;
    cin >> x;
    for (int i = 0; i < 100000; i++){
        if ((i * (i + 1)) / 2 <= x && x <= ((i + 2) * (i + 1)) / 2){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d %d",&a, &b);
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2692
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int total = 0;
        total = (int) (k * Math.pow((k - 1), (n - 1)));
        System.out.println(total);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21204
/*
 * Distance2.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <iomanip>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main(void) {

	int n = 0;
	cin >> n;

	vector<int> vecX, vecY;
	for (unsigned int i = 0; i < n; i++) {
		int iX = 0;
		cin >> iX;
		vecX.push_back(iX);
	}

	for (unsigned int i = 0; i < n; i++) {
		int iY = 0;
		cin >> iY;
		vecY.push_back(iY);
	}

	double dDistance1 	= 0.0;	// p = 1
	double dDistance2 	= 0.0;	// p = 2
	double dDistance3 	= 0.0;	// p = 3
	double dDistanceInf = 0.0;	// p = infinity
	vector<double> vecInf;
	for (unsigned int j = 0; j < vecX.size(); j++) {
		dDistance1 += fabs(vecX.at(j) - vecY.at(j));
		dDistance2 += pow(fabs(vecX.at(j) - vecY.at(j)), 2.0);
		dDistance3 += pow(fabs(vecX.at(j) - vecY.at(j)), 3.0);
		vecInf.push_back(fabs(vecX.at(j) - vecY.at(j)));
	}
	dDistance2		= sqrt(dDistance2);
	dDistance3 		= cbrt(dDistance3);
	dDistanceInf 	= *max_element(vecInf.begin(), vecInf.end());

	cout << fixed << setprecision(6) << dDistance1 << endl;
	cout << fixed << setprecision(6) << dDistance2 << endl;
	cout << fixed << setprecision(6) << dDistance3 << endl;
	cout << fixed << setprecision(6) << dDistanceInf << endl;

	return 0;
}

Measured memory_bytes: 1364
import sys
input=sys.stdin.readline
from bisect import bisect_left
class SegmentTree():
    def __init__(self,size,func,default):
        self.leaf=2**(size-1).bit_length()
        self.data=[default]*(2*self.leaf-1)
        self.f=func; self.d=default
    def rangeupdate(self,l,r,x):
        l+=self.leaf-1; r+=self.leaf-1
        while l<r:
            if not l&1:
                self.data[l]=self.f(self.data[l],x)
                l+=1
            if not r&1:
                r-=1
                self.data[r]=self.f(self.data[r],x)
            l>>=1; r>>=1
    def getvalue(self,i):
        k=i+self.leaf-1
        ret=self.d
        while k>=0:
            ret=self.f(ret,self.data[k])
            k=(k-1)>>1
        return ret

n,q=map(int,input().split())
seg=SegmentTree(q,min,float('inf'))
STX=[list(map(int,input().split())) for _ in range(n)]
D=[int(input()) for _ in range(q)]
for s,t,x in STX:
    seg.rangeupdate(bisect_left(D,s-x),bisect_left(D,t-x),x)
for i in range(q):
    print(-1 if seg.getvalue(i)==float('inf') else seg.getvalue(i))

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    string ans = "";
    while(n--){
        ans += "ACL";
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,k,x,ans=0,tem;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x;
		tem = min(x*2,abs(k-x)*2);
		ans += tem;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[100010];
    rep(i, N) cin >> A[i];
    priority_queue<int> que;
    rep(i, N) que.push(A[i]);
    rep(i, M) {
        int num = que.top(); que.pop();
        num /= 2;
        que.push(num);
    }
    int ans = 0;
    while(!que.empty()) {
        ans += que.top(); que.pop();
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n;
PII e[N];
VI g[N];
int col[N];

void dfs(int v, int p = -1)
{
	int ban = -1;
	for(auto i: g[v])
	{
		int to = e[i].Y;
		if (to == p) ban = col[i / 2];
	}
	
	int curr = 0;
	for(auto i: g[v])
	{
		int to = e[i].Y;
		if (to == p) continue;
		if (curr == ban)
			curr++;
		col[i / 2] = curr++;
		dfs(to, v);
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	cin >> n;
	FOR(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		g[u].PB(2 * i);
		g[v].PB(2 * i + 1);
		e[2 * i] = {u, v};
		e[2 * i + 1] = {v, u};
	}
	
	int mx = 0;
	FOR(i, 1, n + 1) mx = max(mx, SZ(g[i]));
	cout << mx << endl;
	
	FOR(i, 1, n + 1) if (SZ(g[i]) == 1)
	{
		dfs(i, -1);
		break;
	}
	
	FOR(i, 0, n - 1) cout << col[i] + 1 << '\n';	
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 14208
#include <iostream>

using namespace std;


int main(void) {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int pos = A > B ? (A > C ? 0 : 2): B > C ? 1 : 2;
  for(int i = 0; i < K; i++) {
    switch(pos) {
      case 0:
        A *= 2;
        break;
      case 1:
        B *= 2;
        break;
      case 2:
        C *= 2;
        break;
      default:
        cout << "ERROR" << endl;
        break;
    }
  }
    cout << A + B + C << endl;
 	return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0; 
	for(int i=1;i<=n-1;i++) ans += i;
	cout << ans << endl;
    
	return 0;
}


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


using namespace std;

int main() {


	int n;
	string s;

	cin >> n;
	cin >> s;

	char* chrs = new char[s.size() + 1];
	strcpy(chrs,  s.c_str());

	for (int i = 0;i < s.size();i++) {

		int c = chrs[i] + n;
		if (c > 90) {
			c = c - 26;
		}
		chrs[i] = c;
	}


	cout << chrs << endl;
	return 0;
}



Measured memory_bytes: 256
N = gets.to_i
MAX_NUM = 3500

1.upto(MAX_NUM) do |h|
  1.upto(MAX_NUM) do |n|
    numerator = N * h * n
    denominator = 4 * h * n - N * n - N * h
    next if denominator.zero? || !(numerator % denominator).zero?

    w = numerator / denominator
    if w.positive?
      puts "#{h} #{n} #{w}"
      exit
    end
  end
end

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int m = 1e9;
  int ans = 0;
  rep(i, n) if (p[i] < m) {
    ++ans;
    m = p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4040
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static int n; // switch count
        static int m; // bulb count
        static bulb[] bulbs;

        static void Main(string[] args)
        {
            // read n, m;
            string[] nm = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(nm[0]);
            m = Convert.ToInt32(nm[1]);

            bulbs = new bulb[m];

            for (int i = 0; i < m; i++)
            {
                // read bulb's switch
                bulbs[i] = new bulb()
                {
                    switches = returnSwitch(Console.ReadLine().Split(' '))
                };
            }

            string[] ps = Console.ReadLine().Split(' ');
            for (int i = 0; i < m; i++)
            {
                // read bulb's p
                bulbs[i].p = Convert.ToInt32(ps[i]);
            }

            int count = isBulbsAllOn(true, 0, new bool[n]) + isBulbsAllOn(false, 0, new bool[n]);

            Console.WriteLine(count);
        }

        static int isBulbsAllOn(bool switchOn, int now, bool[] switches)
        {
            // switches option
            switches[now] = switchOn;
            now++;

            if (now < n)
            {
                return isBulbsAllOn(true, now, (bool[])switches.Clone()) + isBulbsAllOn(false, now, switches.ToArray());
            }
            else // all bulbs on check
            {
                for (int i = 0; i < m; i++)
                {
                    bulb b = bulbs[i];
                    int swCnt = 0;
                    for (int j = 0; j < b.switches.Length; j++)
                    {
                        if (switches[b.switches[j]])
                            swCnt++;
                    }
                    if (b.p == 0 && swCnt % 2 == 0) // even
                    {

                    }
                    else if (b.p == 1 && swCnt % 2 == 1) // odd
                    {

                    }
                    else // bulb is off
                        return 0;
                }
                return 1;
            }
        }

        // get switches from string
        static int[] returnSwitch(string[] s)
        {
            int n = Convert.ToInt32(s[0]);
            int[] result = new int[n];
            for (int i = 1; i <= n; i++)
            {
                result[i - 1] = Convert.ToInt32(s[i]) - 1;
            }
            return result;
        }
    }

    class bulb
    {
        public int[] switches;
        public int p = 0;
    }



Measured memory_bytes: 13396
#include <stdio.h>
#include<string>
#include<string.h>
#include <math.h>
#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace  std;

void init()
{


#ifdef _WIN32
	freopen("1.txt", "r", stdin);
#endif
}

void func();

int main()
{
	init();
	func();

	return 0;
}

#define foreach(i,n) for(i=0;i<n;++i)
#define foreachd(i,n) for(int i=0;i<n;++i)
#define printfInt1(n) printf("%d\n",n)
#define scanfInt1(n) scanf("%d",&n)
#define scanfInt2(a,b) scanf("%d%d", &a, &b)
void func()
{
	int a,b;
	while(~scanfInt2(a,b))
	{
		char s[100];
		sprintf(s, "%d", a+b);
		printfInt1(strlen(s));
	}
}

Measured memory_bytes: 1200
using System;
class Program{
	static void Main(){
		string ans="x";
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		if(s[0]+s[1]==15){ans="+";}
		else if(s[0]*s[1]==15){ans="*";}
		Console.WriteLine(ans);
	}
}

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

int main(){
  int H,A;
  cin >> H >> A;
  
  int counter=0;
  while(H>0){
    H -= A;
    counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1e+16;

void solve(istream &cin) {
    ll L ;
    if (!(cin >> L)) { return; }
    vector<ll> A;
    ll sum = 0;
    for (int i = 0; i < L; ++i) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
        sum += tmp;
    } // end i
    vector<array<ll, 5>> dp(L+1);
    dp[0] = {0, 0, 0, 0, 0};
    for (int i = 0; i < L; ++i) {
        ll odd = A[i] % 2ll;
        ll even = A[i] % 2ll == 0;
        bool zero = A[i] == 0;
        dp[i+1][0] = dp[i][0] + A[i];
        dp[i+1][1] = min(dp[i][1], dp[i][0]) + (zero ? 2 : odd);
        dp[i+1][2] = min({dp[i][0], dp[i][1], dp[i][2]}) + even;
        dp[i+1][3] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) +
                (zero? 2 : odd);
        dp[i+1][4] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]})
                          + A[i];
    } // end i
    cout << *min_element(dp.back().begin(), dp.back().end()) << endl;

}

int main(int argc, char *argv[]) {
    string FileName("D"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}



Measured memory_bytes: 9712
#include <stdio.h>

int main()
{
	int count = 0, x[10], i, max = 0, max2 = 0, max3 = 0;
	while (count < 10)
	{
		scanf("%d", &i);
		x[count] = i;
		if(max < x[count])
		{
			max3 = max2;
			max2 = max;
			max = x[count];
		}else{
			if(max2 < x[count])
			{
				max3 = max2;
				max2 = x[count];
			}else if(max3 < x[count])
			{
				max3 = x[count];
			}
		}
		count++;
	}
	
	printf("%d\n%d\n%d\n", max, max2, max3);

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,M;
vector<int> L,R;

int imos[100010];

int main(){
  cin>>N>>M;
  L.resize(M);
  R.resize(M);

  for(int i=0;i<M;i++) cin>>L[i]>>R[i];

  for(int i=0;i<M;i++){
    imos[L[i]]++;
    imos[R[i]+1]--;
  }

  for(int i=1;i<=N+1;i++) imos[i]+=imos[i-1];

  int ans=0;
  for(int i=1;i<=N;i++){
    if(imos[i]>=M) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pl = pair<ll,ll>;

const ll INF = LLONG_MAX/3;

int main(){
    int n;
    scanf(" %d", &n);
    vector<pl> v(n);
    rep(i,n){
        ll a,b;
        scanf(" %lld %lld", &a, &b);
        v[i] = {a,b};
    }

    sort(all(v));

    vector<ll> preb(n);
    preb[0] = v[0].se;
    for(int i=1; i<n; ++i) preb[i] = preb[i-1]+v[i].se;

    ll sub = preb[n-2];
    ll ans = 0;

    ll mx = -INF;
    for(int i=n-1; i>=0; --i){
        mx = max(mx, preb[i]-v[i].fi);
        ans = max(ans, mx-sub+v[i].fi);
        if(i>0) sub -= v[i-1].se;
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 14456
# coding:utf-8
import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[0 for i in range(4)] for j in range(n)]
index = 0
result[index] = array[0][0:4]
for i in range(1,n):
    if result[index][0:3] == array[i][0:3]:
        result[index][3] += array[i][3]
    elif result[index][0:3] != array[i][0:3]:
        index += 1
        result[index] = array[i][0:]
index = 0
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == result[index][0] - 1 and j == result[index][1] - 1 and k == result[index][2] - 1):
                print result[index][3],
                if index != len(result) - 1:
                    index += 1
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "####################"



Measured memory_bytes: 4716
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb             push_back
#define  ll             long long int
#define  nl             printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);

#define  max3(a,b,c) max(a,max(b,c))


int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 4e5 + 5;
const int N1            = 1e5 + 5;


 
int solve() 
{
	//happy coding
	ll n ,m ;
	cin>>n>>m;
	if(n!=1&&m!=1)
	cout<<(ll)((ll)n*(ll)m+1)/2<<endl;
	else cout<<1<<endl;
	/*if(n&1){
		int a = (n+1)/2;
		if(m%2==0){
			cout<<(a+(a-1))*m/2<<endl;
		}else{
			ll x = (m+1)/2;
			ll z = a*x;
			x--;a--;
			ll z1 = x*a;
			cout<<z+z1<<endl;
		}

	}else{
		cout<<(ll)((n/2)*m)<<endl;
	}*/
	
	return 0;

	//error();
}

int main(){
	
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--){
		solve();
	}


	return 0;
}

Measured memory_bytes: 256
/*
    ||S|A|M|R|A|T||
    Author:codingsamrat
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long 
#define ld long double
#define INF LONG_MAX
#define pb push_back
#define gcd __gcd
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<int>
#define vll vector<long long>
typedef long long  ll;

ll bpow(ll a, ll b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
	int n;
	cin>>n;
	int a[n];
	f(i,0,n)
	cin>>a[i];
	int b[n]={0};
	int XOR = 0; 
    for(int i = 0; i < n; i++) 
    XOR ^= a[i];
    f(i,0,n)
    b[i]=XOR^a[i];
	
	f(i,0,n)
	cout<<b[i]<<" ";
	
return 0;

}


Measured memory_bytes: 6776
#include <stdio.h>
#include <string.h>
int main (void)
{
	char s[10];
	scanf("%s",s);
	if (s[0] == 'M')
		printf("6\n");
	else if(s[0] =='T' && s[1] == 'U')
		printf("5\n");
	else if(s[0] == 'W')
		printf("4\n");
	else if(s[0] == 'T')
		printf("3\n");
	else if(s[0] == 'F')
		printf("2\n");
	else if(s[0] == 'S' && s[1] == 'A')
		printf("1\n");
	else
		printf("7\n");
	return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int n=32;
int k,f[100][10];
int sum[100];
void dfs(int i,int j,int k)
{
    if(i==1)
    {
        printf("%d",j);
        return;
    }
    printf("%d",j);
    if(j==1)
    {   
        if(k==1)
        {
            for(int cl=1;cl<i;cl++)
            printf("0");
            return;
        }
        k--;
        for(int tp=1;tp<i;tp++)
        {
            if(f[tp][1]<k)
            {
                k-=f[tp][1];
            }
            else
            {   
                for(int cl=i-1;cl>tp;cl--)
                printf("0");
                dfs(tp,1,k);
                return;
            }
            
        }
        dfs(i-1,2,k);
        return;
    }
    if(j==9)
    {
        if(f[i-1][8]<k)
        {
            k-=f[i-1][8];
        }
        else
        {
            dfs(i-1,8,k);
            return;
        }
        dfs(i-1,9,k);
        return;
    }
    if(f[i-1][j-1]<k)
        k-=f[i-1][j-1];
    else
    {
        dfs(i-1,j-1,k);
        return;
    }
     if(f[i-1][j]<k)
        k-=f[i-1][j];
    else
    {
        dfs(i-1,j,k);
        return;
    }
     if(f[i-1][j+1]<k)
        k-=f[i-1][j+1];
    else
    {
        dfs(i-1,j+1,k);
        return;
    }
    
}
int main()
{   
    scanf("%d",&k);
    for(int i=1;i<=9;i++) f[1][i]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=2;j<=8;j++)
        {
            f[i][j]=f[i-1][j-1]+f[i-1][j+1]+f[i-1][j];
        }
        for(int j=1;j<i;j++)
        f[i][1]+=f[j][1];
        f[i][1]+=f[i-1][2];
        f[i][1]+=1;
        f[i][9]=f[i-1][8]+f[i-1][9];
        for(int j=1;j<=9;j++) sum[i]+=f[i][j];
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=9;j++)
        {
            if(f[i][j]<k)
            {
                k-=f[i][j];
            }
            else
            {
                dfs(i,j,k);
                return 0;
            }
            
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef long long ll;
#define MOD 1000000007;


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

    int n; cin >> n;
    if(n >= 400 && n <= 599){
        cout << 8 << endl;
        return 0;
    }
    if(n >= 600 && n <= 799){
        cout << 7 << endl;
        return 0;
    }
    if(n >= 800 && n <= 999){
        cout << 6 << endl;
        return 0;
    }
    if(n >= 1000 && n <= 1199){
        cout << 5 << endl;
        return 0;
    }
    if(n >= 1200 && n <= 1399){
        cout << 4 << endl;
        return 0;
    }
    if(n >= 1400 && n <= 1599){
        cout << 3 << endl;
        return 0;
    }
    if(n >= 1600 && n <= 1799){
        cout << 2 << endl;
        return 0;
    }
    if(n >= 1800 && n <= 1999){
        cout << 1 << endl;
        return 0;
    }
    
}

Measured memory_bytes: 3644