akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:96777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

struct min_segment_tree{
	int n,seg[1<<19-1];
	void init(int n_){
		n=1;
		while(n<n_)n*=2;
		rep(i,2*n-1)seg[i]=INF;
	}
	void upd(int k,int a){
		k+=n-1;
		seg[k]=a;
		while(k){
			k=(k-1)/2;
			seg[k]=min(seg[k*2+1],seg[k*2+2]);
		}
	}
	int que(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INF;
		if(a<=l&&r<=b)return seg[k];
		else{
			int vl=que(a,b,k*2+1,l,(l+r)/2);
			int vr=que(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
};
struct max_segment_tree{
	int n,seg[1<<19-1];
	void init(int n_){
		n=1;
		while(n<n_)n*=2;
		rep(i,2*n-1)seg[i]=-INF;
	}
	void upd(int k,int a){
		k+=n-1;
		seg[k]=a;
		while(k){
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	int que(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return -INF;
		if(a<=l&&r<=b)return seg[k];
		else{
			int vl=que(a,b,k*2+1,l,(l+r)/2);
			int vr=que(a,b,k*2+2,(l+r)/2,r);
			return max(vl,vr);
		}
	}
};
int a[110];
int main(){
	int n,k;
	cin>>n>>k;
	rep(i,k){
		int x;
		cin>>x;
		rep(j,x){
			int y;
			cin>>y;
			y--;
			a[y]++;
		}
	}
	int cnt=0;
	rep(i,n){
		if(!a[i])cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3632
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
 
int main() {
        string l;
        l = readln().split("\n")[0];
        string res = "";
        foreach(char x; l) res = x ~ res;
        write(res ~ "\n");
        return 0;
}

Measured memory_bytes: 1092
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	while (1) {
		int n; cin >> n;
		if (n == 0)return 0;
		string s, st; vector<string>v; set<string>ss; map<string, int>m; vector<pair<int, string>>v2;
		for (int x = 0; x <= n; x++) {
			getline(cin, s);
			if (x == 0)continue;
			for0(i, s.size()) {
				if (s[i] == ' ') {
					v.push_back(st); st = "";
				}
				else st += s[i];
			}v.push_back(st); st = "";
		}
		char ch; cin >> ch;
		for (string i : v) {
			if (i[0] == ch) {
				if (ss.find(i) == ss.end()) {
					ss.insert(i);
					m[i] = 1;
				}
				else m[i]++;
			}
		}
		for (string i : ss) v2.push_back(make_pair(-m[i], i));
		sort(v2.begin(), v2.end());
		if (v2.size() == 0)cout << "NA";
		else for0(i, min(5, (int)v2.size())) { if (i)cout << ' '; cout << v2[i].second; }
		cout << endl;
	}
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N,K; cin>>N>>K;
    vec A(N); REP(i,N) cin>>A[i];
    int flag;
    REP(i,N){
        if(A[i]==1){ 
            flag = i;
            break;
        }
    }
    int ans = (N-1)/(K-1);
  if((N-1)%(K-1)!=0) ans ++;
    Out(ans);
}




Measured memory_bytes: 1024
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,x;
	cin>>a>>b>>x;
	if(x>=a&&x<=(a+b))
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

using namespace std;

int main(){
    int k,s;
    cin>>k>>s;
    int ans = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - x - y;
            if(z>=0 && z <=k){
                ans+=1;
            }//the remaining number
            //in case of y+x > s , z < 0, so we can differentiate
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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 mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pii> vp;
typedef vector<pdd> vdd;
typedef vector<pair<double,int> >vdi;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vi m(n);
		map<int,int>M;
		vp in(n);
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			m[i]=a;
			M[a]=i;
			in[i]=pii(b,c);
		}
		vvd cost(n,vd(n,inf));
		rep(i,n)rep(j,i){
			double dis=hypot(in[i].first-in[j].first,in[i].second-in[j].second);
			if(dis<EPS+50)cost[i][j]=cost[j][i]=dis;
		}
		int N;
		cin>>N;
		while(N--){
			int a,b;
			cin>>a>>b;
			a=M[a],b=M[b];
			
			vi visit(n);
			vdi d(n,pdi(inf,inf));
			d[a]=pdi(0,0);
			while(1){
				int v=-1;
				rep(i,n)if(visit[i]==0&&(v==-1||d[v].first>d[i].first))v=i;
				if(v==-1)break;
				visit[v]=true;
				rep(i,n)if(d[v].first+cost[v][i]<d[i].first){
					d[i]=pdi(d[v].first+cost[i][v],v);
				}
			}
			if(abs(d[b].first-inf)<EPS)cout<<"NA"<<endl;
			else{
				vi out;
				out.pb(b);
				while(b!=a){
					out.pb(d[b].second);
					b=d[b].second;
				}
				for(int i=out.size()-1;i>=0;i--)
					cout<<m[out[i]]<<(i?" ":"\n");
			}
		}
	}
}

Measured memory_bytes: 1320
#include <stdio.h>
int main(void){

int W,H,x,y,r;

scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0){
    printf("Yes\n");
}else{
    printf("No\n");
}

return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> r(n);

    for (int i=0;i<n;++i){
        cin>>p[i];
    }
    for (int i=0;i<n;++i){
        cin>>q[i];
    }
    for (int i=0;i<n;++i){
        r[i]=i+1;
    }
    long long int a=0;
    long long int b=0;
    int i=0;
    do {
        i++;
        bool p_t=true;
        bool q_t=true;

        for (int j=0;j<n;++j){
            if(p[j]!=r[j]){
                p_t=false;
            }
            if(q[j]!=r[j]){
                q_t=false;
            }
        }
        if(p_t){
            a=i;
        }
        if(q_t){
            b=i;
        }
    }while(next_permutation(r.begin(),r.end()));
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[110];
    int mi=200,mx=-200;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        mx = max(mx,a[i]);
        mi = min(mi,a[i]);
    }
    int num=100000000;
    for(int i=mi;i<=mx;i++){
        int sum=0;
        for(int j=0;j<n;j++)    sum+=(i-a[j])*(i-a[j]);
        num=min(num,sum);
    }
    cout<<num<<endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;
//using mint=ModInt<998244353>;

string X="ACGT";

bool check(string s){
	rep(i,s.size()){
		if(i+1<s.size())swap(s[i],s[i+1]);
		for(int j=0;j+3<=s.size();j++)if(s.substr(j,3)=="AGC")return false;
		if(i+1<s.size())swap(s[i],s[i+1]);
	}
	return true;
}

signed main(){
	int N;cin>>N;

	map<string,mint>dp;
	rep(i,4)rep(j,4)rep(k,4){
		string s=string()+X[i]+X[j]+X[k];
		if(!check(s))continue;
		dp[s]=1;
	}

	rep(t,N-3){
		map<string,mint>nex;
		for(auto &pr:dp){
			string s;
			mint w;
			tie(s,w)=pr;
			rep(i,4){
				string ss=s+X[i];
				if(!check(ss))continue;
				ss=ss.substr(1);
				nex[ss]+=w;
			}
		}
		dp=nex;
	}
	mint ans=0;
	for(auto &pr:dp)ans+=pr.se;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	m := 120
	ns := make([]int, m)
	n5s := make(map[int]int)
	for i := 0; i < m; i++ {
		n := i * i * i * i * i
		ns[i] = n
		n5s[n] = i
	}

	result1 := 0
	result2 := 0

	for i := range ns {
		b := ns[i]
		if a, ok := n5s[b+x]; ok {
			result1, result2 = a, i
			break
		}
		if a, ok := n5s[x-b]; ok {
			result1, result2 = i, -a
			break
		}
	}

	fmt.Println(result1, result2)

}


Measured memory_bytes: 1852
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    ll ans=0;
    ll cur=a[0];
    rep(i,n){
        if(a[i]<cur){
            ans+=cur-a[i];
        }else cur=a[i];
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 4748
use std::vec::Vec;

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, k) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    let mut ab = Vec::new();
    for _ in 0..n {
        let v: Vec<usize> = read_vec();
        ab.push((v[0], v[1]));
    }

    ab.sort_by(|a, b| a.0.cmp(&b.0));

    let mut count = k;
    for (a, b) in ab {
        if b < count {
           count -= b;
        } else {
            println!("{}", a);
            return
        }
    }
}


Measured memory_bytes: 6396
k,n = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
m = a[n-1] - a[0]
for i in range(1,n):
  ans = 0
  ans = k-a[i]+a[i-1]
  m = min(ans,m)
print(m)

Measured memory_bytes: 32372
def main():
    s = input()
    k = int(input())
    # あたまに '1' が並んでいるケース
    ss = ''
    for w in s:
        if w == '1':
            ss += w
        else:
            break
    if len(ss) >= k:
        print(1)
        return
    for w in s:
        if w != '1':
            print(w)
            break



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
typedef long long ll;
ll longinf=1ll<<60;

int a,b;
int main(){
    cin>>a>>b;
    if(a+b==15) cout<<"+"<<endl;
    else if(a*b==15) cout<<"*"<<endl;
    else cout<<"x"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define rep(i,a,b) for(lli i=a;i<b;i++)
	#define repe(i,a,b) for(int i=a;i<=b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define pie  acosl(-1.0);
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}
	struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

//////////////////////////////////////////////////////////////////////////////////////////////
void solve();
//////////////////////////////////////////////////////////////////////////////////////////////

int main ()
{
	// fastio
 	//lli  t;
// 	cin>>t;
 //	while(t--)
 	{
	solve();

 	}
}
///////////////////////////////////////////
void solve()
{
	lli n,i,d,a,b,c,j,k;
  cin>>n>>k;

  lli wt[n+1],val[n+1],W;
  rep(i,1,n+1)cin>>wt[i];
	lli dp[n+k];
	for(i=0;i<=n;i++)
	{
		dp[i]=inf;
	}
	dp[0]=dp[1]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=k;j++)
		{
			dp[i+j]=min(abs(wt[i+j]-wt[i])+dp[i],dp[i+j]);
		}
	}

