akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    ll k=1e9+7;
    ll n;cin>>n;
    map<vector<ll>,ll[2]>m;
    ll cnt=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        vector<ll>c(2);
        if(a==0&&b==0){
            cnt++;
            continue;
        }
        if(a==0){
            c[0]=0;
            c[1]=1;
            if(m.find(c)==m.end()){
                m[c][0]=1;
                m[c][1]=0;
            }
            else m[c][0]++;
            continue;
        }
        if(b==0){
            c[0]=0;
            c[1]=1;
            if(m.find(c)==m.end()){
                m[c][1]=1;
                m[c][0]=0;
            }
            else m[c][1]++;
            continue;
        }
        //////a*b!=0///////
        ll g=gcd(a,b);
        a/=g;
        b/=g;
        if(a<0){
            a*=-1;
            b*=-1;
        }
        //////////main/////////
        if(b<0){
            c[0]=-b;
            c[1]=a;
            if(m.find(c)==m.end()){
                m[c][1]=1;
                m[c][0]=0;
            }
            else m[c][1]++;
        }
        else {
            c[0]=a;
            c[1]=b;
            if(m.find(c)==m.end()){
                m[c][0]=1;
                m[c][1]=0;
            }
            else m[c][0]++;
        }
    }
    ll ans=1;
    for(auto itr=m.begin();itr!=m.end();itr++){
        ans=ans*((modpow(2,itr->second[0],k)+modpow(2,itr->second[1],k)-1)%k)%k;
    }
    cout<<( ans+cnt-1 + k) % k<<endl;
}


Measured memory_bytes: 25272
def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1])
if __name__ == "__main__":
    main()


