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

int l[2000][2000], r[2000][2000], u[2000][2000], d[2000][2000];

int main() {
  int h, w; cin >> h >> w;

  vector<vector<char>> m(h);

  for(int i=0; i<h; ++i){
    m[i].resize(w);
    for(int k=0; k<w; ++k) cin >> m[i][k];
  }

  for(int y=0; y<h; ++y){
    for(int x=0; x<w; ++x){
      if(m[y][x] == '#') l[y][x] = 0;
      else if(x == 0) l[y][x] = 1;
      else l[y][x] = l[y][x-1] + 1;
    }
  }
  for(int y=0; y<h; ++y){
    for(int x=w-1; x>=0; --x){
      if(m[y][x] == '#') r[y][x] = 0;
      else if(x == w-1) r[y][x] = 1;
      else r[y][x] = r[y][x+1] + 1;
    }
  }
  for(int y=0; y<h; ++y){
    for(int x=0; x<w; ++x){
      if(m[y][x] == '#') u[y][x] = 0;
      else if(y == 0) u[y][x] = 1;
      else u[y][x] = u[y-1][x] + 1;
    }
  }
  for(int y=h-1; y>=0; --y){
    for(int x=0; x<w; ++x){
      if(m[y][x] == '#') d[y][x] = 0;
      else if(y == h-1) d[y][x] = 1;
      else d[y][x] = d[y+1][x] + 1;
    }
  }

  int ans = 0;
  for(int y=0; y<h; ++y)
    for(int x=0; x<w; ++x)
      ans = max(ans, l[y][x] + r[y][x] + u[y][x] + d[y][x] - 3);

  cout << ans;
}


Measured memory_bytes: 66688
a,b,c=map(int, input().split())
n=int(input()) 
flg = 0

if a < b and b < c:
    print('Yes')
    exit()

if a < b:
    flg = 1

while n > 0:
    if flg == 0:
        b = b * 2
        n = n - 1
        #print(a,b,c)
        if a < b:
            flg = 1
            if b < c:
                print('Yes')
                exit()
    else:
        c = c * 2
        n = n - 1
        #print(a,b,c)
        if b < c:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 9204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
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()
{
	ll n, k, r, s, p;
	string t, m;
	ll ans;

	cin >> n >> k >> r >> s >> p >> t;
	ans = 0;

	rep(i, n)
	{
		if (t[i] == 'r')
		{
			if (i - k > -1)
			{
				if (t[i] != t[i - k])
				{
					ans += p;
					m.push_back('p');
				}
				else
				{
					if (m[i - k] == 'p')
						m.push_back('r');
					else
					{
						ans += p;
						m.push_back('p');
					}
				}
			}
			else
			{
				ans += p;
				m.push_back('p');
			}
		}
		else if (t[i] == 's')
		{
			if (i - k > -1)
			{
				if (t[i] != t[i - k])
				{
					ans += r;
					m.push_back('r');
				}
				else
				{
					if (m[i - k] == 'r')
						m.push_back('s');
					else
					{
						ans += r;
						m.push_back('r');
					}
				}
			}
			else
			{
				ans += r;
				m.push_back('r');
			}
		}
		else if (t[i] == 'p')
		{
			if (i - k > -1)
			{
				if (t[i] != t[i - k])
				{
					ans += s;
					m.push_back('s');
				}
				else
				{
					if (m[i - k] == 's')
						m.push_back('p');
					else
					{
						ans += s;
						m.push_back('s');
					}
				}
			}
			else
			{
				ans += s;
				m.push_back('s');
			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>


int main(){
	int n,k;
	cin >> n >> k;
	vector<long long>h(n);
	rep(i,n)cin >> h[i];
	sort(h.begin(),h.end());
	long long sum=0;
	rep(i,n-k)sum+=h[i];
	cout << sum;
}



Measured memory_bytes: 1920
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]=='s')
	    s+="es";
	else s+="s";
	cout<<s<<endl;

}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTimeLimitExceeded solver = new BTimeLimitExceeded();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTimeLimitExceeded {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int tl = in.nextInt();
            int mincost = 10000;
            for (int i = 0; i < n; i++) {
                int c = in.nextInt();
                int t = in.nextInt();
                if (tl >= t) {
                    mincost = Math.min(mincost, c);
                }
            }
            if (mincost > 1000) {
                out.println("TLE");
            } else {
                out.println(mincost);
            }
        }

    }
}



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

