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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

array<pair<int, int>, 4> direction{pair<int, int>{1, 0}, pair<int, int>{-1, 0}, pair<int, int>{0, 1}, pair<int, int>{0, -1}};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}

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

  int n, m, jump; cin >> n >> m >> jump;
  pair<int, int> s, t;
  cin >> s.first >> s.second >> t.first >> t.second;
  --s.first; --s.second; --t.first; --t.second;
  vec<char, 2> grid(n, m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> grid[i][j];
    }
  }

  auto valid = [&](pair<int, int> x) {
    return x.first >= 0 && x.first < n && x.second >= 0 && x.second < m && grid[x.first][x.second] == '.';
  };

  vec<int, 2> dist(n, m, -1);
  dist[s.first][s.second] = 0;
  queue<pair<int, int>> q; q.emplace(s);
  while (sz(q)) {
    auto u = q.front(); q.pop();

    for (auto& dir : direction) {
      auto v = u + dir;
      for (int i = 0; i < jump && valid(v); ++i, v = v + dir) {
        if (~dist[v.first][v.second]) {
          if (dist[v.first][v.second] <= dist[u.first][u.second]) {
            break ;
          }
        } else {
          dist[v.first][v.second] = dist[u.first][u.second] + 1;
          q.emplace(v);
        }
      }
    }
  }

  cout << dist[t.first][t.second] << '\n';

  return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, p, q;
    cin >> n >> p >> q;
    VI a(n), b(n), c(n);
    REP(i,n) cin >> a[i] >> b[i] >> c[i];
    VVI dp(401, VI(401, 1e9));
    dp[0][0] = 0;
    REP(i,n){
        FORR(x,360,0) FORR(y,360,0){
            dp[x+a[i]][y+b[i]] = min(dp[x+a[i]][y+b[i]], dp[x][y] + c[i]);
        }
    }
    int ans = 1e9;
    REP(x,401) REP(y,401){
        if (x * q == y * p && x > 0 && y > 0){
            ans = min(ans, dp[x][y]);
        }
    }
    if (ans == 1e9) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
import sys
input = sys.stdin.readline

