akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <set>
using namespace std;

template<class T> struct Parser {
    typedef string::const_iterator State;

    T solve(const string &S) {
        State begin = S.begin();
        return expr(begin);
    }

    struct Term {
        char op;
        set<int> operand;
        Term(char c, set<int> si) : op(c), operand(si) { }
    };

    // expr ::= factor | factor + factor | factor - factor
    //         | factor * factor | factor / factor
    T expr(State &begin) {
        vector<Term> terms;
        terms.emplace_back('@', factor(begin));
        for (;;) {
            if (*begin == '+') {
                terms.emplace_back('+', factor(++begin));
            } else if (*begin == '-') {
                terms.emplace_back('-', factor(++begin));
            } else if (*begin == '*') {
                terms.emplace_back('*', factor(++begin));
            } else if (*begin == '/') {
                terms.emplace_back('/', factor(++begin));
            } else {
                break;
            }
        }
        return dp(terms);
    }

    T dp(vector<Term> &terms) {
        int n = terms.size();
        vector<vector<T>> dp(n, vector<T>(n + 1));
        for (int i = 0; i < n; i++) {   // len = 1
            dp[i][i + 1] = terms[i].operand;
        }
        for (int len = 2; len <= n; len++) {
            for (int i = 0; i + len <= n; i++) {        // [i, i + len)
                T &res = dp[i][i + len];
                for (int j = i + 1; j < i + len; j++) { // [i, j) + [j, i + len)
                    T tmp = calc(dp[i][j], terms[j].op, dp[j][i + len]);
                    merge(res, tmp);
                }
            }
        }
        return dp[0][n];
    }

    T calc(T left, char op, T right) {
        T res;
        for (int a : left) for (int b : right) {
            if (op == '+') res.insert(a + b);
            else if (op == '-') res.insert(a - b);
            else if (op == '*') res.insert(a * b);
            else if (op == '/' && b != 0) res.insert(a / b);
        }
        return res;
    }

    void merge(T &res, T tmp) {
        for (int e : tmp) res.insert(e);
    }

    // expr ::= ( term ) | number
    T factor(State &begin) {
        if (*begin == '(') {
            begin++; // skip '('
            T ret = expr(begin);
            begin++; // skip ')'
            return ret;
        } else {
            return number(begin);
        }
    }

    // number ::= digit | number digit
    T number(State &begin) {
        int ret = 0;
        while (isdigit(*begin)) {
            ret *= 10;
            ret += *begin - '0';
            begin++;
        }
        return {ret};
    }
};

int main() {
    string S;
    while (cin >> S && S != "#") {
        Parser<set<int>> ps;
        cout << ps.solve(S).size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3304
#include<stdio.h>

int main(){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if (a<b && b<c){
	
	printf ("Yes\n");
	
	}else{
	
	printf ("No\n");
	
	}
	
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a >= b) {
            System.out.println("delicious");
        } else if (x + a >= b) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
        
    }
    
}


Measured memory_bytes: 21844
def make_tree(G,keta,count):
    if keta==1:
        num =[]
        for i in range(1,10):
            count+=1
            if count ==k:
                print(i)
                exit()
            else:
                num.append(i)
        G.append(num)
        make_tree(G,2,count)
    else:
        
        num_list = G[keta-2]
        num_lis =[]
        for num in num_list:
            num_str = str(num)
            num_e = int(num_str[-1])
            if num_e == 0:
                count +=1
                if count == k :
                    print(int(num_str + "0"))
                    exit()
                num_lis.append(int((num_str)+"0"))
                count+=1
                if count == k :
                    print(int(num_str + "1"))
                    exit()
                num_lis.append(int((num_str)+"1"))
            elif num_e == 9:
                count +=1
                if count == k :
                    print(int(num_str + "8"))
                    exit()
                num_lis.append(int((num_str)+"8"))
                count+=1
                if count == k :
                    print(int(num_str + "9"))
                    exit()
                num_lis.append(int((num_str)+"9"))
            else:
                count +=1
                if count == k :
                    print(int(num_str + str(num_e-1)))
                    exit()
                num_lis.append(int(num_str + str(num_e-1)))
                count+=1
                if count == k :
                    print(int(num_str + str(num_e)))
                    exit()
                num_lis.append(int(num_str + str(num_e)))
                count+=1
                if count == k :
                    print(int(num_str + str(num_e+1)))
                    exit()
                num_lis.append(int(num_str + str(num_e+1)))
        G.append(num_lis)

        make_tree(G,keta+1,count)


k = int(input())
G=[]
make_tree(G,1,0)


