akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	REP(i, n) {
		if (i != 0)cout << endl;
		int inpt[9][9]; REP(j, 9)REP(k, 9)inpt[j][k] = in();
		bool dpl[9][9]; REP(j, 9)REP(k, 9)dpl[j][k] = false;
		REP(j, 9) {
			int cnt[9] = { 0,0,0,0,0,0,0,0,0 };
			REP(k, 9)++cnt[inpt[j][k] - 1];
			REP(k, 9)if (cnt[inpt[j][k] - 1] > 1)dpl[j][k] = true;
		}
		REP(k, 9) {
			int cnt[9] = { 0,0,0,0,0,0,0,0,0 };
			REP(j, 9)++cnt[inpt[j][k] - 1];
			REP(j, 9)if (cnt[inpt[j][k] - 1] > 1)dpl[j][k] = true;
		}
		REP(j, 3) {
			REP(k, 3) {
				int cnt[9] = { 0,0,0,0,0,0,0,0,0 };
				for (ll l = j * 3; l < j * 3 + 3; ++l) for (ll m = k * 3; m < k * 3 + 3; ++m) ++cnt[inpt[l][m] - 1];
				for (ll l = j * 3; l < j * 3 + 3; ++l) for (ll m = k * 3; m < k * 3 + 3; ++m) if (cnt[inpt[l][m] - 1] > 1)dpl[l][m] = true;
			}
		}
		REP(j, 9) {
			REP(k, 9) cout << (dpl[j][k] ? '*' : ' ') << inpt[j][k];
			cout << endl;
		}
	}
}


Measured memory_bytes: 3076
// A - HonestOrDishonest

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	char a, b;
	cin >> a >> b;

	char ans;
	if (a == 'H') {
		if (b == 'H') ans = 'H';
		else ans = 'D';
	} else {
		if (b == 'H') ans = 'D';
		else ans = 'H';
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static int ans = 0;
	static int N;
	static int[] V;
	static int[] C;
  public static void main(String[] args) {
	int i;
	Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    V = new int[N];
    C = new int[N];
    for (i = 0; i < N; i++) {
    	V[i] = sc.nextInt();
    }
    for (i = 0; i < N; i++) {
    	C[i] = sc.nextInt();
    }
    Main.keisan(0, 0, 0);
    System.out.println(ans);
  }
  static void keisan(int now, int x, int y) {
	if (now >= N) {
		return;
	}
	int x1 = x + V[now];
	int y1 = y + C[now];
	ans = Math.max(ans, x1-y1);
	ans = Math.max(ans, x-y);
	keisan(now+1, x, y);
	keisan(now+1, x1, y1);
  }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 1e6 + 5;
const int MAXLOG = 45;

ll sum[MAXN];

ll vv[MAXN];
int top_vv;

int good[MAXN];

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	REPN(i, 1, n) {
		int a;
		scanf("%d", &a);
		sum[i] = sum[i - 1] + a;
	}
	REPN(i, 1, n) {
		REPN(j, i, n) {
			vv[top_vv++] = sum[j] - sum[i - 1];
		}
	}
	REP(i, 0, top_vv) {
		good[i] = 1;
	}
	ll ans = 0ll;
	for(int i = MAXLOG; i >= 0; i--) {
		int cnt = 0;
		ll mask = (1ll << i);
		REP(j, 0, top_vv) {
			if (good[j] && (vv[j] & mask)) {
				cnt++;
			}
		}
		if (cnt >= k) {
			ans |= mask;
			REP(j, 0, top_vv) {
				if (good[j] && !(vv[j] & mask)) {
					good[j] = 0;
				}
			}
		}
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0;
    vector<int>a(n+1,0);
    rep(i,n){
        if(s[i]=='<'){a[i+1]=a[i]+1;}
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){a[i]=max(a[i],a[i+1]+1);}
    }
    rep(i,n+1){ans+=a[i];}
    cout<<ans;
}

Measured memory_bytes: 2844
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (transpose)