N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda t: t[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = xyh[0]
        H = h0+abs(x0-cx)+abs(y0-cy)
        flag = True
        
        for x, y, h in xyh:
            h2 = max(H-abs(x-cx)-abs(y-cy), 0)
            
            if h!=h2:
                flag = False
                
        if flag:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 43504
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pint> w;

int main() {
	int n,m,a,b;
	while(n=in()){
		w.clear();
		while(n--){
			cin>>m>>a>>b;
			w.push_back(mp(a,m));
			w.push_back(mp(b,-m));
		}
		sort(w.begin(),w.end());
		int i;
		int weight=0;
		for(i=0;i<w.size();i++){
			weight+=w[i].second;
			if(weight>150)break;
		}
		cout<<(i==w.size()?"OK":"NG")<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int D, G;
vector<int> perm;
vector<int> p;
vector<int> c;
int ans = 100000000;

int main(){
    cin >> D >> G;
    rep(i, 0, D){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
        cin >> tmp;
        c.push_back(tmp);
    }

    rep(i, 0, D){
        perm.push_back(i);
    }

    do{
        int goal = G;
        int tmpans = 0;
        rep(i, 0, D){
            int comp = p[perm[i]]*100*(perm[i]+1) + c[perm[i]];
            if(goal>comp){
                goal -= comp;
                tmpans += p[perm[i]];
                continue;
            }else if(goal == comp){
                tmpans += p[perm[i]];
                break;
            }else{
                if(goal < (comp-c[perm[i]])){
                    tmpans += (goal+100*(perm[i]+1) - 1) / (100*(perm[i]+1));
                }else{
                    tmpans += p[perm[i]];
                }
                break;
            }
        }
        ans = min(tmpans, ans);
    }while(next_permutation(all(perm)));

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




Measured memory_bytes: 256
//https://www.youtube.com/watch?v=aRHqs8SffDo
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define in                  insert
#define all(x)              x.begin(),x.end()

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(i=0;i<n;i++) cin>>w[i]>>v[i];
    ll dp[100010];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=1e5;j>0;j--){
            if(j-v[i]>=0 && dp[j-v[i]]!=-1 && dp[j-v[i]]+w[i]<=W){
                if(dp[j]==-1) dp[j]=dp[j-v[i]]+w[i];
                else dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                ans=max(ans,j);
            }
        }
    }
    cout<<ans;
}


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

int data[16][16];

int main(){
	int n;	cin>>n;
	for(int i=1;i<=n;i++){
		int a;	cin>>a;
		for(int j=0;j<a;j++){
			int x,y;	cin>>x>>y;
			if(y)data[i][x]=1;
			else data[i][x]=-1;
		}
	}

	int ans=0;
	for(int flag=0; flag<(1<<n); flag++){
		vector<bool> people(n+1,false);
		int cnt=0;
		for(int i=0;i<n;i++){
			if((flag>>i)&1){
				people[i+1]=true;
				cnt++;
			}
		}

		bool error=false;
		for(int i=1;i<=n;i++){
			if(people[i]){
				for(int j=1;j<=n;j++){
					if((data[i][j]==-1 && people[j]==true)||(data[i][j]==1&&people[j]==false)){
						error=true;
						break;
					}
				}
				if(error)break;
			}
		}
		if(error)continue;

		ans=max(ans,cnt);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26116
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

LL dp[202020];
LL dfa[202020][30];

int main() {
	string s;
	cin >> s;
	s = '#' + s;
	LL n = s.size();

	for (int j = 0; j < 26; j++) {
		dfa[n - 1][j] = n;
	}
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			dfa[i][j] = dfa[i + 1][j];
		}
		dfa[i][s[i + 1]-'a'] = i + 1;
	}

	for (int i = n - 1; i >= 0; i--) {
		dp[i] = INF;
		for (int j = 0; j < 26; j++) {
			dp[i] = min(dp[i], dp[dfa[i][j]] + 1);
		}
	}
	string ans;
	LL p = 0;
	while (p < n) {
		for (int i = 0; i < 26; i++) {
			if (dp[p] == dp[dfa[p][i]] + 1) {
				ans += (i + 'a');
				p = dfa[p][i];
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 49216
#include <iostream>
using namespace std;
using ll = long long;

ll modAdd(ll a, ll b, ll mod) {
	return ((a % mod) + (b % mod)) % mod;
}

ll modSub(ll a, ll b, ll mod) {
	ll c = ((a % mod) - (b % mod)) % mod;
	return ((c < 0) ? c + mod : c);
}

ll modMul(ll a, ll b, ll mod) {
	return ((a % mod) * (b % mod)) % mod;
}

ll modPow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0)
	{
		if (n & 1) {
			res = modMul(res, a, mod);
		}
		a = modMul(a, a, mod);
		n >>= 1;
	}
	return res;
}

ll modDiv(ll a, ll b, ll mod) {
	return modMul(a, modPow(b, mod - 2, mod), mod);
}

int main()
{
	ll N, K;
	cin >> N >> K;
	ll mod = 1000000000 + 7;
	ll c = 0;
	for (ll k = K; k <= N + 1; k++) {
		ll s1 = modDiv(modMul(N, N + 1, mod), 2, mod);
		ll s2 = modDiv(modMul(N - k, N - k + 1, mod), 2, mod);
		ll s3 = modDiv(modMul(k, k - 1, mod), 2, mod);
		c = modAdd(c, s1, mod);
		c = modSub(c, s2, mod);
		c = modSub(c, s3, mod);
		c = modAdd(c, 1, mod);
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define pb(x) push_back(x);
typedef long long  int ll;
ll mod = 998244353;
ll hmaxii=0;
vector<ll>values[2*100000+1];
ll MAXN = 2*100000+1;
ll spf[2*100000+1];
//vector<ll>values[];
ll diff,x,y,z;
ll flag=1;ll price[1001][1001];

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


void solution(){
    int n;
    cin>>n;
    int arr[n][3];int ans[n][3];
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    ans[0][0]=arr[0][0],ans[0][1]=arr[0][1],ans[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
        ans[i][0] = max(ans[i-1][1]+arr[i][0],ans[i-1][2]+arr[i][0]);
        ans[i][1] = arr[i][1]+max(ans[i-1][0],ans[i-1][2]);
        ans[i][2] = arr[i][2]+max(ans[i-1][0],ans[i-1][1]);
    }
    cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]))<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //sieve();
    /*ll powe[64];
    powe[0]=1;
    ll i=1;
    while(i<64){
        powe[i] = powe[i-1]*2;
        i++;
    }*/
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solution();
    }
    return 0;
}

Measured memory_bytes: 10692
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
ll k,a,b,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(k); read(a); read(b);
	if (b-a>=2&&a<=k) {
		ans=((k-a+1)/2)*(b-a)+a;
		if ((k-a+1)&1) ans++;
	} else ans=k+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int>x(n),ans(n);
	rep(i, n) {
		scanf("%d", &x[i]);
	}
	ans = x;
	sort(all(x));
	int ans1 = x[n / 2 - 1];
	int ans2 = x[n / 2];
	
	rep(i, n) {
		if (ans[i] <= ans1) {
			printf("%d\n", ans2);
		}
		else {
			printf("%d\n", ans1);
		}
		
	}

}



