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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll c[3][3];
	rep(i, 0, 3) {
		rep(j, 0, 3) {
			cin >> c[i][j];
		}
	}

	ll a[3] = {};
	ll b[3] = {};
	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	if (a[1] + b[1] == c[1][1] &&
		a[2] + b[1] == c[2][1] &&
		a[1] + b[2] == c[1][2] &&
		a[2] + b[2] == c[2][2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int N = 2 * (int)1e5;
vector<int> conns[N];
int side[N];
int cou[N];

void dfs(int i, int p) {
	side[i] = 1 ^ side[p];
	++cou[side[i]];
	for (auto t : conns[i]) if (t != p) dfs(t, i);
}

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

	int n;
	cin >> n;
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		conns[a].push_back(b);
		conns[b].push_back(a);
	}
	dfs(0, 0);

	int t1 = (n+2) / 3;
	int s1 = (cou[1] > cou[0]);
	cou[s1] -= t1;

	int t2 = (n+1) / 3;
	int s2 = (cou[1] > cou[0]);
	cou[s2] -= t2;

	if (cou[s1] < 0 || cou[s2] < 0) cout << -1 << '\n';
	else {
		vector<int> inds = {3, 1, 2};
		for (int i = 0; i < n; ++i) {
			if (side[i] == s1 && inds[1] <= n) {
				cout << inds[1] << ' ';
				inds[1] += 3;
			} else if (side[i] == s2 && inds[2] <= n) {
				cout << inds[2] << ' ';
				inds[2] += 3;
			} else {
				cout << inds[0] << ' ';
				inds[0] += 3;
			}
		}
		cout << '\n';
	}
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll A,B,N;
    cin >> A >> B >> N;
    ll min_num = min(B-1,N);
    ll end_num = max((ll)0, min_num - (ll)1e6);

    ld ans =0;
    for (ll i = min_num; i>=end_num; i--) {
        ld tmp = (A*i)/B - A * (i/B);
        ans = max(ans,tmp);
    }

    // resolve

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int Tmp = A+B;
    Tmp = max(Tmp, A-B);
    Tmp = max(Tmp, A*B);
    cout << Tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

    bool issame(int x,int y){
        return root(x)==root(y);
    }

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }

    int ans=0;
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i==j) continue;
            uf.merge(a[j],b[j]);
        }
        if(!uf.issame(a[i],b[i])) ans++;
    }

    cout<<ans<<endl;
}


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

int main()
{
	int m[11], i, j, work;
	for(i=0; i<10; i++)
	{
		cin >> m[i];
	}
	for(i=0; i<10; i++)
	{
	 	for(j=0; j<10; j++)
		{
	    	if(m[i] > m[j])
			{
	   			work = m[i]; m[i] = m[j]; m[j] = work;
	   		}
	  	}
	}
	for(i=0; i<3; i++)
	{
	 	cout << m[i] << endl;
	}
	return 0; 
}

Measured memory_bytes: 3084
import Text.Printf (printf)

surf :: (Double,Double) -> Double
surf (x,h) = x**2.0+2.0*x*(h**2.0+(x/2.0)**2.0)**0.5

main :: IO ()
main = do
    s <- getContents :: IO String
    let input = filter (/=0) . map (\ x -> read x :: Int) . lines $ s
    let n = (length input) `div` 2
    let tuple i = (realToFrac(input!!(i*2)), realToFrac(input!!(i*2+1)))
    let input' = map (tuple) [0..(n-1)]
    mapM_ (\ x -> printf "%.6f\n" x) $ map surf input' 
    

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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

#define uniq(v) (v).erase(unique(ALL((v))), (v).end());

// area of (0, 0)(a, b)(c, d)
double area(double a, double b, double c, double d){
    return abs(a * d - b * c) / 2.0;
}

