akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<stack>
#include<queue>
bool isexist = true;
const int infty = 100000000;
const int vmax = 100000;
typedef int vname;
struct vertex;
struct edge {
	int weight;
	vertex *to;
	edge(int w, vertex *v) :weight(w), to(v) {};
};
struct vertex {
	std::vector<edge> adj;
	int distance;
	vname name;
	vertex(vname s) :name(s) {}
};
class graph {
private:
	std::map<vname, vertex*> work;
public:
	int vertexsize, edgesize;
	void addvertex(const vname& name) {
		if (work.count(name) == 0) work[name] = new vertex(name);
	}
	void addedge(vname from, vname to, int cost) {
		if (work.count(from) > 0 && work.count(to) > 0) {
			(work[from]->adj).push_back(edge(cost, work[to]));
		}
	}
	void bfs() {
		std::map<vname, bool> visited;
		std::stack<vertex *> st;
		for (auto i : work)visited[i.first] = false;
		for (auto i : work) {
			if (!visited[i.first]) {
				visited[i.first] = true;
				work[i.first]->distance = 0;
				st.push(work[i.first]);
				while (!st.empty()) {
					vertex *v = st.top();
					st.pop();
					for (auto e : v->adj) {
						if (!visited[e.to->name]) {
							visited[e.to->name] = true;
							e.to->distance = v->distance + e.weight;
							st.push(e.to);
						}
						else {
							if (e.to->distance != v->distance + e.weight)isexist = false;
						}
					}
				}
			}
		}
	}
};
int main() {
	graph g;
	vname a, b;
	int d;
	scanf("%d%d", &g.vertexsize, &g.edgesize);
	for (int i = 0; i < g.edgesize; i++) {
		std::cin >> a >> b >> d;
		g.addvertex(a);
		g.addvertex(b);
		g.addedge(a, b, d);
		g.addedge(b, a, -d);
	}
	g.bfs();
	if (isexist)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 26112
#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;
const ll MOD = 1000000007;


int main(){
	int n,m;
	cin >> n >> m;
	
	vector<bool> ok(n);
	
	ok.assign(m,true);
	
	rep(i,m){
		int x;
		cin >> x;
		ok[x] = false;
	}
	
	//i段目までの登り方の総数
	vector<ll> dp(n+1);
	dp[0] = 1;
	
	rep(i,n){
		for (int next = i+1; next <= min(n,i+2) ; ++next) {
			if (ok[next]){
				dp[next] += dp[i];
				dp[next] %= MOD;
			}
		}
	}
	
	cout << dp[n] << endl;
	
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  string s[3];;
  int cnt[3] = {0};
  int now = 0;

  Rep(i, 3) cin >> s[i];

  while( 1 ) {
    if( cnt[now] == s[now].size() ) {
      cout << char('A' + now) << endl;
      break;
    }
    char next = s[now][cnt[now]];
    cnt[now]++;
    now = next - 'a';
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
long long k, n;
const int N = 1010101;
long long a[N], f[N];
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> f[i];
  }
  sort(a, a + n);
  sort(f, f + n);
  long long lo = -1, hi = 1e12 + 1;
  while (hi - lo > 1) {
    long long mid = (hi + lo) >> 1;
    long long cost = 0;
    vector<long long> c(n);
    for (int i = 0; i < n; i++) {
      c[i] = mid / f[i];
    }
    sort(c.begin(), c.end());
    for (int i = 0; i < n; i++) {
      cost += max(0LL, a[i] - c[i]);
    }
    if (cost <= k) hi = mid;
    else lo = mid;
  }
  cout << hi << '\n';
  return 0;
}

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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{  
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    int res=0;
    for(int i=0;i<n;i++)
    if(((i+1)&1)&&(arr[i]&1))
    res++;
    cout<<res<<endl;
  
}


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

Measured memory_bytes: 3608
/*  
    Through the fish-eyed lens of tear stained eyes
    I can barely define the shape of this moment in time
    And far from flying high in clear blue skies
    I'm spiralling down to the hole in the ground where I hide
    _________________________
    _________________________
    1032 Hours of Solitude
    Quarantine_Day : 43
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 1000

bool go(string s){
    if(s[0] != 'A') return false;
    if(count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
    for(auto c : s){
        if(c != 'A' && c != 'C' && isupper(c)) return false;
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s; cin>>s;
    cout<<(go(s)?"AC\n":"WA\n");

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    
    if(s[0] == 'S'){
        if(s[1] == 'S'){
            if(s[2] == 'S') ans = 0;
            if(s[2] == 'R') ans = 1;
        }
        if(s[1] == 'R'){
            if(s[2] == 'S') ans = 1;
            if(s[2] == 'R') ans = 2;
        }
    }
    if(s[0] == 'R'){
        if(s[1] == 'S'){
            if(s[2] == 'S') ans = 1;
            if(s[2] == 'R') ans = 1;
        }
        if(s[1] == 'R'){
            if(s[2] == 'S') ans = 2;
            if(s[2] == 'R') ans = 3;
        }
    }

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

Measured memory_bytes: 3584
#include <iostream>
#include <math.h>
#include <string.h>

using namespace std;

const int MAX_N = 24;

class Circle {
public:
	short x, y, r, c; // 中心のxy座標、半径、色番号
};

/* 入力 */
int n; // 円盤の枚数
Circle cir[MAX_N]; // 円の情報

/*
S:すでに取り除いた円の集合(bitで表す、右から円番号0,1,2,...,MAX_N)
dp[S]:ここから取り除ける最大枚数
漸化式
dp[全部取り除いた] = 0
dp[S] = max(dp[S U 取り除いた2つの円]+2)
*/
short dp[1 << MAX_N];

/* 2点間の距離 */
double dis(char x1, char y1, char x2, char y2) {
	return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

/* 円kが上に1枚でも重なっているかどうか、重なっていたらtrue */
bool ispiled(int k, int S) {
	for (int i = k - 1; i >= 0; i--) {
		if (dis(cir[i].x, cir[i].y, cir[k].x, cir[k].y) < cir[i].r + cir[k].r && !(S >> i & 1)) {
			return true;
		}
	}
	return false;
}
/*
bool ispiled(Circle c1, Circle c2) {
	if (dis(c1.x, c1.y, c2.x, c2.y) < c1.r + c2.r) {
		return true;
	}

	return false;
}
*/

/* S:すでに取り除いた円盤の集合 */
short remove(int S) {
	//cout << "S = " << S << " dp[" << S << "]: " << dp[S] << endl;
	if (dp[S] >= 0) {
		return dp[S];
	}
	
        /* 全部取り除いた */
	if (S == ((1 << n) - 1)) {
		return dp[S] = 0;
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		if (S >> i & 1 || ispiled(i, S)) {
			continue;
		}
		for (int j = i + 1; j < n; j++) {
			/* どちらかがすでに取り除かれているか、2つの色が違うか、2枚のうち1枚以上が下にあれば取り除けないので次の組へ */
			if (S >> j & 1 || cir[i].c != cir[j].c || ispiled(j, S)) {
				continue;
			}

			if (true) {
				int tmp = S | 1 << i;
				tmp = tmp | 1 << j;
				res = max(res, remove(tmp) + 2);
			}
		}
	}
	return dp[S] = res;
}

int main() {
	// 方針: bitDP
	//const int MAX_N = 24;
	while (true) {
		//cout << "n=" << endl;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> cir[i].x >> cir[i].y >> cir[i].r >> cir[i].c;
		}
		memset(dp, -1, sizeof(dp));
		//cout << "test" << endl;
		cout << remove(0) << endl;
	}

	return 0;
}

Measured memory_bytes: 33940
import sys

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


def main():
    x = LI()
    if x[0] == 0:
        print(1)
    elif x[1] == 0:
        print(2)
    elif x[2] == 0:
        print(3)
    elif x[3] == 0:
        print(4)
    elif x[4] == 0:
        print(5)
    print()

if __name__ == "__main__":
	main()

Measured memory_bytes: 9208
#include<stdio.h>
#include<math.h>
  
int main(void){
    double pi,a,b,c,s,l,h,rad,x;
    scanf("%lf %lf %lf",&a,&b,&c);
    pi=acos(-1);
    rad=(c/(double)180)*pi;
    s=a*b*sin(rad)*0.5;
    x=sqrt(a*a+b*b-(double)2*a*b*cos(rad));
    l=a+b+x;
    h=(double)2*(s/a);
    printf("%f\n%f\n%f\n",s,l,h);
return 0;
}


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

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(s.find(x)==s.end())s.insert(x);
        else{
            s.erase(s.find(x));
        }
    }
    cout<<s.size();
}


