akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	if (s == "Sunny")cout << "Cloudy" << "\n";
	else if (s == "Cloudy")cout << "Rainy" << "\n";
	else cout << "Sunny" << "\n";


}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

struct edge{
    int from, to, cost;
    edge(int to, int cost): to(to), cost(cost) {}
};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr LL INF = 1000000000000000;

template<class T> inline T sqr(T x) {return x*x;}

template <typename T = pair<LL, LL>>
void Dijkstra(int s, vector<edge> g[], LL d[] = nullptr, LL numv = 0, LL prev[] = nullptr) {
    priority_queue<T, vector<T>, greater<T>> q;
    for (int i = 0; i < numv; ++i) d[i] = INF;
    d[s] = 0;
    q.emplace(0,s);

    while (!q.empty()) {
        T p = q.top(); q.pop();
        LL v = p.second; // vertex
        if (d[v] < p.first) continue;
        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.emplace(d[e.to], e.to);
                prev[e.to] = v;
            }
        }
    }
}
/*
struct S {
    int u,v,a,b;
};
*/

void solve() {
    LL df[100001], db[100001], prev[100001];
    vector<edge> gf[100001], gb[100001];
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    int u,v,a,b;
    //vector<S> s(m);
    REP(i,0,m) {
        cin >> u >> v >> a >> b;
        gf[u-1].pb(v-1,a);
        gf[v-1].pb(u-1,a);
        gb[u-1].pb(v-1,b);
        gb[v-1].pb(u-1,b);
        /*
        i.u = u;
        i.v = v;
        i.a = a;
        i.b = b;
        */
    }
    Dijkstra(s - 1, gf, df, n, prev);
    Dijkstra(t - 1, gb, db, n, prev);
    VLL diff(n);
    

    
    REP(i,0,n) diff[i] = df[i] + db[i];

    /*
    REP(i,0,n) cout << df[i] << " " << db[i] << " " << diff[i] << endl;
    cout << "---" << endl;
    */

    RREP(i,0,n-1) diff[i] = min(diff[i], diff[i+1]);

    /*
    REP(i,0,n) cout << df[i] << " " << db[i] << " " << diff[i] << endl;
    cout << "---" << endl;
    */

    REP(i,0,n) cout << 1000000000000000 - diff[i] << endl;
}

int main() {
    solve();
    
    return 0;
}

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

