akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    vector<int> pw(p.size(),0);
    for(int i=2;i<=N;i++){
        int tmp=i;
        for(int j=0;j<p.size();j++){
            while(tmp%p[j]==0){
               pw[j]++;
               tmp/=p[j];
            }
        }
    }
    int ans=0;
    for(int i=0;i<pw.size();i++){
        if(pw[i]>=74) ans++;
        if(pw[i]>=24){
            for(int j=0;j<pw.size();j++){
                if(i!=j&&pw[j]>=2) ans++;
            }
        }
        if(pw[i]>=14){
            for(int j=0;j<pw.size();j++){
                if(i!=j&&pw[j]>=4) ans++;
            }
        }
        if(pw[i]>=4){
            for(int j=i;j<pw.size();j++){
                if(i!=j&&pw[j]>=4) {
                    for(int k=0;k<pw.size();k++){
                         if(i!=k&&j!=k&&pw[k]>=2) ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

//ll dp[110][110][310];
ll dp[110][410][110];

int main(){
    ll N, W; cin >> N >> W;
    ll w1, v1; cin >> w1 >> v1;
    dp[1][0][1] = v1;
    FOR(i, 1, N){
        ll w, v; cin >> w >> v;
        w -= w1;
        REP(j, 310) REP(k, 105){
            if(j >= w) dp[i+1][j][k+1] = max(dp[i][j][k+1], dp[i][j-w][k]+v);
            else dp[i+1][j][k] = dp[i][j][k];
        }
    }
    ll ans = 0;
    REP(i, 310) REP(k, N+1){
       if(k*(w1) + i <= W) ans = max(ans, dp[N][i][k]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 36096
import java.util.*;

public class Main{

    int n,m,l,k,a,h;
    int[][] times;
    boolean[] cancold;
    int min;
    int INF = Integer.MAX_VALUE;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt(); m = sc.nextInt();
            l = sc.nextInt(); k = sc.nextInt();
            a = sc.nextInt(); h = sc.nextInt();
            if(n+m+l+k+a+h==0) break;

            cancold = new boolean[101];
            for(int i=0; i<l; i++) cancold[sc.nextInt()] = true;

            times = new int[n][n];
            for(int i=0; i<n; i++) Arrays.fill(times[i],-1);
            for(int i=0; i<k; i++){
                int x = sc.nextInt(), y = sc.nextInt();
                int t = sc.nextInt();
                times[x][y] = t;
                times[y][x] = t;
            }

            min = INF;
            dijkstra();

            if(min==INF) System.out.println("Help!");
            else System.out.println(min);
        }
    }

    void dijkstra(){
        // pos, limit, time, sumtime
        PriorityQueue<int[]> q 
            = new PriorityQueue<int[]>(n, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b){
                        return a[2] - b[2];
                    }
                });
        q.add(new int[]{a,m,0,0});
        boolean[][] v = new boolean[n][101];

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], limit = qq[1], time = qq[2];

            if(pos==h){
                if(qq[3]<m) min = Math.min(min, time-limit+(m-qq[3]));
                else min = Math.min(min, time-limit);
                continue;
            }

            if(v[pos][limit]) continue;
            v[pos][limit] = true;

            for(int i=0; i<n; i++){
                if(times[pos][i]==-1 
                   || times[pos][i]>limit) continue;
                if(cancold[i]){
                    q.add(new int[]
                        {i, m, time+times[pos][i]*2+(m-limit), 
                         qq[3]+times[pos][i]});
                }else{
                    q.add(new int[]
                        {i, limit-times[pos][i], time+times[pos][i],
                         qq[3]+times[pos][i]});
                }
            }
        }
    }


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

Measured memory_bytes: 15000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long n = in.nextLong();
			long s = in.nextLong();

			if (s == n) {
				out.println(n+1);
				return;
			}
			if (s > n) {
				out.println(-1);
				return;
			}

			// b <= √n
			for (int b = 2; b <= (int)Math.sqrt(n); b++) {
				if (ketawa(n, b) == s) {
					out.println(b);
					return;
				}
			}

			// b > √n
			long ans = LINF;
			for (int p = 1; p < Math.sqrt(n); p++) {
				if ((n-s) % p == 0) {
					long b = (n-s) / p + 1;
					if (ketawa(n, b) == s) {
						ans = Math.min(b, ans);
					}
				}
			}

			out.println(ans == LINF ? -1 : ans);
		}

		long ketawa(long n, long mod) {
			long ret = 0;
			while (n > 0) {
				ret += n % mod;
				n /= mod;
			}
			return ret;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

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

  cout << printf("%.12f", (double)L*L*L/27) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

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

    if (R < 1200)      cout << "ABC";
    else if (R < 2800) cout << "ARC";
    else               cout << "AGC";
    cout << endl;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 200005;

vector<int> G[MAXN];
int p[MAXN];

void dfs(int cur, int par) {
  p[cur] = p[par] + p[cur];
  for (int i = 0; i < G[cur].size(); ++i) {
    int next = G[cur][i];
    if (next != par) {
      dfs(next, cur);
    }
  }
}

int main() {
  int n, q;
  cin >> n >> q;

  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for (int i = 0; i < q; ++i) {
    int p_, x;
    cin >> p_ >> x;
    p_--;
    p[p_] += x;
  }

  dfs(0, -1);
  for (int i = 0; i < n; ++i) {
    cout << p[i];
    if (i == n - 1) {
      puts("");
    } else {
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2005;

int N,K, dp[MX][MX], cum[MX][MX]; // extra on the left, current

ll mul(ll a, ll b) { return a*b%MOD; }
ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
void ad(int& a, int b) { a = (a+b)%MOD; }

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    dp[N][N] = 1;
    F0Rd(sum,N+1) {
        // cout << "ZZ " << cum[1][1] << "\n";
        F0Rd(i,sum+1) {
            ad(cum[sum][i],cum[sum][i+1]);
            ad(dp[sum][i],cum[sum][i]);
        }
        FORd(y,1,sum+1) {
            // cout << "OH " << sum << " " << y << " " << dp[sum][y] << "\n";
            if (sum > y) ad(dp[sum-1][y],dp[sum][y]); // take off left
            ad(cum[sum-1][y-1],dp[sum][y]);
        }
    }
    cout << mul(po(2,max(N-K-1,0)),dp[N-K][0]);
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 30720
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		
		int wmin = 0;
		int wmax = w;
		int hmin = 0;
		int hmax = h;
		
		for(int i = 0; i < n ;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			
			if(a == 1) {
				wmin = Math.max(wmin, x);
			}
			if(a == 2) {
				wmax = Math.min(wmax, x);
			}
			if(a == 3){
				hmin = Math.max(hmin, y);
			}
			if(a == 4) {
				hmax = Math.min(hmax, y);
			}
			
		}
		
		if(wmax <= wmin || hmax <=hmin) {
			System.out.println(0);
		}
		else {
			System.out.println((wmax-wmin)*(hmax - hmin));
		}
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string a, b, c;
const ll M = 2000;
bool ab[100000] = {}, bc[100000] = {}, ac[100000] = {};
ll ans = 10000;

bool match(char c1, char c2) {
	return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main() {
	cin >> a;
	cin >> b;
	cin >> c;
	ll A = sz(a);
	ll B = sz(b);
	ll C = sz(c);
	rep(i, A) {
		rep(j, B) {
			if (!match(a[i], b[j]))ab[i - j + 50000] = true;
		}
	}
	rep(i, A) {
		rep(j, C) {
			if (!match(a[i], c[j]))ac[i - j + 50000] = true;
		}
	}
	rep(i, B) {
		rep(j, C) {
			if (!match(b[i], c[j]))bc[i - j + 50000] = true;
		}
	}
	for (int i = -2 * M; i <= 2 * M; i++) {
		for (int j = -2 * M; j <= 2 * M; j++) {
			if (!ab[i + 50000] && !ac[j + 50000] && !bc[j - i + 50000])ans = min(ans, max(A, max(i + B, j + C)) - min(0, min(i, j)));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;

typedef long long ll;
const int maxn=100005;

struct edge {
	int u,v,w;
	bool operator < (const edge &other) const {
		return w<other.w;
	}
}e[maxn<<1];
int now,n,en;
struct point {
	int x,y,id;
	bool operator < (const point &other) const {
		if(now) return x<other.x;
		return y<other.y;
	}
}a[maxn];
int f[maxn];
int find(int x) {
	return x==f[x]?x:f[x]=find(f[x]);
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) {
		a[i].id=i;
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	now=1;
	sort(a+1,a+n+1);
	rep(i,2,n) 
		e[++en]=(edge){a[i-1].id,a[i].id,a[i].x-a[i-1].x};
	now=0;
	sort(a+1,a+n+1);
	rep(i,2,n)
		e[++en]=(edge){a[i-1].id,a[i].id,a[i].y-a[i-1].y};
	rep(i,1,n) f[i]=i;
	sort(e+1,e+en+1);
	ll mst=0,cnt=n;
	rep(i,1,en) {
		int u=e[i].u,v=e[i].v;
		if(find(u)!=find(v)) {
			f[find(u)]=find(v);
			mst+=e[i].w;
			cnt--;
			if(cnt==1) break;
		}
	}
	printf("%lld\n",mst);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;


int N, K, Q, A[2000];

long long when_X_is(int X){
    int A_copy[2000];
    for(int i = 0; i < N; i++){
        A_copy[i] = A[i];
    }
    //printf("a\n");
    vector<int> removable;
    for(int l = 0, r = 0; l < N; l = r = r+1){
        while(r < N && A[r] >= X){
            r++;
        }
        //printf("before sort %d %d\n", l, r);
        sort(A_copy + l, A_copy + r);
        for(int i = 0; i < (r-l) - K + 1; i++){
            removable.push_back(A_copy[l+i]);
        }
    }
    //printf("%d\n", X);
    sort(removable.begin(), removable.end());
    if(removable.size() >= Q){
        return removable[Q-1];
    }else{
        return 2000000000;
    }
}


int main(){
    cin >> N >> K >> Q;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long ans = 1000000000;
    for(int i = 0; i < N; i++){
        ans = min(ans, when_X_is(A[i]) - A[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll a[200000];
int main(){
	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}
	sort(a,a+n);

	ll mini = 0;

	REP(i,n - 1) {

		if(a[i] * 2 < a[i + 1]) {
			mini = i + 1;
		}
		a[i + 1] += a[i];
	}

	cout << n - mini << endl;
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int need=0;
    while (b<=a) {
	need++;
	b*=2;
    }
    while (c<=b) {
	need++;
	c*=2;
    }

    if (need<=k) out("Yes");
    out("No");
    
    
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define N 333
int n,K,mod,f[N][N],g[N][N],C[N][N];
int main(){
	scanf("%d%d%d",&n,&K,&mod);
	for(int i=C[0][0]=1;i<=300;i++)
		for(int j=C[i][0]=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	for(int i=0;i<=K;i++)
		f[1][i]=1,g[1][i]=K-i+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<K;j++)
			for(int k=1;k<i;k++)
				f[i][j]=(f[i][j]+C[i-2][k-1]*1ll*f[i-k][j]%mod*g[k][j+1])%mod;
		for(int j=K-1;~j;j--)
			g[i][j]=(g[i][j+1]+f[i][j])%mod;
	}
	printf("%d\n",f[n+1][0]);
	return 0;
}


Measured memory_bytes: 1408
h,w=map(int, input().split())
S=["."+input()+"." for _ in range(h)]
S = ["."*(w+2)]+S+["."*(w+2)]
# print(S)
flag=True
for i in range(h):
    for j in range(w):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=False
print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int point[4][13];
int bai[9];
pair<int, int> hand[5];
map<char, int> convNum;
map<char, int> convCol;

void init(){
  convNum['A'] = 0;
  for(int i=2;i<=9;i++){
    convNum['0'+i] = i-1;
  }
  convNum['T'] = 9;
  convNum['J'] = 10;
  convNum['Q'] = 11;
  convNum['K'] = 12;
  convCol['S'] = 0;
  convCol['C'] = 1;
  convCol['H'] = 2;
  convCol['D'] = 3;
}

bool roi(){
  int p = hand[0].second;
  for(int i=1;i<5;i++){
    if(p != hand[i].second) return false;
  }
  if(hand[0].first == 0 &&
     hand[1].first == 9 &&
     hand[2].first == 10 &&
     hand[3].first == 11 &&
     hand[4].first == 12
    ) return true;
  return false;
}

bool four(){
  int tmp = hand[0].first;
  if(hand[1].first == tmp &&
     hand[2].first == tmp &&
     hand[3].first == tmp 
    ) return true;
  tmp = hand[4].first;
  if(hand[1].first == tmp &&
     hand[2].first == tmp &&
     hand[3].first == tmp 
    ) return true;
  return false;
}

bool st(){
  if(hand[0].first == 0 &&
     hand[1].first == 9 &&
     hand[2].first == 10 &&
     hand[3].first == 11 &&
     hand[4].first == 12
    ) return true;
  for(int i=1;i<5;i++){
    if(hand[i-1].first+1 != hand[i].first) return false;
  }
  return true;
}

bool fra(){
  int tmp = hand[0].second;
  for(int i=1;i<5;i++){
    if(tmp != hand[i].second) return false;
  }
  return true;
}

bool fru(){
  if(hand[0].first == hand[1].first &&
     hand[0].first == hand[2].first &&
     hand[3].first == hand[4].first
    ) return true;
  if(hand[0].first == hand[1].first &&
     hand[2].first == hand[3].first &&
     hand[2].first == hand[4].first
    ) return true;
  return false;
}

bool three(){
  for(int i=2;i<5;i++){
    if(hand[i].first == hand[i-1].first && hand[i].first == hand[i-2].first) return true;
  }
  return false;
}

bool two(){
  int i;
  bool f = false;
  for(i=1;i<5;i++){
    if(hand[i].first == hand[i-1].first){
      i++;
      f = true;
      break;
    }
  }
  if(!f) return false;
  for(;i<5;i++){
    if(hand[i].first == hand[i-1].first) return true;
  }
  return false;
}

bool one(){
  for(int i=1;i<5;i++){
    if(hand[i].first == hand[i-1].first) return true;
  }
  return false;
}

int calc(){
  sort(hand, hand+5);
  if(roi()) return bai[8];
  if(st() && fra()) return bai[7];
  if(four()) return bai[6];
  if(fru()) return bai[5];
  if(fra()) return bai[4];
  if(st()) return bai[3];
  if(three()) return bai[2];
  if(two()) return bai[1];
  if(one()) return bai[0];
  return 0;
}

int solve(){
  int base = 0;
  for(int i=0;i<5;i++){
    base += point[hand[i].second][hand[i].first];
  }
  return base * calc();
}

main(){
  init();
  int n;
  bool f = true;
  while(cin >> n){
    if(!f) cout << endl;
    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++){
        cin >> point[i][j];
      }
    }
    for(int i=0;i<9;i++){
      cin >> bai[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<5;j++){
        char a, b;
        cin >> a >> b;
        hand[j].first = convNum[a];
        hand[j].second = convCol[b];
      }
      cout << solve() << endl;
    }
    f = false;
  }
  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),even;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(a.at(i)%2==0)even.push_back(a.at(i));
    }
    int count=0;
    for(int i=0;i<even.size();i++){
        while(even.at(i)%2==0){
            even.at(i)/=2;
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        String A = sc.next(), B = sc.next(), C = sc.next();
                        if(A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0)) {
                                System.out.println("YES");
                        } else {
                                System.out.println("NO");
                        }
                }
        }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  map<ll, int> cnt;
  cnt[0] = 1;
  int n;
  cin >> n;
  ll sum = 0, res = 0;
  while (n--) {
    int a;
    cin >> a;
    sum += a;
    res += cnt[sum];
    cnt[sum]++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main (int argc, char *argv[]) {
	int N;
	cin >> N;
	cin.ignore();
	for(int i = 0; i < N; ++i) {
		string str;
		int out_count = 0, base[3] = {0, 0, 0}, point = 0;
		while (true) {
			getline(cin,str);
			if (str == "OUT") out_count++;
			else if (str == "HIT") {
				if (base[2] == 1) {
					point++;
					base[2] = 0;
				}
				base[2] = base[1];
				base[1] = base[0];
				base[0] = 1;
			}
			else if (str == "HOMERUN") {
				point += 1 + count(base,base+3,1);
				memset(base, 0, sizeof base);
			}
			if (out_count == 3) break;
		}
		cout << point << endl;
	}
	return 0;
}

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

typedef struct {
  int parent;
  int left;
  int right;
} node;


void initNode( node* a, int length) {
  int i;

  for( i=0; i<length; i++) {
    a[i].parent = -1;
  }

}


void scanNode( node* a, int length) {
  int i, id;

  for( i=0; i<length; i++) {
    scanf("%d", &id);

    scanf("%d%d", &a[id].left, &a[id].right);
    if( a[id].left != -1) {
      a[ a[id].left ].parent = id; //左の子の親はid
    }
    if( a[id].right != -1) {
      a[ a[id].right ].parent = id; //右の子の親はid
    }
  }

}

int searchSibling( node* a, int id) {

  if( a[id].parent == -1 ) {
    return -1;
  }
  
  if (a[ a[id].parent ].right == id ) {
    return a[ a[id].parent ].left;
  }else {
    return  a[ a[id].parent ].right;
  }
  return 0;

}

int searchDegree( node* a, int id) {
  int degree = 0;

  if( a[id].left != -1 ) {
    degree += 1;
  }
  if( a[id].right != -1 ) {
    degree += 1;
  }

  return degree;

}


int searchDepth( node* a, int id) {

  if( a[id].parent == -1 ) {
    return 0;
  }else {
    return searchDepth( a, a[id].parent)+1;
  }

}


int searchHeight( node* a, int id) {

  int left, right;

  if( a[id].left == -1 ) {
    left = -1;
  }else {
    left = searchHeight( a, a[id].left);
  }

  if( a[id].right == -1 ) {
    right = -1;
  }else {
    right = searchHeight( a, a[id].right);
  }

  if( left > right ) {
    return left+1;
  }else {
    return right+1;
  }

}


void printNode( node* a, int length) {
  int i;

  for( i=0; i<length; i++) {
    printf("node %d: parent = %d, ", i, a[i].parent);
    printf("sibling = %d, ", searchSibling( a, i));
    printf("degree = %d, ", searchDegree( a, i));
    printf("depth = %d, ", searchDepth( a, i));
    printf("height = %d, ", searchHeight( a, i));




    if( a[i].parent == -1 ) {
      printf("root\n");
    }else if( searchDegree( a, i) >= 1 ) {
      printf("internal node\n");
    }else {
      printf("leaf\n");
    }

  }
    
}


int main() {

  int n, id;
  node* a;

  int i;

  scanf("%d", &n);

  a = (node* )malloc( sizeof( node ) * n);

  initNode( a, n);

  scanNode( a, n);

  printNode( a, n);

  return 0;

}

Measured memory_bytes: 612
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int n, x;
vector<int> a, p;

int f(int N, int X) {
  if (X <= 0) return 0;
  if (X >= a[N]) return p[N];
  int ans = 0;
  ans += f(N - 1, X - 1);
  if (X > a[N - 1] + 1) ans++;
  ans += f(N - 1, X - a[N - 1] - 2);

  return ans;
}

signed main() {
  int n, x;
  cin >> n >> x;
  a.resize(n + 1);
  p.resize(n + 1);
  a[0] = 1;
  p[0] = 1;
  loop(i, 1, n + 1) {
    a[i] = a[i - 1] * 2 + 3;
    p[i] = p[i - 1] * 2 + 1;
  }
  cout << f(n, x) << endl;

  return 0;
}


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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	int a[n];
	FOR(i,0,n)cin >> a[i];
	int target = -100;
	int ans = INF;
	while(1){
		int cost = 0;
		FOR(i,0,n){
			int difference = a[i] - target;
			cost += difference * difference;
		}
		if(cost < ans){
			ans = cost;
		}else{
			break;
		}
		if(target == 100)break;
		target++;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++){
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using Graph = vector<vector<pair<int,int>>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;
//abc146d
Graph G;
int ans = 0;

void dfs(int v, int p, int pc, vector<int> &res){
    int color = 1;
    if(color == pc)++color;
    for (auto e : G[v]) {
        if (e.first == p) continue; // 逆流しない
        res[e.second] = color;
        dfs(e.first, v, color, res);
        ++color;
        if (color == pc) ++color;
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    G.assign(n, vector<pair<int, int>>());
    rep(i , n - 1){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) chmax(ans, (int)G[i].size());
    vector<int> res(n - 1, -1);
    dfs(0, -1, -1, res);
    cout << ans << endl;
    for(int i = 0;i < res.size(); i++)cout << res[i] << endl;
}

Measured memory_bytes: 8320
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, i+k+1):
        li.append(s[i:j+1])
li = list(set(li))
li.sort()
print(li[k-1])

Measured memory_bytes: 5424
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
	int n, q, t;
	string name;
	
	queue<pair<string, int>> Q;

	cin >> n;
	cin >> q;

	for (int i = 0; i < n; i++) {
		cin >> name;
		cin >> t;
		Q.push(make_pair(name, t));
	}

	pair<string, int> u;
	int elaps = 0, a;

	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		a = min(u.second, q);
		u.second -= a;
		elaps += a;
		if (u.second > 0) {
			Q.push(u);
		}
		else {
			cout << u.first << " " << elaps << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int d, e;
    while(1){
        int n, m;
        cin >> n >> m;
        if(n + m == 0) break;
        vector<P> data;
        rep(i, 0, n){
            int d, p;
            cin >> d >> p;
            data. push_back(P(p, d));
        }
        sort(all(data));
        reverse(all(data));
        int ans = 0;
        rep(i, 0, n){
            if(data[i].second <= m){
                m -= data[i].second;
            }else if(m == 0){
                ans += data[i].first * data[i].second;
            }else{
                ans += data[i].first * (data[i].second - m);
                m = 0;
            }
        }
        cout << ans << endl;
    }
}

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

int n,a[100100];

int main(){
	int ans=0;
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++){
		if (a[i]==i){
			if (a[i+1]==i+1) i++;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int hv[1000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;

    rep(i,k){
        int d; cin>>d;
        rep(i, d){
            int a;
            cin>>a;
            hv[a] = 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=n; i++) if(hv[i]==0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>


int main() {
    int n, t;

    std::cin >> n;
    std::cin >> t;

    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    int result = 0;
    for (int i = 0; i < n-1; i++) {
        if (v[i+1] - v[i] >= t) result += t;
        else result += v[i+1] - v[i];
    }
    result += t;

    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s; cin >> s;
    ll minv = INFLL;

    for(ll i=0; i<=s.size()-3; i++){
        ll x = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        chmin(minv, abs(753-x));
    }
    cout << minv << endl;
}

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

using namespace std;
char ch[30]; 

int main( )
{
	string s;
	cin >> s;
	int len = s.length();
	memset(ch,false,sizeof(ch));
	for(int j = 0; j < len; j++)
		ch[s[j] - 'a'] = true;
	for(int j = 0; j < 26; j++)
		if(!ch[j]){
			cout << char(j + 'a') << endl;
			return 0;
		}
	puts("None");
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node
{
  struct node *parent;
  struct node *left;
  struct node *right;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void Tprint(Node);
void find(Node, int);
Node get(Node, int);
Node successor(Node);
void delete(Node);
Node min(Node);
Node root;

int main()
{
  int m, i, k;
  char str[8];

  scanf("%d", &m);
  for(i=0; i<m; i++)
    {
      scanf("%s", str);
      if(strcmp(str, "insert") == 0)
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(strcmp(str, "print") == 0)
	{
	  Tprint(root);
	}
      else if(strcmp(str, "find") == 0)
	{
	  scanf("%d",&k);
	  find(root,k);
	}
      else if(strcmp(str, "delete") == 0)
	{
	  scanf("%d",&k);
	  delete(get(root,k));
	}
    }
  
  
  return 0;
}

void insert(int key)
{
  Node t, x, y;
  t = (Node)malloc(sizeof(struct node));
  t->key=key;
  t->right = NULL;
  t->left = NULL;
  y = NULL;
  x = root;

  while(x != NULL)
    {
      y = x;
      if(key<x->key)
	x = x->left;
      else
	x = x->right;
    }
  t->parent = y;

  if(y==NULL)
    root = t;
  else if(t->key<y->key)
    y->left = t;
  else
    y->right = t;
}

void preorder(Node T)
{
  if(T == NULL) return;

  printf(" %d", T->key);
  preorder(T->left);
  preorder(T->right);
}
void inorder(Node T)
{
  if(T == NULL) return;

  inorder(T->left);
  printf(" %d", T->key);
  inorder(T->right);
}
void Tprint(Node T)
{
  inorder(T);
  printf("\n");
  preorder(T);
  printf("\n");
}
void find(Node T, int key)
{
  if(T == NULL)
    {
      printf("no\n");
      return;
    }
  else if(key == T->key)
    {
      printf("yes\n");
      return;
    }

  if(key<T->key)
    find(T->left,key);
  else
    find(T->right,key);
}
Node get(Node T, int key)
{
  if(T == NULL)
    {
      return NULL;
    }
  else if(key == T->key)
    {
      return T;
    }

  if(key<T->key)
    return get(T->left,key);
  else
    return get(T->right,key);
}
Node min(Node x){
  while(x->left != NULL){
    x = x->left;
  }
  return x;
}
Node successor(Node T)
{
  Node y,m;
  if(T->right != NULL)
    {
      return min(T->right);
    }

  y=T->parent;
  while(y!=NULL && T==y->right)
    {
      T=y;
      y=y->parent;
    }
  return y;
  }
void delete(Node T)
{
  Node x, y;
  
  if(T->left == NULL || T->right==NULL)
    y=T;
  else
    y=successor(T);

  if(y->left!=NULL)
    x=y->left;
  else
    x=y->right;

  if(x!=NULL)
    {
      x->parent = y->parent;
    }
  
  if(y->parent==NULL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;

  if(y!=T)
    T->key=y->key;
}

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

int yakusuu(int a, int b){
    int r, tmp;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}
int main(){

    int n, i, j, k;
    long int sum=0;
    cin >> n;

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                sum += yakusuu(yakusuu(i,j),k);
            }
        }
    }

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int n ;
    cin >> n;
    vector<int> a(100010);

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

    int answer= 0;

    for(int i = 0; i < a.size()-2; i++){
        answer = max(a[i] + a[i+1] + a[i+2], answer);
    }

    cout << answer << endl;
    
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        var T = new Two_D(1000, 1000);
        int N = cin.Nextint;
        for (int i = 0; i < N; i++)
        {
            var c = cin.Scanint;
            T.imos(c[0], c[1], c[2] - 1, c[3] - 1);
        }
        T.build();
        long ans = 0;
        for (int i = 0; i < T.H; i++)
        {
            for (int j = 0; j < T.W; j++)
            {
                ans = Math.Max(ans, T.D[i, j]);
            }
        }
        Console.WriteLine(ans);
    }

}

class Two_D
{
    public long[,] D;
    public int H;
    public int W;
    public Two_D(int H, int W)
    {
        this.H = H + 10;
        this.W = W + 10;
        D = new long[this.H, this.W];
    }
    public void build()
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 1; j < W; j++)
            {
                D[i, j] += D[i, j - 1];
            }
        }
        for (int i = 1; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                D[i, j] += D[i - 1, j];
            }
        }
    }
    public void imos(int min_y, int min_x, int max_y, int max_x)
    {
        D[min_y, min_x]++;
        D[min_y, max_x + 1]--;
        D[max_y + 1, min_x]--;
        D[max_y + 1, max_x + 1]++;
    }
    //sum [(min_y, min_x), (max_y, max_x)]
    public long query(int min_y, int min_x, int max_y, int max_x)
    {
        long ret = D[max_y, max_x];
        if (min_y > 0) ret -= D[min_y - 1, max_x];
        if (min_x > 0) ret -= D[max_y, min_x - 1];
        if (min_y > 0 && min_x > 0) ret += D[min_y - 1, min_x - 1];

        return ret;
    }
}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}


Measured memory_bytes: 23904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		if((100 * r + 10 * g + b) % 4 == 0) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


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

typedef long long ll;

int main()
{
    int n,ans;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i,n){
        forx(j,i+1,n){
            ans = max(ans, abs(a[i] - a[j]));
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Hs = list(map(int, input().split()))

cnt = 0
l = 0
r = 1
while max(Hs) > 0:
  if Hs[l] == 0:
    l += 1
    r = l + 1
  elif r < N and Hs[r] > 0:
    r += 1
  else:
    for i in range(l,r):
      Hs[i] -= 1
    cnt += 1
    r = l + 1
  
print(cnt)

Measured memory_bytes: 73108
#include <iostream>
using namespace std;
int main()
{
    long long int n,x,t,s=0;
    long long int a[150000];
    cin>>n>>x;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(a[0]>x)  {s+=a[0]-x; a[0]=x;}
    for(int i=1;i<n;i++)
    {
       if(a[i]+a[i-1]>x) {
        t=a[i]+a[i-1]-x ;
        a[i]-=t;
        s+=t;
       }
    }
   cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
queue<pint> q;
string s,t;
int num[1141919];
int main()
{
	int out=0,n;
	cin>>n;
	cin>>s;cin>>t;
	int now=n-1;
	for(int i=n-1;i>=0;i--){
		while(now>=0 && (now>i || s[now]!=t[i])) now--;
		//cout<<i<<' '<<now<<endl;
		if(now<0){
			cout<<-1<<endl;return 0;
		}
		num[i]=now;
	}
	for(int i=n-1;i>=0;i--){
		if(i<n-1 && num[i]==num[i+1]) continue;
		//if(num[i]==i) continue;
		q.push(mp(num[i],i));
		while(!q.empty() && q.front().fi>=i+q.size()-1) q.pop();
		out=max(out,(int)q.size());
	}
	cout<<out<<endl;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a = 0;
  int b = 0;
  int c = 0;
  rep(i,n) {
    if(s[i] == 'a') a++;
    else if(s[i] == 'b') b++;
    else c++;
  }

  vector<int> d = {a,b,c};
  sort(d.begin(),d.end());
  
  bool flag;
  if(d[2]-d[0] > 1) flag = 0;
  else flag = 1;
  cout << (flag == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3760
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+3):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
    
a,b = [int(x) for x in input().split()]
import fractions
gcd = fractions.gcd(a,b)
factors = factorization(gcd)
if factors ==[[1,1]]:
    print(1)
else:
    print(len(factors)+1)


Measured memory_bytes: 66028
HandW = input().split()
h = HandW[0]
w = HandW[1]

list1 = [["." for i in range(int(w)+2)] for j in range(int(h)+2)]

for i in range(int(h)):
    str1 = input()
    for j in range(int(w)):
        list1[i+1][j+1] = str1[j]

for i in range(int(h)):
    for j in range(int(w)):
        if list1[i+1][j+1] != '#':
            #count = [l1[j:j+3] for l1 in list1[i:i+3]].count('#') 0になる
            count = sum(l[j:j+3].count('#') for l in list1[i:i+3])
            list1[i+1][j+1] = count

#print([l[1:int(w)+1] for l in list1[1:int(h)+1]])

for i in range(1,int(h) + 1):
    for j in range(1,int(w) + 1):
        print(list1[i][j],end = '')
    print('')


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
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;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

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

    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;


    if(s[0] != t[0]){
        ppp(-1);
        return 0;
    }

    ll g = gcd(n, m);
    if(g != 1){
        ll l = n/g*m;
        int idx = 0;
        //cerr << "l:" << l << sp << "g:" << g << endl;
        for(int i = 0; i < l; i += (l/m)){
            //cerr << s[i] << sp << t[idx] << sp << endl;
            if(s[i] != t[idx]){
                ppp(-1);
                return 0;
            }
            if(idx + l/n < t.size()){
                idx += (l/n);
            }
            else{
                ppp(l);
                break;
            }
        }
    }
    else{
        ppp(n/g*m);
    }

    return 0;
}


Measured memory_bytes: 640