akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
    ll N; cin >> N;
    map<ll, ll> counter;
    REP(i, N){
        ll a; cin >> a;
        counter[a]++;
        counter[a] %=2;
    }
    ll ans = 0;
    for(auto &e : counter){
        ans += e.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) (a).size()
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(int &a, int b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

const int nax = 3005;

int dp[nax][nax];

void solve()
{
  int n, k;
  cin>>n>>k;

  vector<int > dp(k+1);

  dp[0] = 1;

  rep(child, 0, n-1)
  {
    int upto;
    cin>>upto;

    vector<int> fake(k + 1);

    nrep(used, k, 0)
    {
      int tmp = dp[used];

      int L = used + 1;
      int R = used + min(k - used, upto);

      if(R >= L){
        add_self(fake[L], tmp);
        if(R + 1 <= k)
          sub_self(fake[R + 1], tmp);
      }
    }
    int pref_sum = 0;

    rep(i, 0, k)
    {
      add_self(pref_sum, fake[i]);
      add_self(dp[i], pref_sum);
    }
  }
  cout<<dp[k]<<endl;
}
signed main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

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















Measured memory_bytes: 1792
//
// Created by 永徳泰明 on 2019-03-03.
//

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

using namespace std;
#define dump(x)  cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define fill(x, y) memset(x,y,sizeof(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 999999999;

void readFromInputFile() {
#ifdef LOCAL
    static std::ifstream in("/Users/hoo/CLionProjects/for_atcoder/input");
    std::cin.rdbuf(in.rdbuf());
#endif
}

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


    for(int m = max(a,b);m>0;m--){
        if (a%m==0 && b%m==0){
            k--;
            if (k==0){
                cout<<m<<endl;
                return 0;
            }
        }
    }
    cout<<"ERROR"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

// long long pow_mod(long long a, long long b){
// 	if(a == 0)
// 		return 0ll;
// 	if(b == 0)
// 		return 1ll;
// 	if(b == 1)
// 		return a%MOD;
// 	long long x = pow_mod(a,b/2);
// 	return ((b%2 == 1) ? (((x*x)%MOD)*a)%MOD : (x*x)%MOD);
// }

// long long pow_int(long long a, long long b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	long long x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }

// int pow_int(int a, int b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	int x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }


// void print_vec(vector<int>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void print_vec(vector<long long>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void solve_kick_start(int test_case){

// }

void solve(){
	int x,y;
	cin >> x >> y;
	long long smm = 0;
	if(x == 1 && y == 1)
		smm += 400000;

	if(x==1){
		smm += 300000;
	}
	if(x==2){
		smm+=200000;
	}
	if(x==3)
		smm+=100000;
	x = y;
	if(x==1){
		smm += 300000;
	}
	if(x==2){
		smm+=200000;
	}
	if(x==3)
		smm+=100000;
	cout<<smm<<"\n";
}

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

	// // CodeChef Template
	// int t;       
	// cin >> t;
	// while(t--){
	// 	solve();
	// }

	// Single test case input
	solve();

	// // Kick Start Template	
	// int test_cases;
	// cin >> test_cases;
	// for(int i=1;i<=test_cases;i++){
	// 	solve_kick_start(i);
	// }

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left, bisect_right


    W, H = map(int, input().split())
    P = [int(input()) for _ in range(W)]
    P.sort()
    P_count = [0] * (W + 2)

    Q = [int(input()) for _ in range(H)]
    Q.sort()

    ans = 0
    for q in Q:
        tmp = bisect_right(P, q)
        P_count[tmp] += 1
        ans += q * (1 + W - tmp)

    for i in range(W, - 1, -1):
        P_count[i] += P_count[i + 1]
    # print ('途中', ans)
    # for p in P:
    #     tmp = bisect_left(Q, p)
    #     ans += p * (1 + H - tmp)
    for index, p in enumerate(P):
        ans += p * (P_count[index + 1] + 1)
    print (ans)
    # print ('P:', P)
    # print ('Q:', Q)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15568
s = str(input())
k = int(input())

dic = {}
for i in range(1,6):
    for j in range(len(s)+1-i):
        dic.setdefault(s[j:j+i],0)
        dic[s[j:j+i]] += 1
sort_dic = sorted(dic)
print(sort_dic[k-1])

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
#define ll long long
ll mod = 1000000000+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    ll T;
    T=1;
    //cin>>T;
    start:
    while(T--)
    {
        ll n,m,k;
        cin>>n>>m>>k;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
        int ans = 0;
        for(int i=0;i<(1<<n);i++)
        {
            for(int j=0;j<(1<<m);j++)
            {
                char temp[n][m];
                for(int ii=0;ii<n;ii++)
                {
                    for(int jj=0;jj<m;jj++)
                    {
                        temp[ii][jj] = a[ii][jj];
                    }
                }
                for(int bi=0;bi<6;bi++)
                {
                    if(i&(1<<bi))
                    {
                        for(int jj=0;jj<m;jj++)
                        {
                            temp[bi][jj] = '.';
                        }
                    }
                }
                for(int bj=0;bj<6;bj++)
                {
                    if(j&(1<<bj))
                    {
                        for(int jj=0;jj<n;jj++)
                        {
                            temp[jj][bj] = '.';
                        }
                    }
                }
                int count = 0;
                for(int ii=0;ii<n;ii++)
                {
                    for(int jj=0;jj<m;jj++)
                    {
                        if(temp[ii][jj]=='#')
                        {
                            count++;
                        }
                    }
                }
                if(count==k){ans++;}
                    
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(M);
  for (int i =0; i < M; i++) {
    cin >> A.at(i);
  }
  int B;
  B = 0;
 for (int i =0; i < M; i++) { 
    B += A[i];
                              }
  
  //cout << N-B << endl;
  
  if ( N-B >= 0 ) {
    cout << N-B << endl;
  }
else 
  cout << -1 << endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  double a,b;
  cin >> a >> b;
  cout << a/b;
} 

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "POSSIBLE"
#define FALSE__ "IMPOSSIBLE"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

bool m1[200000];
bool mn[200000];

bool ch(int N)
{
	rep(i, N) if (m1[i] && mn[i]) return true;
	return false;
}

int main()
{
	CIN(int, N);
	CIN(int, M);
	rep(i, M) {
		CIN(int, a);
		CIN(int, b);
		if (a == 1) m1[b-1] = true;
		if (b == N) mn[a-1] = true;
	}
	PRINT(ch(N));
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

#define NONE INT_MAX>>1

vector< vector<int> > WarshallFloyd(vector< vector<int> >A)
{
  for(int k=0;k<A.size();k++)
    for(int i=0;i<A.size();i++)
      for(int j=0;j<A.size();j++)
        A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
  return A;
}

int main()
{
  int n;
  int r,k,t;
  int p;
  int s,d,v;

  cin>>n;
  vector< vector<int> > m(n+1,vector<int>(n+1,NONE));
  for(int i=0;i<n;i++){
    cin>>r>>k;
    for(int j=0;j<k;j++){
      cin>>t;
      m[r][t]=1;
    }
  }
  m=WarshallFloyd(m);

  cin>>p;
  for(int i=0;i<p;i++){
    cin>>s>>d>>v;
    if(m[s][d]<v)cout<<m[s][d]+1<<endl;
    else puts("NA");
    }
}

Measured memory_bytes: 0
import fractions
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = 0
key = 1
key1 = 1
l = []
while key == 1:
    if a[0] % b == 0:
        b *= 2
        c += 1
    else:
        b //= 2
        c -= 0
        key = 0
for i in range(n):
    if a[i] % b == 0:
        if (a[i]//b) % 2 == 0:
            key1 = 0
            break
        else:
            l.append(a[i]//b)
    else:
        key1 = 0
        break
if key1 == 0 or c == 0:
    print(0)
else:
    d = l[0]
    for i in range(1,n):
        d = d*l[i]// fractions.gcd(d,l[i])
        if m < d:
            break
    d = d*b//2
    if (m//d)%2 == 0:
        print((m//d)//2)
    else:
        print((m//d)//2+1)

Measured memory_bytes: 89952
using System;

namespace AtCoderABC135B
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int[] X = new int[N];

            for (int i = 0; i < N; i++)
            {
                X[i] = int.Parse(s[i]);
            }

            int count = 0;

            for(int i=0;i<N;i++)
            {
                if (X[i] != i + 1)
                    count++;
            }

            if (count <= 2)
                Console.Write("YES");
            else
                Console.Write("NO");

        }
    }
}



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

int main() {
    int N, K; cin >> N >> K;
    vector<long long> H(N + 1, 0);
    for(int i=1; i<=N; ++i) cin >> H[i];

    if(K == 0) {
        long long res = H[1];
        for(int i=2; i<=N; ++i) res += max(H[i] - H[i - 1], 0LL);
        cout << res << endl;
    } else {
        const long long INF = 1001001001001001001;
        vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, INF));
        for(int i=0; i<=N; ++i) {
            dp[i][0] = 0;
            dp[i][1] = H[i];
        }

        for(int i=2; i<=N; ++i) {
            for(int j=2; j<=N; ++j) {
                for(int k=1; k<i; ++k) {
                    dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0LL, H[i] - H[k]));   
                }
            }
        }

        long long res = 1001001001001001001;
        for(int i=1; i<=N; ++i) res = min(res, dp[i][N - K]);
        cout << res << endl;
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
    return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
    return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 while(x != NIL){
   y = x;
   if(z->key < x->key) x = x->left;
   else x = x->right;
 }
 
 z->parent = y;
 if(y == NIL){
   root = z;
   // printf("root = %d\n" ,z->key);
 }
 else if(z->key < y->key) {
   y->left = z;
   // printf("key = %d yl = %d\n" ,z->key,y->key);
 }
 else {
   y->right = z; 
   // printf("key = %d yr = %d\n" ,z->key,y->key);
 }
 
 
}

void inorder(Node u){
  if(u->left != NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)inorder(u->right); 
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL)preorder(u->left);
  if(u->right != NIL)preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

bool chk[100];

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	vector<int>Q(n);
	for (int i = 0; i < n; i++)
		cin >> Q[i];
	int cnt = 0;
	sort(Q.begin(), Q.end());
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (Q[i] <= a && a + 1 <= Q[j] && Q[j] <= b && b + 1 <= Q[k]) {
					if (chk[i] == false && chk[j] == false && chk[k] == false) {
						cnt++;
						chk[i] = true;
						chk[j] = true;
						chk[k] = true;
					}
				}
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;cin>>n;
    vector<string> s(2);
    rep(i,2)cin>>s[i];
    ll ans =1;
    bool last = true;
    rep(i,n){
        if(s[0][i]==s[1][i]){
            if(!(last)||i==0){
                ans*=1;
            }
            else{
                ans*=2;
            }
            last = true;
        }
        else{
            if(i==0){
                ans*=2;
                last=false;
                i++;
                continue;
            }
            if(!last){
                ans*=3;
            }
            else{
                ans*=2;
            }
            i++;
            last =false;
        }
        ans%=mod;
    }
    cout<<ans*3%mod<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  int x;
  cin >> x;
  
  if(x == 7 || x == 5 || x ==3) cout << "YES" <<endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
a,p=[1],[1]
for i in range(N):
  a.append(a[i] * 2 + 3) 
  p.append(p[i] * 2 + 1)

def f(N,X):
  if N == 0:
    return 0 if X <= 0 else 1 
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1) 
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 9128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int n, a, b, c, ans = 1000000000;
vector<int> l;


void DFS(int i, int x, int y, int z, int mp){
    if(i==n){
        if(x && y && z){
            mp -= 30;
            mp += abs(x-a) + abs(y-b) + abs(z-c);
            ans = min(ans,mp);
        }
        return;
    }
    DFS(i+1, x     , y     , z     , mp);
    DFS(i+1, x+l[i], y     , z     , mp+10);
    DFS(i+1, x     , y+l[i], z     , mp+10);
    DFS(i+1, x     , y     , z+l[i], mp+10);
}

int main(){
    cin >> n >> a >> b >> c;
    l.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    DFS(0, 0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int n;
ll ans;

int main() {
    cin >> n;
    ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans = (ans * i) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    ll a[5];
    ll minn = INFLL;
    rep(i,5){
        cin >> a[i];
        chmin(minn, a[i]);
    }
    ll ans = (N+minn-1) / minn -1 + 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int nullNum = -1;

class Node{
public:
    Node() : 
    id( nullNum ), parent( nullptr ), left( nullptr ), right( nullptr ) {}

    void SetID( int id_ ){
        id = id_;
    }

    void SetParent( Node* prt ){
        parent = prt;
    }

    void SetLeft( Node* l ){
        left = l;
    }

    void SetRight( Node* r ){
        right = r;
    }

    int& ID(){
        return id;
    }

    int Degree(){
        int deg = 0;
        deg += ( left )? 1 : 0;
        deg += ( right )? 1 : 0;
        return deg;
    }

    int Depth(){
        int depth = 0;
        Node* ptr = Parent();
        while( ptr ){
            ++depth;
            ptr = ptr->Parent();
        }
        return depth;
    }

    int Height( Node* const node ){
        if( !node || ( !node->Left() && !node->Right() ) ){
            return 0;
        }else{
            return 1 + std::max( Height( node->Left() ), Height( node->Right() ) );
        }
    }

    Node* Parent(){
        return parent;
    }

    Node* Left(){
        return left;
    }

    Node* Right(){
        return right;
    }
    
    Node* Sibling(){
        if( parent == nullptr ){
            return nullptr;
        }else if( this == parent->Left() ){
            return parent->Right();
        }else{
            return parent->Left();
        }
    }

    const char* CategoryName(){
        if( !parent ){
            return "root";
        }else if( !left && !right ){
            return "leaf";
        }
        return "internal node";
    }
    
private:
    int id;
    Node* parent;
    Node* left;
    Node* right;
};

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<Node> tree(n);

    for( auto& elem : tree ){
        elem = Node();
    }
    
    int id;
    int lid;
    int rid; 
    for( int i = 0; i < n; ++i ){
        std::cin >> id >> lid >> rid;
        tree[id].SetID( id );
        if( lid != nullNum ){
            tree[id].SetLeft( &tree[lid] );
            tree[lid].SetParent( &tree[id] );
        }
        if( rid != nullNum ){
            tree[id].SetRight( &tree[rid] );
            tree[rid].SetParent( &tree[id] );
        }
    }

    for( int i = 0; i < n; ++i ){
        std::cout << "node " << tree[i].ID();
        std::cout << ": parent = " << ( ( !tree[i].Parent() )? -1 : tree[i].Parent()->ID() );
        std::cout << ", sibling = " << ( ( !tree[i].Sibling() )? -1 : tree[i].Sibling()->ID() );
        std::cout << ", degree = " << tree[i].Degree();
        std::cout << ", depth = " << tree[i].Depth();
        std::cout << ", height = " << tree[i].Height( &tree[i] );
        std::cout << ", " << tree[i].CategoryName() << "\n";
    }
}



Measured memory_bytes: 3112
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll int
#define ld long double
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;
ll n, m, x[N], y[N], vx[N], vy[N];
int add(int a, int b){
    return (a + b) % mod;
}
int mul(int a, int b){
    return (1ll * a * b) % mod;
}
ll sub(int a, int b){
    return (((a - b) % mod) + mod) % mod;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        vx[i] = x[i] - x[i - 1];
    }
    for(int i = 0; i < m; i++){
        cin >> y[i];
        vy[i] = y[i] - y[i - 1];
    }
    ll w = 0, l = 0, ans = 0;
    for(int i = 1; i < n; i++)
        l = add(l, mul(mul(n - 1, n - i), vx[i]));
    for(int i = 1; i < n; i++)
        l = sub(l, mul(vx[i], mul(n - i, n - i - 1)));
    for(int i = 1; i < m; i++)
        w = add(w, mul(mul(m - 1, m - i), vy[i]));
    for(int i = 1; i < m; i++)
        w = sub(w, mul(vy[i], mul(m - i, m - i - 1)));
    ans = mul(l, w);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); //2個
		int d = scan.nextInt(); //3次元

		int[][] index = new int[n][d];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				index[i][j] = scan.nextInt();
			}
		}
		
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				
				int sum = 0;
				for (int k = 0; k < d; k++) {
					sum += Math.pow((index[i][k] - index[j][k]), 2);
				}
				
				int root = (int) Math.sqrt(sum);
				
				if (root * root == sum) count++;
			}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 23892
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))
#define all(v) v.begin(),v.end()