void solve(long long A, long long B) {
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int>::iterator it;
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
    }
    it=unique(begin(vec), end(vec));
    vec.erase(it, end(vec));
    for (it=begin(vec); it < end(vec); it++) {
        if (it == --end(vec))
            cout << *it << endl;
        else cout << *it << " ";
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n,q;
std::vector<int> g[N];
int sz[N],pos[N];
std::vector<int> ord;
int ans[N];
void dfs(int u,int p){
	pos[u]=sz(ord);
	ord.pb(u);
	sz[u]=1;
	for(auto v : g[u]){
		if(v!=p){
			dfs(v,u);
			sz[u]+=sz[v];
		}
	}
}
int main()
{
  

    	scanf("%d %d",&n,&q);

    	for(int i=1;i<n;i++){
    		int a,b;
    		scanf("%d %d",&a,&b);
    		g[a].pb(b);
    		g[b].pb(a);
    	}
    	dfs(1,0);
    	while(q--){

    		int u , x;
    		scanf("%d %d",&u,&x);
    		ans[pos[u]]+=x;
    		ans[pos[u]+sz[u]]-=x;
    	}

    	for(int i=0;i<n;i++){
    		if(i)ans[i]+=ans[i-1];
    	}

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

Measured memory_bytes: 32120
//template.cpp
#include <bits/stdc++.h>
using namespace std;
 
#define lll long long int  
#define mp make_pair
#define pb push_back
 
#define fl(i,n) for (i=0;i<n;i++)
#define fl1(i,n) for (i=1;i<=n;i++)
#define fla(i,n,a) for (i=a;i<n;i++)
#define flr(i,n) for (i=n-1;i>=0;i--)
#define fl1r(i,n) for (i=n;i>=1;i--)
#define flar(i,n,a) for (i=n-1;i>=a;i--)
#define mem(a,i) memset(a,i,sizeof(a))
 
typedef pair<int,int> pii;
typedef pair<lll,lll> pll;
typedef pair<lll,int> pli;
typedef map<lll, lll> mll;
typedef map<int, int> mii;
typedef vector<pll> vpll;
typedef vector<lll> vll;
 
#define gcd __gcd
#define debug(x) cout<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl
#define debug4(x,y,z,P) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#P<<" :: "<<P<<endl
#define debug5(x,y,z,P,O) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#P<<" :: "<<P<<"\t"<<#O<<" :: "<<O<<endl
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bb begin()
#define ee end()
 
#define MOD 1000000007
#define MAX 300001
 
lll aA[MAX], aB[MAX], aC[1001][1001];
vll vA, vB;
lll T,n,i,j,k,a,b,c,m,u,v,x,y,l,r,s,e,ans;
string sA, sB, sC[MAX];
 
int main(){
 
    boost;
    cin >> n >> m;
    map<int, int> mp;
    fl(i, m){
        cin >> x >> y;
        a = min(x, y);
        b = max(x, y);

        if(a == 1){
            mp[b]++;
        } else {
            mp[a]++; mp[b]++;
        }
    }
    a = 0;
    for(auto k : mp){
        if(k.second % 2){
            a = 1;
            break;
        }
    }
    if(a) cout << "NO" << endl;
    else cout << "YES" << endl;
    
    return 0;
} 


Measured memory_bytes: 8448
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

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

  vector<vector<int>> s(M);
  vector<int> pm(M);

  REP(m,M){
    int km;
    cin >> km;
    REP(k,km){
      int tmp;
      cin >> tmp;
      s[m].push_back(tmp-1);
    } 
  }

  REP(m,M) cin >> pm.at(m);

  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
    vector<int> S(N);
    REP(n,N) S[n] = 0;
    for (int i = 0; i < N; ++i) if (bit & (1<<i)) S[i] = 1;

    int count = 0;
    REP(m,M){
      int nONswitch = 0;
      REP(km,s[m].size()){
        if(S[s[m][km]] == 1) nONswitch +=1;
      }
      if (nONswitch%2 == pm[m]) count +=1;
    }
    if(count == M) ans += 1;
    
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x=0;
  int N=0;
  int b=0;
  int list[100]={0};
  scanf("%d %d",&x,&N);
  int check[100][2] ={0};
  //リストに値打ち込み
  if(N!=0){
    for(int i=0;i<N;i++){
     scanf("%d ",&b);
     list[i]=b;
   }
  }
  //計算
  for(int i=0;i<N;i++){
    if(x-list[i]>0){
      check[x-list[i]][0] = 1;
    }else if(x-list[i]<0){
      check[-(x-list[i])][1] = 1;
    }else{
      check[x-list[i]][0] = 1;
      check[x-list[i]][1] = 1;
    }
  }
  for(int i=0;i<=N;i++){
    if(check[i][0]==0){
      printf("%d",x-i);
      break;
    }else if(check[i][1]==0){
      printf("%d",x+i);
      break;
    }
  }
  /*
  printf("%d",x);
  printf("%d",check[0][0]);
  printf("%d",check[0][1]);
  /*
  for(int i=0;i<N;i++){
    if(check[i][0]==0){
      printf("%d",x-i);
    }else if(check[i][1]==0){
      printf("%d",x+i);
    }
  }
  */
  
}

Measured memory_bytes: 2156
import sys
import itertools

sys.setrecursionlimit(3 * 10**5)


class Node:
  def __init__(self, color):
    self.color = int(color) - 1
    self.children = []

  def add_child(self, node):
    self.children.append(node)

  @staticmethod
  def prepare_nodes(n):
    nodes = tuple(map(Node, input().split()))
    for _ in range(n - 1):
      a, b = map(lambda x: int(x) - 1, input().split())
      nodes[a].add_child(nodes[b])
      nodes[b].add_child(nodes[a])

    return nodes


def main():
  n = int(input())
  nodes = Node.prepare_nodes(n)

  dp = [0 for _ in range(n)]
  ans_list = [n*(n + 1) // 2 for _ in range(n)]

  def update_ans(s, color):
    ans_list[color] -= (s + dp[color]) * (s + dp[color] + 1) // 2

  def dfs(s, node, parent):
    color = node.color
    pre_s = s + dp[color]
    for child in node.children:
      if child == parent: continue

      dp[color] = -s
      s = dfs(s, child, node)
      update_ans(s, color)

    s += 1
    dp[color] = pre_s - s

    return s

  s = dfs(0, nodes[0], Node(-1))

  for i in range(n):
    update_ans(s, i)
    print(ans_list[i])


main()


Measured memory_bytes: 306816
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int d[n];
    rep(i, n)   cin >> d[i];
    sort(d, d+n);
    int overlap = 0;
    rep(i, n-1){
        if(d[i] == d[i+1])  overlap++;
    }
    cout << n - overlap << endl;
    return 0;
}

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

int main()
{
	int A, B;
	std::cin >> A >> B;

	if (A <= 8 && B <= 8)
		std::cout << "Yay!" << std::endl;
	else
		std::cout << ":(" << std::endl;
	return 0;
}

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

int main()
{
    int n, m, d;

    cin >> n >> m;

    bool a[n+2];
    for( int i = 0; i < n + 2; i++ )
        a[i] = 0;
    a[0] = a[n+1] = 1;

    int ma = 0;
    for( int i = 0; i < m; i++ )
    {
        cin >> d;
        if( i == 0 )
            ma = d - 1;
        if( i == m - 1 )
            ma = max( ma, n - d );
        a[d] = 1;
    }

    int sum = 0;
    for( int i = 0; i < n + 2; i++ )
    {
        if( a[i] )
            sum = 0;
        if( !a[i] )
            sum++;
        if( ma < ( sum + 1 ) / 2 )
            ma = ( sum + 1 ) / 2;
    }

    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b; cin>>a>>b;
    a--; b--;
    cout<<"100 100"<<endl;
    for(int i=0;i<25;i++){
        for(int j=0;j<50;j++){
            cout<<"#";
            if(a>0){
                cout<<".";
                a--;
            }else{
                cout<<"#";
            }
        }
        cout<<endl;
        for(int j=0;j<100;j++){
            cout<<"#";
        }
        cout<<endl;
    }
    for(int i=0;i<25;i++){
        for(int j=0;j<100;j++){
            cout<<".";
        }
        cout<<endl;
        for(int j=0;j<50;j++){
            cout<<".";
            if(b>0){
                cout<<"#";
                b--;
            }else{
                cout<<".";
            }
        }
        cout<<endl;
    }
    return 0;
}


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

int main()
{
    int A,B,C;
    while(~scanf("%d%d%d",&A,&B,&C))
    {
        if(C>=A&&C<=B)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
import itertools

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    p = LI()
    ps = sorted(p)
    ans = 0

    for i in range(K):
        ans += ps[i]

    print(ans)
    #print(len(clist))
    #print(sum(clist[2]))



if __name__ == "__main__":
	main()

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


int main(){
    long long N, A;
    long long step_tot = 0;
    long long step, mae = 0;

    std::cin >> N;
    for(int i = 0; i < N; i++){
        std::cin >> A;
        if(A < mae){
            step_tot = step_tot + mae - A;
        }

        if(A > mae){
            mae = A;
        }
    }

    std::cout << step_tot;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,A,B,C,D;
    string S;
    bool ok = true;
    cin >> N >> A>>B>>C>>D>>S;
    for(ll i = A - 1;i < max(C,D) - 2;i++){
        if(S[i] == '#' && S[i + 1] == '#')ok = false;
//        cout << S[i] << S[i + 1] << endl;
    }
    if(ok){
        if(C < D){
            cout << "Yes" << endl;
        }
        else{
            bool ans = false;
            for(ll i = B - 1;i <= D - 1;i++){
                if(S[i] == '.' && S[i - 1] == '.' && S[i + 1] == '.')ans = true;
            }
            if(ans)cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6;
int a[N+5];
int dp[N+5];
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout << dp[n-1] << endl;	
	return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  long long min = INF;
  std::vector<long long> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  VSORT(h);
  for (int i = 0; i < n-k+1; i++) {
    min = min > h[i+k-1] - h[i] ? h[i+k-1] - h[i] : min;
  }

  cout << min << endl;
}


Measured memory_bytes: 1024
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(int(i) for i in input().split()) for _ in range(N)]

ans=-10**10
for i in range(1,1<<10):
    prof=0
    for j,f in enumerate(F):
        prof+=P[j][bin(i&f).count("1")]
    ans=max(ans,prof)

print(ans)

Measured memory_bytes: 3064
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    int res = 2e9 + 5;
    for (int a = -1; a <= 1; a += 2)
        for (int b = -1; b <= 1; b += 2) {
            int xp = x * a, yp = y * b;
            if (xp <= yp) {
                res = min(res, (a == -1) + (b == -1) + yp - xp);
            }
        }
    cout << res << endl;
}


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


def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for j in A:
        print(j)


m = int(input())
lst = []
for i in range(m):
    lst.append(int(input()))

cnt = 0
shellSort(lst, m)


Measured memory_bytes: 45512
N, M, C = gets.chomp.split(' ').map(&:to_i)
B = gets.chomp.split(' ').map(&:to_i)
ans = 0
input = Array.new(N) { gets.chomp.split(' ').map(&:to_i) }
input.each do |i|
  sum = 0
  i.each_with_index do |j, index|
    sum += j * B[index]
  end
  new_sum = sum + C
  ans += 1 if new_sum > 0
end
p ans


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;
  map<char, int> m;
  REP(i, SZ(s)) {
    m[s[i]]++;
  }
  ll ans = 1;
  MFOR(i, m) {
    ans *= i->second + 1;
    ans %= MOD;
  }
  ans--;
  cout << ans << endl;
}


Measured memory_bytes: 512
import math

n, d = map(int, input().split())
X = []

def dis(a, b):
  t = 0
  for i in range(d):
    t += (a[i] - b[i])**2
  t = t**(0.5)
  return t
C = []
for i in range(n):
  X.append(list(map(int, input().split())))
for i in range(n-1):
  for j in range(i+1, n):
    C.append(dis(X[i], X[j]))
ans = 0
for i in C:
  if int(i) == math.ceil(i):
    ans += 1
print(ans)

Measured memory_bytes: 3188
INF = 10**18

N, M = map(int,input().split())

A = []
B = []
C = []

for _ in range(M):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
    c = tuple(map(int,input().split()))
    C.append(c)
    
dp = [[INF for j in range(2**N)] for i in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    s = 0
    for k in range(B[i]):
        s += 2**(C[i][k] - 1)
    for j in range(2**N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | s] = min(dp[i + 1][j | s], dp[i][j] + A[i])
        
res = dp[M][2**N - 1]

print(res if res != INF else -1)

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n,m,cnt;
int k,t,u[N];
int p[N],sz[N];

int get (int v) {
        if (v == p[v])
                return v;
        return p[v] = get(p[v]);
}
void unite (int x,int y) {
        x = get(x);
        y = get(y);

        if (x != y) {
                if (sz[x] < sz[y])
                        swap(x,y);
                p[y] = x;
                sz[x] += sz[y];
        }
}
set<int> st;

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

        for (int i = 1; i <= n + m; i ++)
                p[i] = i,sz[i] = 1;

        for (int i = 1; i <= n; i ++) {
                cin >> k;
                for (int j = 1; j <= k; j ++) {
                       cin >> t;
                       unite(i,t + n);
                }
        }
        for (int i = 1; i <= n; i ++) {
                int o = get(i);
                if (!u[o])
                        cnt ++,u[o] = 1;
                if (cnt >= 2) {
                        cout << "NO";
                        return 0;
                }
        }
        if (cnt == 1)
                cout << "YES" << endl;
        else
                cout << "NO" << endl;
}


Measured memory_bytes: 4352
number = int(input())

count = 0

if number >=0 and number < 10:  
    count+=number

elif number >=10 and number < 100:  
    count+=9

elif number >= 100 and number < 1000:
    count+=((number - 100) + 1)
    count+=9

elif number >= 1000 and number < 10000:
    count+=(9 + 900)

elif number >= 10000 and number < 100000:
    count=+((number - 10000) + 1)
    count+=(9 + 900)

elif number == 100000:
    count+=9+900+90000 

print(count)

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

int main(){
    int n,cnt = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++){
        if(((int)log10(i)+1)%2) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        long power = 1;
        double mod = Math.pow(10, 9) + 7;
        for(int i=1; i<=N; i++){
            power *= i;
            power %= mod;
        }
        System.out.println(power);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

vector<ll> fact, inv;

ll modInv(ll a, ll b = MOD-2) {
	if (b & 1) return a * modInv(a, b^1) % MOD;
	else if (b == 0) return 1;
	else return modInv(a*a % MOD, b / 2);
}
ll choose(int a, int b) {
	if (a < b) return 0;
	ll dv = inv[a-b] * inv[b] % MOD;
	return fact[a] * dv % MOD;
}

//   \sum_{v = 0}^{t} \sum_{s = 0}^{v} \sum_{c = k}^{n} -1^{c-k} (n choose k) (n-k choose c-k) ((n-1 + v-sc choose n-1) - (n-1 + v-k-sc choose n-1))
// = \sum_{c = k}^{n} -1^{c-k} (n choose k) (n-k choose c-k) \sum_{v = 0}^{t} \sum_{s = 0}^{v/c} ((n-1 + v-sc choose n-1) - (n-1 + v-k-sc choose n-1))
// = \sum_{c = k}^{n} -1^{c-k} (n choose k) (n-k choose c-k) \sum_{s = 0}^{t/c} \sum_{x = t-k-sc}^{t-sc} (n-1 + x choose n-1)
ll solve(int n, int k, int t) {
	ll res = choose(n+t, n);
	for (int c = k; c <= n; ++c) {
		ll v1 = ((c-k) % 2 ? -1 : 1) * choose(n, k) * choose(n-k, c-k) % MOD;
		ll v2 = 0;
		for (int s = 0; s*c <= t; ++s) v2 += choose(n + t - s*c, n);
		for (int s = 0; s*c <= t-k; ++s) v2 -= choose(n + t-k - s*c, n);
		res = (res - v1 * (v2 % MOD)) % MOD;
	}
	return res + MOD*(res < 0);
}

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

	int n, m, v0, v1;
	cin >> n >> m >> v0 >> v1;

	fact.resize(n + v1 + 1, 1);
	inv.resize(n + v1 + 1, 1);
	for (int i = 1; i <= n + v1; ++i) {
		fact[i] = (fact[i-1] * i) % MOD;
		inv[i] = modInv(fact[i]);
	}

	ll res = solve(n, m, v1) - solve(n, m, v0-1);
	cout << res + MOD*(res < 0) << '\n';
}


Measured memory_bytes: 9600
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;
        String str = "";


        String a = sc.next();
        String b = sc.next();

        if( a.equals( b ) ) System.out.print("H");
        if( !a.equals( b ) ) System.out.print("D");


        System.out.println();
    }

}

