akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ cp-batch Partition | diff Partition.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Partition.cpp && ./a.out

/*
 
 1/17/2019
 
 15:06-
 
 */


LL N,M;

void solve() {
  LL res=1LL;
  for(LL p=1; p*p<=M; ++p) if(M%p==0) {
    LL q=M/p;
    if(q>=N) SMAX(res,p);
    if(p>=N) SMAX(res,q);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define lb lower_bound
#define ld long double
using namespace std;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ld l;
	cin>>l;
	ld hh = l/(ld)3;
	ld ans = hh*hh*hh;
	cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //x???n???????¨????????????????n??????2?????¨?¨???????????¨????
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//???????????????
        }
        x=(x*x)%mod;//2???
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int zenbu=0;
    int kidoku=0;
};

class xxIntu {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        //?¬¬1?????¶
        if(riLeft.z != riRight.z){
            return riLeft.z < riRight.z;//<:??????(?°??????????)???>:??????(??§?????????)
        }
        //?¬¬2?????¶
        return riLeft.x < riRight.x;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //????????????
    
    int n;
    cin >> n;
    int a[100000];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    vector<int>lis;
    lis.clear();
    
    for(int i=0;i<n;i++){
        vector<int>::iterator it = lower_bound(lis.begin(),lis.end(),a[i]);
        if(it==lis.end()){
            lis.push_back(a[i]);
        }else{
            *it=a[i];
        }
    }
    