Measured memory_bytes: 4864
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
double dp[3000][3000];
void solve()
{
	IN(n);
	vector<double>v;
	cout << setprecision(10);
	FOR(i, 0, n)
	{
		double in;
		cin >> in;
		v.push_back(in);
	}
	dp[0][0] = 1;
	FOR(i, 1, n + 1)	dp[i][0] =dp[i-1][0]*( 1 - v[i - 1]);
	FOR(i, 1, n + 1)
	{
		FOR(j, 1, i + 1)
		{
			dp[i][j] = dp[i - 1][j - 1] * v[i - 1] + dp[i - 1][j] * (1 - v[i - 1]);
		}
	}
	double ans = 0;
	FOR(i, n / 2+1, n+1)
		ans += dp[n][i];
	cout << ans;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 49852
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const int N = 1000001;
using namespace std;


void f() {

}


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll suf[n];
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        suf[i] = (a[i] + suf[i + 1]) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans = (ans + a[i] * suf[i + 1]) % mod;
    }
    
    cout << ans;

}

Measured memory_bytes: 6776
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include<bitset>


using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846


int main()
{
    ll n;
    cin >> n;
    vector<ll> vc(n);

    for (ll i = 0; i < n; i++)
    {
        cin >> vc[i];
    }
    ll count = 1;
    ll ans = 0;
    ll temp = -1;

    for (ll i = 0; i < n; i++)
    {
        if (vc[i]==count)
        {
            ans+= i-temp-1;
            count++;
            temp = i;
        }
    }
    ans+=n-temp-1;
    
    if (count==1)
    {
        cout << -1 << endl;
    }else
    {
        cout << ans << endl;
    }
    
    
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  if(n != 1 && n != 2 && n != 3 && n != 5 && n != 6 && n != 9 && n != 10 && n != 13 && n != 17)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <utility>
#include <valarray>
#include <vector>

#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n)    rep(i, 0, n)
#define all(e)       (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#else
#define show() true
#endif

using namespace std;
using ll=long long;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1000000007;

class Solver {
public:
    bool solve() {
        getline(cin, S);

        if (S == ".") return false;

        for (auto c:S) {
            if (c == '(') {
                kakko.push(c);
            }
            if (c == '[') {
                kakko.push(c);
            }
            if (c == ')') {
                if (kakko.empty() || kakko.top() != '(') {
                    puts("no");
                    return true;
                } else {
                    kakko.pop();
                }
            }
            if (c == ']') {
                if (kakko.empty() || kakko.top() != '[') {
                    puts("no");
                    return true;
                } else {
                    kakko.pop();
                }
            }
        }

        puts(kakko.empty() ? "yes" : "no");

        return true;
    }

private:
    string S;
    stack<char> kakko;
};

int main() {

    while (Solver().solve());

    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  string s;
  cin >> s;
  sort(s.begin(), s.end());
  map<char, int> ss;
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<ll> l(n);
  for(int i = 0;i < n;i++)cin >> l[i];
  ll res = 0;
  res = pow(10,18);
  vector<ll> p(n);
  for(int i = 0;i < n;i++)p[i] = 0;
  for(int i = 0;i < pow(4,n);i++){
    ll change = -1;
    for(int j = 0;j < n;j++){
      if(p[j] <= 2){
        p[j]++;
        change = j;
        break;
      }
    }
    if(change == -1)break;
    //cout << "A" << endl;
    for(int j = 0;j < change;j++)p[j] = 0;
    ll ae = 0;
    ll be = 0;
    ll ce = 0;
    ll now = 0;
    for(int j = 0;j < n;j++){
      if(p[j] == 1)ae += l[j],now += 10;
      if(p[j] == 2)be += l[j],now += 10;
      if(p[j] == 3)ce += l[j],now += 10;
    }
    if(ae*be*ce == 0)continue;
    now += abs(a - ae) + abs(b - be) + abs(c - ce);
    now -= 30;
    res = min(res,now);
  }
  cout << res << endl;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
int n,a,b,satu=0;
vector <int> v[100005];
queue<pair<int,int> > q;
int f[100005]={0};

void bfs(){
	satu=0;
	while (!q.empty()){
		pair<int,int> front = q.front();
		++satu;
		q.pop();
		for (int j=0; j<v[front.first].size(); j++)
			if (f[v[front.first][j]]>front.second+1){
				f[v[front.first][j]]=front.second+1;
				q.push(make_pair(v[front.first][j],front.second+1));
			}
	}
}
int main(){
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i=1; i<=n; i++) f[i]=2000000000;
	q.push(make_pair(1,0));	
	f[1]=0;
	bfs();
	q.push(make_pair(n,0));	
	f[n]=0;
	bfs();
	if (satu>=n-satu) cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,q;
  string s;
  cin >> n >> s >> q;
  while(q--) {
    ll k;
    cin >> k;
    ll d=0,m=0,dm=0;
    ll res=0;
    for(ll i=0;i<n;i++) {
      if(i>=k) {
        if(s[i-k]=='D') d--,dm-=m;
        if(s[i-k]=='M') m--;
      }
      if(s[i]=='D') d++;
      if(s[i]=='M') m++,dm+=d;
      if(s[i]=='C') res+=dm;
    }
    cout << res << endl;
  }
}

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

long long a[200000][5];

bool cmp(long long p,long long q)
{
	return p>q;
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	long long ans=-1;
	for(int i=0;i<8;i++)
	{
		long long f[1000000];
		for(int j=1;j<=n;j++)
		{
			long long sum=0;
			int tmp=i;
			for(int k=1;k<=3;k++)
			{
				if(tmp%2==1)
					sum+=a[j][k];
				else
					sum-=a[j][k];
				tmp/=2;
			}
			f[j]=sum;
		}
		sort(f+1,f+1+n,cmp);
		long long s=0;
		for(int j=1;j<=m;j++)
			s+=f[j];
		ans=max(s,ans);
	}
	cout<<ans;
	return 0;
}


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

#define vec_range(n1, n2) vec.begin() + n1, vec.begin() + n2

int main() {
	vector<int> vec; int an, qn, cn, fn1, fn2; cin >> an; vec.resize(an);
	for (int i = 0; i < an; i++) cin >> vec[i];
	cin >> qn;
	for (int i = 0; i < qn; i++) {
		cin >> cn >> fn1 >> fn2;
		switch (cn) {
		case 0:	cout << *min_element(vec_range(fn1, fn2)) << endl; break;
		case 1:	cout << *max_element(vec_range(fn1, fn2)) << endl; break;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
   int n,i,m,p[10000],a;

   scanf("%d",&n);
   for (i=0;i<n;i++)
      scanf("%d",&p[i]);
   m=p[0];
   a=0;
   for (i=0;i<n;i++){
      a=a+p[i];
      if (m<p[i])
        m=p[i];
   }
   printf("%d\n",a-(m/2));
   return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> b(n+1);
	for (int i = 1; i < n;i++) {
		cin >> b.at(i);
	}
	b.at(0) = b.at(1);
	b.at(n) = b.at(n - 1);

	int result = 0;
	for (int i = 0; i < n; i++) {
		result += min(b.at(i), b.at(i + 1));
	}

	cout << result;
}

Measured memory_bytes: 256
#https://www.geeksforgeeks.org/fifth-root-of-a-number/
def floorRoot5(n):
	if n == 0 or n == 1:
		return n
	low, high, ans = 1, n, 0
	while low <= high:
		mid = (low + high) // 2
		mid5 = mid * mid * mid * mid * mid

		if mid5 == n:
			return mid
		if mid5 < n:

			low = mid + 1
			ans = mid
		else:
			high = mid - 1

	return ans


val = int(input())
start = -floorRoot5(val) - 1

while True:
	b = start
	a = floorRoot5(val + b ** 5)
	for aa in range(a - 1, a + 2):
		for bb in range(b - 1, b + 2):
			if aa ** 5 - bb ** 5 == val:
				print(aa, bb)
				exit(0)
			if bb ** 5 - aa ** 5 == val:
				print(bb, aa)
				exit(0)
	start += 1


Measured memory_bytes: 9228
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int in0 = int.Parse(inS[0]);
            int in1 = int.Parse(inS[1]);

            string str = Console.ReadLine();

            for (int i = 0; i < str.Length; i++)
            {
                if ((i + 1) != in1)
                {
                    Console.Write("{0}", str[i]);
                }
                else
                {
                    Console.Write("{0}", (char)(str[i] - 'A' + 'a'));
                }
            }
        }
    }
}


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