struct cmp {
    bool operator() (const ll& a, const ll& b){
        return a < b;
    }
};

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll H,W,M; cin>>H>>W>>M;
    ll countH[H+1], countW[W+1];
    fill(countH,countH+H+1,0);
    fill(countW,countW+W+1,0);
    map<pair<ll,ll>,ll> m;
    for(ll i=1;i<=M;i++){
        ll x,y; cin>>x>>y;
        m[{x,y}]++;
        countH[x]++;
        countW[y]++;
    }
    ll maxH = 0, valH = 1, maxW = 0, valW = 1;
    for(ll i=1;i<=H;i++){
        if(countH[i] > maxH){
            maxH = countH[i];
            valH = i;
        }
    }
    for(ll i=1;i<=W;i++){
        if(countW[i] > maxW){
            maxW = countW[i];
            valW = i;
        }
    }
    ll ans = 0;
    for(ll i=1;i<=H;i++){
        ll val = maxW+countH[i]-m[{i,valW}];
        ans = max(ans,val);
    }
    for(ll i=1;i<=W;i++){
        ll val = maxH+countW[i]-m[{valH,i}];
        ans = max(ans,val);
    }
    cout<<ans;

    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


Measured memory_bytes: 64528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll H, N;
  cin >> H >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  rep(i, N){
    H -= A.at(i);
  }
  if(H <= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
S = input()
T = input()

s = len(S)
t = len(T)
a = s-t+1
ans = t

for i in range(a) :
    x = t
    for j in range(t) :
        if S[i+j] == T[j] :
            x -= 1
    ans = min(ans,x)

print(ans)    
            

Measured memory_bytes: 9116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int emp;

		Scanner scan = new Scanner(System.in);

		emp = scan.nextInt();
		int[] array = new int[emp-1];
		for(int i = 0; i < array.length; i++) {
			array[i] = scan.nextInt();
		}

		int[] manager = new int[emp+1];
		for(int i = 0; i < array.length; i++) {
			manager[array[i]]++;
		}

		for(int i = 1; i < manager.length; i++) {
			System.out.println(manager[i]);
		}
	}
}