    cout << lis.size() << endl;
    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>

#define ll long long int

const ll MOD = 998244353;

ll facs[300005];
ll invs[300005];

using namespace std;

ll mod_pow(ll k, ll pow) {
  ll ans = 1;
  while (pow > 0) {
    if (pow & 1) ans = ans * k % MOD;
    k = k * k % MOD;
    pow >>= 1;
  }
  return ans;
}

ll get_ways(ll n, ll na, ll nb) {
  ll nca = (facs[n] * ((invs[n - na] * invs[na]) % MOD)) % MOD;
  ll ncb = (facs[n] * ((invs[n - nb] * invs[nb]) % MOD)) % MOD;
  return (nca * ncb) % MOD;
}

int main() {
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  invs[0] = 1;
  facs[0] = 1;
  for (int i = 1; i <= n; i++) {
    facs[i] = facs[i - 1] * i % MOD;
    invs[i] = (invs[i - 1] * mod_pow(i, MOD - 2)) % MOD;
  }
  ll ans = 0;
  for (ll na = 0; na <= n; na++) {
    if (k < na * a) break;
    if ((k - na * a) % b == 0) {
      ll nb = (k - (na * a)) / b;
      if (nb <= n) {
	ll ways = get_ways(n, na, nb);
	ans = (ans + ways) % MOD;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 4992
a = input().split()
w = int(a[0])
h = int(a[1])
n = int(a[2])

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    a = input().split()
    wp = int(a[0])
    hp = int(a[1])
    ap = int(a[2])
    if ap == 1:
        if x_min < wp:
            x_min = wp
    elif ap == 2:
        if x_max > wp:
            x_max = wp
    elif ap == 3:
        if y_min < hp:
            y_min = hp
    elif ap == 4:
        if y_max > hp:
            y_max = hp
    # print(x_min, x_max, y_min, y_max)

if x_max < x_min:
    ws = 0
else:
    ws = x_max - x_min

if y_max < y_min:
    hs = 0
else:
    hs = y_max - y_min

squea = ws * hs

print(squea)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    fastio;
    int h, a, c=0;
    cin >> h >> a;
    while(1){
        h = h-a;
        ++c;
        if(h<=0){
            break;
        }
    }
    cout << c << "\n";
    #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  ll a, b, k, d;
  cin >> a >> b >> k;
  d = min(a, k);
  a -= d;
  k -= d;
  d = min(b, k);
  b -= d;
  k -= d;
  cout << a << ' ' << b << '\n';
}

int main(){
  fastio

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


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

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

using namespace std;


int main(){
    string s;
    cin >> s;
    char n = s[0];
    ll cnt = 0;
    rep(i, (ll)s.size()){
        if(n != s[i]){
            cnt++;
            n = s[i];
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1020
object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val List(a,b,k) = List.fill(3)(sc.nextInt)
    val gcdAB = gcd(a,b)
    var divisor = 1
    var ans:Int = gcdAB
    var count = 0
    while(count != k){
      if(gcdAB % divisor == 0){
        count += 1
        ans = gcdAB / divisor
      }
      divisor += 1
    }
    
    println(ans)
    
  }
  
  def gcd(a:Int, b:Int) : Int = {
    if(a<b) gcd(b,a) else if(b==0) a else gcd(b,a%b)
  }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

constexpr ll MOD = 1'000'000'007;
int N, K;
ll cnt[100100];

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

    std::cin >> N >> K;

    ll res = 0;

    for(int g=K;g>=1;--g){
        cnt[g] = mod_expt<ll>(K / g, N, MOD);

        for(int i=2*g;i<=K;i+=g){
            cnt[g] -= cnt[i];
            if(cnt[g] < 0){
                cnt[g] += MOD;
            }
        }

        res = res + cnt[g] * g % MOD;
        if(res >= MOD){
            res -= MOD;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 4432
name1,a1,b1=input().split()
name2,a2,b2=input().split()
name3,a3,b3=input().split()
name4,a4,b4=input().split()
name5,a5,b5=input().split()
name6,a6,b6=input().split()
name7,a7,b7=input().split()
name8,a8,b8=input().split()
name9,a9,b9=input().split()

print(name1,int(a1)+int(b1),int(a1)*200+int(b1)*300)
print(name2,int(a2)+int(b2),int(a2)*200+int(b2)*300)
print(name3,int(a3)+int(b3),int(a3)*200+int(b3)*300)
print(name4,int(a4)+int(b4),int(a4)*200+int(b4)*300)
print(name5,int(a5)+int(b5),int(a5)*200+int(b5)*300)
print(name6,int(a6)+int(b6),int(a6)*200+int(b6)*300)
print(name7,int(a7)+int(b7),int(a7)*200+int(b7)*300)
print(name8,int(a8)+int(b8),int(a8)*200+int(b8)*300)
print(name9,int(a9)+int(b9),int(a9)*200+int(b9)*300)



Measured memory_bytes: 5608
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>

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

using namespace std;

int pos;
char s[1024];

bool formula(){
	if(s[pos]=='T'){
		pos++;
		return true;
	}
	else if(s[pos]=='F'){
		pos++;
		return false;
	}
	else if(s[pos]=='-'){
		pos++;
		return !formula();
	}
	else if(s[pos]=='('){
		pos++;
		bool a=formula();
		char op=s[pos];
		if(op=='-') pos+=2;
		else        pos++;
		bool b=formula();
		pos++;
		switch(op){
			case '*': return a&&b;
			case '+': return a||b;
			case '-': return !a||b;
		}
		// error
	}
}

bool parse(const char *s){
	strcpy(::s,s);
	pos=0;
	return formula();
}

int main(){
	for(char s[1024];scanf("%s",s),s[0]!='#';){
		int n=strlen(s);
		vector<char> C;
		int eq;
		rep(i,n){
			if(s[i]=='=') eq=i;
			if(islower(s[i])) C.push_back(s[i]);
		}
		sort(C.begin(),C.end());
		C.erase(unique(C.begin(),C.end()),C.end());

		bool ok=true;
		rep(S,1<<C.size()){
			char tmp[1024];
			strcpy(tmp,s);

			// T or F を代入
			rep(i,n) if(islower(s[i])) {
				int pos=find(C.begin(),C.end(),s[i])-C.begin();
				s[i]=(S&1<<pos?'T':'F');
			}

			if(parse(s)!=parse(s+eq+1)) ok=false;

			strcpy(s,tmp);
		}
		puts(ok?"YES":"NO");
	}

	return 0;
}

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

int n,H,W,nw,r;
pair<int,int> a[200010];

int main()
{
	scanf("%d%d%d",&H,&W,&n);
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i].first,&a[i].second);
	sort(a+1,a+1+n),nw=1,r=0;
	for (int i=1; i<=n; i++)
	{
		if (a[i].first>nw) r+=a[i].first-nw,nw=a[i].first;
		if (a[i].second>r+1) continue;
		if (a[i].second==r+1) r--; else return printf("%d\n",nw-1),0;
	}
	return printf("%d\n",H),0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

class QuickFind{
private:
    vec<int> G;
    vvec<int> comp;
public:
    QuickFind(int N){
        G.resize(N);
        comp.resize(N);
        iota(G.begin(),G.end(),0);
        for(int i=0;i<N;i++) comp[i].push_back(i);
    }

    void unite(int x,int y){
        x = G[x],y = G[y];
        if(is_same_set(x,y)) return ;
        if(comp[x].size()<comp[y].size()) swap(x,y);
        for(auto& e:comp[y]){
            comp[x].push_back(e);
            G[e] = x;
        }
        comp[y].clear();
    }

    bool is_same_set(int x,int y){return G[x]==G[y];}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N >> Q;
    QuickFind qf(N);
    for(int i=0;i<Q;i++){
        int t,x,y;
        cin >> t >> x >> y;
        if(t==0) qf.unite(x,y);
        else cout << qf.is_same_set(x,y) << endl;
    }
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <iostream>
#define Re register int
#define LL long long

int N,H[100005];
LL f[100005];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
inline int abs(int x) {return x<0?-x:x;}
inline LL min(LL a,LL b) {return a<b?a:b;}
inline LL max(LL a,LL b) {return a>b?a:b;}
int main(int argc, char const *argv[])
{
	read(N); for (Re i=1; i<=N; ++i) read(H[i]);
	f[2]=abs(H[2]-H[1]);
	for (Re i=3; i<=N; ++i)
		f[i]=min(f[i-1]+abs(H[i]-H[i-1]),f[i-2]+abs(H[i]-H[i-2]));
	printf("%lld\n",f[N]);
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

main(){
  int s[10],top=0,a,b;

  void push(int x){
    s[++top]=x;
  }
  int pop(){
    int x=s[top--];
    return x;
  }

  while(scanf("%d",&a) !=EOF){
    if(a!=0) push(a);
    else{
      b=pop();
      printf("%d\n",b);
    }
  }
  return 0; 
}

Measured memory_bytes: 0
/**
*    created: 12.07.2020 00:19:34
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

int modpow(int a, int n, int mod) {
    int ret = 1;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        a %= mod;
        ret %= mod;
        n >>= 1;
    }
    return ret;
}

void f (int n, int &ret) {
    if (n == 0) return;
    else {
        ret++;
        return f(n % (pcnt(n)), ret);
    }
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);
   
    int n; cin >> n;
    string s; cin >> s;

    reverse(all(s));
    int popcnt = 0;
    rep(i,n) if (s[i] == '1') popcnt++;

    int val0 = 0, val1 = 0;

    // 0 -> 1
    int t0 = 1, mod0 = popcnt + 1;
    if (mod0 != 1 && mod0 != 0) {
        rep(i,n) {
            if (s[i] == '1') {val0 += t0; val0 %= mod0;}
            t0 *= 2;
            t0 %= mod0;
        }
    }

    // 1 -> 0
    int t1 = 1, mod1 = popcnt - 1;
    if (mod1 != 1 && mod1 != 0) {
        rep(i,n) {
            if (s[i] == '1') {val1 += t1; val1 %= mod1;}
            t1 *= 2;
            t1 %= mod1;
        }
    }

    vector<int> ret;

    rep(i,n) {
        int val;
        // 0 -> 1
        if (s[n-i-1] == '0') { 
            if (mod0 == 1) {ret.push_back(1); continue;}
            if (mod0 == 0) {ret.push_back(0); continue;}
            int dif = modpow(2, n-i-1, mod0);
            val = val0 + dif;
            val %= mod0;
            if (val < 0) val += mod0;
        }
        // 1 -> 0
        else {
            if (mod1 == 1) {ret.push_back(1); continue;}
            if (mod1 == 0) {ret.push_back(0); continue;}
            int dif = modpow(2, n-i-1, mod1);
            val = val1 - dif;
            val %= mod1;
            if (val < 0) val += mod1;
        }

        if (val == 0) {ret.push_back(1); continue;}
        int ans = 1; f(val, ans);
        ret.push_back(ans);
    }

    rep(i,n) cout << ret[i] << endl;
    return 0;
}

Measured memory_bytes: 5508
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextInt()
	h := s / 3600
	m := (s - (h * 3600)) / 60
	sec := s % 60
	fmt.Printf("%v:%v:%v\n", h, m, sec)
}



Measured memory_bytes: 1092
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 1;
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (h[i] < h[j]) break;
                if (j == i - 1) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
if(Arr[i]=="0 0")break;
var arr=Arr[i].split(" ");
var x=(arr[0]).split("");
var y=(arr[1]).split("");
var h=0;
var b=0;
for(var j=0;j<4;j++){
   if(x[j]==y[j]){h++;}
   else if(y.indexOf(x[j])!=-1){b++;}
}
console.log(h+" "+b);
}

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

int main() {
  int n;
  long long ans;
  cin>>n;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    long long l;
    cin>>l;
    a[i]=l;
    b[i]=l;
  }
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(a[i]<b[n/2])ans=b[n/2];
    else ans=b[(n/2)-1];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 5376
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>

typedef unsigned long long ll;

typedef unsigned int ui;

using namespace std;

int main() {
    // your code goes here
   ll a;

string s , t ;

cin>>s>>t;a=0;

for(int i = 0 ; i < s.size() ; i++){
    if(s[i] != t[i])a++;
}
    cout<<a;

    return 0;
}


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

int main() {
    string s;
    unsigned long long n;
    cin >> s;
    n = atoi(s.c_str());
    int x=0;
    string y;
    for(int i=0;i<s.size();i++){
        y=s[i];
        x+=atoi(y.c_str());
    }
    if(n%x==0){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin >> n;

	vector<double> prob(n+1);
	rep(i,1,n+1) cin >> prob[i];

	vector<double> dp(n+1);
	dp[0] = 1;

	rep(i,1,n+1){

		for(int j=i; j>=0; j--){

			if(j==0) dp[j] = dp[j] * (1 - prob[i]);
			else dp[j] = dp[j] * (1 - prob[i]) + dp[j-1] * prob[i];
		}

	// pvi(dp);
	}

	double ans=0;
	rep(i,n/2+1,n+1) ans += dp[i];
	ret(ans);
}


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

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,tree[li*4],dp[li];
int cev;
string s;
vector<int> v;

inline void update(int node,int start,int end,int l,int r,int val){
	if(start>end || start>r || end<l)return ;
	if(start>=l && end<=r){tree[node]=val;return ;}
	update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
	tree[node]=max(tree[node*2],tree[node*2+1]);
}

inline int query(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l)return 0;
	if(start>=l && end<=r)return tree[node];
	return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}

main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&b[i]);
	}
	FOR{
		scanf("%lld",&a[i]);
	}
	FOR{
		//~ cout<<dp[1]<<" "<<b[i]<<" "<<a[i]<<" "<<query(1,1,n,1,b[i]-1)<<endl;
		dp[b[i]]=max(dp[b[i]],query(1,1,n,1,b[i]-1)+a[i]);
		update(1,1,n,b[i],b[i],dp[b[i]]);
	}
	printf("%lld\n",query(1,1,n,1,n));
	return 0;
}


Measured memory_bytes: 16128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define MAX 200005
#define ll long long
char s[MAX];
map<char,ll> vis;
ll c(ll x)
{
    if(x>=2)
    return x*(x-1)/2;
    else
        return 0;
}
int main()
{
    scanf("%s",s);
    ll n;
    n=strlen(s);
    for(int i=0;i<n;i++)
        vis[s[i]]++;
    ll ans=1;
    for(int i=1;i<n;i++)
        ans+=i;
    for(int i=0;i<26;i++)
        ans-=c(vis[i+'a']);
        printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

import com.sun.org.apache.bcel.internal.generic.LSTORE;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	int[] head;
	int[] to;
	int[] next;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();

		head = new int[n];
		to = new int[2 * m];
		next = new int[2 * m];

		Arrays.fill(head, -1);

		int[] deg = new int[n];

		for (int i = 0; i < m; i++) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;
			deg[v]++;
			deg[u]++;
			to[2 * i] = u;
			next[2 * i] = head[v];
			head[v] = 2 * i;

			to[2 * i + 1] = v;
			next[2 * i + 1] = head[u];
			head[u] = 2 * i + 1;
		}

		int q = nextInt();
		int[] froms = new int[q];
		int[] ds = new int[q];
		int[] cols = new int[q];
		
		for (int i = 0; i < q; i++) {
			froms[i] = nextInt() - 1;
			ds[i] = nextInt();
			cols[i] = nextInt();
		}

		int[][] lastQ = new int[n][11];
		for (int i = 0; i < n; i++) {
			Arrays.fill(lastQ[i], -1);
		}

		PriorityQueue<Query> pq = new PriorityQueue<>();
		for (int i = 0; i < q; i++) {
			lastQ[froms[i]][ds[i]] = i;
		}

		for (int i = 0; i < n; i++) {
			for (int d = 0; d <= 10; d++) {
				if (lastQ[i][d] != -1) {
					pq.add(new Query(i, lastQ[i][d], d));
				}
			}
		}
		
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		
		while (!pq.isEmpty()) {
			Query qq = pq.poll();
			
//			System.err.println(qq.node + " " + qq.query + " " + qq.dist);
			
			if (lastQ[qq.node][qq.dist] != qq.query) {
				continue;
			}
			ans[qq.node] = Math.max(ans[qq.node], qq.query);
			if (qq.dist > 0) {
				for (int i = head[qq.node]; i >= 0; i = next[i]) {
					int u = to[i];
					if (lastQ[u][qq.dist - 1] < qq.query) {
						lastQ[u][qq.dist - 1] = qq.query;
						pq.add(new Query(u, qq.query, qq.dist - 1));
					}
				}
			}
		}
		
		for (int i = 0; i < n; i++) {
			if (ans[i] == -1) {
				out.println(0);
			} else {
				out.println(cols[ans[i]]);
			}
		}
	}

	static class Query implements Comparable<Query> {
		int node;
		int query;
		int dist;

		@Override
		public int compareTo(Query o) {
			return -Integer.compare(query, o.query);
		}

		public Query(int node, int query, int dist) {
			this.node = node;
			this.query = query;
			this.dist = dist;
		}
		
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  // 解答
  cout << a * b - (a + b) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
struct edge{ ll to, cost; };//　一つ目は結んでいるノード,二つ目はその辺の重みを指す
//#define sort(a) sort(a.begin(),a.end())
using Graph = vector<vector<edge>>;  //隣接リスト
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
  ll n,m;cin>>n>>m;
  ll data[n][n];
  fr(i,n){
    fr(j,n){
      data[i][j] = 1e8;
      if(i==j)data[i][j] = 0;
    }
  }
  ll node[m][3];
  fr(i,m){
    ll a,b,c;cin>>a>>b>>c;
    a--;
    b--;
    node[i][0] = a;
    node[i][1] = b;
    node[i][2] = c;
    data[a][b] = min(data[a][b],c);
    data[b][a] = min(data[b][a],c);
  }
  fr(i,n){
    fr(j,n){
      fr(k,n){
        data[j][k] = min(data[j][k],data[j][i] + data[i][k]);
      }
    }
  }
  ll ans = 0;
  fr(i,m){
    bool t = true;
    fr(j,n){
      if(data[j][node[i][0]] + node[i][2] == data[j][node[i][1]])t = false;
    }
    if(t)ans++;
  }
  cout << ans << endl;
}

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

int main(){
    string S ;
    cin >> S ;
    int n = S.size() ;
    for(int i =n-3 ; i > 0 ; i -= 2 ){
        int count = 0 ;
        for(int j = i ; j  > i/2  ; j-- ){ 
            if( S.at(j) == S.at( j- i/2-1 ) ) count++ ;
            if( count == i/2 +1){
                cout << 2*count << endl;
                return 0 ;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
int a[200000],x[200000],y[200000],z[200000];
signed main() {
	int n, vx = 0, vy = 0;
	cin >> n;
	f(i, n) {
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		if (i % 2) {
			y[vy] += a[i];
			if (vy)y[vy] += y[vy - 1];
			vy++;
		}
		else {
			x[vx] += a[i];
			if (vx)x[vx] += x[vx - 1];
			vx++;
		}
	}
	f(i, n / 2) {
		if (i) {
			if (n % 2)z[i] = max(z[i - 1], x[i] - y[i]);
			else z[i] = max(z[i - 1], y[i] - x[i]);
		}
		else {
			if (n % 2)z[i] = max(z[i], x[i] - y[i]);
			else z[i] = max(z[i], y[i] - x[i]);
		}
	}
	int ans = 0;
	if (n % 2) {
		int ma = 0;
		f(i, n / 2) {
			ans += a[i * 2];
		}
		f(i, n / 2) {
			ma= max(ma,y[n / 2 - 1 - i] - x[n / 2 - i] + x[0]+ z[n / 2 - 1 - i]);
		}
		ans += ma;
	}
	else {
		f(i, n / 2) {
			ans += a[i * 2];
		}
		ans += z[n / 2 - 1];
	}
	cout << ans << endl;
}


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

string s;
int main(){
    cin>>s;
    for (int i=0; i<s.size(); i++){
        if (i%2==0 and s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
        else if (i%2==1 and s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
N=gets.to_i
G={}
(N-1).times do
    a,b,c=gets.chomp.split(" ").map(&:to_i)
    G[a-1]||={}
    G[a-1][b-1]=c
    G[b-1]||={}
    G[b-1][a-1]=c
end
Q,K=gets.chomp.split(" ").map(&:to_i)
D=Array.new(N)
D[K-1]=0
targets=[K-1]
while !targets.empty? do
    nexts=[]
    targets.each do |v|
        G[v].each do |key,value|
            if D[key]==nil
                D[key]=D[v]+value
                nexts.push(key)
            end
        end
    end
    targets=nexts
end

Q.times do
    x,y=gets.chomp.split(" ").map(&:to_i)
    puts D[x-1]+D[y-1]
end


Measured memory_bytes: 44800
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort( a.begin(), a.end() );

    long ans=0;
    long count=0;
    for(i=0; i<n; i++) {
        long curr= a[i];        
        while(i<n&&a[i]==curr) {
            i++;
            count++;
        }
        i--;
        ans++;
        if(count%2==0) {
            count=1;
        }
        else {
            count=0;
        }
    }
    printf("%ld\n", ans-count);

    return 0;
}


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

using namespace std;

typedef long long ll;
int n,k;
int a[100005];
bool dp[100005];

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(a[j]<=i && dp[i-a[j]]==0){
                dp[i]=1;
            }
        }
    }
    if(dp[k]==1) cout<<"First";
    else cout<<"Second";

    return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int n;
bool can[200];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            can[i*j] = true;
        }
    }
    cin>>n;
    if(can[n]) cout<<"Yes\n";
    else cout<<"No\n";
}


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

int main() {
	long long H, N;
	std::cin >> H >> N;
	std::vector<std::pair<long long, long long>> AB(N);
	for (int i = 0; i < N; i++) {
		std::cin >> AB[i].first >> AB[i].second;
	}
	std::vector<std::vector<long long>> DP(N + 1);
	std::for_each(std::begin(DP), std::end(DP), [H](auto& dp) {
		dp.resize(H + 1);
		dp[0] = 0;
	});
	for (auto& a : DP[0]) {
		a = 1000000000;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= H; j++) {
			DP[i + 1][j] = std::min(DP[i + 1][std::max(j - AB[i].first, 0LL)] + AB[i].second, DP[i][j]);
		}
	}
	std::cout << DP[N][H] << std::endl;
}


Measured memory_bytes: 78464
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def main():
    """ ????????? """
    n = int(input())
    A = sorted(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))
    g = 0

    tA = []
    l = 2 ** n
    for i in range(1,l):
        c = 0
        bi = "{0:0{width}b}".format(i,width=n)
        bi = bi[::-1]
        for j in range(n):
            if bi[j] == "1":
                c += A[j]
        tA.append(c)
#    tA.sort()

    for mi in M:
        if mi in tA:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()

Measured memory_bytes: 44976
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int gcd(int a,int b){
	if(a>b)return gcd(b,a);
	if(a==0)return b;
	return gcd(b%a,a);
}
int A[100001];
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int ans=A[0];
	REP(i,N){
		ans=gcd(ans,A[i]);
	}
	cout<<ans<<endl;
}

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

int main(){
 long long int n;
  cin>>n;
 long long int sum=0;
  rep(i,n+1){
    if(i%3==0||i%5==0) continue;
    else sum=sum+i;
  }
  cout<<sum<<endl;
}


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

ll gcd(ll a, ll b){
  if(b == 0) return a;

  return gcd(b, a%b);
}

ll lcm(ll a,  ll b){
  ll gc = gcd(a, b);

  return a * b / gc;
}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll lc  = lcm(c, d);
  ll co_c = (b / c) - (a / c);
  if(a % c == 0) co_c++;
  ll co_d = (b / d) - (a / d);
  if(a % d == 0) co_d++;
  ll co_lc = (b / lc) - (a / lc);
  if(a % lc == 0) co_lc++;
  cout << b - a - (co_c + co_d - co_lc)+1 << endl;
  // printf("%lld %lld %lld\n", co_c, co_d, co_lc);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007
#define MOD 86400
#define RAN 10800

using namespace std;

long long N;
long long ans;


/*
 *範囲の和を取得
 */
//区間[l, r)
struct segtree {
	vector<long long> data;
	long long n;
	segtree(long long nin){
		n = pow( 2, ceil( log(nin) / log(2) ) );
		long long size = 2 * n - 1;
		this->data.resize(size, 0);
	}

	//API for update val
	void update(long long idx, long long val){
		update(idx, val, 0, 0, n);
	}

	long long update(long long idx, long long val, long long node_id, long long left, long long right){
		//if query idx is within range return val
		if( !( left <= idx && idx < right ) ){
			return data[node_id];
		}
		if( left + 1 < right ) {
			//when node range is not 1, get update children val and update node data
			long long mid = (left + right) / 2 ;
			long long L = update(idx, val, 2 * node_id + 1, left, mid);
			long long R = update(idx, val, 2 * node_id + 2, mid, right);
			data[node_id] = L + R;
		} else {
			//when node range is 1, update node data
			data[node_id] = data[node_id] + val;
		}
		return data[node_id];
	}
	
	//API for get value of [l, r)
	long long get(long long l, long long r){
		return get(l, r, 0, 0, n);
	}

	/*
	 *internaly used function
	 *query_l: query left range
	 *query_r: query right range
	 *node_id: node id of 
	 *node_l:  node left range 
	 *node_r:  node right range
	 */
	long long get(long long query_l, long long query_r, long long node_id, long long node_l, long long node_r){
		//query range is outside of node range: return INF
		if( query_r <= node_l || node_r <= query_l ){
			return 0;
		}
		//query range is within node range: return node val
		if( query_l <= node_l && node_r <= query_r ){
			return data[node_id];
		}
		long long mid = (node_l + node_r) / 2;
		long long L = get(query_l, query_r, 2 * node_id + 1, node_l, mid);
		long long R = get(query_l, query_r, 2 * node_id + 2, mid, node_r);
		return L + R;
	}
};




int main(){
	segtree sg(2*MOD + 10);
	cin >> N;
	long long cur = 0;
	for(int i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		cur += a;
		sg.update(cur%MOD, 1);
		sg.update(cur%MOD + MOD, 1);
		cur += b;
		cur %= MOD;
	}
	long long ans = 0;
	for(int s = 0; s + RAN <= 2*MOD; s++){
		ans = max(ans, sg.get(s, s + RAN + 1));
	}
	cout << ans << endl;
}


Measured memory_bytes: 4352
#include <iostream>
 
using namespace std;
int n;
 
class Node {
public:
    int id;
    int p;
    int l;
    int r;
};
 
Node T[30];
 
void preOrder(int u) {
    if (u == -1) {
        return;
    }
    cout << " " << u;
    preOrder(T[u].l);
    preOrder(T[u].r);
}
 
void midOrder(int u){
    if(u==-1){
        return;
    }
    midOrder(T[u].l);
    cout << " " << u;
    midOrder(T[u].r);
}
 
void postOrder(int u){
    if(u==-1){
        return;
    }
    postOrder(T[u].l);
    postOrder(T[u].r);
    cout << " " << u;
}
 
int main() {
    cin >> n;
    int id, left, right;
    for(int i=0;i<n;i++){
        T[i].p=-1;
    }
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        T[left].p = T[right].p = id;
    }
    int root;
    for(int i=0;i<n;i++){
        if(T[i].p==-1){
            root=i;
        }
    }
    cout<<"Preorder"<<endl;
    preOrder(root);
    cout<<endl<<"Inorder"<<endl;
    midOrder(root);
    cout<<endl<<"Postorder"<<endl;
    postOrder(root);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
int main(void){
	int a,b,c,d,e,f,g,h,i;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	
	f = c+e;
	g = d+e;
	h = c-e;
	i = d-e;
	if(a>=f&&b>=g&&c>=0&&d>=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;


void solve(){
	int n;
	cin >> n;
	ll mul=1;
	ll INF=1e18;
	bool tem=1,tem2=1;
	forn(i,n){
		ll k;cin >> k;
		if(mul>0&&k<=INF/mul){
			mul*=k;
		}else tem=0;
		if(k==0) tem2=0;
	}
	if(!tem2){
		cout << 0;
		return;
	}
	cout << (tem?mul:-1);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 3652