akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2> inline bool relax(T1& a, const T2& b) {
    return a > b ? a = b, true : false;
}

template <typename T1, typename T2> inline bool strain(T1& a, const T2& b) {
    return a < b ? a = b, true : false;
}

// :::::::::::::::::::::::::::::::

const int MOD = 1e9 + 7; // 998244353;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int binpow(int a, ll n) {
    if (n < 0)
        a = binpow(a, MOD - 2), n *= -1;
    
    int res = 1;
    while (n) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n /= 2;
    }
    return res;
}

int inv(int x) {
    return binpow(x, MOD - 2);
}

const int N = 3000;

int fact[N];

int C(int n, int k) {
    if (k > n) return 0;
    return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}

void solve() {
    fact[0] = 1;
    for (int i = 1; i < N; ++i)
        fact[i] = mul(i, fact[i - 1]);
    
    int s;
    cin >> s;
    
    int ans = 0;
    for (int n = 1; n * 3 <= s; ++n) {
        int cur = s - 3 * n;
        ans = add(ans, C(n + cur - 1, cur));
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 3672
#%%
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

x1 = 0
x2 = 0
x3 = 0

for i in range(n):
    if p[i] <= a:
        x1 += 1
    elif a < p[i] <= b:
        x2 += 1
    else:
        x3 += 1

print(min(x1, x2, x3))

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, k;
vector<vector<int> > g;
vector<vector<pair<int,int> > > at;
int DFS(int u, int p, int d, int id) {
	if (at[d].empty() || at[d].back().second != id)
		at[d].push_back(make_pair(0, id));
	++at[d].back().first;
	int ret = d;
	for(int i=0;i<g[u].size();++i)
		if (g[u][i] != p)
			ret = max(ret, DFS(g[u][i], u, d + 1, id));
	return ret;
}
int calc(int k, int a) {
	at.clear();
	at.resize(n);
	int id = 0;
	for (int i = 0; i < g[a].size(); ++i)
		DFS(g[a][i], a, 1, id++);
	int limit = (k + 1) / 2;
	int res = n;
	for (int i = 1; i<n; ++i)
		if (at[i].size() == 1) {
			limit = min(limit, i - 1 + (k & 1));
			break;
		}
	for (int i = limit + 1; i < n; ++i) {
		for (int j = 0; j < at[i].size(); ++j)
			res -= at[i][j].first;
		at[i].clear();
	}
	if (k & 1) {
		sort(at[limit].begin(), at[limit].end());
		for (int i = 0; i + 1 < at[limit].size(); ++i)
			res -= at[limit][i].first;
	}
	return res;
}
int main()
{
	scanf("%d%d", &n, &k);
	g.resize(n + 1);
	for (int i = 1, a, b; i < n; ++i) {
		scanf("%d%d", &a, &b);
		--a; --b;
		g[a].push_back(b);
		swap(a, b);
		g[a].push_back(b);
	}
	for (int i = 0; i < n; ++i)
		sort(g[i].begin(), g[i].end());
	int res = n;
	for (int i = 0; i < n; ++i) {
		res = min(res, n - calc(k, i));
		for (int j = 0; j < g[i].size(); ++j) {
			int u = i;
			int v = g[i][j];
			g[u].erase(lower_bound(g[u].begin(), g[u].end(), v));
			swap(u, v);
			g[u].erase(lower_bound(g[u].begin(), g[u].end(), v));
			swap(u, v);
			g[n].clear();
			g[n].push_back(u);
			g[n].push_back(v);
			++n;
			res = min(res, n - calc(k + 1, n - 1));
			--n;
			g[u].insert(lower_bound(g[u].begin(), g[u].end(), v), v);
			swap(u, v);
			g[u].insert(lower_bound(g[u].begin(), g[u].end(), v), v);
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    string ss;
    
    for(int i = 0;i<n;i++) {
        if(s[i] != s[i+1]) ss += s[i];

    }
    
    cout << ss.size() << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int c[3][3];
    for(int i=0;i<3;i++) scanf("%d%d%d",&c[i][0],&c[i][1],&c[i][2]);
    if(c[0][0]-c[1][0]==c[0][1]-c[1][1]&&c[0][0]-c[1][0]==c[0][2]-c[1][2]&&c[0][0]-c[2][0]==c[0][1]-c[2][1]&&c[0][0]-c[2][0]==c[0][2]-c[2][2]) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z);
}


Measured memory_bytes: 256
# 盤面座標は8000x8000(x 2)
N = 8000
s = input()
target_x, target_y = map(int, input().split())

# "FTTFF" -> [1, 0, 2]と変換。'F1TF0TF2T'のFだけとる
dat_f = [len(Fcount) for Fcount in s.split("T")]

# マイナスを含むxとyのDP用配列(=x2)を作る +1するのは原点用
# x, yの閾値判定するのが面倒なので倍(=x2)用意する(index error対策)
curmap_x = [False] * ((N * 2 * 2) + 1)
curmap_y = [False] * ((N * 2 * 2) + 1)
nextmap_x = [False] * ((N * 2 * 2) + 1)
nextmap_y = [False] * ((N * 2 * 2) + 1)

# 初期座標 0,0なのだが、最初Fから始まる場合は(x,0)から始まるし、y軸を向きながら処理する
if s[0] == "F":
    start = 1
    curmap_x[N * 2 + dat_f[0]] = True
    direction_x = False
else:
    start = 0
    curmap_x[N * 2] = True
    direction_x = True

# y=0
curmap_y[N * 2] = True

# 処理すべき最初のFから
for i in range(start, len(dat_f)):
    step = dat_f[i]
    if direction_x:
        for j in range(N, N + (N * 2) + 1):
            nextmap_x[j] = True if curmap_x[j - step] or curmap_x[j + step] else False
        curmap_x, nextmap_x = nextmap_x, curmap_x
    else:
        for j in range(N, N + (N * 2) + 1):
            nextmap_y[j] = True if curmap_y[j - step] or curmap_y[j + step] else False
        curmap_y, nextmap_y = nextmap_y, curmap_y

    # くる
    direction_x = not direction_x

print("Yes" if curmap_x[N * 2 + target_x] and curmap_y[N * 2 + target_y] else "No")


Measured memory_bytes: 45276
#include<stdio.h>
#define NIL -1
#define MAX 100000

struct Node{
  int p,l,r;
};

struct Node T[MAX];

int n;

int depth(int a);
int print(int a);

int main(){

  int i,j,x,d,c,l;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d", &c);
      if(j==0) T[x].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=x;
    }
  }

  for ( i=0; i<n; i++ ) print(i);
  return 0;
}

int print(int a){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", a, T[a].p,depth(a));
  if(T[a].p==NIL) printf("root, ");
  else if(T[a].l!=NIL) printf("internal node, ");
  else printf("leaf, ");

  printf("["); 

  for(i=0, c=T[a].l; c!=NIL; i++, c=T[c].r){
    if(i==0) printf("%d", c);
    else printf(", %d", c);
  }
  printf("]\n");

  return 0;
}

int depth(int a){
  int num=0,s=T[a].p;
  while(s!=NIL){
    num++;
    s=T[s].p;
  }
  return num;
}

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n*m%2==0)
    {
        cout<<"Even";
    }
    if(n*m%2!=0)
    {
        cout<<"Odd";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int A = scanner.nextInt();
 		int B = scanner.nextInt();
 		if (2*B >= A ) {
 			System.out.println("0");
 		} else {
 			System.out.println(A - 2*B);
 		}
	}
}


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

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<E> v;

