akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{c:chars};
    let c = c[0];
    println!("{}", (c as u8 + 1) as char);
}

Measured memory_bytes: 4352
H, W = map(int, input().split())
def change(x):
    if x == '#':
        return 1
    else:
        return 0
field = list()
for i in range(H):
    field.append(list(map(change,[i for i in input()])))

vector = [[1, 0], [0, 1]]
check_list = [[0 for _ in range(W)] for i in range(H)]
check_list[0][0] = 1
count_list = [[[0, [0, 0]] for _ in range(W)] for i in range(H)]
count_list[0][0][0] = field[0][0]
zahyo_check = [[(0, 0)]]
for i in range(H+W-2):
    zahyo = zahyo_check[i]
    zahyo_kari = list()
    for (y, x) in zahyo:
        for (dy, dx) in vector:
            v = count_list[y][x][0]
            y_k = y + dy
            x_k = x + dx
            try:
                if field[y_k][x_k] == 1 and field[y][x] == 0:
                    v += 1
                        
                if check_list[y_k][x_k] == 0:
                    count_list[y_k][x_k][0] = v
                    count_list[y_k][x_k][1] = [y, x]
                    check_list[y_k][x_k] = 1
                    zahyo_kari.append((y_k, x_k))
                    
                else:
                    if v < count_list[y_k][x_k][0]:
                        count_list[y_k][x_k][0] = v
                        count_list[y_k][x_k][1] = [y, x]
                        
            except:
                pass
    zahyo_check.append(zahyo_kari)

print(count_list[H-1][W-1][0])

Measured memory_bytes: 5876
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll N,i;
    cin>>N>>i;
    cout<<N-i+1<<endl;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int x,n;cin >> x >> n;
    vector<int> p(n);rep(i,n)cin >> p[i];
    rep(i,105)
    {
        int l,s;
        l = x+i;
        s = x-i;
        bool flag = true;
        for (auto &&j : p)
        {
            if(s==j)
            {
                flag = false;
                break;
            }

        }
        if(flag)
        {
            cout << s << endl;
            return 0;
        }else
        {
            flag = true;
            for (auto &&j : p)
            {
                if (l == j)
                {
                    flag = false;
                    break;
                }
                
            }
            if(flag)
            {
                cout << l << endl;
                return 0;
            }
        }
        
        
    }
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

bool check(int a, int b, int x) {
    return x > abs(a - b);
}