typedef long long ll;


int N = 26;
int D;

vector<int> c(N+1);
vector<vector<int>> s;
vector<int> t;

ll now_score = 0;

ll greedy(){
    vector<int> last(N+1, 0);
    ll greedy_score=0;
    for(int d = 1; d <= D; d++){
        ll max_score = -1e9;
        vector<int> max_last;
        for(int n = 1; n <= N; n++){
            ll tmp_score = 0;
            vector<int> tmp_last(N+1);
            tmp_last = last;
            
            tmp_score +=  s[d][n];
            tmp_last[n] = d;
     
            int penalty = 0;
            for(int i = 1; i <= N; i++){
                penalty += c[i]*(d-tmp_last[i]);    
                
            }
            
            tmp_score -= penalty;

            if(max_score < tmp_score){
                max_score = tmp_score;
                max_last = tmp_last;
                t[d] = n;
            }                    
            
        }
        
        last = max_last;
        greedy_score += max_score;
    }

    return greedy_score;
}


ll scoring(){
    vector<int> last(N+1, 0);
    ll score = 0;
    for(int d = 1; d <= D; d++){

        score += s[d][t[d]];
        last[t[d]] = d;

        int penalty = 0;
        for(int i = 1; i <= N; i++){
            penalty += c[i]*(d-last[i]);    
        }
        
        score -= penalty;            
    }
    return score;
}