Measured memory_bytes: 43408
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N;
    string S;
    int K;
    cin >> N >> S >> K;

    rep(i,N){
        if (S[i] == S[K-1]){
            cout << S[i];
        }
        else{
            cout << '*';
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b, c;
	
	scanf("%d %d %d",&a, &b, &c);
	
	if ((a==b && a!=c)||(a==c && a!=b)||(b==c && b!=a)){
	printf ("Yes\n");
	
	}else
	printf ("No\n");
	return 0;
}

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

const ll mod = 998244353;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n&1) res = res * x % mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> d(N-1);
    int d0;
    cin >> d0;

    map<int, ll> mp;
    rep(i, N-1) {
        cin >> d[i];
        mp[d[i]]++;
    }

    if (d0 != 0) {
        cout << 0 << endl;
        return 0;
    }

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

    ll ans = 1;
    int cur = 1;
    ll prev = 1;
    for (auto & tmp : mp) {
        if (cur != tmp.first) {
            ans = 0;
            break;
        }
        else {
            if (cur == 1) {
                prev = tmp.second;
            }
            else {
                //cout << ans << ", " << mod_pow(prev, tmp.second, mod) << endl;
                ans *= mod_pow(prev, tmp.second, mod);
                ans %= mod;
                prev = tmp.second;
            }
        }
        cur++;
    }

    cout << ans << endl;

}


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

using namespace std;

static void inputArray(int A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i];
   }
}

static void printArray(int A[], int num) {
  for (int i = 0; i < num; i++) {
    cout << ((i != 0) ? " " : "") << A[i];
  }
  cout << endl;
}

static const int NMAX = 10000;
static vector<int> C(NMAX + 1, 0);