int main() {
    
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i,N) cin >> L[i];

    sort(L.begin(), L.end(), greater<int>());

    long long ans = 0;

    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (!check(L[i], L[j], L[j + 1])) continue;
            int bottom = j + 1;
            int top = N - 1;
            while (bottom < top) {
                int x = bottom + (top - bottom) / 2;
                if (x == bottom) x++;
                if (check(L[i], L[j], L[x])) bottom = x;
                else top = x - 1;
            }
            ans += bottom - (j + 1) + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// ref. https://www.youtube.com/watch?v=bHzohtVsG0Q&feature=youtu.be

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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 rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const int MX = 2005;
bool d[3][3][MX]; // d[i][j][k] .. check (i,j) pair with k diff

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  vector<string> s(3);
  rep(i, 3) {
    cin >> s[i];
  }

  int ans = 3 * MX;
  sort(s.begin(), s.end());
  do {
    rep(i,3)rep(j,3)rep(k,MX) {
      if (i >= j) { continue; } // only check (i < j)

      // Check (i,j) pair with k difference.
      // check s[i][ni] and s[j][nj]. nj = ni-k.
      bool ok = true;
      for (int ni = k; ni < s[i].size(); ++ni) {
        int nj = ni-k;
        if (nj >= s[j].size()) { break; }
        if (s[i][ni] == '?' || s[j][nj] == '?') { continue; }
        if (s[i][ni] != s[j][nj]) { ok = false; }
      }
      d[i][j][k] = ok;
    }

    auto f = [&](int i, int j, int k) {
      // If diff is larger thant the size of i, it is true.
      if (k >= s[i].size()) { return true; }
      return d[i][j][k];
    };

    rep(x,MX)rep(y,MX) {
      // diff x at (0,1), diff y at (1,2)
      if (!f(0,1,x)) { continue; }
      if (!f(1,2,y)) { continue; }
      if (!f(0,2,x+y)) { continue; }
      int now = 0;
      now = max<int>(now, s[0].size());
      now = max<int>(now, x+s[1].size());
      now = max<int>(now, x+y+s[2].size());
      ans = min(ans, now);
    }
  } while (next_permutation(s.begin(), s.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

H = I()
W = I()
N = I()

t = max(H,W)
print(math.ceil(N/t))

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,k;
        cin>>n>>k;

        vector<ll> ans;

        for(ll i=0;i<n;i++)
        {
            ll x;
            cin>>x;

            ans.pb(x);
        }

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

        ll sum=0;

        for(ll i=0;i<k;i++)
        sum+=ans[i];

        cout<<sum;
    }
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
#define N 100010
const ll inf=0x3f3f3f3f3f3f3f3fll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m;
ll dp[N],mn[N][19];
vector<pair<int,int> > vec[N];
void Insert(int x){
	mn[x][0]=dp[x];
	for(int i=1;i<=18;++i){
		if(x<=(1<<i-1))break;
		mn[x][i]=min(mn[x][i-1],mn[x-(1<<i-1)][i-1]);
	}
}
ll Query(int l,int r){
	int k=log2(r-l+1);
	return min(mn[r][k],mn[l+(1<<k)-1][k]);
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int l=read(),r=read(),c=read();
		vec[r].emplace_back(l,c);
	}
	memset(mn,0x3f,sizeof(mn));
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	Insert(1);
	for(int i=2;i<=n;++i){
		for(auto x:vec[i]){
			dp[i]=min(dp[i],Query(x.first,i-1)+x.second);
		}
		Insert(i);
	}
	printf("%lld\n",dp[n]==inf?-1:dp[n]);
	return 0;
}


Measured memory_bytes: 24552
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int MAX=1e5;
int a[MAX];

