akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll k, n;
    cin >> k >> n;
    ll a[n];
    ll s = 0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    vector<ll> t;
    for(ll i=0;i<n;i++){
        if(i == 0){
            s+=(a[0] + k - a[n-1])%k;
            t.push_back((a[0] + k - a[n-1])%k);
        }
        else{
            s+=(a[i] - a[i-1] + k)%k;
            t.push_back((a[i] - a[i-1] + k)%k);
        }
    }
    // t.push_back((a[i] - a[i-1] + k)%k);
    sort(t.begin(), t.end(), greater<ll>());
    // for(ll i=0;i<t.size();i++){
    //     cout << t[i] << "\n";
    // }
    // cout << t[0] << "\n";
    cout << s - t[0] << "\n";

    return 0;
}

Measured memory_bytes: 3956
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

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

void solve(int TEST_CASE){
    int n;
    cin >> n;
    int a[n];
    fr(i,n) cin >> a[i];
    int mx=a[0], cnt=1;
    frA(i,1,n-1){
        if(mx<=a[i]) cnt++;
        mx = max(mx, a[i]);
    }
    cout << cnt;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/data/arc/059/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
LL dp[404][404];
LL a[404], b[404], abPow[404][404], cPow[404][404];

int main(){
    
    // 1. 入力情報.
    int N, C;
    scanf("%d %d", &N, &C);
    rep(i, N) scanf("%lld", &a[i]);
    rep(i, N) scanf("%lld", &b[i]);
    
    // 2. 冪乗 を 保存.
    rep(i, 404) abPow[i][0] = 1;
    repx(i, 1, 403){
        rep(k, 403){
            abPow[i][k + 1] = abPow[i][k] * (LL)i;
            abPow[i][k + 1] %= MOD;
        }
    }
    
    // 3. 累積和 を 保存.
    rep(k, 403) rep(i, 403) cPow[i][k] = abPow[i][k];
    rep(k, 403){
        rep(i, 403){
            cPow[i + 1][k] += cPow[i][k];
            cPow[i + 1][k] %= MOD;
        }
    }
    // rep(k, C + 1){
    //     rep(i, N + 1) printf("k=%d i=%d %lld ", k, i, cPow[i][k]);
    //     puts("");
    // }
    
    // 4. dp更新.
    dp[0][0] = 1;
    rep(i, N + 1){
        rep(j, C + 1){
            rep(k, j + 1){
                dp[i + 1][j] += dp[i][j - k] * (cPow[b[i]][k] + MOD - cPow[a[i] - 1][k]);
                dp[i + 1][j] %= MOD;
            }
        }
    }
    
    // 5. 出力.
    printf("%lld\n", dp[N][C]);
    return 0;
    
}

Measured memory_bytes: 7640
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
s = str(input())
dp = [[0] * 13 for i in range(len(s)+1)]
dp[0][0] = 1
Naoppy = 1
mod = 13
ansmod = 10 ** 9 + 7
ans = 0
for i in range(len(s)):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k * 10 +j)%mod] += dp[i][k]
    else:
        for k in range(13):
            dp[i+1][(k * 10 + (int(s[i])))%mod] += dp[i][k]
    for j in range(13):
        dp[i+1][j] %= ansmod
  #    print(dp)
print(dp[len(s)][5])

Measured memory_bytes: 61788
s = str(input())

ans = 0
for i in range(2 ** (len(s)-1)):
    plus_l = []
    cal_l = []
    for j in range(len(s)):
        bit = 2 ** j
        if i & bit > 0:
            plus_l.append(j)
    if len(plus_l) == 0:
        cal_l = [int(s)]
    else:
        pre = 0
        for k in plus_l:
            cal_l.append(int(s[pre:k+1]))
            pre = k+1
        cal_l.append(int(s[pre:]))
    ans += sum(cal_l)

print(ans)




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

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m;