Measured memory_bytes: 21716
def cost(n, nums):
    dp = [0 for _ in range(n)]
    dp[0] = 0
    dp[1] = abs(nums[1] - nums[0])
    for i in range(2, n):
        dp[i] = min(
            dp[i-1] + abs(nums[i]-nums[i-1]),
            dp[i-2] + abs(nums[i]-nums[i-2]))
    return dp[-1]

n = int(input())
nums = [int(i) for i in input().split()]
print(cost(n, nums))

Measured memory_bytes: 13924
N,K = list(map(int,input().split()))
xs = list(map(int,input().split()))

ans = 10 ** 10
for  i,x  in enumerate(xs):
    if N == 1:
        ans = abs(x)
    if i +  K  > N and i > 0:
        break
    num = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i])
    num1 = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i + K -1])
    ans = min([num,num1,ans])
print(ans)

Measured memory_bytes: 14224
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<10, mod = 1e9 + 7, i2 = (mod+1)/2;
int n, h, w, mat[maxn][maxn], a[maxn*maxn], cur = 1;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> h >> w >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= h; i++)
		for(int j = (i&1) ? 1 : w; (i&1) ? j <= w : j; (i&1) ? j++ : j--) {
			mat[i][j] = cur;
			cur += --a[cur] == 0;
		}
	for(int i = 1; i <= h; i++, cout << '\n')
		for(int j = 1; j <= w; j++)
			cout << mat[i][j] << " ";
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int r, s, p;
int points(char c){
  if(c == 's')return s;
  if(c == 'p')return p;
  if(c == 'r')return r;
}
int main(){
  int n, k, res;
  string t;
  cin>>n>>k;
  cin>>r>>s>>p;
  cin>>t;
  res = 0;
  string x;
  x = t;
  for(int i = 0; i < n; ++i){
    if(t[i] == 'r'){
      res += points('p');
      x[i] = 'p';
    }
    if(t[i] == 'p'){
      res += points('s');
      x[i] = 's';
    }
    if(t[i] == 's'){
      res += points('r');
      x[i] = 'r';
    }
  }
  for(int i = k; i < n; ++i){
    if(t[i - k] == t[i]){
      if(t[i] == 'r'){
	if(x[i - k] == 'p'){
	  x[i] = t[i];
	  res -= points('p');
	}
      }
      if(t[i] == 'p'){
	if(x[i - k] == 's'){
	  x[i] = t[i];
	  res -= points('s');
	}
      }
      if(t[i] == 's'){
	if(x[i - k] == 'r'){
	  x[i] = t[i];
	  res -= points('r');
	}
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    vector<int> niz(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> niz[i];
        sum += niz[i];
    }
    sort(niz.begin(), niz.end());
    if (sum % 10)
    {
        cout << sum;
        return 0;
    }
    for (auto x : niz)
    {
        if (x % 10)
        {
            cout << sum - x;
            return 0;
        }
    }
    cout << 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, A;
	cin >> N >> A;
	vector<map<int, ll>> mp(N + 1);
	mp[0][0] = 1;
	REP(i,N){
		int x;
		cin >> x;
		for (int j = i;j >= 0;j--) {
			for (auto it = mp[j].begin();it != mp[j].end();it++) {
				mp[j + 1][it->first + x] += mp[j][it->first];
			}
		}
	}
	ll res = 0;
	for (int i = 1;i <= N;i++) {
		res += mp[i][i*A];
	}
	cout << res << "\n";
	/*for (int i = 0;i <= N;i++) {
		for (auto it = mp[i].begin();it != mp[i].end();it++) {
			printf("mp[%d][%d] = %lld\n", i, it->first, it->second);
		}
	}*/

	return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInt();
            var number = new bool[1000001];
            number[s] = true;
            var cnt = 1;
            while (true)
            {
                cnt++;
                if (s % 2 == 0)
                {
                    s = s / 2;
                    if (number[s]) { Console.WriteLine(cnt); return; }
                    else number[s] = true;
                }
                else
                {
                    s = 3 * s + 1;
                    if (number[s]) { Console.WriteLine(cnt); return; }
                    else number[s] = true;
                }
            }
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

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

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; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while(true)
    {
        int n; cin >> n;
        if(n == 0) break;
        vd x(n), y(n), z(n), r(n), d(n, INF);
        priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;
        double ans = 0;
        REP(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];
        d[0] = 0;
        q.push(mp(0, 0));
        while(!q.empty())
        {
            pair<double, int> p = q.top(); q.pop();
            if(p.fi > d[p.se]) continue;
            ans += d[p.se];
            REP(i, n)
            {
                if(chmin(d[i], max(sqrtl(powl(x[i]-x[p.se], 2)+powl(y[i]-y[p.se], 2)+powl(z[i]-z[p.se], 2)) - r[i] - r[p.se], (double)0.0)))
                {
                    q.push(mp(d[i], i));
                }
            }
        }
        cout << fixed << setprecision(3) << ans << endl;
    }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int as[5100];
bool dp[5100][5100], dp2[5100][5100];

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

    int N, K;
    std::cin >> N >> K;

    for(int i=1;i<=N;++i){
        std::cin >> as[i];
    }

    dp[0][0] = 1;
    for(int i=1;i<=N;++i){
        for(int j=0;j<K;++j){
            dp[i][j] |= dp[i-1][j];
            if(j - as[i] >= 0){
                dp[i][j] |= dp[i-1][j-as[i]];
            }
        }
    }

    dp2[N+1][0] = 1;
    for(int i=N;i>=1;--i){
        for(int j=0;j<K;++j){
            dp2[i][j] |= dp2[i+1][j];
            if(j - as[i] >= 0){
                dp2[i][j] |= dp2[i+1][j-as[i]];
            }
        }
    }    
    
    int res = 0;
    for(int i=1;i<=N;++i){        
        queue<int> q;
        int k = K - 1;
        bool isNeeded = false;
        for(int j=0;j<K;++j){
            // [lb, ub)
            int lb = max(0, K - as[i] - j),
                ub = K - j;
            
            while(lb <= k && k < ub){
                if(dp2[i+1][k]){
                    q.emplace(k);
                }
                --k;
            }

            if(not q.empty() && (q.front() < lb || ub <= q.front())){
                q.pop();
            }

            if(dp[i-1][j] && not q.empty()){
                isNeeded = true;
            }
        }

        if(not isNeeded){
            // std::cout << "! " << i << std::endl;
            ++res;
        }
    }

    std::cout << res << std::endl;
}


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

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

    vector<int> L(M), R(M);
    for(int i = 0; i < M; i++){
        cin >> L .at(i) >> R .at(i);
    }
    sort (L .begin(), L .end());
    sort (R .begin(), R .end());

    for (int i = 0; i < 1; i++){
        if(L .at(M - 1) > R .at(0) || N < L .at(M - 1)){
            cout << 0 << endl;
            break;
        }
        if(N > R .at(0)){
            cout << R .at(0) - L .at(M - 1) + 1 << endl;
            break;
        }
            if(N <= R .at(0) && N >= L .at(M - 1)){
            cout << N - L .at(M - 1) + 1 << endl;
        }
    }
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
#define mp make_pair
pair<int,int> num[200005];
map<int,int> m; 
int n;
#include<iostream>
using namespace std;
int find( int key)
{
           int left = 0;   //??????,?arr[0]?
           int right = n - 1;//?????????,?arr[n-1],?????n

           //?????????
           while (left <= right)
          {
                    int mid = left + ((right - left) >> 1);//???mid????????while????,??mid??????;???????????2??????,?????????
                    if (num[mid].first > key)//????????????????,??????????????
                   {
                             right = mid - 1;
                   }
                    else if (num[mid].first < key)//????????????????,??????????????
                   {
                             left = mid + 1;
                   }
                    else
                   {
                              return mid;//?????????????
                   }
          }

           //??????????????????????
           return -1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i].first;
		num[i].second=i;
		m[i]=num[i].first;
	}
	sort(num,num+n);
	for(int i=0;i<n;i++){
		int o=num[find(m[i])].first;
		int ans=num[n/2].first;
		if(o>=ans){
			ans=num[n/2-1].first;
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	if(x>=400 && x<=599){
		cout<<8;
	}
	else if(x>=400 && x<=599){
		cout<<8;
	}else if(x>=600 && x<=799){
		cout<<7;
	}else if(x>=800 && x<=999){
		cout<<6;
	}else if(x>=1000 && x<=1199){
		cout<<5;
	}else if(x>=1200 && x<=1399){
		cout<<4;
	}else if(x>=1400 && x<=1599){
		cout<<3;
	}else if(x>=1600 && x<=1799){
		cout<<2;
	}else if(x>=1800 && x<=1999){
		cout<<1;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char getc(int x) {
	if (x <= 26) return 'a' + x - 1;
	else if (x <= 52) return 'A' + x - 27;
	else return '0' + x - 53;
}
vector <string> a;
int query(string x) {
	cout << '?' << ' ' << x << endl;
	int res; read(res);
	return res;
}
string merge(int len, string a, string b) {
	int pos = 0;
	for (auto x : b) {
		while (true) {
			string bak = a;
			a.insert(a.begin() + pos, x), pos++;
			if (query(a) + a.size() == len) break;
			else a = bak;
		}
	}
	return a;
}
int main() {
	int len = 0;
	for (int i = 1; i <= 62; i++) {
		string cur = "";
		for (int j = 1; j <= 128; j++)
			cur.push_back(getc(i));
		int cnt = 128 - query(cur); len += cnt;
		if (cnt != 0) {
			cur.clear();
			for (int j = 1; j <= cnt; j++)
				cur.push_back(getc(i));
			a.push_back(cur);
		}
	}
	while (a.size() >= 2) {
		sort(a.begin(), a.end(), [&] (string a, string b) {
			return a.size() > b.size();
		});
		string s = a.back(); a.pop_back();
		string t = a.back(); a.pop_back();
		a.push_back(merge(len, s, t));
	}
	cout << '!' << ' ' << a.back() << endl;
	return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int arr[10];
	
	for (int a=0;a<3;a++){
		scanf ("%d",&arr[a]);
	}
	
	sort(arr,arr+3);
	
	printf ("%d\n",arr[0]+arr[1]);
	
	return 0;	
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        k: usize,
    }

    let a = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
        1, 51,
    ];
    println!("{}", a[k - 1]);
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

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

    cout << a.at(n-1) - a.at(0) <<endl;

    return 0;
}


Measured memory_bytes: 256
n,m=gets.split.map &:to_i
list=Array.new(n){Array.new}
m.times do |i|
    a,b=gets.split.map &:to_i
    list[a-1] << b
    list[b-1] << a
end
nums=Array.new
orders=Array.new
1.upto(n) do |i|
    nums << i
end
nums.permutation(n){|ary| orders << ary }
orders.keep_if{|order| order[0]==1}
cnt=0
orders.each do |order|
    chk="true"
    0.upto(n-2) do |num|
        unless (list[order[num]-1]).include?(order[num+1])
            chk="false"
            break
        end
    end
    if chk=="true"
        cnt += 1
    end
end

puts cnt

Measured memory_bytes: 7036
def solve():
    n = int(input())
    A = list(map(int, input().split(" ")))
    colors = [False] * 8
    meta = 0
    for a in A:
        if 1 <= a <= 399:
            colors[0] = True
        elif 400 <= a <= 799:
            colors[1] = True
        elif 800 <= a <= 1199:
            colors[2] = True
        elif 1200 <= a <= 1599:
            colors[3] = True
        elif 1600 <= a <= 1999:
            colors[4] = True
        elif 2000 <= a <= 2399:
            colors[5] = True
        elif 2400 <= a <= 2799:
            colors[6] = True
        elif 2800 <= a <= 3199:
            colors[7] = True
        else:
            meta += 1

    cnt = 0
    for c in colors:
        if c == True:
            cnt += 1

    print(max(1, cnt), cnt + meta)


solve()

Measured memory_bytes: 3188
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[300005];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",a+i);
        if(abs(i-a[i])&1){
            puts("No");
            return 0;
        }
    }
    for(int i=1;i<=1200;++i){
        //for(int j=2;j<n;++j)if(a[j-1]>a[j]&&a[j]>a[j+1])swap(a[j-1],a[j+1]),++j;
        for(int j=n-1;j>1;--j)if(a[j-1]>a[j]&&a[j]>a[j+1])swap(a[j-1],a[j+1]),--j;
    }
    bool ok=1;
    for(int i=2;i<n;++i)if(a[i-1]>a[i+1]&&(a[i-1]<a[i]||a[i]<a[i+1]))ok=0,i=n;
    if(ok)puts("Yes");
    else puts("No");
	//system("pause");
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, d, x;
    cin >> n >> d >> x;
    int acum = 0;
    fo(i, n) {
        int a;
        cin >> a;
        acum++;
        acum += ((d - 1) / a);
    }

    cout << acum + x << endl;

    return 0;
}

Measured memory_bytes: 256