main :: IO ()
main = do
  (n : k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ps <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    cs :: [Int]
    cs = scanl (+) 0 ps
    m :: Int
    m = maximum . diff $ cs
      where
        diff :: [Int] -> [Int]
        diff = zipWith subtract <$> id <*> drop k
  print . fromRational $ toRational (m + k) / 2

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 39164
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

def main():

    K = int(input())

    ans = []

    queue = deque(['1','2','3','4','5', '6', '7', '8', '9'])

    visited = set()
    for i in range(9):
        visited.add(queue[i])

    for i in range(K):

        current = queue.popleft()
        ans.append(int(current))
        digit_tail = int(current[-1])


        digit_tail_1 = str(digit_tail - 1)
        digit_tail_2 = str(digit_tail)
        digit_tail_3 = str(digit_tail + 1)

        if int(digit_tail_1) != -1 and current+digit_tail_1 not in visited:

            queue.append(current+digit_tail_1)
            visited.add(current+digit_tail_1)

        if current+digit_tail_2 not in visited:
            queue.append(current+digit_tail_2)
            visited.add(current+digit_tail_2)

        if int(digit_tail_3) != 10 and current+digit_tail_3 not in visited:
            queue.append(current+digit_tail_3)
            visited.add(current+digit_tail_3)

    ans.sort()
    print(ans[K-1])

if __name__ == "__main__":
    main() 

Measured memory_bytes: 110936
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std; 
vector<int> right;
int main()
{
  int i,n;
  scanf("%d",&n);
  for(i=1; i<=2*n; i++)
  {
    	int a;
     	scanf("%d",&a);
    	right.push_back(a);
  }
  sort(right.begin(),right.end());
  int sum=0; 
  for(i=0; i<2*n; i++)
  {
    if(i%2==0)sum+=right[i];
  }
  printf("%d",sum); 
}


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

#define int long long
#define fi first
#define se second
#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 repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807



int n,a,ans;
vector<int> v,bin;
map<int,int> m;

main() {
    int hoge = 1;
    rep(i,30) hoge *= 2,bin.pb(hoge);
    cin >> n;
    rep(i,n) cin >> a,m[a]++,v.pb(a);
    sort(rall(v));
    rep(i,n) {
        if (!m[v[i]]) continue;
        int pi = *upper_bound(all(bin),v[i])-v[i];
        m[v[i]]--;
        if (m[pi]) ans++,m[pi]--;
    }
    cout << ans << endl;
}


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


int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> Switch(M);
    for(int i=0; i<M; i++){
        int k; cin >> k;
        Switch[i].resize(k);
        for(int j=0; j<k; j++){
            cin >> Switch[i].at(j); //二次元配列　行が電球、列がスイッチ
 			Switch[i].at(j) --;
        }
    }
    vector<int> p(M);
	for (int i = 0; i < M; ++i){
        cin >> p[i];                     //余り配列
    }

    int ans=0; //組み合わせの個数(答え)
    
    for (int bit = 0; bit < (1<<N); ++bit){ //1ならon
      	bool Allon=true;
        for(int i=0; i<M; i++){
            //i行目についての処理
            int on=0;//スイッチonの数
            for(auto x: Switch[i]){ //スイッチの番号を全て列挙
                if(bit & (1<<x)) on++;
            }
          	if(on%2!=p[i]) Allon = false;
        }
      	if(Allon) ans++;
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1LL << 30
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " = " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) cout << x[i][j] << " "; printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define mp make_pair
 
typedef long long int ll;
typedef pair < int, int > ii;
typedef pair < int, ii > iii;


int main()
{
	
	string a, b; cin >> a >> b;
	a+=b;
	ll aux = 0;
	rep(i, 0, a.size()){
		aux*=10;
		aux+=a[i]-'0';
	}	
	
	ll xua = sqrt(aux);
	if(xua*xua==aux) puts("Yes");
	else puts("No");
	
	return 0;	
} 

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vvp G;
vi dp;
int n,m;
bool h=true;
void dfs(int a){
	rep(i,G[a].size()){
		int to=G[a][i].first;
		if(dp[to]==inf){
			dp[to]=dp[a]+G[a][i].second;
			dfs(to);
		}else{
			if(dp[to]-dp[a]!=G[a][i].second)h=false;
		}
	}
}
int main(){
	cin>>n>>m;
	G=vvp(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		G[a].pb({b,c});
		G[b].pb({a,-c});
	}
	dp=vi(n,inf);
	rep(i,n)if(dp[i]==inf){
		dp[i]=0;
		dfs(i);
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}








Measured memory_bytes: 11008
const D = 24;
const L = 3;

function new64(n) {
    return [n % (1<<D), (n / (1<<D)) | 0, 0];
}

function mul64s(a, b) {
    var r = [];
    var x = 0;
    for (var i = 0; i < L; i++) {
        x = a[i] * b + x;
        r[i] = x % (1<<D);
        x = Math.floor(x / (1<<D));
    }
    return r;
}

function add64s(a, b) {
    var r = [];
    var x = b;
    for (var i = 0; i < L; i++) {
        x = a[i] + x;
        r[i] = x % (1<<D);
        x = Math.floor(x / (1<<D));
    }
    return r;
}

function cmp64(a, b) {
    for (var i = L-1; i >= 0; i--) {
        if (a[i] < b[i]) return -1;
        if (a[i] > b[i]) return 1;
    }
    return 0;
}

function add64(a, b) {
    var r = [];
    var x = 0;
    for (var i = 0; i < L; i++) {
        x = a[i] + b[i] + x;
        r[i] = x % (1<<D);
        x = Math.floor(x / (1<<D));
    }
    return r;
}

function sub64(a, b) {
    var r = [];
    var x = 0;
    for (var i = 0; i < L; i++) {
        x = a[i] - b[i] - x;
        var borrow = 0;
        while (x < 0) {
            x += (1<<D);
            borrow++;
        }
        r[i] = x % (1<<D);
        x = borrow;
    }
    return r;
}

function div64s(a, b) {
    var x = 0;
    for (var i = L-1; i >= 0; i--) {
        x = a[i] + x * (1<<D);
        a[i] = (x / b) | 0;
        x = x % b;
    }
    return x;
}

function copy64(a, b) {
    for (var i = 0; i < L; i++) {
        a[i] = b[i];
    }
}

function shiftL64(a) {
    const msb = [0, 0, (1<<(D-1))];
    var d = a;
    var r = 0;
    if (cmp64(a, msb) >= 0) {
        r = 1;
        d = sub64(a, msb);
    }
    var c = add64(d, d);
    copy64(a, c);
    return r;
}

function div64(a, b) {
    var d = new64(0);
    var x = a.slice();
    var r = new64(0);
    for (var i = 0; i < L*D; i++) {
        var bit = shiftL64(x);
        shiftL64(d);
        d = add64s(d, bit);
        var y = 0;
        if (cmp64(d, b) >= 0) {
            d = sub64(d, b);
            y = 1;
        }
        shiftL64(r);
        r = add64s(r, y);
    }
    return r;
}

function parse64(s) {
    const l = s.length;
    var a = new64(0);
    for (var i = 0; i < l; i++) {
        a = mul64s(a, 10);
        a = add64s(a, parseInt(s.substr(i, 1), 10));
    }
    return a;
}

function print64(a) {
    var s = "";
    var x = a.slice();
    while (cmp64(x, new64(0)) !== 0) {
        s += div64s(x, 10);
    }
    if (s === "") {
        s = "0";
    }
    console.log(s.split('').reverse().join(''));
}

function divisors(a, x) {
    return add64s(div64(a, x), 1);
}

function solve(a, b, x) {
    return sub64(divisors(b, x), (cmp64(a, new64(1)) >= 0 ? divisors(sub64(a, new64(1)), x) : new64(0)));
}

function main(input) {
    const args = input.trim().split(' ');
    const a = parse64(args[0]);
    const b = parse64(args[1]);
    const x = parse64(args[2]);
    const c = solve(a, b, x);
    print64(c);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11720
#include<iostream>
#include<stdio.h>
using namespace std;
int n;
int t[11][11];
int main(){
  while(cin>>n){
    if(n==0)break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>t[i][j];
      }
    }
    for(int j=0;j<n;j++){
      t[n][j]=0;
      for(int i=0;i<n;i++){
	t[n][j]+=t[i][j];
      }
    }
    for(int i=0;i<=n;i++){
      t[i][n]=0;
      for(int j=0;j<n;j++){
	t[i][n]+=t[i][j];
      }
    }

    for(int i=0;i<=n;i++){
      
      for(int j=0;j<=n;j++){

	printf("%5d",t[i][j]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int array[] = new int[x];
		for (int i = 0; i < array.length; i++) {
			x = sc.nextInt();
			array[i] = x;
		}
		for (int i = array.length - 1; i >= 0; i--) {
			System.out.print(array[i]);
			if (i != 0) {
				System.out.print(" ");
			}
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  ll N,M,D; cin>>N>>M>>D;
  cout<<setprecision(15);
  if(D==0){
    cout<<1.0*(M-1)/N<<endl;
  }else{
    cout<<2.0*(M-1)*(N-D)/(N*N)<<endl;
  }
  return 0;
}


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

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

	if (a <= b && b <= c ){
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c && c <= b){
		cout << a << " " << c << " " << b << endl;
	}
	else if (b <= a && a <= c){
		cout << b << " " << a << " " << c << endl;
	}
	else if (b <= c && c <= a){
		cout << b << " " << c << " " << a << endl;
	}
	else if (c <= a && a <= b){
		cout << c << " " << a << " " << b << endl;
	}
	else if (c <= b && b <= a){
		cout << c << " " << b << " " << a << endl;
	}


	return 0;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v;
    pair<string, long long> n;
    set<string> y;
    long long a,b,c,d=101,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h[102],p[101];
    string t,s,x;
    double q,u;
    cin>>a>>b;
    for(i=0;i<=101;i++){
        h[i]=0;
    }
    for(i=1;i<=b;i++){
        cin>>p[i];
        h[p[i]]=1;
    }
    d=a;
    e=0;
    for(i=1;i<=101;i++){
        if(h[i]==0){
            if(abs(i-a)<d){
                d=abs(i-a);
                e=i;
            }
        }
    }
    cout<<e;
}

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

int a[100001] = { 0 };

int sort(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int N;
	//int x = 0, y = 0;
	long long int ans, x = 0, y = 0;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	qsort(a, N, sizeof(a[0]), sort);
	//for (int i = 0; i < N; i++) printf("%d\n", a[i]);

	for (int i = N - 1; i > 0; i--) {
		if (a[i] == a[i - 1]) {
			if (x == 0) x = a[i];
			else {
				y = a[i];
				break;
			}
			//printf("%d\n", i);
			i--;
		}
	}

	ans = x*y;
	printf("%lld\n", ans);

	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    int ans = 1;
    int mi = p[0];
    for(int i = 1; i < n; i++){
        if(p[i] <= mi){
            ans++;
            mi = min(mi, p[i]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3988
/* Madar Bozorg migoft : "dorost mishavad"
va hamishe badash b aseman negah mikard o mikhandid
hatm daram k chiz haii ""DARBARE KHODA"" midanest
k ma az an bi khabar budim :) */
//RTn_E
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
#define piii pair < int , pair < int , int > >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 100;
const ll inf = 1e18;

//Main CODE :/\

ll b[maxn];
ll c[maxn];
ll a[maxn];
ll n ;
ll ans;
bool cmp(int i , int j )
{
    return b[i]-a[i]>b[j]-a[j];
}
ll i ;
int main() {
    ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
    cin>>n;
    for(ll y = 0 ; y < n  ; y++)
        cin>>a[y];
    for(ll y = 0 ; y<n ; y++)
        cin>>b[y],c[y]=y;
    sort(c,c+n,cmp);
    for(ll y= 0 ; y < n ; y++)
    {
        if(a[c[y]]-b[c[y]]<0)
            i+=(b[c[y]]-a[c[y]]),ans++;
        else
            break ;
    }

    ll po  = n-1 ;

    while(po>-1&&i>0)
    {
        ans++;
        i-=(a[c[po]]-b[c[po]]);
        po--;
    }
    if(i>0)
        return cout<<-1,0;
    cout<<ans;
    return 0;
}
//The_End
//Game Over :D


Measured memory_bytes: 9216
<?php
fscanf(STDIN, '%d %d %d %d', $x, $y, $z, $k);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$c = array_map('intval', explode(' ', trim(fgets(STDIN))));

rsort($a);
rsort($b);
rsort($c);

$q = new SplPriorityQueue;
$q->insert([$a[0] + $b[0] +$c[0], 0 , 0, 0], $a[0] + $b[0] +$c[0]);
for ($i = 0; $i < $k; $i++) {
    list($max, $ai, $bi, $ci) = $q->extract();
    echo $max . PHP_EOL;
    addQueue($ai + 1, $bi, $ci);
    addQueue($ai, $bi + 1, $ci);
    addQueue($ai, $bi, $ci + 1);
}

function addQueue($ai, $bi, $ci) {
    global $a, $b, $c, $q, $added;

    if (isset($added[$ai][$bi][$ci])) return;
    if (!isset($a[$ai]) || !isset($b[$bi]) || !isset($c[$ci])) return;

    $q->insert([$a[$ai] + $b[$bi] + $c[$ci], $ai, $bi, $ci], $a[$ai] + $b[$bi] + $c[$ci]);
    $added[$ai][$bi][$ci] = true;
}

Measured memory_bytes: 8696
import bisect

n,c,k = list(map(int, input().split()))
t = []
for i in range(n):
	t.append(int(input()))
t.sort()

ans = 0
remain = c-1
if c==1:
	print(n)
	exit()
time = t[0]
for i in range(1,len(t)):
	if time+k<t[i]:
		time = t[i]
		remain = c
		ans+=1
	if remain==0:
		remain=c
		time = t[i]
		ans+=1
	remain-=1

print(ans+1)

Measured memory_bytes: 7512
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int32_t n, m;

    cin >> n >> m;

    vector<vector<int32_t>> A(n, vector<int32_t>(m));
    vector<int32_t> b(m);

    for (int32_t i = 0; i < n; i++) {
        for (int32_t j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int32_t i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int32_t i = 0; i < n; i++) {
        int32_t c_i = 0;

        for (int32_t j = 0; j < m; j++) {
            c_i += A[i][j] * b[j];
        }

        cout << c_i << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

// inline ll gcd(ll a,ll b) {while(b^=a^=b^=a%=b); return b;}
signed main()
{
	ll a,b,c;
	fin>>a>>b>>c;
	b=b*100+c;
	a*=b;
	a/=100;
	fout<<a;
	return 0;
}
// ----------------------------
// by imzzy


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

const string YES = "Yes";

const string NO = "No";

void solve(int A, int B, int C, int K)
{
    int count = 0;
    while (B <= A)
    {
        B *= 2;
        count += 1;
    }
    while (C <= B)
    {
        C *= 2;
        count += 1;
    }
    cout << ((count <= K) ? YES : NO) << endl;
}

int main()
{
    int A;
    cin >> A;
    int B;
    cin >> B;
    int C;
    cin >> C;
    int K;
    cin >> K;
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>

using namespace std;

int main()
{
	int S, h, m, s;
	scanf("%d", &S);

	h = S / 3600;
	S %= 3600;
	m = S / 60;
	S %= 60;
	s = S;

	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2728
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	string s;
	cin >> s;

	if(s.substr(0, 4) == "2017"){
		s[3] = '8';
	}

	cout << s << endl;
}

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

signed main(){
	int k,a[100000],low = 2,up = 2;
	cin >> k;
	for(int i = 0;i < k;i++) cin >> a[i];
	for(int i = k - 1;i >= 0;i--){
		int l = (int)((low + a[i] - 1) / a[i]) * a[i],u = (int)(up / a[i]) * a[i];
		if(l > up){
			cout << -1 << endl;
			return 0;
		}
		low = l;
		up = u + a[i] - 1;
	}
	cout << low << " " << up << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b;
  
  if (a>b) {
    c=a;
    d=a-1;
  } else if (b>a) {
    c=b;
    d=b-1;
  } else {
    c=a;
    d=b;
  }
  cout << c+d;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";



int main(){
    int N,count = 0; cin >> N;
    vint p(N);REP(i,N) cin >> p.at(i);
    vector<int>::iterator itr;
    // ループして入れ替えていく
    REP(i,N/2 + 1){
        if(i+1 != p.at(i)){
            // i+1 の要素をpから探索して添字番号を出力する
            itr = find(p.begin(), p.end(), i+1);
            if((itr - p.begin() + 1) != p.at(i)) { 
                cout << "NO" << endl;
                return 0;
            }else{
                iter_swap(p.begin() + i, p.begin() + (itr - p.begin()));
                count++;
                if(count > 1){
                    cout << "NO" << endl;
                    return 0;
                }
            }

        }

    }


  cout << "YES" << endl;

}

Measured memory_bytes: 256
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
if(k<a) cout<<k<<endl;
else if(k<=a+b) cout<<a<<endl;
else{
	ll val=k-a-b;
	cout<<a-val<<endl;
}


}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
def main(num):
  count = 0
  primes = [3,5,7,11,13]
  
  
  for j in range(1,num+1):
    factors = 1
    primelist =[1,1,1,1,1]
    for i in range(len(primelist)):
      while j%primes[i] == 0:
        primelist[i] += 1
        j = int(j/primes[i])
    for li in primelist:
      factors *= li
    if factors ==8:
      count += 1
      
    
  return count

print(main(int(input())))



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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, m, a, b;
  vector<pair<int, int>> ab;
  int64_t ans = 0;

  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    cin >> a >> b;
    ab.push_back(make_pair(a, b));
  }
  sort(ab.begin(), ab.end());
  for (int i = 0; i < n; i++)
  {
    ans += (int64_t)ab[i].first * min(m, ab[i].second);
    m -= min(m, ab[i].second);
    if (m == 0)
      break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4300
n = int(input())
a = list(map(int,input().split()))
INF = 100100100
aa = [INF for i in range(n)]
q = int(input())
for j in range(q):
  b, m, e = map(int,input().split())
  for i in range(n):
    if b <= i < e  :
      d = b+((i-b+(e-m))%(e-b))
      aa[d] = a[i]
  for k in range(n):
    if aa[k] == INF:
      aa[k] = a[k]
  a = list(aa)
  aa = [INF for i in range(n)]

print(a[0],end="")
for aa in a[1:]:
  print(" {}".format(aa),end="")
print()


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

typedef long long ll;
const ll INF = 1LL  << 50;
int main() {
  int n, m;
  cin >> n >> m;
  int nmax = 1000, mmax = 2000;
  vector<ll> a(m), b(m), c(m);
  for(int i=0;i<m;i++) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }
  vector<ll> dist(n);

  for(int i=0;i<n;i++) {
    dist[i] = INF;
  }
  dist[0] = 0;
  for(int loop=0;loop<n-1;loop++) {
    for(int i=0;i<m;i++) {
      if(dist[a[i]-1] == INF) continue;

      if(dist[b[i]-1] > dist[a[i]-1] + c[i])
        dist[b[i]-1] = dist[a[i]-1] + c[i];
    }
  }

  ll ans = dist[n-1];

  vector<bool> negative(n, false);
  for(int loop=0;loop<n;loop++) {
    for(int i=0;i<m;i++) {
      if(dist[a[i]-1] == INF) continue;
      if(dist[b[i]-1] > dist[a[i]-1]+c[i]) {
        dist[b[i]-1] = dist[a[i]-1] + c[i];
        negative[b[i]-1] = true;
      }

      if(negative[a[i]-1])
        negative[b[i]-1] = true;
    }
  }

  if(negative[n-1])
    cout << "inf" << endl;
  else
    cout << -dist[n-1] << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func median(a []int) int {
	m := len(a)/2 + 1
	return a[m]
}

type BinaryIndexedTree struct {
	data []int
	sz   int
}

func NewBinaryIndexedTree(sz int) *BinaryIndexedTree {
	BIT := &BinaryIndexedTree{}
	BIT.data = make([]int, sz+1)
	BIT.sz = sz
	return BIT
}

func (bit *BinaryIndexedTree) sum(k int) (ret int) {
	for k > 0 {
		ret += bit.data[k]
		k -= k & -k
	}
	return ret
}

func (bit *BinaryIndexedTree) add(k int, x int) {
	for k <= bit.sz {
		bit.data[k] += x
		k += k & -k
	}
}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	N := nextInt()
	a := nextInts(N)
	b := make([]int, N)
	copy(b, a)
	sort.Ints(b)
	ub := N
	lb := 0
	border := ((N * (N + 1) / 2) + 1) / 2
	for ub-lb > 1 {
		mid := (ub + lb) / 2
		midn := b[mid]
		sum := 0
		bit := NewBinaryIndexedTree(2*N + 1)
		bit.add(sum+N, 1)
		result := 0
		for i := 0; i < N; i++ {
			if a[i] >= midn {
				sum += 1
			} else {
				sum -= 1
			}
			result += bit.sum(sum + N)
			bit.add(sum+N, 1)
		}
		if result >= border {
			lb = mid
		} else {
			ub = mid
		}
	}
	fmt.Println(b[lb])
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
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...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int64> a(3);
	REP(i, 3) cin >> a[i];
	sort(all(a));
	if (a[0] == a[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	int n;
	cin >> n >> s;
	int sz = s.size();
	if (n >= sz) cout << s;
	else {
		s = s.substr(0, n);
		cout << s << "...";
	}
	return 0;
}


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

#define debug(x) cout << #x << ": " << (x) << endl

int main(int argc, char *argv[]) {
  int N, T;
  cin >> N >> T;
  int A[N];

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

  set<int> nums;
  map<int, int> diffs;
  for (int i = 0; i < N; ++i) {
    nums.insert(A[i]);
    int diff = A[i] - *nums.begin();
    if (0 < diff)
      ++diffs[diff];
  }

  cout << (diffs.empty() ? 0 : diffs.rbegin()->second) << endl;

  return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
int p[100010],d[100010],c[100010],n,m,q;
int to[200010],nxt[200010],fst[100010],tot;
void add(int u,int v)
{
    to[++tot]=v;
    nxt[tot]=fst[u];
    fst[u]=tot;
}
int a[100010];
bool vis[100010][11];
void color(int p,int d,int c)
{
    if(vis[p][d]||d<0)return;
    vis[p][d]=1;if(!a[p])a[p]=c;
    for(int e=fst[p];e;e=nxt[e])
        color(to[e],d-1,c);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,u,v;i<=m;++i)
    {
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    scanf("%d",&q);
    for(int i=1;i<=q;++i)
        scanf("%d%d%d",&p[i],&d[i],&c[i]);
    for(int i=q;i;--i)color(p[i],d[i],c[i]);
    for(int i=1;i<=n;++i)printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 5248
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

int32_t main(){
      string s;
      cin >>s;
      if(s == "Sunny")
            cout <<"Cloudy";
      else if(s == "Cloudy")
            cout <<"Rainy";
      else
            cout <<"Sunny";
      return false;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

const int INF = 200;
int h[200];
int N;

int count(int l, int r){
    int tmp = INF;
    for(int i=l;i<=r;i++){
        tmp = min(h[i], tmp);
    }
    for(int i=l;i<=r;i++){
        h[i] -=tmp;
    }
    return tmp;
}

bool check(){
    for(int i=1;i<=N;i++){
        if(h[i] !=0) return false;
    }

    return true;
}
int main(void){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> h[i];
    }

    int ans = 0;
    while(!check()){
        for(int l=1;l<=N;l++){
            for(int r=l;r<=N;r++){
                if(h[l-1] == 0 && h[l] != 0){
                    if(h[r] != 0 && h[r+1] == 0){
                        ans += count(l,r);
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char S[3];
  cin >> S;
  if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N + 1);
    A[0] = 0;
    for(int i = 1; i < N+1; i++) cin >> A[i];

    ll sum = 0;
    for(int i = 0; i < N; i++)
    {
        sum += abs(A[i] - A[i+1]);
    }
    sum += abs(A[N] - A[0]);
    for(int i = 1; i < N; i++)
    {
        sum = sum - abs(A[i- 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]);
        cout << sum << endl;
        sum = sum + abs(A[i- 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i - 1] - A[i + 1]);
    }
    sum = sum - abs(A[N] - 0) - abs(A[N - 1] - A[N]) + abs(A[N - 1] - 0);
    cout << sum << endl;
}

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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    int n; cin >> n;
    vector<pair<int, int>> x(n);
    rep(i, n) {cin >> x.at(i).first >> x.at(i).second;}
    sort(all(x), compare_by_b);

    ll s=0;
    rep(i, n) {
        s += x.at(i).first;
        if (s > x.at(i).second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
 
ll n,s,ans=10000000000000ll;
inline bool check(int x)
{
	if(x==1) return 0;
	ll tt=0,ts=n;
	while(ts)
	{
		tt+=ts%x;
		ts/=x;
	}
//	if(x==10) printf("%d\n",tt);
	return tt==s;
}
signed main()
{
	cin >> n >> s;
	if(n==s){printf("%lld\n",n+1); return 0;}
	for(int i=1;i<=sqrt(n);i++)
	{
		if((n-s+i)%i==0&&i*i<n){ if(((n-s+i)/i)) if(n/((n-s+i)/i)==i) ans=min(ans,(n-s+i)/i);}
		if(check(i)) ans=min(ans,(ll)i);	
	}
	if(ans==10000000000000ll) puts("-1");
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> a(N);
    readvec(a);

    int evensum = 0, oddsum = 0;
    vector<int> evenminus(0), oddminus(0);

    for(int i = 0; i < N; i+= 2){
        if(a[i] >= 0){
            evensum += a[i];
        }else{
            evenminus.push_back(i);
        }
    }

    for(int i = 1; i < N; i+= 2){
        if(a[i] >= 0){
            oddsum += a[i];
        }else{
            oddminus.push_back(i);
        }
    }

    if(oddsum == 0 && evensum == 0){
        int maxv = -10000000000000, ind = -1;
        REP(i, N){
            if(a[i] > maxv){
                maxv = a[i];
                ind = i;
            }
        }
        cout << maxv << endl << N - 1 << endl;
        REP(i, ind){
            cout << 1 << endl;
        }
        N -= ind;
        while(N > 1){
            cout << N << endl;
            N--;
        }
        return 0;
    }

    cout << max(evensum, oddsum) << endl;
    vector<int> ans(0);
    if(evensum >= oddsum){
        for(int i = evenminus.size() - 1; i >= 0; i--){
            ans.push_back(evenminus[i]);
            if(evenminus[i] == N - 1) N++;
            N -= 2;
            if(evenminus[i] == 0) ans.push_back(0);
        }
        if(N % 2 == 0){
            ans.push_back(N - 1);
            N--;
        }
        while(N > 1){
            ans.push_back(1);
            N -= 2;
        }
    }else{
        for(int i = oddminus.size() - 1; i >= 0; i--){
            ans.push_back(oddminus[i]);
            if(oddminus[i] == N - 1) N++;
            N -= 2;
        }
        if(N % 2 == 1){
            ans.push_back(N - 1);
            N--;
        }
        ans.push_back(0);
        N--;
        while(N > 1){
            ans.push_back(1);
            N -= 2;
        }
    }

    cout << ans.size() << endl;
    REP(i, ans.size()){
        cout << ans[i] + 1 << endl;
    }

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main(){
    int n; cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
        char ch; cin>>ch;
        a[i] = (ch =='W')?1:0;
    }
    for(int i=0;i<n;i++){
        a[i+1] += a[i];
    }
    int ans = 9999999;
    for(int i=1;i<=n;i++){
        ans = min(ans,a[i-1]+(n-i)-(a[n]-a[i]));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1408
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>n;
		// n=s.length();
		ll a[n];
		rep(i,n)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		k=(n/2);
		c=a[k]-a[k-1];
		
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++){
        x = (i*108)/100;
        if(x==n){
            idx = i;
            break;
        }
    }

    if(idx==-1)cout<<":(\n";
    else cout<<idx<<"\n";


    return 0;
}


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

int main(void){
    using namespace std;
    int n,f=0,s=0,fn=0;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>f){
            s=f;
            f=a;
            fn=i;
        }
        else if(s<a)s=a;
    }
    for(int i=0;i<n;i++)cout<<(i!=fn?f:s)<<endl;
}

Measured memory_bytes: 1664
# 初期入力
N = int(input())
W = list(map(int, input().split()))

#
kotae =100 # 初期値を制限の最大値にする
for i in range(N):
    x =abs(sum(W[:i]) - sum(W[i:]) )
    kotae = min(x,kotae)
print(kotae)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 367
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>w(n);
    REP(i,n){
        IN(w[i]);
    }
    vector<int>sum(n+1,0);
    REP(i,n){
        sum[i+1]=sum[i]+w[i];
    }
    int ans=INF;
    for(int i=1;i<n;i++){
        ans=min(ans,abs(sum[n]-2*sum[i]));
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn 100010
#define INF 1e18
using namespace std;
struct data{int b, l, r;};
int K, n;
ll calc(data x) {return x.r * ((ll)K - x.b) + (ll)x.l * x.b;}
bool cmp(data x, data y) {return calc(x) > calc(y);}
data A[maxn];
ll pre[maxn];
bool check(ll x)
{
	ll mx = -INF, need = 0;
	int able = x / K;
	for (int i = 1; i <= n; i++)
		need -= (ll)A[i].l * A[i].b;
	for (int i = 1; i <= n; i++)
	{
		ll sum = need + x % K * A[i].l;
		if (x % K > A[i].b)
		{
			ll t1 = (x % K - A[i].b) * ((ll)A[i].r - A[i].l);
			sum += t1;
		}
		if (i <= able) sum += pre[able + 1] - calc(A[i]);
		else sum += pre[able];
		mx = max(mx, sum);
	}
	return mx >= 0;
}
int main()
{
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; i++)
		scanf("%d%d%d", &A[i].b, &A[i].l, &A[i].r);
	sort(A + 1, A + n + 1, cmp);
	for (int i = 1; i <= n; i++)
		pre[i] = pre[i - 1] + calc(A[i]);
	ll lef = 0, righ = (ll)n * K - 1, ch = (ll)n * K;
	while (lef <= righ)
	{
		ll mid = (lef + righ) / 2;
		if (check(mid)) {ch = mid; righ = mid - 1;}
		else lef = mid + 1;
	}
	printf("%lld\n", ch);
	return 0;
}

Measured memory_bytes: 2176
def insertion_sort(A ,N, g):
	global cnt
	for i in range(g, N):
		v = A[i]
		j = i - g
		while j>=0 and A[j]>v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
			A[j+g] = v


def shell_sort(A, N):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G


N = int(input())
A = [int(input()) for i in range(N)]

shell_sort(A, N)
print(cnt)
for a in A:
	print(a)



Measured memory_bytes: 45516
n = gets.chomp.to_i
if n <=104
    puts 0
elsif 105 <= n && n <= 134
    puts 1
elsif 135 <= n && n <= 164
    puts 2
elsif 165 <= n && n <= 188
    puts 3
elsif 189 <= n && n <= 194
    puts 4
else
    puts 5
end

Measured memory_bytes: 1788