Measured memory_bytes: 80176
n,m=map(int,input().split())
ab=[]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ab.append((a,b))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
uf=UnionFind(n)
ans=[n*(n-1)//2]
for i in range(m):
  a,b=ab[m-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    asize=uf.size(a)
    bsize=uf.size(b)
    ans.append(ans[-1]-asize*bsize)
    uf.union(a,b)
for i in range(m):
  print(ans[m-i-1])

Measured memory_bytes: 22492
k = int(input())
from collections import deque
d = deque( )
d.append((1,1))
discovered = set()
while True:
  node, cost = d.popleft()
  discovered |= {node}
  if node == 0: 
  	print(cost)
  	quit()
  if (node*10)%k not in discovered:
    d.appendleft( ((node*10)%k  ,cost))
  if (node+1)%k not in discovered:
    d.append((node+1,cost+1))

Measured memory_bytes: 17816
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
using namespace std;

typedef long long ll;

int n;
char ini[] = {'M', 'A', 'R', 'C', 'H'};
ll ini_cnt[] = {0, 0, 0, 0, 0};

int main(){
  cin >> n;
  ll cnt=0;

  string name;
  for(int i=1; i<=n; i++){
    cin >> name;
    for(int j=0; j<5; j++){
      if(name[0]==ini[j]){
        ini_cnt[j]++;
        cnt++;
      }
    }
  }

  ll ans = 0;
  for(int i=0; i<5; i++){
    for(int j=i+1; j<5; j++){
      for(int k=j+1; k<5; k++){
        ans += ini_cnt[i]*ini_cnt[j]*ini_cnt[k];
      }
    }
  }

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


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val res = ( 1 to n).foldLeft((1, 0)){case ((max, maxV),k) =>
    val v = loop(k,0)
    if(maxV < v) (k,v) else (max,maxV)
  }._1

  println(res)



  def loop(num: Int, cnt:Int): Int ={
    if(num % 2 != 0) cnt else loop(num / 2, cnt + 1)
  }


}

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

typedef long double ld;
//#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
ld pi= 3.14159265358979;
const int mod = 1e9+7;
const int N = 1e6+7;

void solve()
{  
	int a[6];
	rep(i, 1, 6){
		cin>>a[i];
		if(!a[i]) cout<<i;
	}
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<setprecision(20);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3592
N = input()

a = list(N)

s = int(a[-1])

if s == 2 or s == 4 or s == 5 or s == 7 or s == 9:
    print('hon')
    
elif s == 0 or s == 1 or s == 6 or s == 8:
    print('pon')
    
else:
    print('bon')
    
    

Measured memory_bytes: 9112
x = 0
m_list = []
f_list = []
r_list = []
while x < 50:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:
    break
  m_list.append(m)
  f_list.append(f)
  r_list.append(r)
  x = x+1
  
for(mlist,flist,rlist) in zip(m_list,f_list,r_list):
  if mlist == -1 or flist == -1:
    print("F")
  elif 80 <= mlist + flist:
    print("A")
  elif 65 <= mlist + flist and mlist + flist < 80:
    print("B")
  elif 50 <= mlist + flist and mlist + flist < 65:
    print("C")
  elif 30 <= mlist + flist and mlist + flist < 50:
    if 50 <= rlist:
      print("C")
    else:
      print("D")
  elif mlist + flist < 30:
    print("F")


Measured memory_bytes: 5608
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair

int N,W;
vector< vector <int> > dp;
vector<int> v;
vector<int> w;
int DP(int weight, int m){
    if(dp.at(m).at(weight)>0){
        return dp[m][weight];
    }
    if(m == N){
        dp.at(m).at(weight)= 0;
        return dp[m][weight];
    }
    
    if(weight+w.at(m)>W){
        dp.at(m).at(weight) = DP(weight,m+1);
        return dp[m][weight];
    }else{
        dp.at(m).at(weight) = max( DP(weight+w[m],m+1)+v[m], DP(weight,m+1));
        return dp[m][weight];
    }


}

int solve(){
    cin >> N >> W;
    dp.assign(N+1, vector<int>(W+1,0));
    v.assign(N+1,0);
    w.assign(N+1,0);
    REP(i,N){
        cin >> v.at(i) >> w.at(i);
    }
    cout<<(DP(0,0))<<endl;
    return 0;
}

int main(){
    solve();
}


Measured memory_bytes: 6808
n = list(map(int,input().split()))
a = n[0]
b = n[1]
c = n[2]
d = n[3]

while a > 0 and c > 0:
    c -= b
    if c <= 0:
        print("Yes")
        break
    a -= d
    if a <= 0:
        print("No")
        break

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, L;
    cin >> N >> L;

    if (L <= 0 && L + N - 1 > 0 || L < 0 && L + N - 1 >= 0) {
        cout << L*N + N*(N-1)/2 << endl;
    } else {
        if (abs(L) < abs(L+N-1)) {
            cout << L*N + N*(N-1)/2 - L << endl;
        } else {
            cout << L*N + N*(N-1)/2 - L - N + 1<< endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, base = 2e8 ;
using namespace std ;
int T, n, m, tot, d[N], bit[N] ;
struct poi {
	int l, r ;
} a[N] ;
bool cmp(poi a, poi b) { return a.l < b.l ; }
int calc(int x, int y) {
	if (!y) return x + base ;
	if (x == n) return y + base * 2 ;
	if (y == m) return n - x + base * 3 ;
	if (!x) return m - y + base * 4 ;
	return 0 ; 
}
int find(int x) {
	int l = 1, r = d[0] ; 
	for ( ; l <= r ; ) {
		int mid = (l + r) / 2 ;
		if (d[mid] == x) return mid ;
		if (x < d[mid]) r = mid - 1 ; else l = mid + 1 ;
	} 
	return 0 ;
}
void pre() {
	d[0] = 0 ;
	rep(i, 1, tot) d[++ d[0]] = a[i].l, d[++ d[0]] = a[i].r ;
	sort(d + 1, d + d[0] + 1) ;
	d[0] = unique(d + 1, d + d[0] + 1) - (d + 1) ;
	rep(i, 1, tot) a[i].l = find(a[i].l), a[i].r = find(a[i].r) ;
}
void put(int x) {
	for ( ; x <= d[0] ; x += x & (- x)) ++ bit[x] ;
}
int get(int x) {
	int res = 0 ;
	for ( ; x ; x -= x & (- x)) res += bit[x] ;
	return res ;
}
int main() {
	scanf("%d%d%d", &n, &m, &T) ;
	int x, y ; tot = 0 ;	
	rep(i, 1, T) {
		int l, r ;
		scanf("%d%d", &x, &y), l = calc(x, y) ;
		scanf("%d%d", &x, &y), r = calc(x, y) ;
		if (l > r) swap(l, r) ;
		if (l && r) ++ tot, a[tot].l = l, a[tot].r = r ;
	}
	pre() ;
	sort(a + 1, a + tot + 1, cmp) ;
	int top = 1 ;
	rep(i, 1, tot) {
		for ( ; top <= tot && a[top].l < a[i].l ; ++ top) put(a[top].r) ;
		if (get(a[i].r) - get(a[i].l)) { puts("NO") ; return 0 ; }
	}
	puts("YES") ;
	return 0 ;
}

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

int main() {
  int N; cin >> N;
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    if (s == "AC") a++;
    else if (s == "WA") b++;
    else if (s == "TLE") c++;
    else d++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}

Measured memory_bytes: 3624
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<i64>();
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            ans += v[i] * v[j];
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,y=map(int,input().split())
    for n in range(x+1):
        m=x-n
        if 2*n+4*m==y:
            print("Yes")
            sys.exit()
    print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 61816
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;
int sx, sy, tx, ty;

int main() {
    cin >> sx >> sy >> tx >> ty;
    int dis_x=tx-sx, dis_y=ty-sy;
    for(int i=0; i<abs(dis_y); ++i){
        if(dis_y>0) cout << "U";
        if(dis_y<0) cout << "D";
    }for(int i=0; i<abs(dis_x); ++i){
        if(dis_x>0) cout << "R";
        if(dis_x<0) cout << "L";
    }
    for(int i=0; i<abs(dis_y); ++i){
        if(dis_y>0) cout << "D";
        if(dis_y<0) cout << "U";
    }for(int i=0; i<abs(dis_x); ++i){
        if(dis_x>0) cout << "L";
        if(dis_x<0) cout << "R";
    }
    
    cout << "L";
    for(int i=0; i<abs(dis_y)+1; ++i){
        if(dis_y>0) cout << "U";
        if(dis_y<0) cout << "D";
    }
    for(int i=0; i<abs(dis_x)+1; ++i){
        if(dis_x>0) cout << "R";
        if(dis_x<0) cout << "L";
    }
    cout << "D"<<"R";
    for(int i=0; i<abs(dis_y)+1; ++i){
        if(dis_y>0) cout << "D";
        if(dis_y<0) cout << "U";
    }
    for(int i=0; i<abs(dis_x)+1; ++i){
        if(dis_x>0) cout << "L";
        if(dis_x<0) cout << "R";
    }
    cout << "U" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		String s= in.next();
		int end= s.length()-1;
		if(end%2!=0){
			end--;
		}
		while(end>0){
			String beg= s.substring(0, end/2);
			String last= s.substring(end/2, end);
			if(beg.equals(last)){
				System.out.println(beg.length()+last.length());
				break;
			}
			end-=2;             
		}
		
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

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


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a))

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	int max = a + b;
	if (max < a - b) max = a-b;
	if (max < a*b) max = a*b;

	printf("%d\n", max);
	return 0;
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

template<unsigned mod=1000000007>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=1000000007>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};
using Mint=mint<>;

Mint dp[410][410];
Mint psum[410][410];

int main(){
   int n,c; scanf("%d%d",&n,&c);
   vector<int> a(n),b(n);
   rep(i,0,n)scanf("%d",&a[i]);
   rep(i,0,n)scanf("%d",&b[i]);

   psum[0][0]=1;
   rep(i,1,401){
      psum[i][0]=1;
      rep(j,0,401)psum[i][j+1]=psum[i][j]*i;
   }
   rep(i,0,401)rep(j,0,401)psum[i+1][j]+=psum[i][j];

   dp[0][0]=1;
   rep(i,0,n)rep(j,0,c+1)if(dp[i][j].val){
      rep(add,0,c-j+1){
         dp[i+1][j+add]+=dp[i][j]*(psum[b[i]][add]-psum[a[i]-1][add]);
      }
   }
   printf("%d\n",dp[n][c].val);
   return 0;
}

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

class ps{
	public:
		int w;
		int d;

		ps(){}
		ps(int b,int c){
			w=b;
			d=c;
		}

		int area(){
			return w*d;
		}
};


int main(void){
	int n,w,d;
	int p,s;
	int k;
	while(cin>>n>>w>>d,n||w||d){ 
		k=2;
		vector<ps> v;
		v.push_back(ps(w,d));
		for(int i=0;i<n;i++){
			cin>>p>>s; 
			p--;
			s%=(v[p].w*2+v[p].d*2);
			if(s<=v[p].w){
				int w1,d1,w2,d2;
				w1=s;
				d1=v[p].d;
				w2=v[p].w-s;
				d2=v[p].d;
				v.erase(v.begin()+p);
				if(w1*d1>w2*d2){
					v.push_back(ps(w2,d2));
					v.push_back(ps(w1,d1));
				}else{
					v.push_back(ps(w1,d1));
					v.push_back(ps(w2,d2));
				}
			}else if(s<=v[p].w+v[p].d){
				int w1,d1,w2,d2;
				w1=v[p].w;
				d1=v[p].d-s+v[p].w;
				w2=v[p].w;
				d2=v[p].d-d1;
				v.erase(v.begin()+p);
				if(w1*d1>w2*d2){
					v.push_back(ps(w2,d2));
					v.push_back(ps(w1,d1));
				}else{
					v.push_back(ps(w1,d1));
					v.push_back(ps(w2,d2));
				}
			}else if(s<=v[p].w*2+v[p].d){
				int w1,d1,w2,d2;
				w1=v[p].w-s+v[p].w+v[p].d;
				d1=v[p].d;
				w2=v[p].w-w1;
				d2=v[p].d;
				v.erase(v.begin()+p);
				if(w1*d1>w2*d2){
					v.push_back(ps(w2,d2));
					v.push_back(ps(w1,d1));
				}else{
					v.push_back(ps(w1,d1));
					v.push_back(ps(w2,d2));
				}
			}else{
				int w1,d1,w2,d2;
				w1=v[p].w;
				d1=v[p].d-s+v[p].w+v[p].d+v[p].w;
				w2=v[p].w;
				d2=v[p].d-d1;
				v.erase(v.begin()+p);
				if(w1*d1>w2*d2){
					v.push_back(ps(w2,d2));
					v.push_back(ps(w1,d1));
				}else{
					v.push_back(ps(w1,d1));
					v.push_back(ps(w2,d2));
				}
			}

			// cout<<"v["<<k-1<<"]="<<v[k-1].w<<","<<v[k-1].d;
			// cout<<" v["<<p<<"]="<<v[p].w<<","<<v[p].d<<endl;
		}
		vector<int> ee;
		for(int i=0;i<=n;i++)ee.push_back(v[i].area());
		sort(ee.begin(),ee.end());
		for(int i=0;i<ee.size();i++){
			if(i!=ee.size()-1)cout<<ee[i]<<" ";
			else cout<<ee[i];
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int right=0,left=0;
  rep(i,m){
    int a;
    cin>>a;
    if(a>x){
      right++;
    }else{
      left++;
    }
  }
  cout<<min(right,left)<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B string
	fmt.Scan(&A, &B)
	if A == B {
		fmt.Println("EQUAL")
	} else if A > B && len(A) >= len(B) {
		fmt.Println("GREATER")
	} else {
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([(sx, sy)])
    dist = [[-1]*W for _ in range(H)]
    dist[sx][sy] = 0
    
    while q:
        x, y = q.popleft()
        
        for nx, ny in [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]:
            if 0<=nx<H and 0<=ny<W and A[nx][ny]=='.' and dist[nx][ny]==-1:
                dist[nx][ny] = dist[x][y]+1
                q.append((nx, ny))
    
    return dist

H, W, K = map(int, input().split())
A = [input()[:-1] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j]=='S':
            sx, sy = i, j

dist = bfs()
ans = 10**18

for i in range(H):
    for j in range(W):
        if 0<=dist[i][j]<=K:
            ans = min(ans, 1+(min(i, j, H-1-i, W-1-j)+K-1)//K)

print(ans)

Measured memory_bytes: 85760
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, ans[N];

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

	cin >> n;

	for (int x = 1; x * x <= n; x++) {
		for (int y = 1; y * y <= n; y++) {
			for (int z = 1; z * z <= n; z++) {
				int f = 0;
				f += x * x + y * y + z * z;
				f += x * y + y * z + z * x;
				ans[f] += 1;
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}

	return 0;
}


Measured memory_bytes: 3888
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main()
{
    char s;
    cin >> s;
    cout << (char)(s+1) << endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

int main()
{
    int h, w, m;
    cin >> h >> w >> m;
    int maxr = 0, maxc = 0;
    vector<int> hs(h), ws(w);
    set<P> s;
    rep(i,m) {
        int r, c;
        cin >> r >> c;
        --r; --c;
        hs[r]++;
        ws[c]++;
        s.emplace(r,c);
    }
    int mh = 0, mw = 0;
    rep(i,h) mh = max(mh, hs[i]);
    rep(i,w) mw = max(mw, ws[i]);
    vector<int> is, js;
    rep(i,h) if (mh == hs[i]) is.push_back(i);
    rep(j,w) if (mw == ws[j]) js.push_back(j);
    int ans = mh+mw;
    for (int i : is) for (int j : js) {
        if (s.count(P(i,j))) continue;
        cout << ans << endl;
        return 0;
    }
    --ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23816
#include <bits/stdc++.h>
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 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
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

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

/*
 
 2/3/2019
 
 10:40-11:12 WA
 
 */

int N;
LL X;

const int MAX_N=52;
pair<LL,LL> dp[MAX_N];
pair<LL,LL> f(int x) {
  if(x==0) return dp[x]={1,1};
  auto p=f(x-1);
  LL a=2LL*p.first+1,b=2LL*p.second+3;
//  dump(x,a,b);
  return dp[x]={a,b};
}
LL g(LL x, int lv) {
  assert(x>=0);
  assert(x<=dp[lv].second);
  SMAX(x,0LL);
  SMIN(x,dp[lv].second);
  if(x==0) return 0;
  if(x==dp[lv].second) return dp[lv].first;
//  if(lv==0) return 1;
  --x;
  LL l=g(min(max(0LL,x),dp[lv-1].second),lv-1);
  x-=dp[lv-1].second;
  LL c=0;
  if(x>0) ++c;
  x--;
  LL r=g(min(max(0LL,x),dp[lv-1].second),lv-1);
//  dump(x,lv,dp[lv].second,l,c,r);
  return l+c+r;
}
void solve() {
  f(50);
  cout<<g(X,N)<<endl;
}

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


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    e = []
    f = [[0]*n for i in range(n)]
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        a -= 1
        b -= 1
        e.append([a,b,c])
        f[a][b] = c
        f[b][a] = c
        v[a].append(b)
        v[b].append(a)
    ans = 0
    S = []
    for p in range(n):
        K = [{p}]
        for q in v[p]:
            K += [s|{q} for s in K]
        S += K
    for s in S:
        for x in s:
            for y in s:
                if x == y:
                    continue
                if f[x][y] > 0:
                    continue
                else:
                    break
            else:
                continue
            break
        else:
            m = [float("inf")]*n
            for a in s:
                for b in s:
                    if a == b:
                        continue
                    if f[a][b] < m[a]:
                        m[a] = f[a][b]
                    if f[a][b] < m[b]:
                        m[b] = f[a][b]
            k = 0
            for i in m:
                if i != float("inf"):
                    k += i
            if ans < k:
                ans = k


    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 74288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	string s;
	cin >> s;
	cout << ((s[0]==s[2])?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c=INT_MAX,d=0,count=0,e,f;
  cin>>a>>b;
  rep(i,b){
    cin>>e>>f;
    c=min(c,f);
    d=max(d,e);
  }
  count=c-d+1;
  if(count<=0)cout<<0;
  else cout<<count;
}


Measured memory_bytes: 256
#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=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int d, n;
  cin >> d >> n;

  if (n == 100) n++;
  cout << (int)(n * pow(100,d)) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

ll di[10000010];

int main() {
    ll n; cin >> n;
    ll ans = 0;
    Rep(i, 1, n){
        for(int j = i; j <= n; j += i) ans += j;
    }

    co(ans);


    return 0;
}


Measured memory_bytes: 3676
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };


int main(void) {
	long long int n;
	long long int total = 0;
	long long int result = 0;
	long long int left, right;
	long long int count = 0;
	bool flag = true;
	long long int posl, posr;

	cin >> n;
	vector<long long int> a(n);

	FOR(i, 0, n - 1) {
		cin >> a[i];
	}

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

	left = a[0];
	right = a[0];
	posl = 1;
	posr = n - 1;


	while (1) {
		if (flag) {
			flag = false;
			total += abs(left - a[posr]);
			left = a[posr];
			posr--;
			if (posr < posl) {
				break;
			}
			total += abs(right - a[posr]);
			right = a[posr];
			posr--;
			if (posr < posl) {
				break;
			}
		}
		else {
			flag = true;
			total += abs(left - a[posl]);
			left = a[posl];
			posl++;
			if (posr < posl) {
				break;
			}
			total += abs(right - a[posl]);
			right = a[posl];
			posl++;
			if (posr < posl) {
				break;
			}

		}
	}


	left = a[n-1];
	right = a[n-1];
	posl = 0;
	posr = n - 2;
	flag = false;

	while (1) {
		if (flag) {
			flag = false;
			result += abs(left - a[posr]);
			left = a[posr];
			posr--;
			if (posr < posl) {
				break;
			}
			result += abs(right - a[posr]);
			right = a[posr];
			posr--;
			if (posr < posl) {
				break;
			}
		}
		else {
			flag = true;
			result += abs(left - a[posl]);
			left = a[posl];
			posl++;
			if (posr < posl) {
				break;
			}
			result += abs(right - a[posl]);
			right = a[posl];
			posl++;
			if (posr < posl) {
				break;
			}

		}
	}

	cout << max(total, result) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;


typedef int value_type; /* ソートするキーの型 */

/* x, y, z の中間値を返す */
value_type med3(value_type x, value_type y, value_type z) {
    if (x < y) {
        if (y < z) return y; else if (z < x) return x; else return z;
    } else {
        if (z < y) return y; else if (x < z) return x; else return z;
    }
}

/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
/* wikipediaからコピペしてちょっと改変(a[] を a[][] に) */
void quicksort(value_type a[][2], int left, int right) {
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i][1], a[i + (j - i) / 2][1], a[j][1]);
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
          while (a[i][1] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
          while (pivot < a[j][1]) j--; /* a[j] <= pivot となる位置を検索 */
          if (i >= j) break;
          
          tmp = a[i][1]; a[i][1] = a[j][1]; a[j][1] = tmp;
          tmp = a[i][2]; a[i][2] = a[j][2]; a[j][2] = tmp;

            i++; j--;
        }
        quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}/* コピペここまで*/

int main(){
  int N,M,a,b= 0;
  long long shop_date_i_1,out = 0;
  int shop_date[100000][2]={};  
  cin >> N >> M;

  //shop_date[i][1]が価格
  //shop_date[i][2]が購入可能な数
  
  for(int i=0; i < N; i++){
    cin >> shop_date[i][1] >> shop_date[i][2];
  }
  
  quicksort(shop_date, 0, N-1);
  
  int i=0;
  
  while(shop_date[i][2] < M){
    M -= shop_date[i][2];
    shop_date_i_1 = shop_date[i][1] ;
    out += shop_date[i][2] * shop_date_i_1;
    i++;
  }
//  cout << shop_date[i][1] <</* << << <<*/ endl;

  shop_date_i_1 = shop_date[i][1];
  out = out + M * shop_date_i_1;

  cout << out;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

set<string> sub;

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

    int nk = 0;
    for (int i=0; i<26; i++) {
        char c = 'a' + i;
        for (int j=0; j<S.size(); j++) {
            if (S[j] == c) {
                for (int k=j; k<min(S.size(), (size_t)(j+K)); k++) {
                    auto ret = sub.insert(S.substr(j, k-j+1));
                    if (ret.second) nk++;
                }
            }
        }
        if (nk >= K) break;
    }

    int cnt = 0;
    for (auto& i : sub) {
        if (++cnt == K) {
            cout << i << LF;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e7 + 5;
int pnum , facnum[maxn] , p[maxn] , d[maxn];
bool noprime[maxn];
void get_facnum()
{
    int pnum = 0;
    facnum[1] = 1;
    for(int i = 2; i < maxn; i++)
    {
        if(!noprime[i])
        {
            p[pnum ++] = i;
            facnum[i] = 2;
            d[i] = 1;
        }
        for(int j = 0; j < pnum && i * p[j] < maxn; j++)
        {
            noprime[i * p[j]] = true;
            if(i % p[j] == 0)
            {
                facnum[i * p[j]] = facnum[i] / (d[i] + 1) * (d[i] + 2);
                d[i * p[j]] = d[i] + 1;
                break;
            }
            facnum[i * p[j]] = facnum[i] * 2;
            d[i * p[j]] = 1;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    get_facnum();
    ll n , ans = 0 ; cin >> n;
    for (int i = 2 ; i <= n ; i++){
        ans += (ll)i * (ll)facnum[i];
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 94076
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H,W;
        while(sc.hasNextLine()){
            String[] str = sc.nextLine().split(" ");
            H = Integer.parseInt(str[0]);
            W = Integer.parseInt(str[1]);
            if(H == 0 && W == 0) break;
            for(int y = 0; y < H; y++){
                for(int x = 0;x < W; x++){
                    if((y + x) % 2 == 0) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}


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

int main(){
  int N;
  string A,B;
  string ans = "";
  cin >> N >> A >> B;

  
 for(int i = 0; i < N; i++){
 	ans += A[i];
    ans += B[i];
 }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int N,a,b,count=0;
    cin >> N >> a >> b;
    for (int i = 1; i <= b; i++){
        if(N*i <= b && a <= N*i){
            count++;
            break; 
        }
    }
    if (count==1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
        
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 4e5 + 5 ;
int n, D, A, at[N] ; 
struct node {
	int h, w ;
} a[N] ;
bool cmp( node x, node y ) {
	return x.w < y.w ; 
}
int fd( int x ) {
	int l = 1, r = n, ans = 1 ;
	while( l <= r ) {
		int mid = ( l + r ) >> 1 ; 
		if( a[mid].w <= x ) ans = mid, l = mid + 1 ;
		else r = mid - 1 ; 
	} return ans ;
}
signed main()
{
	n = gi(), D = gi() * 2, A = gi() ;
	rep( i, 1, n ) a[i].w = gi(), a[i].h = gi() ;
	sort( a + 1, a + n + 1, cmp ) ;
	int AT = 0, Ans = 0 ;
	for( re int i = 1; i <= n; ++ i ) {
		AT += at[i] ; 
		if( AT >= a[i].h ) continue ; 
		int tp = ( a[i].h - AT ) / A ;
		if( tp * A + AT < a[i].h ) ++ tp ; 
		Ans += tp, AT += A * tp ; 
		int tg = fd( a[i].w + D ) ;
		at[tg + 1] -= A * tp ; 
	}
	printf("%lld\n", Ans ) ;
	return 0 ;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n; cin >> n;
    v<int> h(n); rep(i,n) cin >> h[i];
    reverse(h.begin(), h.end());
    int ans = 0, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (h[i-1] <= h[i]) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	cout<<a[n/2+1]-a[n/2];
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;


int main() {
    int X = 0;
    int Y = 0;
    int Z = 0;
    int swap = 0;
    cin >> X >> Y >> Z;
    
    cout << Z << " " << X << " " << Y << " ";

    return 0;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n,ans;
string slime;
int main()
{
	char now='1';
	scanf("%d",&n);
	cin>>slime;
	for(int i=0;i<=n-1;i++)
	{
		if(now!=slime[i]) ans++;
		now=slime[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    
    if((a*b)%2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
  long long acc = 0;
  for(long long i = 0; i < N.size(); i++) {
    acc = (acc+('0' - N[i]))%9;
  }

  cout << ((acc == 0) ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string N;
  std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mymod(ll a, ll b)
{
	return (a%b + b)%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct vertex
{
	vll adj;
};

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll happ=0;
    happ+=(n/500)*1000;
    n = n - (n/500)*500;
    happ+=(n/5)*5;
    cout<<happ<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX_N 100005

int N;
long long A, B;

long long a[MAX_N], b[MAX_N];

int cnt;

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

	for (int i = 1; i <= N; i++) {
		scanf("%lld", &a[i]);
	}

	long long l = 0, r = 1000000000;

	while (r - l > 1) {
		long long mid = (r + l) >> 1;
		for (int i = 1; i <= N; i++) b[i] = a[i] - mid * B;
		long long t = 0;
		for (int i = 1; i <= N; i++) if (b[i] > 0) t += b[i] / (A - B) + (b[i] % (A - B) != 0);
		if (t <= mid) r = mid;
		else l = mid;
	}
	printf("%lld\n", r);

	return 0;
}

Measured memory_bytes: 1664
const val MOD_BASE = 1000000007L

infix fun Int.addMod(x: Int): Int {
    return ((this.toLong() + x.toLong()) % MOD_BASE).toInt()
}

infix fun Int.mulMod(x: Int): Int {
    return ((this.toLong() * x.toLong()) % MOD_BASE).toInt()
}

infix fun Int.subMod(x: Int): Int {
    return ((this.toLong() + MOD_BASE - x.toLong())
            % MOD_BASE).toInt()
}

fun main() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    val ans = (k..(n+1)).map {
        ((n - it + 1) mulMod it) + 1
    }.reduce { acc, i ->
        acc addMod i
    }

    println(ans)
}

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

int main(){
  string n;
  cin >> n;
  
  int sum = 0;
  for (int i=0 ; i<n.size() ; i++){
    sum += n.at(i) - '0';
  }
  
  int m = atoi(n.c_str());
  
  if (m%sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3584