akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[1000000];
  cin >> s;
  int x=0,y=0;
  for(int i=0;i<strlen(s);i++){
	if(i%2==0){
	  if(s[i]=='0'){
		x++;
      }
    }
	if(i%2==1){
	  if(s[i]=='1'){
		x++;
      }
    }
  }
  for(int i=0;i<strlen(s);i++){
	if(i%2==0){
	  if(s[i]=='1'){
		y++;
      }
    }
	if(i%2==1){
	  if(s[i]=='0'){
		y++;
      }
    }
  }
  if(y<x){
	x=y;
  }
  cout << x;
}


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

import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		
		int begin = 0;
		int end = 0;
		int res = 0;
		
		while (end < s.length()) {
			char c = s.charAt(end);
			if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
				res = Math.max(res, end - begin + 1);
				end++;
			} else {
				end++;
				begin = end;
			}
		}
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";

signed main()
{
	//freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	int ans = 0;
	for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++)
	for(int k = 1; k<=n; k++) ans++;
	cout<<ans<<"\n";
	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<set>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )

class Cube{
    public:
    string f, order;
    int y, x, p, c;
    Cube(int y=0, int x=0, string o=""):y(y), x(x), order(o){
	f = "rmbygc"; rep(i, 6) p = 0; c = 0;
    }
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
	char t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
    void rolld(int r){
	if ( r == 0 ) rep(i, 3) roll_y();
	else if ( r == 1 ) roll_x();
	else if ( r == 2 ) roll_y();
	else rep(i, 3) roll_x();
    }
    bool operator < ( const Cube &c) const{
	if ( x != c.x ) return x < c.x;
	if ( y != c.y ) return y < c.y;
	if ( p != c.p ) return p < c.p;
	if ( f != c.f ) return f < c.f;
	return false;
    }
};

#define MAX 32
int W, H;
char G[MAX][MAX];

int bfs(Cube s){
    queue<Cube> Q;
    set<Cube> V;
    Q.push(s);

    static const int dy[4] = {0, -1, 0, 1};
    static const int dx[4] = {1, 0, -1, 0};

    Cube u, v;
    int ny, nx;
    while(!Q.empty()){
	u = Q.front(); Q.pop();
	if ( u.p == 6 ) return u.c;
	rep(r, 4){
	    ny = u.y + dy[r];
	    nx = u.x + dx[r];
	    if ( G[ny][nx] == 'k' ) continue;
	    v = u;
	    v.rolld(r);
	    if ( G[ny][nx] == 'w' || G[ny][nx] == u.order[u.p] && v.f[0] == G[ny][nx]){
		v.c++;
		v.y = ny;
		v.x = nx;
		if ( G[ny][nx] != 'w' ) v.p++;
		if ( V.find(v) == V.end() ) {
		    V.insert(v);
		    Q.push(v);
		}
	    }
	}
    }
    return -1;
}

main(){
    Cube init;
    int y, x;
    string order;
    while( cin >> W >> H && W ){
	rep(i, H+2) rep(j, W+2) G[i][j] = 'k';
	for ( int i = 1; i <= H; i++ ){
	    for ( int j = 1; j <= W; j++ ){
		cin >> G[i][j];
		if ( G[i][j] == '#' ) {
		    G[i][j] = 'w';
		    y = i; x = j;
		}
	    }
	}
	cin >> order;
	Cube init = Cube(y, x, order);
	int cost = bfs(init);
	if ( cost == -1 ) cout << "unreachable" << endl;
	else cout << cost << endl;
    }
}

Measured memory_bytes: 5496
sx,sy,tx,ty = map(int, input().split())
dx = tx-sx
dy = ty-sy

if dx >=0 and dy >=0:
    print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"D"*1+"R"*(dx+1)+"U"*(dy+1)+"L"*1+"U"*1+"L"*(dx+1)+"D"*(dy+1)+"R")

elif dx < 0 and dy >=0:
    print("U"*dy+"L"*abs(dx)+"D"*dy+"R"*abs(dx)+"D"*1+"L"*(abs(dx)+1)+"U"*(dy+1)+"R"*1+"U"*1+"R"*(abs(dx)+1)+"D"*(dy+1)+"L")