	cout<<dp[n]<<"\n";







}


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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int kaibun(string x){
  
  int size = x.size();
  int flag = 1;
  
  for ( int i = 0; i < size/2; i++){
    if ( x[i] != x[size-1-i] ){
      flag = 0;
    }
  }
  
  return flag;
  
}
      

int main() {
  
  string s,t,u;
  cin >> s;
  
  int stp1 = 1,stp2 = 1,stp3 = 1;
  
  stp1 = kaibun(s);
  
  for ( int i = 0; i < ((s.size()-1) / 2);i++){
    t += s[i];
  }
  
  stp2 = kaibun(t);
  
  for ( int i = ((s.size()+3)/2)-1; i < s.size();i++){
    u += s[i];
  }
  
  stp3 = kaibun(u);
  
  if ( stp1 == 1 && stp2 == 1 && stp3 == 1 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
			inv[i]=ppow(fact[i],MOD-2);
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};

int main(){
	Fact fac(100000);
	int n,a,b,c;cin>>n>>a>>b>>c;
	ll A=a*ppow(a+b,MOD-2)%MOD;
	ll B=b*ppow(a+b,MOD-2)%MOD;
	ll p=0;
	for(int i=0;i<n;i++){
		p+=(i+n)*fac.nCr(n+i-1,i)%MOD*ppow(A,i)%MOD*ppow(B,n)%MOD;
		p+=(i+n)*fac.nCr(n+i-1,i)%MOD*ppow(B,i)%MOD*ppow(A,n)%MOD;
		p%=MOD;
	}
	if(c){
		ll C=(100-c)*ppow(100,MOD-2)%MOD;
		(p*=ppow(C,MOD-2))%=MOD;
	}
	cout<<p<<endl;
}

Measured memory_bytes: 3328
#include<string>
#include<iostream>
 
using namespace std;
int main(){
  string S,T;
  int ans;
  cin>>S;
  cin>>T;
  for(int i=0;i!=3;i++){
    if(S[i] == T[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i, n) cin >> vec[i];
  sort(all(vec));
  if(n % 2 != 0){
    ll ans1 = 0, ans2= 0;
    for(int i=0;i<n/2; i++) ans1 -= 2*vec[i];
    ans1 += vec[n/2]+vec[n/2+1];
    for(int i=n/2+2;i<n; i++) ans1 += 2*vec[i];
    for(int i=0;i<n/2-1; i++) ans2 -= 2*vec[i];
    ans2 -= vec[n/2-1]+vec[n/2];
    for(int i=n/2+1;i<n; i++) ans2 += 2*vec[i];
    cout << max(ans1, ans2) << endl;
  }else{
    ll ans = 0;
    for(int i=0; i<n/2-1; i++) ans -= 2*vec[i];
    for(int i=n/2+1; i<n; i++) ans += 2*vec[i];
    ans += vec[n/2]-vec[n/2-1];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s;
  cin>>s;
  int result=0;
  if(s.size()==1){
    result=1;
  }else if(s.size()==2){
    if(s[0]==s[1]){
      result=1;
    }else{
      result=2;
    }
  }else{
    bool prev_single=true;
    char prev=s[0];
    int itr=1;
    result=1;
    while(true){
      if(itr>=s.size()) break;
      if(prev_single){
        if(prev==s[itr]){
          if(itr==s.size()-1){
            break;
          }
          prev_single=false;
          itr+=2;
          result++;
        }else{
          prev=s[itr];
          result++;
          itr++;
        }
      }else{
        prev_single=true;
        prev=s[itr];
        result++;
        itr++;
      }
    }


  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 720
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

dl = raw_input()
dl = dl.split()
dl = map(int,dl)
dl.sort()

m = raw_input()
m = int(m)

tl = raw_input()
tl = tl.split()
tl = map(int,tl)
tl.sort()

status = 0
i = 0
j = 0
while j < m:
    d = dl[i]
    t = tl[j]
    #print d,t
    if d > t:
        status = 1
        break
    elif d == t:
        i += 1
        j += 1
    else:
        i += 1

if status == 0:
    print "YES"
else:
    print "NO"


Measured memory_bytes: 26564
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;
bool eq(double a, double b)
{
	return abs(a - b) < Eps;
}

using namespace std;

int main()
{
	int Size[] = { 60, 80, 100, 120, 140, 160, 100000 };
	int Weight[] = { 2, 5, 10, 15, 20, 25, 100000 };
	int Fee[] = { 600, 800, 1000, 1200, 1400, 1600, 0 };

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		while (n--)
		{
			int x, y, h, w;
			scanf("%d %d %d %d", &x, &y, &h, &w);
			int i;
			int s = x + y + h;
			for (i = 0; s > Size[i] || w > Weight[i]; ++i)
				;
			ans += Fee[i];
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[int(i) for i in input().split()]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

left=[0]*n
right=[0]*n
for i in range(1,n):
    left[i]=gcd(left[i-1],a[i-1])
    right[n-i-1]=gcd(right[n-i],a[n-i])

ans=0
for i,j in zip(left,right):
    ans=max(ans,gcd(i,j))
print(ans)

Measured memory_bytes: 14052
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
const int N=2e5+7;
int n,p[N],f[2][N][20],Log[N],pos[N]; 
inline int ask(int opt,int l,int r)
{
	int k=Log[r-l+1];
	return min(f[opt][l][k],f[opt][r-(1<<k)+1][k]);
}
inline pair<int,int> cal(int l,int r)
{
	int x,y;
	x=ask(l&1,l,r);
	y=ask((l-1)&1,pos[x]+1,r);
	return make_pair(-x,-y);
}
priority_queue<pair<pair<int,int>,pair<int,int > > > q;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d",&n);
  for(int i=1;i<=n;i++) 
  {
  	scanf("%d",&p[i]);
  	f[i&1][i][0]=p[i];
  	f[(i-1)&1][i][0]=1e9+7;
  	pos[p[i]]=i;
  }
  Log[1]=0;
  for(int i=2;i<=N-7;i++)
    Log[i]=Log[i>>1]+1;
  for(int k=0;k<=1;k++)//奇or偶
    for(int j=1;j<=19;j++)
	  for(int i=1;i+(1<<j)-1<=n;i++)
	    f[k][i][j]=min(f[k][i][j-1],f[k][i+(1<<(j-1))][j-1]);
  q.push({{cal(1,n)},{1,n}}); 
  while(q.size())
  {
  	pair<pair<int,int>,pair<int,int> > tmp=q.top(); q.pop(); //cout<<tmp.second.first<<endl;
  	int x=tmp.first.first,y=tmp.first.second; 
  	printf("%d %d ",-x,-y);
  	x=pos[-x],y=pos[-y];
  	int l=tmp.second.first,r=tmp.second.second; 
  	//cout<<l<<" "<<r<<" "<<x<<" "<<y<<endl;
  	if(l+1<x) q.push({{cal(l,x-1)},{l,x-1}});
  	if(x+1<y-1) q.push({{cal(x+1,y-1)},{x+1,y-1}});
  	if(y+1<r) q.push({{cal(y+1,r)},{y+1,r}});
  }
  return 0;
}


Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
#define pie 3.1415926
int ara[200020],ara2[200020];
int main()
{
  long long n,sum=0,k;
  cin>>n>>k;
  while(k--)
  {
    long long x;
    cin>>x;sum+=x;
  }
  if(sum>n) cout<<-1<<endl;
  else cout<<n-sum<<endl;


    return 0;
}


Measured memory_bytes: 3580
def getContinueRainDay(weathers):
  maxChainNum = 0
  nowChainNum = 0
  preDayRain = True

  for weather in list(weathers):
    if weather == "S":
      maxChainNum = nowChainNum if maxChainNum < nowChainNum else maxChainNum
      nowChainNum = 0
      preDayRain = False
    else:
      nowChainNum = nowChainNum+1 if preDayRain else 1
      preDayRain = True
  
  maxChainNum = nowChainNum if maxChainNum < nowChainNum else maxChainNum

  return maxChainNum

if __name__ == "__main__":
  S = input()
  print (getContinueRainDay(S))

Measured memory_bytes: 9140
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,f,x,ans;
	char s[35],k[]="yuiophjklnm";
	while(1){
		scanf("%s",s);
		if(strcmp(s,"#")==0)break;ans=0;
		for(i=0;i<strlen(s);i++){
			f=0;
			for(j=0;j<strlen(k);j++){
				if(s[i]==k[j]){f=1;break;}
			}
			if(!i)x=f;
			else{
				if(f!=x)ans++;
				x=f;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<ll,ll> tb;
int main(){
    ll n,k,a,b;
    cin>>n>>k;
    rep(i,n){
        cin>>a>>b;
        tb[a]+=b;
    }
    ll cnt=0;
    for(map<ll,ll>::iterator it=tb.begin();it!=tb.end();++it){
        cnt+=it->second;
        if(cnt>=k){
            cout<<it->first<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int h, w;
  cin >> h >> w;
  string grid[h];
  vector<bool> t(h, false);
  vector<bool> y(w, false);
  for(int i = 0; i < h; i++) cin >> grid[i];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(grid[i][j] == '#'){
        t[i] = true; y[j] = true;
      }
    }
  }
  for(int i = 0; i < h; i++){
    if(!t[i]) continue;
    for(int j = 0; j < w; j++){
      if(y[j]) cout << grid[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	long long k;
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	cin>>k;
	if(k&1){
		cout<<b-a;
	}
	else{
		cout<<a-b;
	}
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
ans = 12*(10**5)+1
C = []
A = []

for _ in range(n):
    AC = list(map(int,input().split()))
    C.append(AC[0])
    A.append(AC[1:])

for i in range(2**n):
    understood = [0]*m
    cost = 0
    
    for j in range(n):
        if (i>>j)&1:
            cost += C[j]
            
            for k in range(m):
                understood[k] += A[j][k]
            
    if min(understood) >= x:
        ans = min(ans,cost)

if ans == 12*(10**5)+1:
    ans = -1
        
print(ans)

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

using namespace std;

typedef long long int lo;
typedef pair<int,int> PII;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR for(int i=1;i<=  n;i++)
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mid (start+end)/2

const lo mod = 1000000007;
const lo li = 100005;
const lo inf = 1000000000;
const lo MAX = 1000000000000000000;
const lo MIN = -1000000000000000000;
const lo LOG = 30;

int n,m,cev,k,z;

int main(){
	scanf("%d %d %d %d",&n,&k,&m,&z);
	if(k==1 || n==1 || m==1 || z==1) cev++;
	if(k==9 || n==9 || m==9 || z==9) cev++;
	if(k==7 || n==7 || m==7 || z==7) cev++;
	if(k==4 || n==4 || m==4 || z==4) cev++;
	if(cev==4){printf("YES\n");return 0;}
	printf("NO\n");
	return 0;
}


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

int N, M, a[103];
bool success;

int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < 100; i++) {
		a[i] = -1;
	}
	success = true;
	for (int i = 0; i < M; i++) {
		int s, c;
		scanf("%d %d", &s, &c);
		if (a[s] == -1) {
			a[s] = c;
		} else {
			if (a[s] != c) {
				success = false;
			}
		}
	}
	if (N == 1 && M == 0) {
		printf("0\n");
		return 0;
	}
	if (!success || (a[1] == 0 && N != 1)) {
		printf("-1\n");
	} else {
		if (a[1] == -1) {
			a[1] = 1;
		}
		if (a[2] == -1) {
			a[2] = 0;
		}
		if (a[3] == -1) {
			a[3] = 0;
		}
		for (int i = 1; i <= N; i++) {
			printf("%d", a[i]);
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;


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

  for (char c:t) {
    if (s.find(c)==string::npos) {
      OUT(-1);
      return 0;
    }
  }

  vector<vector<int>> pos(26);
  REP(i,siz(s)) {
    char c = s[i];
    pos[c-'a'].push_back(i);
  }

  ll ans = 0;
  int tmp = 0;

  REP(i,siz(t)) {
    int tchar = t[i]-'a';
    auto it = lower_bound(ALL(pos[tchar]),tmp);
    // 一周して戻ってくる
    if (it==pos[tchar].end()) {
      ans += (pos[tchar].front()+1)+(siz(s)-tmp);
      tmp = (pos[tchar].front()+1)%siz(s);
    } else {
      ans += *it-tmp+1;
      tmp = (*it+1)%siz(s);
    }
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
    int A, B, C, D, E, F;
    double mx = -1;
    int max_ws = 0,max_su = 0;
    cin >> A >> B >> C >> D >> E >> F;
    //a,b,c,dは操作1,2,3,4の回数
    for (int a = 0; 100*A*a<=F; ++a) {
        for (int b = 0; 100*B*b<=F; ++b) {
            int s = (A*a + B * b)*E;//水に溶ける砂糖の最大値
            for (int c = 0; C*c<=s; ++c) {
                for (int d = 0; D*d<=s; ++d) {
                    int su = C * c + D * d;//砂糖の量
                    int ws = 100 * A*a + 100 * B*b + su;//全体量
                    if (su > s)continue;
                    if (ws > F)continue;
                    if (mx < 100 * su / (double)ws) {
                        mx = 100 * su / (double)ws;
                        max_ws = ws;
                        max_su = su;
                    }
                }
            }
        }
    }
    cout << max_ws << " " << max_su << endl;
    return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env -S JULIA_VERSION=1.4.0 julia
# contest: abc167, problem: abc167_d, alphabet: D

function solve(N::Int, K::Int, A::Vector{Int})
  hist = zeros(Int, N+10)
  hist[0+1] = 1
  dic = Dict(1=>0)
  k = 1
  p = A[1]
  while k < K
    k0 = get!(dic, p, k)
    if k0 < k
      p0 = hist[k0+1]
      m = k - k0
      kK = k0 + (K - k0) % m
      println(hist[kK + 1])
      return
    end
    hist[k+1] = p
    p = A[p]
    k += 1
  end
  println(p)
end

function main()
  tokens = Channel{String}(32)
  Task() do
    for line in eachline(@static VERSION < v"0.6" ? STDIN : stdin)
      startswith(line, '\0') && break
      for token in split(chomp(line))
        put!(tokens, token)
      end
    end
    close(tokens)
  end |> schedule
  N = parse(Int, take!(tokens))
  K = parse(Int, take!(tokens))
  A = similar(Vector{Int}, N)
  for i in 1:N
    A[i] = parse(Int, take!(tokens))
  end
  solve(N, K, A)
end

if isempty(get(ENV, "ATCODER_LOCAL", ""))
  isempty(ARGS) && main()
else
  @eval begin
    const samples = [("4 5\n3 2 4 1", "4"), ("6 727202214173249351\n6 5 2 5 3 2", "2")]
    function test(sampleids...)
      isempty(sampleids) && return test(collect(1:length(samples))...)
      ostdin, ostdout = @static VERSION < v"0.6" ? (STDIN, STDOUT) : (stdin, stdout)
      rd, wr = first(redirect_stdout()), last(redirect_stdin())
      try
        map(sampleids) do sampleid
          input, output = samples[sampleid]
          print(ostdout, "Testing sample #$(sampleid)..."); flush(ostdout)
          println(wr, input)
          println(wr, "\0")
          t = @elapsed main()
          println()
          result = strip(String(readavailable(rd)))
          if result == output
            println(ostdout, "OK ($t sec).")
            true
          else
            println(ostdout, "ERROR ($t sec)")
            println(ostdout, "== expected ==\n$output")
            println(ostdout, "== actual ==\n$result\n")
            false
          end
        end |> all
      finally
        redirect_stdin(ostdin)
        redirect_stdout(ostdout)
      end
    end
    submit() = test() && (prog = @__FILE__; run(`atcoder-submit $prog`))
    !isinteractive() && submit()
  end
end


Measured memory_bytes: 214768
#include<stdio.h>

int main(void){
	int N,i=0,j;
	int a[100];

	scanf("%d",&N);

	while(1){
		if(N%2 != 0 && N<0){
			a[i++]=1;
			N=N/(-2)+1;
		}
		else if(N%2 != 0){
			a[i++]=1;
			N=N/(-2);
		}
		else {
			a[i++]=0;
			N=N/(-2);
		}
		if(N==0){
			break;
		}
	}
	for(j=i-1;j>=0;j--)
		printf("%d",a[j]);
	printf("\n");

	return 0;
}

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

void dijk(int s, vector<vector<pair<int,int>>> &E, vector<long long> &D)
{
    int N=D.size(),vis[N];
    for (int i = 0; i < N; ++i)
    {
        D[i]=10000000000000000LL;
    }
    for (int i = 0; i < N; ++i)
    {
        vis[i]=0;
    }
 
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
 
    D[s] = 0;
    que.push({ 0, s });
 
    while (!que.empty()) 
    {
        auto q = que.top(); que.pop();
 
        long long cst = q.first;
        int cu = q.second;
 
        if (vis[cu]) continue;
        vis[cu] = 1;
 
        for(auto &p:E[cu]) 
        {
            long long cst2 = cst + p.second;
            int to = p.first;
 
            if (D[to]>cst2)
            {
                D[to]=cst2;
                que.push({D[to],to});
            }
        }
    }
}

int main(int argc, char const *argv[])
{
	int n,m,s,t;
	cin>>n>>m>>s>>t;--s;--t;
	vector<vector<pair<int,int>>> edge1(n),edge2(n);
	int u,v,a,b;
	for (int i = 0; i < m; ++i)
	{
		cin>>u>>v>>a>>b;--u;--v;
		edge1[u].push_back({v,a});
		edge1[v].push_back({u,a});
		edge2[u].push_back({v,b});
		edge2[v].push_back({u,b});
	}
	vector<long long> d1(n),d2(n);
	dijk(s,edge1,d1);
	dijk(t,edge2,d2);
	long long ans[n];
	ans[n-1]=d1[n-1]+d2[n-1];
	for (int i = n-2; i >= 0; --i)
	{
		ans[i]=min(ans[i+1],d1[i]+d2[i]);
	}
	for (int i = 0; i < n; ++i)
	{
		cout<<1000000000000000-ans[i]<<endl;
	}
	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, D[55];
bool visited[24];

int Solve(int num){
  int ans = 24;
  for (int i = 0; i < 24; i++){
    if (!visited[i]) continue;
    ans = min(ans, min(abs(i-num), 24-abs(i-num)));
  }
  return ans;
}

int main(){
  visited[0] = true;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> D[i];
  sort(D, D + N);

  for (int i = 0; i < N; i++){
    if (D[i] == 0){
      cout << 0 << endl;
      return 0;
    }
    if (visited[D[i]] && visited[24-D[i]]){
      cout << 0 << endl;
      return 0;
    }
    if (!visited[D[i]] && !visited[24-D[i]]){
      if (Solve(D[i]) >= Solve(24-D[i])){
        visited[D[i]] = true;
      }else{
        visited[24-D[i]] = true;
      }
    }else{
      visited[D[i]] = true;
      visited[24-D[i]] = true;
    }
  }

  int ans = 24;
  for (int i = 0; i < 24; i++){
    if (!visited[i]) continue;
    for (int j = 0; j < 24; j++){
      if (i == j) continue;
      if (!visited[j]) continue;
      ans = min(ans, min(abs(i-j), 24-abs(i-j)));
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int K;
  cin>>K;
  vector<int64_t> p={1,2,3,4,5,6,7,8,9};
  for(int i=0;i<100000;i++){
    if(p.at(i)%10==0){
      p.push_back(p.at(i)*10);
      p.push_back(p.at(i)*10+1);
    }
    else if(p.at(i)%10==9){
      p.push_back(p.at(i)*10+8);
      p.push_back(p.at(i)*10+9);
    }
    else{
      p.push_back(p.at(i)*10+p.at(i)%10-1);
      p.push_back(p.at(i)*10+p.at(i)%10);
      p.push_back(p.at(i)*10+p.at(i)%10+1);
    }
  
    if(p.size()>100000){
      break;
    }
  }
    cout<<p.at(K-1)<<endl;
}

Measured memory_bytes: 1464
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,ma,mb = li()
drugs = []
for _ in range(n):
    drugs.append(tuple(li()))
    
dp = [[[10**10]*(401) for _ in range(401)] for _ in range(n+1)]
dp[0][0][0] = 0

for i in range(n):
    ca, cb, cc = drugs[i]
    for aa in range(401):
        for bb in range(401):
            if 0 <= aa - ca <= 400 and 0 <= bb - cb <= 400:
                dp[i+1][aa][bb] = min(dp[i][aa-ca][bb-cb] + cc,
                                      dp[i][aa][bb])
                
            else:
                dp[i+1][aa][bb] = dp[i][aa][bb]

ans = 10**10     
for aa in range(1,401):
    for bb in range(1,401):
        if (aa/bb) == (ma/mb):
            ans = min(ans, dp[n][aa][bb])
            
if ans == 10**10:
    print(-1)
else:
    print(ans)

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

void solve(int tc) {
    string s;
    cin >> s;

    int ans = 0;
    for (char c : s) {
        ans += c - '0';
    }

    cout << (ans % 9 ? "No" : "Yes");
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) solve(tc);
}


Measured memory_bytes: 3708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {

			long n = sc.nextLong();
			long[] map = new long[5];
			for(int i=0; i<5; i++) {
				map[i] = sc.nextLong();
			}
			long max = 0;
			long ans = 0;
			for(int i=0; i<5; i++) {
				long now = n/map[i] + ((n%map[i]>0)? 1:0);
				ans += (now>max)? now - max : 0;
				max = Math.max(now, max);
			}
			System.out.println(ans+4);
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int n;
	
	cin >> n;
	
	cout << (double)(n/2+n%2)/n << endl;
	
	return 0;
}

Measured memory_bytes: 256