Measured memory_bytes: 61652
//Binary Search Tree I
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *parent = nullptr, *left = nullptr, *right = nullptr;
    explicit Node(int key) : key(key){}
};

class Tree {
public:
    void insert(int key);
    Node *root = nullptr;
};

void Tree::insert(int key) {
    Node *x = root;
    Node *y = nullptr;
    auto *n = new Node(key);
    while(x != nullptr) {
        y = x;
        if(key < x -> key) x = x -> left;
        else x = x -> right;
    }
    if(y == nullptr) {
        root = n;
    }
    else {
        n -> parent = y;
        if(key < y -> key) y -> left = n;
        else y -> right = n;
    }
}

void inOrder(Node *N) {
    if(N == nullptr) return;
    inOrder(N -> left);
    cout << " " << (N -> key);
    inOrder(N -> right);
}

void preOrder(Node *N) {
    if(N == nullptr) return;
    cout << " " << (N -> key);
    preOrder(N -> left);
    preOrder(N -> right);
}


int main() {
    Tree T;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string opr;
        int key;
        cin >> opr;
        if(opr == "insert") {
            cin >> key;
            T.insert(key);
        }
        if(opr == "print") {
            inOrder(T.root);
            cout << endl;
            preOrder(T.root);
            cout << endl;
        }
    }
}


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

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

    int res = 0, now = 0;
    for (int i = 0; i < N; i++) {
        if (h[i] > now)
            res += h[i] - now;
        now = h[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int c=0,x=s.length();
    for(int i=0;i<(x/2);i++)
    if(s[i]!=s[x-i-1])
    c++;
    cout<<c;
}

Measured memory_bytes: 3616
#![allow(unused)]

//==============================================================================
//
// Boilerplate code
//
//==============================================================================

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        if let Some(t) = self.iter.next() {
            return t.parse().ok().expect("Parse error")
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get()
    }

    fn gets<T: std::iter::FromIterator<char>>(&mut self) -> T {
        use std::io::Read;
        assert_eq!(self.iter.next(), None);
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|&c| c.is_whitespace())
            .take_while(|&c| !c.is_whitespace())
            .collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

//==============================================================================
//
// Problem-specific code
//
//==============================================================================

fn combinations_with_replacement<F: FnMut(&Vec<i64>)>(
    (min, max): (i64, i64),
    n: usize,
    mut f: F
) {
    fn go<F: FnMut(&Vec<i64>)>(
        pos: usize,
        seq: &mut Vec<i64>,
        (min, max): (i64, i64),
        n: usize,
        f: &mut F
    ) {
        if pos == n {
            f(seq);
            return;
        }
        let start = if pos == 0 { min } else { seq[pos - 1] };
        for i in start..=max {
            seq[pos] = i;
            go(pos + 1, seq, (min, max), n, f);
        }
    }

    let mut seq = vec![0; n];
    go(0, &mut seq, (min, max), n, &mut f);
}

fn eval(seq: &Vec<i64>, constrs: &Vec<(usize, usize, i64, i64)>) -> i64 {
    constrs.iter()
        .map(|&(a, b, c, d)| if seq[b - 1] - seq[a - 1] == c { d } else { 0 })
        .sum()
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n = sc.get();
    let m = sc.get();
    let q = sc.get();
    let constrs: Vec<(usize, usize, i64, i64)> =
        (0..q).map(|_| (sc.get(), sc.get(), sc.get(), sc.get())).collect();

    let mut ans = 0;
    combinations_with_replacement((1, m), n, |seq| {
        ans = std::cmp::max(ans, eval(seq, &constrs));
    });

    println!("{}", ans);
}


Measured memory_bytes: 2084
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int n,d;
    cin>>n>>d;
    d=2*d+1;

    int ans=n/d;
    if(n%d!=0) ans++;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3612
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  tmp0 = input[0].split(" ");
  N = Number(tmp0[0]);
  K = Number(tmp0[1]);
  S = input[1];
  ans = [];

  for (var i = 0; i < N; i++) {
    if (i === K - 1) {
      if (S[i] === "A") {
        ans.push("a");
      }
      if (S[i] === "B") {
        ans.push("b");
      }
      if (S[i] === "C") {
        ans.push("c");
      }
    } else {
      ans.push(S[i]);
    }
  }

  console.log(ans.join(""));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("4 3\nCABA\n");


Measured memory_bytes: 21064
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

const int maxn=200000+16;

int n;
int a[maxn];

int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	while (cin>>n)
	{
		REP(i,n) cin>>a[i];
		int64 s=0;
		REP(i,n) s+=a[i];
		int64 d=0;
		int64 ret=(1LL<<60);
		REP(i,n-1)
		{
			d+=a[i];
			int64 e=abs(d-(s-d));
			ckmin(ret,e);
		}
		cout<<ret<<endl;
#ifndef _MSC_VER
		break;
#endif
	}
	return 0;
}



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

