akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 3; i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }
        int x = i;
        while(x / 10){
            if(x % 10 == 3 ||  x / 10 == 3){
                cout << " " << i;
                break;
            } 
            x = x / 10;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
LL n, m, ans = 0, f[1000000] = {}, sum = 0;
int flag = 0;
string str;
LL ll(LL aa) {
	f[aa] = f[aa - 1] + f[aa - 2];
	return f[aa];
}
int main(){
	f[0] = 2, f[1] = 1;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		ll(i);
	}
	cout << f[n] << endl;
	return 0;
}

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


int main (){
    int n,k,q;
    cin >> n >> k >> q;
    int b[n];
    rep(i,n){
        b[i] = k-q;
    }
    vector<int> a(q);
    rep(i,q){
        cin >> a[i];
        b[a[i]-1]++;
    }
    rep(i,n){
        if(b[i] > 0)
        cout <<"Yes" << endl;
        else{
        cout <<  "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    double n,d;
    int ans=0;
    cin>>n>>d;
    vector<int> x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n){
        if(sqrt(pow(x[i],2)+pow(y[i],2))<=d) ans++;
    }
    cout<<ans;
    }

Measured memory_bytes: 4896
import java.util.Scanner;

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

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    int64_t ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0) {
        } else if (i % 3 == 0) {
        } else if (i % 5 == 0) {
        } else {
            ans+= i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

  vector<int> s(M);
  vector<int> c(M);
  int _s, _c, i=0;
  while (cin >> _s >> _c) {
    s[i] = _s;
    c[i] = _c;
    i++;
  }

  int n_start, n_end;
  if (N==1) {
    n_start = 0;
    n_end = 9;
  } else if (N==2) {
    n_start = 10;
    n_end = 99;
  } else if (N==3) {
    n_start = 100;
    n_end = 999;
  }

  int digit1, digit2, digit3;
  int answer;
  if (M>0) {
    answer = -1;
  } else {
    answer = n_start;
  }
  for (int n=n_start; n<=n_end; n++) {
    if (N==1) {
      digit1 = n;
      digit2 = -1;
      digit3 = -1;
    } else if (N==2) {
      digit1 = floor( n / 10.0 );
      digit2 = floor( n-10.0*digit1 );
      digit3 = -1;
    } else if (N==3) {
      digit1 = floor( n / 100.0 );
      digit2 = floor( (n-100.0*digit1) / 10.0 );
      digit3 = floor( n-100.0*digit1-10.0*digit2 );
    }

    int OK=0;
    for (int i=0; i<M; i++) {
      if (s[i]==1 && digit1==c[i]) {
        OK++;
      } else if (s[i]==2 && digit2==c[i]) {
        OK++;
      } else if (s[i]==3 && digit3==c[i]) {
        OK++;
      }
    }
    if (M>0 && OK==M) {
      answer = n;
      break;
    }
  }

  cout << answer << endl;

  return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct UnionFind {
    vector<int> v;
    UnionFind(int N) : v(N, -1) {}
    int root(int x) {
        if (v[x] < 0) return x;
        else return v[x] = root(v[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (v[x] > v[y]) swap(x, y);
        v[x] += v[y];
        v[y] = x;
    }
    int size(int x) {
        return -v[root(x)];
    }
};


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    UnionFind uf1(N);
    map<int, int> mp;
    rep(i, N) {
        cin >> p[i];
        p[i]--;
        mp[p[i]] = i;
    }
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf1.unite(p[x], p[y]);
    }
    int ans = 0;
    rep(i, N) {
        if (uf1.root(p[p[i]]) == uf1.root(p[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void)
{
	int A, B, X;

	scanf("%d %d %d", &A, &B, &X);

	if(A > X)
		printf("NO\n");
	else if(A + B < X)
		printf("NO\n");
	else
		printf("YES\n");

	return 0;

}


Measured memory_bytes: 128
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=60;
const int mod=1e9+7;
int n,s;
string s1,s2;
int dp[maxn];

int mult(int a,int b){return (ll)a*(ll)b%mod;}
void add(int &a,int b){a=(a+b)%mod;}

int main(){
	cin>>n>>s1>>s2;
	if(s1[0]==s2[0])dp[0]=3,s=1;
	else dp[1]=6,s=2;
	for(int i=s;i<n;i++){
		if(s1[i]==s2[i]){
			if(s1[i-1]==s2[i-1])add(dp[i],mult(dp[i-1],2));
			else add(dp[i],dp[i-1]);
		}
		else{
			if(i+1<n&&s1[i]==s1[i+1])continue;
			if(s1[i-2]==s2[i-2])add(dp[i],mult(dp[i-2],2));
			else add(dp[i],mult(dp[i-2],3));
		}
	}
	cout<<dp[n-1];
	return 0; 
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int n;	cin >> n;
	int ans = (n%1000 != 0) ? (1000 - n%1000) : 0;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

N, = map(int, sys.stdin.readline().rstrip().split())
a_s = list(map(int, sys.stdin.readline().rstrip().split()))

mina = min(a_s)
maxa = max(a_s)
if (maxa - mina > 1):
    print("No")
    exit(0)
if(maxa == mina):
    if(maxa <= N//2 or N == (maxa+1)):
        print("Yes")
    else:
        print("No")
    exit(0)
if maxa - mina == 1:
    alones = sum(a == mina for a in a_s)
    #print(alones)
    #print(N-alones)
    #print(maxa-alones)
    if  (N-alones) >= (maxa - alones) * 2 and alones < maxa:
        print("Yes")
    else:
        print("No")
    exit(0)

raise Exception()
exit(0)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n;
  cin>>n;
  int res=n;
  r(i,n+1){
    int cc=0;
    int t=i;
    while(t>0)cc+=t%6,t/=6;
    t=n-i;
    while(t>0)cc+=t%9,t/=9;
    if(res>cc)res=cc;
   }
   cout<<res<<endl;

  return 0;
}


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

int main() {
	int n; cin >> n;
	vector<long int> a(n+1),b(n+1);
	for(int i=0; i<n+1; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		cin >> b[i];
	}
	b[n]=0;

	long int ans = 0;
	long int nokori = 0;

	for(int i=0; i<n+1; i++){
		if(a[i]<nokori){
			ans += a[i];
			nokori = b[i];
		}

		else{
			if(a[i]-nokori >= b[i]){
				ans += b[i] + nokori;
				nokori = 0;
			}
			else{
				ans += a[i];
				nokori = b[i]+nokori-a[i];
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct range_edge_graph {
    int n;
    struct edge { int to; long long weight;};
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) : n(n_) {
        g.resize(n<<2);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i)
            g[i].push_back({i+2*n, 0});
    }

    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, long long w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> node;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) node.push_back({l2++, w});
            if (r2 & 1) node.push_back({--r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(node);
    }

    vector<long long> dijkstra(int s) {
        s += n;
        vector<long long> dist(g.size(), numeric_limits<long long>::max());
        dist[s] = 0;
        using P = pair<long long, long long>;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (edge& e : g[v]) {
                if (dist[e.to] > dist[v] + e.weight) {
                    dist[e.to] = dist[v] + e.weight;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        vector<long long> res(dist.begin() + n, dist.begin() + 2*n);
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    range_edge_graph g(n);

    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        g.add_edge(l, r+1, l, r+1, c);
    }
    auto dist = g.dijkstra(0);
    long long ans = dist[n-1];
    cout << (ans == numeric_limits<long long>::max() ? -1 : ans) << endl;
}


Measured memory_bytes: 89588
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {

	vector<string>list = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

	string s;

	cin >> s;

	if (s == "SUN") {
		cout << 7 << endl;
		return 0;
	}

	int index;

	for (int i = 0; i < 7; i++) {
		if (s == list[i]) {
			index = i;
			break;
		}
	}

	int sum = 0;

	for (int i = 0; i < 7; i++) {
		if ("SUN" == list[(index + i ) % 7]) {
			index = i;
			break;
		}

		sum++;
	}


	cout << sum << endl;


	return 0;
}


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

struct test{
	int i, j, k, r;
};

int main()
{
	while (true){
		int a, b, c;
		cin >> a >> b >> c;
		if (!a && !b && !c) break;
		int n, ans[301] = { 0 };
		cin >> n;
		test result[1000];
		for (int i = 0; i < n; i++){
			cin >> result[i].i >> result[i].j >> result[i].k >> result[i].r;
		}
		for (int i = 1; i <= a + b + c; i++){
			ans[i] = 2;
		}
		
		for (int i = 0; i < n; i++){
			if (result[i].r){
				ans[result[i].i] = 1;
				ans[result[i].j] = 1;
				ans[result[i].k] = 1;
			}
		}
		for (int i = 0; i < n; i++){
			if (!result[i].r){
				if (ans[result[i].i] == 1 && ans[result[i].j] == 1) ans[result[i].k] = 0;
				if (ans[result[i].j] == 1 && ans[result[i].k] == 1) ans[result[i].i] = 0;
				if (ans[result[i].k] == 1 && ans[result[i].i] == 1) ans[result[i].j] = 0;
			}
		}
		for (int i = 1; i <= a + b + c; i++){
			cout << ans[i] << endl;
		}
	}
	return 0;
}

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

int main() {
	int n, q;
	long long sum = 0;
	int check[100001] = { 0, };
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		sum += a;
		check[a]++;
	}

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int b, c;
		scanf("%d %d", &b, &c);
		sum -= (long long)check[b] * b;
		sum += (long long)check[b] * c;
		check[c] += check[b];
		check[b] = 0;
		printf("%lld\n", sum);
	}

	return 0;
}

Measured memory_bytes: 2096
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))

# x_1 = (A_1 - A_2 + A_3 - A_4 + ... + A_N) / 2 である
# x_2 以降は代入しながら求めればよい
ans = ' '.join(
    str(2 * x)
    for x in accumulate(
        [(sum(A[::2]) - sum(A[1::2])) // 2] + A[:-1],
        lambda acc, a: a - acc
    )
)

print(ans)


Measured memory_bytes: 16304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i=0,j=0,c=0,k;
    //int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n>>m;
    i = n/2;
    j = m/2;
    k = j;
    if(n==1 || m==1)
    {
        cout<<1;
        return 0;
    }
    if(m%2!=0)
    {
        k = j+1;
    }
    if(n%2!=0)
    {
        k = k*(i+1);
    }
    else{
        k = k*i;
    }
    long long int p = i*j;
    cout<<p+k;

}


Measured memory_bytes: 256
#include <iostream>
#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>

using namespace std;
const int MAXN = 1e6 + 2;
const int INF = 1e9;
int lc(vector<int>& a) {
    int n = a.size();
    if (n == 0) {
        return 0;
    }
    vector<int> d(n + 1);
    d[0] = -INF;
    for (int i=1; i<=n; ++i) {
        d[i] = INF;
    }
     
    for (int i=0; i<n; i++) {
        int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (d[j-1] < a[i] && a[i] < d[j]) {
            d[j] = a[i];
        }
    }
    for (int i = n; i >= 0; --i) {
        if (d[i] != INF) {
            return i;
        }
    }
    return 0;
}

long double find_min(vector<pair<int, int>>& a, int x1, int y1, int x2, int y2) {
    int n = a.size();
    if (y2 < y1) {
        y1 *= -1;
        y2 *= -1;
        for (int i = 0; i < n; ++i) {
            a[i].second *= -1;
        }
    }
    std::vector<pair<int, int>> cur;
    for (int i = 0; i < n; ++i) {
        if (a[i].first <= x2 && a[i].first >= x1 && a[i].second <= y2 && a[i].second >= y1) {
            cur.push_back(a[i]);
        }
    }
    long double ans = 0;
    vector<int> k(cur.size());
    sort(cur.begin(), cur.end());
    for (int i = 0; i < (int)cur.size(); ++i) {
        k[i] = cur[i].second;
    }
    int lcs = lc(k);
    if (lcs == x2 - x1 + 1 || lcs == y2 - y1 + 1) {
        ans += 10 * M_PI - 20.0;
        ans += (20.0 - 5 * M_PI);
    }
    return 100.0*((long double)x2 - (long double)x1 + (long double)y2 - (long double)y1) + ans - (long double)lcs * (20.0 - 5 * M_PI);
}

int main(void) {
    int x1, y1, x2, y2;
    int n;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) {
        std::swap(x1, x2);
        std::swap(y1, y2);
    }
    scanf("%d", &n);
    std::vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first, &a[i].second);
    }
    if (x1 == x2) {
        for (int i = 0; i < n; ++i) {
            if (a[i].first == x1 && a[i].second <= max(y2, y1) && a[i].second >= min(y1, y2)) {
                printf("%.15Lf\n", abs((long double)y2 - (long double)y1)*100.0 + 10.0 * M_PI - 20.0);
                return 0;
            }
        }
    } else if (y1 == y2) {
        for (int i = 0; i < n; ++i) {
            if (a[i].second == y1 && a[i].first <= max(x2, x1) && a[i].first >= min(x1, x2)) {
                printf("%.15Lf\n", abs((long double)x2 - (long double)x1)*100.0 + 10.0 * M_PI - 20.0);
                return 0;
            }
        }
    }
    printf("%.15Lf\n", find_min(a, x1, y1, x2, y2));
    return 0;
}


Measured memory_bytes: 4976
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
typedef pair<ll,ll> P;
const ll MOD=1000000007LL;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<P>data(n);
  rep(i,n)cin>>data[i].first>>data[i].second;
  sort(data.begin(),data.end());
  ll ans=0;
  ll count=0;
  for(int i=0;i<n;i++){
    if(data[i].second+count<=m){
      ans+=data[i].second*data[i].first;
      count+=data[i].second;
    }
    else {
      ans+=(m-count)*data[i].first;
      break;
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, l;
    string str[105];
    cin >> n >> l;

    for (int i = 0; i < n; i++) {
        cin >> str[i];
    }

    sort(str, str + n);

    for (int i = 0; i < n; i++) {
        cout << str[i];
    }
    cout << endl;


    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<ll,ll>> x;
    rep(i,0,n){
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        x.push_back(make_pair(tmp1,tmp2));
    }
    sort(all(x));
    int max_x = x[0].first + x[0].second;
    int cnt=1;
    rep(i,1,n){
        if(max_x <= x[i].first-x[i].second){
            max_x = x[i].first+x[i].second;
            cnt++;
            continue;
        }
        if(max_x < x[i].first+x[i].second) continue;
        max_x = x[i].first + x[i].second;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static final int mod = (int) (1e9 + 7);

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        if (k == 0) out.println(1);
        else {
            int[][] memo = new int[n + 1][k + 1];
            Arrays.fill(memo[n], 1);
            for (int i = n - 1; i >= 0; i--) {
                for (int rem = k; rem >= 0; rem--) {
                    memo[i][rem] = memo[i + 1][rem];
                    if (rem - a[i] - 1 >= 0) memo[i][rem] = add(memo[i][rem], -memo[i + 1][rem - a[i] - 1]);
                }
                for (int rem = 1; rem <= k; rem++)
                    memo[i][rem] = add(memo[i][rem], memo[i][rem - 1]);
            }
            out.println(add(memo[0][k], -memo[0][k - 1]));
        }
        out.flush();
        out.close();
    }

    static int add(int a, int b) {
        long c = a + b;
        if (c >= mod) c -= mod;
        if (c < 0) c += mod;
        return (int) c;
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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


Measured memory_bytes: 80308
// #include <ext/pb_ds/assoc_container.hpp> 
        // #include <ext/pb_ds/tree_policy.hpp> 
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        #define trace(x) cerr << #x << ": " << x << " " << endl;
         
        typedef int64_t ll;
         
        #define endl '\n'
        #define int ll
        ll mod=1e18;
        ll mod1=1e9+5;
         
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
         
        // using namespace __gnu_pbds;
        // #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
        //find_by_order(k)  returns iterator to kth element starting from 0;
        //order_of_key(k) returns count of elements strictly smaller than k;
        //erase,insert same as normal set
        
        int32_t main()
        {
            IOS
        
            int n;
            cin>>n;
            string s;
       set<int> s1[26];
       cin>>s;
       for(int i=0;i<s.length();++i)
       {
            s1[s[i]-'a'].insert(i+1);
       }
       int q;
       cin>>q;
       while(q--)
       {
            int x;
            cin>>x;
            if(x==1)
            {
                int p;
                cin>>p;
                char ch;
                cin>>ch;
                s1[s[p-1]-'a'].erase(p);
                s[p-1]=ch;
                s1[ch-'a'].insert(p);
                //cout<<s<<endl;
            }
            else
            {
                int p,q;
                cin>>p>>q;
                int ans=0;
                for(int i=0;i<26;++i)
                {
                    auto it=s1[i].lower_bound(p);
                    if(it==s1[i].end())
                        continue;
                    int y=*it;
                    if(y>q)
                        continue;
                    
                    ans++;
                }
                cout<<ans<<endl;
            }
       }



            
        }       

Measured memory_bytes: 24220
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

ll dp[2020][2020];
ll sdp[2020][2020];
int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll>S(N), T(M);
	rep(i, 0, N)cin >> S[i];
	rep(i, 0, M)cin >> T[i];

	dp[0][0] = 1;
	rep(i, 0, 2020)sdp[i][0] = 1, sdp[0][i] = 1;
	rep(i, 1, N+1)rep(j, 1, M+1) {
		if (S[i-1] == T[j-1]) {
			dp[i][j] = sdp[i-1][j-1];
			dp[i][j] %= MOD;
		}
		sdp[i][j] = sdp[i - 1][j] + sdp[i][j - 1] - sdp[i - 1][j - 1] + dp[i][j];
		sdp[i][j] += MOD;
		sdp[i][j] %= MOD;
	}
	cout << sdp[N][M] << endl;

	return 0;
}


Measured memory_bytes: 63744
def compare(t,s):
  diff=0
  assert len(t) == len(s)
  for i in range(len(s)):
    if s[i]!=t[i]:
      diff+=1
  return diff
 
t = input().strip()
s = input().strip()
smallchange = len(s)
assert len(t) >= len(s)
for i in range(len(t)-len(s)+1):
  x = compare(t[i:len(s)+i], s)
  if smallchange > x:
    smallchange = x
 
print(smallchange)

Measured memory_bytes: 8984
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = nx[0];
        long x = nx[1];
        long[] xcity = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long[] tmp = new long[n + 1];
        tmp[0] = x;
        for (int i = 1; i < n + 1; i++)
        {
            tmp[i] = xcity[i - 1];
        }

        Array.Sort(tmp);

        long[] diff = new long[n];
        for (int i = 0; i < n; i++)
        {
            diff[i] = tmp[i + 1] - tmp[i];
        }

        //配列の最大公約数を求める
        long ans = 0;
        if (n == 1)
        {
            ans = diff[0];
        }
        else
        {
            ans = Gcd(diff[0], diff[1]);
            for (int i = 2; i < n; i++)
            {
                ans = Gcd(ans, diff[i]);
            }
        }

        Console.WriteLine(ans);
    }

    // ユークリッドの互除法 
    // 最大公約数を求める
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}


Measured memory_bytes: 22624
#include<bits/stdc++.h>
using namespace std;
long long s[100007],t[100007];
int main(){
    long long n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    s[n+1]=1e18;
    s[0]=-1e18;
    sort(s,s+n+2);
    for(int i=1;i<=m;i++)
        scanf("%lld",&t[i]);
    t[m+1]=1e18;
    t[0]=-1e18;
    sort(t,t+m+2);
    long long x=0;
    long long tmp1=0,tmp2=0;
    long long ans=0;
    for(int i=1;i<=q;i++){
        scanf("%lld",&x);
        tmp1=lower_bound(s,s+n+2,x)-s;
        tmp2=lower_bound(t,t+m+2,x)-t;
        ans=1e18;
        for(int j=tmp1-1;j<tmp1+1;j++){
            for(int k=tmp2-1;k<tmp2+1;k++){
                ans=min(ans,abs(x-s[j])+abs(s[j]-t[k]));
                ans=min(ans,abs(x-t[k])+abs(s[j]-t[k]));
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>

int house[4][3][10];//[building][floor][room_number]

int main(){
  int i,j,k;
  int n,b,f,r,v;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d%d%d%d", &b, &f, &r, &v);
    house[b-1][f-1][r-1] += v;
  }
  
  for(i=0; i<4; i++){
    for(j=0; j<3; j++){
      for(k=0; k<10; k++)
	printf(" %d",house[i][j][k]);
      putchar('\n');
    }
    if(i != 3)
      printf("####################\n");
  }
  
  return 0;
}

Measured memory_bytes: 612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int w,h;
	while(cin>>h>>w,w&&h){
		vs f(h,string(w,' '));
		REP(i,h){
				cin>>f[i];
		}
		vvi v(h,vi(w));
		int x=0,y=0;
		while(1){
			if(v[y][x]){
				cout<<"LOOP"<<endl;
				goto loop;
			}
			char c=f[y][x];
			v[y][x]=1;
			switch(c){
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case 'v':
				y++;
				break;
			case '^':
				y--;
				break;
			default:
				goto end;
			}
		}
end:
		cout<<x<<" "<<y<<endl;
loop:
		;
	}

}

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

int main() {
  int n; cin >> n;
  map<string,int> mp;
  
  rep(i, n){
    string s; cin >> s;
    auto itr = mp.find(s);
    if(itr != mp.end())
      mp[s]++;
    else
      mp[s] = 1;
  }
  int max = 0;
  for(auto it = mp.begin(); it != mp.end(); it++)
    if(max < it->second)  max = it->second;
  
  for(auto it = mp.begin(); it != mp.end(); it++){
    if(max == it->second)  cout << it->first << endl;
  }
}

Measured memory_bytes: 19248
import java.util.*;
public class Main{
	
	public static class Pair implements Comparable<Pair>{
		int id, val;
		public Pair(int id, int val) {
			this.id = id; this.val = val;
		}
		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.val, o.val);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt(), K = sc.nextInt();
		
		int arr[] = new int[200001];
		HashSet<Integer> set = new HashSet<Integer>();

		for(int i = 1; i<=N; i++) {
			int n = sc.nextInt();
			arr[n]++;
			set.add(n);
		}

		PriorityQueue<Pair> queue = new PriorityQueue<Pair>();
		for(int i = 1; i<=N; i++) {
			if(arr[i] != 0) queue.add(new Pair(i, arr[i]));
		}
		
		int count = 0;
		while(set.size() > K) {
			count += queue.peek().val;
			set.remove(queue.poll().id);
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 102892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n,l;
  cin>>n>>l;
  vector<string>s(n);
  for(int i=0;i<n;i++){
  	cin>>s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
  	cout<<s[i];
  }
  cout<<endl;
}






Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    if (s.back() == '1' || s[0] == '0')
        return cout << -1, 0;
    s.pop_back();
    int n = sz(s);
    forn (i, 0, n)
        if (s[i] != s[n - i - 1])
            return cout << -1, 0;
    vector <int> a;
    forn (i, 0, n)
        if (s[i] == '1')
            a.pb(i);
    forn (i, 0, sz(a))
        cout << i + 1 << " " << i + 2 << "\n";
    int cnt = sz(a) + 2;
    forn (i, 1, sz(a)) {
        forn (j, 0, a[i] - a[i - 1] - 1) {
            cout << cnt++ << " " << i + 1 << "\n";
        }
    }
    return 0;
}

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

typedef long long ll;

ll N, A, B;
const ll MOD = 1e9 + 7;
const ll MAX = 2e5;
ll PowN;
ll Inv[MAX + 1];
ll R;

ll choose(ll x) {
  ll r = 1;
  for (ll i = 0; i < x; ++i) {
    (r *= N - i) %= MOD;
    (r *= Inv[i + 1]) %= MOD;
  }
  return r;
}
int main() {
  cin >> N >> A >> B;
  Inv[1] = 1;
  for (ll i = 2; i <= MAX; ++i) {
    Inv[i] = MOD - (MOD / i) * Inv[MOD % i] % MOD;
  }
  PowN = 1;
  ll pow = 2;
  for (ll bit = 1; bit <= 2e9; bit *= 2) {
    if (bit & N) (PowN *= pow) %= MOD;
    (pow *= pow) %= MOD;
  }
  R = PowN - choose(A) - choose(B) - 1;
  R = (R % MOD + MOD) % MOD;
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 1920
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

a,b,x=rl()

YN(a<= x and x <= a+b)

Measured memory_bytes: 3064
import sys

n = int(input())
s = input()

if n == 0 or n == 1:
    print(n)
    sys.exit()

ans = 0
for i in range(1, n):
    x = s[0:i]
    y = s[i:]

    x_set = set(x)
    y_set = set(y)
    x_and_y = x_set & y_set
    z = len(x_and_y)
    if ans < z:
        ans = z
print(ans)

Measured memory_bytes: 3064
def four_adjacent(N: int, A: list)->bool:
    n2, n4 = 0, 0
    for a in A:
        if a % 4 == 0:
            n4 += 1
        elif a % 2 == 0:
            n2 += 1
    return N//2 == n4 or N <= 2*n4 + n2


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    yes = four_adjacent(N, A)
    print('Yes' if yes else 'No')


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int>snuke(n);
	rep(i,k){
		int d;
		cin>>d;
		rep(j,d){
			int sn;
			cin>>sn;
			sn--;
			snuke[sn]++;
		}
	}
	int cnt=0;
	rep(i,n){
		if(!snuke[i]){
			cnt++;
		}	
	}
	cout<<cnt<<endl;

}

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


Measured memory_bytes: 3668
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long D = sc.nextLong();
        int counter = 0;
        for(int i = 0;i < N;i++){
            long X = sc.nextLong();
            long Y = sc.nextLong();
            if(D*D >= (X*X + Y*Y)){
                counter++;
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 60652
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	for(int i=1;i<=5;i++){
		int x;
		cin>>x;
		if(x==0) cout<<i<<endl;
	}
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
    string s, t ,ans;
    
    cin >> s >> t;
    
    sort (s.begin(), s.end());
    sort (t.begin(), t.end());
    reverse (t.begin(), t.end());
    
    if(s < t) ans = "Yes";
    else ans = "No";
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

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

	int a, b;
	cin >> a >> b;
	cout << max(a + a-1, max(b + b - 1, b + a)) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int n = Integer.parseInt(line[0]);
		
		List<String> list = new ArrayList<String>();

		String min = "";
		
		for(int i=0;i<n;i++){
			list.add(sc.nextLine());
		}
		sc.close();
		
		Collections.sort(list);
		for(String col:list) {
			min += col;
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 24276
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  while(true){
	int N, M; cin >> N >> M;
	if(N == 0) break;

	vector<PII> cost(N);
	REP(i,N) cin >> cost[i].second >> cost[i].first;
	sort(ALL(cost), greater<PII>());
	LL sum = 0;
	REP(i,N){
	  if(M >= cost[i].second)
		M -= cost[i].second;
	  else{
		cost[i].second -= M;
		M = 0;
		sum += cost[i].first * cost[i].second;
	  }
	}
	cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
map<ll, ll> m;

int main()
{
    ll n, res = 0;

    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
        if (m.find(i + 1 - a[i]) != m.end())
        {
            res += m[i + 1 - a[i]];
        }
        if (m.find(i + 1 + a[i]) == m.end())
        {
            m.insert(make_pair(i + 1 + a[i], 1));
        }
        else
        {
            m[i + 1 + a[i]]++;
        }

        // for (int j = 0; j < i - a[i]; j++)
        // {
        //     if (i - j == a[i] + a[j])
        //     {
        //         res++;
        //     }
        // }
    }
    cout << res << endl;
}

Measured memory_bytes: 16424
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
using ll = long long;

int N;
int a[16][16];
ll memo[(1<<16)]; // memo[S] := score when usagi in S are grouped
ll dp[(1<<16)];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N;
    REP(i,N) REP(j,N) cin >> a[i][j];

    // preprocess
    REP(bit,(1<<N)){
        REP(i,N){
            rep(j,i+1,N){
                if(bit&(1<<i) && bit&(1<<j)) memo[bit] += a[i][j];
            }
        }
    }
  
    // calc max score
    REP(bit,(1<<N)){
        for(int i=bit; i; i=(i-1)&bit){ // search all subset of bit
            dp[bit] = max(dp[bit], memo[i] + dp[bit^i]);
        }
    }
    cout << dp[(1<<N)-1] << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int a,b,n;
int res=0;
int cal(int x){
	int t=floor(a*x/b)-a*floor(x/b);res=max(res,t);
	return t;
}
void solve(int l,int r){
    while(r - l > 10){
        int m1 = l+(r-l)/3,m2 = r - (r-l)/3;
        if(cal(m1) > cal(m2)) r = m2;
        else l = m1;
    }
    int ans = 0;
    for(int i = l;i <= r;i++)
        ans = max(ans,cal(i));
    ans=max(ans,res);
    printf("%lld\n",ans);
}
signed main(){
	res=0;
	cin>>a>>b>>n;
	int l=0,r=n;
	solve(0,n);
	return 0;
}

Measured memory_bytes: 3724
#include <cstdio>

int
main(void)
{
  int a, b, c;
  // a = 1, b = 2, c = 3;
  scanf("%d %d %d", &a, &b, &c);

  if (a < b && b < c) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}



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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  for (long long int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long int ans = 0;
  for (long long int i = 0; i < N - 1; i++) {
    ans += A.at((i + 1) / 2);
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int k;
void input()
{
    cin>>k;   
}

void solve()
{
    vll table; queue<ll> q;
    for(int i=1;i<10;++i) {table.emplace_back(i);q.push(i);}
    int times=100000;
    while(times>0){
        ll tmp=q.front(); q.pop();
        if(tmp%10==0){
            table.emplace_back(tmp*10);table.emplace_back(tmp*10+1);
            q.push(tmp*10);q.push(tmp*10+1);
        }
        else if(tmp%10==9){
            table.emplace_back(tmp*10+tmp%10-1);table.emplace_back(tmp*10+tmp%10);
            q.push(tmp*10+tmp%10-1);q.push(tmp*10+tmp%10);
        } else {
            table.emplace_back(tmp*10+tmp%10-1);
            table.emplace_back(tmp*10+tmp%10);
            table.emplace_back(tmp*10+tmp%10+1);
            q.push(tmp*10+tmp%10-1);
            q.push(tmp*10+tmp%10);
            q.push(tmp*10+tmp%10+1);
        }
        --times;
    }
    sort(table.begin(),table.end());
    // for(int i=0;i<100;++i) cout<<table[i]<<" ";
    // cout<<endl;
    cout<<table[k-1]<<endl;
}

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

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a'){
    cout << "vowel" << endl;    
  } 
  else if(c == 'e'){
    cout << "vowel" << endl;  
  }
  else if(c == 'i'){
    cout << "vowel" << endl;
  }
  else if(c == 'o'){
    cout << "vowel" << endl;
  }
  else if(c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
string S;
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FOR(i,S.size()) if(i%2==0) cout<<S[i];
	cout<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0,g;
  cin>>n;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a==b)
      count++;
    else
      count=0;
    
    if(count==3){
      cout<<"Yes\n";
      g=1;
      break;
    }
    else{
        g=0;
    }
  }
  if(g==0)
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3632