akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int k,s; cin >> k >> s;
    int ans = 0;
    rep(i,k+1) rep(j,k+1){
        int x = s-i-j;
        if(0 <= x && x <= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  ll W[N];
  ll S[N];
  
  rep(i,N){
    cin >> W[i];
    if(i==0){
      S[0] = W[0];
    }
    else{
      S[i] = S[i-1] + W[i];
    }
  }
  ll ans=INT_MAX;
  rep(i, N-1){
    ans = min(ans, abs(S[i]-(S[N-1]-S[i])) );
  }

  cout << ans << endl;

  return 0;
    

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<lli,lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int dijkstra(int n,int s,vector<mp>* vs,lli* dist,int g=-1){
	memset(dist,-1,sizeof(lli)*n);
	//rep(i,n)dist[i]=-1;
	priority_queue<mp,vector<mp>,greater<mp> > que;
	que.push(mp(0,s));
	while(!que.empty()){
		mp pa=que.top();
		que.pop();
		lli co=pa.fir,
			no=pa.sec;
		if(dist[no]!=-1 && dist[no]<co)continue;
		dist[no]=co;
		if(no==g)return co;
		rep(i,vs[no].size()){
			mp pb=vs[no][i];
			lli to=pb.fir,
				tc=co+pb.sec;
			if(dist[to]!=-1 && dist[to]<=tc)continue;
			dist[to]=tc;
			que.push(mp(tc,to));
		}
	}
	return -1;
}


int n,m,N;
vector<mp> vs[100005];
lli ds[100005];
lli dt[100005];
mp dats[100005];

vector<lli> bit[400005];

void set(int p){//to 1-index
	int td = p;
	//printf("%d %d %d\n",p,dats[p].fir,dats[p].sec);
	p++;
	while(p<=N){
		bit[p].push_back(dats[td].sec);
		p += (p&(-p));
	}
}

void init(){
	N=1;
	while(N<=n+5)N*=2;
	
	rep(i,n){
		set(i);
	}
	reg(i,1,N){
		sort(bit[i].begin(),bit[i].end());
	}
}

int query(lli p,lli q){
	int st = upper_bound(ds,ds+n,p)-ds;
	//printf("que .. p .. %d is %d\n",p,st);
	//st--daga,1-indexednanodest++de.
	int res = 0;
	while(st>0){
		vector<lli>& nv = bit[st];
		int on = (lower_bound(nv.begin(),nv.end(),q)  - nv.begin()); //if(on>0)on--;
		
		//printf("on .. st .. %d q .. %d is %d\n",st,q,on);
		//rep(i,nv.size())printf("%d ",nv[i]);
		//printf("\nsiz .. %d\n",((int)nv.size()));
		res += nv.size() - on;
		st -= (st&(-st));
	}
	return res;
}

int main(void){
	/*
	int ha[5]={1,3,3,4,4};
	printf("%d %d\n",lower_bound(ha,ha+5,2)-ha,upper_bound(ha,ha+5,2)-ha);
	*/
	scanf("%d%d",&n,&m);
	rep(i,m){
		lli a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		vs[a].push_back(mp(b,c));
		vs[b].push_back(mp(a,c));
	}
	
	dijkstra(n,0,vs,ds);
	dijkstra(n,n-1,vs,dt);
	
	rep(i,n){
		dats[i] = mp(ds[i],dt[i]);
		//printf("dists .. %d %d %d\n",i,ds[i],dt[i]);
	}
	sort(dats,dats+n);
	sort(ds,ds+n);
	
	init();
	
	int iq;
	scanf("%d",&iq);
	rep(i,iq){
		lli a,b;
		scanf("%lld%lld",&a,&b);
		printf("%d\n",query(a,b));
	}
	
	return 0;
}

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

const int N = 1e5 + 7;

int n, a, b;
int v[N];

bool judge(int all)
{
    long long cur_damage = 1LL * b * all;
    long long need = 0;
    for(int i = 0; i < n; i ++)
    {
        if(cur_damage >= v[i])
            continue;
        long long dif = a - b;
        long long ret = v[i] - cur_damage;
        need += (ret + dif - 1) / dif;
    }
    return need <= all;
}


int main()
{
    while(cin >> n >> a >> b)
    {
        int l = 1, r = 1e9;
        for(int i = 0;i < n; i ++)
            cin >> v[i];
        int res = r + 1;
        while(l <= r)
        {
            int mid = (l + r) / 2;
            if(judge(mid))
            {
                res = min(res, mid);
                r = mid - 1;
            }
            else 
                l = mid + 1;
        }
        cout << res << endl;
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a;i <= b;i++) {
		int p = i;
		if (p % 10 == p / 10000 && (p / 10) % 10 == (p / 1000) % 10)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int a,b,c,k;
signed main(){
	Rd(a),Rd(b),Rd(c),Rd(k);
	if(k<a)wr(k),exit(0);
	k-=a;
	if(k<=b)wr(a),exit(0);
	k-=b;
	wr(a-k);
	exit(0);
}


Measured memory_bytes: 3584
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
A, B = tuple(li())
if A == B:
    print(A * 2)
else:
    C = max(A, B)
    print(2*C -1)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int m;int ans;
int a[100010];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
//	for(int i=1;i<=n;i++) printf("%d ",a[i]);
	for(int i=1;i<=n;i++)
		if(m>=a[i]) m-=a[i],ans++;
		else printf("%d",i-1),exit(0);
	printf("%d",n-(m>0));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;

int main() {
	char s[4];
	int ans=700;
	cin>>s[1]>>s[2]>>s[3];
	for (int i=1;i<=3;i++){
		if (s[i]=='o')
			ans+=100;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>
#define mkp make_pair

ll N,P;
ll p2;

int prm[1010101];

ll ans;
ll i, j,k;
int main(){
    scanf("%lld%lld",&N,&P);
    if(N==1){
        printf("%lld", P);
        return 0;
    }

    for (p2 = 1; p2 * p2 <= P;p2++);

    ans = 1;
    fornum(i,2,p2){
        if(prm[i])
            continue;
        j = i;
        while(j<p2){
            prm[j] = 1;
            j += i;
        }
        //printf("%lld:%lldc ", i,j);
        j = P;
        k = 0;
        while(j%i==0){
            j /= i;
            k++;
        }
        
        k = k / N;
        fornum(j,0,k){
            ans *= i;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 4096
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvl vector<vector<long long> >
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin();it != container.end(); it++)
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[1000000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

int32_t main() {
	IOS;
	ll t,i,j,k,n,x,y,z,a,b,c,d;
	string s;
	t=1;
	for(i=0;i<t;i++)
	{
		cin>>n;
		z=(pm(10,n) - (2*pm(9,n))%mod + pm(8,n) + 2*mod)%mod;
		cout<<z;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    ll k; cin >> k;
    if (k == 1 || k == 7) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 1;
    ll mod = 7;

    rep1(i,k+1) {
        if (mod % k == 0) {
            break;
        }
        ans++;
        mod = (mod * 10 + 7) % k;
    }
    if (mod % k == 0)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
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 first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
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 debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int cnts[109];

void factors(int k) {
    int p = 2;
    while (k > 1) {
        if (k % p == 0) {
            cnts[p]++;
            k /= p;
        } else {
            p++;
        }
    }
}



int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    FOR(i, 2, N) {
        factors(i);
    }
    ll ans = 0;
    FOR(i, 2, N) if (cnts[i] > 73) ans++; 
    FOR(i, 2, N) {
        FOR(j, i + 1, N) {
            if (cnts[i] > 23 && cnts[j] > 1) {
                ans++;
            }
            if (cnts[j] > 23 && cnts[i] > 1) {
                ans++;
            }
            if (cnts[i] > 13 && cnts[j] > 3) {
                ans++;
            }
            if (cnts[j] > 13 && cnts[i] > 3) {
                ans++;
            }
        }
    }
    FOR(i, 2, N) {
        FOR(j, i + 1, N) {
            FOR(k, j + 1, N) {
                if (cnts[i] > 3 && cnts[j] > 3 && cnts[k] > 1) {
                    ans++;
                }
                if (cnts[i] > 1 && cnts[j] > 3 && cnts[k] > 3) {
                    ans++;
                }
                if (cnts[i] > 3 && cnts[j] > 1 && cnts[k] > 3) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <class K, class V>
class RadixHeap {
    static constexpr int bit_length = sizeof(K)*8;
    K last;
    size_t sz, cnt;

    array<vector<pair<K, V>>, bit_length> v;
    static inline int bsr(int x){
        return x ? bit_length-__builtin_clz(x) : 0;
    }
    static inline int bsr(ll x){
        return x ? bit_length-__builtin_clzll(x) : 0;
    }

    void pull() {
        if(cnt < v[0].size()) return;;
        int i = 1;
        while(v[i].empty()) i++;
        last = min_element(v[i].begin(),v[i].end())->first;
        for (auto &&x : v[i]) v[bsr(x.first ^ last)].push_back(x);
        v[i].clear();
    }
public:
    RadixHeap() : last(0), sz(0), cnt(0) {}
    void emplace(K x, V val){
        sz++;
        v[bsr(x^last)].emplace_back(x, val);
    }

    pair<K, V> top() {
        pull();
        return v[0][cnt];
    }

    void pop() {
        pull();
        sz--;
        cnt++;
    }

    size_t size() const { return sz; }
    bool empty() const { return !sz; }
};
template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

bool solve(){
    int c, n, m, s, g;
    cin >> c >> n >> m >> s >> g;
    if(!c) return 0;
    s--; g--;
    vector<vector<edge<int>>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b, f;
        cin >> a >> b >> f;
        a--; b--;
        G[a].emplace_back(b, f);
        G[b].emplace_back(a, f);
    }
    auto dp = make_v(c+1, n, INF<int>);
    dp[0][s] = 0;
    RadixHeap<int, pair<int, int>> Q;
    Q.emplace(0, {0, s});
    while(!Q.empty()){
        int a, x; tie(a, x) = Q.top().second; int C = Q.top().first;
        Q.pop();
        if(dp[a][x] < C) continue;
        for (auto &&e : G[x]) {
            if(a != c){
                if(dp[a+1][e.to] > C+e.cost/2) {
                    dp[a+1][e.to] = C+e.cost/2;
                    Q.emplace(C+e.cost/2, {a+1, e.to});
                }
            }
            if(dp[a][e.to] > C+e.cost){
                dp[a][e.to] = C+e.cost;
                Q.emplace(C+e.cost, {a, e.to});
            }
        }
    }
    int ans = INF<int>;
    for (int i = 0; i <= c; ++i) {
        chmin(ans, dp[i][g]);
    }
    cout << ans << "\n";
    return 1;
}

int main() {
    while(solve());
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
using namespace std;
int main() {
	int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
	cout << (y1 - y2) + x2 << ' ' << x2 - x1 + y2 << ' ' << y1 - y2 + x1 << ' ' << x2 - x1 + y1 << endl;
	cin >> x1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
	
vector<int>a(26);
for(int i=0;i<26;i++){
	  a.at(i)=0;
}

for(int i=0;i<s.size();i++){
	 a.at( (int)(s.at(i)-'a'))=1;
}

for(int i=0;i<27;i++){
     if(i==26){
     cout<<"None"<<endl;
     break;
     }
     
	  if(a.at(i)==0){
		 cout<<(char)('a'+i)<<endl;
	    	break;
}
}
	 
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define pi  pair<int,int>
#define pl  pair<ll,ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 200000+5
ll dp[N];
ll k;
ll solve(ll a[],ll n,ll i)
{
    if(i>=n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll q=INT_MAX,p;

    for(ll j=i+1;j<=min(n-1,i+k);j++)
    {
        p=abs(a[i]-a[j])+solve(a,n,j);
        q=min(q,p);

    } 
    dp[i]=q;
    return dp[i];
    
}


int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ll n,i;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    ll ans=solve(a,n,0);
    cout<<ans;
    return 0;
    
}

Measured memory_bytes: 10368
#include <bits/stdc++.h> //1
using namespace std; // 2
#define rep(a) for(int i=0;i<a;++i) // 3
int n; // 4
int cnt[101010];  //5
int main(void){ //1
    cin >> n; // 2
    rep(n)cin>>cnt[i]; // 3
    map<int,int> m; // 4
    rep(n) ++m[cnt[i]] ;  //5
    int sum=0; //1
    for(auto &&e : m) { // 2
        #define Would  // 3
        #define you // 4
        if(e.second>=2){    //5
            sum+=e.second-1; //1
        } // 2 
    } // 3
    if(sum % 2 == 0) // 4
        Would you cout<<m.size()<<endl;   //5
        Would you cerr << "ちゃろー！"; //1 
    if(sum % 2 != 0) // 2  
    { // 3
        Would you cout << m.size() - 1 << endl; // 4
        }    //5
    Would you cerr << "試合を終えて家路へ向かうサッカー部員達。"; //1
    Would you cerr << "疲れからか、不幸にも"; // 2
}

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
const int e = 100000+10;

long long t[e];

int A(int a, int b)
{
    int c = a-b;
    if(c < 0)return -c;
    return c;
}

int main()
{
    int n,w;
    cin >> n >> w;
    for(int i = 0; i < n; i++)
    {
        int a,b;
        cin >> a >> b;
        for(int i = w; i >= a; i--) t[i] = max(t[i], t[i-a]+b);
    }
    long long wynik = 0;
    for(int i = 0; i <= w; i++) wynik = max(t[i],wynik);
    cout << wynik;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
int a[300000];
int main()
{
        IO;
        int i, n, j, k, mx=0, x, y, d;
        cin>>n>>x>>y;
        for(i=1; i<n; i++)
        {
            for(j=i+1; j<=n; j++){
                d=j-i; k=INT_MAX-5;
                if(i<=x&&(j>x&&j<=y)) k = x+y-i-j;
                else if((i<=y&&i>=x)&&(j>x&&j<=y)) k = y+i-x-j;
                else if(i<=x&&j>=y) k = j+x-i-y;
                else if(i<=y&&j>=y)  k = j-x-y+i;
                d= min(d,k+1);
                a[d]++;

            }

        }
        for(i=1; i<n; i++) cout<<a[i]<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int X; cin >> X;
    cout << 10 - X/200 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
using namespace std; 

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main()
{
	ll S,W;
	cin >> S >> W;
	if(W>=S)
		cout << "unsafe\n";
	else
		cout << "safe\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define N 4000005
#define MOD 1000000007
using namespace std;
int n,k,f[2005][2005],inv[N],fac[N];
int C(int x,int y){
	return x>=y?fac[x]*inv[y]%MOD*inv[x-y]%MOD:0;
}
signed main(){
	cin>>n>>k;
	if(k==1){
		cout<<1<<endl;
		return 0;
	}
	fac[0]=inv[0]=inv[1]=1;//first deal
	for(int i=1;i<=n*k;i++)
		fac[i]=fac[i-1]*i%MOD;
	for(int i=2;i<=n*k;i++)
		inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=n*k;i++)
		inv[i]=inv[i-1]%MOD*inv[i]%MOD;
	for(int i=0;i<=n;i++)
		f[i][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
//			cout<<i<<" "<<j<<"*"<<"%"<<C(k-2,(n-i)+(n-j+1)*(k-1)-1)<<endl;
			f[i][j]=(f[i-1][j]+C((n-i)+(n-j+1)*(k-1)-1,k-2)*f[i][j-1]%MOD*(n-j+1)%MOD)%MOD;
//			cout<<f[1][1]<<endl;
		}
	}
	cout<<f[n][n];
	return 0;
}

Measured memory_bytes: 88724
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> H;
	int i;
	for (i = 0; i < N; i++) {
		int h;
		cin >> h;
		H.push_back(h);
	}
	int ans = 0;
	for (i = 0; i < N; i++) {
		ans += H.at(i);
		if (i != N - 1 && H.at(i) >= H.at(i + 1)) {
			ans -= H.at(i + 1);
		}
		if (i != 0 && H.at(i - 1) < H.at(i)) {
			ans -= H.at(i - 1);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

ll a[5];

void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i < 5; i++)
    {
        a[i] = 0;
    }
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(s[0] == 'M')
            a[0]++;
        if(s[0] == 'A')
            a[1]++;
        if(s[0] == 'R')
            a[2]++;
        if(s[0] == 'C')
            a[3]++;
        if(s[0] == 'H')
            a[4]++;
    }
    
    ll res = 0;
    
    for(int i = 0; i < 5; i++)
    {
        for(int k = i + 1; k < 5; k++)
        {
            for(int j = k + 1; j < 5; j++)
            {
                res += (a[i] * a[k] * a[j]);
            }
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
class birthday {
public:
	int y, m, d, D , M, Y, today, x;
	birthday() {
		cin >> y >> m >> d;
		y--; m--;
		today = 999 / 3 * 590 + 1;
		D = y / 3 * 590 + y % 3 * 195 + m / 2 * 39 + m % 2 * 20 + d;
		if ((y + 1) % 3 == 0) {
			if ((m + 1) % 2 == 1)D += (m + 1) / 2;
			else D += m / 2;
		}
		x = today - D;
		cout << x <<endl;
	}
};
int main() {
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	birthday people;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
int n;
vector<int> g[N];
int dp[N];

void dfs(int v)
{
    vector<int> a;
    dp[v] = (int)g[v].size();
    for (int u : g[v])
    {
        dfs(u);
        a.push_back(dp[u]);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < (int)a.size(); i++)
        dp[v] = max(dp[v], a[i] + (int)a.size() - i);
    return;
}

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

    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        int v;
        scanf("%d", &v);
        v--;
        g[v].push_back(i);
    }
    dfs(0);
    printf("%d\n", dp[0]);

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

const int N_MAX = 1000005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

map<ll, ll> mp;
void prime_factorization(ll x){
    bool flag = true;
    while(flag){
        ll sqx = sqrt(x)+1;
        for(ll j=2;j<sqx+1;j++){
            if(x%j==0){
                mp[j]++;
                x/=j;
                break;
            }
            if(j==sqx) flag = false;
        }
    }
    if(x!=1){
        mp[x]++;
    }
}

int main(){
	ll N, M;
	cin >> N >> M;

	make();
	prime_factorization(M);
	ll res = 1;

	for(auto itr=mp.begin();itr!=mp.end();itr++){
		res *= Combination(itr->second + N - 1, itr->second);
		res %= mod;
	}

	cout << res << endl;

    return 0;
}

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

ll MOD = 998244353;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
    ll N,K;
    cin>>N>>K;
    typedef pair<ll,ll> P;
    vector<P> lr(K);
    rep(i,K){
        ll l,r;
        cin>>l>>r;
        ++r;
        lr[i] = P(l,r);
    }

    vector<ll> dp(N);
    dp[0] = 1;
    dp[1] = -1;

    rep(i,N){
        if(i>0) dp[i] += dp[i-1];
        rep(j,K){
            ll l,r;
            l = lr[j].first;
            r = lr[j].second;
            // if(i+l<N) dp[i+l]+= dp[i];
            // if(i+r<N) dp[i+r]-= dp[i];
            if(i+l<N) dp[i+l]= (dp[i+l]+ dp[i])%MOD;
            if(i+r<N){
                dp[i+r] -= dp[i];
                if(dp[i+r]<0) dp[i+r]+=MOD;
                else dp[i+r]%=MOD;
            }
        }
    }
    cout<<dp[N-1]%MOD<<"\n";

	return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

bool comp(pair<ll,ll>& a, pair<ll,ll>& b){
    if(a.first > b.first){
        return a.first > b.first;
    }else if(a.second > b.second){
        return a.second > b.second;
    }
}

int main(){
    ll N; cin >> N;
    vector<pair<ll,ll> > r,bl;
    for(int i=0;i<N;++i){
        ll a,b; cin >> a >> b;
        r.push_back(make_pair(a,b));
    }
    for(int i=0;i<N;++i){
        ll a,b; cin >> a >> b;
        bl.push_back(make_pair(a,b));
    }
    
    sort(r.begin(),r.end());
    sort(bl.begin(),bl.end());
    
    ll res = 0;
    vector<bool> used(N,false);
    for(int i=0;i<N;++i){
        auto x = lower_bound(r.begin(),r.end(),bl[i]);
        ll y = x - r.begin() - 1;
        ll ma = -INF;
        ll tar = -1;
        for(int j=y;j>=0;--j){
            if(used[j] == false && r[j].second < bl[i].second){
                if(ma < r[j].second){
                    ma = r[j].second;
                    tar = j;
                }
            }
        }
        if(tar != -1){
            used[tar] = true;
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1<<29;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int N, t; cin >> N;
    vint a(100006, 0);
    rep(i, N){
        cin >> t;
        a[t + 1]++;
        a[t]++;
        a[t + 2]++;
    }
    sort(ALL(a));
    cout << a.back() << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  int n,i;
  
  cin >> n;
  
    
  i = n % 1000;
  
  if(i == 0){
  	n = 0;
  }else{
  	n = 1000 - i;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 5000;
char str[2*MAXN + 5], mn;
char ans[MAXN + 5];
int N, K;
bool check(char *S) {
	for(int i=1;i<=N;i++)
		if( ans[i] != S[i] )
			return ans[i] > S[i];
	return false;
}
void update(char *S) {
	for(int i=1;i<=N;i++)
		ans[i] = S[i];
}
int pw[35];
char S[MAXN + 5];
int main() {
	pw[0] = 0, pw[1] = 2;
	for(int i=2;i<=30;i++) pw[i] = 2*pw[i-1];
	scanf("%d%d%s", &N, &K, str + 1);
	mn = 'z';
	for(int i=1;i<=N;i++)
		mn = min(mn, str[i]), ans[i] = 'z';
	if( K >= 30 ) {
		for(int i=1;i<=N;i++)
			putchar(mn);
	}
	else {
		for(int i=1;i<=N;i++)
			str[2*N - i + 1] = str[i];
		int cnt = 0;
		for(int i=1;i<N;i++)
			cnt = (str[i] == str[i-1]) ? cnt + 1 : 1;
		for(int i=N;i<=2*N;i++) {
			cnt = (str[i] == str[i-1]) ? cnt + 1 : 1;
			if( pw[K - 1] <= N/cnt ) {
				for(int j=1;j<=pw[K-1]*cnt;j++)
					S[j] = str[i];
				int k = i - cnt;
				if( K == 1 ) k = i;
				for(int j=pw[K-1]*cnt+1;j<=N;j++)
					S[j] = str[k--];
			}
			else {
				for(int j=1;j<=N;j++)
					S[j] = str[i];
			}
			if( check(S) ) update(S);
		}
		puts(ans + 1);
	}
}

Measured memory_bytes: 256
#a>b
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
#a>b
def lcm(a,b):
    return a*b // gcd(a,b)
def divisor(n):
    a = []
    root_n = int(n**0.5)
    for i in range(root_n):
        if n % (i+1) == 0:
            a.append(i+1)
            if (i+1) != n // (i+1):
                a.append(n//(i+1))
    a.sort()
    return a
A,B = map(int,input().split())
c = max(A,B)
d = min(A,B)
llcm = gcd(c,d)
yakus = divisor(llcm)

ans = 1
yak_flag = [1] * len(yakus)
for i in range(len(yakus)):
    if i == 0:
        continue
    k = yakus[i]
    if yak_flag[i] == 0:
        continue
    for j in range(i+1,len(yakus)):
        if yak_flag[j] == 0:
            continue
        if gcd(yakus[j],k) != 1:
            yak_flag[j] = 0
    ans += 1
print(ans)

Measured memory_bytes: 3300
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	s := "Zabcdefghijklmnopqrstuvwxyz"
	var a [1 + 26]bool
	cnt := 0
	for i := 0; i < len(S); i++ {
		for j := 1; j < len(s); j++ {
			if !a[j] && S[i] == s[j] {
				a[j] = true
				cnt++
			}
		}
	}
	if cnt == 26 {
		fmt.Print("None")
	} else {
		for i := 1; i < len(s); i++ {
			if !a[i] {
				fmt.Printf("%c", s[i])
				break
			}
		}
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    ll n;
    cin >> n;
    n++;

    int m = 100;
    vi ans;
    rep1 (i, m) ans.push_back(i);

    int mi = 1, ma = 100;
    while (n > 1) {
        if (n % 2 == 1) {
            ans.push_back(ma--);
            n--;
        }
        else {
            ans.push_back(mi++);
            n /= 2;
        }
    }

    cout << ans.size() << endl;
    rep (i, ans.size()) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dl;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define cont continue
#define inf ll(1e10)
using namespace std;
ll power(ll a,ll b,ll mod)
{
	if(b==0)return 1;
	ll ans=1;
	while(b>0)
	{
		if(b&1)ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
ll inv(ll num)
{
	return power(num,N-2,N);
}
int main()
{
	ios;
	ll n,k;
	cin>>n>>k;
	vtr<pll> a(n);ll i;
	for(i=1;i<=n;i++)
	{
		cin>>a[i-1].fi;
		if(a[i-1].fi>=0)a[i-1].se=1;
		else {
		a[i-1].se=-1;a[i-1].fi=-a[i-1].fi;}
	}
	sort(a.begin(),a.end(),greater<pll>());
	ll ans=1;
	for(i=0;i<k;i++)
	{
		ans=(ans*a[i].fi*a[i].se)%N;
	}
	if(ans>0)cout<<ans;
	else
	{
		ll p1,n1,p2,n2;
		p1=n1=p2=n2=inf;
		for(i=k-1;i>=0;i--)
		{
			if(a[i].se==-1)
			{
				n1=a[i].fi;break;
			}
		}
		for(i=k-1;i>=0;i--)
		{
			if(a[i].se==1)
			{
				p2=a[i].fi;break;
			}
		}
		for(i=k;i<n;i++)
		{
			if(a[i].se==1)
			{
				p1=a[i].fi;break;
			}
		}
		for(i=k;i<n;i++)
		{
			if(a[i].se==-1)
			{
				n2=a[i].fi;break;
			}
		}
		if(p1!=inf)
		{
			ans=(ans*-1)%N;
			if(p2!=inf and n2!=inf)
			{
				if(p1*p2>=n1*n2)
				{
					ans=(ans*p1)%N;
					ans=(ans*inv(n1))%N;
				}
				else
				{
					ans=(ans*n2)%N;
					ans=(ans*inv(p2))%N;
				}
			}
			else
			{
				ans=(ans*p1)%N;
				ans=(ans*inv(n1))%N;
			}
		}
		else
		{
			if(p2==inf or n2==inf){
			ans=1;
			for(i=n-1;i>=n-k;i--)
			{
				ans=(ans*a[i].fi*a[i].se)%N;
				ans=(ans+N)%N;
			}
		}
		else
		{
				ans=(ans*-1)%N;
				ans=(ans*n2)%N;
					ans=(ans*inv(p2))%N;
		}
		}
		cout<<(ans+N)%N;
	}
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pair<ll, ll>> fox(n);
	rep(i,n) cin >> fox[i].first >> fox[i].second;
	sort(fox.begin(), fox.end());
	ll tot = 0;
	ll ans = 0;
	queue<pair<ll, ll>> q;
	rep(i,n){
		ll x = fox[i].first;
		ll h = fox[i].second;
		while(q.size() && q.front().first < x){
			tot -= q.front().second;
			q.pop();
		}
		h -= tot;
		if(h > 0){
			ll num = (h+a-1)/a;
			ans += num;
			ll damage = num*a;
			tot += damage;
			q.emplace(x+2*d, damage);
		}
	}
	cout << ans << endl;
}

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

int main() {
  int a,b,c;
  int i,n1,n2,n3,n4;

  cin >> a;
  cin >> b;
 
  
  if(a >= b)
    cout << 10;
  else
    cout << 0;
  
}


Measured memory_bytes: 256
#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++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int h, w;
  cin >> h >> w;
  vs f(h);
  vii ans(h, vi(w));
  rep(i,h) cin >> f[i];
  rep(y,h) {
    rep(x,w) {
      if(f[y][x] == '#') {
        cout << '#';
        continue;
      }
      int cnt = 0;
      rep(i,8) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if(f[ny][nx] == '#') cnt++;
      }
      cout << cnt;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut i = String::new();
    io::stdin().read_line(&mut i).ok();
    let s = i.trim().chars();
    let mut i = String::new();
    io::stdin().read_line(&mut i).ok();
    let t = i.trim().chars();
    
    let ans = s.zip(t).filter(|(x,y)| x != y).count();
    println!("{}", ans);   
}


Measured memory_bytes: 2528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static long MAX = 100000000000000L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N+1; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long[] suff = new long[N+1];
         suff[N] = arr[N];
         for(int i=N-1; i >= 0; i--)
            suff[i] = suff[i+1]+arr[i];
         long active = 1L;
         long res = 1L;
         for(int i=0; i <= N; i++)
         {
            long chains = arr[i];
            if(active < chains)
            {
               System.out.println(-1);
               return;
            }
            active -= chains;
            if(i < N)
               active = Math.min(2*active, suff[i+1]);
            res += active;
         }
         System.out.println(res);
      }
   }

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n & 1) {
        cout << "No" << endl;
        return 0;
    }
    n /= 2;
    cout << (s.substr(0,n) == s.substr(n,n)?"Yes":"No") << endl;
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i, n-1) if(s[i]!=s[i+1]) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3736
W, H, N = map(int, input().split())
region_w = [0, W]
region_h = [0, H]

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        region_w[0] = max(region_w[0], x)
    elif a == 2:
        region_w[1] = min(region_w[1], x)
    elif a == 3:
        region_h[0] = max(region_h[0], y)
    else:
        region_h[1] = min(region_h[1], y)

if (region_w[0] >= region_w[1]) or (region_h[0] >= region_h[1]):
    print(0)
else:
    print((region_w[1]-region_w[0])*(region_h[1]- region_h[0]))


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

int main() {
    int N, a, b, c;
    cin >> N;
    while (N--) {
        cin >> a >> b >> c;
        if (a > b) {
            int t = a; a = b; b = t;
        }
        if (b > c) {
            int t = b; b = c; c = t;
        }
        if (a > b) {
            int t = a; a = b; b = t;
        }

        if (c * c == a * a + b * b) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2992