int main(){
	Init();
	cin>>n>>m;
	vi a(n+m+1);
	for(int i=0;i<n;i++) a[i+m+1]=Div(nCk(m+i-1,i),Pow(2,m+i));
	for(int i=1;i<=n+m;i++) (a[i]+=a[i-1])%=mod;
	ll S=1,L=0,R=0;
	for(int i=0;i<n+m-1;i++){
		(a[i+1]+=Div((S-L-R+2*mod)%mod,Pow(2,i+1)))%=mod;
		(S*=2)%=mod;
		(L*=2)%=mod;
		(R*=2)%=mod;
		if(i>=n-1) (L+=nCk(i,i-n+1))%=mod;
		if(i>=m-1) (R+=nCk(i,m-1))%=mod;
	}
	for(int i=1;i<=n+m;i++) cout<<a[i]<<endl;
}

Measured memory_bytes: 4480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      String[] s = new String[q+q];
      Arrays.fill(s, "");
      List<String> list  = Arrays.asList(s);
      int head = q;
      int tail = q;

      String[] query;
      int op;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            if ( Integer.parseInt(query[1]) == 0 )
              list.set(head--,query[2]);
            else
              list.set(++tail,query[2]);
            break;
          case 1 :
            System.out.println( list.get(head+1 + Integer.parseInt(query[1])) );
            break;
          case 2 :
            if ( Integer.parseInt(query[1]) == 0 )
              head++; // list.set(head++,"");
            else
              tail--; // list.set(tail--,"");
            break;
          default:
        }
      }
    }
  }
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename T >
int64_t largest_rectangle(vector< T > height) {
  stack< int > st;
  height.push_back(0);
  vector< int > left(height.size());
  int64_t ret = 0;
  for(int i = 0; i < height.size(); i++) {
    while(!st.empty() && height[st.top()] >= height[i]) {
      ret = max(ret, (int64_t) (i - left[st.top()] - 1) * height[st.top()]);
      st.pop();
    }
    left[i] = st.empty() ? -1 : st.top();
    st.emplace(i);
  }
  return (ret);
}

int main() {
  int N;
  cin >> N;
  vector< int > h(N);
  cin >> h;
  cout << largest_rectangle(h) << endl;
}




Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> cum(n);
    rep(i,n){
        if(i==0) cum[i]=a[i];
        else cum[i]=cum[i-1]+a[i];
    }
    ll res=1e17;
    for(ll M=1; M<n-2; M++){ //a[0]...a[M] / a[M+1]...a[n-1]
        ll p,q,r,s;
        ll left=0, right=M-1;
        while(right-left>1){
            //a[0]...a[mid] / a[mid+1]...a[M]
            //cum[mid] / cum[M]-cum[mid]
            //-mid ~ cum[M]-cum[mid]*2
            ll mid=(left+right)/2;
            if(cum[M]-2*cum[mid]>0) left=mid;
            else right=mid;
        }
        if(abs(cum[M]-2*cum[left]) < abs(cum[M]-2*cum[right])){
            p=cum[left]; q=cum[M]-cum[left];
        }else{
            p=cum[right]; q=cum[M]-cum[right];
        }
        
        left=M+1, right=n-2;
        while(right-left>1){
            //a[M+1]...a[mid] / a[mid+1]...a[n-1]
            //cum[mid]-cum[M+1] / cum[n-1]-cum[mid]
            //-mid ~ cum[n-1]-2*cum[mid]+cum[M+1]
            ll mid=(left+right)/2;
            if(cum[n-1]-2*cum[mid]+cum[M]>0) left=mid;
            else right=mid;
        }
        if(abs(cum[n-1]-2*cum[left]+cum[M]) < abs(cum[n-1]-2*cum[right]+cum[M])){
            r=cum[left]-cum[M]; s=cum[n-1]-cum[left];
        }else{
            r=cum[right]-cum[M]; s=cum[n-1]-cum[right];
        }

        vector<ll> V={p,q,r,s};
        sort(V.begin(), V.end());
        chmin(res, V[3]-V[0]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_mod_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_mod_combination() {}
	fast_mod_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value);
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0 || n < r) return 0;
		if (n == r || r == 0) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_mod_combination<long long> fmc(N, MOD);