Measured memory_bytes: 3712
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int bef = 0;
        int ans = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (bef >= tmp) {
                ans++;
                if (ans > max) max = ans;
            } else {
                ans = 0;
            }
            bef = tmp;
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 46484
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll w, h, n;
    cin >> w >> h >> n;
    vector<vector<ll>> v(h, vector<ll>(w, 1));
    REP(i, n){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            REP(i, h){
                REP(j, x) v[i][j] = 0;
            }
        }
        if(a == 2){
            REP(i, h){
                for(int j=x; j<w; j++) v[i][j] = 0;
            }
        }
        if(a == 3){
            for(int i=h-y; i<h; i++){
                REP(j, w)v[i][j] = 0;
            }
        }
        if(a == 4){
            REP(i, h-y){
                REP(j, w) v[i][j] = 0;
            }
        }
    }
    ll res = 0;
    REP(i, h){
        REP(j, w){
            if(v[i][j] == 1) res++;
        }
    }
    cout << res << endl;
}

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

Measured memory_bytes: 384
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s.sort()
s.append("unkounkounkounko")

m=int(input())
ss=[]
for i in range(m):
    ss.append(input())
ss.sort()
ss.append("unkounkounkounko")


s_number=[]
k=1
for i in range(n):
    if s[i]!=s[i+1]:
        s_number.append([s[i],k])
        k=1
    else:
        k+=1

ss_number=[]
k=1
for i in range(m):
    if ss[i]!=ss[i+1]:
        ss_number.append([ss[i],k])
        k=1
    else:
        k+=1

point=0
point_m=[]
for i in range(len(s_number)):
    point=s_number[i][1]
    for j in range(len(ss_number)):

        if s_number[i][0]==ss_number[j][0]:
            point=max(0, s_number[i][1]-ss_number[j][1])
    point_m.append(point)


#print(s,ss)