elif dx >= 0 and dy <0:
    print("D"*abs(dy)+"R"*dx+"U"*abs(dy)+"L"*dx+"U"*1+"R"*(dx+1)+"D"*(abs(dy)+1)+"L"*1+"D"*1+"L"*(dx+1)+"U"*(abs(dy)+1)+"R")

else:
    print("D"*abs(dy)+"L"*abs(dx)+"U"*abs(dy)+"R"*abs(dx)+"U"*1+"L"*(abs(dx)+1)+"D"*(abs(dy)+1)+"R"*1+"D"*1+"R"*(abs(dx)+1)+"U"*(abs(dy)+1)+"L")

Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  vector <int> c(5, 0);
  for (int i = 0; i < 3; i++) {
	  int a, b;
	  cin >> a >> b;
	  c[a]++;
	  c[b]++;
	}
  sort(c.begin(), c.end());
  if (c[1] == 1 && c[2] == 1 && c[3] == 2) {
	  cout << "YES" << endl;
	} else {
	  cout << "NO" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
#define rep(i,N) for (int i = 0; i < (N); i++)
using ll = long long;
using lb = long double;
using namespace std;
const int mod = 1000000007;

ll nCk(ll N, ll K){
    ll kid = 1;
  for(ll i = N; i > N - K; i--){
      kid = kid * i;
    }
    for(ll i = 1; i < K + 1; i++){
        kid = kid / i;
    }
  return kid;
}

ll gcd(ll P, ll Q){
  return Q ? gcd(Q,P % Q):P;
}

ll lcm(ll P, ll Q){
  return P / gcd(P,Q) * Q;
}

string change_big(string str){
  transform(str.begin(), str.end(), str.begin(), ::toupper);
  return str;
}

string change_small(string str){
  transform(str.begin(), str.end(), str.begin(), ::tolower);
  return str;
}

bool is_prime(int x){
  if(x<=1) return false;
  for(int i=2;i*i<=x;i++)
    if(x%i==0) return false;
  return true;
}

ll sum_of_num(ll num){
  ll dig;
  ll sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll how_many_break(ll n, ll m){
  ll counter = 0;
  while (n % m == 0){
    n = n / m;
    counter++;
  }
  return counter;
}

/*------------------------------------------------------------------------------------*/

int main(){
 ll N;
  cin >> N;
  ll A,B,i;
  A = 0; B = 0; i = 1;
  string S[N],T[N];
  while(i <= N){
    cin >> S[i-1] >> T[i-1];
    if(S[i-1] > T[i-1]){
      A += 3;
    }
    else if(T[i-1] > S[i-1]){
      B += 3;
    }
    else{
      A++; B++;
    }
    i++;
  }
  cout << A << " " << B << endl;
}



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

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder


using namespace std;
using namespace atcoder;

int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	dsu d(n);
	for (int i = 0; i < q; i++) {
		int t, u, v;
		scanf("%d %d %d", &t, &u, &v);
		if (t) {
			puts(d.same(u, v) ? "1" : "0");
		} else {
			d.merge(u, v);
		}
	}
	return 0;
}


Measured memory_bytes: 3932
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
  unsigned long long i, N, res = 1;
  cin >> N;
  
  for (i = 1; i <= N; i++) {
    res = res*i % (10*10*10*10*10*10*10*10*10 + 7);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
/*#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define next next228

const int N = 10000 + 7;

int n;
int c[N], value[N], p[N], deg[N], h[N];
vector<int> g[N];

void dfs(int v, int par = -1) {
	if (par == -1) h[v] = 0;
	else h[v] = h[par] + 1;
	p[v] = par;
	for (int to : g[v]) {
		if (to != par) {
			dfs(to, v);
		}
	}
}

bool cmp(int i, int j) {
	return h[i] < h[j];
}

ghost main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector< pair<int, int> > edges;
	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		edges.push_back({u, v});
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) cin >> c[i];
	if (n <= 2) {
		int sum = 0;
		for (int i = 1; i <= n; ++i) sum += c[i];
		cout << sum << '\n';
		for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
		cout << '\n';
		return 0;
	}
	sort(c + 1, c + n + 1);
	reverse(c + 1, c + n + 1);
	dfs(1);
	vector<int> ve;
	for (int i = 1; i <= n; ++i) ve.push_back(i);
	sort(ve.begin(), ve.end(), cmp);
	int ptr = 1;
	for (int i : ve) value[i] = c[ptr++];
	int res = 0;
	for (int i = 2; i <= n; ++i) res += c[i];
	cout << res << '\n';
	for (int i = 1; i <= n; ++i) cout << value[i] << ' ';
	cout << '\n';
	return 0;
} // kek ;








Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define N (4)
#define N2 (N * N)

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
    int f[N2], space, MD;
    int cost;
    
    bool operator < ( const Puzzle &p ) const {
	for ( int i = 0; i < N2; i++ ) {
	    if ( f[i] == p.f[i] ) continue;
	    return f[i] < p.f[i];
	}
	return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;

    // priority_queue????????????????????§?????§??????????????????
    // ????°????????????????????????????????????????????????±????????????????????????????????¨????????????
    bool operator < ( const State &s ) const {
	return estimated > s.estimated;
    }
};

int getAllMD( Puzzle pz ) {
    int sum = 0;
    for ( int i = 0; i < N2; i++ ) {
	if ( pz.f[i] == N2 ) continue;
	sum += MDT[i][pz.f[i] - 1];
    }

    return sum;
}

int astar( Puzzle s ) {
    priority_queue<State> PQ;
    s.MD = getAllMD( s );
    s.cost = 0;
    map<Puzzle, bool> V;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD( s );
    V[s] = true;
    PQ.push( initial );

    while ( !PQ.empty() ) {
	State st = PQ.top(); PQ.pop();
	Puzzle u = st.puzzle;

	if ( u.MD == 0 ) return u.cost;
//	V[u] = true;
	
	int sx = u.space / N;
	int sy = u.space % N;
	
	for ( int r = 0; r < 4; r++ ) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];
	    
	    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
	    Puzzle v = u;
	    
	    v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
	    v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];
	    
	    swap( v.f[sx * N + sy], v.f[tx * N + ty] );
	    v.space = tx * N +ty;

	    if ( !V[v] ) {

		v.cost++;
		State news;
		news.puzzle = v;
		news.estimated = v.cost + v.MD;
		V[v] = true;
		PQ.push( news );
	    }
	}
    }

    return -1;
}


int main()
{
    for ( int i = 0; i < N2; i++ ) {
	for ( int j = 0; j < N2; j++ ) {
	    MDT[i][j] = abs( i / N - j / N ) + abs( ( i % N ) - ( j % N ) );
	}
    }

    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
	scanf("%d", &in.f[i]);
	if ( in.f[i] == 0 ) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }

    int ans = astar( in );
    
    if ( ans != -1 ) {
	printf("%d\n", ans);
    }

    return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll now = 1000;
    
    //先読みする
    int j;
    for(int i=0;i<n;i = j+1){
        j=i;
        ll l_price = a[i];
        while(l_price >= a[j]){
            j++;
            if(j >= n){
                out(now);
                return 0;
            }
            l_price = min(l_price,a[j]);
        }
        //売る場合
        if(l_price < a[j]){
            ll rot = now/l_price;
            //out(rot);
            now -= rot*l_price;
            now += rot*a[j];
            //売る場合jをデクリメント
            j--;
        }
        //out(now);
    }
    out(now);
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vll a(n);
  ll s = 0;
  re(i, n) {
    std::cin >> a[i];
    s+=a[i];
  }
  sort(all(a));
  reverse(all(a));

  ll th = s/(4*m) + (s%(4*m)?1:0);
  re(i, m){
    if(a[i]<th){
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

int main() {
	ll t;
	rd(t);
	repi(i, 0, t) {
		ll n, k, a[100000] = {};
		cin >> n >> k;
		repi(j, 0, n) rd(a[j]);
		ll ans = a[n - 1] - a[0];
		repi(j, 0, n - 1) a[j] = a[j + 1] - a[j];
		sort(a, a + (n - 1));
		reverse(a, a + (n - 1));
		repi(j, 0, k - 1) ans -= a[j];
		ans = max(0LL, ans);
		wrln(ans);
	}
	return 0;
}



Measured memory_bytes: 3884
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d);
    cout << endl;
}


Measured memory_bytes: 256
shiki = input().split(' ')
stack = [];

for i in shiki:
    if i == '+':
        stack.append(stack.pop() + stack.pop())
    elif i == '-':
        stack.append(- stack.pop() + stack.pop())
    elif i == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(i))

print(stack.pop())

Measured memory_bytes: 7652
#include "bits/stdc++.h"
using namespace std;
bool is_prime[300000]; //?????????????´???°
int main() {
	for(int i=6;i<300000;i++) {
		if(i%7==1||i%7==6) is_prime[i]=1;
	}
	for(int i=6;i<300000;i++) {
		if(is_prime[i]&&(i%7==1||i%7==6)) {
			for(int j=i*2;j<300000;j+=i) is_prime[j]=0;
		}
	}
	int n;
	while(scanf("%d",&n),n!=1) {
		printf("%d:",n);
		for(int i=6;i<=n;i++) {
			if(is_prime[i]&&n%i==0) printf(" %d",i);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3432
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), dp(n, inf);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; --i) {
        *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    cout << lower_bound(dp.begin(), dp.end(), inf) - dp.begin() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define pii pair < int, int > 

#define pb push_back
#define pf push_front
#define pB pop_back()
#define pF pop_front()

using namespace std;

int n, m;
char s[105][105];
int dst[105][105];
int drr[] = {0, 1};
int drc[] = {1, 0};

bool chk(int i, int j)
{
	if(i < 0 || j < 0 || i >= n || j >= m) return 0;

	return 1;
}

void bfs()
{
	for(int i = 0; i < 105; i++) fill(dst[i], dst[i] + 105, 1e9);

	deque < pii > dq;
	
	if(s[0][0] == '.') dst[0][0] = 0;
	else dst[0][0] = 1;

	dq.pb({0, 0});

	while(!dq.empty()){
		pii cur = dq.front();
		dq.pF;

		int x = cur.first, y = cur.second;

		for(int i = 0; i < 2; i++){
			int r = x + drr[i], c = y + drc[i];

			if(chk(r, c)){
				int weight = 0;

				if(s[x][y] == '.' && s[r][c] == '#') weight = 1;

				if(dst[r][c] > dst[x][y] + weight){
					dst[r][c] = dst[x][y] + weight;

					if(weight == 0) dq.pf({r, c});
					else dq.pb({r, c});
				}
			}
		}
	}
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif

	cin >> n >> m;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++) cin >> s[i][j];
	}

	bfs();

	cout << dst[n - 1][m - 1] << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A.at(i) = x;
    B.at(i) = x;
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  if (B.at(0) == B.at(1)) {
    for (int i = 0; i < N; i++) {
      cout << B.at(0) << endl;
    }
  }
  else {
    for (int i = 0; i < N; i++) {
      if (A.at(i) == B.at(0)) cout << B.at(1) << endl;
      else cout << B.at(0) << endl;
    }
  }
}


Measured memory_bytes: 3200
import java.util.Scanner;

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

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			s = new int[n];
			int sum = 0;
			double m = 0, a = 0, a2 = 0;
			for (int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
				sum += s[i];
			}
			m = (double) sum / n;
			for (int i = 0; i < n; i++) {
				a2 += Math.pow((s[i] - m), 2);
			}
			a = Math.sqrt(a2 / n);
			System.out.printf("%.8f\n", a);
		}

	}
}


Measured memory_bytes: 31268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    sort(s.begin(), s.end());
    map<string, int> mp;
    vector<string> t = s;
    int sum = 0;
    t.erase(unique(t.begin(), t.end()), t.end());
    rep(i, 0, t.size()) {
        mp[t[i]] = 0;
    }
    rep(i, 0, s.size()) {
        mp[s[i]]++;
    }
    rep(i, 0, t.size()) {
        sum = max(sum, mp[t[i]]);
    }
    rep(i, 0, t.size()) {
        if(mp[t[i]] == sum) {
            cout << t[i] << endl;
        }
    }
    return 0;
}

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

struct Node {
    int parent,left,right;
    Node() : parent(-1), left(-1),right(-1){}
};

void printPre(int root, vector<Node> &v){
    if (root == -1)return;
    cout << " " << root;
    printPre(v[root].left,v);
    printPre(v[root].right,v);
}

void printIn(int root, vector<Node> &v){
    if (root == -1)return;
    printIn(v[root].left,v);
    cout << " " << root;
    printIn(v[root].right,v);
}

void printPost(int root, vector<Node> &v){
    if (root == -1)return;
    printPost(v[root].left,v);
    printPost(v[root].right,v);
    cout << " " << root;
}

int main(){
    int n;
    cin >> n;
    vector<Node> v(n);
    for (int i = 0; i < n; ++i){
        int id,left,right;
        cin >> id >> left >> right;
        v[id].left = left;
        v[id].right = right;
        v[left].parent = id;
        v[right].parent = id;
    }
    int root;
    for (int j = 0; j < n; ++j) if(v[j].parent == -1) root = j;
    cout << "Preorder" << endl;
    printPre(root,v);
    cout << endl;
    cout << "Inorder" << endl;
    printIn(root,v);
    cout << endl;
    cout << "Postorder" << endl;
    printPost(root,v);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int ans = 10000;
    for (int i = 0; i < s.size() - 2; ++i)
    {
        int t = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        ans = min(ans, abs(753 - t));
    }
    cout << ans << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];

        var tmp = n / k;

        var list = new List<long>();

        for(int i = -10; i <= 10; i++)
        {
            list.Add(Math.Abs((n - (tmp * k)) + (k * i)));
        }

        Console.WriteLine(list.Min());
    }
}

Measured memory_bytes: 13268
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();

    let mut a = vec![ vec!['.'; w]; h];
    let mut row = vec![0; h];
    let mut col = vec![0; w];
    for i in 0..h {
        a[i] = read::<String>().chars().collect();
    }

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    for i in 0..h {
        if row[i] == 0 {
            continue;
        }
        for j in 0..w {
            if col[j] == 0 {
                continue;
            }
            print!("{}", a[i][j]);
        }
        println!();
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> void chmax(T &a, const T &b){if(a<b) a=b;}
template<class T> void chmin(T &a, const T &b){if(b<a) a=b;}
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
vi dp;
int main() {
	int n; cin >> n;
    dp.resize(n + 1, INT_MAX);
    int a, length = 1;
    rep(i, 0, n) {
        cin >> a;
        if(dp[length - 1] < a) dp[length++] = a;
        else *lower_bound(dp.begin(), dp.begin() + length, a) = a;
    }
    P(length);
	return 0;
}

Measured memory_bytes: 3372
require 'prime'
pr = []
pr2 = Array.new(25, 0)
Prime.each(100) do |prime|
  pr.push(prime)
end
nu = gets.to_i
for i in 1..nu
  inst = i
  for j in 0..24
    while inst % pr[j] == 0
      pr2[j] += 1
      inst /= pr[j]
    end
    if inst == 1
      break
    end
  end
end

ans = 0
if pr2[0] >= 74
  ans += 1
end
inst1 = 0
inst2 = 0
inst3 = 0
inst4 = 0
for i in 0..24
  if pr2[i] >= 2
    inst1 += 1
  end
  if pr2[i] >= 24
    inst2 += 1
  end
  if pr2[i] >= 4
    inst3 += 1
  end
  if pr2[i] >= 14
    inst4 += 1
  end
end
ans += inst2 * (inst1 - 1)
ans += inst4 * (inst3 - 1)
ans += ((inst3 * (inst3 - 1)) / 2) * (inst1 - 2)
puts ans


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int k;
    cin >> k;
    int sum = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                int temp = __gcd(a, b);
                sum += __gcd(temp, c);
            }
        }
    }
    cout << sum;
}

Measured memory_bytes: 3624
#include<stdio.h>

#define N 45

int main() {
  int i,x;
  int data[45];
  data[0] = data[1] = 1;

  for(i = 2; i < N; i++) {
    data[i] = data[i - 1] + data[i - 2];
  }

  scanf("%d",&x);
  printf("%d\n",data[x]);

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int main()
{
	int x, y, z, k; cin >> x >> y >> z >> k;

	vector<uint64_t> as(x);
	vector<uint64_t> bs(y);
	vector<uint64_t> cs(z);
	for (auto &a : as) {
		cin >> a;
	}
	for (auto &b : bs) {
		cin >> b;
	}
	for (auto &c : cs) {
		cin >> c;
	}

	sort(as.begin(), as.end(), greater<uint64_t>());
	sort(bs.begin(), bs.end(), greater<uint64_t>());
	sort(cs.begin(), cs.end(), greater<uint64_t>());

	// 何通りあるか計算
	int count = 0;
	{
		FOR_LT(i_x, 0, x) {
			int val_x = i_x + 1;
			int k_rem_x = k / val_x;
			if (k_rem_x == 0) break;

			FOR_LT(i_y, 0, y) {
				int val_y = i_y + 1;
				int k_rem_y = k_rem_x / val_y;
				if (k_rem_y == 0) break;

				FOR_LT(i_z, 0, z) {
					int val_z = i_z + 1;
					if (k_rem_y < val_z) break;

					count++;
				}
			}
		}
	}

	// 必要な奴だけ入れる
	vector<uint64_t> scores(count);
	{
		FOR_LT(i_x, 0, x) {
			int val_x = i_x + 1;
			int k_rem_x = k / val_x;
			if (k_rem_x == 0) break;

			FOR_LT(i_y, 0, y) {
				int val_y = i_y + 1;
				int k_rem_y = k_rem_x / val_y;
				if (k_rem_y == 0) break;

				FOR_LT(i_z, 0, z) {
					int val_z = i_z + 1;
					if (k_rem_y < val_z) break;

					scores.push_back(
						as[i_x] + bs[i_y] + cs[i_z]
					);
				}
			}
		}
	}

	// ソートして出力
	sort(scores.begin(), scores.end(), greater<uint64_t>());
	for(int i = 0; i < k; i++) {
		cout << scores[i] << endl;
	}

	return 0;
}


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

vector<int> p;
int use[10000];
int ans,n,ansp[10000];
void dfs(int x){
  for(int i=0;i<(int)p.size();i++){
       if(p[x]!=p[i]) ans=p[x]-p[i];
    else continue;
    if(ans<0) ans+=n;
    if(ans>(n-1)/2) ans=n-ans;
    ansp[ans]++;
  }
  if(x+1<(int)p.size())dfs(x+1);
  }

int main(){
  while(1){
  cin>>n;
  if(n==0) break;
  int t;
  for(int i=0;i<10000;i++) use[i]=0,ansp[i]=0;
    for(int i=1;i<n;i++)t=(i*i)%n,use[t]=1;
    for(int i=0;i<n;i++) if(use[i]==1) p.push_back(i);
    dfs(0);
    for(int i=1;i<=(n-1)/2;i++) cout<<ansp[i]<<endl;
    p.clear();
  }
  return 0;
}

Measured memory_bytes: 1344
import java.util.Scanner;

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

        long ans = 0;
        for (int i=1;i<=(n+1);i++) {
            if (i>=k) {
                ans += (n - i + 2) * i - (i - 1);
                while (ans>1000000007) {
                    ans-=1000000007;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35788
from math import sqrt
N=int(input())
ans=0
for i in range(1,N+1,2):
  d=[]
  for j in range(1,int(sqrt(i))+1):
    if i%j==0:
      d.append(j)
      d.append(N//j)
  d=list(set(d))
  if len(d)==8:
    ans+=1
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<ll> flag(n, 0);
    vector<int> count(3, 0);
    rep(i, 0, n) {
        if(a[i] % 4 == 0) {
            flag[i] = 2;
        }
        else if(a[i] % 2 == 0) {
            flag[i] = 1;
        }
        count[flag[i]]++;
    }
    ll sum = 0;
    if(count[2] == count[0]) {
        cout << "Yes" << endl;
    }
    else if(count[1] == n || count[2] == n) {
        cout << "Yes" << endl;
    }
    else if(count[1] == 0 && count[2] == count[0]-1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)


typedef long long  ll;
#define endl '\n'




int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

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


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

int A, B;
void Input() {

    cin >> A >> B;
}



void Solve() {


    if(A == 1 && B == 2) {

        cout << 3 << endl;
    }
    else if(A == 2 && B == 3) {

        cout << 1 << endl;
    }
    else if(A == 3 && B == 2) {

        cout << 1 << endl;
    }
    else if(A == 2 && B == 1) {

        cout << 3 << endl;
    }
    else if(A == 1 && B == 3) {

        cout << 2 << endl;
    }
    else if(A == 3 && B == 1) {

        cout << 2 << endl;
    }



}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> svector;

int bubblesort(svector &A){
    int n = A.size();
    for (int i=0; i<n; i++)
        for (int j=n-1; j>i; j--)
            if (A[j][1] < A[j-1][1]){
                swap(A[j], A[j-1]);
            }
    return 0;
}

int selectionsort(svector &A){
	int n = A.size(), mini;
	for (int i=0; i<n; i++){
		mini = i;
		for (int j=i; j<n; j++)
			if (A[j][1] < A[mini][1])
				mini = j;
		if (i!=mini){
			swap(A[i], A[mini]);
		}
	}
	return 0;
}


int nums_out(svector &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int main(void){
	int n;
	cin>>n;
	svector tmp, A(n), B(n);
		
	for (int i=0; i<n; i++){
		cin >> A[i];
	}

	B = A;

	bubblesort(A);
	selectionsort(B);

	nums_out(A);
	cout << "Stable"<<endl;

	nums_out(B);
	if (A == B) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, B);
		if (sum_BIT(BIT, A - 1) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		if (s[B+1] < 0) {
			L = B + 2;
			R = W + 1;
			while (L < R) {
				M = (L + R) / 2;
				if (sum_BIT(BIT, M) <= tmp) L = M + 1;
				else R = M;
			}
			s[B+1] = s[left[L]];
			left[B+1] = left[L];
			left[L] = B + 1;

			if (B + 1 <= W) {
				d.key = B + 1 - s[B+1];
				d.id = B + 1;
				push(d, &h);
				add_BIT(W, BIT, B + 1, 1);
			}
		}
		for (j = left[B+1]; j >= A; j = left[j]) {
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		left[B+1] = j;
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll , ll > pll;
typedef vector < ll > vi;
#define INF (2e18)
#define eps (1e-6)
#define pb push_back
#define mp make_pair
#define modulo1e9 ((ll)1e9 + 7)

ll mn(ll a , ll b) {if (a < b) return a; return b;}
ll mx(ll a , ll b) {if (a > b) return a; return b;}

ll a , b , c;

int main(){
	
	cin >> a >> b;
	
	printf ( " %.6Lf \n" , (ld(a) / ld(b) ) ) ;
	
	
	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
v = list(map(int,input().split()))
m = 0
for i in range(n+1):
  if i > k:
    break
  s = sum(v[:i])
  h = [j for j in v[:i] if j < 0]
  h.sort()
  m = max(m,s-sum(h[:min(len(h),k-i)]))
  for j in range(1,n-i+1):
    if i+j > k:
      break
    cs = s
    cs += sum(v[-j:])
    ch = h[:]
    ch += [j for j in v[-j:] if j < 0]
    ch.sort()
    cs -= sum(ch[:min(len(ch),k-i-j)])
    m = max(m,cs)
print(m)

Measured memory_bytes: 41456
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  vector<P> A(N);
  for(Int i=0;i<N;i++){
    Int a, b;
    cin>>a>>b;
    A[i] = P(b, a);
  }

  sort(A.begin(), A.end());

  Int ans = 1;
  Int t = 0;
  
  for(Int i=0;i<N;i++){
    Int b, a; tie(b, a) = A[i];
    t += a;
    if(b < t) ans = 0;
  }

  cout<<(ans? "Yes":"No")<<endl;

  

  return 0;
}


Measured memory_bytes: 3456
import sys
n=input()
sys.setrecursionlimit(n+1000)
adj=[[] for i in range(n+1)]
for i in range(n-1):
	x, y=map(int, raw_input().split())
	adj[x].append(y)
	adj[y].append(x)
def dfs(cur, father):
	result=0
	for to in adj[cur]:
		if to!=father:
			result^=dfs(to, cur)+1
	return result
print "Alice" if dfs(1, -1) else "Bob"

Measured memory_bytes: 110716
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */

void solve(istream& cin) {
    string t;
    while(cin >> t){
        auto s = t.begin();
        for (auto i = t.rbegin(); i != t.rend(); ++i) {
            if(*s != *i){
                cout << "No\n";
                return;
            }
            s++;
        }// i
        cout << "Yes\n";
    
    }
}

int main(int argc, char *argv[]) {
    string FileName("A"), Modifier("_MEPH");
    string ExecutionName = FileName + Modifier;
    string sub(argv[0]);
    // pass消去
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

	// 数値計算もの用
    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "A_sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}


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

void ways(ll *ar ,int n ,int k){
    ll dp[n+1][k+1]={0};

    for(int j=0;j<=k;j++){
        dp[1][j] = (j<=ar[1]) ? 1 : 0;
    }

    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - ((j-ar[i]-1 >= 0) ? dp[i-1][j-1-ar[i]]:0))%mod;
            }
        }
    }
    /*
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    cout<<dp[n][k];
}

int main(){
    int n,k;
    cin>>n>>k;
    ll ar[n+1];
    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
    ways(ar,n,k);
}


Measured memory_bytes: 81688
N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        score = 1
    else:
        score = 0
    for c in '753':
        score += dfs(s+c)
    return score
 
print(dfs('0'))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;

     signed main(){
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       int dp[c-a+1][d-b+1];
       for(int i=0;i<c-a+1;i++)fill(dp[i],dp[i]+d-b+1,0);
       dp[0][0]=1;
       for(int i=0;i<c-a+1;i++)for(int j=0;j<d-b+1;j++){
          if(i!=0)dp[i][j]=(dp[i-1][j]*(b+j))%MOD;
          if(j!=0)dp[i][j]=(dp[i][j]+dp[i][j-1]*(a+i)%MOD)%MOD;
          if(i!=0&&j!=0)dp[i][j]=(MOD+dp[i][j]-dp[i-1][j-1]*(b+j-1)%MOD*(a+i-1)%MOD)%MOD;
       }
       cout<<dp[c-a][d-b]<<endl;



     }


 


 






    





      

        


Measured memory_bytes: 73836
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int a,b,sum;
  cin>>a>>b;
  sum=a+b;
  if(sum>=24)sum-=24;
  cout<<sum<<endl;
  return 0;
}


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

using namespace std;

typedef long double ld;
int N,M;
struct Color{
  ld l,a,b;
  ld dis(const Color& c1) const{
    return (c1.l-l)*(c1.l-l)+(c1.a-a)*(c1.a-a)+(c1.b-b)*(c1.b-b);
  }
};

vector<Color> V;

ld getDis(int n){

  vector<Color> added;

  for(int i = 0; i < N; i++)
    if(n&(1<<i)) added.push_back(V[i]);


  ld dis = 0;

  for(int i = 0; i < added.size(); i++)
    for(int j = i+1; j < added.size(); j++)
      dis += added[i].dis(added[j]);

  return dis;
}
ld solve(int num, int addN, int added){

  if(addN == M) return getDis(added);
  if(num == N) return 0.0;

  ld a = solve(num+1,addN+1,added+(1<<num));
  ld b = solve(num+1,addN,added);
  return max(a,b);
}

int main(){

  cin >> N >> M;
  
  for(int i = 0; i < N; i++){
    Color in;
    cin >> in.l >> in.a >> in.b;
    V.push_back(in);
  }
  
  printf("%.5Lf\n",solve(0,0,0));
  return 0;
}

Measured memory_bytes: 1272
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (x, n) = (v[0], v[1]);
    let p = read_vec::<i64>().into_iter().collect::<HashSet<_>>();

    let mut diff = std::i64::MAX;
    let mut ans = 0;
    for cand in 0..101 + 1 {
        if p.contains(&cand) {
            continue;
        }
        if (cand - x).abs() < diff {
            ans = cand;
            diff = (cand - x).abs();
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	char a[n][n]; 
	char b[m][m];
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			cin >> a[i][j];
		}
	}
	for( int i = 0; i < m; ++i ){
		for( int j = 0; j < m; ++j ){
			cin >> b[i][j];
		}
	}
	for( int k = 0; k <= (n-m); ++k ){
		for( int l = 0; l <= (n-m); ++l ){			
			bool flag = true;
			for( int i = 0; i < m; ++i ){
				for( int j = 0; j < m; ++j){
					if( a[i+k][j+l] != b[i][j] ){
						flag = false;
					}
				}
			}
			if( flag ){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n;
  int k;
  cin >> n >> k;
  // n=7: 2*2
  // n=8: 2*3 1000
  // n=10: 2*3 1010 
  //
  int i=0;
  /*
  do{
	i++;
  }while(pow(k,i) < n);
  */
  // 8 < 10
  while(pow(k,i) <= n){
	//cout << k << " " << i << " " << pow(k,i) << endl;
	i++;
  }
  //i-=1;
  cout << i << endl;
  return 0;
  
}


Measured memory_bytes: 256