//long long result = fmc.process(n, r);

fast_mod_combination<long long> fmc;

const int MAX = 2e5 + 1;
const long long MOD = 1e9 + 7;

int N;

vector<vector<int>> adj;
vector<int> subsize;

vector<long long> dp;
vector<long long> result;

void dfs_size(int curr, int prev)
{
	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dfs_size(next, curr);

		subsize[curr] += subsize[next];
	}

	subsize[curr]++;

	dp[curr] = fmc.fact[subsize[curr] - 1];
	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dp[curr] = (dp[curr] * dp[next]) % MOD * fmc.fact_inv[subsize[next]] % MOD;
	}
}

void dfs_rerooting(int curr, int prev)
{
	if (prev == -1)
		result[curr] = dp[curr];
	else
		result[curr] = (result[prev] * fmc.fact[subsize[curr]] % MOD * fmc.fact_inv[subsize[curr] - 1] % MOD * fmc.fact[N - 1 - subsize[curr]] % MOD * fmc.fact_inv[(N - subsize[curr])]) % MOD;

	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dfs_rerooting(next, curr);
	}
}

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

	fmc = fast_mod_combination<long long>(MAX, MOD);

	cin >> N;

	adj.assign(N, vector<int>());
	subsize.assign(N, 0);

	dp.assign(N, -1);
	result.assign(N, -1);

	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs_size(0, -1);
	dfs_rerooting(0, -1);

	for (int i = 0; i < N; i++)
	{
		cout << result[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 22516
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
const int maxn=1000000+5;
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	string s;
	int x1,x2;
	cin>>s;
	for(int i=0;i<s.length();i++) if(s[i]=='A')
	{
		x1=i;break;
	}
	for(int i=s.length();i>=0;i--) if(s[i]=='Z')
	{
		x2=i;break;
	}
	cout<<x2-x1+1<<endl;
	
    return 0;
}


Measured memory_bytes: 640
/**************
*	Shell Sort
*************/

#include <cstdio>
#include <vector>	//??£?¨?
#include <algorithm>
using namespace std;
typedef vector<int> TList;	//??????????????????

void insertionSort(TList& A, int g, int& cnt ){

	for(unsigned int i=g ; i<(A.size()); i++){
		int v = A[i];
		int j = i-g;
		while(j>=0 && A[j]>v){
			A[j+g] = A[j];
			j = j-g;
			cnt++;
		}
		A[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(TList& A, TList& G, int& cnt){

	for(unsigned int i=0; i<(G.size()); i++){
		insertionSort(A, G[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??????????¨????
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	//??\???
	int n;
	scanf("%d\n",&n);
//	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
	//	cin >> A[i];
		scanf("%d\n", &A[i]);
	}
	
	//??????
	TList G;
//	G.reserve(100);//????????????????´???°???????????£??????????????¨????????????
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(A, G, cnt);

	//??????
//	cout << G.size() << endl;
	printf("%d\n", G.size());
	for(unsigned int i=0; i<(G.size()); i++){
		printf("%d", G[i]);
//		cout << G[i];
		if(i!=(G.size()-1)){
//			cout <<" " ;
			printf(" ");
		}
	}
//	cout << endl;
	printf("\n");
	printf("%d\n", cnt);
//	cout << cnt << endl;
	for(int i=0; i< n; i++){
//		cout << A[i]<< endl;
		printf("%d\n", A[i]);
	}
	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6324
#include <iostream>
#include <string>

using namespace std;

int main(){
	int n, k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;
	for(int i = 0; i < n; i++){
		if(s[i] != s[k-1]){
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

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

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	xs = append(xs, x)
	sort.Ints(xs)

	diffs := make([]int, 0, n)
	for i := 1; i < len(xs); i++ {
		diffs = append(diffs, abs(xs[i-1]-xs[i]))
	}
	ans := diffs[0]
	for i := 1; i < len(diffs); i++ {
		ans = gcd(ans, diffs[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define MAXN 100010
const long long M = 1000000007;
using namespace std;
long long dp[MAXN];
long long N, K;

int pot(long long a, long long b){
    long long ans = 1;
    while(b){
        if(b&1){
            ans = (ans * a) % M;
        }
        a = (a * a) % M;
        b >>= 1;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> K;
    long long ans = 0;
    for(int i = K; i > 0; i--){
        dp[i] = pot(K / i, N);
        for(int j = i+i; j <= K; j += i){
            dp[i] -= dp[j];
        }
        dp[i] = ((dp[i] % M) + M) % M;
        ans += i * dp[i];
        ans %= M;
    }
    
    ans = ((ans % M) + M) % M;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string n;
    cin >> n;
    if (n[0] == '9' || n[1] == '9')
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

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


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define strcin(s) string (s); cin >> (s);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    #define back_sort(a) sort(all((a)),[](const int &p,const int &q){return p > q;})
    using intv = vector<int>;
    using douv = vector<double>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
    void YN (bool b){
        if(b){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(sx,sy);
    incin2(tx,ty);

    for(int i=0;i<tx-sx;i++){
        cout<<'R';
    }
    rap(ty-sy,i){
        cout<<'U';
    }
    for(int i=0;i<tx-sx;i++){
        cout<<'L';
    }
    rap(ty-sy,i){
        cout<<'D';
    }
    cout<<'D';
    rap(tx-sx+1,i){
        cout<<"R";
    }
    rap(ty-sy+1,i){
        cout<<'U';
    }
    cout<<"LU";
    rap(tx-sx+1,i){
        cout<<'L';
    }
    rap(ty-sy+1,i){
        cout<<'D';
    }
    cout<<'R'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<char> d;
int main(){
	string s;
	cin>>s;
	int q;
	cin>>q;
	int now=0;
	for(int i=0;i<s.length();i++){
		d.push_back(s[i]);
	}
	while(q--){
		int op,tag;
		char c;
		scanf("%d",&op);
		if(op==1){
			now^=1;
			continue;
		}
		else{
			scanf("%d %c",&tag,&c);
			tag=tag%2+now;
			if(tag==1) d.push_front(c);
			else d.push_back(c);
		}
	}
	string ans="";
	while(!d.empty()){
		ans+=d.front();
		d.pop_front();
	}
	if(now==1) reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 1412
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
set<ll> fact(ll n){
  set<ll> res;
  for(ll i=2;i*i<=n;++i){
    if(n%i==0){
      res.insert(i);
      while(n%i==0) n /= i;
    }
  }
  if(n>1)res.insert(n);
  return res;
}

int main() {
  ll a,b;
  cin >> a >> b;
  cout << fact(gcd(a,b)).size() + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;
int test_case = 1;

void func(){

	int table[M+1],next[M+1];

	table[0] = N;
	for(int i = 1; i <= M; i++)table[i] = 0;

	int count = 0;

	while(true){
		for(int i = 0; i <= M; i++)next[i] = 0;

		count++;

		for(int i = 0; i < M; i++){
			if(table[i] >= 2){
				next[i+1] += table[i]/2;
				next[0] += table[i]/2;
				next[i] += table[i]%2;
			}else{
				next[i] += table[i];
			}
		}

		for(int i = 0; i <= M; i++)table[i] = next[i];

		if(table[M] > 0)break;
	}

	printf("Case %d: %d\n",test_case++,count);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3084
A,B,C,X,Y=list(map(int,input().split()))

ans=0

if 2*C >= A+B:#A,Bを個別に買う
#     print('a')
    ans = A*X+B*Y
else:
    if 2*C <= A and 2*C <= B:
        if X >= Y:
#             print('b_1')
            ans = C*2*X
            
        elif X < Y:
#             print('b_2')
            ans = C*2*Y
            
    elif 2*C <= A:
#         print('b')
        ans = C*2*X + max(0,Y-X)*B
    elif 2*C <= B:
#         print('c')
        ans = max(0,X-Y)*A + C*2*Y
    else:
        if X <= Y:
#             print('d_1')
            ans = C*2*X + max(0,Y-X)*B
            
        elif X > Y:
#             print('d_2')
            ans = max(0,X-Y)*A + C*2*Y
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n - 1);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int t = 1; t < n; t++){
    int sum1 = 0, sum2 = 0;
    for(int j = 0; j < n; j++){
      if(j + 1 <= t) sum1 += a[j];
      else sum2 += a[j];
    }
    ans[t - 1] = abs(sum1 - sum2);
  }
  cout << *min_element(ans.begin(),ans.end()) << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  string s, t;
  cin >> s >> t;
  ll ans = 0LL;
  ll n = s.size();
  rep(i,n) if(s[i]!=t[i]) ans++;
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int N[3];
	cin >> N[0] >> N[1] >> N[2];
	sort(N, N + 3);
	cout << N[0] << " " << N[1] << " " << N[2] << endl;

    return 0;
}



Measured memory_bytes: 3156
#include<cstdio>
#include <algorithm>
static const int MAX_N = 100000;
using namespace std;
int n;
int dat[MAX_N+1];

void add(int i,int v){
    while(i<=n){
        dat[i]+=v;
        i+=i&-i;
    }
}
int sum(int i){
    int res=0;
    while(i>0){
        res+=dat[i];
        i-=i&-i;
    }
    return res;
}
int main(){
    int q, y, prev, curr;
    long long ans;
    scanf("%d %d", &n, &q);
    for (int i = 1; i < n; i++) {
        scanf("%d", &y);
        add(i, y);
    }

    prev = 1, ans = 0;
    for (int i = 0; i < q; i++) {
        scanf("%d", &y);
        curr = prev + y;
        //printf("prev, curr: %d %d\n", prev, curr);
        if (curr > prev) ans+= sum(curr-1)-sum(prev-1);
        else ans+= sum(prev-1)-sum(curr-1);
        prev = curr;
    }
    printf("%lld\n", ans%100000);
    return 0;

}



Measured memory_bytes: 3144
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

string S;

int ans, cnt;

int main(void){
	cin>>S;

	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < S.size(); i++) {
		(S[i] == '0' ? cnt0++ : cnt1++);
	}

	cnt = min(cnt0, cnt1);

	ans = 2 * cnt;

	printf("%d\n", ans);
	
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;
  std::vector<int64_t> a(m);
  std::cin >> a;

  std::vector<int64_t> s(n + 1, 0);
  s[0] = 1;
  constexpr int64_t mod = 1000000007;

  auto itr = a.cbegin();
  for (int64_t i = 0; i < n + 1; i++) {
    s[i] %= mod;
    if (itr != a.cend() && *itr == i) {
      s[i] = 0;
      itr++;
    } else {
      if (i + 1 < n + 1) {
        s[i + 1] += s[i];
      }
      if (i + 2 < n + 1) {
        s[i + 2] += s[i];
      }
    }
  }

  std::cout << s.back() << std::endl;
  return 0;
}


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

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

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void){
    ll x,y;cin>>x>>y;
    ll ans=0;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;
int N;

ll dfs(string s, int deep, int last, ll left) {
    // 深さが桁数-1で打ち切り
    if (deep == N) {
        return left + stoll(s.substr(last, s.size() - last));
    }

    // depp番目までを数に直す
    string s_sub = s.substr(last, deep + 1 - last);
    ll right = stoll(s_sub);

    auto sum1 = dfs(s, deep + 1, deep + 1, left + right);  // yes
    auto sum2 = dfs(s, deep + 1, last, left);              // no

    return sum1 + sum2;
}

int main() {
    string s;
    cin >> s;
    N = s.size() - 1;
    auto ans = dfs(s, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19

int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for (auto& e : a) {
        cin >> e;
    }
    int color = 0;
    int id = 0;
    vector<vector<int>> b(h, vector<int>(w, 0));
    for (int r = 0; r < h; ++r) {
        for (int c = 0; c < w; ++c) {
            auto column = c;
            if (r % 2 == 1) {
                column = w - c - 1;
            }
            if (color == a[id]) {
                ++id;
                color = 0;
            }
            b[r][column] = id;
            ++color;
        }
    }

    for (auto& row : b) {
        for (auto el : row) {
            cout << el + 1<< " ";
        }
        cout << "\n";
    }
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100005];
int lev[100005], mx[100005], nxt[100005], u, par[100005];
bool ok[100005];
void dfs(int x)
{
    if(x==u)ok[x]= 1;
    mx[x]= lev[x];
    for(int i=0; i<adj[x].size(); i++)
    {
        int y= adj[x][i];
        if(y!=par[x])
        {
            lev[y]= lev[x]+1;
            par[y]= x;
            dfs(y);
            mx[x]= max(mx[x], mx[y]);
            if(ok[y])ok[x]= 1, nxt[x]= y;
        }
    }
    return;
}
int main()
{
    int n, v, x, y;
    scanf("%d %d %d", &n, &u, &v);
    for(int i=1; i<n; i++)
    {
        scanf("%d %d", &x, &y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(v);
    int res= 0;
    if(lev[u]>lev[v]+1)
    {
        while(lev[u]-lev[v]>2)
        {
            res++;
            v= nxt[v];
            u= par[u];
        }
        res+= (mx[u]-lev[u]);
        res+= (lev[u]-lev[v]-1);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 13824
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        int result = 0;
        if (s.contains("RRR")) {
            result = 3;
        } else if (s.contains("RR")) {
            result = 2;
        } else if (s.contains("R")) {
            result = 1;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007


ll dp[102][100004],s[102][100004],a[102];

ll fsum(int i,int l,int r)
{
	if(l<0)
	l=0;
	/*if(l!=0 and s[i][r]<s[i][l-1])
	cout<<"here "<<i<<" "<<l-1<<" "<<r<<"  "<<s[i][l-1]<<" "<<s[i][r]<<endl;*/
	if(l==0)
	return (mod+s[i][r])%mod;
	else if(s[i][r]-s[i][l-1]<0)
	return (mod +(s[i][r]-s[i][l-1]));
	else
	return (s[i][r]-s[i][l-1]);
	
}

main()
{ ll n,k;
fastread
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
	cin>>a[i];
	
	for(int i=1;i<=n;i++)
{
		dp[i][0]=1;
		s[i][0]=1;
	}
	for(int i=1;i<=k;i++)
{
		dp[0][i]=0;
		s[0][i]=0;
	}
	dp[0][0] =0;
	s[0][0]=0;
	
	ll sum=0;
	for(int i=1;i<=k;i++)
	{
		if(i<=a[1])
			dp[1][i]=1;
		
		else
		dp[1][i]=0;
		
	
		s[1][i]=(dp[1][i]+s[1][i-1])%mod;
	}

	
	for(int i=2;i<=n;i++)
	{

	for(int j=1;j<=k;j++)
	{
	
	ll val = fsum(i-1,j-a[i],j);
/*	if(val<0)
	cout<<"vuhdud" <<i<<" "<<j<<endl;*/
	dp[i][j]= val;
    s[i][j]= (s[i][j-1]+dp[i][j])%mod;
  /*  if(s[i][j]<0)
    cout<<"bvf df "<<i<<" "<<j<<endl;*/
}
}
/*cout<<endl;

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

	//cout<<"here is  "<<i<<" "<<j<<endl;
	cout<<s[i][j]<<" ";
	cout<<endl<<endl;
}
cout<<endl;*/
/*cout<<"helloo "<<endl;
for(int i=0;i<=n;i++)
{
	for(int j=0;j<=k;j++)
	cout<<dp[i][j]<<" ";
	cout<<endl<<endl;
}*/
cout<<dp[n][k];
}


Measured memory_bytes: 158848
package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var n, k int
	fmt.Fscan(in, &n, &k)
	if (n-1)%(k-1) == 0 {
		fmt.Fprintln(out, (n-1)/(k-1))
	} else {
		fmt.Fprintln(out, (n-1)/(k-1)+1)
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    map<int, int> hs;

    for (int i = 0; i < N; ++i)
    {
        int K, A;
        cin >> K;

        while (K--)
        {
            cin >> A;
            ++hs[A];
        }
    }

    int ans = 0;

    for (auto p : hs)
    {
//        cout << p.first << ": " << p.second << '\n';
        ans += (p.second == N ? 1 : 0);
    }
 
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Flying Jenny
 */
public class Main {

	static int[] c = {4, 1, 4, 1, 2, 1, 2, 1};

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int[] p = new int[16];
			for (int i = 0; i < 8; i++) {
				p[i] = p[i + 8] = parseInt(st.nextToken());
			}

			int min = Integer.MAX_VALUE;
			int V = Integer.MAX_VALUE;


			for (int i = 0; i < 8; i++) {
				int _min = 0;
				int _V = 0;
				for (int j = 0; j < 8; j++) {
					_min += (p[i + j] - c[j] > 0 ? p[i + j] - c[j] : 0);
					_V *= 10;
					_V += c[(8 - i + j) % 8];
				}
				if (_min < min) {
					min = _min;
					V = _V;
				} else if (_min == min) {
					if (_V < V) {
						V = _V;
					}
				}
			}

			List<String> ans = new ArrayList<>();

			for (char cc : String.valueOf(V).toCharArray()) {
				ans.add("" + cc);
			}

			System.out.println(String.join(" ", ans));
		}
	}
}

Measured memory_bytes: 24760
N=int(input())
b=list(map(int,input().split()))

ans=[]

while len(b)>0:
    r=-1
    for i in range(len(b)):
        if b[i]==i+1:
            r=i
    if r==-1:
        print(-1)
        exit()
    ans.append(r+1)
    b=b[:r]+b[r+1:]

for i in range(N):
    print(ans[-i-1])


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

int main() {
  int n;
  scanf("%d",&n);
  
  vector<int>w(n);
  for(int i=0; i <n; i++){
    cin >>w[i];
  }
  
  int sum =0;
  for(int i=0; i<n; i++){
    sum+= w[i];
  }
  
  int sum2 =w[0];
  vector<int>v(n-1);
  
  for(int i=0; i <n-1; i++){
    if(sum2-(sum-sum2)<0){
      v[i] = -1*(sum2-(sum-sum2));
    }
    else{
      v[i] = sum2-(sum-sum2);
    }
    sum2+=w[i+1];
  }
    
  sort(v.begin(), v.end());
  
  cout << v[0] <<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
char a, b;
 
scanf("%c %c", &a, &b);
 
  if(a=='H'&&b=='H'){
      puts("H");
  }
  else if(a=='H'&&b=='D') puts("D");
  else if(a=='D'&&b=='D') puts("H");
  else if(a=='D'&&b=='H') puts("D");
 
  return 0;
}

Measured memory_bytes: 128
<?php
$n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
if ((int)$input[0] !== 0) {
	echo 0;
	exit();
}

$list = [];
for ($i=0; $i < $n; $i++) { 
	$list[$i] = 0;
}
foreach ($input as $v) {
	$list[(int)$v] += 1;
}
if ($list[0] !== 1) {
	echo 0;
	exit();
}
// var_dump($list);
$cnt = 0;
$mod = 998244353;
foreach ($list as $k => $v) {
	if ($k == 0) {
		$prev = 1;
		$cnt = 1;
	}else{
		if ($v != 0 && $prev == 0) {
			echo 0;
			exit();
		}
		$cnt = ($cnt * binPow($prev, $v, $mod)) % $mod;
		$prev = $v;
	}
}
echo $cnt;


function binPow($x, $n, $mod){
	$ans = 1;
	$bin = decbin($n);
	$cur_pos = strlen($bin) -1;
	while ($cur_pos >= 0) {
		if ($bin[$cur_pos] == '1') {
			$ans = ($ans * $x) % $mod;
		}
		$x = ($x * $x) % $mod;
		--$cur_pos;
	}
	return $ans;
}


Measured memory_bytes: 18932
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a==b||a==c||a==d||b==c||b==d||c==d){
        cout << "NO" << endl;
        return 0;
    }
    bool flag = true;
    if(!(a==1||b==1||c==1||d==1)) flag = false;
    if(!(a==7||b==7||c==7||d==7)) flag = false;
    if(!(a==9||b==9||c==9||d==9)) flag = false;
    if(!(a==4||b==4||c==4||d==4)) flag = false;
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define INF 0x3fffffff
using namespace std;

int d[10];
int k;

bool in(int p, int c) {
	while (p > 0) {
		if (p % 10 == c) return true;
		p /= 10;
	}
	return false;
}

bool ok(int p) {
	REP(i, 0, k) {
		if (in(p, d[i])) return false;
	}
	return true;
}

int main() {
	int n;
	cin >> n >> k;
	REP(i, 0, k) {
		cin >> d[i];
	}
	while (!ok(n)) {
		++n;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

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

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;
const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        string L[1010];//作物の名前
        int P[1010];//値段
        int A[1010];//芽が出るまでの時間
        int B[1010];//若葉が出るまでの時間
        int C[1010];//葉が茂るまでの時間
        int D[1010];//花が咲くまでの時間
        int E[1010];//身がなるまでの時間
        int F[1010];//一つのタネから成る身の個数
        int S[1010];//身の売れる値段
        int M[1010];//身が成る回数
        vector<pair <double,string> > g(n);
        rep(i,n){
            cin >> L[i] >> P[i] >> A[i] >> B[i] >> C[i]
                >> D[i] >> E[i] >> F[i] >> S[i] >> M[i];
            //M[i]>1の場合.実が成ったあと葉に戻る
            //成るまでの時間
            int ft = A[i]+B[i]+C[i]+D[i]+E[i];
            //葉が茂った後に身がなるまでの時間
            int lt = D[i]+E[i];
            //合計時間
            int tt = ft+lt*(M[i]-1);
            //合計利益
            int ri = F[i]*S[i]*M[i]-P[i];
            g[i].fi = (double)ri/tt*-1;
            g[i].se = L[i];
        }
        sort(g.begin(),g.end());
        rep(i,n){
            cout << g[i].se << endl;
        }
        cout << "#" << endl;


    }

    return 0;
}



Measured memory_bytes: 3272
# -*- coding: utf-8 -*-

import numpy as np
from sys import stdin

def load():
    n = stdin.readline()
    data = [int(x) for x in stdin.readline().split()]
    return (n,data)

def calc(n, data):
    d = np.asarray(data)
    m = d.mean()
    diff = np.abs(d - m)
    return diff.argmin()

n, data = load()
print(calc(n, data))

Measured memory_bytes: 21872
package main

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

func main() {
    var sc = bufio.NewScanner(os.Stdin)
    n := []int{0,0,0}
    sc.Split(bufio.ScanWords)
    sc.Scan()
    n[0], _ = strconv.Atoi(sc.Text())
    sc.Scan()
    n[1], _ = strconv.Atoi(sc.Text())
    sc.Scan()
    n[2], _ = strconv.Atoi(sc.Text())
    sort.Sort(sort.IntSlice(n))
    fmt.Println(fmt.Sprintf("%d %d %d",n[0],n[1],n[2]))
}


Measured memory_bytes: 1116
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


int main(){  
    
    int l,r,k;
    cin >> l >> r >> k;
    set<int> se;
    for(int i=0;i<k && l <= r;i++)
        se.insert(l++);
    for(int j=0;j<k && r >= l;j++)
        se.insert(r--);
        
    for(int i:se)
        cout << i << '\n';
}


Measured memory_bytes: 256