#print(s_number)
#print(ss_number)
print(max(point_m))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  vi dx = {0, 1, 1, 0, -1, -1};
  vi dy = {1, 1, 0, -1, -1, 0};

  while(1) {
    int t, n; cin >> t >> n;
    if(t == 0 && n == 0) break;
    map<P, bool> obst;
    REP(i, n) {
      int tmpx, tmpy; cin >> tmpx >> tmpy;
      obst[make_pair(tmpx, tmpy)] = true;
    }
    int sx, sy; cin >> sx >> sy;
    map<P, bool> sel;
    queue<pair<P, int>> q;
    sel[make_pair(sx, sy)] = true;
    q.push(make_pair(P(sx, sy), 0));

    int cnt = 1;
    while(!q.empty()) {
      pair<P, int> now = q.front(); q.pop();
      REP(i, 6) {
        pair<P, int> next = make_pair(P(now.first.first + dx[i], now.first.second + dy[i]), now.second+1);
        if(!sel[next.first] && !obst[next.first] && next.second <= t) {
          cnt++;
          sel[next.first] = true;
          q.push(next);
        }
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3520
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll A, ll B) {
  cout << min(A, B) << " " << max(A + B - N,0ll) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1e18;

    for(int bit = 0; bit < (1 << n); ++bit) {
        vector<ll> copya(a);
        ll maxh = copya[0];
        int num = 0;
        ll tmp = 0;
        for(int i = 1; i < n; ++i) {
            if(bit & ( 1 << i )) {
                num++;
                if(copya[i] <= maxh) {
                    tmp += maxh - copya[i] + 1;
                    copya[i] += maxh - copya[i] + 1;
                }
            }
            maxh = max(copya[i],maxh);
        }
        if(num != k - 1) continue;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
/// <summary>
/// https://atcoder.jp/contests/dp/tasks/dp_c
/// </summary>
internal static class CR
{
    public static string GetText() { return Console.ReadLine(); }
    public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
    public static long GetLong() { return long.Parse(Console.ReadLine()); }
    public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
}

namespace AtCoder.C
{
    public class Program
    {
        public static long N { get; private set; }
        public static long[] A { get; private set; }
        public static long[] B { get; private set; }
        public static long[] C { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            N = CR.GetLong();
            A = new long[N];
            B = new long[N];
            C = new long[N];

            for (int i = 0; i < N; i++)
            {
                var inputs = CR.GetLongs();
                A[i] = inputs[0];
                B[i] = inputs[1];
                C[i] = inputs[2];
            }

            var dpA = new long[N];
            var dpB = new long[N];
            var dpC = new long[N];

            dpA[0] = A[0];
            dpB[0] = B[0];
            dpC[0] = C[0];

            for (int i = 1; i < N; i++)
            {
                dpA[i] = Math.Max(dpB[i - 1] + A[i], dpC[i - 1] + A[i]);
                dpB[i] = Math.Max(dpC[i - 1] + B[i], dpA[i - 1] + B[i]);
                dpC[i] = Math.Max(dpA[i - 1] + C[i], dpB[i - 1] + C[i]);
            }

            return new long[] { dpA[N - 1], dpB[N - 1], dpC[N - 1] }.Max();
        }
    }
}


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

using namespace std;

#define MOD 998244353
typedef long long int ll;

ll a[3001]={0};
ll dp[3002][3002][3]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n,s;
	cin>>n>>s;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}

	dp[0][0][0]=1;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<=s;j++){
			(dp[i+1][j][0]+=dp[i][j][0])%=MOD;
			(dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1])%=MOD;
			(dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2])%=MOD;
			if(j+a[i]<=s){
				(dp[i+1][j+a[i]][1]+=dp[i][j][0]+dp[i][j][1])%=MOD;
				(dp[i+1][j+a[i]][2]+=dp[i][j][0]+dp[i][j][1])%=MOD;
			}
		}
	}
	cout<<dp[n][s][2]<<endl;

	return 0;
}

