akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# 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>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f[200000];
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[210000], b[210000], 
nex[210000][26],dp[210000];
int main() {
	cin >> str;
	rep(i, 26)nex[str.size()][i] = str.size() + 1;
	rep(j, str.size() + 1)dp[j] = INF;
	dp[str.size()+1] = 0;
	Rrep(i, str.size()) {
		rep(j, 26) {
			nex[i][j] = nex[i + 1][j];
		}
		nex[i][str[i] - 'a'] = i + 1;
	}
	Rrep(i, str.size()) {
		rep(j, 26) {
			dp[i] = min(dp[nex[i][j]] + 1, dp[i]);
		}
	}
	LL cur = 0;
	while (cur != str.size()+1) {
		LL ne = 0, eval = INF;
		Rrep(i, 26) {
			if (eval >= dp[nex[cur][i]]) {
				eval = dp[nex[cur][i]];
				ne = i;
			}
		}
		ss.push_back(ne + 'a');
		cur = nex[cur][ne];
	}
	cout << ss << endl;
	return 0;
}

Measured memory_bytes: 43524
#include<bits/stdc++.h>
using namespace std;
int main(){

    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i<N; i++){
        cin >> H[i];
    }

    vector<int> S(N);
    S = H; 
    bool can = true;

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

    for(int i = 0; i<N; i++){
        if(abs(H[i] - S[i]) > 1){
            can = false;
        }
    }

    if(can){cout << "Yes" <<endl;}
    else{cout << "No" <<endl;}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int n; string s;
vector<int> buf;
ll ans=0;

