akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
string s[100005];
int occ[26];
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	map<string,int>Map;
	rep(i,n){
		cin>>s[i];
		rep(j,26)occ[j]=0;
		rep(j,SZ(s[i]))occ[s[i][j]-'a']++;
		string mask="";
		rep(j,26)mask+=occ[j]+'0';
		Map[mask]++;
	}
	ll ans=0;
	for(map<string,int>::iterator it=Map.begin();it!=Map.end();it++){
		ans+=(ll)it->second*((ll)it->second-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19840
from collections import deque

n, q = map(int, input().split())
S = [deque() for _ in range(n)]
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        S[query[1]].append(query[2])
    elif len(S[query[1]]) > 0:
        if query[0] == 1:
            print(S[query[1]][-1])
        elif query[0] == 2:
            S[query[1]].pop()


Measured memory_bytes: 14536
a,b=map(int,input().split())
a_odd = (a%2==1)
b_odd = (b%2==1)

if a_odd and b_odd:
    ans = ((b-a)//2%2)^a
elif a_odd and not b_odd:
    ans = ((b-a-1)//2%2)^a^b
elif not a_odd and b_odd:
    ans = (b-a+1)//2%2
else:
    ans = ((b-a)//2%2)^b
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3084
#include <stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x+r>W||x-r<0||y+r>H||y-r<0){
	printf("No\n");
}else{
	printf("Yes\n");
}
return 0;


	
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,w,a,b;
  cin >> h >> w >> a >> b;

  vector<string> s(h, "");
  REP(k, h){
    string fr = "0";
    string ba = "1";
    if(k < b)
      swap(fr, ba);

    REP(i, w){
      if(i < a)
        s[k] += fr;
      else
        s[k] += ba;
    }
  }


  REP(i, h)
    cout << s[i] << endl;

}


Measured memory_bytes: 2304
from collections import defaultdict
while True:
    n = int(input())
    if n == 0:
        break

    SALES = defaultdict(int)
    for _ in range(n):
        id, p, num = [int(x) for x in input().split()]
        SALES[id] += p * num
        
    L = [k for k, v  in SALES.items() if v >= 1000000]

    if len(L) > 0:
        for i in L:
            print(i)
    else:
        print("NA")



Measured memory_bytes: 6220
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	string str; cin >> str;
	LL blacks = count(str.begin(), str.end(), '#'), whites = count(str.begin(), str.end(), '.');
	LL curr_black = 0, curr_white = 0;
	LL ans = blacks;
	rep(i, 0, n) {
		if(str[i] == '#')
			ans = min(ans, (whites - curr_white) + curr_black);
		if(str[i] == '.')	curr_white++;
		else	curr_black++;
	}
	pll(ans); nl;
}


Measured memory_bytes: 640
from collections import deque

m,n = map(int,list(input().split()))

dirr = ((1,0),(0,1),(-1,0),(0,-1))


def valid(tmp,maze,seen):
    x = tmp[0]
    y = tmp[1]
    if x<0 or y<0 or x>=len(maze) or y>=len(maze[0]) or (tmp in seen) or maze[x][y] == '#':
        return False
    return True

def bfs(maze,i,j):    
    seen = {(i,j)}
    q = deque()
    q.append((i,j))

    tmpMoves = 0

    while q:
        gen = deque()
        while q:
            curr = q.pop()
            for d in dirr:
                x = curr[0]+d[0]
                y = curr[1]+d[1]
                tmp = (x,y)
                if valid(tmp,maze,seen):
                    gen.append(tmp)
                    seen.add(tmp)

        if not gen:break
        tmpMoves+=1        
        q = gen

    return tmpMoves
    

maze = [['.' for _ in range(n) ] for _ in range(m)]
for i in range(m):
    maze[i] = list(input())


max_moves = 0

for i in range(m):
    for j in range(n):
        if maze[i][j] == '#':continue
        ans = bfs(maze,i,j)        
        max_moves = max(ans,max_moves)

print(max_moves)


Measured memory_bytes: 3316
n,m=gets.chomp.split.map(&:to_i)
s=gets.chomp.split.map(&:to_i)
t=gets.chomp.split.map(&:to_i)
MOD=10**9+7

dp=Array.new(n+1).map{Array.new(m+1,0)}
sum=Array.new(n+1).map{Array.new(m+1,0)}


1.upto(n) do |i|
  1.upto(m) do |j|
    if s[i-1] == t[j-1]
      dp[i][j]=sum[i-1][j-1] + 1

    else
      dp[i][j]=0
    end
    sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j])%MOD
  end