int main()
{
    int n;
    cin>>n;
    int thiscnt=0,maxcnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0){
            if(a[i]<=a[i-1]){
                thiscnt++;
            }
            else{
                thiscnt=0;
            }
            if(thiscnt>maxcnt){
                maxcnt=thiscnt;
            }
        }
    }
    cout<<maxcnt;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<pair<int, ll> > td(n);
  for (auto &x: td) cin >> x.first >> x.second;

  vector<vector<ll> > c(n);
  for (int i = 0; i < n; i++) {
    c[td[i].first-1].push_back(td[i].second);
  }

  for (int i = 0; i < n; i++) sort(c[i].rbegin(), c[i].rend());

  ll ans = 0;
  ll varCount = 0;
  priority_queue<ll, vector<ll>, greater<ll> > noPenalty, penalty;
  for (int i = 0; i < n; i++) {
    if (c[i].size() == 0) continue;
    varCount++;
    penalty.push(c[i][0]);
    for (int j = 1; j < (int) c[i].size(); j++) noPenalty.push(c[i][j]);
    for (auto &x: c[i]) ans += x;
  }
  ans += varCount * varCount;
  for (int i = n; i > k; i--) {
    ll p, np;
    p = penalty.top();
    if (!noPenalty.empty()) np = noPenalty.top();
    else np = 9e18;
    if (p + 2 * varCount - 1 <= np) {
      penalty.pop();
      ans -= p + 2 * varCount - 1;
      varCount--;
    }
    else {
      noPenalty.pop();
      ans -= np;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8440
#include <iostream>
#include <vector>
#include <cmath>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
 
const ll M = pow(10,9)+7;
 
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
// k^{M-2} == k^{-1}
//a,bの範囲的にこれだけ配列を用意していけば十分
 
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
 
ll comb2(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
 
long long gcd(long long a, long long b)
{
    long long c;
 
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
 
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
 
    return a;
}
 
ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
 
pair<ll, ll> add_bunsuu(pair<ll, ll> a, pair<ll, ll> b){
    ll bunbo = lcm(a.second, b.second);
 
    cout << a.first << "/" << a.second << endl;
    cout << b.first << "/" << b.second << endl;
    cout << a.first * bunbo / a.second + b.first * bunbo / b.second << "/" << bunbo << endl;
 
    return make_pair(a.first * bunbo / a.second + b.first * bunbo / b.second , bunbo);
}
 
ll valid_amida_pattern(ll w){
    if(w <= 0){
        return 1;
    }
    return valid_amida_pattern(w - 1) % 1000000007 + valid_amida_pattern(w - 2) % 1000000007;
}
 
int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    ll** int_probs = new ll*[H + 1];
    for(ll i = 0; i < H + 1; i ++){
        int_probs[i] = new ll[W];
    }
 
    for(ll i = 0; i < W; i ++){
        if(i == 0){
            int_probs[0][i] = 1;
        }
        else{
            int_probs[0][i] = 0;
        }
    }
 
    for(ll i = 1; i < H + 1; i ++){
        for(ll n = 0; n < W; n ++){
            if(n == 0){
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(W - 2) % 1000000007 + int_probs[i - 1][n + 1] * valid_amida_pattern(W - 3) % 1000000007;
            }
            else if (n == W - 1){
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(W - 2) % 1000000007 + int_probs[i - 1][n - 1] * valid_amida_pattern(W - 3) % 1000000007;
            }
            else{
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(n - 1) * valid_amida_pattern(W - n - 2) % 1000000007
                    + int_probs[i - 1][n + 1] * valid_amida_pattern(n - 1) * valid_amida_pattern(W - n - 3) % 1000000007
                    + int_probs[i - 1][n - 1] * valid_amida_pattern(n - 2) * valid_amida_pattern(W - n - 2) % 1000000007;
            }
            int_probs[i][n] = int_probs[i][n] % 1000000007;
        }
    }
    cout << int_probs[H][K - 1];
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

int main() {
	string S;
	cin >> S;

	vector<bool> c(26, false);
	rep(i, S.length())
	{
		c[(int)(S[i] - 'a')] = true;
	}

	rep(i, 26)
	{
		if (c[i])
		{
			continue;
		}
		cout << S << (char)('a' + (char)i) << endl;
		return 0;
	}

	for (int i = S.length() - 1; i > 0; i--)
	{
		int index = S[i] - 'a';
		c[index] = false;
		int next = S[i - 1] - 'a';
		if (index > next)
		{
			cout << S.substr(0, i - 1);
			for (int j = next; j < 26; j++)
			{
				if (!c[j])
				{
					cout << (char)('a' + (char)j) << endl;
					return 0;
				}
			}
			for (int j = 0; j < 26; j++)
			{
				if (!c[j])
				{
					cout << (char)('a' + (char)j) << endl;
					return 0;
				}
			}
		}
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
    int N, A, B;
    scanf("%d",&N);
    scanf("%d",&A);
    scanf("%d",&B);

    int result = 0;
    for(int i = 1; i <= N; i++) {
        int total = 0;
        int target = i;
        while(target > 0) {
            total += target%10;
            target /= 10;
        }
        if(A <= total && total <= B) {
            result += i;
        }
    }
    printf("%d\n",result);
}


Measured memory_bytes: 128
def solve(X):
    ans = 1
    if X <= 1999:
        ans = 1
    if X <= 1799:
        ans = 2
    if X <= 1599:
        ans = 3
    if X <= 1399:
        ans = 4
    if X <= 1199:
        ans = 5
    if X <= 999:
        ans = 6
    if X <= 799:
        ans = 7
    if X <= 599:
        ans = 8
    print(ans)


if __name__ == '__main__':
    # S = input()
    X = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(X)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int temp;
  int p1 = 0, p2 = 0, p3 = 0;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    if (temp <= A) {
      p1++;
    } else if (temp <= B) {
      p2++;
    } else {
      p3++;
    }
  }
  cout << min(p1, min(p2, p3));

  return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int h, w;
	cin >> h >> w;

	vector<vector<char>> s(h, vector<char>(w));
	rep (i, 0, h)
		rep (j, 0, w)
		cin >> s[i][j];

	bool judge = true;
	rep (i, 0, h) {
		rep (j, 0, w) {
			if (s[i][j] == '#') {
				if (i != 0 && s[i - 1][j] == '#')
					continue;
				if (i != h - 1 && s[i + 1][j] == '#')
					continue;
				if (j != 0 && s[i][j - 1] == '#')
					continue;
				if (j != w - 1 && s[i][j + 1] == '#')
					continue;

				judge = false;
				break;
			}
		}
	}

	if (judge)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

long long int M, A, R, C, H, N;
string s;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        cin >> s;
        switch(s[0]){
            case 'M':
                ++M;
                continue;
            case 'A':
                ++A;
                continue;
            case 'R':
                ++R;
                continue;
            case 'C':
                ++C;
                continue;
            case 'H':
                ++H;
                continue;
        }
    }
    cout << M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H << endl;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <cstdio>
#include <iostream>
#include <cstdlib>

namespace IO
{
//    inline char gc()
//    {
//        static char s[1<<20|1]={0},*p1=s,*p2=s;
//        return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
//    }
	inline char gc() { return getchar(); }
	inline long long read()
	{
		long long ret=0;bool flag=0;char c=gc();
		while ((c<'0')|(c>'9')) flag ^= !(c^'-'),c=gc();
		while ((c>='0')&(c<='9')) ret=(ret<<1)+(ret<<3)+(c^'0'),c=gc();
		return flag?-ret:ret;
 	}
 	char OutputAns[1<<20|1],*OutputCur = OutputAns;
 	inline void output()
 	{
 		OutputCur -= fwrite(OutputAns,1,OutputCur - OutputAns,stdout);
	}
	inline void print(long long ans)
	{
		char s[20]={0};
		if (OutputCur - OutputAns + sprintf(s,"%lld",ans) >> 20) output();
		OutputCur += sprintf(OutputCur,"%lld",ans);
	}
	inline void printc(char c)
	{
		if (OutputCur - OutputAns + 1 >> 20) output();
		*(OutputCur++) = c;
	}
}

using IO::read;
using IO::print;
using IO::printc;
using IO::output;

const int M = 3e5 + 11;

const int INF = 1e9 + 7;

int End[25][M], Fir[25][M], Dp1[M], Dp2[M], Pos[M], T[25];

int n, lim, top, sumBlock;

inline void Input()
{
	n = read(), lim = read(); for (int i = 1;i <= n; ++i) Pos[i] = read();
	int tmp = lim; while (tmp) { T[top++] = tmp >> 1; tmp >>= 1; } T[top] = lim;
}

inline void Solve()
{
	for (int i = 0;i <= top; ++i)
	{
		Fir[i][1] = 1;
		for (int j = 2;j <= n; ++j)
		{
			if (Pos[j] - Pos[j - 1] <= T[i]) Fir[i][j] = Fir[i][j - 1];
			else Fir[i][j] = j;
		}
	}
	for (int i = 0;i <= top; ++i)
	{
		End[i][n] = n;
		for (int j = n - 1; j >= 1; --j)
		{
			if (Pos[j + 1] - Pos[j] <= T[i]) End[i][j] = End[i][j + 1];
			else { End[i][j] = j; if (i == top) ++sumBlock; }
		}
	} 
	if (sumBlock > top)
	{
		for (int i = 1;i <= n; ++i) puts("Impossible");
		exit(0);
	} int all = (1<<top);
	for (int s = 0;s < all; ++s) Dp2[s] = n + 1;
	for (int S = 0;S < all; ++S)
		for (int i = 0;i <= top; ++i)
			if (!((1<<i) & S))	
				Dp1[S | (1<<i)] = std::max(Dp1[S | (1<<i)], End[i][Dp1[S] + 1]),
				Dp2[S | (1<<i)] = std::min(Dp2[S | (1<<i)], Fir[i][Dp2[S] - 1]);
	for (int i = 1;i <= n; ++i)
	{
		bool ok = 0;
		for (int S = 0;S < all; ++S)
		{
			int ss = (all - 1) ^ S;
			if (Dp1[S] >= i - 1 && Dp2[ss] <= End[top][i] + 1) { ok = 1; break; }
		}
		for (int j = i;j <= End[top][i]; ++j)
		{
			if (ok) puts("Possible");
			else puts("Impossible");
		} i = End[top][i];
	}
}

int main(void)
{
//	freopen("jump.in","r",stdin);
///	freopen("jump.out","w",stdout);
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 36576
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
int n;
struct Block{
	int w;
	int s;
	long long v;
}b[1005];
bool operator <(Block x,Block y){
	return x.w+x.s<y.w+y.s;
}
long long dp[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>b[i].w>>b[i].s>>b[i].v;
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i){
		for(int j=b[i].s;j>=0;--j){
			dp[j+b[i].w]=max(dp[j+b[i].w],dp[j]+b[i].v);
		}
	}
	long long ans=0;
	for(int i=1;i<=100000;++i){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>
#define LEN 100000

int i=0,head,tail,TIME=0;
int MAX,Q;

struct p{
	char name[20];
	int t;
};

struct p q[LEN];

int main(){

    scanf("%d%d", &MAX,&Q);
    for(tail=0;tail<MAX;tail++){

        scanf("%s%d", &q[tail].name,&q[tail].t);

    }

	for(head=0,tail=MAX;head!=tail;head=(head+1)%(MAX+1)){

		i=head;
		if(q[i].t<=Q){

			TIME+=q[i].t;
			printf("%s %d\n", q[i].name,TIME);
			q[i].t=0;

		}else{

			TIME+=Q;
			q[tail].t=q[i].t-Q;
			strcpy(q[tail].name,q[i].name);
			tail=(tail+1)%(MAX+1);

		}
	}
	return 0;
}



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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    string s[2];
    for(auto &z : s)
        cin >> z;

    for(int i = 0; i < n; ++i)
        cout << s[0][i] << s[1][i];
}


Measured memory_bytes: 3612
#include <stdio.h>

int number[10];

int check(int num) {
	int i;
	
	while(num > 0) {
		if (number[num%10]) {
			return 0;
		}
		num /= 10;
	}
	
	return 1;
}

int main(void) {
	int n,k,d,i,ans;

	scanf("%d %d",&n,&k);
	
	for (i = 0;i < k;i++) {
		scanf("%d",&d);
		number[d] = 1;
	}
	
	ans = n;
	while(!check(ans)) {
		ans++;
	}
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>  // ver1.9
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(8);
  int n;
  cin >> n;
  Vi a(100002);
  int memo;
  rep(i,0,n){
    cin >> memo;
    a[memo]++;
  }
  int maxx=0;
  
  rep(i,0,100000){
    memo = a[i]+a[i+1]+a[i+2];
    maxx = max(maxx,memo);
  }
  cout << maxx << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int sumb = 0;
Int q, ord;
Int a, b;
multiset<Int> small, big;
Int smallsum = 0, bigsum= 0;

Int calc(Int x){
    return x * small.size() -  smallsum + bigsum - x * big.size();
}

int main(){
    cin >> q;
    while(q--){
        cin >> ord;
        if(ord == 1){
            cin >> a >> b;
            sumb += b;
            if(small.empty() || a < *small.rbegin()){
                small.insert(a);
                smallsum += a;
            }
            else{
                big.insert(a);
                bigsum += a;
            }
            while(small.size() < big.size()){
                small.insert(*big.begin());
                smallsum += *big.begin();
                bigsum -= *big.begin();
                big.erase(big.begin());
            }
            while(small.size() > big.size() + 1){
                big.insert(*small.rbegin());
                bigsum += *small.rbegin();
                smallsum -= *small.rbegin();
                small.erase(small.find(*small.rbegin()));
            }
        }
        else{
            cout << *small.rbegin() << " " << sumb + calc(*small.rbegin()) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
    string str;
    cin >> str;
    if(str == "hihi" || str == "hihihi" || str == "hihihihi" || str == "hihihihihi" || str == "hi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N + 2);
    A[0] = A[N + 1] = 0;
    for (int i = 1; i <= N; i++)
        cin >> A[i];
    long long sum = 0;
    for (int i = 1; i <= N + 1; i++)
        sum += abs(A[i] - A[i - 1]);
    for (int i = 1; i <= N; i++)
    {
        cout << sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  int n;
  cin >> n;
  int p[30];
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < n - 2; i++)
  {
    if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])
    {
      ans++;
    }
    if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

#define N_MAX 5000
#define M_MAX 500000

int nails[N_MAX+2][N_MAX+2];

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

  rep(i, n){
    rep(j,n)
      nails[i][j]=0;
  }

  int a,b,x;
  rep(i, m){
    scanf("%d %d %d", &a, &b, &x);
    nails[a][b]=max(x+1, nails[a][b]);
  }

  int res=0;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=i; j++){
      nails[i][j] = max(nails[i][j],
			max(nails[i-1][j-1], nails[i-1][j])-1);
      if(nails[i][j]>0) res++;
    }
  }

  cout << res << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, m;
    cin >> h >> w >> m;
    set<P> st;
    map<int, int> Hmp, Wmp;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        ++Hmp[a];
        ++Wmp[b];
        st.insert(P(a, b));
    }
    int H1id = 0, H2id = 0, H1mx = 0, H2mx = 0;
    for(auto p : Hmp){
        if(p.second > H1mx){
            H2mx = H1mx;
            H2id = H1id;
            H1mx = p.second;
            H1id = p.first;
        }
        else if(p.second > H2mx){
            H2mx = p.second;
            H2id = p.first;
        }
    }
    //cout << H1id << " "<< H2id << " " << H1mx << " " << H2mx << endl;
    int W1id = 0, W2id = 0, W1mx = 0, W2mx = 0;
    for(auto p : Wmp){
        if(p.second > W1mx){
            W2mx = W1mx;
            W2id = W1id;
            W1mx = p.second;
            W1id = p.first;
        }
        else if(p.second > W2mx){
            W2mx = p.second;
            W2id = p.first;
        }
    }
    map<int, int> mp1;
    for(auto p : Hmp){
        if(p.second == H1mx){
            mp1[p.first] = p.second;
        }
    }
    map<int, int> mp2;
    for(auto q : Wmp){
        if(q.second == W1mx){
            mp2[q.first] = q.second;
        }
    }
    //cout << W1id << " "<< W2id << " " << W1mx << " " << W2mx << endl;
    int ans = 0, ideal_ans = H1mx + W1mx;
    for(auto p : mp1){
        for(auto q : mp2){
            if(st.find(P(p.first, q.first)) == st.end()){
                cout << ideal_ans << endl;
                return 0;
            }
        }
    }
    --ideal_ans;
    chmax(ideal_ans, 0);
    cout << ideal_ans << endl;
    return 0;
}


Measured memory_bytes: 73932
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int N,M,Q;

ll ans=0;
void dfs(vector<int> &A,vector<int> a,vector<int> b,vector<int> c,vector<int> d){
    if(A.size()==N){
        ll tmp=0;
        for(int i=0;i<Q;i++){
            if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
        }
        ans=max(ans,tmp);
        return;
    }

    if(A.size()==0){
        for(int v=0;v<M;++v){
            A.push_back(v);
            dfs(A,a,b,c,d);
            A.pop_back();
        }
    }else{
        for(int v=A[A.size()-1];v<M;++v){
            A.push_back(v);
            dfs(A,a,b,c,d);
            A.pop_back();
        }
    }
    

}
int main(){
    cin>>N>>M>>Q;
    vector<int> a(Q),b(Q),c(Q),d(Q);
    REP(i,Q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    
    //全探索
    vector<int> A;
    dfs(A,a,b,c,d);
    cout<<ans<<endl;

    
}

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

int main(){
    string s;
    cin>>s;
    int count=0;
    rep(j,s.size()){
        int now=0;
        for(int i=j;i<s.size();i++){
        if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
            now+=1;
        }
        else {
            break;
        }
        }

        count=max(count,now);
    }
    cout<<count<<endl;
}



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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(){
	ios_base::sync_with_stdio(false);
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	bool answer = false;
	for(ll i = 0; i < n; ++i){
		const ll x_min = a - d * i, x_max = a - c * i;
		const ll y_min = x_min + (n - i - 1) * c;
		const ll y_max = x_max + (n - i - 1) * d;
		if(y_min <= b && b <= y_max){ answer = true; }
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define log(x,b) (log(x)/log(b))
using namespace std;

string s;

int32_t main()
{
    int n;
    cin>>n>>s;
    int cnt=0;
    int res=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){cnt++;res=max(res,cnt);}
        else cnt--;
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3600
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

//dp[i][j] tells the no. of ways to distribute total of j candies among the first i boys
//according to the given constraints.

ll dp[104][N];

int main()                  
{
    int n,k;
    
    scn(n); scn(k);
    
    int a[n];
    
    rep(i,0,n)
    scn(a[i]);
    
    dp[0][0]=1;
    
    rep(i,0,n)
    {
        rep(j,1,k+1)
        dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        
        rep(used,0,k+1)
        {
            int l=used,r=used+min(k-used,a[i]);
            
            dp[i+1][l]=(dp[i+1][l]+dp[i][used])%mod;
            
            dp[i+1][r+1]=(dp[i+1][r+1]-dp[i][used]+mod)%mod;
        }
    }
    
    cout<<dp[n][k];
} 


Measured memory_bytes: 80128
import java.util.*;

public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int n1 = n;
		int count=0;
		int j;
		for(int i=0 ; ;i++){
			n1=n;
			n1-=i*r;
			j=0;
			while(n1-j*g>=0){
				if(n1<0) break;
				if((n1-j*g)%b==0) count++;
				j++;
			}
			if(n1<0) break;
		}
		System.out.println(count);
		}
}

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

int main(){
int N;
cin>>N;
  vector<int> vec(N);
  int sum=0;
  int max=0;
  for(int i=0;i<N;i++){
    cin>>vec.at(i);  
    
    if(max<=vec.at(i)){
      max=vec.at(i);
      sum++;
    }
    
    
  }
  
    cout<<sum<<endl;
  }
  


Measured memory_bytes: 256
n = int(input())
x = 0
l = 0
while x < n:
    l += 1
    x += 26**l
for i in range(1,l):
    n -= 26**i
n -= 1
ans = ""
while len(ans) < l:
    ans += chr(ord("a")+n%26)
    n //= 26
print(ans[::-1])

Measured memory_bytes: 9092
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

vector<pair<int, int>> vp;

int a[12];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int t;
        cin >> t;
        if (t / 400 >= 8)
            a[8]++;
        else
        {
            a[t / 400]++;
        }
    }

    int color = 0;
    for (int i = 0; i < 8; ++i)
        if (a[i])
            color++;

    //cout << color << endl;

    if (color == 0)
    {
        cout << 1 << " ";
    }
    else
    {
        cout << color << " ";
    }
    cout << color + a[8] << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

ll p[55],a[55];

ll func(int N,ll X) {
  if ( N == 0 && X <= 0 ) return 0;
  else if ( N == 0 && X > 0 ) return 1;
  else if ( X <= 1+a[N-1] ) return func(N-1,X-1);
  else if ( X == 2+a[N-1] ) return p[N-1]+1;
  else if ( X <= 2+2*a[N-1] ) return p[N-1]+1+func(N-1,X-2-a[N-1]);
  else return 2*p[N-1]+1;
}

int main() {
  int N; ll X; cin >> N >> X;
  p[0] = 1;
  a[0] = 1;
  for ( int i = 1; i <= N; i++ ) {
    p[i] = p[i-1] * 2 + 1;
  }

  for ( int i = 1; i <= N; i++ ) {
    a[i] = a[i-1] * 2 + 3;
  }

  cout << func(N,X) << endl;
  return 0;
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

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

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

//typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		40010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//



//
int main(){
	int M,D;cin>>M>>D;

	int d1 = D%10, d10 = D/10;
	int ans = 0;
	REPS(i,2,M+1){
		REPS(j,2,d10+1)REPS(k,2,10){
			if(i == (j*k) && D>=(j*10+k)){
				ans++;
				//printf("%d %d %d\n",i,j,k);
			}
		}
	}

	cout << ans << endl;

	return 0;
}




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

typedef long long ll;
const ll N = 200005, inf = 1e18;

ll n, a[N], s[N], ans = inf;

ll sum (ll S, ll E) {
	return s[E] - s[S-1];
}

ll getb (ll A, ll B) {
	ll S = A, E = B;
	while(S<E) {
		ll M = (S+E)/2;
		sum(A, M) >= sum(M+1, B) ? E = M : S = M+1;
	}
	return S;
}

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		s[i] = s[i-1] + a[i];
	}
	for(ll i=2;i<=n-2;i++) {
		ll I1[2], I2[2];
		I1[0] = getb(1, i);
		I1[1] = I1[0]+1;
		I2[0] = getb(i+1, n);
		I2[1] = I2[0]+1;
		for(auto &A : I1) {
			for(auto &B : I2) {
				ans = min(ans, max({sum(1, A-1), sum(A, i), sum(i+1, B-1), sum(B, n)}) - min({sum(1, A-1), sum(A, i), sum(i+1, B-1), sum(B, n)}));
			}
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
N = int(input())

import sys
sys.setrecursionlimit(10**6)

def dfs(v, c, p):
    k = 1
    for _v, _id in V[v]:
        if _v == p:
            continue
        if k == c:
            k += 1
        C[_id] = k
        dfs(_v, k, v)
        k += 1

V = [[] for _ in range(N)]
C = [-1 for _ in range(N-1)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append([b, i])
    V[b].append([a, i])

dfs(0, -1, -1)
print(max(C))
for i in range(N-1):
    print(C[i])

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L < R) {
  	cout << "Right" << endl;
  }
  else if (L == R) {
  	cout << "Balanced" << endl;
  }
  else {
  	cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
import sys
import copy
import math
import fractions

import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
import numpy as np
from decimal import *

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == '__main__':
    a,b,c = map(int, input().split())
    np.set_printoptions(precision=100)

    while(1):
        com = gcd(a,b,c)

        if com ==1:
            break
        else:
            a = a // com
            b = b // com
            c = c // com
    ra = Decimal(a).sqrt()
    rb = Decimal(b).sqrt()
    rc = Decimal(c).sqrt()
    if  ra + rb < rc:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14424
#include<bits/stdc++.h>
using namespace std;
char n;
int main()
{
	cin>>n;
	if(n=='a'||n=='e'||n=='i'||n=='o'||n=='u')
	{
		cout<<"vowel"<<endl;
		return 0;
	}
	cout<<"consonant"<<endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long n = sc.nextLong();

        Vector<Long> vector = new Vector<>();
        long i = 2;
        while (i*i <= n) {
            if (n % i == 0) {
                vector.add(i);
                n /= i;
            } else {
                i++;
            }
        }
        if (n > 1)
            vector.add(n);
        vector.add(-1l);  // 番兵

        long ans = 0;
        long num = vector.get(0);
        int cnt = 1;
        for (int j = 1; j < vector.size(); j++) {
            long tmp = vector.get(j);
            if (num == tmp) {
                cnt++;
            } else {
                int cur = 1;
                while (cnt >= cur) {
                    cnt -= cur++;
                    ans++;
                }
                cnt = 1;
                num = tmp;
            }
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32884