Measured memory_bytes: 211456
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  string s;
  cin >> s;
  auto it = find(s.begin(), s.end(), '9');
  if (it != s.end()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;
ll dp[110][200100];

/*
int main(){
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vector<ll> pos(0), neg(0);
    int zero=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a>0) pos.push_back(a);
        if(a==0) zero++;
        if(a<0) neg.push_back(-a);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    ll ub=INF;
    ll lb=-INF;
    while(ub-lb>1){
        ll m=(ub+lb)/2;
        ll num=0;
        //cout<<m<<endl;
        if(m<=0){
            for(ll u:neg){
                num+=pos.end()-upper_bound(pos.begin(),pos.end(),-m/u);
            }
        }else{
            num+=neg.size()*pos.size();
            num+=zero*(neg.size()+pos.size());
            num+=zero*(zero-1)/2;
            for(int i=0;i<pos.size();i++){
                num+=lower_bound(pos.begin()+i, pos.end(), m/pos[i])-(pos.begin()+i);
            }
            for(int i=0;i<neg.size();i++){
                num+=lower_bound(neg.begin()+i, neg.end(), m/neg[i])-(neg.begin()+i);
            }
        }
        if(num<=k){
            lb=m;
        }else{
            ub=m;
        }
    }
    cout<<ub<<endl;
}

*/

int main(){
    int n;
    cin>>n;
    ll cap;
    cin>>cap;
    vector<ll> W(n+1);
    vector<int> V(n+1);
    for(int i=1;i<=n;i++){
        ll w;
        int v;
        cin>>w>>v;
        W[i]=w;
        V[i]=v;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=100100;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        ll w=W[i];
        int v=V[i];
        for(int j=0;j<=100100;j++){
            dp[i][j]=dp[i-1][j];
            if(j-v>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v]+w);
        }
    }
    ll ans=0;
    for(int j=0;j<=100100;j++){
        if(dp[n][j]>cap) continue;
        ans=j;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 82540
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string O, E;
  cin >> O >> E;
  if (O.size()-E.size()==0) {
    for (int i=0; i<O.size(); i++) cout << O[i] << E[i];
  }
  else {
    for (int i=0; i<E.size(); i++) cout << O[i] << E[i];
    cout << O[O.size()-1];
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    H, W, K = map(int, input().split())
    k = 0
    counter = 0
    I = []
    def ichigo(s):
        nonlocal k, counter, I, H, W
        i = (counter//W, counter%W)
        counter += 1
        if s == '#':
            k += 1
            I.append(i)
            return k
        else:
            return 0
    cake = np.array([list(map(ichigo, input())) for _ in range(H)], dtype=int)
    J = []
    for h in range(H):
        w_ = 0
        if any(cake[h,:]):
            for w in np.where(cake[h])[0]:
                cake[h,w_:w] = cake[h,w]
                w_ = w+1
            cake[h,w_:] = cake[h,w]
            if J:
                cake[J,:] = cake[h,:]
                J = []
        else:
            if h != 0 and any(cake[h-1,:]):
                cake[h,:] = cake[h-1,:]
            else:
                J.append(h)
    res = '\n'.join([' '.join(map(str, cake[h])) for h in range(H)])
    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 24044
s=input()
k=int(input())
fl=0
t=0
ans='1'
for i in range(len(s)):
  if s[i]=='1' and fl==0:
    t+=1
  else:
    if fl==0:
      ans=s[i]
      fl=1
if t>=k:
  ans='1'
print(ans)

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

std::vector<int> vec, vec2;
int n, k;

int main() {
    std::cin >> n;
    vec.assign(n, 0);
    vec2.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> k;
        vec[i] = k;
        vec2[i] = k;
    }
    std::sort(vec.begin(), vec.end());
    int median_index = (n/2) - 1;
    int mipone = (n/2);
    for (int i = 0; i < n; i++) {
        if (vec2[i] <= vec[median_index]) {
            std::cout << vec[mipone] << std::endl;
        }
        else {
            std::cout << vec[median_index] << std::endl;
        }
    }
}


Measured memory_bytes: 3712
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> weights(n);
    for (int i = 0; i < n; ++i)
        cin >> weights[i];

    int min_abs = INT_MAX;
    for (int i = 0; i < n; ++i) {
        int s1 = 0, s2 = 0;
        for (int j = 0; j <= i; ++j)
            s1 += weights[j];
        for (int j = i + 1; j < n; ++j)
            s2 += weights[j];

        min_abs = min(min_abs, abs(s1 - s2));
    }
    cout << min_abs << '\n';
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        ab: [(u64, u64); n],
    }
    let (mut a, mut b): (Vec<_>, Vec<_>) = ab.into_iter().unzip();
    a.sort();
    b.sort();
    let ans = if n % 2 == 1 {
        b[n / 2] - a[n / 2] + 1
    } else {
        (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1
    };
    println!("{}", ans);
}


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL x;cin>>x;
    LL ans=x/11;
    x-=11*ans;
    ans*=2;
    if(x>0){
        if(x>6)ans+=2;
        else ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn input() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).unwrap();
    inp.trim().to_string()
}

fn main() {
    let n: usize = input().parse().unwrap();
    let l: Vec<i32> = input()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                if l[i] == l[j] || l[j] == l[k] || l[i] == l[k] {
                    continue;
                }
                if l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[i] + l[k] > l[j] {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	if(2*n>=m)ans=m/2;
	else {
		ans+=n,m-=2*n;
		ans+=m/4;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int fac[2000006], inv[2000006], invfac[2000006];

int calc(int r, int c) {
    // -1 + r+c+2 choose r+1
    return ((1ll * fac[r+c+2] * invfac[r+1] % MOD * invfac[c+1] % MOD) + MOD - 1) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    fac[0] = 1; invfac[0] = 1;
    inv[0] = 1; inv[1] = 1;
    rep1(i, r2+c2+2) {
        if(i != 1) inv[i] = 1ll * inv[MOD % i] * (MOD - MOD/i) % MOD;
        fac[i] = 1ll * fac[i-1] * i % MOD;
        invfac[i] = 1ll * invfac[i-1] * inv[i] % MOD;
    }
    cout << (4ll*MOD + calc(r2, c2) - calc(r1-1, c2) - calc(r2, c1-1) + calc(r1-1, c1-1)) % MOD << endl;
}



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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
  ll a,b;
  cin >>a>>b;
  if ( (a+b) %2){
      cout << "IMPOSSIBLE";
      return 0;
  }
  cout << (a+b)/2;
    return 0;
}


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

struct UF{
    int par[200008];
    int rank[200008];
    
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x!=y){
            if(rank[x]<rank[y]){
                par[x]=y;
            }else{
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(void){
    int n,m,p[200008],c=0;
    UF z;
    cin>>n>>m;
    z.init(n+1);
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        z.unite(x,y);
    }
    for(int i=1;i<=n;i++){
        if(z.same(i,p[i]))c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c;
cin >> a >> b >> c;
if(a+b>=c) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;

    long long minv = 1e9;
    for(long long i = 0; i < s.size(); i++){
        if(i + t.size() > s.size()) continue;
        long long start = i;
        long long cnt = 0;
        for(long long j = 0; j < t.size(); j++){
            if(s[start] != t[j]) cnt++;
            start++;
        }
        minv = min(minv, cnt);
    }

    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            for (int i = 0; i < str.Length; i++)
            {
                int index = 0;

                for (int j = 0; j < str.Length; j++)
                {
                    if (str.Substring(i, 1) == str.Substring(j, 1))
                    {
                        index++;
                    }
                }

                if (index != 2)
                {
                    Console.WriteLine("No");

                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25860
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll _pow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; b >> i; i++) {
		if ((b >> i) & 1) ans *= a;
		a *= a;
	}
	return ans;
}
int a, b, c;
int main(void) {
	scanf("%d %d %d", &a, &b, &c);
	if (a == b && b == c) {
		if (a == 1) printf("No\n");
		else printf("Yes\n");
	} else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
raw = $stdin.readlines

square = Array.new(150){Array.new(150)}

for height in 1..149
  for width in (height + 1)..150
    square[height][width] = height**2 + width**2
  end
end


for line in raw 

  stnum = line.split(" ")
  inp_h = stnum[0].to_i()
  inp_w = stnum[1].to_i()

  if inp_h * inp_w == 0
    #do nothing
  else
    length = inp_h**2 + inp_w**2
    min_l = (150**2)*2
    min_h = inp_h
    min_w = 150

    for i in 1..149
      for j in (i + 1)..149
        if square[i][j] == length
          if i > inp_h
            if min_l != length || min_h > i
              min_l = length
              min_h = i
              min_w = j
            end
          end
        elsif square[i][j] > length
          if min_l > square[i][j]
            min_l = square[i][j]
            min_h = i
            min_w = j
          elsif min_l == square[i][j] && min_h > i
            min_h = i
            min_w = j
          end
        end
      end
    end
    puts min_h.to_s() + " " + min_w.to_s()
  end
end

Measured memory_bytes: 6324
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

double bikkuri(double N){
  double ans=1;
  for(int i=1;i<=N;i++){
    ans*=i;
  }
  return ans;
}
int main() {
  double N;
  cin>>N;
  int i,j,k;
  vector<double>x(N),y(N);

  double ans=0;
  double sumx,sumy;
  double sum;
  double bikkurii;
  double combination=N*(N-1)/(double)2;
  bikkurii=bikkuri(N);
  for(i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      sumx=(x[i]-x[j])*(x[i]-x[j]);
      sumy=(y[i]-y[j])*(y[i]-y[j]);
      sum=sumx+sumy;
      sum=sqrt(sum);
      //cout<<sum<<endl;
      sum=sum*2*bikkurii/N;
      ans+=sum;
    }
  }
  ans=ans/bikkurii;
  printf("%.10lf\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,x;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  
  int cnt=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x) cnt++;
      }
    }
  }
  
  printf("%d\n",cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * 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;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<P> p(n);
    rep(i, n) {
        ll x, l; cin >> x >> l;
        p[i].first = x + l;
        p[i].second = x - l;
    }
    sort(ALL(p));
    int cnt = 1, j = 0;
    rep1(i, n-1) {
        if (p[i].second < p[j].first) continue;
        j = i; cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4760
#include <stdio.h>

#if 0
/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int main(void) {
	int P[32];
	int N;
	int i;
	int answer = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (N > 32) {
		puts("N too big");
		return 1;
	}
	for (i = 0; i < N; i++) P[i] = i + 1;
	do {
		int sum = 0;
		for (i = 0; i < N; i++) {
			sum += (i + 1) % P[i];
		}
		if (sum > answer) answer = sum;
	} while (next_permutation(P, N));
	printf("%d\n", answer);
	return 0;
}
#else
#include <inttypes.h>

int main(void) {
	/* zikken kekka -> 1 kara (N-1) made no wa */
	uint64_t N;
	if (scanf("%" SCNu64, &N) != 1) return 1;
	printf("%" PRIu64 "\n", N * (N - 1) / 2);
	return 0;
}
#endif


Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = k;
    for (int i = 1; i < n; i++) {
      ans *= (k - 1);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define f first
#define s second
#define mp make_pair
#define pb push_back

int main(void){
  int n,k;
  cin>>n>>k;
  unsigned long long ret = k;
  rep(i,n-1){
    ret *= (k-1);
  }
  cout<<ret<<endl;

}

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


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }

using pll = pair<long long, long long>;
int N;
long long D, A;
vector<long long> X, H;

long long solve() {
    // モンスターを X が小さい順に
    vector<int> ids(N);
    for (int i = 0; i < N; ++i) ids[i] = i;
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j]; });
    vector<long long> nX(N), nH(N);
    for (int i = 0; i < N; ++i) nX[i] = X[ids[i]], nH[i] = H[ids[i]];
    X = nX, H = nH;

    // イベントソートしていく
    long long res = 0, tmp = 0;
    queue<pair<long long, long long>> que;
    for (int i = 0; i < N; ++i) {
        while (!que.empty()) {
            if (que.front().first >= X[i]) break;
            tmp -= que.front().second;
            que.pop();
        }
        long long con = max(0LL, (H[i] + A - 1) / A - tmp);
        res += con;
        tmp += con;
        que.push({X[i] + D * 2, con});
    }
    return res;
}

int main() {
    cin >> N >> D >> A;
    X.resize(N); H.resize(N);
    for (int i = 0; i < N; ++i) cin >> X[i] >> H[i];
    cout << solve() << endl;
}


Measured memory_bytes: 10624
#include <stdio.h>

int main(){
    int n,i;
    int ans[4]= {0,0,0,0};
    for(i = 0;i<4;i++){
        scanf("%d",&n);
        if(n == 1) ans[0] = 1;
        if(n == 9) ans[1] = 1;
        if(n == 7) ans[2] = 1;
        if(n == 4) ans[3] = 1;
    }
    if(ans[0] && ans[1] && ans[2] && ans[3]) printf("YES");
    else printf("NO");
    return 0;

}

Measured memory_bytes: 128
n, m = map(int, input().split())
ans = ["-1" for i in range(n)]
for i in range(m):
    s, c = input().split()
    s = int(s)
    if s == 1 and c == '0' and n != 1:
        print(-1)
        exit()
    if ans[s-1] == "-1":
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            print(-1)
            exit()
if ans[0] == '-1':
    ans[0] = "1"
if m == 0:
    ans[n-1] = "0"
print(("".join(ans)).replace("-1","0"))


Measured memory_bytes: 38384
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
        if (tmp[0] == tmp[1])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");   
        }
    }
}

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

