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

#define rep(i,s,t) for(int i = s; i <= t; ++ i)
#define fi first
#define se second
#define mp make_pair
const int dx[] = {0,1};
const int dy[] = {1,0};
char mat[9][9];
int n, m;
queue<pair<int,int> > Q;
bool vis[9][9];

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%s",mat[i]+1);
	if(mat[1][1] != '#') {puts("Impossible"); return 0;}
	Q.push(mp(1,1));
	pair<int,int> h, nx; 
	while(!Q.empty())
	{
		h = Q.front(); Q.pop();
		if(vis[h.fi][h.se]) continue;
		vis[h.fi][h.se] = true;
		rep(i,0,1)
		{
			nx.fi = h.fi+dx[i];
			nx.se = h.se+dy[i];
			if(nx.fi < 1 || nx.se < 1 || nx.fi > n || nx.se > m) continue;
			if(mat[nx.fi][nx.se] != '#') continue;
			Q.push(nx);
			break;
		}
	}
	rep(i,1,n) rep(j,1,m) if(mat[i][j] == '#' && vis[i][j] == false) {puts("Impossible"); return 0;}
	rep(i,1,n) rep(j,1,m) if(mat[i][j] == '.' && vis[i][j] == true) {puts("Impossible"); return 0;}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long double a, b;
	cin>>a>>b;
	int ans=0;
	forr(i, 0, a)
	{
		long double x, y;
		cin>>x>>y;
		long double d=sqrt((x*x)+(y*y));
		//cout<<d<<'\n';
		if(d<=b)
			ans++;
	}
	
	cout<<ans;
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll x;
    cin >> x;
    ll ans = 0;
    ans += 2 *( x / 11);
    ll res = x % 11;
    if (res != 0)
    {
        if (res <= 6) ans++;
        else ans += 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>

char c[128];
std::string s;

void set(void){

  using namespace std;

  c['('] = ')';
  c[')'] = '(';
  c['i'] = 'i';
  c['w'] = 'w';

}

int main(void){

  using namespace std;

  set();
  
  cin >> s;

  int S = s.size();
  int ans = 0;
  
  if( S % 2 == 1 )
    if( s[S/2] != 'i' && s[S/2] != 'w' ) ans++;
  
  for( int i = 0 ; i < S/2 ; i++ )
    if( s[i] != c[s[S - 1 - i]] ) ans++;
 
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 1000000007
#define pb push_back
using namespace std;
int num[200009];
int main(){
	int n;
	long long ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	if(num[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<n;i++){
		if(num[i]>num[i-1]+1){
			cout<<-1<<endl;
			return 0;
		}
	}
	int cur=n-1;
	while(cur>=0){
		ans+=num[cur];
		cur--;
		while(cur>=0 && num[cur] == num[cur+1]-1){
			cur--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000

									// nestedcode

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll n;
  cin>>n;
  ll lcm,ml = 1,g,i,p,j;
  g = 0;
  map<ll,ll>m;
  ll a[n+5];
  for(j=0;j<n;j++){
  	cin>>a[j];
  	p = a[j];
  	ll k;
  	for(i=2;i*i<=p;i++){
  		k = 0;
  		if(p%i == 0){
  			while(p%i == 0){
  				p/=i;
  				k++;
			  }
			  m[i] = max(m[i],k);
			  
		  }
	  }
	  if(p>1){
	  	m[p] = max(1LL,m[p]);
	  //	cout<<p<<" "<<m[p]<<endl;
	  }

  }
  
  lcm = 1;
  for(auto it=m.begin();it!=m.end();it++){
     // cout<<it->first<<" "<<it->second<<endl;
  	if(it->second != 0){
  		for(i=0;i<(it->second);i++){
  			lcm = (lcm%M * (it->first)%M)%M;
		  }
	  }
  }
  //cout<<lcm;
  ll ans = 0;
  for(i=0;i<n;i++){
  	ans = (ans%M + (lcm%M * binpow(a[i],M-2,M))%M)%M;
  }
  cout<<ans;
  
   
}

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

int selectionSort(int arr[], int size) {
	int idxMin;
	int sw = 0;
	for (int i = 0; i < size; i++) {
		idxMin = i;
		for (int j = i; j < size; j++) {
			if (arr[j] < arr[idxMin]){
				idxMin = j;
			}
		}
		if (i != idxMin) {
			swap(arr[i], arr[idxMin]);
			sw++;
		}
	}
	return sw;
}

int main() {
	int size, sw;
	cin >> size;

	int* arr = new int[size];
	for (int i = 0; i < size; i++)cin >> arr[i];

	sw = selectionSort(arr, size);
	for (int i = 0; i < size; i++) {
		if (i) cout << ' ';
		cout << arr[i];
	}
	cout << endl << sw << endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B, C;
	int K;
	cin >> A >> B >> C >> K;
	int ans = 0;
	while(A >= B){
		B *= 2;
		ans++;
	}
	while(B >= C){
		C *= 2;
		ans++;
	}
	if(ans <= K) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3592
n, k = map(int, input().split())
d = set(map(int, input().split()))
d ^= {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}

while True:
    if d >= set(map(int, list(str(n)))):
        print(n)
        break
    n += 1


Measured memory_bytes: 2940
n=int(input())
l=[0]*n
ind=n//2
l0=list(map(int,input().split()))
f=1
if n%2==0:
  f=-1
for i in range(n):
  if f==1:
    l[ind-i]=l0[i]
    f=-1
    ind-=i
  else:
    l[ind+i]=l0[i]
    f=1
    ind+=i
print(*l)

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

int H, W, K;
int c[10][10];
bool red[20];

int redline(int n) {
    if (n == H + W) {
        int sum = 0;
        for (int i = 0; i < H; i++) {
            if (red[i]) {
                continue;
            }
            for (int j = 0; j < W; j++) {
                if (red[H + j]) {
                    continue;
                }
                if (c[i][j] == 1) {
                    ++sum;
                }
            }
        }
        if (sum == K) {
            return 1;
        } else {
            return 0;
        }
    }
    red[n] = false;
    int ans = redline(n + 1);
    red[n] = true;
    ans += redline(n + 1);
    ++n;
    return ans;
}

int main(void) {
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char cc;
            cin >> cc;
            if (cc == '.') {
                c[i][j] = 0;
            } else {
                c[i][j] = 1;
            }
        }
    }
    printf("%d\n", redline(0));

    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    
    int a, b, c, d;
    int total_r, total_l;
    
    cin >> a >> b >> c >> d;

    total_l = a+b;
    total_r = c+d;

    if(total_r > total_l) cout << "Right" << endl;
    else if(total_r == total_l) cout << "Balanced" << endl;
    else cout << "Left" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;


int main() {
	int n;
	cin >> n;
	ll cnt = 0;
	for (int i = 1; i <= n / 2; i++) {
		if (i != n - i) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print((n // x + int((n % x)!=0)) * t)
    return




n, x, t = RA()
solve()


Measured memory_bytes: 64756
#include <cstdio>
#include <iostream>

using namespace std;

#define MAXN 110
#define ll long long

int n, W;
int w[MAXN];
ll f[100010], v[MAXN];

int main()
{
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; ++ i)
		scanf("%d%lld", &w[i], &v[i]);
	for (int i = 1; i <= n; ++ i)
		for (int j = W; j >= w[i]; -- j)
			f[j] = max(f[j], f[j - w[i]] + v[i]);
	printf("%lld", f[W]);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
mounts =list(map(int, input().split()))
#print(mounts)

counter = 1
comp = []
comp.append(mounts[0])

for mount in mounts[1:]:
    Flag = False
    #print("count{} mount{}".format(counter, mount))
    for c in comp:
        if c > mount:
            Flag = True
            break
    if not Flag:
        counter += 1
    comp.append(mount)
    #print(counter)

print(counter)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int r = a + b + c;
        if(r >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 23252
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll x,ans;
  cin >> x;
  ans = 2*(x/11);
  x %= 11;
  if(x>0) ans++;
  if(x>6) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
using namespace std;

const double PI=acos(-1);

double rad(int d){
    return (double)d/360*2*PI;
}

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

    int A[100], B[100];
    fill(A, A, 0);
    fill(B, B, 0);

    int a;
    double s1 = 0.0, s2 = 0.0, s3 = 0.0, si = 0.0;
    for(int i = 0; i < n; i++){
        cin >> a;
        A[i] = a;
    }
    for(int i = 0; i < n; i++){
        cin >> a;
        B[i] = a;
    }
    for(int i = 0; i < n; i++){
        s1 += fabs(A[i] - B[i]);
        s2 += pow(fabs(A[i] - B[i]), 2);
        s3 += pow(fabs(A[i] - B[i]), 3);
        si = fmax(si, fabs(A[i] - B[i]));
    }

    printf("%.5f\n%.5f\n%.5f\n%.5f\n", s1, sqrt(s2), cbrt(s3), si);
    return 0;
}


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

int main()
{
 int n,w,i;
    cin>>n>>w;
    
    vector<long long>dp(w+1);
    //dp[i]=== maximum value with weight i;
    for(i=0;i<n;i++)
    {
     int wt,val;
        cin>>wt>>val;
        
        for(int al=w-wt;al>=0;al--)
            dp[al+wt]=max(dp[al+wt],dp[al]+val);
        
    }
    long long ans=0;
    for(x:dp)
        ans=max(ans,x);
    cout<<ans;
    
    
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

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

	if (arr[N-1] > arr[0] + 1) {
		print("No");
	} else if (arr[0] != arr[N-1]) {
		int i = 0;
		while (i < N && arr[i] == arr[0]) ++i;
		int B = arr[N-1] - i; 
		print((B > 0 && B <= (N - i) / 2) ? "Yes" : "No");
	} else {
		print((N == arr[0] + 1 || N % arr[0] == 0) ? "Yes" : "No");
	}
}

Measured memory_bytes: 3708
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
h.sort!{|a, b| b<=>a}

cnt = 0
for i in 0..(n-1)
  if k > 0
    k -= 1
  else
    cnt += h[i]
  end
end
puts cnt

Measured memory_bytes: 17796
#include <iostream>

using ll = long long int;

int main()
{
    ll x;

    std::cin >> x;

    ll a = 100;

    int ans = 0;

    for (; a < x; ++ans)
    {
        a = a + a / 100;
        //std::cerr << a << std::endl;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using ll = long long;

int A[200001];
map<int,int> M;

const int p2 = 262144;

int st[p2+p2];
int true_ans[200001];
bool vis[200001];
vector<int> adj[200001];

int query(int l, int r)
{
	l+=p2-1;
	r+=p2-1;

	int ans=0;

	while(l<=r)
	{
		if(l%2==1) ans=max(ans,st[l++]);
		if(r%2==0) ans=max(ans,st[r--]);
		l/=2;
		r/=2;
	}

	return ans;
}

void upd(int i, int val)
{
	i += p2-1;
	st[i]=val;
	i/=2;

	while(i>0)
	{
		st[i]=max(st[i+i],st[i+i+1]);
		i/=2;
	}
}

void dfs(int v)
{
	vis[v]=1;
	true_ans[v] = max(query(1,p2), 1 + query(1,A[v]-1));

	int old_ans = query(A[v],A[v]);
	upd(A[v],1+query(1,A[v]-1));

	for(auto u:adj[v])
	{
		if(vis[u]) continue;
		dfs(u);
	}

	upd(A[v],old_ans); // leave this scope
}

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	vector<int> avals;

	for(int i=1; i<=n; i++)
	{
		cin>>A[i];
		avals.push_back(A[i]);
	}

	for(int i=1; i<n; i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

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

	// for(auto a:avals) cout << a << " ";

	M[avals[0]]=1;

	for(int i=1; i<n; i++)
	{
		if(avals[i]!=avals[i-1]) M[avals[i]]=M[avals[i-1]]+1;
	}

	// for(auto m:M) cout << m.first << " " << m.second << endl;
	// cout << endl;

	for(int i=1; i<=n; i++)
	{
		// cout << i << " " << A[i] << " ";
		A[i] = M[A[i]];
		// cout << A[i] << endl;
	}

	dfs(1);

	for(int i=1; i<=n; i++)
	{
		cout << true_ans[i] << "\n";
	}
}

Measured memory_bytes: 36952
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const T = arg[1].split("");
    
    const N = S.length;
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        if(S[i] !== T[i]) {
            answer++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 36472
// https://atcoder.jp/contests/abc168/tasks/abc168_d

#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;
#define lli long long int

vector<int> V[100005];
int par[100005];

queue<int> Q;

void bfs()
{
    Q.push(1);
    par[1]=1;
    while(!Q.empty())
    {
        int n=Q.front();
        Q.pop();
        for(int i=0;i<V[n].size();i++)
        {
            if(par[V[n][i]]==-1)
            {
                par[V[n][i]]=n;
                Q.push(V[n][i]);
            }
        }
    }
}

int main()
{
    int n,m,i,a,b,flag;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    memset(par, -1, sizeof(par));
    bfs();
    flag=0;
    for(i=2;i<=n;i++)
    {
        if(par[i]==-1)
            flag=1;
    }
    if(flag)
        cout<<"No\n";
    else
    {
        cout<<"Yes\n";
        for(i=2;i<=n;i++)
            cout<<par[i]<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 10388
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>


long long int Q[10];
using namespace std;
typedef pair <long long int, long long int> Edge;
Edge D[900008];

int main() {
	long long int n = 0;
	long long int k = 0;
	long long int H, W, N;
	cin >> H >> W >> N;
	long long int a, b;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		if (a != 1 && b != 1 && a != H && b != W) {
			D[k].first = a;
			D[k].second = b;
			
			k++;
		}
		if (a - 1>1&&b!=1&&b!=W) {
			D[k].first = a - 1;
			D[k].second = b;
			
			k++;
		}
		else n++;
		if (a + 1 < H&&b!=1&&b!=W) {
			D[k].first = a + 1;
			D[k].second = b;
			
			k++;
		}
		else n++;
		if (b - 1 > 1&&a!=H&&a!=1) {
			D[k].first = a;
			D[k].second = b - 1;
		
			k++;
		}
		else n++;
		if (b + 1 < W&&a!=1&&a!=H) {
			D[k].first = a;
			D[k].second = b + 1;
			
			k++;
		}
		else n++;
		if (a - 1 >1 && b - 1 >1) {
			D[k].first = a - 1;
			D[k].second = b - 1;
			
			k++;
		}
		else n++; 
		if (a + 1 <H && b + 1<W) {
			D[k].first = a + 1;
			D[k].second = b + 1;
			
			k++;
		}
		else n++;
		if (a - 1 >1 && b + 1 <W) {
			D[k].first = a - 1;
			D[k].second = b + 1;
			
			k++;
		}
		else n++;
		if (a + 1 <H && b - 1 >1) {
			D[k].first = a + 1;
			D[k].second = b - 1;
			
			k++;
		}
		else n++;
	}
	sort(D, D +k,greater<Edge>());
	
	
	long long int d = 0;
	for (int i = 0; i <k ; i++) {


		if (D[i].first == D[i + 1].first&&D[i].second == D[i + 1].second) {
			d++;
		}
		else {
			Q[d+1]++;
			d = 0;
		}
	}
	int q = 0;
	for (int i = 0; i < 10; i++) {
		q += Q[i];
	}
	Q[0] = H * W - q-2*H-2*W+4;


	for (int i = 0; i < 10; i++) {
		cout << Q[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	string S=in<string>();
	vector<int> L(N,0),R(N,0);
	REP(i,N){
		if(S[i]=='#') L[i]++;
		if(S[N-1-i]=='.') R[N-1-i]++;
		if(i>0){
			L[i]+=L[i-1];
			R[N-1-i]+=R[N-i];
		}
	}
	int minV = 1<<30;
	REP(i,N){
		minV = min(minV,L[i]+R[i]);
	}
	out(minV-1);
	return 0;
}


Measured memory_bytes: 2196
#include<stdio.h>

int main(){
  int i, n, a, b, scoreA, scoreB;

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

    scoreA = 0;
    scoreB = 0;
    for(i=0; i<n; i++){
      scanf("%d %d", &a, &b);

      if(a == b){
        scoreA += a;
        scoreB += b;
      }else if(a > b){
        scoreA += (a + b);
      }else{
        scoreB += (a + b);
      }
    }

    printf("%d %d\n", scoreA, scoreB);
  }

  return 0;
}

Measured memory_bytes: 0
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0]
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[i][2]
print(max(dp[-1]))


Measured memory_bytes: 47280
import itertools

n = int(input())
s = [input() for i in range(n)]

cnt = [0]*5
for i in range(n):
    if s[i][0]== 'M':
      cnt[0] += 1
    elif s[i][0]== 'A':
      cnt[1] += 1
    elif s[i][0]== 'R':
      cnt[2] += 1
    elif s[i][0]== 'C':
      cnt[3] += 1
    elif s[i][0]== 'H':
      cnt[4] += 1
cnt.sort()
# print(cnt)
p = 0
if cnt[2] == 0:
    p = 0
elif cnt[1] == 0:
    p = cnt[2]*cnt[3]*cnt[4]
elif cnt[0] == 0:
    p += cnt[1]*cnt[2]*cnt[3]
    p += cnt[1]*cnt[2]*cnt[4]
    p += cnt[1]*cnt[3]*cnt[4]
    p += cnt[2]*cnt[3]*cnt[4]
else:
    num = [0,1,2,3,4]
    combi = list(itertools.combinations(num,3))
    # print(combi)
    for i in range(len(combi)):
        a,b,c = combi[i][0], combi[i][1], combi[i][2]
        p += cnt[a]*cnt[b]*cnt[c]
print(p)

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

int main() {
  string s;
  while(cin >> s) {
    for(int i = 0; i < s.size(); ++i) {
      if(s[i] == '@') {
        cout << string(s[i+1]-'0', s[i+2]);
        i += 2;
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string s;
    cin >> s;
    pii ans = make_pair(-1, -1);
    
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            ans.first = i + 1; 
            ans.second = i + 2;
            break;
        }
    }
    
    for (int i= 0; i < s.size() - 2; i++) {
        if (s[i] == s[i + 2]) {
            ans.first = i + 1; 
            ans.second = i + 3;
            break;
        }
    }
    

    cout << ans.first << " " << ans.second << endl;
    
    
    
    
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;
const int N = 1e5+5;

//==========================================//

void solve()
{
	string s;
	ll ans=0;
	cin>>s;
	loopi(s.length())
	{
		int x=s[i]-'0';
		ans=(ans+x)%9;	
	}
	cout<<(ans?"No":"Yes");
	
}
int main()
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


Measured memory_bytes: 3764
n,m=map(int,input().split())
dp=[1]*n

mod=10**9+7
for i in range(m):
  a=int(input())
  dp[a-1]=0

ans=[]
ans.append(1 if dp[0]==1 else 0)
if len(dp)>1 and dp[0]==1 and dp[1]==1:
    ans.append(2)
elif len(dp)>1 and dp[0]==1 and dp[1]==0:
    ans.append(0)
elif len(dp)>1 and dp[0]==0 and dp[1]==1:
    ans.append(1)
elif len(dp)>1 and dp[0]==0 and dp[1]==0:
    print(0)
    exit()
for i in range(2,n):
    ans.append((ans[i-1]+ans[i-2])*dp[i]%mod)
print(ans[-1]%mod)

Measured memory_bytes: 7832
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
int n,m,x;
cin>>n>>m>>x;
int c[n],a[n][m];
for(int i=0;i<n;i++){
  cin>>c[i];
  for(int j=0;j<m;j++)cin>>a[i][j];
}
int ans=MOD*MOD;
for(int i=0;i<(1ll<<n);i++){
  int p[m]={},cc=0;
  for(int j=0;j<n;j++){
    
    if(i&(1ll<<j))continue;
    cc+=c[j];
    for(int k=0;k<m;k++){
        p[k]+=a[j][k];
    }
  }
  bool t=true;
  for(int k=0;k<m;k++)if(p[k]<x)t=false;
  if(t)ans=min(ans,cc);
}
if(ans==MOD*MOD)cout<<-1<<endl;
else cout<<ans<<endl;




}


        


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	map<int,int> even;
	map<int,int> odd;
	
	rep(i,n){
		if(i%2==0){
			even[a[i]]++;
		}else{
			odd[a[i]]++;
		}
	}
	
	vector<pair<int,int>> even2;
	vector<pair<int,int>> odd2;
	
	rep(i,100005){
		even2.push_back(make_pair(even[i], i));
		odd2.push_back(make_pair(odd[i],i));
	}
	
	sort(even2.begin(),even2.end());
	sort(odd2.begin(),odd2.end());
	reverse(even2.begin(),even2.end());
	reverse(odd2.begin(),odd2.end());
	
	if(even2[0].second != odd2[0].second){
		cout << n - even2[0].first - odd2[0].first << endl;
	}else{
		int ans = min(n-even2[1].first-odd2[0].first, n - even2[0].first - odd2[1].first);
		cout << ans << endl;
	}
	
	
	
    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < 3; i++)
    if (S[i] == 'o') cnt++;
  cout << 700 + 100 * cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 100000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'


ll n, k , a[202020], mni = inf, ans = inf;
vl p, q, v;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> k;

rep(i, 1, n){

    cin >> a[i];
    if(a[i]>=0)mni = min((ll)i, mni);
    if(a[i]>=0)v.pb(a[i]);
    if(a[i]<0)q.pb(a[i]);
}

sort(all(v));
sort(all(q));

mni = n - mni+1;

if(mni>=k){
    ans = min(ans, v[k-1] );
}

int m = q.size();
reverse(all(q));
if(m>=k){
    ans = min(ans, abs(q[k-1]) );
}

//cout << mni << " " << m << endl;



rep(i, 1, mni){

    if(m+i<k)continue;

    ll temp = 2*v[i-1];
    if(k - i >0 ){
        temp+= abs(q[k-i-1]);
    }
    ans = min(ans, temp);
    //cout << temp << endl;

}

rep(i, 1, m){

    if(mni + i <k)continue;
    ll temp = abs(2*q[i-1]);
    if(k-i > 0){
        temp+= v[k-i-1];
    }
    //cout << temp << endl;
    ans = min(ans, temp);
}


cout << ans << endl;



return 0;}
///....


Measured memory_bytes: 2424
#include "bits/stdc++.h"

using namespace std;
using int64 = long long int;

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

    for (int ans = 0; ans < 100000; ans++)
    {
        if (ans * 8 / 100 == a && ans * 10 / 100 == b)
        {
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

struct Node {
    int parent;
    ll distance;
    vector<int> children;
};

int main()
{
    scanInt(N);
    // printf("N: %d\n", N);
    vector<unordered_map<int, int>> edges(N);
    loop(i, N - 1){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        scanInt(ci);
        // printf("%d, %d, %d\n", ai, bi, ci);
        edges[ai].emplace(bi, ci);
        edges[bi].emplace(ai, ci);
    }
    scanInt(Q);
    // printf("Q: %d\n", Q);
    scanInt(K); --K;
    vector<Node> nodes(N);
    function<void(int, ll)> makeTree = [&](int n, ll dist){
        nodes[n].distance = dist;
        for (auto& e : edges[n]){
            auto& next = e.first;
            if (next == nodes[n].parent) continue;
            nodes[n].children.emplace_back(next);
            nodes[next].parent = n;
            makeTree(next, dist + e.second);
        }
    };
    // K is root
    nodes[K].parent = -1;
    makeTree(K, 0);

    loop(q, Q){
        scanInt(x); --x;
        scanInt(y); --y;
        printf("%lld\n", nodes[x].distance + nodes[y].distance);
    }
}


Measured memory_bytes: 31488
n = int(input())
a = list(map(int, input().split()))

x = [0]*(n+1)
for i in range(1, n+1):
    x[a[i-1]] += 1
sumx = 0
for i in range(1, n+1):
    sumx += x[i] * (x[i]-1) // 2

for i in range(1, n+1):
    print(sumx - x[a[i-1]] * (x[a[i-1]]-1) // 2 + (x[a[i-1]]-1) * (x[a[i-1]]-2) // 2)

Measured memory_bytes: 81996
#include<stdio.h>
int main()
{
    int A, B, C, D;
    while(scanf("%d %d %d %d", &A, &B, &C, &D)!=EOF)
    {
        int a=(A*B), b=(C*D);
        if(a>b)
            printf("%d", a);
        else if (a<b)
            printf("%d", b);
        else
            printf("%d", a);
    }
    return 0;
}

Measured memory_bytes: 128
//132 C - Divide the Problems

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

/* NG source
int main(){
    int n; cin >> n;
    vector<int> d(n);
    int count_low = 0;
    int count_high = 0;
    int ans = 0;
    rep(i ,n) cin >> d[i];
    rep(k ,100000){
        rep(i ,n){
            if(d[i] < k) ++count_low;
            else ++count_high;
        }
        if (count_low == count_high) ++ans;
        count_low = count_high = 0;
    }
    cout << ans << endl;
}
*/

int main(int argc , char* argv[]){
    int n; cin >> n;
    vector<int> d(n);
    rep(i ,n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}



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

int main(void) {
	int N;
	scanf("%d", &N);
	int tmp = N;
	int f = 0;
	while (tmp > 0) {
		f += tmp % 10;
		tmp /= 10;
	}

	printf(N % f == 0 ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>cnt(n,0);
    for(ll i=0;i<n;i++){
        cin >> a[i];
        cnt[a[i]-1]++;
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=(cnt[i]*(cnt[i]-1))/2;
    }
    ll copy=ans;
    for(ll i=0;i<n;i++){
        copy-=(cnt[a[i]-1]*(cnt[a[i]-1]-1))/2;
        copy+=((cnt[a[i]-1]-2)*(cnt[a[i]-1]-1))/2;
        cout << copy << endl;
        copy=ans;
    }
}

Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mod 1000000007
using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    int minimum = 1000001;
    int maximim = -1000001;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        minimum = min(x, minimum);
        maximim = max(x, maximim);
        sum += x;
    }

    cout << minimum << " " << maximim << " " << sum << endl;
    return 0;
}



Measured memory_bytes: 3120
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}


fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let string: String = iter.parse();
    let s = string.chars().collect::<Vec<_>>();

    let mut w = if s[0] == '0' { 0 } else { 1 };
    let mut b = if s[0] == '1' { 0 } else { 1 };

    for (i, &c) in s[1..].into_iter().enumerate() {
        let col = if i % 2 == 0 { '1' } else { '0' };
        if c == col {
            b += 1;
        } else {
            w += 1;
        }
    }

    println!("{}", std::cmp::min(w, b));
}

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

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

    llong n, p;
    cin >> n >> p;

    unordered_map<llong, llong> UM;
    llong i = 2;
    while(i * i <= p) {
        if (p % i == 0) {
            ++UM[i];
            p /= i;
        } else {
            ++i;
        }
    }

    if (p != 1) ++UM[p];
    llong ans = 1;
    for (unordered_map<llong, llong>::iterator itr = UM.begin(); itr != UM.end(); ++itr) {
        ans *= pow(itr->first, itr->second / n);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::set<int> as;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
    }

    int vari = 0;
    for (int i = 0; i < n; i++)
    {
        if(a[i] >= 3200) {
            vari++;
        } else if(a[i] >= 2800) {
            as.insert(0);
        } else if(a[i] >= 2400) {
            as.insert(1);
        } else if(a[i] >= 2000) {
            as.insert(2);
        } else if(a[i] >= 1600) {
            as.insert(3);
        } else if(a[i] >= 1200) {
            as.insert(4);
        } else if(a[i] >= 800) {
            as.insert(5);
        } else if(a[i] >= 400) {
            as.insert(6);
        } else{
            as.insert(7);
        }
    }

    int minans = as.size();
    if (as.size() == 0)
    {
        minans = 1;
    }
    std::cout << minans << " " << as.size() + vari << "\n";
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int p;
  while(true){
    cin >> p;
    if(p==0) break;
    int u[p],d[p],l[p],r[p];
    int U=1,D=0,L=0,R=1;
    u[0]=1;d[0]=0;l[0]=0;r[0]=1;
  //d::0-l,1-d,2-r,3-u
    for(int i=1;i<p;i++){
      int n,dir;
      cin >> n >> dir;
      if(dir==0){
        u[i]=u[n];d[i]=d[n];l[i]=l[n]-1;r[i]=r[n]-1;
        U=max(U,u[i]);D=min(D,d[i]);L=min(L,l[i]);R=max(R,r[i]);
      }
      else if(dir==1){
        u[i]=u[n]-1;d[i]=d[n]-1;l[i]=l[n];r[i]=r[n];
        U=max(U,u[i]);D=min(D,d[i]);L=min(L,l[i]);R=max(R,r[i]);
      }
      else if(dir==2){
        u[i]=u[n];d[i]=d[n];l[i]=l[n]+1;r[i]=r[n]+1;
        U=max(U,u[i]);D=min(D,d[i]);L=min(L,l[i]);R=max(R,r[i]);
      }
      else{
        u[i]=u[n]+1;d[i]=d[n]+1;l[i]=l[n];r[i]=r[n];
        U=max(U,u[i]);D=min(D,d[i]);L=min(L,l[i]);R=max(R,r[i]);
      }
    }
    cout << R-L << " " << U-D << endl;
  }
}

Measured memory_bytes: 3032
h, w = map(int, input().split())
l = []
for i in range(h):
  s = input()
  a = []
  for j in range(w):
    a.append(s[j])
  l.append(a)

non_h = []
for i in range(h):
  set_l = list(set(l[i]))
  if len(set_l) == 1 and set_l[0] == '.':
    non_h.append(i)
for i in range(len(non_h)):
  l.pop(non_h[i] - i)

non_w = []
for j in range(w):
  a = []
  for i in range(len(l)):
    a.append(l[i][j])
  b = list(set(a))
  if len(b) == 1 and b[0] == '.':
    non_w.append(j)

new_l = []
for i in range(len(l)):
  new = []
  for j in range(len(l[i])):
    if not j in non_w:
      new.append(l[i][j])
  new_l.append(new)

for e in new_l:
  for i in range(len(e)):
    print(e[i], end='')
  print()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  vector<int> d(n);
  for(int i = 0 ; i < n ; i++){
    cin >> d.at(i);
  }
  int sum;
  int onaji;
  for(int i = 0 ; i < n ; i++){
    int hikaku = d.at(i);
    onaji = 0;
      for(int j = 0 + i ; j < n ; j++){
        if( hikaku == d.at(j)){
          onaji += 1;

        }
                  if(onaji == 2){
            break;
          }
        if( j == n - 1){
            sum += 1;
        }
      }
  }
  cout << sum << endl;  
}


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

#define INF (INT32_MAX)
#define MOD (1000000000+7)
#define MAX 100000

string w;

int c[26];

int main() {
	cin >> w;

	for( int i = 0; i < w.size(); i++ ) {
		c[ w[i] - 'a' ]++;
	}
	int ans = 0;
	for( int i = 0; i < 26; i++ ) {
		if( c[i] % 2 ) {
			ans = 1;
		}
	}

	if( ans == 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int n;
	cin>>n;
	int a[n];
	REP(i,n) cin>>a[i];
	int i=0,j=n-1;
	int k=0;
	int b[n];
	while(j>=0)
	{
		b[k]=a[j];
		j--;
		b[n-k-1]=a[j];
		j--;
		k++;
	}
	if(n%2==1)
		b[n/2]=a[0];
	REP(i,n) cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]){
    bool all_visited = true;

    roop(i, n){
        if(visited[i] == false){
            all_visited = false;
        }
    }

    if(all_visited) return 1;

    int ret = 0;

    roop(i, n){
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,n,visited);
        visited[i] = false;
    }

    return ret;
}

int main(void){

    int n, m;
    cin >> n >> m;

    roop(i, m){
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[nmax];
    roop(i, n){
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, n, visited) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    int n, q, c, b, e;
    cin >> n;
  	int a[n];
  	for (int i = 0; i < n; i++) cin >> a[i];
  	cin >> q;
  	for (int i = 0; i < q; i++)
  	{
        cin >> c >> b >> e;
  	    if (c == 0) cout << *min_element(a+b,a+e) << endl;
  	    if (c == 1) cout << *max_element(a+b,a+e) << endl;
  	}
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);
static const int MAX = 200005;
vector<vector<int>> g(MAX);
int N, Q;
int cnt[MAX];
ll ans[MAX];

ll dfs(int idx, ll sum) {
  ans[idx] = sum + cnt[idx];
  ll y;

  for (auto x : g[idx]) {
    y += dfs(x, ans[idx]);
  }
  
 // ans[idx] = y;

  return y;
}

int main() {
  cin >> N >> Q;
  rep(i, N-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }
  rep(i, Q) {
    int p, x; cin >> p >> x;
    p--;
    cnt[p] += x;
  }

  ll tmp = dfs(0, 0LL);

  rep(i, N) {
    cout << ans[i] << " ";
  }
  

  return 0;
}


Measured memory_bytes: 24832
#include <iostream>

int main() {
  long long x;

  std::cin >> x;

  if (1 <= x && x <= 6) {
    std::cout << 1 << "\n";
  } else if (7 <= x && x <= 11) {
    std::cout << 2 << "\n";
  } else {
    long long cnt = x / 11 * 2;
    int mod = x % 11;
    if (mod > 6) {
      std::cout << cnt + 2 << "\n";
    } else if (mod != 0) {
      std::cout << cnt + 1 << "\n";
    } else {
      std::cout << cnt << "\n";
    }
  }
  return 0;
}

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

using namespace std;

int main() {

    long long a, b, c;
    cin >> a >> b >> c;

    if (b >= c) {
        cout << b + c << endl;
    } else {
        if (a + b >= c) {
            cout << b + c << endl;
        } else {
            cout << (a + b) + b + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 


int main() {
    string s;
    cin >> s; 
    if ((s[2] == s[3]) && (s[4] == s[5])) 
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

typedef long long int ll;
typedef long double ld;

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

// order_of_key (k) : Number of items strictly smaller than k, basically 0-based index of k
// find_by_order(k) : K-th element in a set (counting from zero)

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	char c; cin >> c;
	c = 'a' + ((c - 'a') + 1);
	cout << c << endl;
	return 0;
}


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

int idx[100010] = {0};

int main()
{
    int N, Q;
    string s;

    cin >> N >> Q;
    cin >> s;

    int cnt = 1;
    for (int i = N-2; i >= 0; i--)
    {
        if (s[i] == 'A' && s[i+1] == 'C')
        {
            idx[i] = idx[i+1]+1;
        }
        else
        {
            idx[i] = idx[i+1];
        }
    }


    int l, r;
    for (int i = 0; i < Q; i++)
    {
        cin >> l >> r;
        cout << idx[l-1]-idx[r-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include<vector>
#include<string>
#include <numeric>
#include <utility>
#include<math.h>
#include<functional>
#include<queue>
#include<sstream>
#include<stack>
#include<algorithm>

int solve(int N,int K,int X,int Y){
    int ct=0;
    for(int i=0;i<N;i++){
        if(i>K-1)ct+=Y;
        else ct+=X;
    }
    std::cout<<ct;
    return 0;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N,K,X,Y;
    std::cin>>N>>K>>X>>Y;
    return solve(N,K,X,Y);
}


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

int main() {
	int n; cin >> n;
	bool ans = true;
	int t, x, y, pt = 0, px = 0, py = 0;
	for (int i = 0; i < n; ++i) {
		cin >> t >> x >> y;
		int l = abs(x - px) + abs(y - py);
		if ((t - pt - l) < 0 || (t - pt - l) % 2 == 1)
			ans = false;
	}
	
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
    int n; scanf("%d", &n);
    int a[n]; for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int num_query; scanf("%d", &num_query);
    int k;
    
    for (int i = 0; i < num_query; ++i) {
        scanf("%d", &k);
        int result = 0;
        
        if (binary_search(a, a + n, k)) result = 1;
        
        printf("%d\n", result);
    }
    return 0;
}


Measured memory_bytes: 3604
#include"stdio.h"
#include"string.h"
main(){
	char S[26];
	int i,j;
	gets(S);
	for(i=0;i<(strlen(S)-1);i++)
	{for(j=i+1;j<strlen(S);j++)
	{if(S[i]==S[j]) break;}
	if(j!=strlen(S)) break;}
	if(i==(strlen(S)-1)) printf("yes\n");
	else printf("no\n");
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 17:51:20 2020

@author: shinba
"""

n = int(input())
d,x = map(int,input().split())
cnt1 = 0
for i in range(n):
    a = int(input())
    cnt2 = 0
    while cnt2*a+1 <= d:
        cnt2 += 1
        cnt1 += 1

print(x+cnt1)


Measured memory_bytes: 3064