int main() {
  ll n,k; cin>>n >>k;
  ll a= 0;
  for(int i=k;i<=n+1; i++){
    a+=(n-i+1)*i+1;
    a%= l;
  }
  cout<<a<<endl;
}

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

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

ll modpow(ll a, ll b, ll mod)
{
    if (b == 0) return 1%mod;
    ll u = modpow(a, b / 2, mod);
    u = (u * u)%mod;
    if (b%2) u = (a * u)%mod;
    return u;
}

int main()
{
    int mod = 1E9 + 7;
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    ll dp[k + 1];
    for (int i = 1; i <= k; i++) {
        dp[i] = modpow(k / i, n, mod);
    }
    for (int i = k; i >= 1; i--) {
        for (int j = 2 * i; j <= k; j += i) {
            dp[i] = (dp[i] - dp[j] + mod)%mod;
        }
    }
    for (int i = 1; i <= k; i++) {
        ans += (dp[i] * i)%mod;
        ans %= mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
    int N,W;
    cin>>N>>W;

    vector<ll> value(N),weight(N);
    for(int i=0; i<N; i++){
        cin>>weight[i]>>value[i];
    }

    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));

    for(int n=0; n<N; n++){
        for(int w=0; w<=W; w++){
            if(w>=weight[n]){
                dp[n+1][w]=max(dp[n][w-weight[n]]+value[n],dp[n][w]);
            }else{
                dp[n+1][w]=dp[n][w];
            }
        }
    }

    cout<<dp[N][W]<<endl;

    return 0;
}