void exchange(int d, int x){
    swap(t[d], t[d+x]);

    ll swap_score = scoring();
    
    if(now_score >= swap_score){
        swap(t[d], t[d+x]);
    }else{
        now_score = swap_score;
    }

}



int main(){

    cin>> D;

    s.resize(D+1);
    for(int i=0; i<=D; i++){
        s[i].resize(N+1);
    }
    t.resize(D+1);

    for(int i=1; i<=N; i++){
        cin>>c[i];
    }
 
    for(int i=1; i<=D; i++){
        for(int j=1; j<=N; j++){
            cin>>s[i][j];
        }
    }
    for(int i=1; i<=D; i++){
        cin>>t[i];
    }

    now_score = greedy();

    //解交換
    
    for(int x=1; x<D; x++){
        for(int d=1; d<=D-x; d++){
            exchange(d, x);
        }
    }
    
    
    for(int i=1; i<=D; i++){           
        cout<<t[i]<<endl;
    }
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
int dist[111];
vector<vector<int>> G;

int main() {
   cin >> N;
   G = vector<vector<int>>(N);
   rep (i, N) {
      int u, k; cin >> u >> k; u--;
      rep (i, k) {
         int a; cin >> a; a--;
         G[u].push_back(a);
      }
   }

   rep (i, N) dist[i] = -1;

   queue<int> que;
   que.push(0);
   dist[0] = 0;
   while (que.size()) {
      int cur = que.front(); que.pop();
      for (int x : G[cur]) {
         if (dist[x] == -1) {
            dist[x] = dist[cur] + 1;
            que.push(x);
         }
      }
   }

   rep (i, N) {
      printf("%d %d\n", i+1, dist[i]);
   }


   return 0;
}


Measured memory_bytes: 3280
import numpy as np
N = int(input())
num_list = np.array(input().split(), dtype="int")

max_num = max(num_list)
max_bit_num = format(max_num, "b")
max_bit_num_length = len(max_bit_num)
ans = 0
radix = 1
for i in range(max_bit_num_length):
  new_num_list = (num_list >> i) & 1
  one_amount = np.count_nonzero(new_num_list == 1)
  zero_amount = len(num_list) - one_amount
  ans += (one_amount*zero_amount)*radix
  radix *= 2
print(ans%(10**9+7))

Measured memory_bytes: 82364
import sys


def factorial(N: int, mod: int) -> int:
    res = 1
    for i in range(1, N+1):
        res *= i
        res %= mod
    return res


N = int(input())
S = input()
mod = 10**9+7

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = [0]*(2*N)
op[0] = False
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        op[i] = True if op[i-1] is False else False
    else:
        op[i] = True if op[i-1] is True else False

if op.count(True) != N:
    print(0)
    sys.exit()

ans = 1
L_ct = 0
R_ct = 0
for i in op:
    if i:
        ans *= L_ct
        L_ct -= 1
    else:
        L_ct += 1
    ans %= mod

print(factorial(N, mod) * ans % mod)


Measured memory_bytes: 4968
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	string str;
	while(getline(cin,str)){
		for(auto it:str){
			if('a'<=it&&it<='z'){it-=32;}
			else if('A'<=it&&it<='Z'){it+=32;}
			cout<<it;
		}
		cout<<endl;
	}
	RE;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vector<ll>on(60),a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++){
    for(int j=0; j<60; j++){
      if(a[i] >> j & 1) on[j]++;
    }
  }
  
  for(int i=0; i<60; i++){
    on[i]%=2;
    //cout << on[i] << " " ;
  }
  //cout << endl;
  
  ll ans=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<60; j++){
      ll count;
      if(a[i] >> j & 1) count=1;
      else count =0;
      //cout << count << " ";
      if(count!=on[j]) ans += pow(2,j);
    }
    cout << ans << endl;
    ans=0;
  }
}
  
  
  


