akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

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


int main(){fastio
    ll h,w;cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    
    ll d[h][w];rep(i,0,h-1)rep(j,0,w-1)d[i][j]=inf;
    queue<l_l>q;
    rep(i,0,h-1)rep(j,0,w-1){
        if(s[i][j]=='#'){
            d[i][j]=0;
            q.push(l_l(i,j));
        }
    }
    while(!q.empty()){
        l_l t=q.front();q.pop();
        rep(i,0,3){
            ll x=t.first+dx[i];
            ll y=t.second+dy[i];
            if(0<=x&&x<=h-1&&0<=y&&y<=w-1&&d[x][y]==inf){
                d[x][y]=d[t.first][t.second]+1;
                q.push(l_l(x,y));
            }
        }
    }
    
   /* rep(i,0,h-1){
        rep(j,0,w-1){
            cout<<d[i][j]<<" ";
        }cout<<endl;
    }cout<<endl;*/
    ll ans=0;
    rep(i,0,h-1)rep(j,0,w-1)Max(ans,d[i][j]);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 25524
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

const int INF = INT_MAX / 3;

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


double EPS = 1e-10;

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
	return a + b;
}

struct P {
	double x, y;
	P() {}
	P(double x, double y) : x(x), y(y) {
	}
	P operator +(P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator -(P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator *(double d) {
		return P(d*x, d*y);
	}
	double dot(P p) {
		return add(x*p.x, y*p.y);
	}
	double det(P p) {
		return add(x*p.y, -y*p.x);
	}
	void print() {
		printf("%.10lf %.10lf \n", x, y);
		return;
	}
};

double dist(P p1, P p2) {
	double dx = p1.x - p2.x;
	double dy = p1.y - p2.y;
	return sqrt(dx*dx + dy*dy);
}

double TriangleArea(P p1, P p2){
	return (1.0/2.0)*p1.det(p2);
}

double Area(vector<P> &polygon){
	int n =  polygon.size();
	double S=0;
	for(int i=0;i<n-1;i++){
		S = S +TriangleArea(polygon[i], polygon[i+1]);
	}
	S = S + TriangleArea(polygon[n-1], polygon[0]);
	return fabs(S);
}

int main(){
	int n;
	cin >> n;
	vector<P> polygon;
	REP(i,n){
		P p;
		cin >> p.x >> p.y;
		polygon.push_back(p);
	}

	printf("%.1lf\n", Area(polygon)) ;
	return 0;
}

Measured memory_bytes: 1252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * New Town
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int W, H, C;

		StringTokenizer st = new StringTokenizer(br.readLine());
		W = parseInt(st.nextToken());
		H = parseInt(st.nextToken());
		C = parseInt(st.nextToken());

		int gcd = gcd(W, H);

		System.out.println(W * H / gcd / gcd * C);
	}

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

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

int main() {
	int N;
	priority_queue<int64_t> a;
	cin >> N;
	int64_t ans = 0;
	a.push(0);
	for (int i = 0; i < N; i++)
	{
		int x; cin >> x;
		if (a.top() > x) ans += a.top() - x;
		a.push(x);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 5344
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
const int NIL = -1;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct SegmentTree {
	int n;
	vector<int>d, lazy;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
		lazy.assign(2 * n, NIL);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != NIL) {
			d[k] = lazy[k];
			if (r - l > 1) {
				lazy[2 * k] = lazy[2 * k + 1] = lazy[k];
			}
			lazy[k] = NIL;
		}
	}
	void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = min(d[2 * k], d[2 * k + 1]);
		}
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return INF;
		else if (a <= l&&r <= b)return d[k];
		else return min(find(a, b, 2 * k, l, (l + r) / 2), find(a, b, 2 * k + 1, (l + r) / 2, r));
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.find(s, t + 1) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4900
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int A[80][80];
int B[80][80];
#define VMAX (80 * 80 + 5)
int T[80][80][VMAX];

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int h = 0; h < H; ++h) for (int w = 0; w < W; ++w) cin >> A[h][w];
    for (int h = 0; h < H; ++h) for (int w = 0; w < W; ++w) cin >> B[h][w];
    
    T[0][0][abs(A[0][0]-B[0][0])] = 1;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W-1; ++w) {
            for (int v = 0; v < VMAX; ++v) {
                if (T[h][w][v]) {
                    int temp = abs(A[h][w+1] - B[h][w+1]);
                    if (v+temp < VMAX) {
                        T[h][w+1][v+temp] = 1;
                    }
                    T[h][w+1][abs(v-temp)] = 1;
                }
            }
        }
        if (h == H-1) {
            break;
        }
        for (int w = 0; w < W; ++w) {
            for (int v = 0; v < VMAX; ++v) {
                if (T[h][w][v]) {
                    int temp = abs(A[h+1][w] - B[h+1][w]);
                    if (v+temp < VMAX) {
                        T[h+1][w][v+temp] = 1;
                    }
                    T[h+1][w][abs(v-temp)] = 1;
                }
            }
        }
    }
    
    for (int v = 0; v < VMAX; ++v) {
        if (T[H-1][W-1][v]) {
            cout << v << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 159744
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int INF = 1e8;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;

int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[] = {1, -1, 0, 1, -1, 0, 1, -1};
ll MOD = 1e9 + 7;
long long  per(long long x, ll step){

    long long r = 1;

    while (step){
        if (step & 1) r = (r * x ) % MOD;
        x *= x;
        x %= MOD;
        step >>= 1;
    }
    return r;
}
ll ch[MAXN], zn[MAXN];
int n, m, a, b;

void calc(){
    ch[0] = 1;
    for (int i = 1; i <= MAXN - 10; i++)
        ch[i] = ch[i - 1] * i % MOD;
    zn[MAXN - 10] = per(ch[MAXN - 10], MOD - 2);
    for (int i = MAXN - 11; i >= 0; i--){
        zn[i] = zn[i + 1] * (i + 1)  % MOD;
    }
}
ll C(int n, int m){
    return ch[n] % MOD * zn[m] % MOD * zn[n - m] % MOD;
}
void solve(){
    cin >> n >> m >> a >> b;
    calc();
    n--; m--; a--; b--;
    ll ans =C(n + m, n);
    ans %= MOD;
    int x = n - a;
    int y = b;
    while (true){

        if (y < 0) break;
        if (x > n) break;
        ll temp = C(x + y, x) * C (n - x + m - y, m - y);
        temp %= MOD;
        ans = (ans - temp + MOD) % MOD;
        x++;
        y--;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(7);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();

}

Measured memory_bytes: 4992
import math

A,B,N=map(int,input().split())


if N>=B-1:
    x=B-1
    ans=math.floor(x*A/B)-math.floor(x/B)
    print(ans)
elif N<B-1:
    x=N
    ans=math.floor(x*A/B)-math.floor(x/B)
    print(ans)

Measured memory_bytes: 9192
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

vector<string> v = { "AC", "WA", "TLE", "RE" };

int main()
{
  int n;
  cin >> n;
  map<string, int> cnt;
  for(int i = 0; i < n; i++) {
    string a;
    cin >> a;
    cnt[a]++;
  }
  for(int i = 0; i < sz(v); i++) {
    cout << v[i] << " x " << cnt[v[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################

primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# 全て1の時、primesが空になってmaxが取れない
if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
# min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 177588
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>

using namespace std;

vector<long long int> white;
vector<long long int> black;
vector<vector<int>> adj;
const long long int p = 1e9 + 7;

void dfs(int node, int parent){
    if(adj[node].size()==1 && adj[node][0]==parent){
        //leaf node
        white[node] = 1;
        black[node] = 1;
        return;
    }

    for(auto child : adj[node]){
        if(child!=parent)
            dfs(child,node);
    }

    long long int temp_b = 1;
    long long int temp_w = 1;

    for(auto child: adj[node]){
        if(child!=parent){
            temp_b = (temp_b * white[child])%p;
            temp_w = (temp_w * ((white[child] + black[child])%p))%p;
        }
    }
    white[node] = temp_w;
    black[node] = temp_b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n;
        cin >> n;
        white = vector<long long int> (n+1,-1);
        black = vector<long long int> (n+1,-1);
        adj = vector<vector<int>> (n+1);
        int x,y;
        for(int i=0 ; i<n-1 ; i++){
            cin >> x >> y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        dfs(1,1);
        cout << (white[1] + black[1])%p << "\n";
    }
    return 0;
}



Measured memory_bytes: 15728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;
ll dp[401][401];
ll p[401][401];

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

    ll n,m;
    cin>>n>>m;
    ll a[n],b[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(ll i=1;i<=400;i++){
        p[i][0]=1;
        for(ll j=1;j<=400;j++){
            p[i][j] = p[i][j-1]*i%mod;
        }
        for(int j=0;j<=400;j++){
            (p[i][j] += p[i-1][j]) %= mod;
        }
    }

    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            for(int k=0;k<=j;k++){
                ll sum = (p[b[i]][k] + mod - p[a[i]-1][k])%mod;
                (dp[i+1][j] += sum * dp[i][j-k]) %= mod;
            }
        }
    }
    cout << dp[n][m] << endl; 
    

}

Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main(){
    int n;
    int max = 0;
    int total = 0;

    cin >> n;

    int l;

    for(int i = 0; i < n; i++){
        cin >> l;
        if(max < l){
            max = l;
        }
        total += l;
    }


    if(total - max > max){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




bool isPrime(ll n) {
	if (n < 2) return false;
	for (int i = 2; i*i <= n; i++) if (n%i == 0) return false;
	return true;
}

int solve(int num) {
	int i = 2, cnt = 0, ret = 0;
	
	while (cnt < num) {
		if (isPrime(i)) {
			ret += i;
			cnt++;
		}
		i++;
	}
	
	return ret;
}

int main() {
	int n;
	
	while (1) {
		cin >> n; if (n==0) break;
		cout << solve(n) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int A[4]={};
    int n;
    string s;
    cin>>n;
    REP(i,n){
        cin>>s;
        if(s.compare("AC")==0) A[0]++;
        else if(s.compare("WA")==0) A[1]++;
        else if(s.compare("TLE")==0) A[2]++;
        else A[3]++;
    }
    cout<<"AC x "<<A[0]<<endl;
    cout<<"WA x "<<A[1]<<endl;
    cout<<"TLE x "<<A[2]<<endl;
    cout<<"RE x "<<A[3]<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
int main(){
  vvi v(26);
  string s,t;cin>>s>>t;
  int n=s.size(),m=t.size();
  ll ans=-1;
  rep(i,n){
    v[s[i]-'a'].push_back(i);
  }
  rep(i,m){
    if(v[t[i]-'a'].size()==0){
       cout<<-1<<endl;
       return 0;
    }
    int j=lb(v[t[i]-'a'],ans%n+1);
    if(j==v[t[i]-'a'].size())ans=(ans/n+1)*n+v[t[i]-'a'][0];
    else ans=(ans/n)*n+v[t[i]-'a'][j];
  }
  cout<<ans+1<<endl;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S.at(3) = '8';
    cout << S << "\n";
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> v(13, 0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a; v[a]++;
    }
    if (v[0]) {
        cout << 0 << "\n";
        return 0;
    }
    vector<int> c = {0, 24}, b;
    for (int i = 1; i <= 12; i++) {
        if (v[i] > 2) {
            cout << 0 << "\n";
            return 0;
        }
        if (v[i] == 2) {
            c.emplace_back(i), c.emplace_back(24-i);
        }
        if (v[i] == 1) b.emplace_back(i);
    }
    int m = b.size();
    int ans = 0;
    for (int i = 0; i < (1 << m); i++) {
        vector<int> x = c;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) x.emplace_back(b[j]);
            else x.emplace_back(24-b[j]);
        }
        sort(x.begin(), x.end());
        int minim = 1e9;
        for (int j = 1; j < x.size(); j++) {
            minim = min(minim, x[j]-x[j-1]);
        }
        ans = max(minim, ans);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


lim = 55555
prime = [1]*(lim+1)
prime[0] = 0
prime[1] = 0

for i in range(lim+1):
	if prime[i] == 1:
		for j in range(2, lim//i + 1):
			prime[i*j] = 0

p = []
i = 0
while i <= lim:
	if prime[i] and i%10 == 1:
		p.append(i)
	i += 1

N = INT()
print(*p[:N])

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

#define MAX 100000

#define WHITE 0
#define GRAY 1
#define BLACK 2


using namespace std;

vector<int> G[MAX];
int graphc[MAX];
int color[MAX];
int colorCount;

void def(int o)
{
	int v;

	for (int i = 0; i < G[o].size(); i++) {

		v = G[o][i];
		if (color[v] == WHITE) {

			color[v] = GRAY;
			def(v);
		}
	}
	color[o] = BLACK;
	graphc[o] = colorCount;
}


int main(void)
{
	int n;
	int m;
	int s;
	int t;
	int q;


	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	for (int i = 0; i < n; i++) {

		if (color[i] == WHITE) {
			colorCount++;
			def(i);
			
		}
	}



	cin >> q;

	for (int i = 0; i < q; i++) {

		cin >> s >> t;

		cout << ((graphc[s] == graphc[t]) ? "yes" : "no" )<< endl;
	}

	return 0;
}

Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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



int main(int argc, const char * argv[]) {
    
  
    
    
    int n; cin >> n;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    
    double AllProduct = 1;
    double PartProduct = 0;
    rep(i,n) AllProduct *= A[i];
    rep(i,n) PartProduct += AllProduct/A[i];
    
    cout << setprecision(10) << AllProduct/PartProduct << endl;
    
    return 0;
    
    

    
}


Measured memory_bytes: 256
import java.io.*;
 
class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] str2 = str.split(" ");
        int x =  Integer.parseInt(str2[0]);
        int y =  Integer.parseInt(str2[1]);
        System.out.println(x*y + " "+ 2*(x+y));
        }
}

Measured memory_bytes: 17060
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace ABC118_D___Match_Matching
{
    class Program
    {
        static void Main(string[] args)
        {
            var stroke = new int[] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).OrderByDescending(n => n).ToArray();

            var matches = new Dictionary<int, int>();
            foreach (int i in Ai)
            {
                if (matches.ContainsKey(stroke[i])) continue;
                matches.Add(stroke[i], i);
            }

            var DP = new String[NM[0] + 10];
            for (int i = 0; i < DP.Length; i++) DP[i] = "";
            foreach (int i in matches.Keys) DP[i] = matches[i].ToString();
            for (int i = 0; i < NM[0]; i++)
            {
                if (DP[i] != "")
                {
                    foreach (int j in matches.Keys)
                    {
                        var temp = DP[i] + matches[j].ToString();
                        if (temp.Length > DP[i + j].Length || (temp.Length == DP[i + j].Length && temp.CompareTo(DP[i + j]) > 0)) DP[i + j] = temp;
                    }
                }
            }
            Console.WriteLine(DP[NM[0]]);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    vector<vector<P>> graph(n);
    ll a,b,c;
    rep(i,m){
        cin>>a>>b>>c;
        a--;
        b--;
        graph[a].pb(mp(b,c));
        graph[b].pb(mp(a,c));
    }
    rep(i,n-1){
        graph[i+1].pb(mp(i,0LL));
    }
    priority_queue<ll, vector<P>, function<bool(P, P)>> q([](P a, P b)->ll {
        return a.second>b.second;
    });

    //dbg(graph);

    Vec d(n,INF);
    q.push(mp(0LL,0LL));
    d[0]=0LL;
    while(!q.empty()){
        P now = q.top();
        q.pop();
        if(d[now.fi]<now.se){
            continue;
        }
//        dbg(now.fi);
//        dbg(now.se);
        // dbg(d);
        Each(elm,graph[now.fi]){
            if(d[elm.fi]>now.se+elm.se){
//                dbg(elm.fi);
//                dbg(now.se);
//                dbg(elm.se);
                d[elm.fi]=now.se+elm.se;
                q.push(mp(elm.fi,now.se+elm.se));
            }
        }
    }
    ll ans= d[n-1]==INF?-1:d[n-1];
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 12664
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    int xamin, xbmin, xamax, xbmax;
    xamin = (a * 100 + 7) / 8;
    xbmin = (b * 100 + 9) / 10;
    xamax = ((a + 1) * 100 + 7) / 8 - 1;
    xbmax = ((b + 1) * 100 + 9) / 10 - 1;
    int ans;
    if (xamin <= xbmin && xbmin <= xamax)
    {
        ans = xbmin;
    }
    else if (xbmin <= xamin && xamin <= xbmax)
    {
        ans = xamin;
    }
    else
    {
        ans = -1;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
    
int n, G[110][110];
int u, k, v, cost, a, c[110], d[110], p[110];
  
void prim(){
  
  int i, j;
  
  for(i = 0; i < n; i++){
    c[i] = 0;
    p[i] = -1;
    d[i] = 1000000;
  }
    
  d[0]=0;
    
  while(1){
    cost = 1000000;
    for(i = 0; i < n; i++){
      if(c[i] != 2 && d[i] < cost){
    cost = d[i];
    a = i;
      }
    }
      
    if(cost == 1000000) break;
         
    c[a] = 2;
    
    for(i = 0; i < n; i++){
      if(G[a][i] != -1 && c[i] != 2 && (G[a][i] + d[a]) < d[i]){
    p[i]= a;
    d[i] = G[a][i] + d[a];
    c[i] = 1;
      }
    }
  }
    
  for(i = 0 ; i < n; i++)
    printf("%d %d\n", i, d[i]);
  
}
  
int main(){
   
  int i, j, c;
    
  for(i = 0; i < 110; i++){
    for( j = 0; j < 110; j++){
      G[i][j] = -1;
    }
  } 
  
  scanf("%d",&n);
    
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ;j < k ;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
    
  prim();
    
  return 0;
   
}



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

using namespace std;
const int inf = 1e9;
#define F first
#define S second
queue<pair<int, int> > q;
int dist[51][51];
int main(){
	int h, w;
	cin >> h >> w;
	char c[h][w];
	int cntb = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			cin >> c[i][j];
			dist[i][j] = 500;
			if(c[i][j] == '#'){ 
				cntb += 1;
			}
		}
	}
	q.push({0, 0});
	dist[0][0] = 1;
	while(!q.empty()){
		pair<int, int> p = q.front();
		q.pop();
		for(int x = -1; x <= 1; ++x){
			for(int y = -1; y <= 1; ++y){
				if(abs(x) == abs(y)) continue;
				int fx = p.F + x;
				int fy = p.S + y;
				if(fx >= 0 && fx < h && fy >= 0 && fy < w && dist[fx][fy] == 500 && c[fx][fy] == '.'){
					dist[fx][fy] = dist[p.F][p.S] + 1;
					q.push({fx, fy});
				}
			}
		}
	}
	if(dist[h - 1][w - 1] == 500){
		cout << -1 << endl;
	}
	else{
		//cout << h * w << " "  << cntb << " " << dist[h - 1][w-  1] << '\n';
		cout << h * w - cntb - dist[h - 1][w - 1] << endl; 
	}

}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    bool is_same = true;
    ll ans = 0, minb = HIGHINF;
    for (int i=0; i<n; i++) {
        ll a, b; cin >> a >> b;
        if (a != b) is_same = false;
        ans += a;
        if (a > b) chmin(minb, b);
    }
    if (is_same) cout << 0 << '\n';
    else cout << ans - minb << '\n';
    return 0;
}


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

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		long a = scanner.nextInt();
		long b = scanner.nextInt();
		long c = scanner.nextInt();
		long d = scanner.nextInt();
		
		long ac = a*c;
		long bd = b*d;
		long ad = a*d;
		long bc = b*c;
		
		System.out.println(Math.max(ac, Math.max(bd, Math.max(ad, bc))));
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

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


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

int binary_search(vector<int> &a, int x){
    int ok = a.size();
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (a[mid] >= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ok = a.size();
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        int below_x = binary_search(a, a[mid]);
        int above_x = binary_search(a, a[mid] + m + 1);
        long long tmp = 0;
        tmp += (long long)below_x * m;
        tmp += (long long)(n - above_x) * m;
        for (int i = below_x; i < above_x; i++){
            tmp += m - (a[i] - a[mid]);
        }
        int z = n - above_x;
        bool flag = false;
        if (z < p && tmp >= (long long)m * v) flag = true;
        int now = above_x - 1;
        while (tmp < (long long)m * v){
            if (now == mid) break; 
            tmp += a[now] - a[mid];
            z++;
            if (z >= p) break;
            if (tmp >= (long long)m * v) flag = true;
            now--;
        }
        if (flag) ok = mid;
        else ng = mid;
    }
    cout << n - binary_search(a, a[ok]) << endl;
}

Measured memory_bytes: 640
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      num_500=500*i
      num_100=100*j
      num_50=50*k
      if num_500+num_100+num_50==x:
        ans+=1
        
print(ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 1000000000
#define inf -100000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(15)<<2*M_PI*r<<endl;
}	

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

template<typename T>
struct Imos2D {
    vector<vector<T>> imos;
    Imos2D(int h = 0, int w = 0) : imos(h + 2, vector<T>(w + 2)) { }
    void add(int i, int j, T x) { imos[i + 1][j + 1] += x; }
    void add_rect(int i1, int j1, int i2, int j2, T x = 1) {
        add(i1, j1, +x); add(i1, j2, -x); add(i2, j1, -x); add(i2, j2, +x);
    }
    void build() {
        int H = imos.size(), W = imos[0].size();
        for (int i = 1; i < H; i++) for (int j = 1; j < W; j++) {
            imos[i][j] += imos[i][j - 1] + imos[i - 1][j] - imos[i - 1][j - 1];
        }
    }
    T get(int i, int j) { return imos[i + 1][j + 1]; }
    T diff(int si, int sj, int ti, int tj) {        // [si, ti) x [sj, tj)
        return imos[ti][tj] - imos[ti][sj] - imos[si][tj] + imos[si][sj];
    }
};

int main() {
    const int MAX = 1001;
    Imos2D<int> imos(MAX, MAX);
    int n; cin >> n;
    while (n--) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        imos.add_rect(x1, y1, x2, y2);
    }
    imos.build();
    int ma = 0;
    for (int i = 0; i < MAX; i++) for (int j = 0; j < MAX; j++) {
        ma = max(ma, imos.get(i, j));
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 6688
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, a, b = map(int, input().split())
    all_sum = 0
    for i in range(1, n+1):
        digit_sum = 0
        for j in list(str(i)):
            digit_sum += int(j)
        if a <= digit_sum and digit_sum <= b:
            all_sum += i
    print(all_sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys
import bisect

readline = sys.stdin.readline

def main():
    N, M, X = map(int, readline().split())
    A = list(map(int, readline().split()))

    leftcost = len(A[:bisect.bisect_left(A, X)])
    rightcost = len(A[bisect.bisect_left(A, X):])

    ans = min(leftcost, rightcost)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            ans += '1';
        }else if(s[i] == '0'){
            ans += '0';
        }else if(ans.size() != 0 && s[i] == 'B'){
            ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import math
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


n = int(input())
print(48-n)

Measured memory_bytes: 2940
#include<stdio.h>

int main() {
	int h, w, i, j;
	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}
		if (h == 1 && w == 1) {
			printf("#\n\n");
			continue;
		}
		for (i = 0; i < w; i++) {
			printf("#");
		}
		printf("\n");
		for (i = 0; i < h - 2; i++) {
			printf("#");
			for (j = 0; j < w - 2; j++) {
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for (i = 0; i < w; i++) {
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}

Measured memory_bytes: 588
n = input()
R = [0 for i in range(n)]
for i in range(n):
    R[i] = input()
maxv = -2000000000
minv = R[0]

for j in range(1, n):
    maxv = max(maxv, R[j] - minv)
    minv = min(minv, R[j])

print maxv

Measured memory_bytes: 18780
N=int(input()) # メンバーの数
A=[0]+list(map(int,input().split(" "))) # 直属の上司の番号リスト
R=[[] for _ in range(N)] # 部下のリスト

for i in range(1,N):
    R[A[i]-1].append(i) # 部下のリストを形成

for j in range(N): # 各メンバーについて
    print(len(R[j])) # 直属の部下の数を表示

Measured memory_bytes: 44068
from collections import deque
N, C, K = map(int, input().split())
times = []
for _ in range(N):
    time = int(input())
    times.append(time)
times.sort()
times = deque(times)
ans = 0
bus_time = times[0] + K
human = 0
while times:
    if times[0] <= bus_time:
        times.popleft()
        human += 1
        if human == C:
            ans += 1
            human = 0
            if times:
               bus_time = times[0] + K
    else:
        human = 0
        ans += 1
        bus_time = times[0] + K
if human:
    print(ans + 1)
else:
    print(ans)

Measured memory_bytes: 13864
def rotate(arr,i):
    if i=='W':
        arr=[arr[k-1] for k in [3,2,6,1,5,4]]
    if i=='E':
        arr=[arr[k-1] for k in [4,2,1,6,5,3]]
    if i=='N':
        arr=[arr[k-1] for k in [2,6,3,4,1,5]]
    if i=='S':
        arr=[arr[k-1] for k in [5,1,3,4,6,2]]
    return arr
arr=input().split()

deck=[]
for i in 'W'*4:
    arr=rotate(arr,i)
    for k in 'NNNN':
        arr=rotate(arr,k)
        deck.append(arr)
arr=rotate(arr,'N')
arr=rotate(arr,'W')
for k in 'NNNN':
    arr=rotate(arr,k)
    deck.append(arr)
arr=rotate(arr,'W')
arr=rotate(arr,'W')
for k in 'NNNN':
    arr=rotate(arr,k)
    deck.append(arr)
n=int(input())
for i in range(n):
    query=input().split()
    for v in deck:
        if v[0]==query[0] and v[1]==query[1]:
            print(v[2])
            break



Measured memory_bytes: 5612
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
struct aa {
	int id;
	int time;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};
int main() {
	while (1) {

		int N; cin >> N;
		if (!N)break;
		map<string, int>mp;
		vector<int>costs;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			int cost; cin >> cost;
			mp[st] =i;
			costs.push_back(cost);
		}
		int M; cin >> M;
		vector<vector<pair<int,vector<int>>>>recipes(N);
		for (int i = 0; i < M; ++i) {
			string make; cin >> make;
			int makeid = mp[make];
			int a; cin >> a;
			vector<int>ids;
			for (int j = 0; j < a; ++j) {
				string name; cin >> name;
				int nameid = mp[name];
				ids.emplace_back(nameid);
			}
			for (auto id : ids) {
				recipes[id].emplace_back(makeid,ids);
			}
		}
		priority_queue<aa, vector<aa>, Compare>que;
		for (int i = 0; i < N; ++i) {
			que.push(aa{ i,costs[i] });
		}
		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			if (atop.time != costs[atop.id])continue;
			for (auto re : recipes[atop.id]) {
				int sum = 0;
				for (auto i : re.second) {
					sum += costs[i];
				}
				if (sum < costs[re.first]) {
					costs[re.first]=sum;
					que.push(aa{ re.first,sum });
				}
			}
		}
		string ans; cin >> ans;
		cout << costs[mp[ans]] << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3172
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n,l;
pair<int,int>pp[200005];

int cmp(pair<int,int> a,pair<int,int>b){
	return a.second<b.second;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&pp[i].first,&pp[i].second);
	sort(pp+1,pp+n+1,cmp);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=pp[i].first;
		if(ans>pp[i].second){
			puts("No");
			return 0;
		}
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, B;
	cin >> A >> B;
	int C = A + B;

	if (C < 10) cout << C << endl;
	else cout << "error" << endl;

	return 0;
}

Measured memory_bytes: 256