void dfs(int i, const int size, const int range_start, const int range_end)
{
    if (i == size) {
        int cnt=0;
        rep(j,0,n){
            if((s[j]-'0')==buf[cnt]){
                cnt++;
            }
        }
        if(cnt>=3) ans++;
    }
    else{
        int from = range_start;
        // if(i == 0) from = range_start; // 広義単調増加数列を作りたければこの2行を追加.
        // else from = buf[i-1];
        for(int j = from; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}


int main(){
    cin>>n;
    cin>>s;
    buf.resize(3);
    dfs(0, 3, 0, 9);
    cout<<ans<<endl;
}

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

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

Measured memory_bytes: 1920
// atcoder/abc118/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    cout << (b % a ? b - a : a + b) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    string s;
    cin >> s;
    bool flag=false;
    int count=0;
    do{
        s.pop_back();
        count++;
        if(s.size()%2!=0) {
            flag=true;
            continue;
        }
        for(int i=0;i<s.size()/2;i++){
            if(s[i]!=s[i+s.size()/2]){
                flag=true;
                break;
            }
            flag=false;
        }

    }while(flag);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n;
	scanf ("%d",&n);
	double *f;
	f = (double *)malloc(sizeof(double)*n);
	int i=0;
	while (i < n)
	{
		scanf("%lf",&(f[i]));
		i++;
	}
	double **dp;
	dp = (double **)malloc(sizeof(double*)*3000);
	i = 0;
	while (i <= n)
	{
		dp[i] = (double*)malloc(sizeof(double)*3000);
		i++;
	}
	i = 0;
	dp[1][0] = 1-f[0];
	dp[1][1] = f[0];
	i = 2;
	int j = 1;
	//printf("debug00100\n");
	while (i <= n)
	{
		j = 0;
		//printf("debug00150, i;%d, j;%d\n",i,j);
		while (j <= i)
		{
			//printf("debug00151, i;%d, j;%d\n",i,j);
			if (j == 0)
			{
				//printf("debug00152, i;%d, j;%d\n",i,j);
				//printf("dp[i-1][j];%lf\n",dp[i-1][j]);
				//printf("f[i-1];%lf\n",f[i-1]);
				dp[i][j] = dp[i-1][j] * (1-f[i-1]);
				//printf("dp[i][j];%lf\n",dp[i][j]);
			}
			else if (j == i)
			{
				//printf("debug00153, i;%d, j;%d\n",i,j);
				dp[i][j] = dp[i-1][j-1] * (f[i-1]);
			}
			else
			{
				//printf("debug00154, i;%d, j;%d\n",i,j);
				dp[i][j] = dp[i-1][j-1]*f[i-1] + dp[i-1][j]*(1-f[i-1]);
			}
			//printf("debug00158, i;%d, j;%d\n",i,j);
			j++;
		}
		i++;
	}
	i = (n+1)/2;
	//printf("debug00200\n");
	double sum = 0.0;
	while (i <= n)
	{
		sum = sum + dp[n][i];
		i++;
	}
	printf("%.10lf\n",sum);
	return (0);
}


Measured memory_bytes: 46336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    vector<int> a(5);
    rep(i,5)cin>>a.at(i);
    int k; cin>>k;
    rep(i,5){
        rep(j,5){
            if(abs(a.at(i)-a.at(j))>k){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include <utility>
#include<algorithm>
using namespace std;
int n;
int main(){
  cin>>n;
  int i=1;
  while(1){
    i++;
    if(i*i>n){cout<<(i-1)*(i-1)<<endl;return 0;}
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;int k;cin>>s>>k;
	vector<string>v;
	rep(i,s.size()){
		for(int j=1;j<=10;j++){
			v.push_back(s.substr(i,j));
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	k--;
	cout<<v[k]<<endl;
}

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

int main() {
  int n;
  int x[100];

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }

  int cost;
  int mincost = INT_MAX;

  for (int p = 1; p <= 100; p++) {
    cost = 0;
    for (int i = 0; i < n; i++) {
      cost += (x[i] - p) * (x[i] - p);
    }
    if (cost < mincost) {
      mincost = cost;
    }
  }

  printf("%d\n", mincost);

  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool ac[100100];int wa[100100];
int main()
{
	memset(ac,false,sizeof(ac));
	memset(wa,0,sizeof(wa));
	int n,m,p,out=0,sw=0;string s;
	cin>>n>>m;
	rep(i,m){
		cin>>p>>s;
		if(ac[p]) continue;
		if(s=="AC"){
			sw+=wa[p];out++;ac[p]=true;
		}
		else wa[p]++;
	}
	cout<<out<<' '<<sw<<endl;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
    
    int width;
    int height;
    int x;
    int y;
    int radius;

    scanf("%d %d %d %d %d", &width, &height, &x, &y, &radius);

    // x,y????????§?¨??????????radius?????§???????????°????????????
    // x,y????????§?¨???¨radius????¶????????????????width,height????????§???????????°????????????
    if(x < radius || y < radius || x + radius > width || y + radius > height) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 584
#include<stdio.h>

long long int X,A=0,B=0;
long long int temp;

int checkA = 0;
int checkB = 0;

int i=0;

long long int five(long long int x){

    return x*x*x*x*x;
}

int main(void){

    scanf("%lld", &X);

    for(A=0; A<1000; A++){
        for(B=0; B<A+1; B++){
            if(five(A)-five(B)==X){
                checkA=1;
                checkB=1;
                break;
            }
            if(five(A)-five(-B)==X){
                checkA=1;
                checkB=-1;
                break;
            }
        }
        if(checkA != 0)break;
    }

    printf("%lld %lld\n", checkA*A, checkB*B);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <array>
#include <string>
#include <set>
using namespace std;

int main() {
    int N;
    cin>>N;
    string st;
    set <string> s;


    for (int i=1;i<=N;i++){
        cin>>st;
        s.insert(st);
    }

    cout<<s.size();
}

Measured memory_bytes: 19252
#include <stdio.h>

#define lint long long int
#define N_MAX 2000



int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    int n_taka = c / b;
    if (c % b) n_taka++;
    
    int n_ao = a / d;
    if (a % d) n_ao++;
    
    if (n_taka <= n_ao) printf("Yes\n");
    else printf("No\n");
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> S(h, vector<char>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (S[i][j]=='#') continue;
            pair<int, int> start = make_pair(i, j);
            queue<pair<int, int>> q;
            vector<vector<int>> d(h, vector<int>(w, -1));
            int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
            q.push(start);
            d[i][j] = 0;
            while (!q.empty()) {
                pair<int, int> p = q.front(); q.pop();
                for (int k = 0; k < 4; ++k) {
                    int nx = p.first + dx[k], ny = p.second + dy[k];
                    if (0 <= nx && nx < h && 0 <= ny && ny < w && S[nx][ny]!='#' && d[nx][ny]<0) {
                        d[nx][ny] = d[p.first][p.second] + 1;
                        ans = max(ans, d[nx][ny]);
                        q.push(make_pair(nx, ny));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;

struct re {
    int x, y;
//    const bool operator < (const re &a) const {
//        if (x != a.x) return x < a.x;
//        return y < a.y;
//    }
};

int f[1111][1111];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    int h, w, a, b;
    cin >> h >> w >> a >> b;

//    if (h * a != w * b) {
//        cout << -1;
//        return 0;
//    }

    ff(i, 1, b)
    ff(j, 1, a) f[i][j] = 1;

    ff(i, b + 1, h)
    ff(j, a + 1, w) f[i][j] = 1;


    ff(i, 1, h) {
        ff(j, 1, w) cout << f[i][j];
        cout << endl;
    }
}
//This code belongs to s34vv1nd


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 141;
int const M = 1e4 + 1;
int const INF = 1e9 + 41;

int n;
int a[MAX];
int ans;
int d[MAX][2];

void solve() {		
	fi(1, n) {
		d[i][0] = d[i][1] = INF;
	}	
	d[1][0] = 0;
	d[1][1] = 1;

	fi(2, n) {
		if (a[i] == a[i - 1]) {
			d[i][0] = d[i - 1][1];
			d[i][1] = 1 + min(d[i - 1][0], d[i - 1][1]);
		} else {
			d[i][0] = min(d[i - 1][0], d[i - 1][1]);
			d[i][1] = 1 + min(d[i - 1][0], d[i - 1][1]);
		}
	}
	printf("%d\n", min(d[n][0], d[n][1]));
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll dp[3010][3010 + 100][2];

int main() {
	int n, m;
	cin >> n >> m;
	dp[0][0][1] = 1LL;
	rep(i, n) dp[0][i + 1][0] = 1LL;

	rep(i, m) {
		rep(j, 3010) {
			if (j == 0) {
				if (j < n) {
					// blue -> red
					(dp[i + 1][0][1] += dp[i][0][1]) %= MOD;
					// blue -> blue
					(dp[i + 1][1][1] += dp[i][0][1]) %= MOD;
				}
			} else if (j == 1) {
				// red -> red
				(dp[i + 1][0][1] += dp[i][1][0] + dp[i][1][1]) %= MOD;

				// red -> blue
				(dp[i + 1][1][1] += dp[i][1][0] + dp[i][1][1]) %= MOD;

				// blue -> red
				if (j < n) {
					(dp[i + 1][1][0] += dp[i][1][0]) %= MOD;
					(dp[i + 1][1][1] += dp[i][1][1]) %= MOD;

					// blue -> blue
					(dp[i + 1][2][0] += dp[i][1][0]) %= MOD;
					(dp[i + 1][2][1] += dp[i][1][1]) %= MOD;
				}
			} else {
				// red -> red
				(dp[i + 1][j - 1][0] += dp[i][j][0]) %= MOD;
				(dp[i + 1][j - 1][1] += dp[i][j][1]) %= MOD;

				// red -> blue
				(dp[i + 1][j][0] += dp[i][j][0]) %= MOD;
				(dp[i + 1][j][1] += dp[i][j][1]) %= MOD;

				if (j < n) {
					// blue -> red
					(dp[i + 1][j][0] += dp[i][j][0]) %= MOD;
					(dp[i + 1][j][1] += dp[i][j][1]) %= MOD;

					// blue -> blue
					(dp[i + 1][j + 1][0] += dp[i][j][0]) %= MOD;
					(dp[i + 1][j + 1][1] += dp[i][j][1]) %= MOD;
				}
			}
		}
	}
	// rep(i, n+1) cout << " " << dp[m][i][1];
	// cout << endl;
	ll ans = 0LL;
	rep(i, n + 1) (ans += dp[m][i][1]) %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 146048
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

bool calc(int h, int w, string[] ss) {
    foreach (r; 0..h) {
        foreach (c; 0..w) {
            if (ss[r][c] == '#') {
                int k = 1;
                if (r > 0 && ss[r-1][c] == '#') k++;
                if (r < h-1 && ss[r+1][c] == '#') k++;
                if (c > 0 && ss[r][c-1] == '#') k++;
                if (c < w-1 && ss[r][c+1] == '#') k++;

                if (k == 1) return false;
            }
        }
    }
    return true;
}

void main() {
    int h, w; scan(h, w);
    string[] ss;
    foreach (_; 0..h) ss ~= read!string;
    writeln(calc(h, w, ss) ? "Yes" : "No");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n[31]={}, who;
    for(int i=1; i<=28; i++){
        cin >> who;
        n[who]=1;
    }
    
    for(int i=1; i<=30; i++){
        if(n[i]==0){
            cout << i << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

class DIS{
private:
	struct cmp1{
		bool operator()(const int*a,const int*b)const{
			return *a<*b;
		}
	};
	int *a[N],top,num[N];
public:
	il int operator[](int x){ return num[x]; }
	il void push(int*p){ a[++top]=p; }
	il int solve(){
		sort(a+1,a+top+1,cmp1());
		int cur=0; num[0]=-1;
		rep(i,1,top) *a[i]= num[cur]==*a[i] ? cur:(num[++cur]=*a[i],cur) ;
		return cur;
	}
}dis;

struct data{ ll mx; };
data NIL = (data){(ll)(0)};
il data operator+(const data&a,const data&b){
	return (data){
		max(a.mx,b.mx)
	};
}
class SEG{
private:
	int n;
	data tr[N*4];
	#define lc(x) ((x)<<1)
	#define rc(x) ((x)<<1|1)
	il void update(int x){
		tr[x]= tr[lc(x)]+tr[rc(x)];
	}
	il void func(int x,ll k){
		tr[x].mx = max(tr[x].mx,k);
	}
	void add(int x,int l,int r,int ql,int qr,ll k){
		if( ql<=l && r<=qr ){
			func(x,k);
			return ;
		}
		int mid = (l+r)/2;
		if( ql<=mid ) add(lc(x),l,mid,ql,qr,k);
		if( qr> mid ) add(rc(x),mid+1,r,ql,qr,k);
		update(x);
	}
	data query(int x,int l,int r,int ql,int qr){
		if( ql<=l && r<=qr ){
			return tr[x];
		}
		int mid = (l+r)/2;
		return 
			( ql<=mid ? query(lc(x),l,mid,ql,qr):NIL )+
			( qr> mid ? query(rc(x),mid+1,r,ql,qr):NIL );
	}
public:
	void init(int n0){
		n = n0;
	}
	il void add(int l,int r,ll k){
		add(1,1,n,l,r,k);
	}
	il data query(int l,int r){
		if( l>r ) return NIL;
		return query(1,1,n,l,r);
	}
}seg;

struct sth{
	int l,r;
	bool operator<(const sth&e)const{
		return r<e.r;
	}
}d[N];

int main(){
	int n=ci();
	rep(i,1,n){
		int x=ci(), l=ci();
		d[i] = (sth){x-l,x+l};
		dis.push(&(d[i].l));
		dis.push(&(d[i].r));
	}
	int s = dis.solve();
	seg.init(s);
	sort(d+1,d+n+1);
	int ans = 0;
	rep(i,1,n){
//		printf("%d %d\n",d[i].l,d[i].r);
		int x= seg.query(1,d[i].l).mx + 1;
		ans = max(ans,x);
		seg.add(d[i].r,d[i].r,x);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 9848
#include <bits/stdc++.h>
  using namespace std;
  #define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
  #define p(x) cout<<(x)<<endl

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

    rep(i, n.size()) {
      if (i%2 == 0){
        cout << n[i];
      } 
    }
  }


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

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

int main() {
  ll a, b, c, d, ans;
  cin >> a >> b >> c >> d;

  ll cdev = b / c - a / c;
  if (a % c == 0) cdev++;
  ll ddev = b / d - a / d;
  if (a % d == 0) ddev++;
  ll lc = lcm(c, d);
  ll cddev = b / lc - a / lc;
  if (a % lc == 0) cddev++;

  ans = b - a + 1 - (cdev + ddev - cddev);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll sum[SIZE];

int main(){
  int n, m;
  ll suma = 0;
  map<pair<int,int>,int> mm;
  
  scanf("%d%d", &n,&m);

  for(int i=0;i<m;i++){
    int a, b;

    scanf("%d%d", &a,&b);
    suma += a;
    mm[make_pair(a,b)]++;
  }
  
  for(auto it : mm){
    int a = it.first.first;
    int b = it.first.second;
    int c = it.second;
    
    for(int i=b-a;i<=n;i+=b){
      if(i) sum[i] -= (ll)c * b;
    }
  }

  for(int i=0;i<n;i++){
    suma += m + sum[i+1];    
    printf("%lld\n",suma);
  }
  
  return 0;
}



Measured memory_bytes: 9820
using System;

class ServalVsMonster {
    static void Main(string[] args) {
        string[] line = System.Console.ReadLine().Trim().Split(' ');
        int rtn = int.Parse(line[0]) / int.Parse(line[1]);
        if ((int.Parse(line[0]) % int.Parse(line[1])) > 0) {
            rtn++;
        }
        System.Console.WriteLine(rtn);
    }
}


Measured memory_bytes: 11092
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Measured memory_bytes: 79848
s=[]
s.append(list(input()))
s.append(list(input()))
s.append(list(input()))
re=["A","B","C"]

i=0
while(1):
  if len(s[i])==0:
    break
  else:
    d=s[i][0]
    s[i].pop(0)
  if d=="a":
    i=0
  elif d=="b":
    i=1
  else:
    i=2

print(re[i])

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>




int main()
{
	int n;
	int i,j;
	int ans,sum;

	while(1)
	{
		scanf("%d",&n);
		if(n==0){break;}
		else
		{
			ans=0;
			for(i=1;i<500;i++)
			{
				sum = i;
				for(j=i+1;j<501;j++)
				{
					sum+=j;
					if(sum==n)
					{
						ans+=1;
						break;
					}
					if(sum>n){break;}
				}
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}
	

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	ll N, X;
	cin >> N >> X;

	ll A = X;
	ll B = N - X;

	if (A == B) co(A * 3);
	else if (A < B) {
		ce(B);
		ll kotae = N;
		while (true) {
			kotae += (B / A) * 2 * A;
			ce(kotae);
			if (B % A == 0) {
				kotae -= A;
				co(kotae);
				return 0;
			}
			B = B % A;
			swap(A, B);
		}

	}
	else {

		ll kotae = A + B + (A / B) * 2 * B;
		if (A % B == 0) {
			kotae -= B;
			co(kotae);
			return 0;
		}
		A %= B;
		while (true) {
			kotae += (B / A) * 2 * A;
			if (B % A == 0) {
				kotae -= A;
				co(kotae);
				return 0;
			}
			B = B % A;
			swap(A, B);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int X, Y, Z, K;
        {int[] a = r.ii(); X = a[0]; Y = a[1]; Z = a[2]; K = a[3];}
        long[] A = r.ll();
        long[] B = r.ll();
        long[] C = r.ll();
        long[] D = new long[X*Y];
        long[] E = new long[K*Z];
        for(int i = 0; i < X; i++)
            for(int j = 0; j < Y; j++)
                D[i*Y+j] = A[i]+B[j];
        Arrays.sort(D);

        for(int i = 0; i < Math.min(K, D.length); i++)
            for(int j = 0; j < Z; j++)
                E[i*Z+j] = D[D.length-1-i]+C[j];
        Arrays.sort(E);
        StringBuilder sb = new StringBuilder();
        for(int i = E.length-1; i > E.length-1-K; i--)
            sb.append(E[i]+"\n");
        print(String.valueOf(sb));
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

typedef long long ll;

typedef pair<ll, int> p;

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

    int N;
    ll A, B;
    cin >> N >> A >> B;
    
    vector<ll> h(N);

    for(int i = 0; i < N; i++) cin >> h[i];

    ll front = 1;
    ll back = pow(10, 9) + 100;

    ll mid = (front + back) / 2LL;

    ll ans = back;

    while(front < back) {
        ll count = 0;
        ll enough = mid;
        for(int i = 0; i < N; i++) {
            if(h[i] > mid * B) {
                enough -= (h[i] - mid * B + (A - B - 1LL)) / (A - B);
            }
        }
        if(enough >= 0) {
            ans = min(ans, mid);
            back = mid;
        } else {
            front = mid + 1LL;
        }
        
        mid = (front + back) / 2LL;
    }

    cout << ans << endl;
}

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

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	

	int a, b;
	cin >> a >> b;

	int c = b - a;

	int takasa = 0;
	rep(i, c) takasa += i;

	cout << takasa - a << "\n";

	Would you please return 0;
}

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

/* 高橋くんはAtCoder銀行に 100 円を預けています。
AtCoder銀行では、毎年預金額の 1 % の利子がつきます(複利、小数点以下切り捨て)。
利子以外の要因で預金額が変化することはないと仮定したとき、
高橋くんの預金額が初めて X 円以上になるのは Y 年後。 */
long long int X;
int main(){
  cin >> X;
  int Y = 0;
  for(long long int i = 100; i < X; i += i / 100){
    Y ++;
    cout << "";
  }
  cout << Y << endl;
}

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

int main() {
    int N,K,A,r=0;
    cin >> N >> K;
    map<int,int> m;
    vector<int> t;

    rep(i,N) {
        cin >> A;
        if(m.count(A))
            m.at(A)++;
        else
            m[A] = 1;
    }

    for(auto p : m)
        t.push_back(p.second);
    sort(t.begin(), t.end());

    if((int)t.size()-K > 0)
        rep(i, t.size()-K)
            r += t.at(i);
    
    cout << r << endl;
}

Measured memory_bytes: 10748
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr int kMax = 10001;

int main() {
  int dp[kMax];
  std::vector<int> num_match = {0,2,5,5,4,5,6,3,7,6};

  int N, M; std::cin >> N >> M;
  std::vector<int> a(M);
  for (int i = 0; i < M; ++i) std::cin >> a[i];

  dp[0] = 0;
  for (int i = 1; i <= N; ++i) dp[i] = -10;

  for (int number : a) {
    int n = num_match[number];
    dp[n] = 1;
  }

  for (int i = 0; i < N; ++i) {
    if (dp[i] < 0) continue;

    for (int number : a) {
      int n = num_match[number];
      if (dp[i + n] < dp[i] + 1) {
        dp[i + n] = dp[i] + 1;
      }
    }
  }

  #if DEBUG
  for (int i = 0; i <= N; ++i) {
    std::cout << dp[i] << " ";
  }
  std::cout << std::endl;
  #endif

  std::sort(a.rbegin(), a.rend());
  std::string ans;
  int matches = N;
  while(dp[matches]>0) {
    for (int number : a) {
      int n = num_match[number];

      if (matches-n<0) continue;
      if (dp[matches-n]<0) continue;

      if ((matches >= n) && ((dp[matches-n] == dp[matches]-1))) {
        ans += std::to_string(number);
        matches -= n;
        break;
      }
    }
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  string s,t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
import fractions
from functools import reduce
input = sys.stdin.readline

n = int(input())
t = [int(input()) for i in range(n)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(t))


Measured memory_bytes: 5560
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
typedef unsigned long long ll;

int num[100000]={0};
char ch[100000];
int main(){
    int N,sum=0,Q,K,i,l,r;
    scanf("%d%d",&N,&Q);
    scanf("%s",ch);
    num[0] =0;
    for(i=1;i<N;i++){
        if(*(ch+i)=='C'&&*(ch+i-1)=='A'){
            sum++;
        }
        *(num+i) = sum; 
    }
    Q = Q-1;
    for(i=Q;i>=0;i--){
        scanf("%d%d",&l,&r);
        printf("%d\n",*(num+r-1)-*(num+l-1));
    }

    return 0;
}


Measured memory_bytes: 1280
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<u128> = sc.vec(n + 1);

    if n == 0 {
        if xs[0] == 1 {
            put!(1);
        } else {
            put!(-1); // ?
        }
        return;
    }
    if xs[0] == 1 {
        if n == 0 {
            put!(1);
        } else {
            put!(-1);
        }
        return;
    }

    let mut rest_nodes: u128 = xs.iter().sum();
    let mut cur_nodes: u128 = 1;
    let mut ok = true;
    let mut ans = 0;

    for &x in xs.iter() {
        // trace!(cur_nodes, rest_nodes, x);
        ans += cur_nodes;
        if cur_nodes >= x {
            cur_nodes -= x;
        } else {
            ok = false;
            break;
        }
        rest_nodes -= x;
        cur_nodes = min!(cur_nodes * 2, rest_nodes);
    }
    if ok {
        put!(ans);
    } else {
        put!(-1);
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var money = 1000L;
        for (int i = 0; i < N - 1; i++)
        {
            money += A[i] < A[i + 1] ? (A[i + 1] - A[i]) * (money / A[i]) : 0;
        }
        Console.WriteLine(money);
    }
}


Measured memory_bytes: 28196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()

#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int k; string s; cin>>k>>s;
	if(sz(s) <= k){
		cout<<s<<endl;
	}
	else{
		cout<<s.substr(0, k)<<"...\n";
	}
}


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

typedef long long LL;

const int N=10000000,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,a,b;

void into(){
  scanf("%d%d%d",&n,&a,&b);
}

int inv[N*2+9],fac[N*2+9],ifac[N*2+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2;i<=n<<1;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int Get_c(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}
int Get_ans(int x,int y){return sub(Get_c(x+y,x),Get_c(x+y,x+1));}

int ans;

void Get_ans(){
  if (!b) {ans=1;return;}
  for (int i=0;i<=n-b&&i<=a;++i){
	if (b+i==n) {sadd(ans,mul(i==a,Get_ans(b-1,a)));continue;}
	sadd(ans,mul(Get_ans(b-1,i),Get_c(n-b-i-1+a-i,a-i)));
  }
}

void work(){
  Get_inv();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 238080
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


int bit_count(ll v)
{
	int ret=0;

	for(;v>0;)
	{
		ret++;
		v&=v-1;
	}

	return ret;
}


int msb(ll v)
{
	if(v==0) return -1;

	int ret=0;
	if(v & 0xFFFFFFFF00000000LL) v>>=32,ret+=32;
	if(v & 0xFFFF0000LL) v>>=16,ret+=16;
	if(v & 0xFF00) v>>=8,ret+=8;
	if(v & 0xF0) v>>=4,ret+=4;
	if(v & 0xC) v>>=2,ret+=2;
	if(v & 0x2) v>>=1,ret+=1;
	return ret;
}


int lsb(ll v)
{
	if(v==0) return -1;

	int ret=0;
	if(!(v & 0xFFFFFFFFLL)) v>>=32,ret+=32;
	if(!(v & 0xFFFF)) v>>=16,ret+=16;
	if(!(v & 0xFF)) v>>=8,ret+=8;
	if(!(v & 0xF)) v>>=4,ret+=4;
	if(!(v & 0x3)) v>>=2,ret+=2;
	if(!(v & 0x1)) v>>=1,ret+=1;
	return ret;
}


template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	ll a, b, c, d;
	map<ll,ll> dp;
	vpii act;

	solve(ll a, ll b, ll c, ll d) : a(a),b(b),c(c),d(d)
	{
		act={{2,a},{3,b},{5,c}};
	}
	ll operator()(ll n)
	{
		if(n==0) return 0;
		if(n==1) return d;
		if(dp[n]>0) return dp[n];

		ll ans=a*msb(n)+d*bit_count(n);
		if(ans/n>d) min_u(ans, d*n);

		for(auto [r, cost]:act)
		{
			int updown=n-n/r*r;
			if(updown==0)
			{
				min_u(ans, cost+(*this)(n/r));
				continue;
			}
			min_u(ans, cost+d*updown+(*this)(n/r));
			min_u(ans, cost+d*(r-updown)+(*this)(n/r+1));
		}
		dp[n]=ans;
		return ans;
	}
};


int main(void)
{
	int t;
	while(scanf("%d", &t)==1)
	{
		ll n;
		int a, b, c, d;
		for(int i=0;i<t;i++)
		{
			scanf("%lld%d%d%d%d", &n, &a, &b, &c, &d);
			printf("%lld\n", solve(a, b, c, d)(n));
		}
	}
	return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int a[220000],b[220000];
using pll = pair<ll,ll>;
int main()
{
    int n;
    cin >> n;
    rep(i,n)cin >> a[i] >> b[i];
    vector<pll> p;
    rep(i,n)p.emplace_back(b[i],a[i]);
    sort(p.begin(),p.end());
    bool ok = true;
    ll time = 0;

    rep(i,n){
        if(time +p[i].second > p[i].first )ok = false;
        time += p[i].second;


    }
    if(ok)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 8048
# include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(W>=x+r&&0<=x-r){
        if(H>=y+r&&0<=y-r)
            printf("Yes\n")
    ;}
    if(W<x+r||0>x-r||H<y+r||0>y-r){

            printf("No\n")
    ;}
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define int long long
using namespace std;


vector<vector<int> >adj;
map<int,int>mm;
int vis[100005];
int cnt=0;
void dfs(int ver)
{
    vis[ver]=1;
    cnt++;
    for(auto i:adj[ver])
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
}

int a[100005];

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    adj.resize(n+1);
    pair<int,int> b[n+1];
    int temp[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>temp[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i].first;
        b[i].second=i;
    }

    sort(b+1,b+n+1);

    for(int i=1;i<=n;i++)
    {
        a[i]=temp[b[i].second];
    }
    for(int i=1;i<=n;i++)
    {
        temp[i]=a[i];
        mm[temp[i]]=i;
    }

    sort(temp+1,temp+1+n);
    bool flag=false;
    for(int i=1;i<n;i++)
    {
        if(temp[i+1]<=b[i].first)
        {
            flag=true;
        }
        if(temp[i]>b[i].first)
        {
            cout<<"No";
            return 0;
        }
    }

    if(temp[n]>b[n].first)
    {
        cout<<"No";
        return 0;
    }

    if(flag)
    {
        cout<<"Yes";
        return 0;
    }

    for(int i=1;i<=n;i++)
    {
        adj[mm[temp[i]]].push_back(i);
    }
    for(int i=1;i<=1;i++)
    {
        if(!vis[i])
        {
            cnt=0;
            dfs(i);
        }
    }
    if(cnt==n)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    

}

Measured memory_bytes: 21848
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
int i=Integer.parseInt(line);
        System.out.println(i*(i+1)/2);
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= b and a >= c) {
        rep (i, k)
            a *= 2;
    } else if (b >= a and b >= c) {
        rep (i, k)
            b *= 2;
    } else {
        rep (i, k)
            c *= 2;
    }
    print(a + b + c);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,r,n,i,j,k,l,c,f;
	cin>>r>>c>>k;
	vector<vc> mat((r+1),vc(c+1));
	vector<vector<vc>> dp((r+1),vector<vc>((c+1),vc(4)));
	//vc score(k+1),row(k+1),col(k+1);
	vector<vc>dp2(r+1,vc(c+1));
	ll row,score,col;
	for(i=1;i<=k;i++)
	{
	    cin>>row>>col>>score;
	    mat[row][col]=score;
	}
	ll temp=0,mx=0;
	for(i=1;i<=r;i++)
	{
	    f=0;
	    for(j=1;j<=c;j++)
	    {
	        /*if(mat[i-1][j]>=mat[i][j-1])
	        {
	            dp[i][j][1]=mat[i][j];
	            temp=mat[i-1][j];//f=j;
	            mat[i][j]=mat[i-1][j]+mat[i][j];
	        }
	        else 
	        {
	            //mx=0;
	            for(k=3;k>=1;k--)
	            {
	                dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+mat[i][j]);
	  
	            }
	            mat[i][j]=temp+max(dp[i][j][2],dp[i][j][3]);
	        }*/
	        dp[i][j][1]=max(dp[i][j-1][1],mat[i][j]+max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3])));
	        dp[i][j][2]=max(dp[i][j-1][2],mat[i][j]+dp[i][j-1][1]);
	        dp[i][j][3]=max(dp[i][j-1][3],mat[i][j]+dp[i][j-1][2]);
	    }
	}
	cout<<max(dp[r][c][1],max(dp[r][c][2],dp[r][c][3]));
	return 0;
}


Measured memory_bytes: 777472