Measured memory_bytes: 4888
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

vector<long long int> divisor(long long int n) {
	vector<long long int> res;
	for (long long int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}

vector<int>compress(vector<int>nums) {
	auto divs(divisor(nums.size()));
	reverse(divs.begin(),divs.end());
	for (auto div : divs) {
		bool ok=true;

		for (int i = 0; i < nums.size() / div; ++i) {
			for (int j = 1; j < div; ++j) {
				if(nums[i*div+j])ok=false;
			}
		}
		if (ok) {
			vector<int>ans(nums.size()/div);
			for (int i = 0; i < nums.size() / div; ++i) {
				ans[i]=nums[i*div];
			}
			return ans;
		}
	}
	assert(false);
	return vector<int>();
}

vector<int>mk(string st) {
	vector<int>nums(st.size()/2);
	for (int i = 0; i < st.size() / 2; ++i) {
		char c1 = st[2*i];
		char c2=st[2*i+1];
		int num=!isdigit(c1)?(c1-'A'+10):c1-'0';
		num*=16;
		num+=!isdigit(c2)?(c2-'A'+10):c2-'0';

		nums[i]=num;
	}
	return compress(nums);
}

long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

int main() {
	int Q;cin>>Q;
	while (Q--) {
		int N;cin>>N;

		vector<vector<int>>rythms;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			rythms.push_back(mk(st));
		}

		int alca=1;
		for (int i = 0; i < N; ++i) {
			alca=alca*rythms[i].size()/gcd(alca,rythms[i].size());
			if (alca > 1024) {
				alca=-1;
				break;
			}
		}
		if (alca == -1) {
			cout<<"Too complex."<<endl;
		}
		else {
			vector<int>anss(alca);
			for (auto rythm: rythms) {
				
				for (int i = 0; i < rythm.size(); ++i) {
					anss[i*(alca/rythm.size())] |= rythm[i];
				}
				
			}
			anss=compress(anss);
			for (auto ans : anss) {
				int l=ans/16;
				int r=ans%16;
				if(l>=10)cout<<string(1,char('A'+l-10));
				else cout<<l;

				if(r>=10)cout<<string(1,char('A'+r-10));
				else cout<<r;
			}
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3260
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

// NO SAD

int l[2005];
void solve() {
  int n;
  ll k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> l[i];
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      if(l[i] == l[j]) continue;
      else if(l[i] < l[j]) {
        ret += (k-1)*(k-0)/2;
      }
      else {
        ret += (k-0)*(k+1)/2;
      }
      ret %= 1000000007;
    }
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  // casesolve();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t N,X;
int64_t solve(int64_t n,int64_t x){
if(n==0 && x==1)
  return 1;
  else{
  if(x==1)
    return 0;
    else if(2<=x && x<=pow(2,n+1)-2)
      return solve(n-1,x-1);
    else if(x==pow(2,n+1)-1)
      return pow(2,n);
    else if(pow(2,n+1)<=x && x<=pow(2,n+2)-4)
      return pow(2,n)+solve(n-1,x+1-pow(2,n+1));
      else
        return pow(2,n+1)-1;
  }

}
int main(){
  cin>>N>>X;
  int64_t ans=solve(N,X);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4104
N = int(input())
B = [[0]*3]*N
for i in range(N):
    B[i] = list(map(int,input().split()))
ans = 'Yes'
B.insert(0,[0,0,0])
for i in range(N):
    T = B[i+1][0] - B[i][0] 
    S = abs(B[i+1][1] - B[i][1]) + abs(B[i+1][2] - B[i][2])
    if T >= S and (T - S)%2 == 0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,k;
int anss[1007][1007],ans[1007][1007];
int main()
{
	n=read(),m=read(),k=read();
	if (k%2==1)
	{
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++)
				ans[i][j]=(i+j)%2+1;
	} else
	{
		
		for (int i=0;i<=n+m;i++)
			for (int j=0;j<=n+m;j++)
			{
				if (i%(2*k)<k&&j%(2*k)<k) anss[i][j]=1;
				if (i%(2*k)<k&&j%(2*k)>=k) anss[i][j]=2;
				if (i%(2*k)>=k&&j%(2*k)<k) anss[i][j]=3;
				if (i%(2*k)>=k&&j%(2*k)>=k) anss[i][j]=4;
			}
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++)
				ans[i][j]=anss[i-j+m][i+j];
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (ans[i][j]==1) printf("R");
			if (ans[i][j]==2) printf("Y");
			if (ans[i][j]==3) printf("G");
			if (ans[i][j]==4) printf("B");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  int ans = 0;
  int l, r;
  int mini;
  

  for (int i = 0; i < n; ){
    if(h[i] == 0){
      i++;
      continue;
    }
    mini = h[i];
    l = i;
    
    for (int j = i; j < n; j++){
      if (h[j] == 0){
        break;
      }
      r = j;
      mini = min(h[j], mini);
    }
    //cout << i << " " << r << " ";
    for (int j = i; j <= r; j++){
      h[j] -= mini;
    }
    ans += mini;
    //cout << mini << "\n";
  }
  cout << ans << "\n";

  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

void solve(){
    int r,c,n;
    cin >> r >> c >> n;
    vector<vector<pair<int,int>>> graph(r+c);
    rep(i,0,n){
        int x,y,a;
        cin >> y >> x >> a;
        --y;
        --x;
        graph[y].push_back(make_pair(x+r,a));
        graph[x+r].push_back(make_pair(y,a));
    }

    vector<int64_t> val(r+c);
    vector<bool> done(r+c);
    int64_t min_y,min_x;
    function<bool(int)> dfs=[&](int u){
        if(u<r) min_y=min(min_y,val[u]);
        else min_x=min(min_x,val[u]);
        for(auto &e:graph[u]){
            if(done[e.first]){
                if(val[u]+val[e.first]!=e.second) return false;
                continue;
            }
            done[e.first]=true;
            val[e.first]=e.second-val[u];
            if(not dfs(e.first)) return false;
        }
        return true;
    };
    rep(i,0,r+c){
        if(done[i]) continue;
        done[i]=true;
        min_y=min_x=inf;
        if(not dfs(i) or min_y+min_x<0){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 15872
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		fact();
		int n=nextInt();
		int pos[]=new int[n+1];
		int diff=0;
		for(int i=1;i<=n+1;i++)
		{
			int a=nextInt();
			if(pos[a]!=0)
				diff=i-pos[a]+1;
			else
				pos[a]=i;
		}
		for(int i=1;i<=n+1;i++)
		{
			long ans=choose(n+1,i);
			ans=(ans-choose(n+1-diff,i-1)+mod)%mod;
			out.println(ans);
		}
	}
	long choose(int n,int r)
	{
		if(n<r)
			return 0;
		return (((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod;
	}
	final int maxn=(int)(1e5+1);
	long fact[];
	void fact(){
		fact=new long[maxn+1];
		fact[0]=1;
		for(int i=1;i<=maxn;i++)
			fact[i]=(fact[i-1]*i)%mod;
	}
	final long mod=(long)(1e9+7);
	long modinv(long x){
	    return modpow(x,mod-2);
	}
	long modpow(long a,long b){
	    long ret=1;
	    while(b!=0)
	    {
	        if(b%2==1)
	            ret=(ret*a)%mod;
	        a=(a*a)%mod;
	        b=b/2;
	    }
	    return ret;
	} 

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 42892
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a = 1;
    int b = 1;
    int c = n - (a * b);
    int result = 0;
    while (a <= n)
    {
        while (b <= n)
        {
            c = n - (a * b);
            if (c <= 0)
            {
                break;
            }
            //cout << a << b << c;
            result++;
            b++;
        }
        b = 1;
        a++;
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n, a, b;
    cin >> n >> a >> b;

    if(a % 2 == b % 2) {
        cout << (b - a) / 2 << endl;
        return 0;
    }

    cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

double power2(int x)
{
	double power=1.0;
	for (int i = 0; i < x; i++) {
		power *= 2;
	}
	return power;
}

int main(void)
{
	int N, K;
	int j = 0.0;
	double sa;
	double anser = 0.0;
	double an[100001];
	scanf("%d %d", &N, &K);
	for (int i = 1; i <= K; i++) {
		an[i] = 1.0;
	}
	sa = N -K +1.0;
	if (sa >= 0) {
		an[K] = sa / N;
	}
	if (sa >= 0) {
		for (int i = K-1; i > 0; i--) {
			while (true) {
				if (i * power2(j) >= K) {
					an[i] /= power2(j);
					an[i] /= N;
					break;
				}
				j++;
			}
		}
	}
	if (sa < 0) {
		for (int i = N; i > 0; i--) {
			while (true) {
				if (i * power2(j) >= K) {
					an[i] /= power2(j);
					an[i] /= N;
					break;
				}
				j++;
			}
		}
	}
	if (sa >= 0) {
		for (int i = 1; i <= K; i++) {
			anser += an[i];
		}
	}
	if (sa < 0) {
		for (int i = 1; i <= N; i++) {
			anser += an[i];
		}
	}
	printf("%.12f", anser);
	return 0;
}

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

int main(){
  int a,b;
  string str;
  cin>>a>>b;
  for(int i=0;i<b+2;i++){
    cout<<'#';
  }
  cout<<endl;
  for(int i=0;i<a;i++){
    cin>>str;
    cout<<'#'<<str<<'#'<<endl;
  }
  for(int i=0;i<b+2;i++){
    cout<<'#';
  }
}

Measured memory_bytes: 256
#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++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  vs s(3);
  rep(i,3) cin >> s[i];
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
}

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

using namespace std;

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  const int dx = tx - sx;
  const int dy = ty - sy;

  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow (ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    vec C(N);
    Rep (i, N) cin >> C[i];

    COMinit();

    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());

    ll cnt = modpow(2, N-1);
    ll ans = 0;
    Rep (i, N) {
        ll tmp = cnt + modpow(2, N-2) * i;
        tmp %= MOD;
        ans += C[i] * tmp % MOD;
        ans %= MOD;
    }

    ans *= modpow(2, N);
    ans %= MOD;

    cout << ans << endl;
}

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

using namespace std;

long long gcd(long long a, long long b){
    if(b == 0){ return a;}
    return gcd(b, a%b);
}
long long lcm(long long a, long long b) { 
    long long g = gcd(a,b);
    return (a/g)*b; 
}


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

  long long ans = a[0];
  
  for(int i = 0; i < n; i++){

      ans = lcm(ans, a[i]);

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

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        String s = reader.readLine();
        if(isOk(s.charAt(0))) {
            writer.println("vowel");
        } else writer.println("consonant");
    }

    private boolean isOk(char c) {
        return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("trees.in"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("trees.out");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 8404
#include <bits/stdc++.h>
using namespace std;
int n,al,bo,cnt;
int main(){
	//cout<<al<<" "<<bo<<endl;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>=0;i--){
		cnt++;
		if(cnt%2==1){
			al+=a[i];
		}
		else{
			bo+=a[i];
		}
	}
	//cout<<al<<" "<<bo<<endl;
	cout<<al-bo<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, a, b, c, d;
string s;
int main() {
	cin>>n>>a>>b>>c>>d>>s;
	s = '-' + s;
	for(int i=a; i<c-1; i++) {
		if(s[i]=='#' && s[i+1]=='#') {puts("No"); return 0;}
	}
	for(int i=b; i<d-1; i++) {
		if(s[i]=='#' && s[i+1]=='#') {puts("No"); return 0;}
	}
	if(c<d) {
		puts("Yes"); return 0;
	} else {
		for(int i=b; i<=d; i++) {
			if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {
				{puts("Yes"); return 0;}
			}
		}
		puts("No"); return 0;
	}
}

Measured memory_bytes: 772