const int PREC = 10;
#define coutf(val) cout << fixed << setprecision(PREC) << (val) << endl;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make2(string, S, T);

    int ans = 0;
    REP(i, sz(S)) {
        if (S.at(i) != T.at(i)) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3924
fun main(args: Array<String>) {
    val N = nextInt()
    val X = listOfInt().mapIndexed { index, value -> value to index }.sortedBy { it.first }
    val P = IntArray(N)
    repeat(N) { n -> P[X[n].second] = n}
    val c = N / 2
    val ans = Array(N) {  n ->
        val i = if (P[n] >= c) c - 1 else c
        X[i].first
    }
    println(ans.joinToString("\n"))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }


Measured memory_bytes: 128196
/*I wanna be the very best, like no one ever was...*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MAX = 1e6 + 10;
const ll MOD = 1e9 + 7;
ll fact[MAX];
ll modExp(ll b, ll p) {
	ll res = 1;
	while(p > 0) {
		if(p & 1) res = (res * b) % MOD;
		b = (b * b) % MOD, p >>= 1;
	}
	return res;
}
void add(ll &a, ll b) {
	b %= MOD;
	a = (a + b) % MOD;
}
void mul(ll &a, ll b) {
	b %= MOD;
	a = (a * b) % MOD;
}
void sub(ll &a, ll b) {
	b %= MOD;
	a = (a - b) % MOD;
	a = (a + MOD) % MOD;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	if(n == 1) return cout << 0, 0;
	ll ans = modExp(10, n);
	sub(ans, 2 * modExp(9, n));
	add(ans, modExp(8, n));
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3616
N,K = map(int,input().split())
D = input().split()
num = set([str(i) for i in range(10)])
Ds = set(D)
diff = num^Ds
ans = N
while True:
    strN = set(list(str(ans)))
    if strN - diff:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 3064
def cnt_operations(i, K):
    ans = 0
    while i < K:
        i *= 2
        ans += 1
    return ans


N, K = map(int, input().split())

ans = 0
if K <= N:
    ans += (N - K + 1) / N
    for i in range(1, K):
        op = cnt_operations(i, K)
        ans += (1 / N) * (1 / 2)**(op)
else:
    for i in range(1, N + 1):
        op = cnt_operations(i, K)
        ans += (1 / N) * (1 / 2)**(op)
print(ans)


Measured memory_bytes: 3060
N, M = map( int, input().split())
Q = [[int(s) for s in input().split()] for _ in range(M)]
Q = sorted(Q)
ans = 1
stan = Q[0][1]
for i in range(M):
    if Q[i][0] < stan:
        stan = min(stan,Q[i][1])
    else:
        ans += 1
        if i == M-1:
            break
        else:
            stan = Q[i][1]
print(ans)

Measured memory_bytes: 22432
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int ans, n, a, b, c, x, now, y[101];
	
	while(1){
		cin >> n >> a >> b >> c >> x;
		if(!n) break;
		for(int i=0; i<n; i++){
			cin >> y[i];
		}
		now = 0;
		ans = -1;
		while(ans <= 10000 && now < n){
			ans++;
			//cout << "(x,now,y)=" << x << " " << now << " " << y[now] << endl;
			if(x == y[now]){
				now++;
			}
			x = ( a * x + b ) % c;
		}
		if(ans <= 10000)cout << ans << endl;
		else cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int a,b,k; cin >> a >> b >> k;

  if(a>=k){
    a-=k;
  }else{
    k-=a;
    a = 0;
    if(b>=k) b = b - k;
    else b = 0;
  }
  
  cout << a << " " << b << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int num, temp;
int count = 0;

void print(int array[]) {
    for (int i = 0; i < num; i++) {
        if (i == num - 1) {
            cout << array[i] << endl;
        } else {
            cout << array[i] << " ";
        }
    }
}

    int main() {
        cin >> num;
        int array[num] = {};
        for (int i = 0; i < num; i++) {
            cin >> array[i];
        }
        for (int i = 1; i < num; i++) {
            for (int j = 0; j < num - 1; j++) {
                if (array[j] > array[j + 1]) {
                    temp = array[j + 1];
                    array[j+1] = array[j];
                    array[j] = temp;
                    count++;
                }
            }

        }
        print(array);
        cout << count << endl;
        return 0;
    }


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int done[200001];
int visited[200001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,pathLength=0,cur=1,recursAt;
    ll k;
    cin>>n>>k;
    int a[n+1];
    int path[n+1];
    for (int i=1;i<=n;++i)
        cin>>a[i];
    for (int i=0;1;++i)
    {
        path[i]=cur;
        if (done[cur])
        {
            pathLength=i;
            recursAt=cur;
            break;
        }
        done[cur]=i+1;
        cur=a[cur];
    }
    //cout<<pathLength<<" "<<recursAt<<"\n";
    if (k<=pathLength)
    {
        cout<<path[k];
        return 0;
    }
    k-=pathLength;
    cur=recursAt;
    //cout<<"test\n";return 0;
    for (int i=0;1;++i)
    {
        if (visited[cur])
        {
            pathLength=i;
            break;
        }
        path[i]=cur;
        visited[cur]=1;
        cur=a[cur];
    }
    cout<<path[k%pathLength];
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
typedef pair<ll,ll> P;
vector<ll> vl[1000];
vector<P> vp[1000];
void readtime(){
	ll a,b,c,d;
	char e;
	int f;
	scanf("%lld/%lld %lld:%lld %c %d\n",&a,&b,&c,&d,&e,&f);
	vl[f].pb((mon[a-1]+b)*24*60+c*60+d);
}
int main(){
	rep(i,12) mon[i+1]+=mon[i];
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,1000) vl[i].clear(),vp[i].clear();
		rep(i,N) readtime();
		rep(i,1000){
			rep(j,vl[i].size()/2) vp[i].pb(P(vl[i][j*2],vl[i][j*2+1]));
		}
		ll ans=0;
		rep1(i,999){
			ll tmp=0;
			for(P p:vp[i]) for(P q:vp[0]) tmp+=max(0LL,min(p.sc,q.sc)-max(p.fs,q.fs));
			chmax(ans,tmp);
		}
		cout<<ans<<endl;
	}
}

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

typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a%2==0&&a==b&&b==c){
        cout << -1 << endl;
        return 0;
    }
 
    if(a%2!=0||b%2!=0||c%2!=0){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 0;
 
    while(true){
        int aa = a,bb= b,cc=c;
        a = bb/2 + cc/2;
        b = aa/2 + cc/2;
        c = aa/2 + bb/2;
        ans++;
        if(a%2!=0||b%2!=0||c%2!=0){
            break;
        }
    }
 
 
    cout << ans << endl;
}


Measured memory_bytes: 3620
def area(higt, wide):
    a = higt
    b = wide
    return a * b

def circ(higt, wide):
    a = higt
    b = wide
    return 2 * int(a) + 2 * int(b)


imput = raw_input().split()
menseki = area(int(imput[0]), int(imput[1]))
ensyu = circ(imput[0], imput[1])

print(str(menseki) + " " + str(ensyu))

Measured memory_bytes: 6356
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <algorithm>
using namespace std;

int n,m;
struct Node
{
    int x;
    int y;
}node[200005];
int l[200005],r[200005];

bool cmp(Node a,Node b)
{
    return a.x<b.x;
}

int main()
{
    scanf ("%d %d",&n,&m);
    for (int i=1;i<=m;i++)
        scanf ("%d %d",&node[i].x,&node[i].y);
    sort(node+1,node+1+m,cmp);
    for (int i=1;i<=n;i++)
        l[i]=r[i]=i;
    for (int i=1;i<=m;i++)
        {
        l[node[i].y]=l[node[i].y+1]=min(l[node[i].y],l[node[i].y+1]);
        r[node[i].y]=r[node[i].y+1]=max(r[node[i].y],r[node[i].y+1]);
        }
    for (int i=1;i<n;i++)
        printf ("%d ",r[i]-l[i]+1);
    printf ("%d\n",r[n]-l[n]+1);
}

Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        Console.WriteLine(Console.ReadLine().ToCharArray().Contains('7') ? "Yes" : "No");
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 26008
# coding: utf-8

def bubbleSort(A, N):
    flag = 1
    c = 0
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                c += 1
                flag = 1
    print(' '.join(map(str, A)))
    print(c)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    bubbleSort(A, N)


Measured memory_bytes: 5604
//Rainy Season 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')cout<<3<<nnn;
    else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R')cout<<2<<nnn;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')cout<<1<<nnn;
    else cout<<0<<nnn;
    return 0;
}

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

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1;
        while (n < sz) n *= 2;

        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for (int i=0; i<sz; ++i) node[i+n-1] = v[i];
        for (int i=n-2; i>=0; --i) node[i] = node[i*2+1] + node[i*2+2];
    }

    // 伝搬させるため
    void eval(int k, int l, int r) {
        if (lazy[k] != 0) {
            node[k] += lazy[k];

            // 範囲が半分になるから，値も半分になる
            if (r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }

            lazy[k] = 0;
        }
    }

    // [a, b)
    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;

        // k番目のノードで遅延評価
        eval(k, l, r);

        // 範囲外なら何もしない
        if (r <= a or b <= l) return;

        // 完全に被覆していたら評価
        if (a <= l and r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            // そうじゃないなら，被覆するまで下がる
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        if (r <= a or b <= l) return 0;

        eval(k, l, r);
        if (a <= l and r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> v(n, 0);

    LazySegmentTree lst(v);
    rep(i, q) {
        int c;
        cin >> c;
        if (c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            s--;
            lst.add(s, t, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            s--;
            cout << lst.getsum(s, t) << endl;
        }
    }
}



Measured memory_bytes: 8432
MOD = 10 ** 9 + 7
L = input()
N = len(L)
p3 = [1] * N
for i in range(1, N):
    p3[i] = p3[i - 1] * 3 % MOD
p2 = 1
total = 0
for i in range(N):
    if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD
print((total + p2 * p3[N - i - 1]) % MOD)

Measured memory_bytes: 7156
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch))
	{
	 	if(ch=='-')
		 	f=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
	 	x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll a=read(),b=read();
	cout<<(a+b-1)/b<<endl;
	return 0;
}

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

int main(){
    int a,b,c,d,l,r;
    cin>>a>>b>>c>>d;
    
    l=a+b;
    r=c+d;
    
    if(l>r)
        cout<<"Left"<<endl;
    else if(l<r)
        cout<<"Right"<<endl;
    else
        cout<<"Balanced"<<endl;
        
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int a, b; cin >> a >> b;
    int ret{0};
    if (b != 1) {
        ret++;
        while(a + (a-1)*(ret-1) < b) {
            ret++;
        }
    }
    cout << ret << endl;
}

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

Measured memory_bytes: 256
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc125/tasks/abc125_b

n = int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
e = [v - c for v, c in zip(v, c) if v - c > 0]
print(sum(e)) if len(e) > 0 else print(0)


Measured memory_bytes: 2940
from collections import defaultdict

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

rate = defaultdict(int)

for a in A:
    if 1 <= a <= 399:
        rate[1] += 1
    if 400 <= a <= 799:
        rate[2] += 1
    if 800 <= a <= 1199:
        rate[3] += 1
    if 1200 <= a <= 1599:
        rate[4] += 1
    if 1600 <= a <= 1999:
        rate[5] += 1
    if 2000 <= a <= 2399:
        rate[6] += 1
    if 2400 <= a <= 2799:
        rate[7] += 1
    if 2800 <= a <= 3199:
        rate[8] += 1
    if a >= 3200:
        rate[9] += 1

valiable = len(rate.keys())
topcoder = rate[9]

if topcoder:
    if valiable == 1:
        print(1, min(topcoder, 9))
    else:
        print(valiable - 1, valiable + topcoder - 1)
else:
    print(valiable, valiable)


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

int main() {
  int n;
  cin>>n;
  int long long k=0;
  for(int i=0;i<n+1;i++){
    int a=i%5;
    int b=i%3;
    if(a==0||b==0){
      k+=0;
    }
    else{ 
      k+=i;
        }
  }
  cout<<k<<endl;
}



Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	cnt := make([]int, 5)
	// M A R C H
	// 0 1 2 3 4

	for i := 0; i < n; i++ {
		n := sc.NextLine()
		tmp := string(n[0])
		switch tmp {
		case "M":
			cnt[0]++
		case "A":
			cnt[1]++
		case "R":
			cnt[2]++
		case "C":
			cnt[3]++
		case "H":
			cnt[4]++
		}
	}
//	fmt.Printf("%+v\n", cnt) // output for debug

	ans := 0
	for i := 0; i < 5-2; i++ {
		for j := i + 1; j < 5-1; j++ {
			for k := j + 1; k < 5; k++ {
				//				fmt.Printf("%+v %d %d\n", cnt[i], cnt[j], cnt[k]) // output for debug

				ans += cnt[i] * cnt[j] * cnt[k]
			}
		}
	}

	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	bool res = false;
	string str,str2,key = "keyence";
	cin >> str;
	int length = str.length();
	if (str == key) {
		res = true;
	}
	for (int i = 0; i < 7;i++) {
		str2 = str.substr(0, i) + str.substr(length - (7 - i));
		if (key == str2) {
			res = true;
		}
	}
	if (res) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    string data;
    cin >> data;
    int ans = 0;
    char befo;
    for (int i = 0; i < data.length(); i++)
    {
        char now = data.at(i);
        if (befo != now)
        {
            ans++;
        }
        befo = now;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
use std::cmp::min;
use std::collections::HashSet;

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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>();
    let s1: Vec<char> = s.chars().collect();

    let answer = solve(n, s, &s1);
    println!("{}", answer);
}

fn solve(n: usize, s: String, s1: &[char]) -> usize {
    let mut v_max = 0;
    for i in 0..n {
        let s2 = &s1[i..n];
        let z = z_algo(s2.len(), s2);
        //println!("z: {:?}", z);
        let tmp = get_max(z.len(), &z);
        //println!("tmp: {}", tmp);
        if tmp > v_max {
            v_max = tmp;
        }
    }
    return v_max;
}

fn z_algo(n: usize, s: &[char]) -> Vec<usize> {
    //println!("*** {}, {:?}", n, s);
    let mut z: Vec<usize> = vec![0; n];
    let mut l: usize = 0;
    let mut r: usize = 0;
    for i in 1..n {
        //println!("{}", i);
        if i >= r {
            //println!("   A");
            l = i;
            r = i;
            while r < n && s[r] == s[r - l] {
                r += 1;
            }
            z[i] = r - l;
        //r -= 1;
        } else {
            let k = i - l;
            if z[k] < r - i {
                //println!("   B1");
                z[i] = z[k];
            } else {
                //println!("   B2");
                l = i;
                while r < n && s[r] == s[r - l] {
                    r += 1;
                }
                z[i] = r - l;
            }
        }
    }
    // println!("{:?}", z);
    return z;
}

/**
 * l1 + len <= l2
 *  --> z[i] <= l1
 */
fn get_max(n: usize, z: &[usize]) -> usize {
    let mut v_max: usize = 0;
    for i in 1..n {
        let tmp = min(z[i], i);
        if tmp > v_max {
            v_max = tmp;
        }
    }
    return v_max;
}


Measured memory_bytes: 4352
#include "stdio.h"

int main(){
  int a, b, c, d, e;
  scanf("%d %d", &a, &b);
  c = a + b;
  d = a - b;
  e = a * b;
  if(c > d){
    if(c > e){
      printf("%d\n", c);
    }
    else{
      printf("%d\n", e);
    }
  }
  else if(d > e){
    printf("%d\n", d);
  }
  else{
    printf("%d\n", e);
  }
}


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

namespace ABC117_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (M == 1 || N >= M)
            {
                Console.WriteLine(0);
                return;
            }

            Array.Sort(X);

            long ans = 0;
            var dis = new long[M];
            for (int i = 1; i < M; i++)
            {
                dis[i] = X[i] - X[i - 1];
            }

            var ignore = dis.OrderByDescending(x => x).Take(N - 1).ToArray().Sum();
            ans = dis.Sum() - ignore;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25696
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
template< typename T = long long >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
int main(){
    int n;
    cin>>n;
    auto a=make_v<int>(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    int now=0;
    ll ret=0;
    for(int i=0;i<n;i++){
        ret+=a[i];
        now++;
        if(now==n-1)break;
        ret+=a[i+1];
        now++;
        if(now==n-1)break;
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 4028
#include <iostream>
using namespace std;
int main() {
	int N;
  int K;
	cin >> N;
  cin >> K;
  int x[N];
  for (int i=0 ;i< N;i++)
  {
    cin >> x[i];
  }
  int sum = 0;
  for(int i = 0; i < N; i++)
  {
    double k_middle = K/2.0;
    if(x[i] < k_middle)
    {
      sum += x[i]*2;
    }
    else
    {
      sum += (K - x[i])*2;
    }
  }
	cout << sum << endl;
}

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

ll solve(ll W[], ll V[]){
  ll dp[n+1][w+1];
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=w;j++)
		{
			//cout<<"1"<<endl;
			if(i==0 || j==0)
			{
				dp[i][j] = 0;
				continue;
			}
			if(W[i-1]<=j)
			{
				dp[i][j] = max(V[i-1]+dp[i-1][j-W[i-1]],dp[i-1][j]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	return dp[n][w];
}

int main()
{
	
	cin>>n>>w;
	
	ll W[n],V[n];
	for(ll i=0;i<n;i++)
	{
		cin>>W[i]>>V[i];
	}
	
	cout<<solve(W,V)<<endl;
	return 0;
}

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

std::vector< std::vector< int > > exist_No(26);

int binary_search(int word_No, int key) {
    int left = -1;
    int right = (int)exist_No[word_No].size();
    
    while(right - left > 1){
        int mid = left + (right - left) / 2;
        
        if(exist_No[word_No][mid] > key){
            right = mid;
        }else{
            left = mid;
        }
    }
    
    return right;
}

int main(){
    std::string S, T;
    std::cin >> S >> T;
    
    for(int i=0; i<S.size(); i++){
        exist_No[S[i] - 'a'].push_back(i);
    }
    
    long long cnt = 0;
    int cur_word = -1;
    for(int i=0; i<T.size(); i++){
        if(exist_No[T[i] - 'a'].size() == 0){
            std::cout << -1 << std::endl;
            return 0;
        }
        if(exist_No[T[i] - 'a'][exist_No[T[i] - 'a'].size() - 1] <= cur_word){
            cnt += S.size();
            cur_word = -1;
        }
        
        int cur_index = binary_search(T[i] - 'a', cur_word);
        cur_word = exist_No[T[i] - 'a'][cur_index];
    }
    cnt += cur_word + 1;
    
    
    std::cout << cnt << std::endl;
    
    return 0;
}



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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

const int N = 300010;
const int mod = 998244353;

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        int d1 = a.ss - a.ff, d2 = b.ss - b.ff;
        return ((d1 > d2) || (d1 == d2 && a.ff < b.ff));
    }
};

int seg[4 * N] = {};

void update(int node, int l, int r, int pos, int val) {
    if (l == r) {
        seg[node] = val;
        return;
    }

    int mid = l + r >> 1;
    if (pos <= mid) {
        update(2 * node, l, mid, pos, val);
    }
    else
        update(2 * node + 1, mid + 1, r, pos, val);

    seg[node] = max(seg[2 * node], seg[2 * node + 1]);
}


int query(int node, int l, int r, int x, int y) {
    if (x > y) return 0;

    if (l == x && r == y) return seg[node];

    int mid = l + r >> 1;

    return max(query(2 * node, l, mid, x, min(mid, y)), query(2 * node + 1, mid + 1, r, max(mid + 1, x), y));
}

int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, k;
    cin >> n >> k;

    int a[n];

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

    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int l;
        l = query(1, 0, N, max(0ll, a[i] - k), min(N, a[i] + k));
        l += 1;

        update(1, 0, N, a[i], l);

        ans = max(ans, l);
    }

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

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

using namespace std;
using ll = long long;

#define int ll
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define sz(x) int(x.size())



signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a;
	int b;
	cin >> a >> b;
	cout << a / __gcd(a, b) * b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

ll n, m;
ll ans = 1;

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

    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(n == m){
        rrep(i, n){
            ans = (ans * i) % DIV;
        }
        rrep(i, m){
            ans = (ans * i) % DIV;
        }
        ans = (ans * 2) % DIV;
    }
    else{
        rrep(i, n){
            ans = (ans * i) % DIV;
        }
        rrep(i, m){
            ans = (ans * i) % DIV;
        }
    }
    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 N, K;
  scanf("%d %d", &N, &K);
  int H[100005];
  for (int i = 0; i < N; i++) {
    scanf("%d", &H[i]);
  }
  sort(H, H + N);
  int res = 1e9 + 10;
  for (int i = 0; i < N - K + 1; i++) {
    res = min(res, H[i + K - 1] - H[i]);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 





import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
//        solver.test();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    //================================================================================
    int N, K, R, S, P;
    char[] C;
    char[] rec = new char[100010];
    public void solve() {
    	N = Integer.parseInt(sc.next());
    	K = Integer.parseInt(sc.next());
    	R = Integer.parseInt(sc.next());
    	S = Integer.parseInt(sc.next());
    	P = Integer.parseInt(sc.next());
    	C = sc.next().toCharArray();
    	long ans = 0;
    	int cnt;
    	for (int i = 0; i < N; i++) {
    		cnt = i - K;
			if(cnt >= 0) {
				if(C[i] == 'r') {
					if(rec[cnt] != 'p') {
						rec[i] = 'p';
						ans += P;
					}
				} else if(C[i] == 's') {
					if(rec[cnt] != 'r') {
						rec[i] = 'r';
						ans += R;
					}
				} else if(C[i] == 'p') {
					if(rec[cnt] != 's') {
						rec[i] = 's';
						ans += S;
					}
				}
			} else {
				if(C[i] == 'r') {
					rec[i] = 'p';
					ans += P;
				} else if(C[i] == 's') {
					rec[i] = 'r';
					ans += R;
				} else if(C[i] == 'p') {
					rec[i] = 's';
					ans += S;
				}
			}
		}
    	out.println(ans);
    }
}

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

using Int = unsigned long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int n;
	cin >> n;
	std::vector<Int> l(n);

	RC(i, n) cin >> l[i];

	std::sort(l.begin(), l.end());

	/*
	RC(i, n) cout << l[i] << ' ';
	cout << endl;
	*/

	Int ans = 0;
	for(auto i = l.begin(); i != l.end(); ++i){
		for(auto j = l.begin(); j != i; ++j){
			auto k = lower_bound(i, l.end(), *i + *j);
			ans += k - i - 1;
	//		cout << k - i - 1 << endl;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    string s,t,str="";
    cin>>s>>t;
    for(int i=0;i<t.length()-1;i++)
    str+=t[i];
    if(s==str)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
vector<ll> v(10);
for(int i = 0; i < 4; ++i){
    int a; cin >> a;
    ++v[a];
}
string ans = "NO";
if(v[1]&&v[9]&&v[7] && v[4])ans = "YES";
cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll n,ans=0;
	cin>>n;
	f(i,1,n+1){
		ans+=(n-1)/i;
	}
	cout<<ans<<"\n";
    return 0; 
}

Measured memory_bytes: 3608
def main():
    N = int(input())
    K = int(input())
    
    x = [int(i) for i in input().split()]
         
    #print(N)
    #print(K)
    #print(x)
    
    sum_dis = 0
    for pos in x:
        min_dis = min(pos, K - pos) * 2
        sum_dis += min_dis
        
    print(sum_dis)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int x,y;
    cin >> x >> y;
    bool ok = true;
    if(y-2*x < 0 || 4*x -y < 0) ok = false;
    if((y-2*x)%2 != 0 || (4*x -y)%2 != 0) ok = false;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628