int n,m,a,b,c,d,s,g,v,p,K[30][30];
const int inf=10000000;

int main(){
    for(int i=0;i<30;i++){
        for(int j=0;j<30;j++){K[i][j]=inf;}
    }
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        //cout<<a<<b<<c<<d<<endl;
        K[a][b]=c;
        K[b][a]=d;
    }
    scanf("%d,%d,%d,%d",&s,&g,&v,&p);
    //cout<<s<<g<<v<<g<<endl;
    for(int k=1;k<=n;k++){
        for(int l=1;l<=n;l++){
            for(int j=1;j<=n;j++){
                if(K[l][j]>K[l][k]+K[k][j]){K[l][j]=K[l][k]+K[k][j];}
            }
        }
    }
    cout<<v-p-K[s][g]-K[g][s]<<endl;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();

    if(d <= t*s){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }




}
}

Measured memory_bytes: 35656
package main

import "fmt"

func max(nums ...int) int {
	var max int
	for i := range nums {
		if i == 0 {
			max = nums[i]
			continue
		}
		if max < nums[i] {
			max = nums[i]
		}
	}
	return max
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(max(a+b, a-b, a*b))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
int n,p[N],sz[N],U[N],V[N];ll tot,d[N];
map<ll,int>mp;vector<int>G[N];
inline bool cmp(int x,int y){return d[x]>d[y];}
void dfs(int x,int d){tot+=d;for(int i=0;i<G[x].size();i++)dfs(G[x][i],d+1);}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&d[i]),mp[d[i]]=i,sz[i]=1,p[i]=i;
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<n;i++)
	{
		int x=p[i];ll w=d[x]-(n-sz[x])+sz[x];
		if(!mp[w]||w>=d[x]){puts("-1");return 0;}
		int y=mp[w];U[i]=x;V[i]=y;
		sz[y]+=sz[x];G[y].push_back(x);
	}
	dfs(p[n],0);
	if(tot!=d[p[n]]){puts("-1");return 0;}
	for(int i=1;i<n;i++)printf("%d %d\n",U[i],V[i]);
	return 0;
}


Measured memory_bytes: 17792
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	double r, x = 3.141592653589, a, b;
	cin >> r;
	a = 2 * r*x;
	b = r*r*x;
	printf("%f" " %f", b, a);
	
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<char> S(N);
  int r = 0;
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
    if(S.at(i) == 'R') {
      r++;
    }
  }
  int ans = 0;
  for(int i = 0; i < r; i++) {
    if(S.at(i) == 'W') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620