end
puts (sum[n][m] + 1)%MOD


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

using namespace std;


int main(int argc, const char * argv[]) {
    int k, n, ans, i, j;
    cin >> k;
    if(k % 2 == 0){
        n = k / 2;
        ans = n * n;
    }else{
        i = (k+1) / 2;
        j = (k -1)/ 2;
        ans = i * j;
    }
    printf("%d\n", ans);
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

template<typename T> void chmin(T& a,const T& b){a=min(a,b);}

int main()
{
	for(int n,m,s,g1,g2;cin>>n>>m>>s>>g1>>g2,n|m|s|g1|g2;){
		s--; g1--; g2--;
		vvi g(n,vi(n,INFTY));
		rep(i,n) g[i][i]=0;
		rep(i,m){
			int a,b,c; cin>>a>>b>>c; a--; b--;
			g[a][b]=c;
		}
		
		rep(k,n) rep(i,n) rep(j,n)
			chmin(g[i][j],g[i][k]+g[k][j]);
		
		int res=INFTY;
		rep(i,n)
			chmin(res,g[s][i]+g[i][g1]+g[i][g2]);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1260
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n;
  ccin >> n;
  vector<ll> a(n);
  rep(i, n) {
    ccin >> a[i];
  }
  sort(all(a));
  ll1d ra(n + 1, 0);
  rep(i, n) {
    ra[i + 1] = ra[i] + a[i];
  }
  ll cnt = 1;
  rrep(i, n) {
    if (ra[i] * 2 >= a[i])
      ++cnt;
    else break;
  }
  ccout << cnt << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1792
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int n;
string s;
int can(int x, int y) {
	for (int j = x; j < y; ++j)
		if (s[j] == '#' && s[j + 1] == '#')
			return 0;
	return 1;
}
int three(int x, int y) {
	for (int j = x; j <= y; ++j) {
		if (s[j - 1] == '.' && s[j] == '.' && s[j + 1] == '.') {
			return 1;	
		}
	}
	return 0;
}
int main() {
	cin >> n;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	--a, --b, --c, --d;
	cin >> s;
	if (!can(b, d)) {
		cout << "No\n";
		return 0;
	}
	if (c < d) {
		if (can(a, c)) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
		return 0;
	}
	if (!three(b, d)) {
		cout << "No\n";
		return 0;
	}
	if (can(a, c)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	
}



















Measured memory_bytes: 644
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string s,ans="";
	cin >> s;

	FOR(i, 0, s.length()) {
		if (s[i] == '0')
			ans += '0';
		else if (s[i] == '1')
			ans += '1';
		else
			ans = ans.substr(0, ans.length() - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i;
  cin >> n >> k;
  int p[1010];
  for(i=0;i<n;i++){
  cin >> p[i];
  }
  sort(p,p+n);
  int sum=0;
  for(i=0;i<k;i++){
  sum+=p[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int N;
  cin>>N;
  if(N==3||N==5||N==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }


  

  



}


  
  

  


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

int main()  
{  
    int n;
    cin>>n;
    int a[n], index=1, c=0;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        if(a[i]!=index) {
            c++;
        } else if(a[i]==index) {
            index++;
        }
    }
    if(c==n) {
        cout<<-1;
    } else {
        cout<<c;
    }
}  

Measured memory_bytes: 1024
n = int(input())
d, x = map(int, input().split())
a = list(int(input()) for _ in range(n))
ans = 0
for i in range(n):
    j = 0
    while j * a[i] + 1 <= d:
        ans += 1
        j += 1
ans += x
print(ans)


Measured memory_bytes: 3060
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
if(array_search(0,$a)){
  echo 0;
  exit;
}
$l=pow(10,18);
$i=0;
$ans=(int)1;
while($i<$n){
  $ans*=$a[$i];
  if($ans>$l){
    echo -1;
    exit;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 25644
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

const int MOD = 1000000007;

struct Edge {
    int to;
    int weight;

    Edge(int t, int w) : to(t), weight(w) {}
};

int main() {
    int M, D;
    cin >> M >> D;

    int ans = 0;
    for (int m = 1; m <= M; ++m) {
        for (int d = 1; d <= D; ++d) {
            int d2 = d % 10;
            int d1 = d / 10;

            if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 123456
int sosu[2*MAX+1];

void furui()
{
  int i, j;
  for(i=0; i<=2*MAX; i++){
    sosu[i]=1;
  }
  for(i=2; i<=MAX; i++){
    if(sosu[i]==0) continue;
    j = i+i;
    while(j<=2*MAX){
      sosu[j]=0;
      j+=i;
    }
  }
}

int main()
{
  int n;
  int c;
  int i;
  furui();
  while(1){
    scanf("%d", &n);
    if(n==0) break;
    c=0;
    for(i=n+1; i<=2*n; i++)
      c+=sosu[i];
    printf("%d\n", c);
  }
  return 0;
} 

Measured memory_bytes: 1564
#include <bits/stdc++.h>
using namespace std;
int a, b, i;
string s;
void INP()
{
    cin >> a >> b;
}
void Solve()
{
    if (a > b)
    {
        for (i = 1; i <= a; i++)
        {
            s += char(b + 48);
        }
    }
    else
    {
        for (i = 1; i <= b; i++)
        {
            s += char(a + 48);
        }
    }
    cout << s;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freoepn("B.INP", "r", stdin);
    //freoepn("B.OUT", "w", stdout);
    INP();
    Solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll ac = 0;
  ll wa = 0;
  ll tle = 0;
  ll re = 0;
  I(N);
  string s;
  REP(i, N) {
    I(s);
    if (s == "AC") ac++;
    else if (s == "WA") wa++;
    else if (s == "TLE") tle++;
    else if (s == "RE") re++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

}


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

int main(){
 
  int N;
    cin>>N;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    sort(S.begin(),S.end());
    S.push_back(0);
    int ans=0,cnt=1;
    for(int i=1;i<N+1;i++){
        if(S.at(i)!=S.at(i-1)){
            if(S.at(i-1)>cnt) ans+=cnt;
            cnt=1;
        }
        else{
            if(S.at(i)>cnt){
                cnt++;
            }
            else{
                ans++;
                cnt++;
        }
    }
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1024
n = int(input())
a = [int(i)+1 for i in range(n)]

for i in range(len(a)):
    num = a[i]
    cnt = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        cnt += 1
    if i == 0:
        ans = num
        max_cnt = cnt
    elif max_cnt < cnt:
        ans = num
        max_cnt = cnt

print(ans)

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

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

ll n,k;
vector<vector<ll>> graph(1e5);
const ll MOD = 1e9+7;
ll ans = 1;

vector<bool> vdist(1e5,false);
vector<ll> kaizyou(1e5+2,1);
vector<ll> kaizyouinv(1e5+2,1);

ll inv_mod(ll a, ll MOD)
{
    ll b = MOD, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t*b;   swap(a,b);
        u -= t*v;   swap(u,v);
    }
    u %= MOD;
    if(u < 0) u+= MOD;
    return u;
}

void dfs(ll now)
{
    vdist.at(now) = true;
    if(graph.at(now).size()-1 > k-2){
        ans = 0;
        return;
    }else{
        ans *= kaizyou.at(k-2);
        ans %= MOD;
        ans *= kaizyouinv.at(k-2-(graph.at(now).size()-1));
        ans %= MOD;
        for(auto next:graph.at(now)){
            if(!vdist.at(next)) dfs(next);
        }
    }
    return;
}

int main()
{
    ll i,j;
    kaizyou.at(0) = 1;
    kaizyou.at(1) = 1;
    for(i = 2;i < kaizyou.size();++i){
        kaizyou.at(i) = kaizyou.at(i-1)*i%MOD;
    }
    kaizyouinv.at(0) = 1;
    kaizyouinv.at(1) = inv_mod(1, MOD);
    for(i = 2;i < kaizyouinv.size();++i){
        kaizyouinv.at(i) = kaizyouinv.at(i-1)*inv_mod(i, MOD)%MOD;
    }
    cin >> n >> k;
    
    for(i = 0;i < n-1;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }
    vdist.at(0) = true;
    ans *= k;
    ans %= MOD;
    if(graph.at(0).size() > k-1){
        cout << 0 << endl;
        return 0;
    }else{
        ans *= kaizyou.at(k-1);
        ans %= MOD;
        ans *= kaizyouinv.at(k-1-graph.at(0).size());
        ans %= MOD;
    }
    for(auto next:graph.at(0)){
        if(!vdist.at(next)) dfs(next);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

const FACT_MAX: usize = 300000;
const MOD: i64 = 1000000000+7;

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };
}

fn solve(n: usize, m: usize) -> i64 {
    if (n as i64 - m as i64).abs() > 1 {
        return 0
    }

    let nf = FACT.with(|fact| { fact[n] });
    let mf = FACT.with(|fact| { fact[m] });

    let mut ans = (nf * mf) % MOD;

    if n == m {
        ans = (ans * 2) % MOD;
    }

    ans
}

fn main() {
    let (n, m) = parse_line!(usize, usize);

    println!("{}", solve(n, m));
}

#[test]
fn solve_test() {
    assert_eq!(solve(3,2), 12);
    assert_eq!(solve(2,2), 8);
    assert_eq!(solve(1,8), 0);
    assert_eq!(solve(100000, 100000), 530123477);
}


Measured memory_bytes: 8444
#include <iostream>
using namespace std;
 
int main() {
	int n, i = 1;
	while(true){
		cin >> n;
		if(n != 0){
			cout << "Case" << " " << i << ":" << " " << n << endl;
			i++;
		}
		else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = (x-a)/b;
    System.out.println(x-a-(b*c));
  }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int min = 1000;
        int max = 0;
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            if(min > a){
                min = a;
            }
            if(max < a){
                max = a;
            }
        }
        
        System.out.println(max - min);
    }
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n;  i++)
	{
		if(i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

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

  int a[N];
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }

  if (N == 1) {
    if (a[1] == 1) {
      cout << 0 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  int num = 1, ans = 0;
  for (int i = 1; i <= N; i++) {
    if (a[i] == num) {
      num++;
    } else {
      ans++;
    }
  }

  if (ans == N) {
    cout << -1 << endl;
  } else if (num > 1) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0;i<n;i++) {
        int x;
        cin >> x;
        if(x >= k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
s = input()
c = Counter(s)
w, r = 0, c['R']
ans = max(w, r)
for i in range(N):
    if s[i] == 'W': w += 1
    else: r -= 1 
    ans = min(ans, max(w, r))

print(ans)

Measured memory_bytes: 9632
#include <stdio.h>

int main(void) {
    int n, i=0;
    int min = 1000001;
    int max = -1000001;
    long long sum = 0;
    scanf("%d", &n);

    int a[n];
    while (i < n){
    scanf("%d",&a[i]);
    if (a[i] < min) min = a[i];
    if (max < a[i]) max = a[i];
    sum += a[i];
    i++;
    }

    printf("%d %d %lld\n", min, max, sum);    
    return 0;
}


Measured memory_bytes: 1992
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

vector<int> a;

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n, c, k;
	scanf("%d%d%d", &n, &c, &k);
	a.resize(n);
	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	int res = 1;
	int last = 0;
	FOR(i, 1, a.size()) {
		if ((i - last >= c) || (a[i] - a[last] > k)) {
			res++;
			last = i;
		}
	}
	cout << res << endl;

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 640
import std.algorithm, std.conv, std.range, std.stdio, std.string;

const mod = 10 ^^ 9 + 7;
alias mint = FactorRing!(mod, true);

void main()
{
  auto n = readln.chomp.to!int;
  auto p = mint(1);
  foreach (i; 1..n+1) p *= i;
  writeln(p);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) {
    union { long vl; struct { int vi2; int vi; } }
  } else {
    union { long vl; int vi; }
  }

  @property int toInt() { return vi; }
  alias toInt this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref FactorRing!(m, pos) opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const
  {
    static if (pos) return v % m;
    else return (v % m + m) % m;
  }

  pure auto mod(long v) const
  {
    static if (pos) return cast(int)(v % m);
    else return cast(int)((v % m + m) % m);
  }

  static if (m < int.max / 2) {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vi + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vi - rhs)); }
  } else {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vl + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vl - rhs)); }
  }
  pure auto opBinary(string op: "*")(int rhs) const { return FactorRing!(m, pos)(mod(vl * rhs)); }

  pure auto opBinary(string op)(FactorRing!(m, pos) rhs) const
    if (op == "+" || op == "-" || op == "*") { return opBinary!op(rhs.vi); }

  static if (m < int.max / 2) {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vi + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vi - rhs); }
  } else {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vl + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vl - rhs); }
  }
  auto opOpAssign(string op: "*")(int rhs) { vi = mod(vl * rhs); }

  auto opOpAssign(string op)(FactorRing!(m, pos) rhs)
    if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(rhs.vi); }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[1000][1000] = { 0 };
int main() {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1; i <= m; i++) {
		int l, r;
		cin >> l >> r;
		co[l][r]++;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			co[i][j] += co[i - 1][j] + co[i][j - 1];
			co[i][j] -= co[i - 1][j - 1];
		}
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << co[r][r] - co[r][l - 1] - co[l - 1][r] + co[l - 1][l - 1] << endl;
	}
	return 0;
}


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

int main() {
    int n;
    int v[1010] = { 0 };
    float result = 0.0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    sort(v, v + n);

    for (int i = 0; i < n; i++) {
        result = (((i == 0) ? v[i] : result) + v[i]) / 2;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[]

def distance(list1,list2):
    dis=0
    for i in range(len(list1)):
        dis=dis+(list1[i]-list2[i])*(list1[i]-list2[i])
    return dis
                                     

for i in range(n):
    x.append(list(map(int,input().split())))

ans=0
for i in range(n):
    for j in range(n-i-1):
        a=distance(x[i],x[i+j+1])
        if a==int((math.sqrt(a)))*int((math.sqrt(a))):
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {

  int A, B ;
  int ans ;

  scanf("%d %d", &A, &B) ;

  if (B % A == 0) {
    ans = A + B ;
  }
  else {
    ans = B - A ;
  }

  printf("%d\n", ans) ;

  return 0 ;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
int A,B;
int X;
int i;
int max;
int sum=0;
  
  scanf("%d",&A);
  scanf("%d",&B);
  for(i=0;i<2;i++){
  if(A>B){
  max=A;
  sum=sum+max;
    A=A-1;
  }
    else{
     max=B;
  sum=sum+max;
    B=B-1;
    }
  }
  printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
a,b,k = map(int, input().split())

S=set()
for i in range(k):
    if a+i <= b:
        S.add(a+i)
    if b-i >= a:
        S.add(b-i)
S = [x for x in S]
S.sort()
for i in range(len(S)):
    print(S[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(9);
  for(int i = 0; i < 9; i++) cin >> vec.at(i);
  int N;
  cin >> N;
  vector<int> vec1(9);
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    for(int j=0; j < 9; j++){
      if(vec.at(j)==tmp) vec1.at(j)++;
    }
  }
  int ans=0;
  if(vec1.at(0)>0 && vec1.at(1)>0 && vec1.at(2)>0) ans++;
  if(vec1.at(3)>0 && vec1.at(4)>0 && vec1.at(5)>0) ans++;
  if(vec1.at(6)>0 && vec1.at(7)>0 && vec1.at(8)>0) ans++;
  if(vec1.at(0)>0 && vec1.at(3)>0 && vec1.at(6)>0) ans++;
  if(vec1.at(1)>0 && vec1.at(4)>0 && vec1.at(7)>0) ans++;
  if(vec1.at(2)>0 && vec1.at(5)>0 && vec1.at(8)>0) ans++;
  if(vec1.at(0)>0 && vec1.at(4)>0 && vec1.at(8)>0) ans++;
  if(vec1.at(2)>0 && vec1.at(4)>0 && vec1.at(6)>0) ans++;
  if(ans>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  string str[H];
  for(int i = 0; i < H; ++i){
    cin >> str[i];
  }
  for(int i = 0; i < W + 2; ++i){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < H; ++i){
    cout << "#" << str[i] << "#" << endl;
  }
  for(int i = 0; i < W + 2; ++i){
    cout << "#";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
  if(U==S)A=A-1;
  if(U==T)B=B-1;
  cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
local n = io.read("*n")
if n == 3 then
  print("2 3 25")
elseif n % 4 == 1 then
  local rep = (n - 1) // 4
  for i = 0, rep - 1 do
    io.write(2 + 6 * i .. " " .. 3 + 6 * i .. " " .. 4 + 6 * i .. " " .. 6 + 6 * i .. " ")
  end
  if n % 8 == 1 then
    print(rep * 6 + 6)
  else
    print(rep * 6 + 3)
  end
elseif n % 4 == 0 then
  local rep = n // 4 - 1
  for i = 0, rep - 1 do
    io.write(2 + 6 * i .. " " .. 3 + 6 * i .. " " .. 4 + 6 * i .. " " .. 6 + 6 * i .. " ")
  end
  io.write(2 + 6 * rep .. " " .. 3 + 6 * rep .. " " .. 4 + 6 * rep .. " ")
  if n % 8 == 0 then
    print(rep * 6 + 6)
  else
    print(rep * 6 + 9)
  end
elseif n % 4 == 2 then
  local rep = (n - 2) // 4
  for i = 0, rep - 1 do
    io.write(2 + 6 * i .. " " .. 3 + 6 * i .. " " .. 4 + 6 * i .. " " .. 6 + 6 * i .. " ")
  end
  if n % 8 == 2 then
    print(2 + 6 * rep .. " " .. 4 + rep * 6)
  else
    print(3 + 6 * rep .. " " .. 6 + rep * 6)
  end
else
  local rep = (n - 3) // 4
  for i = 0, rep - 1 do
    io.write(2 + 6 * i .. " " .. 3 + 6 * i .. " " .. 4 + 6 * i .. " " .. 6 + 6 * i .. " ")
  end
  if n % 8 == 3 then
    print(2 + 6 * rep .. " " .. 4 + rep * 6 .. " " .. 6 + rep * 6)
  else
    print(2 + 6 * rep .. " " .. 3 + rep * 6 .. " " .. 4 + rep * 6)
  end
end


Measured memory_bytes: 1008
import queue
n,m = map(int, input().split())
V = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)
ans = [-1]*(n+1)
q = queue.Queue()
q.put(1)
while not q.empty():
    p = q.get()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.put(c)
print('Yes')
for i in range(2,n+1): print(ans[i])


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


int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0) {
            int j = n / i;
            if (1 <= j && j <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> A(N), B(N-1);
  for (int n = 0; n < N-1; ++n) {
    std::cin >> B[n];
  }
  A[0] = B[0];
  for (int n = 1; n < N-1; ++n) {
    A[n] = std::min(B[n-1], B[n]);
  }
  A[N-1] = B[N-2];

  std::cout << std::accumulate(A.begin(), A.end(), 0) << std::endl;;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// LHiC氏.
// https://atcoder.jp/contests/code-festival-2017-quala/submissions/1617008
#include <bits/stdc++.h>
using namespace std;
int h, w, d;
int c[1200];
char s[1200][1200];

int main(){
    scanf("%d %d %d", &h, &w, &d);
    for(int i = 0; i < h + w - 1; ++i){
        if(i >= d) c[i] = c[i - d] ^ 1;
        else       c[i] = 0;
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int a = c[i + j] * 2 + c[i + (w - 1 - j)];
            if(a == 0)       s[i][j] = 'R';
            else if (a == 1) s[i][j] = 'G';
            else if (a == 2) s[i][j] = 'B';
            else             s[i][j] = 'Y';
        }
    }
    for(int i = 0; i < h; ++i) printf("%s\n", s[i]);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main() {
	vector<int> a(100, 0);
	int d = 0;
	int g = 0;
	bool c = false;
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (i != j) {
				if (a[i] == a[j]) {
					d = i;
					g = j;
					break;
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		if (i == d || i == g) {
			continue;
		}
		for (int j = 0; j < 4; j++) {
			if (j == d || j == g) {
				continue;
			}
			if (i != j) {
				if (a[i] == a[j]) {
					c = true;
				}
			}
		}
	}
	if (c) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    int cnt[26]={};
    
    while(cin >> ch){
        ch=tolower(ch);
        if(isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    
    for(int i=0; i<26; i++){
        printf("%c : %d\n", i+'a', cnt[i]);
    }
    return 0;
}



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

using namespace std;

int main()
{
    int N;
    string s1, s2;
    cin >> N >> s1 >> s2;
    long ans = 0;
    bool tate;
    //true : x | false : xx
    //       x |         yy

    int Pos = 0;

    if (s1[0] == s2[0])
    {
        Pos = 1;
        ans = 3;
        tate = true;
    }
    else
    {
        Pos = 2;
        ans = 6;
        tate = false;
    }

    while (Pos < N)
    {
        if (s1[Pos] == s2[Pos])
        {
            if (tate)
            {
                ans *= 2;
            }
            else
            {
                ans *= 1;
            }
            Pos += 1;
            tate = true;
        }
        else
        {
            if (tate)
            {
                ans *= 2;
            }
            else
            {
                ans *= 3;
            }
            Pos += 2;
            tate = false;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for (int i = 0; i < n; i++)
		{
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			double x4 = sc.nextDouble();
			double y4 = sc.nextDouble();
			boolean a = ((y1 - y2) / (x1 - x2) == (y3 - y4) / (x3 - x4));
			System.out.println(a ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 12000
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ma=max(A)
    l=0.0
    r=ma
    if K==0:
        print(ma)
        return

    def hantei(mid):
        cnt=0
        for a in A:
            cnt+=math.ceil(a/mid)-1
        return cnt<=K

    while r-l>1:
        mid=(l+r)//2
        if hantei(mid):
            r=mid
        else:
            l=mid
    mid=(l+r)//2



    print(int(r))

    



if __name__ == "__main__":
    main()

Measured memory_bytes: 109072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

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

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  
  string S;
  cin>>S;
  
  vector<ll>R;
  vector<ll>L;
  vector<ll>M;
  
  ll sum=1;
  rep(i,N){
    if(i>=1){
if(S[i]==S[i-1]){
  sum++;
}
else{
  if(S[i-1]=='R'){
R.push_back(sum);
  }
    else{
      L.push_back(sum);
    }
      
sum=1;
}
    }

    if(i==N-1){
      if(S[i]=='R'){
R.push_back(sum);
      }
else{
L.push_back(sum);
}
    }
}
ll vast=0;
    
    vector<ll>date;
  date.resize(R.size()+L.size());
    
    if(S[0]=='R'){
      ll r=1;
      ll l=0;
      date[0]=R[0];
      
      for(ll i=1;i<R.size()+L.size();i++){
        if(i%2==1){
        date[i]=date[i-1]+L[l];
          l++;
        }
     else{
       date[i]=date[i-1]+R[r];
       r++;
     }
      }
    }

  else{
      ll r=0;
      ll l=1;
      date[0]=L[0];
      
      for(ll i=1;i<R.size()+L.size();i++){
        if(i%2==1){
        date[i]=date[i-1]+R[r];
          r++;
        }
     else{
       date[i]=date[i-1]+L[l];
       l++;
     }
      }
    }
  M.resize(R.size()+L.size());
  rep(i,R.size()+L.size()){
if(i==0){
M[i]=date[i]-1;
}
    else{
M[i]=M[i-1]+date[i]-date[i-1]-1;
    }
  }
  
if(date.size()<=K*2){
  vast=N-1;
}


  rep(i,R.size()+L.size()-2*K+1){
    if(i==0){
vast=max(vast,date[2*K]-1+M[M.size()-1]-M[2*K]);
    }
    else{
      vast=max(vast,date[i+2*K]-date[i-1]-1+M[i-1]+M[R.size()+L.size()-1]-M[i+2*K]);
    }
  }

    cout<<vast<<endl;
  
 

}

  


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

int main() {
  string s; cin >> s;
  int n = 0;
  int sn = 0;
  
  for (int i = 0; i < s.size(); i++) {
    n += (s.at(i) - '0') * pow(10, s.size() - 1 - i);
    sn += s.at(i) - '0';
  }
  
  if (n % sn == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256