akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a) {
    cout << "delicious" << endl;
  } else if (b <= a + x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }
 
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll> sumA(n), sumB(m);
    sumA[0] = a[0]; sumB[0] = b[0];
    for(int i = 1; i < n; i++) sumA[i] = sumA[i-1] + a[i];
    for(int i = 1; i < m; i++) sumB[i] = sumB[i-1] + b[i];
    ll ans = 0;
    int start = 0;
    for(int i = n; i >= 0; i--){
        if (i != 0 && sumA[i-1] > k) continue;
        ll sum;
        if (i != 0) sum = sumA[i-1];
        else sum = 0;
        ll cnt = i + start;
        for(int j = start; j < m; j++){
            if (sum + sumB[j] > k) break;
            cnt++;
            start = j;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9572
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define pb push_back
const ll mod = 1e9 + 7;
int q; int ans[100001], sum[100001], l,r;

int ctrl(int x){ if(x==1 || x==7) return 0; if(x==3 || x==5) return 1;
    int y=0;
    for(int i=2; i<=ceil(sqrt(x))+1; i++){if(x%i==0) y++;}
    int z=(x+1)/2;
    if(z!=2) for(int i=2; i<=ceil(sqrt(z))+1; i++){if(z%i==0) y++;}
    if(y==0) return 1; else return 0;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>q;
    for(int i=3; i<=100000; i++) sum[i]=sum[i-1]+ctrl(i);
    for(int i=1; i<=q; i++){
        cin>>l>>r;
        ans[i]=sum[r]-sum[l-1];}
    for(int i=1; i<=q; i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(){
    int tr[10],v1,v2,i;
    
    while(scanf("%d" ,&tr[0])!=EOF){
        double a = 0;
        int sum = tr[0];
        for(i = 1 ; i < 10 ; i++){
            scanf(",%d" ,&tr[i]);
            sum += tr[i];
        }
        scanf(",%d,%d" ,&v1 ,&v2);
        
        a = v1*((double)sum / (v1+v2));
        
        sum = 0;
        for(i = 0 ; i < 10 ; i++){
            sum += tr[i];
            if(a <= sum){
                printf("%d\n" ,i+1);
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	long long ret=0;
	for (int i=1; i<=n; i++) {
		if (i%3==0||i%5==0) {
		} else ret+=i;
	}
	cout<<ret<<endl;
	return 0;
}


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

#ifdef DEBUG
	#define freopen(...)
#endif

#define Min(_A, _B) (_A < _B ? _A : _B)
#define Max(_A, _B) (_A > _B ? _A : _B)

/*void Build_rmq(int p)
{
	for(int i = 1; i <= n; ++i) r[p][0][i] = b[i][p];
	for(int i = 1; 1 << i <= n; ++i)
		for(int j = 1; j + (1 << i) <= n; ++j)
			r[p][i] = Max(r[p][i - 1][j], r[p][i - 1][j + (1 << i)]);
}
void Merge()
{
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			
}
int RMQ(int Ls, int Rs, int p)
{
	int len = Log[Rs - Ls + 1];
	int t1 = r[p][len][Ls], t2 = r[p][len][Rs - (1 << len) + 1];
	return Max(t1, t2);
}*/
long long ans;
int a[100010], d[100010], n, m;
bool vis[100010];
std::vector<int> b[100010];
namespace bf
{
	void main()
	{
		for(int i = 1; i <= n; ++i)
		{
			long long tmp = 0;
			int cnt = m;
			for(int j = 0; j < m; ++j) 
			{
				tmp += b[i][j];
				d[j] = b[i][j];
				vis[j] = 1;
			}
			ans = Max(tmp, ans);
			for(int j = i + 1; j <= n; ++j)
			{
				for(int k = 0; k < m; ++k) if(b[j][k] > d[k])
				{
					cnt -= vis[k];
					vis[k] = 0;
					tmp += b[j][k] - d[k];
					d[k] = b[j][k];
				}
				tmp -= a[j - 1];
				ans = Max(tmp, ans);
				if(!cnt) break;
			}
		}
		printf("%lld\n", ans);		
	}
}
/*namespace test
{
	long long calc(int lim)
	{
		long long ans = 0;
		for(int i = 1; i <= n; ++i) 
		for(int i = 1; i <= n; ++i)
		{
			long long tmp = 0;
			int cnt = m;
			for(int j = 0; j < m; ++j) 
			{
				tmp += b[i][j];
				d[j] = b[i][j];
				vis[j] = 1;
			}
			ans = Max(tmp, ans);
			for(int j = i + 1, lim = Min(i + 80, n); j <= lim; ++j)
			{
				for(int k = 0; k < m; ++k) if(b[j][k] > d[k])
				{
					cnt -= vis[k];
					vis[k] = 0;
					tmp += b[j][k] - d[k];
					d[k] = b[j][k];
				}
				tmp -= a[j - 1];
				ans = Max(tmp, ans);
				if(!cnt) break;
			}
		}
		printf("%lld\n", ans);		
	}
}*/
int main()
{
	//freopen("restaurants.in", "r", stdin);
	//freopen("restaurants.out", "w", stdout);
	
	scanf("%d %d", &n, &m);
	for(int i = 1; i < n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			int t; scanf("%d", &t);
			b[i].push_back(t);
		}
	//if(1ll * n * n * m <= 2e8) 
	bf::main();
	//else test::main();
	return 0;
}

Measured memory_bytes: 7680
#include <stdio.h>
#include <string.h>

int main() {
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    
    if(a >= k) {
        printf("%d\n", k);
    } else if(a + b - k >= 0) {
        printf("%d\n", a);
    } else {
        printf("%d\n", a + (a + b - k));
    }
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;

int main()
{
	string s;
	while (true)
	{
		getline(cin, s);
		if (s == ".")	break;

		stack<int> data, data2;
		
		for (auto && x : s)
		{
			if (x == '[')
				data.emplace(data2.size());
			else if (x == ']')
			{
				if (data.empty())
				{
					cout << "no" << endl;
					goto END;
				}
				else if (data2.size() != data.top())
				{
					cout << "no" << endl;
					goto END;
				}

				data.pop();
			}
			else if (x == '(')
				data2.emplace(data.size());
			else if (x == ')')
			{
				if (data2.empty())
				{
					cout << "no" << endl;
					goto END;
				}
				else if (data.size() != data2.top())
				{
					cout << "no" << endl;
					goto END;
				}
				data2.pop();
			}
		}

		if (data.empty() && data2.empty())
			cout << "yes" << endl;
		else
			cout << "no" << endl;

	END:;

	}

	return 0;
}

Measured memory_bytes: 3148
def solve(inp):
    S = inp.readline().strip()
    T = inp.readline().strip()

    r = 0
    for i in range(3):
        if S[i] == T[i]:
            r += 1

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

class CombinationCalculator {
    using ull = unsigned long long;
public:
    ull mod;
    std::vector<ull> fact;
    std::vector<ull> inv_fact;
    std::vector<ull> inv;

    /**
     *  組み合わせの数を求めるクラス
     *  @n_max: $ {}_n C_r $ における $ {}_n $ の最大値
     *  @mod:   組み合わせの数に対して取るMODの値
     */
    explicit CombinationCalculator(const ull& n_max, const ull& mod = (int)1e9 + 7):
        mod((mod != 0) ? mod : std::numeric_limits<uint>::max()),
        fact(n_max + 1, 0), inv_fact(n_max + 1, 0), inv(n_max + 1, 0) {
        std::fill(fact.begin(), fact.begin() + 2, 1);
        std::fill(inv_fact.begin(), inv_fact.begin() + 2, 1);
        std::fill(inv.begin(), inv.begin() + 2, 1);
        for(ull i = 2; i <= n_max; i++) {
            fact[i]     = (fact[i - 1] * i) % mod;
            inv[i]      = mod - inv[mod % i] * (mod / i) % mod;
            inv_fact[i] = inv_fact[i - 1] * inv[i] % mod;
        }
    }

    /**
     *  $ {}_n C_r $ を求める
     *  @Return: $ {}_n C_r $
     */
    ull run(const ull& n, const ull& r) const {
        return (n < r) ? 0 : fact[n] * (inv_fact[r] * inv_fact[n - r] % mod) % mod;
    }
};

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

    int H, W, A, B;
    std::cin >> H >> W >> A >> B;

    CombinationCalculator comb(H - 1 + W - 1, MOD);
    auto ans = 0LL;
    REP(i, W - B) {
        auto a = comb.run((H - A - 1) + (B + i), B + i);
        auto b = comb.run((A - 1) + (W - B - i - 1), W - B - i - 1);
        ans += a * b;
        ans %= MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }


template<class T>
T pow(T x, ll n, T r = 1) {
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};
using Mint = ModInt<TEN(9)+7>;

const int MN = 330;
int n;


Mint dp[MN][MN][MN];
bool used[MN][MN][MN] = {};
Mint calc(int m, int a, int b) {
    if (m == 0) {
        if (a == n) return 1;
        return 0;
    }
    if (used[m][a][b]) return dp[m][a][b];
    used[m][a][b] = true;
    Mint &ans = dp[m][a][b]; ans = 0;
    ans += calc(m-1, a+b, 0) * a;
    ans += calc(m-1, a, b) * b;
    ans += calc(m-1, a, b+1) * (n-a-b);
    return ans;
}

int main() {
    cout << setprecision(20);
    int m;
    cin >> n >> m;
    cout << calc(m, 1, 0).v << endl;
    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min(a*b, c);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,w,h,ans=0;
  pair<int,int> han[2][100001];
  cin>>n>>w>>h;
  for(int i=0,x,y,z;i<n;i++){
    cin>>x>>y>>z;
    han[0][i]=P(x-z,x+z);
    han[1][i]=P(y-z,y+z);
  }
  han[0][n]=P(w,w);
  han[1][n++]=P(h,h);
  for(int i=0;i<2;i++)sort(han[i],han[i]+n);
  for(int i=0;i<2;i++){
    int mx=0,f=1;
    for(int j=0;j<n;j++){
      if(han[i][j].first>mx)f=0;
      mx=max(mx,han[i][j].second);
    }
    if(f)ans=1;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 4664
#include<stdio.h>
 int main(void)
 {
     int A,B;
     int c=0;

     scanf("%d%d",&A,&B);

     if(A%3==0) c++;
     if(B%3==0) c++;
     if((A+B)%3==0) c++;

     if(c>0) printf("Possible\n");
     else printf("Impossible\n");

     return 0;
 }



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    priority_queue<int> pq;
    rep(n,0,N){
        int a; cin>>a;
        pq.push(a);
    }

    rep(m,0,M){
        int maxP=pq.top();
        pq.pop();

        maxP/=2;
        pq.push(maxP);
    }

    int64_t ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
def is_ok(arg):
    i = 0
    for item in a:
        i += math.ceil(item /arg) -1
    return i <=K

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(meguru_bisect(0,10**9))

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

int main(){
    int n;
    cin >> n;
    int min1 = 100;
    int sum = 0;
    bool flag = false;
    for(int i=0;i<n;i++){
        int s;
        cin >> s;
        sum += s;
        if(s%10!=0&&min1>s){
            min1 = s;
            flag = true;
        }
    }
    if(!flag) cout << 0 << endl;
    else if(sum%10!=0) cout << sum << endl;
    else cout << sum-min1 << endl;
}


Measured memory_bytes: 256
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);

	int N,K;
	
	cin>>N>>K;
	
	llv arr(K+1);
	ll ans=0;
	for(ll i=K;i>=1;i--){
		//cout << i << " : ";
		arr[i] = modPow(K/i,N,MOD7);
		for(ll j=i*2;j<=K;j+=i){
			arr[i] -= arr[j];
			while(arr[i]<0) arr[i]+=MOD7;
		}
		ans = (ans+i*arr[i])%MOD7;
		//cout << arr[i]<<endl;
	}
	cout<<ans;
}


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

using namespace std;

const int N = 1e6 + 5;

int a[N];

void die() {
  puts("-1");
  exit(0);
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i);
  if (a[0] != 0) die();
  int last = 0;
  long long ans = 0;
  for (int i = n-1; i >= 0; --i) {
    if (a[i] < last -1) die();
    else if (a[i] == last-1) {
    }
    else
      ans += a[i];
    last = a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d,a;cin>>n>>d>>a;
  vector<pair<ll,ll>>xh(n);
  rep(i,n)cin>>xh[i].first>>xh[i].second;
  sort(all(xh));

  ll res=0;
  vector<ll>x(n),h(n),nx(n),dam(n+1);
  rep(i,n){x[i]=xh[i].first;h[i]=xh[i].second;}
  rep(i,n){
    nx[i]=upper_bound(all(x),x[i]+2*d)-x.begin();//open
  }
  rep(i,n){
    if(i!=0)dam[i]+=dam[i-1];
    ll rest=max(0ll,(h[i]-dam[i]-1+a))/a;
    dam[i]+=rest*a;
    dam[nx[i]]-=rest*a;
    res+=rest;

  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 9600
import java.util.Scanner;

class Main {
    int A, B, C, K;

    Main() {
        Scanner sc = new Scanner(System.in);
        this.A = Integer.parseInt(sc.next());
        this.B = Integer.parseInt(sc.next());
        this.C = Integer.parseInt(sc.next());
        this.K = Integer.parseInt(sc.next());
    }

    void solve() {
        int maxInt = A > B ? 
            (B > C ? A : (C > A ? C : A)) :
            (A > C ? B : (C > B ? C : B));

        int answer = maxInt * (int) Math.pow(2, K);
        if (maxInt == A) {
            answer += B + C;
        } else if (maxInt == B) {
            answer += C + A;
        } else {
            answer += A + B;
        }
        System.out.println(answer);
    }

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


Measured memory_bytes: 23892
// https://atcoder.jp/contests/dp/tasks/dp_b
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define MOD 1000000007

using namespace std;

int getMin(vector<int> v) {
    int minElement = *std::min_element(v.begin(), v.end());
    return minElement;
}

int solve(int n, int k, vector<int> h) {
    int ans = 0;
    vector<int> dp1(n, 0);
    rep(i, 1, n) {
        if (i <= k) {
            dp1[i] = abs(h[i] - h[0]);
        } else {
            vector<int> dp2(k, INF);
            rep(j, 0, k) { dp2[j] = abs(h[i] - h[i - j - 1]) + dp1[i - j - 1]; }
            dp1[i] = getMin(dp2);
        }
    }

    return dp1[n - 1];
}

int main() {
    int n, k, hi;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    vector<int> h;

    rep(i, 0, n) {
        cin >> hi;
        h.push_back(hi);
    }

    int ans = solve(n, k, h);
    cout << ans << endl;
}


Measured memory_bytes: 4512
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    ll N;
    cin >> N;

    // process
    ll sum = 0;
    ll max = 1;
    for (; max <= N && sum < N; max++) {
        sum += max;
    }

    if (sum > N) {
        ll e = sum - N;
        for (ll i = 1; i < max; ++i) {
            if (i == e) {
                continue;
            }
            cout << i << endl;
        }
    } else {
        for (ll i = 1; i < max; ++i) {
            cout << i << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
#include <bitset>
using namespace std;
int main(){
    int N,i,a;
    cin >> N;
    a = 0;
    for(i = 1;i <= N;i++){
        string S = to_string(i);
        if (S.size() % 2 == 1) a++;
    }
    cout << a << endl;
}

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

int main(){
    int mod=1000000007;
    int n,w,ans=0;
    scanf("%d %d",&n,&w);
    int x=n*1000+1;
    int dp[x];
    for (int i=1;i<x;i++) dp[i]=mod;
    for (int i=0;i<n;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        for (int j=x-1-b;j>0;j--) if (dp[j]<mod) dp[j+b]=min(dp[j+b],dp[j]+a);
        dp[b]=min(dp[b],a);
    }
    for (int i=x-1;i>0;i--) if (dp[i]<=w) {
        ans=i;
        break;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
};

(function() {
  const input = require('fs').readFileSync('/dev/stdin', 'utf8');
  const Arr = (input.trim()).split("\n");
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  const summing = (a, b) => a + b;
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34940
/*input
4 0 1
1
2 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=4e15;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=305;
const ll maxlg=__lg(maxn)+2;
int dist[maxn][maxn];
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    REP(i,n){
        REP(j,n){
            if(i==j) dist[i][j]=0;
            else dist[i][j]=INF;
        }
    }
    REP(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a;
        --b;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    REP(k,n){
        REP(i,n){
            REP(j,n){
                MNTO(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    REP(i,n){
        REP(j,n){
            if(i==j) dist[i][j]=0;
            else if(dist[i][j]<=l) dist[i][j]=1;
            else dist[i][j]=INF;
        }
    }
    REP(k,n){
        REP(i,n){
            REP(j,n){
                MNTO(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int q;
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        --s;
        --t;
        if(dist[s][t]>=INF) cout<<-1;
        else cout<<dist[s][t]-1;
        cout<<'\n';
    }
}


Measured memory_bytes: 896
N = int(input())
h_list = list(map(int, input().split(" ")))

#counts = [0 for i in range(N)]

start_i = 0
#before_h = h_list[0]

end = False
max_h = 0
for i in range(1, N):
    cur_h = h_list[i]
    before_h = h_list[i-1]
    if before_h < cur_h:
        end_i = i-1

        #out_h = h
        #for j in range(end_i, start_i-1, -1):
        #    counts[j] = end_i - 
        max_h = max(end_i-start_i, max_h)

        start_i = i

        if i == N-1:
            end = True

if not end:
    end_i = N-1
    max_h = max(end_i-start_i, max_h)

print(max_h)

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

int main() {
  int p, q;
  int a, b, c;
  int lcm, gcd;

  while (1) {
    cin >> p >> q;
    if (cin.eof()) break;
    if (p > q) {
      a = p;
      b = q;
    } else {
      b = p;
      a = q;
    }

    while(a%b) {
      c = a%b;
      a = b;
      b = c;
    }
    lcm = b;
    gcd = p/lcm*q;
    cout << lcm << " " << gcd << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int
main(void)
{
	int m, f, r;
	char s;

	for (;;) {
		scanf("%d%d%d", &m, &f, &r);

		if (m < 0 && f < 0 && r < 0)
			break;

		if (m < 0 || f < 0) {
			s = 'F';
		} else if (m + f >= 80) {
			s = 'A';
		} else if (m + f >= 65) {
			s = 'B';
		} else if (m + f >= 50) {
			s = 'C';
		} else if (m + f >= 30) {
			if (r >= 50)
				s = 'C';
			else
				s = 'D';
		} else {
			s = 'F';
		}
		printf("%c\n", s);
	}

	return 0;
}



Measured memory_bytes: 2044
function Main(s) {
  var s = s.split("\n")[0].split(" ").map(e => parseInt(e, 10)).sort((a, b) => b - a);
  var cnt = 0;
  if ((s[1] - s[2]) % 2 === 0) {
    cnt += s[0] - s[1];
    s[2] += cnt;
    cnt += (s[0] - s[2]) / 2;
  } else {
    s[0]++;
    s[1]++;
    cnt++;
    cnt += s[0] - s[1];
    s[2] += s[0] - s[1];
    cnt += (s[0] - s[2]) / 2;
  }
  console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0

a_sort = sorted(a, reverse=True)

for i in range(n):
    if i%2 == 0:
        alice += a_sort[i]
    else:
        bob += a_sort[i]

print(alice-bob)

Measured memory_bytes: 9068
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    lint n, k;
    cin >> n >> k;
    lint zero = n/k;
    lint ans = pow(zero, 3);
    if(k%2 == 0){
        lint half = n/(k/2) - zero;
        ans += pow(half, 3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def gauss_jordan(A):
  m=len(A)
  n=len(A[0])
  rank=0
  for col in range(n):
    pivot=-1
    for row in range(rank,m):
      if A[row][col]!=0:
        pivot=row
        break
    if pivot==-1:
      continue
    A[pivot],A[rank]=A[rank],A[pivot]
    for row in range(m):
      if row!=rank and A[row][col]!=0:
        for col2 in range(n):
          A[row][col2]^=A[rank][col2]      
    rank+=1
  if rank==len(A):
    return True
  else:
    return False

def make_vector(val):
  ret=[]
  for i in range(60,-1,-1):
    if val&(1<<i):
      ret.append(1)
    else:
      ret.append(0)
  return ret

t=int(input())
for _ in range(t):
  n=int(input())
  arr=list(map(int,input().split()))
  s=input()
  if s[-1]=='1':
    print(1)
    continue
  A=[make_vector(arr[-1])]
  for i in range(n-2,-1,-1):
    vector=make_vector(arr[i])
    if gauss_jordan(A+[vector]):
      if s[i]=='1':
        print(1)
        break
      if s[i]=='0':
        A.append(vector)
  else:
    print(0)

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>h(n),p(n);
  rep(i,0,n)cin>>h[i]>>p[i];
  vector<ll>order(n);
  iota(ALL(order),0);
  sort(ALL(order),[&](ll x,ll y){
    return h[x]+p[x]<h[y]+p[y];
  });
  auto dp=vec(n+1,n+1,INF);
  dp[0][0]=0;
  rep(i,0,n){
    ll k=order[i];
    rep(j,0,n+1){
      if(dp[i][j]<=h[k])chmin(dp[i+1][j+1],dp[i][j]+p[k]);
      chmin(dp[i+1][j],dp[i][j]);
    }
  }
  rrep(i,0,n+1){
    if(dp[n][i]!=INF){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[55];
signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];
	sort(A,A+N);
	double ans=A[0];
	REP(i,N){
		ans=(ans+A[i])/2.;
	}
	printf("%.12lf\n",ans);
}


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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }


const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ---------------------------------------------------------------------------- -------------- 



ll choose(int n, int r){
  v64 fac(n+1,1), ifac(n+1,1), inv(n+1,1);   
  for(int i=2;i<=n;i++){
    fac[i]=fac[i-1]*i%mod; 
    int r=mod%i, q=mod/i; 
    inv[i]=mod-q*inv[r]%mod; 
    ifac[i]=ifac[i-1]*inv[i]%mod; 
  }
  return fac[n]*ifac[n-r]%mod*ifac[r]%mod; 
}

void solve(){
  ll n,m,k; 
  cin>>n>>m>>k; 
  ll ans=0;  
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=m;j++){
      ans+=((j-1)*j/2)*(n-i) + (m-j)*(m-j+1)/2*(n-i+1) +(n-i)*(n-i+1)/2*m; 
      ans%=mod; 
    }
  }
  ans*=choose(n*m-2,k-2); 
  ans%=mod; 
  cout<<ans<<endl; 
  return;
}


int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 4992
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

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

    cout << 180 * (N - 2) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, V, B, W, T := ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt()
	B -= A
	if B < 0 {
		B = -B
	}
	if B+W*T <= V*T {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    rep(i, 0, q) {
        string order;
        int a, b;
        string x;
        cin >> order >> a >> b;
        if (order == "print") {
            cout << s.substr(a, b - a + 1) << endl;
        } else if (order == "reverse") {
            reverse(s.begin() + a, s.begin() + b + 1);
        } else {
            cin >> x;
            s.replace(a, b - a + 1, x);
        }
    }
    return 0;
}



Measured memory_bytes: 3224
using System;
using System.Collections.Generic;

namespace ALDS_1_4_C_Dictionary_
{
    class Program
    {
        static void Main(string[] args)
        {
            //hashset??????????????????????????????dictionary?????????

            var hash = new HashSet<string>();
            int n = getint();
            for (int i = 0; i < n; i++)
            {
                string[] str = getsplit();
                if (str[0] == "insert")
                {
                    hash.Add(str[1]);
                }
                else if (hash.Contains(str[1]))
                    Console.WriteLine("yes");
                else
                    Console.WriteLine("no");
            }

        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
    }
}

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

int main(){
	int n;
	cin >> n;
	vector<string>w(n);
	for (int i = 0;i < n;i++) {
		cin >> w[i];
	}

	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for (int i = 0;i < n - 1;i++) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
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;
 
#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,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#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()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
int N,K;
vi v;

bool posi(int S)
{
	int k=K;
	F0R(x,N)
	{
		if(v[x]>S)
		{
			int val=(v[x]+S-1)/S;
			k-=val-1;
			if(k<0)
				return false;
		}
	}
	return true;
}

int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>N>>K;
	int l=1,r=INT_MIN;
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		v.pb(nb);
		// ckmin(l,nb);
		ckmax(r,nb);
	}
	// bug(r);
	int ans=INT_MAX;
	while(l<=r)
	{
		int m=l+(r-l)/2;
		if(posi(m))
		{
			ckmin(ans,m);
			r=m-1;
		}
		else
			l=m+1;
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4252
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint h, w;
    cin >> h >> w;
    lint a, b;
    cin >> a >> b;
    lint ans = h * w - (a * w + b * h - a * b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(3 <= n && n <= 10000){
			for(int i = 3; i <= n; i++){
				int x = i % 3;
				int y = i % 10;
				int anko = i / 10;
				int inko = i / 10 % 10;
				int unko = i / 100;
				int enko = i / 100 % 10;
				int onko = i / 1000;
				
				if(x == 0){
					System.out.print(" " + i);
				}else if(y == 3 || anko == 3 || inko == 3 || unko == 3 || enko == 3 || onko == 3){
					System.out.print(" " + i);
				}
			}
			System.out.println();
		}
		
	}

	public static void main(String[] args) {

		new Main().kami();
	}

}

Measured memory_bytes: 24136
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,t,l,b;
  int i,j,k;
  cin >> n >> t >> l >> b;
  while(n!=0){
    int ls[105]={},bs[105]={};
    for(i=0;i<l;i++){
      cin >> k;
      ls[k]=1;
    }
    for(i=0;i<b;i++){
      cin >> k;
      bs[k]=1;
    }
    double ma[105]={};
    double pre[105]={};
    double rs[105]={};
    pre[0]=1;
    int p;
    for(i=0;i<t;i++){
      fill(ma,ma+105,0);
      ma[n]=pre[n];
      for(j=0;j<n;j++){
	for(k=1;k<=6;k++){
	  p=j+k;
	  if(p>n) p=2*n-p;
	  if(bs[p]==1){
	    ma[0]+=pre[j]/6;
	  }else{
	    ma[p]+=pre[j]/6;
	  }
	}
      }
      for(j=0;j<=n;j++){
	if(ls[j]==1){
	  pre[j]=rs[j];
	  rs[j]=ma[j];
	}else{
	  pre[j]=ma[j];
	}
      }
    }
    //cout << pre[n] << endl;
    printf("%.6f\n",pre[n]);
    cin >> n >> t >> l >> b;
  }
  return 0;
}

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

using namespace std;

int gcd(int a, int b)
{
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

//Runtime Error
// int main()
// {
//   //  cout << eu_gcd(6,8) <<endl;
//   int N, GCD[N], ans = -1;

//   cin >> N;
//   int A[N];
//   for (int i = 0; i < N; i++)
//   {
//     cin >> A[i];
//   }
//   for (int i = 0; i < N; i++)
//   {
//     GCD[i] = A[0];
//     if (i == 0)
//       GCD[i] = A[1];
//     for (int j = 0; j < N; j++)
//     {
//       if (j == i)
//         continue;
//       GCD[i] = gcd(GCD[i], A[j]);
//       //printf("j = %d A[j] = %d\n",j,A[j]);
//     }
//     //cout << "GCD" << i << "=" << GCD[i] <<endl;
//   }
//   for (int i = 0; i < N; i++)
//   {
//     ans = max(ans, GCD[i]);
//   }
//   cout << ans << endl;
//   return 0;
// }

int main()
{
  int N, ans = 0;
  cin >> N;
  int A[N];
  int L[N + 1], R[N + 1];
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  L[0] = R[N] = 0;
  //L-> 左からi番目までの最大公約数
  //R-> 右からi番目までの最大公約数
  for (int i = 0; i < N; i++)
  {
    L[i + 1] = gcd(L[i], A[i]);
    //R[N - i] = gcd(A[N - i - 1], R[N - i + 1]);
  }
  for (int i = 0; i < N; i++)
  {
    R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
  }

  for (int i = 0; i < N; i++)
  {
    ans = max(ans, gcd(L[i], R[i + 1]));
  }
  cout << ans << endl;
  return 0;
}
//A[0] = 7, A[1] = 6 A[2] = 8
//L[0] = 0, L[1] = 7 L[2] = 1 L[3] = 2
//R[0] = ?, R[1] = 1 R[2] = 2 R[3] = 8 R[4] = 0

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

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

  cin >> A >> B;
  string ans = (A*B)%2!=0?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256