akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
	vector<int> par, rank;
	
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
		 par[i] = i;
		 rank[i] = 0;
		}
	}
	
	int operator[] (int x) {
		return find(x);
	}
	
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		
		if (rank[x] < rank[y]) swap(x, y);
		
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
	
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	
};

template <typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
	}
	
	void update(int i, T x) {
		i += n - 1;
		dat[i] = min(dat[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	
	void set(int i, T x) {
		dat[i + n - 1] = x;
		update(i, x);
	}
	
	// 探索範囲[a,b), 現在見ているkノード[l,r)
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
};

using pll = pair<ll, ll>;
using ll3 = tuple<ll, ll, ll>;
int N, D;
vector<int> A;

int main() {
	cin >> N >> D;
	A.resize(N);
	REP(i, N) scanf("%d", &A[i]);
	
	vector<int> ord(N);
	iota(ALL(ord), 0);
	
	sort(ALL(ord), [&](int x, int y) {
		return A[x] > A[y];
	});
	
	vector<ll3> edge;
	
	SegTree<pll> lseg(N, pll(longINF, -1));
	SegTree<pll> rseg(N, pll(longINF, -1));
	
	REP(i, N) lseg.update(i, pll(A[i] + (ll)i * D, i));
	REP(i, N) rseg.update(i, pll(A[i] - (ll)i * D, i));
	
	for (int idx : ord) {
		pll cur = lseg.query(idx + 1, N);
		if (~cur.se) edge.emplace_back(A[idx] - (ll)idx * D + cur.fi, idx, cur.se);
		cur = rseg.query(0, idx);
		if (~cur.se) edge.emplace_back(A[idx] + (ll)idx * D + cur.fi, idx, cur.se);
		lseg.set(idx, pll(longINF, -1));
		rseg.set(idx, pll(longINF, -1));
	}
	
	sort(ALL(edge));
	
	UnionFind uf(N);
	ll ans = 0;
	for (ll3 &cur : edge) {
		ll cost, x, y;
		tie(cost, x, y) = cur;
		if (uf.same(x, y)) continue;
		uf.unite(x, y);
		ans += cost;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 32620
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<20)
 
int main(){
  int N;
  while(1){
    cin >> N;
    if(N == 0) break;
    int a[40002]={0};
    int b[40002]={0};
    for(int i=1;i<=N;i++){
      cin >> a[i];
    }
    for(int i=1;i<=N;i++){
      cin >> b[i];
    }
    a[0] = b[0] = INF;
    sort(a,a+N+1,greater<int>() );
    sort(b,b+N+1,greater<int>() );
    int idx = 1;
    int losecnt[40002]={0};
    int s=1,t=1;
    while(s <= N && t <= N){
      while(a[s] > b[t] && s <= N) s++;
      if(s <= N && b[t] >= a[s]){
    losecnt[s]++;
    s++; t++;
      }
    }
    for(int k=1;k<=N;k++){
      losecnt[k] += losecnt[k-1];
    }
    int ret = -1;
    for(int k=1;k<=N;k++){
      if(k-losecnt[k] >= (k+2)/2) {
    ret = k;
    break;
      }
    }
    if(ret==-1||ret==N) cout << "NA" << endl;
    else cout << ret << endl;
  }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cmath>
#define ll long long
using namespace std;
const int maxn = 105;
int N;
int a[maxn],x[maxn],y[maxn];
ll ans;
int main(){
        srand(19260817);
        scanf("%d", &N);
        for(int i=1;i<=N;i++) scanf("%d%d",&x[i],&y[i]);
        for(int i=1;i<=N;i++) a[i]=i;
        for(int i=1;i<=10000;i++){ 
                random_shuffle(a+1, a+N+1);
                int tx=0,ty=0;
                ll cur=0;
                for(int j=1;j<=N;j++){
                        int id=a[j];
                        int x1=tx+x[id],y1=ty+y[id];
                        ll tmp=1ll*x1*x1+1ll*y1*y1;
                        if(tmp>cur) tx=x1,ty=y1,cur=tmp;
                }
                ans=max(ans,cur);
        }
        printf("%.48lf\n", sqrt(1.0*ans));
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int k, a, b, i, len, flag=0;
	
	scanf("%d %d %d", &k, &a, &b);
	
	len=b/k+1;
	
	for(i=1; i<=len; i++){
		if((k*i>=a)&&(k*i<=b)){
			flag=1;
		}
	}
	
	if(flag==1){
		printf("OK");
	}else if(flag==0){
		printf("NG");
	}
	
	return 0;
}

Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=10005;
int n,k;
bool vis[20];
int sta[max_n],tot;
int nex[max_n];
int ans[max_n];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        int x;scanf("%d",&x);
        vis[x]=true;
    }
    while(n){
        sta[++tot]=n%10,n/=10;
    }
    for(int i=1;i<=tot/2;i++)swap(sta[i],sta[tot+1-i]);
    int mx=0;
    for(int i=0;i<=9;i++)if(!vis[i])mx=max(mx,i);
    nex[tot+1]=tot+1;
    for(int i=tot;i>=1;i--){
        if(sta[i]==mx)nex[i]=nex[i+1];
        else nex[i]=i;
    }
    if(nex[1]==tot+1||sta[nex[1]]<mx){
        bool f=false;
        for(int i=1;i<=tot;i++){
            for(int j=0;j<=9;j++){
                if(vis[j])continue;
                if(f==true){
                    ans[i]=j;
                    break;
                }
                else{
                    if(j<sta[i])continue;
                    if(j==sta[i]){
                        if(nex[i+1]==tot+1||sta[nex[i+1]]<mx){
                            ans[i]=j;
                            break;
                        }
                    }
                    else{
                        ans[i]=j;
                        f=true;
                        break;
                    }
                }
            }
        }
    }
    else{
        for(int i=1;i<=9;i++)if(!vis[i])mx=min(mx,i);
        ans[0]=mx;
        if(!vis[0])mx=0;
        for(int i=1;i<=tot;i++)ans[i]=mx;
    }
    int res=0;
    for(int i=0;i<=tot;i++)res=res*10+ans[i];
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>
#include <numeric>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);j++)
#define frk(n) for(k=0;k<(n);k++)
#define frl(n) for(l=0;l<(n);l++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


//#define int long long

using namespace std;


const int MAX = 510000;

ll mod_inverse(int a,int M){
	int x=M-2;
	ll temp=a;
	ll ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed compare_int(const void *a, const void *b)
{
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


int gcd(int a,int b){
	while(1==1){
		if(a==0||b==0){
			return a+b;
		}else if(a>b){
			a %= b;
		}else{
			b %= a;
		}
	}
}

signed main(void)
{
	//変数の宣言
	int n,m,a,b;
	int h,w;
	static int s[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;

	//データの読み込み


	scanf("%d %d %d",&m,&a,&b);
	//scanf_s("%d %d %d",&m,&a,&b);


	//scanf("%s",&s);
	//scanf_s("%s",&s,200010);


	/*for(i=0;i<n;i++){
	//scanf("%lld",&a[i]);
	scanf_s("%lld",&a[i]);
	}*/

	/*for(i=0;i<q;i++){
	//scanf("%d",&s[i]);
	scanf_s("%d",&s[i]);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	//	clock_t start=clock();
	//	COMinit();

	if((b/m)*m>=a){
		printf("OK");
	}else{
		printf("NG");
	}
	//printf("\n%d",(b/m)*m);

	//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力

	//printf("%d",(d[i-1][j-1]+1)/2);

	//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 3792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var x = Input.NextLong();
            var list = Input.LongList();
            long count = 0;

            if (list[0] > x) {
                count += list[0] - x;
                list[0] = x;
            }

            for (int i = 0; i < N - 1; i++) {
                if (list[i] + list[i + 1] > x) {
                    count += list[i + 1] + list[i] - x;
                    list[i + 1] = x - list[i];
                }
            }

            Console.WriteLine(count);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 26716
#include<cstdio>

const int MAX_W = 100;

int w,h,n;
int x[MAX_W],y[MAX_W],a[MAX_W];
int xr,xl = 0,yt,yb = 0;
int main(){
	scanf("%d %d %d",&w,&h,&n);
	xr = w;
	yt = h;
	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
		if(a[i] == 1){
			if(xl < x[i]) xl = x[i];
		}
		else if(a[i] == 2){
			if(xr > x[i]) xr = x[i];
		}
		else if(a[i] == 3){
			if(yb < y[i]) yb = y[i];
		}
		else{
			if(yt > y[i]) yt = y[i];
		}
	}
	int lenx = xr - xl;
	int leny = yt - yb;
	if(lenx <= 0 || leny <= 0) printf("0\n");
	else  printf("%d",lenx * leny);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
vector<int> E[400000];
int flag[400000];
int N,M;
bool dfs(int x, int ind){
    if(flag[x]==ind) return true;
    flag[x]=ind;
    for(int &to : E[x]){
        if(flag[to]<1000000&&dfs(to, ind)) return true;
    }
    flag[x]=1000000;
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    string s;
    cin>>s;
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        if(a==b){
            E[N+a].pb(a);
        }
        else if(s[a]==s[b]){
            E[N+a].pb(b);
            E[b+N].pb(a);
        }
        else{
            E[a].pb(b+N);
            E[b].pb(a+N);
        }
    }
    rep(i,0,2*N){
        if(!flag[i]){
            if(dfs(i, i+1)){
                cout <<"Yes"<<"\n";
                return 0;
            }
        }
    }
    cout <<"No"<<"\n";
}

Measured memory_bytes: 27344
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int gcd(int m, int n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

int lcm(int m, int n) {
  return abs(m*n) / gcd(m, n);
}

int main() {
  int N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  int g = gcd(N, M);
  bool ok = true;
  for(int i = 0; i < g; ++i) {
    if(S[i*(N/g)] != T[i*(M/g)]) {
      ok = false;
    }
  }
  if(!ok) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << (long long)N * M/g << std::endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string o, e;
    cin >> o >> e;
    int N = o.size() + e.size();
    rep(0, i, N)
    {
        if (i % 2)
        {
            cout << e.at(i / 2);
        }
        else
        {
            cout << o.at(i / 2);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#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(){
  string s;
  cin>>s;
  if(s.at(1)=='B'){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"ABC"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int a, b, c;
	cin>>a >> b>>c;
	if ((a+b+c) >= 22) cout <<"bust" <<endl;
	else cout << "win" <<endl;
	
	
	
	
	
	
	
	return 0;
}



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

int main(void) {
    int X,T,N;
    
    cin >> N >> X >> T;
    
    if (N <= X) {
        cout << T;
    }else
    {
        if (N % X == 0) {
            cout << (N / X) * T;
        }else
            cout << (N / X) * T + T;
    }
    
    return 0;
}


Measured memory_bytes: 3592
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

short a,b;
inline void solve(){
  IN2(a,b);
  OUT((a+b+1)/2);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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


void solve(long long N, std::vector<long long> A){
    double ans = 0;
    for (int i = 0; i < N; ++i) ans += 1/(double)A[i];
    cout << 1/ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define forit(it,a) for(auto it=(a).begin();it!=(a).end();it++)
#define forC(v) for(auto it = (v).begin();it!=(v).end();it++)cout << *it << " "
#define forM(v) for(auto it = (v).begin();it!=(v).end();it++)cout << it->second << " "
#define fori(i,n) for(auto i = 0 ; i < (n) ; i++)
#define endl "\n"
#define pll pair<ll,ll>

using namespace std;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//freopen("TEXT.txt","r",stdin);
	string  A;
	cin >> A ;
	ll cont=0;
	ll rta = 0;
	fori(i,A.length()){
		if(A[i]=='B')cont++;
		else rta+=cont;
	}
	cout << rta << endl;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<





int main(void){
    ll N;
    cin >> N;
    ll d[N];
    rep(i,N){
        cin >> d[i];
    }

    ll ans = 0;

    rep(i,N){
        rep(j,i){
            if(i!=j){
                ans += d[i]*d[j];
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  int N; cin >> N;
  vector<int> A(N+1);
  rep(i, 1, N + 1) cin >> A[i];
  A.push_back(0);
  vector<int> dif(N+2);
  rep(i, 1, N + 2) {
    dif[i] = abs(A[i] - A[i-1]);
  }
  int sum = accumulate(dif.begin(), dif.end(), 0);
  rep(i, 1, N + 1) {
    int el = dif[i] + dif[i+1];
    int add = abs(A[i-1] - A[i+1]);
    cout << sum - el + add << "\n";
  }
  return 0;
}


Measured memory_bytes: 2040
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

typedef pair<int,int> pii;
const int MAXN=805;
const int INF=0x3f3f3f3f;
#define x first
#define y second

int n,m,K,ans=INF;
int vis[MAXN][MAXN];
char s[MAXN][MAXN];
pii S;
int df[4][2]={{0,-1},{0,1},{-1,0},{1,0}};

int f(int x,int y){
    int len=min(min(x-1,y-1),min(n-x,m-y));
    return len/K+((len%K)?1:0);
}

queue <pii> q;
void bfs(){
    memset(vis,0,sizeof vis);
    q.push(S);
    vis[S.x][S.y]=1;
    while(!q.empty()){
        pii now=q.front(); q.pop();
        ans=min(ans,f(now.x,now.y));
        for(int i=0;i<4;i++){
            int nx=now.x+df[i][0];
            int ny=now.y+df[i][1];
            if(nx<1||ny<1||nx>n||ny>m||vis[nx][ny]||abs(nx-S.x)+abs(ny-S.y)>K||s[nx][ny]=='#') continue;
            vis[nx][ny]=1;
            q.push(make_pair(nx,ny));
        }
    }
}

int main(){

    scanf("%d%d%d",&n,&m,&K);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++)
            if(s[i][j]=='S') S.x=i,S.y=j;
    }
    if(S.x==1||S.x==n||S.y==1||S.y==m) return puts("0"),0;
    bfs();
    printf("%d",ans+1);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    ll N=ii(), M=ii();
    vector<ll> A;
    REP(i,0,N) A.push_back(ii());
    ll s=accumulate(A.begin(),A.end(),0LL);
    sort(A.rbegin(),A.rend());
    if(4*M*A[M-1]<s){
        ose("No");
    }else{
        ose("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,m:usize
   }
   let mut f = 1;
   let mut t = if m % 2 == 0 { m + 1 } else { m };
   for i in 0..m {
      if f == t {
         f = if m % 2 == 0 { m + 2 } else { m + 1 };
         t = 2 * m + 1
      }
      println!("{} {}", f, t);
      f += 1;
      t -= 1;
   }
}


Measured memory_bytes: 2200
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
  
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    vector<int> ms,msprime;

        for(int i=0;;i++){
            if(i==0)ms.pb(7*i+6);
            else {
                if(7*i+1>=300000)break;
                ms.pb(7*i+1);
                ms.pb(7*i+6);
            }
        }
        
        auto isPrime=[&](int x){
            //cout<<sqrt(x)+1<<endl;
            for(int i=0;(ms[i]<=sqrt(x)+1);i++){
                if(x%ms[i]==0){
                    //cout<<ms[i]<<endl;
                    return false;
                }
            }
            return true;
        };

        rep(i,0,ms.size()){
            if(isPrime(ms[i]))msprime.pb(ms[i]);
        }


    int n;
    while(cin>>n && n!=1){
        cout<<n<<":";

        rep(i,0,msprime.size()){
            if(n%msprime[i]==0){
                cout<<" "<<msprime[i];
            }
        }
        cout<<endl;

    }

    return 0;
}



Measured memory_bytes: 3436
import Data.Functor ((<$>))

digits :: Int -> [Int]
digits n = go (abs n) []
  where go n' ds
          | n' < 10   = n' : ds
          | otherwise = go (n' `div` 10) ((n' `mod` 10) : ds)

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  putStrLn . (" " ++) . unwords . map show $ filter p [1..n]
    where p x = x `mod` 3 == 0 || 3 `elem` digits x



Measured memory_bytes: 4044
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const H = args[1].map(arg => parseInt(arg, 10))
	let cnt =0

	for (let i = 0; i < N; i++) {
		let flg = true 

		for (let j = 0; j < i; j++) {
			if (H[j] > H[i]) flg = false
		}

		if (flg) cnt++
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = n;
    int a = 0;
    for (int i = 0; i < n; i++) {
      int c = Integer.parseInt(sc.next());
      m = Math.min(m, c);
      if (m >= c) {
        a += 1;
      }
    }
    System.out.println(a);
  }
}


Measured memory_bytes: 48880
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main() {
	string a, b; cin >> a >> b;
	string tmp; tmp.append(a + b);
	double ans = stoi(tmp);
	int half = sqrt(ans);
	if ( ans == half*half) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int A[1000000], n;
 
int binarySearch(int key) {
    int left = 0, right = n, mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid])return 1;
        if (key > A[mid])left = mid + 1;
        else if (key < A[mid])right = mid;
    }
    return 0;
}
 
int main() {
    int i, q, k, sum = 0;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k))sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 988
#include <iostream>

using namespace std;

int main(){
	int x, y, z;                    //x??¨y??¨z?????£?¨???????
	for(int i = 0; i < 9; i++){     //9?????°?????????(x???1???9???)
		x = i + 1;                  //x???1???9?????£??\??????
		for(int j = 0; j < 9; j++){ //9?????°?????????(y???1???9???)
			y = j + 1;              //y???1???9?????£??\??????
			z = x * y;              //z???x * y?????£??\
			cout << x << "x" << y << "=" << z << endl; 
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
const double eps = 1e-7;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<double, int> di;
#define inf 100000000
const double PI = 2 * acos(0);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("ing.txt", "r", stdin);
   // freopen("outg.txt", "w", stdout);
    ll n, h;
    while (cin >> n >> h) {
        vector<pair<ll, ll> > a(n), b(n);
        for (ll i = 0; i < n; i++) {
            cin >> a[i].first >> b[i].first;
            a[i].second = b[i].second = i;
        }
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());
        ll moves = 0;
        bool done = false;
        ll i = n - 1;
        while (i and b[i] <= a[0]) i--;
        for (ll j = 0; j <= i; j++) {
            h -= b[j].first;
            moves++;
            if (h <= 0) {
                done = true;
                break;
            }
        }
        if (done) {
            cout << moves << "\n";
            continue;
        }
        ll step = (h + a[0].first - 1) / a[0].first;
        h -= step * a[0].first;
        moves += step;
        cout << moves << "\n";
    }

    return 0;

}

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

using namespace std;

using ll = long long;

struct State {
    int at;
    int cost;
    int prev;
    State(int at, int cost, int prev) : at(at), cost(cost), prev(prev) {}
    bool operator>(const State& s) const {
        if (cost != s.cost) return cost > s.cost;
        if (prev != s.prev) return prev > s.prev; //最短経路を辞書順最小にする(省略可)
        return at > s.at;
    }
};

struct Edge {
  int to;
  int cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};

typedef vector<vector<Edge> > AdjList; //隣接リスト

const int INF = 1000000000;
const int NONE = -1;

AdjList graph;

//sは始点、mincは最短経路のコスト、Prevは最短経路をたどる際の前の頂点
void dijkstra(int s, vector<int>& minc, vector<int>& Prev){
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.push(State(s, 0, NONE));
    while(!pq.empty()) {
        State cur = pq.top();
        pq.pop();
        if (minc[cur.at] <= cur.cost) continue;
        minc[cur.at] = cur.cost;
        Prev[cur.at] = cur.prev;
        for(Edge e : graph[cur.at]) {
            int cost = cur.cost + e.cost;
            if (minc[e.to] <= cost) continue;
            pq.push(State(e.to, cost, cur.at));
        }
    }
}

const int MAX_K = 100000;

int solve(int x) {
    int res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    graph.resize(MAX_K);
    for (int i = 0; i < MAX_K; i++) {
        for (int j = 0; j <= 9; j++) {
            int hoge = K * j + i;
            graph[i].emplace_back(hoge / 10, hoge % 10);
        }
    }
    vector<int> minc(MAX_K, INF);
    vector<int> Prev(MAX_K, NONE);
    dijkstra(0, minc, Prev);
    int ans = INF;
    for (int i = 1; i < MAX_K; i++) ans = min(ans, minc[i] + solve(i));
    cout << ans << endl;
    return 0;
}

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

int***dp;
int N,M;

struct Info{
	Info(int arg_col,int arg_value){
		col = arg_col;
		value = arg_value;
	}
	int col,value;
};

int calc(Info left,Info right){
	return (left.value+right.value)*abs(left.col-right.col);
}

void func(){

	for(int i = 1; i <= N+1; i++){
		for(int k = 1; k <= 1000; k++){
			for(int p = 0; p <= M; p++){
				dp[i][k][p] = BIG_NUM;
			}
		}
	}

	vector<Info> V[N+1];

	int num,tmp_col,tmp_value;

	for(int row = 1; row <= N; row++){
		scanf("%d",&num);
		for(int i = 0; i < num; i++){
			scanf("%d %d",&tmp_col,&tmp_value);
			V[row].push_back(Info(tmp_col,tmp_value));
		}
	}

	for(int i = 0; i < V[1].size();i++){
		dp[1][V[1][i].col][M] = 0;
	}

	if(M > 0){
		for(int i = 0; i < V[2].size();i++){
			dp[2][V[2][i].col][M-1] = 0;
		}
	}

	int tmp;

	for(int row = 1; row <= N-2; row++){
		for(int a = 0; a <= M; a++){
			for(int b = 0; b < V[row].size();b++){

				for(int c = 0; c < V[row+1].size();c++){
					tmp = calc(V[row][b],V[row+1][c]);
					dp[row+1][V[row+1][c].col][a] = min(dp[row+1][V[row+1][c].col][a],dp[row][V[row][b].col][a]+tmp);
				}

				if(a != 0){
					for(int c = 0; c < V[row+2].size();c++){
						tmp = calc(V[row][b],V[row+2][c]);
						dp[row+2][V[row+2][c].col][a-1] = min(dp[row+2][V[row+2][c].col][a-1],dp[row][V[row][b].col][a]+tmp);
					}
				}
			}

		}
	}

	for(int a = 0; a <= M; a++){
		for(int b = 0; b < V[N-1].size();b++){

			for(int c = 0; c < V[N].size();c++){
				tmp = calc(V[N-1][b],V[N][c]);
				dp[N][V[N][c].col][a] = min(dp[N][V[N][c].col][a],dp[N-1][V[N-1][b].col][a]+tmp);
			}

			if(a != 0){

				dp[N+1][1][a-1] = min(dp[N+1][1][a-1],dp[N-1][V[N-1][b].col][a]);

			}
		}

	}


	for(int a = 0; a <= M; a++){ //75
		for(int b = 0; b < V[N].size();b++){

			dp[N+1][1][a] = min(dp[N+1][1][a],dp[N][V[N][b].col][a]);

		}
	}


	int minimum = BIG_NUM;
	for(int k = 0; k <= M; k++){
		minimum = min(minimum,dp[N+1][1][k]);
	}

	printf("%d\n",minimum);
}

int main(){

	dp = new int**[152];
	for(int i = 1; i <= 151; i++){
		dp[i] = new int*[1001];
		for(int k = 1; k <= 1000; k++){
			dp[i][k] = new int[76];
		}
	}


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

		func();
	}

  return 0;
}

Measured memory_bytes: 51028
#include<stdio.h>
main(){
  int h,w,i,j;
  while(1){
    scanf("%d%d",&h,&w);
    if(h==0 && w==0)
      break;
    for(i=0;i<h;i++){
      if(i>0 && i<h-1){
	for(j=0;j<w;j++){
	  if(j>0 && j<w-1){
	    printf(".");
	  }else{
	    printf("#");
	  }
	}
      }else{
	for(j=0;j<w;j++)
	  printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
// problem: "https://atcoder.jp/contests/abc154/tasks/abc154_d"

#include<bits/stdc++.h>

using namespace std;

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

    vector<int>V(n);
    int i;
    for(i=0;i!=n;i++)
        cin>>V[i];

    for(i=1;i!=n;i++)
        V[i] += V[i-1];

    for(i=n-1;i!=k-1;i--)
        V[i] -= V[i-k];

    double ans = 0.0;

    for(i=k-1;i!=n;i++)
        ans = max(ans,(V[i]+k)/2.0);

    cout<<fixed;
    cout<<setprecision(12)<<ans;

    return 0;
}


Measured memory_bytes: 1024
#https://atcoder.jp/contests/abc158/tasks/abc158_c
import math
e,t = map(int,input().split())
t_s = list(range(math.ceil(t/0.1),math.ceil(t/0.1)+10))
ans = -1
for i in t_s:
    if math.floor(i*0.08) == e:
        ans = i
        break

print(ans)

Measured memory_bytes: 9068
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int get(int x) {
    if (x >= 3200) return 0;
    return x / 400 + 1;
}

int main(){

    /*
     * Rating 1-399 : gray
     * Rating 400-799 : brown
     * Rating 800-1199 : green
     * Rating 1200-1599 : cyan
     * Rating 1600-1999 : blue
     * Rating 2000-2399 : yellow
     * Rating 2400-2799 : orange
     * Rating 2800-3199 : red
     */

    int n;
    set<int> s;

    cin >> n;
    int x;
    int cnt = 0;

    while(n--) {
        cin >> x;
        if (get(x) == 0) cnt++;
        else s.insert(get(x));
    }

    if (s.size() == 0) {
        cout << 1 << " " << cnt << endl;
    } else 
        cout << s.size() << " " << s.size() + cnt << endl;

    return 0;
}


Measured memory_bytes: 256
my $n=<STDIN>;my @a;my$a;
$a=<STDIN>;chomp$a;
my @a =split(/ /,$a);
push(@a,1..$n);
my %count;
foreach(@a){$count{$_}++;}
my $number;
foreach(1..$n){$number=$count{$_}-1;print "$number","\n";}

Measured memory_bytes: 65388
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = -1
diff = float('inf')
for i, h in enumerate(H, 1):
  dt = abs(T-h*0.006 - A)
  if dt < diff:
    diff = dt
    ans = i

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,c=0;
    cin>>n;
    if(n==0)break;
    string s,b;
    for(int i=0;i<n;i++){
      cin>>s;
      if(s[0]!=b[0]&&s[1]==b[1])c++;
      b=s;
    }
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
// 問題文は読んでないがサンプルからエスパー
package main

import "fmt"

var n int

func main() {
	fmt.Scan(&n)
	odd, even := []string{}, []string{}
	for i := 0; i < n; i++ {
		var j string
		fmt.Scan(&j)
		if i%2 == 0 {
			odd = append(odd, j)
		} else {
			even = append(even, j)
		}
	}
	if n%2 == 1 {
		odd, even = even, odd
	}
	ans := []string{}
	for i := 0; i < len(even); i++ {
		ans = append(ans, even[len(even)-i-1])
	}
	for i := 0; i < len(odd); i++ {
		ans = append(ans, odd[i])
	}
	for _, a := range ans {
		fmt.Print(a, " ")
	}
}


Measured memory_bytes: 29828
package main

import (
	"fmt"
	"sort"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	k := nextInt()

	ps := make([]pair, n)
	for i := range ps {
		a := nextInt()
		b := nextInt()
		ps[i] = pair{a, b}
	}
	sort.Stable(pairs(ps))

	var ans int
	for k > 0 {
		ans = ps[0].x
		k -= ps[0].y
		ps = ps[1:]
	}
	fmt.Println(ans)
}

type pair struct{ x, y int }
type pairs []pair

func (ps pairs) Len() int           { return len(ps) }
func (ps pairs) Swap(i, j int)      { ps[i], ps[j] = ps[j], ps[i] }
func (ps pairs) Less(i, j int) bool { return ps[i].x < ps[j].x }


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

void add_to_child(int node,int parent,vector<vector<int>> &is_connected, vector<int> &node_sum){
	for(int i=0;i<(int)is_connected[node].size();i++){
		int tar = is_connected[node][i];
		if(tar == parent){continue;}
		node_sum[tar] += node_sum[node];
		add_to_child(tar,node,is_connected, node_sum);
	}
}
int main(){
	int n,q;
	cin >> n >> q;
	vector<vector<int>> is_connected(n);
	vector<int> node_sum(n);
	for(int i=0;i<n;i++) node_sum[i] = 0;
	int a,b;
	for(int i=0;i<n-1;i++){
		cin >> a >> b;
		is_connected[a-1].push_back(b-1);
		is_connected[b-1].push_back(a-1);
	}
	for(int i=0;i<q;i++){
		cin >> a >> b;
		node_sum[a-1] += b;
	}
	add_to_child(0,-1,is_connected,node_sum);
	for(int i=0;i<n;i++){
		cout << node_sum[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 29696
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int check(LL i,int j){
    if(i%2==1) return j;
    else check(i/=2,j+1);
}

int main(){
    int N;
    cin >> N;
    LL A[N];
    int ans=100000000;
    for(int i=0;i<N;i++){
        cin >> A[i] ;
        ans=min(check(A[i],0),ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#define lnth(a,l) for(l=0;a[l];l++)


int main(){
	int ans=0;
	int n,p;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&p);
		ans += p-1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int n, a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
        if (i != 0)
        {
            printf(" ");
        }
        else
        {
            break;
        }
    }
printf("\n");
return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 4000;
int n,m;
int s[MAXN][MAXN],s1[MAXN][MAXN];
int t[MAXN][MAXN],t1[MAXN][MAXN];
char str[MAXN][MAXN];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",str[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(str[i][j]=='.'){
				s[i][j] = s[i][j-1]+1;
				t[i][j] = t[i-1][j]+1;
				
			}
		}
	}
	for(int i=n;i>=1;i--)
		for(int j=m;j>=1;j--){
			if(str[i][j] == '.'){
				s1[i][j] = s1[i][j+1]+1;
				t1[i][j] = t1[i+1][j]+1;//cout<<i<<" "<<j<<" "<<s1[i][j]<<" "<<t1[i][j]<<endl;
			}
		}
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(str[i][j] == '.')
			ans = max(ans,s[i][j] + s1[i][j] + t[i][j] + t1[i][j]-3);
		}
	}
	cout<<ans;
	
	
	
	return 0;
	
}

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

#define INF 1 << 30

int main(){
  string s;
  vector<int> num;
  cin >> s;
  num = vector<int>(s.length());
  for (int i=0;i<s.length();i++){
    num[i] = s[i] - '0';
  }
  int mi = INF;
  for (int i=0;i<num.size()-2;i++){
    int n = 100*num[i] + 10*num[i+1] + num[i+2];
    mi = min(mi, abs(753 - n));
  }
  cout << mi << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int R, C, N;
bool edge(int x, int y) {
    if (x == 0 || x == R || y == 0 || y == C)
        return true;
    return false;
}
int chg(int x, int y) {
    if (y == 0) {
        return x;
    } else if (x == R) {
        return y + R;
    } else if (y == C) {
        return R + C + (R - x);
    } else if (x == 0) {
        return R + C + R + (C - y);
    }
}
vp P;

void solve() {
    sort(all(P));
    stack<int> S;
    for (auto& p : P) {
        int i = p.second;
        if (!S.empty() && S.top() == i) {
            S.pop();
        } else
            S.push(i);
    }
    YES(S.empty());
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> R >> C >> N;
    FOR(N) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (edge(x1, y1) && edge(x2, y2)) {

            P.pb({chg(x1, y1), i});
            P.pb({chg(x2, y2), i});
        }
    }


    solve();
    return 0;
}


Measured memory_bytes: 6512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>
#include <queue>
#include <assert.h>

using namespace std;

const int N=10000010;

//2 3 25
//2 3 25
//4 6 8 

vector<int> v;

int vis[N],n;
long long sum;

priority_queue<int> Q;

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

inline int check(vector<int> v){
	sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
	int _n=v.size();
	assert(n==_n);
	int s=0;
	for(int i=0;i<n;i++){
		assert(v[i]<=30000);
		s+=v[i];	
	}
	for(int i=0;i<n;i++) assert(gcd(v[i],s-v[i])!=1);
	return 1;
}

vector<int> ans;

int ot[N];

inline void Print(){
	v.push_back(2); v.push_back(3); v.push_back(25); n+=3;
	int cur=v.size();
	for(int i=0;i<v.size() && cur>n;i++)
		if(v[i]%30==0) cur--,ot[i]=1;
	for(int i=0;i<v.size() && cur>n;i++)
		if(!ot[i])
			for(int j=i+1;j<v.size() && cur>n;j++)
				if(!ot[j]){
					if((v[i]+v[j])%30==0){
						ot[i]=ot[j]=1;
						cur-=2;
						break;
					}
				}
	ans.clear();
	if(cur<n) v.push_back(30);
	int ct=0;
	for(int i=0;i<v.size();i++)
		if(!ot[i]) ct++,ans.push_back(v[i]);
	cerr<<ans.size()<<endl;
	check(ans);
	for(int i=0;i<ans.size();i++) printf("%d ",ans[i]);
}

int main(){
	scanf("%d",&n); n-=3;
	if(!n) return puts("2 3 25"),0;
	vis[2]=vis[3]=vis[25]=1;
	for(int i=30;i<=30000;i+=30)
		if(!vis[i]){
			v.push_back(i); vis[i]=1;
			if(v.size()>=n) return Print(),0;
		}
	for(int i=2;i<=30000;i+=2)
		if(!vis[i]){
			v.push_back(i); vis[i]=1; sum+=i;
			if(v.size()>=n && sum%30==0) return Print(),0;
		}
	for(int i=3;i<=30000;i+=3)
		if(!vis[i]){
			v.push_back(i); vis[i]=1; sum+=i;
			if(v.size()>=n && sum%30==0) return Print(),0;
		}
	for(int i=5;i<=30000;i+=5)
		if(!vis[i]){
			v.push_back(i); vis[i]=1; sum+=i;
			if(v.size()>=n && sum%30==0) return Print(),0;
		}
	puts("!!!");
	return 0;
}

Measured memory_bytes: 2688
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define sep cout<<"\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
int main(){
	long n,k;
	cin>>n>>k;
	long A[n];
	long m = 100000000;
	for(int i=0;i<n;i++){
		cin>>A[i];
		m = min(m,A[i]);
	}
	long x = 0,ans = 0;
	for(int i=0;i<n;i++){
		if(A[i] == m){
		}else x++;
	}
	cout<<ceil(x/(float)(k-1))<<"\n";
}
/*
10
3 3 3 3 3 1 3 3 3 3 3 
0 1 2 3 4 5 6 7 8 9 10
* 
* 
8 3
7 3 1 1 1 1 2 5
3 5 2 3 4 1
0 1 2 3 4 5 6 7
* */


Measured memory_bytes: 1024
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 1000000007L;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		long[][] cnt = new long[40][60];
		int ints = 0;
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			
			int ind = s.indexOf(".");
			if (ind==-1) {
				s += ".0";
				ind = s.indexOf(".");
			}
			int M = s.length();
			String str = s.substring(0,ind);
			if (ind < M)
				str += s.substring(ind+1,M);
			long num = Long.parseLong(str);
			int[] pow = new int[2];
			pow[0] = (ind-M+1);
			pow[1] = (ind-M+1);
			while (num % 2 == 0) {
				pow[0] += 1;
				num /= 2;
			}
			while (num % 5 == 0) {
				pow[1] += 1;
				num /= 5;
			}
			if (pow[0] >= 0 && pow[1] >= 0)
				ints += 1;
			cnt[pow[0]+9][pow[1]+9] += 1;
		}
		
		long ans = 0;

		for (int i = 0; i < cnt.length; i++) {
			for (int j = 0; j < cnt[0].length; j++) {
				for (int a = Math.max(18-i,0); a < cnt.length; a++) {
					for (int b = Math.max(18-j,0); b < cnt[1].length; b++) {
						ans += cnt[i][j]*cnt[a][b];
					}
				}
			}
		}
		ans = (ans-ints)/2;
		pw.println(ans);
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 56648