Measured memory_bytes: 80256
let cnt = ref 0

let insertion_sort (n:int) ?(gap=1) (a:int array) =
  for i=gap to n-1 do
    let v = a.(i) in
    let j = ref (i - gap) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+gap) <- a.(!j);
      j := !j - gap;
      incr cnt;
    done;
    a.(!j+gap) <- v
  done

let gen_gaps n =
  let rec aux = function
      [] -> aux [1]
    | h::t when h > n -> t
    | h::_ as l -> aux ((float_of_int h |> ( *. ) 2.25 |> int_of_float) ::l) in
  (if n > 701 then aux [701;301;132;57;23;10;4;1]
   else List.filter ((>=) n) [701;301;132;57;23;10;4;1])
  |> Array.of_list

let shell_sort (array:int array) (n: int) =
  let g = gen_gaps n in
  let m = Array.length g in
  for i=0 to m-1 do
    insertion_sort n ~gap:g.(i) array;
  done;
  Printf.printf "%d\n" m;
  Array.iteri
    (fun i x -> Printf.printf (if i=m-1 then "%d\n" else "%d ") x)
    g;
  Printf.printf "%d\n" !cnt;
  array

let () =
  let n = read_int () in
  let rec read a = function
      i when i = n -> a
    | i -> a.(i) <- (read_int ());
      read a (i+1) in
  let a = read (Array.make n 0) 0 in
  Array.iter (Printf.printf "%d\n") (shell_sort a n)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a,b;
  while (1){
    int c=0;
  cin>>a>>b;
     if (a == 0 && b == 0) break;
  for(int i=1;i<=a;i++){
    for(int j=i+1;j<=a;j++){
      for(int n=j+1;n<=a;n++){
	if(i+j+n ==b) c++;
	//  cout<<i<<"+"<<j<<"+"<<n<<"="<<b<<endl;}// 
      }
    }
  }
  cout<<c<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 1e9 + 12;

vector<vector<int>> v,dp;
int n;
vector<char> choices{'a','b','c'};
int memo(int i=n, char last = 'z'){
    if(i==0)
        return 0;
    if(last-'a' < 3 && dp[i][last-'a']!=INF){
        return dp[i][last-'a'];
    }
    int ans = 0;
    for(char c: choices){
        if(last!=c){
            ans = max(ans, memo(i-1,c) + v[i][c-'a']);
        }
    }
    return dp[i][last-'a'] = ans;
}

void solve() {
    cin >> n;
    v.resize(n+1,vector<int>(3));
    dp.assign(n+1, vector<int>(3,0));
    for(int i=1; i<=n; i++){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
//    cout << memo();
    int ans = 0;
    for(int i=0; i<3; i++){
        dp[1][i] = v[1][i];
    }
    for(int i=2; i<=n; i++){
        for(char last: choices){
            for(auto c: choices){
                if(last == c) continue;
                dp[i][last-'a'] = max(dp[i][last-'a'], dp[i-1][c-'a'] + v[i][last-'a']);
            }
        }
    }
    for(int i=0; i<3; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i=1;i<=n;++i) {
        for (int j=0;j<3;++j) {
            if      (j == 0) dp[i][j] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
            else if (j == 1) dp[i][j] = max(dp[i - 1][2] + b[i], dp[i - 1][0] + b[i]);
            else             dp[i][j] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
        }
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

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

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int n;
string s;
int dp[222222][5];

int dfs(int idx, char old) {
  if (idx >= s.size()) {
    return 0;
  }

  if (dp[idx][old] != -1) {
    return dp[idx][old];
  }

  int ret = 0;

  int a = dfs(idx+1, '#') + (s[idx] == '.');
  int b = (old == '#' ? 1e18 : dfs(idx+1, '.') + (s[idx] == '#'));
  ret += min(a, b);
  // dbg3(idx, old, ret)

  return dp[idx][old] = ret;
}

signed main() {
  cin >> n >> s;
  s = '*' + s;

  rep (i, 222222) rep (j, 5) dp[i][j] = -1;

  int ans = dfs(1, '*');

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
double p,e,t;

double solve(int k, double l, double r){
	double mid = (l +r) /2;
	if(k == 0){
		if(abs(t-mid) < e) return 1;
		else return 0;
	}
	if(t < l && abs(t-l) > e) return 0;
	if(t > r && abs(t-r) > e) return 0;
	double pl,pr;
	if(t < mid){
		pl = 1-p;
		pr = p;
	}else{
		pl = p;
		pr = 1-p;
	}
	return pl*solve(k-1, l, mid) +pr*solve(k-1, mid, r);
}

int main(){
	int k;
	double l,r;
	cin >> k >> l >> r >> p >> e >> t;
	cout << fixed << setprecision(10);
	cout << solve(k, l, r) << endl;
	return 0;
}


Measured memory_bytes: 3288