using namespace std;

int main()
{
	vector<vector<int>> A(3, vector<int>(3));
	vector<vector<bool>> B(3, vector<bool>(3, false));
	for (int count = 0; count < 3; count++)
	{
		for (int index = 0; index < 3; index++)
		{
			cin >> A.at(count).at(index);
		}
	}
	int N, tmp;
	cin >> N;
	for (int count = 0; count < N; count++)
	{
		cin >> tmp;
		for (int index1 = 0; index1 < 3; index1++)
		{
			for (int index2 = 0; index2 < 3; index2++)
			{
				if (tmp == A.at(index1).at(index2))
				{
					B.at(index1).at(index2) = true;
				}
			}
		}
	}
	if ((B.at(0).at(0) && B.at(0).at(1) && B.at(0).at(2)) ||
		(B.at(1).at(0) && B.at(1).at(1) && B.at(1).at(2)) ||
		(B.at(2).at(0) && B.at(2).at(1) && B.at(2).at(2)) ||
		(B.at(0).at(0) && B.at(1).at(0) && B.at(2).at(0)) ||
		(B.at(0).at(1) && B.at(1).at(1) && B.at(2).at(1)) ||
		(B.at(0).at(2) && B.at(1).at(2) && B.at(2).at(2)) ||
		(B.at(0).at(0) && B.at(1).at(1) && B.at(2).at(2)) ||
		(B.at(2).at(0) && B.at(1).at(1) && B.at(0).at(2)))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 800000
int n,x,y,tot,S,T,xb,cnt,head[N],q[N],mx[N],num[N],a[N];
bool vis[N];
struct edge {
	int v,nxt;
} e[N];
void add(int x,int y) {
	e[++tot].v=y;
	e[tot].nxt=head[x];
	head[x]=tot;
}
void bfs() {
	memset(vis,0,sizeof vis);
	int tt=0,ww=0;
	q[++ww]=S;
	vis[S]=1;
	while (tt<ww) {
		int u=q[++tt];
		for (int i=head[u],v; i; i=e[i].nxt)
			if (!vis[v=e[i].v]) {
				vis[v]=1;
				q[++ww]=v;
			}
	}
	T=q[ww];
}
void dfs(int u,int fa) {
	int tmp=0;
	mx[u]=0;
	for (int i=head[u],v; i; i=e[i].nxt)
		if ((v=e[i].v)!=fa) {
			dfs(v,u);
			mx[u]=max(mx[u],mx[v]);
			if (mx[v]>1) ++tmp;
			else if (v!=T) ++num[u];
		}
	if (tmp>1) {
		puts("-1");
		exit(0);
	}
	++mx[u];
	if (u!=S&&u!=T&&mx[u]>1) a[++xb]=num[u];
}
void print(int u,int fa) {
	int t=++cnt;
	for (int i=head[u],v; i; i=e[i].nxt)
		if ((v=e[i].v)!=fa&&mx[v]==1&&v!=T)
			printf("%d ",++cnt);
	printf("%d ",t);
	for (int i=head[u],v; i; i=e[i].nxt)
		if ((v=e[i].v)!=fa&&(mx[v]>1||v==T))
			print(v,u);
}
int main() {
	scanf("%d",&n);
	for (int i=1; i<n; ++i) {
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	S=1;
	bfs();
	S=T;
	bfs();
	dfs(S,0);
	/*cout<<S<<endl;
	for(int i=1; i<=n; i++) {
		printf("%d %c",mx[i],i==n?'\n':' ');
	}
	for(int i=1; i<=n; i++) {
		printf("%d %c",num[i],i==n?'\n':' ');
	}
	for(int i=1; i<=xb; i++) {
		printf("%d %c",a[i],i==xb?'\n':' ');
	}*/
	reverse(a+1,a+xb+1);
	bool fl=1;
	for (int i=1; i<=xb; ++i) {
		if (a[i]<a[xb-i+1]) {
			fl=1;
			break;
		}
		if (a[i]>a[xb-i+1]) {
			fl=0;
			break;
		}
	}
	xb=0;
	if (fl) print(S,0);
	else {
		swap(S,T);
		//dfs(S,0);
		print(S,0);
	}
	return 0;
}

Measured memory_bytes: 19968
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

bool X[100005];
bool Y[100005];
ll n;

void calc() {
	rep(i, 1, n + 2) {
		if (Y[i] && X[i]) Y[i + 1] = Y[i - 1];
		else if (Y[i] && !X[i]) Y[i + 1] = !Y[i - 1];
		else if (!Y[i] && X[i]) Y[i + 1] = !Y[i - 1];
		else if (!Y[i] && !X[i]) Y[i + 1] = Y[i - 1];
	}
	if (Y[n] == Y[0] && Y[n + 1] == Y[1]) {
		rep(i, 0, n) 	cout << (Y[i] ? 'S' : 'W');
		cout << endl;
		exit(0);
	}
}

int main() {
	string s; cin >> n >> s;
	rep(i, 0, n)	X[i] = (s[i] == 'o') ? 1 : 0;
	X[n] = X[0];
	X[n + 1] = X[1];

	Y[0] = 1; Y[1] = 1;
	calc();
	Y[0] = 1; Y[1] = 0;
	calc();
	Y[0] = 0; Y[1] = 1;
	calc();
	Y[0] = 0; Y[1] = 0;
	calc();

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  string s = a+b;
  if(s=="12" || s== "21"){
    cout << 3 << endl;
  }else if(s=="23" || s=="32"){
    cout << 1 << endl;
  }else {
    cout << 2 <<endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll a;
  cin >> a;
  
  cout << a+a*a+a*a*a << endl;
}

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

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	char s[10000];
	int n,k,i,j;
	
	scanf("%d %s %d",&n,s,&k);
	
	char rep;
	i=0;
	while(s[i] != '\0'){
		//printf("%d:%c\n",i+1,s[i]);
		if(i == k-1){
			rep = s[i];
			j=0;
			while(s[j] != '\0'){
				if(s[j] != rep){
					s[j] = '*';
				}
				j++;
			}
		}
		i++;
	}
	printf("%s\n",s);
	
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_K = MAX_N / 2;

/* typedef */

/* global variables */

int cards[MAX_K][MAX_N / 2];
int seq[MAX_N];

/* subroutines */

void gen_seq(int n) {
  for (int i = 0; i < n; i++) seq[i] = rand() & 1;
}

/* main */

int main() {
  srand(time(NULL));

  int n, k;
  cin >> n >> k;

  int nh = n / 2;
  int cmin = n / 8, cmax = 3 * cmin;

  memset(cards, 0, sizeof(cards));
  
  for (int i = 0; i < k; i++)
    for (int j = 0; j < nh; j++) {
      cin >> cards[i][j];
      cards[i][j]--;
    }

  for (;;) {
    gen_seq(n);

    bool ok = true;
    for (int i = 0; i < k; i++) {
      int cnt = 0;
      for (int j = 0; j < nh; j++) cnt += seq[cards[i][j]];
      if (cnt < cmin || cnt > cmax) {
	ok = false;
	break;
      }
    }

    if (ok) break;
  }

  for (int i = 0; i < n; i++) cout << seq[i]; cout << endl;
  
  return 0;
}

Measured memory_bytes: 2156
# A
S = input()
if S[0] == S[1] ==  S[2] == S[3]:
    print('No')
elif S[0] == S[1] and S[2] == S[3]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
//4008160009
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false)
#define lid id<<1|1
#define rid (id<<1)+2
#define mid l+r>>1
#define lson lid, l, mid
#define rson rid, mid, r

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=405;

int N, t, C[MAX][5];
map<ll,pair<int,int> >::iterator it;
map<ll,pair<int,int> > MP;
ll res, tt;

inline void Insert(ll H, int t)
{
    it=MP.find(H);
    if(it!=MP.end())
    {
        it->s.s+=t;
        return;
    }
    int re=H/(ll)1e6==H%(ll)1e6?(H/(ll)1e9==H%(ll)1e3?4:2):1;
    MP[H]=mp(re, t);
}

inline int Find(ll H)
{
    it=MP.find(H);
    return it->s.f*it->s.s;
}

inline ll Get_Hash(int *t, int turn)
{
    ll ret=0;
    forn(i, 4)
        ret=ret*1000+t[(i+turn)&3];
    return ret;
}

inline void Add(ll H, int t)
{
    ll tmp[4];
    forn(i, 4)
        tmp[i]=H, H=H/1000+H%1000*1000000000;
    sort(tmp, tmp+4);
    int ptr=unique(tmp, tmp+4)-tmp;
    forn(i, ptr)
        Insert(tmp[i], t);
}

inline void Add(int *T, int t)
{
    Add(Get_Hash(T, 0), t);
}

int main()
{
    N=in();
    forn(i, N)
    {
        forn(j, 4)
            C[i][j]=in();
        Add(C[i], 1);
    }
    forn(i, N)
    {
        Add(C[i], -1);
        for(int j=i+1; j<N; ++j)
        {
            Add(C[j], -1);
            reverse(C[j], C[j]+4);
            
            forn(k, 4)
            {
                tt=1;
                for(t=0; t<4; ++t)
                {
                    ll h=((C[j][(k+t)&3]*1000LL+C[j][(k+t+1)&3])*1000+C[i][(t+1)&3])*(ll)1000+C[i][t];
                    tt*=Find(h);
                    if(!tt)
                        break;
					Add(h, -1);
                }
                while(t--)
                {
                    ll h=((C[j][(k+t)&3]*1000LL+C[j][(k+t+1)&3])*(ll)1000+C[i][(t+1)&3])*(ll)1000+C[i][t];
                    Add(h, 1);
                }
                res+=tt;
            }
            reverse(C[j], C[j]+4);
            Add(C[j], 1);
        }
    }
    printf("%lld\n", res);
    return 0;
}

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

using namespace std;

#define INF 1e9

bool solve(char c1,char c2){
    if(c1=='(')return c2==')';
    else return c2==']';
}

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

    while(1){
        string s;
        getline(cin,s);
        if(s==".")break;
        stack<char> st;
        bool ans=true;
        for(int i=0;i<s.size();i++){
            if(s[i]=='(' || s[i]=='[')st.push(s[i]);
            else if(s[i]==')' || s[i]==']'){
                if(st.empty())ans=false;
                else{
                    if(solve(st.top(),s[i])){
                        st.pop();
                    }
                    else{
                        ans=false;
                    }
                }
            }
        }
        if(!st.empty())ans=false;
        if(ans)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetNumber();
            var nums = GetNumbersInt(N);
            var count = SelectionSort(nums);
            System.Console.WriteLine(string.Join(" ", nums.Select(x => x.ToString()).ToArray()));
            System.Console.WriteLine(count);
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int SelectionSort(int[] A)
        {
            var count = 0;
            for (var i = 0; i < A.Length; i++)
            {
                var mini = i;
                for (var j = i; j < A.Length; j++)
                {
                    if (A[j] < A[mini])
                    {
                        mini = j;
                    }
                }

                if (i != mini)
                {
                    var tmp = A[i];
                    A[i] = A[mini];
                    A[mini] = tmp;
                    count++;
                }
            }
            return count;
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10048
import math
import numpy as np
a, b, h, m = map(int, input().split())

h_r = math.radians((90 - h * 30 - m * 0.5))
m_r = math.radians((90 - m * 6))
h_v = np.array([math.cos(h_r), math.sin(h_r)]) * a
m_v = np.array([math.cos(m_r), math.sin(m_r)]) * b
ans = (a ** 2 + b ** 2 - 2 * np.dot(h_v, m_v))**(0.5)
print(ans)


Measured memory_bytes: 27184
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct edge {ll to, cost;};

int main(){
    ll N; cin >> N;
    vector<edge> ed[N];
    REP(i, N-1){
        ll a, b, c; cin >> a >> b >> c; a--; b--;
        ed[a].pb({b,c});
        ed[b].pb({a,c});
    }
    ll Q, K; cin >> Q >> K;
    K--;
    queue<ll> q; q.push(K);
    vl dist(N, LINF); dist[K] = 0;
    while(!q.empty()){
        ll now = q.front(); q.pop();
        for(auto e : ed[now]){
            if(dist[e.to] != LINF) continue;
            if(dist[e.to] > dist[now] + e.cost){
                dist[e.to] = dist[now] + e.cost;
                q.push(e.to);
            }
        }
    }
    
    REP(i, Q){
        ll x, y; cin >> x >> y; x--; y--;
        cout << dist[x] + dist[y] << endstr;
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>A[i];
    }
    ll cnt=1;
    for(int i=1; i<=n; i++)
    {
        if(A[i]==cnt)
        {
            cnt++;
        }
    }
    if(cnt==1)
    {
        cout<<-1<<endl;
    }
    else
    cout<<n-cnt+1<<endl;
    return 0;
}



Measured memory_bytes: 2304
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var W = one[1];
  var dp = new Array(N + 1);
  var max = 1000000007;
  var valLen = 100007;
  for(var i = 0; i < N + 1; i++){
    dp[i] = new Array(valLen).fill(max);
  }
  //i個目を付与したらdp[i][価値]が重さになる
  for(var i = 1; i <= N; i++){
    var tmp = nextIntArray();
    var value = tmp[1];
    var weight = tmp[0];
    for(var j = 0; j <= valLen; j++){
      dp[i][j] = dp[i - 1][j];
    }
    for(var j = valLen; j >= value; j--){
      if(dp[i][j - value] != max){
        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - value] + weight);
      }
    }
    dp[i][value] = Math.min(dp[i - 1][value],weight);
    
  }
  var output = 0;
  for(var i = 0; i <= valLen; i++){
    if(dp[N][i] <= W){
      output = i;
    }
  }
  myout(output);
}

Measured memory_bytes: 247196
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100000+5
using namespace std;
int n,a[N],ans,f;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		f++;
		if(a[i] != a[i+1])
		{
			if(f < a[i]) ans += f;
			if(f > a[i]) ans += f-a[i];
			f = 0;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
 
import javax.xml.crypto.Data;
 
import java.math.*;
 
public class Main {
     
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] listA = new int[n];
        for(int i = 0; i < n; i++) {
            listA[i] = sc.nextInt() * 3600 + sc.nextInt() * 60;
        }
        int m = sc.nextInt();
        int[] listB = new int[m];
        for(int i = 0; i < m; i++) {
            listB[i] = sc.nextInt() * 3600 + sc.nextInt() * 60;
        }
        int[] list = new int[n + m];
        for(int i = 0; i < n; i++) {
            list[i] = listA[i];
        }
        for(int i = 0; i < m; i++) {
            list[i + n] = listB[i];
        }
         
        Arrays.sort(list);
        int pre = list[0];
        show(pre);
        for(int i = 1; i < n+m; i++) {
            if(list[i] == pre) continue;
            System.out.print(" ");
            show(list[i]);
            pre = list[i];
        }
        System.out.println();
         
    }
     
    static void show(int a) {
        int h = a / 3600;
        System.out.print(h + ":");
         
        a -= h * 3600;
        a /= 60;
        if(a < 10) {
            System.out.print("0");
        }
        System.out.print(a);
    }
     
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    for(ll i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(all(h));
    ll ans = 1LL << 60;
    k--;
    for(int i = k; i < n; i++){
        ans = min(ans, h[i] - h[i - k]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std ;

int main()
{
	int len ,n ,ans = 0 ;
	cin >> len  ;
	int arry_[ len ] ;

	for( int i = 0 ; i < len ; i++ )
		cin >> arry_[ i ] ;

	cin >> len ;

	for( int i = 0 ; i < len ; i++ )
	{
		cin >> n ;
		for( int j = 0 ; j < sizeof arry_ / sizeof( int ) ; j++ )
		{
			if( n == arry_[ j ] )
			{
				ans++ ;
				break ;
			}
		}
	}

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 3112
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
        
//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ull modpow(ull a, ull b) {
	ll retval = 0;

	if (b == 0) { return 1; }

	else if (b % 2 == 0) {
		retval = modpow(a, b / 2) % mod;
		return (retval * retval) % mod;
	}

	else {
		
		return ((a % mod) * modpow(a, b - 1)) % mod;
	}
}

ull modkaijou(ull a) {

	if (a == 1 || a == 0) { return 1; }

	ll retval = 1;

	for (ull i = a; i >= 1; i--) {
		retval = (retval * (i % mod)) % mod;
	}

	return retval % mod;
}

ull modcomb(ull a, ull b) {

	if (a == 0 || b == 0) return 1;

	return (((modkaijou(a) * modpow(modkaijou(a-b), mod - 2)) % mod) * modpow(modkaijou(b), mod - 2)) % mod;
}


vector<pint> query;

stack<int> to_1;


class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};











string S;

ll dp[100005][3];

int main() {
	ll N, X;


	cin >> S;

	ll type = 1;
	
	for (int i = 0; i < S.size(); i++) {

		dp[i + 1][0] = dp[i][0];
		dp[i + 1][1] = dp[i][1];
		dp[i + 1][2] = dp[i][2];


		if (S[i] == 'A') {
			dp[i + 1][0] = (dp[i][0] + type);

		}

		else if (S[i] == 'B') {
			dp[i + 1][1] = (dp[i][0] + dp[i][1]);
		}

		else if (S[i] == 'C') {
			dp[i + 1][2] = (dp[i][1] + dp[i][2]);
		}

		else if (S[i] == '?') {

			dp[i + 1][0] = 3LL * dp[i][0] + type;
			dp[i + 1][1] = 3LL * dp[i][1] + dp[i][0];
			dp[i + 1][2] = 3LL * dp[i][2] + dp[i][1];

			type = (3 * type) % mod;
		}

		dp[i + 1][0] %= mod;
		dp[i + 1][1] %= mod;
		dp[i + 1][2] %= mod;

	}

	cout << dp[S.size()][2] << endl;
	return 0;
}

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

using namespace std;

int main()
{
	vector<int> v(10);
	for(int i=0; i<10; i++) cin >> v[i];
	sort(v.begin(), v.end(), std::greater<int>());
	for(int i=0; i<3; i++) printf("%d\n", v[i]);
}

Measured memory_bytes: 0
import re
n=int(input())
ans=0
a,b,ba=0,0,0
for i in range(n):
  s=input()
  ans+=len(re.sub("[A-Z]+","",s.replace("AB","s")))
  if s[0]=="B" and s[-1]=="A":ba+=1
  elif s[0]=="B":b+=1
  elif s[-1]=="A":a+=1
ans+=max(ba-1,0)
if ba:
  if a:ans+=1;a-=1
  if b:ans+=1;b-=1
print(ans+min(a,b))

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll calc(ll x){
  ll ret = (x >> 1ll) + 1;
  if (x & 1) return ret & 1;
  return (ret & 1) ^ x ^ 1;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  ll a, b; cin >> a >> b;
  ll x = calc(a - 1), y = calc(b);
  cout << (x ^ y);
return 0;
}



Measured memory_bytes: 384
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

start = []
goal = []
cost = []
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    start.append(A)
    goal.append(B)
    cost.append(C)
    start.append(B)
    goal.append(A)
    cost.append(C)

graph = csr_matrix((cost, (start, goal)), shape = (N, N))
can_reach_with_L = dijkstra(graph, directed = False, limit = L)
ans = dijkstra(can_reach_with_L, directed = False, unweighted = True)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    if ans[s][t] == float('inf'):
        print(-1)
    else:
        print(int(ans[s][t] + 0.5) - 1)


Measured memory_bytes: 49632
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

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

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int a[3];
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }

    sort(a, a + 3);
    cout << a[0] * a[1] / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#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) {
    llint n, m;
    cin >> n >> m;

    llint ans;
    ans = n*m-2*(n+m) + 4;

    if(n==1||m==1) ans = max(n, m) -2;
    if(n==1&&m==1) ans = 1;

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


Measured memory_bytes: 256
all_str = [1,2,3] 
cnt=0
select1 = int(input())
select2 = int(input())
for i in range(len(all_str)-1):
    j = i - cnt
    if all_str[j] == select1:
        all_str.pop(j)
        cnt += 1
    elif all_str[j] == select2:
        all_str.pop(j)
        cnt +=1
        
print(all_str[0])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,a[225816];
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=(n-1); i>=0; i-=2){
		cout << ((i==(n-1))?"":" ") << a[i];
	}
	for(i=(n%2); i<n; i+=2){
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int q[100005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	int length=1;
	q[length]=a[length];
	for(int i=2;i<=n;i++){
		if(q[length]<a[i]){
			q[++length]=a[i];
		}
		else{
				int l=1;
				int r=length;
				while(l<r){
					int mid=l+r>>1;
					if(q[mid]>=a[i]) r=mid;
					else l=mid+1;
				}
				q[l]=a[i];
		}
	}
	cout<<length<<endl;
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  ll N;
  cin >> N;

  // vector<ll> Manhattan(N);// 各点と原点のマンハッタン距離
  const ll MAX = 2e9+5;
  ll M = 0, m = MAX;
  ll M2 = 0, m2= MAX;
  for(ll i=0; i<N; i++){
    ll x, y;
    cin >> x >> y;
    // Manhattan[i] = x + y;
    m = min(m, x+y);
    M = max(M, x+y);

    // x = x - MAX;
    // x = -x;
    y = y;
    m2 = min(m2, -x+y);
    M2 = max(M2, -x+y);
    // cout << " x: " << x << " y: " << y << " m2: " << m2 << " M2: " << M2 << endl;
  }

  // cout << M-m << endl; //←これだけだと　左下の点と右上の点しか考えられてない
  cout << max(M-m, M2-m2) << endl;// 左上の点と右下の点も考慮した

	return 0;
}



Measured memory_bytes: 3608
#include<iostream>
#include<cstdlib>
#include<utility>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

int main() {

	int n;

	cin >> n;

	int count = 0;

	int c[10][10] = { 0 };

	int i, j, k, l;

	for (i = 1; i <= n; i++) {
		j = i % 10;
		k = i;
		while (k >= 10) k /= 10;
		c[j][k]++;
	}

	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			count += c[i][j] * c[j][i];
			//cout << c[i][j] << " ";
		}
		//cout << endl;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
 
int n,m,x,y;
int f[5],col[100005];
int tot=0,h[100005];
bool flag;
struct Edge{
	int x,dis,next;
}e[200005];
long long ans=0;
 
inline void add_edge(int x,int y,int z){
	e[++tot].x=y,e[tot].dis=z;
	e[tot].next=h[x],h[x]=tot;
}
 
void dfs(int x){
	f[col[x]]++;
	for(int i=h[x];i;i=e[i].next){
		f[3]+=e[i].dis==1;
		if(col[e[i].x]==-1){
			col[e[i].x]=(col[x]+e[i].dis)%3;
			dfs(e[i].x);
		}else{
			if(col[e[i].x]!=(col[x]+e[i].dis)%3)
				flag=true;
		}
	}
}
 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add_edge(x,y,1);
		add_edge(y,x,2);
	}
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;i++)
	if(col[i]==-1){
		f[col[i]=0]=f[1]=f[2]=f[3]=flag=0;
		dfs(i);
		if(flag){
			int cnt=f[0]+f[1]+f[2];
			ans+=1LL*cnt*cnt;
		}else if(f[0]==0||f[1]==0||f[2]==0){
			ans+=f[3];
		}else{
			ans+=1LL*f[0]*f[1];
			ans+=1LL*f[1]*f[2];
			ans+=1LL*f[2]*f[0];
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl "\n"
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int main(){
    int k;
    scanf("%d",&k);
    ll sum = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            int q = gcd(i,j);
            for(int l=1;l<=k;l++){
                sum+=gcd(q,l);
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
int main(){
    int a,b;

    scanf("%d %d",&a,&b);

    if (a < b){
        printf("a < b\n");
    }
    else if (a > b){
        printf ("a > b\n");
    }
     else{
        printf ("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}



int main()
{
    boost;


    LL n,k;
    cin>>n>>k;
    int count=0;

    while(n)
    {
        n/=k;
        count++;
    }
    cout<<count;


    return 0;
}

/*

*/


Measured memory_bytes: 256