bool comp(E a, E b){
	return (a.hg < b.hg);
}

int main(void){
	int n,i;
	ll cx,cy,x,y,h;
	bool flag = true;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x >> y >> h;
		v.push_back(E(h,P(x,y)));
	}
	for(cx=0ll; cx<=100ll; ++cx){
		for(cy=0ll; cy<=100ll; ++cy){
			h=INFLL;
			for(i=0; i<n; ++i){
				h = min(v[i].hg+abs(v[i].p-cx)+abs(v[i].q-cy),h);
			}
			flag = true;
			for(i=0; i<n; ++i){
				if(max(h-abs(v[i].p-cx)-abs(v[i].q-cy),0ll)!=v[i].hg){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << cx << " " << cy << " " << h << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    if((x>0&&y>0)||(x<0&&y<0)){
        if(x<y) cout<<y-x<<endl;
        else cout<<2+(x-y)<<endl;
    }
    else if(x==0){
        if(y>0) cout<<y<<endl;
        else cout<<abs(y)+1<<endl;
    }
    else if(y==0){
        if(x<0) cout<<abs(x)<<endl;
        else cout<<abs(x)+1<<endl;
    }
    else{
        cout<<1+abs(abs(y)-abs(x))<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B==C&&A>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
using namespace std;

int main(){
    int n,i;
    while(cin>>n&&n){
        int ans,p,h,w;
        double min=100,bmi,tmp;
        for(i=0;i<n;i++){
            cin>>p>>h>>w;
            bmi=w/(h*h/10000.0);
            tmp=abs(22.0-bmi);
            if(tmp<min){
                min=tmp;
                ans=p;
            }else if(tmp==min){
                if(p<ans) ans=p;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
using namespace std;

bool is_range(int in1, int in2, int cen, int fin){
	if (0 < in1 && in1 < cen && cen < in2 && in2 < fin) return true;
	return false;
}

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> sum(n+1);
	for (int i = 0; i < n; i++) cin >> a[i];

	sum[0] = 0;
	for (int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + a[i-1];
	}
	ll ans = LLINF;
	for (int i = 2; i <= n-2; i++){
		int sep = i;
		ll fir = sum[i];
		ll sec = sum[n] - sum[i];
		auto it1 = lower_bound(sum.begin(), sum.begin()+sep, fir/2);
		auto it2 = lower_bound(sum.begin()+sep+1, sum.end(), sec/2+sum[i]);

		for (int j = -1; j <= 1; j++){
			for (int k = -1; k <= 1; k++){
				int index1 = it1 - sum.begin();
				int index2 = it2 - sum.begin();
				if (is_range(index1 + j, index2 + k, sep, n)){
					ll temp = max(max(sum[index1+j], sum[sep]-sum[index1+j]), max(sum[index2+k]-sum[sep], sum[n]-sum[index2+k])) - min(min(sum[index1+j], sum[sep]-sum[index1+j]), min(sum[index2+k]-sum[sep], sum[n]-sum[index2+k]));
					ans = min(ans, temp);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6416
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

int main(){

	int L,A,B,C,D;
	cin >> L >> A >> B >> C >> D;
	cout << L-max((A-1)/C+1,(B-1)/D+1) << endl;

	return 0;
}

Measured memory_bytes: 1164
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

struct UnionFind {
  std::vector<ll> data;

  UnionFind(ll n) { data.assign(n, -1); }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }

  int find(int k) {
    if (data[k] < 0) return k;
    return data[k] = find(data[k]);
  }

  ll size(int k) { return -data[find(k)]; }

  bool same(int x, int y) { return find(x) == find(y); }
};

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n >> m;
  UnionFind uf(n + 10);
  rep(i, m) {
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  rep(i, n) {
    if (mp[uf.find(i)] == 0) {
      mp[uf.find(i)] = 1;
      ans++;
    }
  }
  Cout(ans - 1);
  return 0;
}

Measured memory_bytes: 7336
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e3+5;
const ll M=1e9+7;
const ll inf=1e18+5;

int main()
{
	ll n;
	lscn(n);
	int ans = 0;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			int ct = 0;
			while(n%i==0)
			{
				n/=i;
				ct++;
			}
			int val = 0;
			for(int j = 1;j<=ct;j++)
			{
				if( j*(j+1)/2 <= ct )
				{
					val = j;
				}
				else
					break;
			}
			ans+=val;

		}
	}
	if(n>1)
		ans++;
	pri(ans);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pll pair<ll, ll>
#define vl vector<ll> 
#define vvl vector<vector<ll>>
#define vpll vector<pair<ll,ll>>
#define umap unordered_map
#define uset unordered_set
#define all(c) c.begin(), c.end()
#define maxarr(A) *max_element(A, A+n) 
#define maxvec(v) *max_element(all(v)) 
#define present(map,elem) map.find(elem)!=map.end()
#define lb(v,elem) (lower_bound(all(v),elem) - v.begin())
#define ub(v,elem) (upper_bound(all(v),elem) - v.begin())
#define pb push_back 
#define mp make_pair
#define For(i,a,b) for(int i=a; i<b; ++i) 
#define mod 1000000007 

const int MAX = 100005;
int main() { 
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  
  string s;
  cin>>s;
  int f=0;
  For(i,0,s.length()) {
     if(s[i]=='R' && i%2==1) {
        f=1;
        break;
     }
     else if(s[i]=='L' && i%2==0) {
      f=1;
      break;
     }
  }   
  if(f==0)
    cout<<"Yes";
  else 
    cout<<"No";
  return 0;
}


Measured memory_bytes: 256
x= [ int(x) for x in input().split()]

a,b,c=x[0],x[1],x[2]

sumaA_B = a+b
sumaA_C = a+c
sumaB_C = b+c

r1 = min(sumaA_B,sumaA_C)
rt = min(r1,sumaB_C)

print(rt)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

const int K = 50;

char r[K*2][K*2];

void solve() {
    int a, b; scanf("%d%d", &a, &b);
    for (int i = 0; i < K; ++i) {
        for (int j = 0; j < 2*K; ++j) {
            r[i][j] = '.';
            r[i+K][j] = '#';
        }
    }
    --a; --b;
    for (int i = 0; i < K-1 && b; i+=2) {
        for (int j = 0; j < 2*K; j+=2) {
            r[i][j] = '#';
            if (!--b) goto Astuff;
        }
    }
    Astuff:
    for (int i = 0; i < K-1 && a; i+=2) {
        for (int j = 0; j < 2*K; j+=2) {
            r[i+K+1][j] = '.';
            if (!--a) goto end;
        }
    }
    end:
    puts("100 100");
    for (int i = 0; i < 2*K; ++i) {
        for (int j = 0; j < 2*K; ++j) {
            putchar(r[i][j]);
        }
        puts("");
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

int main()
{
	string str;
	cin >> str;
	for (int i = 1; i < str.size(); i++) {
		if (str[i - 1] != str[i]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools as itt
#n進m桁のbit列の作成
def bit(n,m):
    bi = list((itt.product([i for i in range(n)],repeat = m)))
    return bi
#入力データの受け取り
N,M = list(map(int,input().split()))
L = [list(map(int,input().split())) for  _ in range(M)]
P = [int(s) for s in input().split()]

ans = 0
petterns = bit(2,N)
for pettern in petterns:#bit列から一つ取り出す
    count = 0
    flag = 1
    for i in range(M): #電球を一つ取り出す
        #点灯しているスイッチをカウント
        count = 0
        for j in range(L[i][0]):#j番目のスイッチを一つ取り出す
            if pettern[L[i][j+1] - 1] == 1:
                count += 1
        if count % 2 != P[i]:
            count = 0
            flag = 0
    if flag == 1:
        ans += 1
print(ans)

Measured memory_bytes: 3188
S = input()

alp = list(map(lambda x: chr(x), range(ord('a'), ord('z')+1)))
def solve():
    for c in alp:
        cand = S.find(c*2)
        if cand != -1:
            return (cand, cand+1)
        for i in alp:
            cand = S.find(c+i+c)
            if cand != -1:
                return (cand, cand+2)

res = solve()
if res is None:
    print('-1 -1')
else:
    print(res[0]+1, res[1]+1)

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

bitset<10> nums;

bool valid(int x) {
    while(x) {
        if (nums.test(x % 10)) return false;
        x /= 10;
    }
    return true;
}

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

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        int d; cin >> d;
        nums.set(d);
    }

    while(!valid(n)) ++n;

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define S second
#define F first
using namespace std;



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

	
	set<ll> st;
	st.clear();

	ll n;
	cin >> n;
	ll ans = 1;
	ll curr = 7;
	while (true) {
		if (curr < n) {
			if (st.find(curr) != st.end()) {
				cout << "-1\n";
				return 0;
			}
			else {
				st.insert(curr);
			}
			ans++;
			curr = curr * 10;
			curr = curr + 7;
		}
		else {
			if (curr % n == 0) {
				cout << ans << '\n';
				return 0;
			}
			else {
				curr = curr % n;
			}
		}
	}

}

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

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int d;
	cin >> d;
	switch(d){
		case 25:
			cout << "Christmas" << endl;
			break;
		case 24:
			cout << "Christmas Eve" << endl;
			break;
		case 23:
			cout << "Christmas Eve Eve" << endl;
			break;
		case 22:
			cout << "Christmas Eve Eve Eve" << endl;
			break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
  int l;
  cin>>l;
   cout<<std::setprecision(10)<<pow(double(l)/3,3);



return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
using namespace std;
string mes[2] = {"Closed by ","Opened by "};
int main(){
  int n,m;
  cin >> n;
  vector<string> u(n);
  set<string> U;
  for(int i = 0;i < n;i++){
    cin >> u[i];
    U.insert(u[i]);
  }
  cin >> m;
  vector<string> t(m);
  int current = 0;//しまっている
  for(int i = 0;i < m;i++){
    cin >> t[i];
    if(U.find(t[i]) == U.end()){
      cout << "Unknown " << t[i] << endl;
    }else{
      current = (current + 1)%2;
      cout << mes[current] << t[i] << endl;
    }
  }
 
}

Measured memory_bytes: 1252
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,w=map(int,input().split())
    W=[0]*n; V=[0]*n
    for i in range(n):
        a,b=map(int,input().split())
        W[i]=a; V[i]=b
    # dp[i][k] iまでの品物で、重さがk以下
    dp=[[0]*(w+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for k in range(w+1):
            if k-W[i-1]>=0:
                dp[i][k]=max(dp[i-1][k-W[i-1]]+V[i-1],dp[i-1][k])
            else:
                dp[i][k]=dp[i-1][k]
    print(dp[n][w])
resolve()

Measured memory_bytes: 118128
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int v, e;
    cin >> v >> e;
    using ii = pair<int, i64>;
    vector<vector<ii>> adj(v);
    for (int i = 0; i < e; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        adj[s].push_back(ii(t, d));
    }

    vvi dp(1 << v, vi(v, 1e18));
    // dp[i][j]: すでにiを回って今jにいる
    dp[0][0] = 0;
    for (int i = 0; i < 1 << v; i++) {
        for (int j = 0; j < v; j++) {
            for (auto &p: adj[j]) {
                if ((i >> p.first) & 1) continue;
                dp[i | (1 << p.first)][p.first] = min(dp[i | (1 << p.first)][p.first], dp[i][j] + p.second);
            }   
        }
    }
    cout << (dp[(1 << v) - 1][0] == 1e18 ? -1 : dp[(1 << v) - 1][0]) << endl;
}


Measured memory_bytes: 7560
#include <bits/stdc++.h>
#include <iostream>
#include <tuple>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < n; i++)

int main()
{
    string s;
    cin >> s;
    int p1 = stoi(s.substr(0,2));
    int p2 = stoi(s.substr(2,2));
    if(p1==0 && p2==0){
        cout << "NA" << endl;
    }else if(p1>12 && p2>12){
        cout << "NA" << endl;
    }
    else if(p1>12 && p2==0 || p1==0 && p2>12){
        cout << "NA" << endl;
    }
    else if(p1==0 && p2<=12){
        cout << "YYMM" << endl;
    }else if(p1<=12 && p2==0){
        cout << "MMYY" << endl;
    }else if(p1<=12 && p2<=12){
        cout << "AMBIGUOUS" << endl;
    }else if(p1<=12){
        cout << "MMYY"<<endl;
    }else{
        cout << "YYMM"<<endl;
    }
}

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

int main()
{
	int n, res;
	while (cin >> n) {
		res = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						if (a + b + c + d == n) {
							res++;
						}
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	string s;
	cin>>s;
	if(s=="Sunny")
		cout<<"Cloudy\n";
	else if(s=="Cloudy")
		cout<<"Rainy\n";
	else
		cout<<"Sunny\n";
}



Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int64 MOD = 1000000007;

int n; int64 k;
vector<int> graph[101010];

int64 ans;

void dfs(int v, int p) {
  int64 can = k - 1;
  if (p != -1) --can;
  for (auto next : graph[v]) {
    if (next == p) continue;
    (ans *= can) %= MOD;
    --can;
    dfs(next, v);
  }
}

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

  cin >> n >> k;
  rep(i, n - 1) {
    int x, y; cin >> x >> y;
    --x; --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  ans = k;
  dfs(0, -1);

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 10496
#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>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>
#include <atcoder/all>

#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;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

using mint = atcoder::modint998244353;

vector<mint> repunit;
vector<mint> pows;

struct S{
    mint value;
    int size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b){ return {a.value + pows[a.size] * b.value, a.size+b.size}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
    if(f != ID) {
        x.value = repunit[x.size] * f;
    }
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

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

    repunit = vector<mint>(300000, 0);
    pows = vector<mint>(300000, 0);
    for (ll i = 1; i < 300000; i *= 2) {
        repunit[i] = (mint(10).pow(i)-1) / 9;
        pows[i] = mint(10).pow(i);
    }

    ll N, Q;
    cin >> N >> Q;
    vector<S> v(N, {mint(1), 1});
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    while (Q--) {
        ll L, R, D;
        cin >> L >> R >> D;
        ll l = N - R;
        ll r = N - L + 1;
        seg.apply(l, r, D);
        cout << seg.all_prod().value.val() << "\n";
    }
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -fsanitize=signed-integer-overflow -fno-sanitize-recover=all -o template template.cpp


signed main()
{
	int n;cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for(int i = 0, i_len = n; i < i_len; ++i){
		cin >> v.at(i);
	}
	for(int i = 0, i_len = n; i < i_len; ++i){
		cin >> c.at(i);
	}

	int x{},y{};
	for(auto i = 0; i < n; ++i){
		if(v.at(i)-c.at(i)>0){
			x += v.at(i);
			y += c.at(i);
		}
	}

	cout << x-y << endl;
	return 0;
}
	//int x = v+v+...;
	//int y = c+c+...;
	//v[i]-c[i]>0

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

using namespace std;

typedef long long ll;

int main(){
  ll N,K;
  ll A[222222];
  cin >> N >> K;
  ll i;
  ll P[2222222];
  P[0] = 1;
  for(i=1;i<=N;i++)
    cin >> A[i];
  ll shuuki = 0;
  ll start = 0;
  ll time = 0;
  ll tuuka[222222] = {0}; //tuuka[P[i]] : P[i]を初めて通ったのはtuuka[P[i]]回目

  if(K > 222222){
   for(i=1;i<=K;i++){
    P[i] = A[P[i-1]];
    if(tuuka[P[i]]){
      shuuki = i - tuuka[P[i]];
      start = P[i];
      time = tuuka[P[i]];
      break;
    }
    else tuuka[P[i]] = i;
    }
  P[time] = start;
  ll left = (K - time) % shuuki;
  for(i=time+1;i<=time + left;i++)
    P[i] = A[P[i-1]];
  cout << P[time + left] << endl;
  }
  else{
  for(i=1;i<=K;i++)
    P[i] = A[P[i-1]];
  cout << P[K] << endl;
  }
}

Measured memory_bytes: 8064
#include<stdio.h>
int c[1000000],m1[1000000],s1[1000000],m2[1000000],s2[1000000],m3[1000000],s3[1000000],m4[1000000],s4[1000000],time[1000000];
int main(void)
{
	int i,n;
	int max,max2,min,min2,num1,num2,num3;
	scanf("%d",&n);
	while(n!=0) {
	min=1000000;
	min2=1000000;
	max=0;
	max2=0;
		for(i=1;i<=n;i++) {
			scanf("%d %d %d %d %d %d %d %d %d",&c[i],&m1[i],&s1[i],&m2[i],&s2[i],&m3[i],&s3[i],&m4[i],&s4[i]);
			time[i]=60*m1[i]+s1[i]+60*m2[i]+s2[i]+60*m3[i]+s3[i]+60*m4[i]+s4[i];
		}
		for(i=1;i<=n;i++) {
			if(time[i]<min) {
				min=time[i];
				num1=c[i];
			}
		}
		for(i=1;i<=n;i++) {
			if(min<time[i] && time[i]<min2) {
				min2=time[i];
				num2=c[i];
			}
		}
		for(i=1;i<=n;i++) {
			if(max<time[i]) {
				max=time[i];
			}
		}
		for(i=1;i<=n;i++) {
			if(time[i]<max && max2<time[i]) {
				max2=time[i];
				num3=c[i];
			}
		}
		printf("%d\n%d\n%d\n",num1,num2,num3);
	scanf("%d",&n);
	}
	return 0;
}

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


vector<ll>g[200010];

ll a[200010], pp[200010];
map<ll,ll>m;
int main()
{
    ll n,k,b;
    cin>>n>>k;
    m.clear();

    for(int i=1; i<=n; i++)
    {
        scanf("%lld", &a[i]);
    }

    ll p=k;
    ll in=1, cnt=0, s=0,e=0;
    for(int i=1; i<=k; i++)
    {
        in=a[in];
        if(m[in])
        {
            //cout<<in<<endl;
            s=m[in];
            e=cnt-1; break;
        }
        m[in]=cnt;
        pp[cnt]=in;
        cnt++;
    }

    /*for(int i=0; i<cnt; i++)
        cout<<pp[i]<<" ";*/
    //cout<<endl<<s<<" "<<e<<endl;

    if(k<=e || e==0)
    {
        cout<<pp[k-1];
    }
    else
    {
        k-=s;
        k%=(e-s+1);
        if(k==0) k=(e-s+1);
        cout<<pp[k+(s-1)];
    }
}
/*
5 4
3 4 2 5 1
*/


Measured memory_bytes: 21164
#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(i,b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(i,b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007  
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}

int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
  //  start_routine();
    
   ll t,sum=0,ans=0,n;
   cin>>n;
   vector<ll> a(n,0),b(n-1,0),c(n-1,0);
   n-=1; 
   loop(i,0,n) 
  { 
      cin>>b[i];
  
  } 
  ans+=b[0];
  ans+=b[n-1]; 
   loop(i,0,n-1)
   { 
        ans+=(min(b[i],b[i+1])); 
   } 
   cout<<ans<<"\n";
   
  // while(t--) {   cin>>n ;  }   
   
    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  double l=0;
  for(int i=0;i<n;i++){
    cin >> w.at(i);
    l+=w.at(i);
  }
  
  l/=2;
  
  double k=0;
  vector<double> a(n);
  
  for(int i=0;i<n;i++){
    k+=w.at(i);
    a.at(i)=max(l-k,k-l);
  }
  
  double ans=100;
  
  for(int i=0;i<n;i++)
    ans=min(ans,a.at(i));
  
  cout << ans*2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  const i64 sum = N + (N % 2 == 0 ? 1 : 0);
  std::vector<std::pair<i64, i64>> edges;
  for (i64 i = 1; i <= N; ++i) {
    for (i64 j = i + 1; j <= N; ++j) {
      if (j != sum - i) {
        edges.push_back(std::make_pair(i, j));
      }
    }
  }

  std::cout << edges.size() << std::endl;
  for (const auto& edge : edges) {
    std::cout << edge.first << ' ' << edge.second << std::endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for(int i=(begin),i##_end = (end);i<i##_end;i++)

int main()
{
    int n,d,cnt=0;
    cin>>n>>d;
    vector<vector<int> > co(n,vector<int>(d));
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin>>co[i][j];
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            double sum = 0;
            for(int k=0;k<d;k++){
                sum+=(co[i][k] - co[j][k])*(co[i][k] - co[j][k]);

            }
            if(sqrt(sum)==floor(sqrt(sum)))
                cnt++;
        }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
int main(){
    string a,b;
    cin >> a;
    getchar();
    cin >> b;
    string s = a+b;
    int i;
    int n = s.length()-1;
    int ans = 0;
    for(i = 0; i <= n; i++){
        if(i != n)
            ans = (ans+(s[i]-'0'))*10;
        else
            ans = (ans+(s[i]-'0'));
    }
    int x = (int)sqrt((double)ans);
    if(x * x == ans){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
 string s,t;
  cin>>s>>t;
  cout<<t+s<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int k;
    cin>>k;
    int d=k%10;
    if(d==2 || d==0 || d==4 || d==5 || d==6 || d==8){
        cout<<-1<<endl;
        return 0;
    }

    ll cur=0,cnt=0;
    while(cur<k)
    {
        cnt++;
        cur=cur*10+7;
    }

    while(true)
    {
        if(cur%k==0) break;
        cur=cur%k;
        cur=cur*10+7;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



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

using namespace std;

int main(){
    int n,m;
    while(cin>>n>>m &&n){
        vector<bool> v(n,true);
        int index=0,count=0;
        while(1){
            if(v[index]){
                count++;
                if(count==m){
                    count=0;
                    v[index]=false;   
                    
                    int ct=0;
                    rep(i,0,n)if(v[i])ct++;
                    if(ct==1) rep(i,0,n)if(v[i]){
                        cout<<i+1<<endl;
                        goto AWAY;
                    }
                }
            }
            index++;
            if(index==n)index=0;
        }
        AWAY:;
    }
    
    return 0;
}



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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s;
  int k;
  cin >> s >> k;
  bool a=1;
  int t=s.size();
  for(int i=0;i<min(k,t);i++){
    if(s[i]!='1'){
      cout << s[i] << endl;
      a=0;
      break;
    }
  }
  if(a)
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    for( int i=0; i<N; i++){
        cin >> A[i];
    }
    int mx, mn;
    mx = A[0];
    mn = A[0];
    for( int i=0; i<N; i++){
        if( A[i] < mn){
            mn = A[i];
        }
        if( A[i] > mx){
            mx = A[i];
        }
    }
    cout << abs(mx -mn) << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)




using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	cin1(n);

	cout(800 * n - (n / 15) * 200);

	return 0;
}





Measured memory_bytes: 256