static inline void countingSort(int A[], int B[], int num) {
  for (int i = 0; i < num; i++) {
    C[A[i + 1]]++;
  }
  for (int i = 1; i <= NMAX; i++) {
    C[i] = C[i] + C[i - 1];
  }
  for (int i = num; i > 0; i--) {
//  for (int i = 1; i <= num; i++) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}  

static vector<int> A(2000000 + 1), B(2000000 + 1);

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

  inputArray(&A[1], n);

  countingSort(&A[0], &B[0], n);

  printArray(&B[1], n);
    
  return 0;
}



Measured memory_bytes: 18240
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
#define MAX_N (100010)
#define MAX_H (1000000010LL)
typedef pair<int, int> P;

int H, W, N;
int A[10];
int main()
{
    scanf("%d %d %d", &H, &W, &N);
    set<ll> cand;
    set<ll> B;
    for ( int i = 0; i < N; i++ ) {
	int a, b;
	
	scanf("%d %d", &a, &b);	
	a--;
	b--;
	
	B.insert( a * MAX_H + b );

	for ( int dy = -1; dy <= 1; dy++ ) {
	    ll y = a + dy;
	    if ( (y >= 1) && (y < H-1) ) {
		for ( int dx = -1; dx <= 1; dx++ ) {
		    ll x = b + dx;
		    if ( (x >= 1) && (x < W-1) ) {
			ll c = y * MAX_H + x;
			cand.insert(c);
		    }
		}
	    }
	}
    }

    for ( set<ll>::iterator it = cand.begin(); it != cand.end(); it++ ) {
	ll tmp = *it;
	ll cy = tmp / MAX_H;
	ll cx = tmp % MAX_H;
	int count = 0;

	for ( int dy = -1; dy <= 1; dy++ ) {
	    ll y = cy + dy;
	    if ( y >= 0 && y < H ) {
		for ( int dx = -1; dx <= 1; dx++ ) {
		    ll x = cx + dx;
		    if ( x >= 0 && x < W ) {
			ll c = y * MAX_H + x;
			if ( B.find(c) != B.end() ) {
			    count++;
			}
		    }
		}
	    }
	}
	
	A[count]++;
    }
    ll remain = 0;
    for ( int i = 1; i <= 9; i++ ) {
	remain += A[i];
    }
    ll all = ((ll)H-2) * ((ll)W-2);
    printf("%lld\n", all - remain);

    for ( int i = 1; i <= 9; i++ ) {
	printf("%d\n", A[i]);
    }

    return 0;
}


Measured memory_bytes: 47104
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int N,L;
int *time;

int func(int table[],int index){

	if(table[index] > table[index-1] && index < N-1 && table[index] > table[index+1]){
		return time[index] = L - table[index];
	}else if(table[index] > table[index-1] && index == N-1){
		return time[index] = L - table[index];
	}else{
		return time[index] =  func(table,index+1) + L - table[index];
	}
}

int main(){

	int maximum;
	scanf("%d %d",&N,&L);
	int* table = new int[N];
	time = new int[N];

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

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

	if(table[0] > table[1]){
		time[0] = L - table[0];
	}else{
		time[0] = func(table,1) + L - table[0];
	}

	for(int i = 1; i <= N-2; i++){
		if(table[i] > table[i-1] && table[i] > table[i+1]){
			time[i] = L - table[i];
		}else{
			if(table[i-1] > table[i] && table[i+1] > table[i]){
				if(time[i+1] != -1){
					time[i] = max(time[i-1],time[i+1]) + L - table[i];
				}else{
					time[i] = max(time[i-1],func(table,i+1)) + L - table[i];
				}
			}else if(table[i-1] > table[i]){
				time[i] = time[i-1] + L - table[i];
			}else if(table[i+1] > table[i]){
				if(time[i+1] != -1){
					time[i] = time[i+1] + L - table[i];
				}else{
					time[i] = func(table,i+1) + L - table[i];
				}
			}
		}
	}

	if(table[N-1] > table[N-2]){
		time[N-1] = L - table[N-1];
	}else{
		time[N-1] = time[N-2] + L - table[N-1];
	}

	maximum = 0;
	for(int i = 0; i < N; i++){
		maximum = max(maximum,time[i]);
	}

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

    return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;
/*
bool comp(P a, P b){
    if(a.first < b.first){
        return true;
    }else{
        return a.second > b.second;
    }
}*/

int main(){
    int N;
    cin >> N;
    vector<P> R(N),B(N);
    rep(i,N){
        cin >> R[i].first >> R[i].second;
    }
    rep(i,N){
        cin >> B[i].first >> B[i].second;
    }
    sort(R.begin(),R.end(),greater<pair<int,int>>());
    sort(B.begin(),B.end());
    int cnt = 0;
    rep(i,N){
        auto iter = upper_bound(B.begin(), B.end(), R[i]);
        if(iter != B.end()){
            //if(B[ind].first > R[i].first && B[ind].second > R[i].second){
            int m = 1000000;
            auto iter_rec = iter;
            while(iter != B.end()){
                //cout << "a"<<endl;
                if((*iter).second <= R[i].second){iter++; continue;}
                int tmp = min(m, (*iter).second);
                if(tmp != m){
                    iter_rec = iter;
                    m = tmp;
                }
                iter++;
            }
            //cout << (*iter).second << " " << (*iter_rec).second << endl;
            if(m > R[i].second && m != 1000000){
                B.erase(iter_rec);
                cnt++;
            }
            
            //B.erase(iter);
            //cnt++;
            //B[ind] = make_pair(-1,-1);
            //}
        }
    }
    cout << cnt << endl;
    /*rep(i,N){
        cout << R[i].first <<" " <<R[i].second<<endl;
    }*/
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
	double a,sum;
	while(~scanf("%lf",&a)){
		sum=0;
		for(int i=0;i<10;i++){
			sum+=a;
			if(i%2==1){
				a=a/3;
			}
			else{
				a=a*2;
			}
		}
		printf("%.8lf\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(){
  int w,h,n,x,y,ans = 0;
  scanf("%d %d %d %d %d",&w,&h,&n,&x,&y);
  for(int i=0;i<n-1;i++){
    int nx,ny;
    scanf("%d %d",&nx,&ny);
    int dx = nx-x;
    int dy = ny-y;
    x = nx;
    y = ny;
    if(dx*dy>0) ans+=max(abs(dx),abs(dy));
    else ans+=abs(dx)+abs(dy);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2748
fun main(args : Array<String>) {
    while (true) {
        val (h, w) = readLine()!!.split(" ").map(String::toInt)
        if (w == 0 && h == 0) {break}
        (1..h).forEach {
            when (it) {
                1 -> println("#".repeat(w))
                h -> println("#".repeat(w))
                else -> println("#".plus(".".repeat(w - 2)).plus("#"))
            }
        }
        println()
    }
}



Measured memory_bytes: 32828
_, *canvas = readlines.map(&:chomp)
result = true
catch(:foo) do
  canvas.each_with_index do |l, i|
    l.each_char.with_index do |c, j|
      next if c == '.'
      left = j > 0 ? l[j - 1] : nil
      right = l[j + 1]
      up = i > 0 ? canvas[i - 1][j] : nil
      down = canvas[i + 1] ? canvas[i + 1][j] : nil
      if left != '#' && right != '#' && up != '#' && down != '#'
        result = false
        throw :foo
      end
    end
  end
end
puts result ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <cstdio>
using namespace std;

int main() {
	char S[20]; scanf("%s", &S);
	int y = (S[0] - '0') * 1000 + (S[1] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0'), m = (S[5] - '0') * 10 + (S[6] - '0'), d = (S[8] - '0') * 10 + (S[9] - '0');

	if (y > 2019) printf("TBD\n");
	if (y == 2019) {
		if (m > 4) printf("TBD\n");
		else if (m == 4 && d > 30) printf("TBD\n");
		else printf("Heisei\n");
	}
	if (y < 2019) printf("Heisei\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;
typedef long long ll;

ll d, n, m;

void solve() {
  // To have d difference, pair should be (1,d+1), ... (n-d, n)
  double p = n - d;
  // If we look at only two elements, all the rest could be anything.
  // (m - 1)C1 * m^(n-2) / m^n * p * 2.0
  double ans = p * (m - 1) / (n * n);
  if (d != 0) {
    ans *= 2.0;
  }
  cout << setprecision(20) << ans << endl;
}

int main() {
  cin >> n >> m >> d;
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop int a[n]; for(i=0;i<n;i++)
#define lloop ll a[n]; for(i=0;i<n;i++)
#define tcase int t; cin>>t; while(t--)
#define max(a,b) (a>b?a:b)
#define check(a,b) for(i=0;i<b;i++) cout<<a[i]<<' '; cout<<endl;
#define pb push_back
#define min(a,b) (a<b?a:b)
#define g(a) (a*(a-1))/2
#define fi first
#define se second
#define M 1000000007
#define pi 3.14159265
using namespace std;

int a[4005][4005];
int b[4005][4005];
int cb[4005][4005];
int cw[4005][4005];
int main()
{
  ios::sync_with_stdio(false);
  //freopen("output.txt","r",stdin);
  int n,k,i,j;
  cin>>n>>k;
  int x,y;
  char c;
  int z=2*k;
  for(i=0;i<n;i++)
  {
    cin>>x>>y>>c;
    x%=z;
    y%=z;
    if(c=='B'){
    cb[x][y]++;
    cb[x+z][y+z]++;
    cb[x][y+z]++;
    cb[x+z][y]++;
    }
    else{
      cw[x][y]++;
      cw[x+z][y+z]++;
      cw[x][y+z]++;
      cw[x+z][y]++;
    }
  }
  for(i=1;i<4*k+2;i++)
  {
    cb[i][0]+=cb[i-1][0];
    cb[0][i]+=cb[0][i-1];
    cw[i][0]+=cw[i-1][0];
    cw[0][i]+=cb[0][i-1];
  }
  for(int j=1;j<4*k+2;j++)
    for(int i=1;i<4*k+2;i++)
    {
      cb[i][j]+=cb[i][j-1]+cb[i-1][j]-cb[i-1][j-1];
      cw[i][j]+=cw[i][j-1]+cw[i-1][j]-cw[i-1][j-1];
    }
 /*for(i=0;i<4*k+2;i++)
  {
    for(j=0;j<4*k+2;j++)
      cout<<cb[i][j]<<' ';
    cout<<endl;
  }*/
  int t=0;
  int an=0;
  for(int i=0;i<k;i++)
    for(int j=0;j<2*k;j++)
    {
      t=cb[i+k][j+k]+cb[i][j]-cb[i+k][j]-cb[i][j+k]+cb[i+k+k][j+k+k]+cb[i+k][j+k]-cb[i+k+k][j+k]-cb[k+i][j+k+k];
      t+=cw[i+k+k][j+k]+cw[i+k][j]-cw[i+k+k][j]-cw[i+k][j+k]+cw[i+k][j+k+k]+cw[i][j+k]-cw[i+k][j+k]-cw[i][j+k+k];
      an=max(an,t);

    }
    cout<<an<<endl;
  return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

signed main(){
	int n=read();
	vi cur(3,0),nx(3,0);
	cur[0]=1;
	for(int i=59;i>=0;i--){
		fill(ALL(nx),0);
		REP(k,3){
			int p=k*2+((n>>i)&1);
			if(p>=2)
				add(nx[min(2LL,p-2)],cur[k]);
			if(p>=1)
				add(nx[min(2LL,p-1)],cur[k]);
			add(nx[min(2LL,p)],cur[k]);
		}
		swap(cur,nx);
	}
	int ans=0;
	add(ans,cur[0]);
	add(ans,cur[1]);
	add(ans,cur[2]);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,k,ans; 
int main(){
    cin>>k;
    cin>>a>>b;
    int largest = ( b / k ) * k ;
    if ( a <= largest ) {
    puts (" OK ");
    } else {
    puts (" NG ");
    }
   
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
    return 0;   
}

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

int main() {
    int s; cin >> s;
    int arr[10000] = {0};
    int i = 1;
    while(1) {
        if (arr[s] == 1) {
            cout << i << endl;
            break;
        }
        arr[s] = 1;
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
        i++;
    }
}


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

using namespace std;

int main()
{
    long double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    long double d;
    d = pow(x2 - x1, 2) + pow(y2 - y1, 2);
    cout << fixed << setprecision(20) << sqrtl(d) << endl;
}


Measured memory_bytes: 3292
#include <iostream>

using namespace std;

int main()
{
    int no_of_hills;
    cin >> no_of_hills;

    int max_so_far = 0;
    int no_of_visible_hills = 0;
    for(int i = 1; i <= no_of_hills; i++)
    {
        int height;
        cin >> height;

        no_of_visible_hills += (height >= max_so_far);

        max_so_far = max(max_so_far, height);
    }

    cout << no_of_visible_hills;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)

P cst[300];
P sts[2000];
map<P, bool> stars;

int main(){
	int m, n;
	int dx, dy;
	while(cin >> m && m){
		stars.clear();
		rep(i, m) cin >> cst[i].first >> cst[i].second;
		cin >> n;
		rep(i, n){
			cin >> sts[i].first >> sts[i].second;
			stars[sts[i]] = true;
		}

		rep(i, n){
			dx = sts[i].first - cst[0].first;
			dy = sts[i].second - cst[0].second;
			bool ok = true;
			rep(j, m){
				if(!stars[P(cst[j].first + dx, cst[j].second + dy)]) ok = false;
			}
			if(ok) break;
		}
		cout << dx << " " << dy << endl;
	}
	return 0;
}

Measured memory_bytes: 4840
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 0

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define rall(x) (x).rbegin (), (x).rend ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7; // UPDATE

int main ()
{
    int i, j;
    string a, b; char c;
    scanf ("%d", &j); getline (cin, a);
    for (i = 0; i < j; i++)
    {
        scanf ("%c", &c);
        a += c;
    }
    scanf ("%*c");
    for (i = 0; i < j; i++)
    {
        scanf ("%c", &c);
        b += c;
    }
    for (i = 0; i < a.length (); i++)
        printf ("%c%c", a[i], b[i]);
    printf ("\n");

    return 0;
}


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

#define int long long

int ans = 0;
string s;
int N;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> s;
  N = s.size();

  int cntA = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( i+2 < N ) {
      if ( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' ) {
	s[i] = 'B';
	s[i+1] = 'C';
	s[i+2] = 'A';	
	ans += cntA+1;
	i++;
      } else {
	if ( s[i] == 'A' ) cntA++;
	else cntA = 0;
      }
    }
  }

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


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, mod = 1e9 + 7;
int n, hsh[maxn], dp[maxn];
std::pair<int, int> pnt[maxn], rng[maxn];
inline int lowbit(int i) { return i & (-i); }
inline void M(int i, int x) { for (; i <= n; i += lowbit(i)) { dp[i] = (dp[i] + x) % mod; } return; }
inline int Q(int i) { if(i < 0) { return 0; } int x = 0; for (; i; i ^= lowbit(i)) { x = (x + dp[i]) % mod; } return x; }
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) { int x, y; scanf("%d%d", &x, &y); pnt[i] = std::make_pair(x, y); hsh[i] = y; }
	std::sort(hsh, hsh + n); for (int i = 0; i < n; ++i) { pnt[i].second = std::lower_bound(hsh, hsh + n, pnt[i].second) - hsh + 1; }
	std::sort(pnt, pnt + n);
	int mx = 0, mn = n + 1;
	for (int i = 0; i < n; ++i) { mx = std::max(mx, pnt[i].second); rng[i].second = mx; }
	for (int i = n - 1; ~i; --i) { mn = std::min(mn, pnt[i].second); rng[i].first = mn; }
	std::sort(rng, rng + n); for (int i = 0; i < n; ++i) { int l = rng[i].first, r = rng[i].second; M(r, (Q(r) - Q(l - 2) + (l == 1)) % mod); }
	printf("%d\n", (Q(n) - Q(n - 1) + mod) % mod);
	return 0;
}

Measured memory_bytes: 4992
n = int(input())
d = [int(i) for i in input().split()]
a = sorted(d)
checkZero = False
if(d[0] != 0):
    checkZero = True
for i in range(1,len(d)):
    if(d[i] == 0):
        checkZero = True

if(checkZero):
    print(0)
else:
    start = 0
    counta = 0
    countb = 1
    ans = 1
    for i in a:
        if(start == i):
            counta += 1
        elif(i - start > 1):
            ans = 0
        else:
            ans *= countb ** counta
            start = i
            countb = counta
            counta = 1
    ans *= countb ** counta
    print(ans%998244353)

Measured memory_bytes: 14396
/**
 *      ABC 61 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-16 16:43:04
**/

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

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

    ll N, K; cin >> N >> K;
    ll a[N] = {}; ll b[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    ll d[100005] = {};

    for (int i = 0; i < N; ++i) {
        d[a[i]] += b[i]; 
    }
    ll count = 0;
    //int begin = 0;

    for (int i = 0; i < 100005; ++i) {
        count += d[i];
        if (count >= K){
            cout << i << endl; return 0;
        }
    }
}

Measured memory_bytes: 2560
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 11, 2020 3:22 PM
 *    Problem Name  : A - Poor
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc155/tasks/abc155_a
 *    @genarated by : ai-virtual-assistant
**/

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

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

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

    if((a == b && b == c && c == a) || (a != b && b != c && c != a)) cout << "No" << endl;
    else cout << "Yes" << endl;



    return 0 ;
}


Measured memory_bytes: 3508
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 1000000000
#define SIZE 100

int main(){
  int n,h,m;
  vector<pair<int,int> > t;
  
  for(int k=0;k<2;k++){
    scanf("%d",&n);

    for(int i=0;i<n;i++){
      scanf("%d%d",&h,&m);
      t.push_back(make_pair(h,m));
    }
  }

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

  int f = false;
  
  for(int i=0;i<t.size();i++){
    if(i>0 && t[i]==t[i-1]){
      continue;
    }
    if(f) printf(" ");
    printf("%d:%02d",t[i].first,t[i].second);
    f = true;
  }

  puts("");
  
  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

int main()
{
	
int n,m; 
int price[1000]; //品物の価格
int sum,max, i, j;

while(scanf("%d %d", &n, &m)){
	if(n==0&&m==0)
    break;


for(i=0; i<n; i++)
{
	scanf("%d", &price[i]);
}
	max=0;
	for(i=0; i<n; i++){
	for(j=i+1;j<n;j++){
		
	sum=price[i]+price[j];
	if(sum>max&&sum<=m)
		max = sum;
	}
	}
	if(max==0)
	printf("NONE\n");
	else
	printf("%d\n",max);
}
	return 0;	

}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
typedef long long ll;
using namespace std;
ll m=1000000007;

vector<vector<ll>> dp(101, vector<ll>(100002));

int main() {
	fastio;
	ll n, k;	cin>>n>>k;
	vector<ll> arr(n);
	for(int i=0; i<n; i++)	cin>>arr[i];
	for(int i=0; i<=n; i++)	dp[i][0]=1;
	ll ans=0;
	for(int i=1; i<=n; i++){
		ll temp=1;
		int j;
		for(j=1; j<=arr[i-1]; j++){
			temp+=dp[i-1][j];
			dp[i][j]=temp;
		}
		for(j; j<=k; j++){
			dp[i][j]=dp[i][j-1] - dp[i-1][j-arr[i-1]-1] + dp[i-1][j];
			if(dp[i][j]==0)	break;
		}
		for(j=1; j<=k; j++){
			dp[i][j]%=m;
		}
	}
	// for(int i=0; i<=n; i++){
	// 	for(int j=0; j<=k; j++)	cout<<dp[i][j]<<"\t";	cout<<"\n";
	// }
	cout<<dp[n][k]<<"\n";
	return 0;
}

Measured memory_bytes: 80256
N,K = map(int,input().split())
L = list(map(int,input().split()))
#dp[i][is_small]  =: i桁目までみた is_small? の中での最大

d = format(K,'b')
dp = [[-1 for _ in range(2)] for _ in range(len(d) +1)]
dp[0][0] = 0
for i in range(len(d))[::-1]:
    if K == 0: break
    index = len(d) - i - 1
    cnt = 0
    for x in L:
        if x & (1 << i):
            cnt += 1
    #上からindex桁目に着目
    tmp = 2 ** i 
    if dp[index][1] != -1:
        dp[index+1][1] =max(dp[index+1][1], dp[index][1] + max(cnt,N-cnt) * tmp)
    #確定していない
    if d[index] == '1':
        #確定
        if dp[index][0] != -1:
            dp[index+1][1] = max(dp[index+1][1],dp[index][0] + cnt * tmp)
        #確定させない
        if dp[index][0] != -1:
            dp[index+1][0] = max(dp[index+1][0],dp[index][0] + (N-cnt)*tmp)
    else:
        #確定させない(0にする)
        if dp[index][0] != -1:
            dp[index+1][0] = max(dp[index+1][0],dp[index][0] + cnt*tmp)
ans = 0
for i in range(len(d),50):
    tmp = 2 ** i
    cnt = 0
    for x in L:
        if x & (1 << i):
            cnt += 1
    ans += cnt * tmp
print(ans + max(dp[len(d)][0],dp[len(d)][1],0))


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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() {
  int A, B, C, D, E; cin >> A >> B >> C >> D >> E;
  int all_n = A + B + C + D + E;
  int a = 0;
  int max_n = 0;
  if(A % 10 != 0) {
    int tmp = ((A / 10) + 1) * 10;
    int dif = abs(A - tmp);
    all_n += dif;
    if(max_n < dif) max_n = dif;
  }

  if(B % 10 != 0) {
    int tmp = ((B/ 10) + 1) * 10;
    int dif = abs(B - tmp);
    all_n += dif;
    if(max_n < dif) max_n = dif;
  }

  if(C % 10 != 0) {
    int tmp = ((C / 10) + 1) * 10;
    int dif = abs(C - tmp);
    all_n += dif;
    if(max_n < dif) max_n = dif;
  }

  if(D % 10 != 0) {
    int tmp = ((D / 10) + 1) * 10;
    int dif = abs(D - tmp);
    all_n += dif;
    if(max_n < dif) max_n = dif;
  }

  if(E % 10 != 0) {
    int tmp = ((E / 10) + 1) * 10;
    int dif = abs(E - tmp);
    all_n += dif;
    if(max_n < dif) max_n = dif;
  }

  cout << all_n - max_n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
void dfs(long N, long nums[3], vector<string> &answer, string num) {
  if (stol(num) > N) {
    return;
  }
  if (stol(num) <=  N
    && num.find("3") != std::string::npos
    && num.find("5") != std::string::npos
    && num.find("7") != std::string::npos
  ) {
    answer.push_back(num);
  }
  for (long i = 0; i < 3; i++) {
    dfs(N, nums, answer, num + to_string(nums[i]));
  }
}
int main() {
  long N;
  const long M = 3;
  cin >> N;
  long nums[M] = {3, 5, 7};
  vector<string> answer;
  for (long i = 0; i < M; i++) {
    dfs(N, nums, answer, to_string(nums[i]));
  }
  cout << answer.size() << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int ans;
void dfs(vector<vector<int>>&g, vector<bool>&v, vector<int>&dp, int u){
        v[u]=1;
        for(int i=0;i<g[u].size();i++){
            if(!v[g[u][i]])
                dfs(g,v,dp,g[u][i]);
            
            dp[u]=max(dp[u], dp[g[u][i]]+1);
            ans=max(dp[u], ans);  
        }
}
int main() {
    int n,e;
    ans=INT_MIN;
    cin>>n>>e;
    vector<vector<int>>graph(n+1);
    vector<int>dp(n+1,0);
    vector<bool>vis(n+1,0);
    vis[0]=1;
    
    for(int i=0;i<e;i++){
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    for(int i=0;i<vis.size();i++){
        if(vis[i]==0)
            dfs(graph, vis, dp, i);
    }
    cout<<ans;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
class Solution {
  vector<int> A;
  int n;
  int calc(vector<int> A) {
    if (count_if(A.begin(), A.end(), [](int v) { 
      return v % 2;
    })) return 1;
    return 0;
  }
  int mex(long long x) {
    for (int i = 0; ; ++i) if (((x>>i) & 1) == 0) return i;
  }
  map<vector<int>, int> dp;
  int test(vector<int> A) {
    sort(A.begin(), A.end());
    if (dp.count(A)) return dp[A];
    if (count(A.begin(), A.end(), 0) == 3) return 0;
    int ans = 0;
    long long toMex = 0;
    if (A[0]) {
      --A[0];
      toMex |= 1 << test(A);
      if (A[1]) {
        --A[1];
        toMex |= 1 << test(A);
        if (A[2]) {
          --A[2];
          toMex |= 1 << test(A);
          ++A[2];
        }
        ++A[1];
      }
      if (A[2]) {
        --A[2];
        toMex |= 1 << test(A);
        ++A[2];
      }
      ++A[0];
    }
    if (A[1]) {
      --A[1];
      toMex |= 1 << test(A);
      if (A[2]) {
        --A[2];
        toMex |= 1 << test(A);
        ++A[2];
      }
      ++A[1];
    }
    if (A[2]) {
      --A[2];
      toMex |= 1 << test(A);
      ++A[2];
    }
    ans = mex(toMex);
    if (ans == 0) cout << A[0] << ' ' << A[1] << ' ' << A[2] << '\n';
    return dp[A] = ans;
  }
public:
  void run(istream &in, ostream &out) {
    in >> n;
    A.resize(n);
    for (int i = 0; i < n; ++i) in >> A[i];
    out << (calc(A) == 0 ? "second" : "first") << '\n';
  }
  
  
};
int main() {
  ios_base::sync_with_stdio(false);
  Solution().run(cin, cout);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
int sum[maxn], prime[maxn], tot, mod = 1e9 + 7;
bool check[maxn];
void init(int n){
    tot = 0; sum[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!check[i]) {
            prime[tot++] = i;
            sum[i] = i - 1;
        }
        for(int j = 0; j < tot && prime[j] <= n / i; j++){
            check[i * prime[j]] = 1;
            if(i % prime[j])
                sum[i * prime[j]] = sum[i] * (prime[j] - 1);
            else{
                sum[i * prime[j]] = sum[i] * prime[j];
                break;
            }
        }
    }
    for(int i = 1; i<= n; i++) sum[i] = (sum[i] + sum[i - 1]) % mod;
}
ll qpow(ll a, ll n){
    ll ans = 1;
    for(a %= mod; n; n >>= 1){
        if(n & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans % mod;
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    init(maxn - 1);
    int n, k; scanf("%d%d", &k, &n);
    ll ans = 0;
    for(int i = 1, r; i <= n; i = r + 1){
        r = min(n / (n / i), n);
        ans += qpow(n / i, k) * (sum[r] - sum[i - 1]) % mod;
        ans %= mod;
    }
    printf("%lld\n", (ans + mod) % mod);
    return 0;
}

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

int main() {
	string w;
	bool flag = true;
	cin >> w;
	int a[26] = { 0 };
	for (int i = 0; i < w.size(); i++) {
		a[w[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (a[i] % 2 == 0) {
			continue;
		}
		else {
			flag = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int m,dp[1401][1401]={m=0},h,w,f,i,j;
main(){
	cin>>h>>w;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		cin>>f;
		if(!f){
			dp[i+1][j+1]=min(dp[i][j],min(dp[i+1][j],dp[i][j+1]))+1;
			m=max(m,dp[i+1][j+1]);}
	}
	cout<<m*m<<endl;
}


Measured memory_bytes: 9668
N,M = map(int,input().split())
H = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = 0

for i in range(N):
    h = H[i]
    high = True
    for j in g[i]:
        if h <= H[j]:
            high = False
    if high:
        ans += 1
print(ans)

Measured memory_bytes: 94472
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL N, A, B;

int main(void) {
    cin >> N >> A >> B;
    if (A > B) {
        cout << 0 << endl;
        return 0;
    }
    if (A != B && N == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << (B * (N - 1) + A) - (A * (N - 1) + B) + 1 << endl;
}


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

int count;

void insertionSort(int A[], int N, int G) {
  for(int i = G; i < N; ++i) {
    int v = A[i];
    int j = i - G;
    while( j >= 0 and A[j] > v ) {
      A[j + G] = A[j];
      j = j - G;
      count += 1;
    }
    A[j + G] = v;
  }
  return;
}
      
void shellSort(int A[], int N) {
  count = 0;
  int G[64];
  int m = 0;


  int temp = N;
  for(int i = 0; temp > 0; ++i) {
    G[i] = temp;
    temp /= 2;
    m = i + 1;
  }
  
  for(int i = 0; i < m; ++i) {
    insertionSort(A, N, G[i]);
  }

  std::cout << m << std::endl;
  for(int i = 0; i < m-1; ++i) {
    std::cout << G[i] << " ";
  }
  std::cout << G[m-1] << std::endl;
  std::cout << count << std::endl;
  for(int i = 0; i < N; ++i) {
    std::cout << A[i] << std::endl;
  }
  return;
}
  
int main() {  

  int N;
  int *A;
  A = new int[1040000];
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  shellSort(A, N);
  delete [] A;

  return 0;
}

Measured memory_bytes: 4892
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

bool check(vector<ll> tmp)
{
	ll f = tmp[0];
	for(auto v:tmp)
	{
		if(abs(v-f)>1)
			return 0;
		f = v;
	}
	return 1;
}

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

	ll k,v,i,j,fl;

	vector<ll> adj,tmp;

	cin >> k;
	
	adj.pb(1);
	ll d = 1;

	for(i=2;i<=k;++i)
	{
		tmp = adj;
		fl = 0;
		for(j=0;j<d;++j)
		{
			if(adj[j] == 9)
				continue;
			
			tmp[j] = adj[j]+1;
			for(v=j-1;v>=0;v--)
				tmp[v] = max(0ll,tmp[v+1]-1ll);

			if(check(tmp))
			{
				fl = 1;
				adj = tmp;
				break;
			}
		}
		if(fl == 0)
		{
			adj.clear();
			for(j=0;j<d;++j)
				adj.pb(0);
			adj.pb(1);
			d += 1;
		}
	}

	reverse(all(adj));
	for(auto v:adj)
		cout << v;
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,ans=0;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)if(a[i]%2==1&&i%2==0)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);

        long x = Math.abs(scan.nextLong());
        long k = scan.nextLong();
        long d = scan.nextLong();

        long st = x/d;
        if(st > k) {
            long res = Math.abs(x - k*d);
            System.out.println(res);
            return;
        }
        k = k - st;
        x = x - (st*d);
        if(k%2==0) {
            System.out.println(x);
            return;
        }
        long res = Math.abs(x-Math.abs(d));
        System.out.println(res);


//        int t = scan.nextInt();
//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
//            int[] arr1 = new int[n];
//            for (int j = 0; j < n; j++) {
//                arr1[j] = scan.nextInt();
//            }
////            scase(n, arr1);
//        }


//        long t = scan.nextLong();

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
////            scase(n);
//        }
    }


    static void solveCase(int t, int x, String s) {

    }

    static void scase(int[] arr1, int[] arr2) {
    }



    public static void main(String[] args) {
        solve();
    }


    static class LoggerNode {
        String message;
        int ts;
    }


    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}

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

int main(){
	vector<int> ansvec;
	for (;;){
		int n;
		cin >> n;
		if (n == 0) break;

		int tmpmin = 1001;
		int tmpmax = -1;
		int tmpans = 0;
		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			tmpmin = min(s, tmpmin);
			tmpmax = max(s, tmpmax);
			tmpans += s;
		}
		tmpans -= (tmpmin + tmpmax);
		tmpans /= (n - 2);
		ansvec.push_back(tmpans);
	}

	for (int ans : ansvec){
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(x*4==y)
    cout<<"Yes"<<"\n";
  else if(x*2==y)
    cout<<"Yes"<<"\n";
  else if(y>x*4)
    cout<<"No"<<"\n";
  else if(y<2*x)
    cout<<"No"<<"\n";
  else if(y%2==0)  
    cout<<"Yes"<<"\n";
  else
    cout<<"No"<<"\n";
return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
c = 0
for i in range(N):
    for j in range(N):
        if i != j:
            dis = sum([abs(a - b)** 2 for a, b in zip(X[i], X[j])])**0.5
            if dis.is_integer() == True:
                c += 1
print(c//2)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll A[N+2];
  FFOR(i,1,N) cin>>A[i];
  bool CAN=false;
  ll t=A[1];
  FFOR(i,2,N){
    t^=A[i];
  }
  if(t==0) CAN=true;
  
  if(CAN) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    vl h(n);
    rep(i, n) {
        cin >> h[i];
    }
    sort(rall(h));

    ll cnt = 0;
    ll ans = 0;
    rep(i, n) {
        cnt++;
        if(cnt <= k) {
            continue;
        }
        ans += h[i];
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792