akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vi  g[10005]; 
bool vis[10005];

inline void solve(){
	int n,ans = 0; cin>>n; 
    vi c(n),res(n+1); 
    for (int i=0;i<n-1;i++){ 
    	int  u, v ; 
    	cin >> u >> v ; 
    	g[u].pb(v) ; 
    	g[v].pb(u) ; 
    } 
    for (int i=0;i<n;i++) cin >> c[i] ; 
    sort(all(c)) ; 
	int  i = n-2 ; 
    function < void(int) > dfs = [&] (int u){
    	if (vis[u]) return ; 
    	vis[u] = true;
    	for (auto &it: g[u]){
    		if (!vis[it]){
    			ans += c[i] ; 
    			res[it] = c[i] ; 
    			i--; 
    			dfs(it); 
    		}
    	}
    };
    res[1] = c[n-1] ; 
    dfs(1) ; 
    co (ans) ; 
    for (int i=1;i<=n;i++) 
    	cout << res[i] << " " ; 
    cout << endl; 
}

signed main()
{
    solve();
    return 0;
}
/* 

5 
1 2 
1 3 
3 4 
3 5 
2 3 4 5 6 

		ans -> 14 



*/

Measured memory_bytes: 4980
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt
  
for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t





main :: IO ()
main = do
  [n,m,x,y] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getLine :: IO [Int]
  ys <- map read . words <$> getLine :: IO [Int]

  let
    xx = sort (x:xs)
    yy = sort (y:ys)

  putStrLn $ if last xx < head yy then "No War" else "War"
  
  


Measured memory_bytes: 1020
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AStillTBD {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int yy,mm,dd;
	    scanf("%d/%d/%d",&yy,&mm,&dd);
	    if(yy<2019 || (yy==2019 && mm<=4 && dd<=30)) out<<"Heisei";
	    else out<<"TBD";

	}
};


int main() {
	AStillTBD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  if(n%2==0){
    int vec[n];
    for(int i=0;i<n;i++){
      cin>>vec[i];
    }
    int x=n-1;
    for(int i=0;i<n;i++){
      if(i<n/2){
        cout<<vec[x]<<" ";
        x-=2;
      }
      if(x==-1){
        x=0;
      }
      if(i>=n/2){
        cout<<vec[x]<<" ";
        x+=2;
      }
    }
    return 0;
  }
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int x=n-1;
  for(int i=0;i<n;i++){
    if(i<n/2+1){
      cout<<vec[x]<<" ";
      x-=2;
    }
    if(x==-2){
      x=1;
    }
    if(i>=n/2+1){
      cout<<vec[x]<<" ";
      x+=2;
    }
  }
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void)
{
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '1')s.replace(i, 1, "9");
		else if (s[i] == '9')s.replace(i, 1, "1");
	}
	print(s);

}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

using P = Point<long long>;
template<class T>
T polygonArea2(vector<Point<T>>& v) {
	T a = v.back().cross(v[0]);
	rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
	return a;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<P> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i].x >> a[i].y;
	}
	long double ans = abs(polygonArea2(a)) / 2.0;
	cout << fixed << setprecision(1);
	cout << ans << '\n';
}


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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll x,a,b;
    cin>>x>>a>>b;
    ll temp1=ceil((a*1.0)/x);
    if (temp1*x<=b){
    	cout<<"OK"<<endl;
    }
    else{
    	cout<<"NG"<<endl;
    }
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3780
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll GCD(ll A, ll B){
  ll M = max(A, B), m = min(A, B);
  while (M % m != 0){
    M = M % m;
    swap(M, m);
  }
  return m;
}

int main(){
  int N; ll X; cin >> N >> X;
  vector <ll> x(N), deg(N);
  for (int i = 0; i < N; i++){
    cin >> x[i];
    deg[i] = abs(x[i] - X);
  }

  ll ans = deg[0];
  for (int i = 0; i < N; i++){
    ans = GCD(ans, deg[i]);
  }
  cout << ans << endl;

  
  return 0;
}


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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

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

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n;
        cin >> n;
        vi arr(n), brr(n), crr(n);
        FOR(i, n) cin >> arr[i] >> brr[i] >> crr[i];

        int dp[n][3];
        dp[0][0] = arr[0];
        dp[0][1] = brr[0];
        dp[0][2] = crr[0];

        for(int i = 1; i < n; ++i)
        {
            dp[i][0] = arr[i] + max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = brr[i] + max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = crr[i] + max(dp[i-1][1], dp[i-1][0]);
        }
        cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});

    }

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
  cout<<1<<endl;
  
  else if(x2==0)
  cout<<2<<endl;
  else if(x3==0)
  cout<<3<<endl;
  else if(x4==0)
  cout<<4<<endl;
  else if(x5==0)
  cout<<5<<endl;
} 

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string nstr(){
    static const int MAX_LEN = 200010;
    static char res_[MAX_LEN];
    scanf("%s",res_);
    return string(res_);
}

int main(){
    string X = nstr();
    int N = sz(X), ans = N, x = 0;
    rep(i, N){
        if(X[i] == 'S')x++;
        else{
            if(x > 0){
                x--;
                ans -= 2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){

        double x1,y1,x2,y2,answer;

        cin >> x1 >> y1 >> x2 >>y2;
        answer = sqrt(pow((x1 - x2),2) + pow((y1 - y2),2));
        cout << fixed << setprecision(8) << answer << endl;


        return 0;
}

Measured memory_bytes: 1284
/* ABC133-A.c
   Yuta Takayanagi */

#include<stdio.h>
int main(void){
    int number, train, taxi, sum;

    sum = 0;

    scanf( "%d %d %d" , &number, &train, &taxi);

    sum = number * train;

    if(sum<taxi){

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

    }else{

        printf( "%d\n" , taxi);
        
    }

    return 0;
}

Measured memory_bytes: 128
x = input()
ori = input()
loop = 1000
while loop != 0:
    if x == ori:
        print("Yes")
        break
    y = [y for y in x]
    if loop == 1000:
        loop = len(y)
    move = y.pop(0)
    y.append(move)
    x = "".join(y)
    loop -= 1
if loop == 0:
    print("No")

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

using namespace std;
using ll = long long;

int main(void) {
  ll x;
  cin >> x;

  for (ll a = -120; a <= 120; a++) {
    for (ll b = -120; b <= 120; b++) {
      if (a*a*a*a*a-b*b*b*b*b == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3648
#include<cstdio>
const int MaxN=100010;
int N,P[2][MaxN];
struct edge{int to,cap;edge*rev,*next;}E[MaxN*4],*ne=E,*fir[MaxN],*cur[MaxN];
void link(int a,int b,int c){
	*ne=(edge){b,c,ne+1,fir[a]};fir[a]=ne++;
	*ne=(edge){a,0,ne-1,fir[b]};fir[b]=ne++;
}
int Q[MaxN],D[MaxN];
int dfs(int i,int c){
	if(i==1||!c)return c;
	int fl=0,f;
	for(edge*&e=cur[i];e&&c;e=e->next)if(e->cap&&D[e->to]==D[i]-1&&(f=dfs(e->to,c<e->cap?c:e->cap)))
		fl+=f,e->cap-=f,e->rev->cap+=f,c-=f;
	return fl;
}
int vtot;
int mf(){
	for(int f=0;;f+=dfs(0,1<<30)){
		for(int i=0;i<vtot;i++)D[i]=0,cur[i]=fir[i];
		for(int*h=Q,*t=Q+(D[*h=1]=1);h<t;h++){
			for(edge*e=fir[*h];e;e=e->next){
				if(e->rev->cap&&!D[e->to])D[*t++=e->to]=D[*h]+1;
			}
		}
		if(!D[0])return f;
	}
}
int id[2][MaxN],sz[2][MaxN],w[2][MaxN];
int main(){
	scanf("%d",&N);
	for(int t=0;t<2;t++)
		for(int i=0;i<N;i++)scanf("%d",P[t]+i);
	int cc[2]={0};
	for(int t=0;t<2;t++){
		for(int i=0;i<N;i++)if(P[t][i]!=i&&!id[t][i]){
			cc[t]++;
			for(int j=i;!id[t][j];j=P[t][j])id[t][j]=cc[t],sz[t][cc[t]]++;
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		if(P[0][i]==i&&P[1][i]==i)continue;
		if(P[0][i]==i)ans++,link(0,1+cc[0]+id[1][i],1);
		else if(P[1][i]==i)ans++,link(1+id[0][i],1,1);
		else{
			ans++;
			link(1+id[0][i],1+cc[0]+id[1][i],1);
			if(P[0][i]==P[1][i])link(1+cc[0]+id[1][i],1+id[0][i],1);
		}
	}
	vtot=2+cc[0]+cc[1];
	printf("%d\n",ans-mf());
}

Measured memory_bytes: 15744
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

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

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

    auto f = [](int v){
        int bx = 0;
        for(int i = 1; i <= 1e12; i *= 2){
            int bits = updiv(v / i, 2) * i;
            if(v / i % 2 == 0){
                bits += v % i;
            }
            if(bits & 1){
                bx += i;
            }
            v -= i;
            if(v <= 0) return bx;
        }
        return bx;
    };

    cout << (f(a) ^ f(b) ^ a) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int cnt = 0;
    bool ans = 0;
    int n; cin>>n;
    for0(i, n){
        int a, b; cin>>a>>b;
        if(a == b) cnt++;
        else cnt = 0;
        if(cnt >= 3) ans = 1;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3648
#include<stdio.h>

int main(){
	long int x, i, j;
	scanf("%ld", &x);
	if(x==2 || x==3){
		printf("%d", x);
		return 0;
	}
	for(x;x>0;x++){
		for(i=2;i<=x/2;i++){
			if(x%i==0)	break;
			if(i==x/2){
				printf("%ld", x);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
A,B,K=map(int,input().split())
for i in range(K):
  if i%2==0:
    if A%2==1:
      A-=1
    B+=A//2
    A//=2
  else:
    if B%2==1:
      B-=1
    A+=B//2
    B//=2
print(A,B)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     998244353 
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll N,A,B;
	cin>>N>>A>>B;
	if(A>B)
		swap(A,B);
	ll diff=B-A;
	if(diff%2==0)
		cout<<diff/2;
	else
	{
		ll ans=min(B-1,N-A);
		ll a=A,b=B;
		b-=a;
		ans=min(ans,a+(b-1)/2);
		a=A,b=B;
		a+=(N-b+1);
		ans=min(ans,N-b+1+(N-a)/2);
		cout<<ans;
	}		
	
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[4];
  int i,a,b,c;
  scanf("%s",s);
  if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
    printf("Yes");
  }else{
  printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


using namespace std;


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

	return 0;

}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,x,y,z,h,j,k;
    cin>>a>>b>>c>>d>>e;
 
    if(a<0){
        x=-a;
    }
    y=x*c;
    h=b-a;
    j=h*e;
    z=b*e;
    if(a<0){
        k=y+d+z;
        cout<<k<<endl;
    }
    else if(a>0){
        cout<<j<<endl;
        
    }
    
}


Measured memory_bytes: 3096
s = input()
left,right = map(int, [s[:2], s[-2:]])
if 0 < left < 13:
    if 0 < right < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < right < 13:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	yen, num int
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	
	drinks := make([]pair, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&drinks[i].yen, &drinks[i].num)
	}
	
	sort.Slice(drinks, func(i, j int) bool {
		return drinks[i].yen < drinks[j].yen
	})
	
	ans := 0
	for _, v := range drinks {
		buy := min(v.num, m)
		ans += buy * v.yen
		m -= buy
		if m < 0 {
			break
		}
	} 
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 6336
n, m = map(int, input().split())
py = [tuple(map(int, input().split())) for _ in range(m)]

spy = sorted(py, key=lambda x: x[1])
ids = {}
maxy = [1] * (n + 1)
for p, y in spy:
    ids[(p, y)] = maxy[p]
    maxy[p] += 1
for p, y in py:
    print('{:0=6}{:0=6}'.format(p, ids[p,y]))




Measured memory_bytes: 35716
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
char ch;
ch=getchar();
if(islower(ch))
{
    printf("a");
}
else
{
    printf("A");
}

    //Write your logic to print the tokens of the sentence here.
    return 0;
}


Measured memory_bytes: 1592
fn main() {
    let (n,m) = {
        let s = rv::<usize>();
        (s[0],s[1])
    };
    let mut g = vec![vec![];n];
    for _ in 0..m {
        let s = rv::<usize>();
        g[s[0]-1].push(s[1]-1);
    }
    let (s,t) = {
        let s = rv::<usize>();
        (s[0]-1,s[1]-1)
    };
    let mut d = vec![[INF;3];n];
    let mut q = std::collections::BinaryHeap::new();
    q.push((0,s));
    while let Some((c,v)) = q.pop() {
        let c = -c;
        let c1 = c/3;
        let c2 = (c%3)as usize;
        if d[v][c2] <= c1 {
            continue;
        }
        d[v][c2]=c1;
        if v==t && c2==0 {
            break;
        }
        let c = c+1;
        let c2 = (c%3)as usize;
        for &u in &g[v] {
            if d[u][c2]>c {
                q.push((-c,u));
            }
        }
    }
    println!("{}",if d[t][0]<INF {d[t][0]} else {-1});
}
const INF: i32 = std::i32::MAX;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 12540
import math

n,k = map(int,input().split())

w = 0
for i in range(1,n+1):
    #k<=(2**j)*iとなるjについてw = w + (1/n) * (1/2)**j
    j = max(0,math.ceil((math.log((k/i),2))))
    w = w + (1/n) * (1/2)**j
print(w)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	static int COUNT = 0;

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		String[] input = br.readLine().split(" ");

		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(input[i]);
		}

		a = selectionSort(a, n);

		for(int i = 0; i < n; i++){
			
			System.out.print(a[i]);

			if(i != (n - 1)){
				System.out.print(" ");
			}else{
				System.out.print("\n");
			}

		}

		System.out.println(COUNT);

	}

	static int[] selectionSort(int[] a, int n){

		for(int i = 0; i < (n - 1); i++){

			int min = i;

			for(int j = (i + 1); j < n; j++){

				if(a[j] < a[min]){
					min = j;
				}

			}

			if(min != i){
				COUNT++;
			}

			int temp = a[min];
			a[min] = a[i];
			a[i] = temp;

		}

		return a;

	}

}

Measured memory_bytes: 24412
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        map<int, ll> info;
        bool used[5000] = {};
        vector<int> v(n, 0);
        bool flag = false;
        for(int i = 0; i < n; i++)
        {
            ll p, q; cin >> v[i] >> p >> q;
            info[v[i]] += p * q;
        }
        for(int i = 0; i < n; i++)
        {
            if(used[v[i]]) continue;
            if(info[v[i]] >= 1000000)
            {
                cout << v[i] << endl;
                used[v[i]] = true;
                flag = true;
            }
        }
        if(flag == false) cout << "NA" << endl;
    }
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int ans1 = 0;
  int ans2 = 0;
  FOR(i, 1, n + 1) {
    if(i % k == 0) ans1++;
    if(k % 2 == 0 && i % k == k / 2) ans2++;
  }
  out(1LL * ans1 * ans1 * ans1 + 1LL * ans2 * ans2 * ans2);
  return 0;
}


Measured memory_bytes: 256
import copy
H,W,K = [int(_n) for _n in input().split()]
WHITE = 0
BLACK = 1
grid = []
for i in range(H):
    s = input()
    grid.append([])
    for c in s:
        grid[i].append(BLACK if c == "#" else WHITE)
res = 0
for tate in range(2**H):
    for yoko in range(2**W):
        # print("-----")
        grid2 = copy.deepcopy(grid)
        for t in range(H):
            if ((tate >> t) & 1) == 1:
                # print(t)
                grid2[t] = [WHITE]*W
        # print("-")
        for y in range(W):
            if ((yoko>>y) & 1) == 1:
                # print(y)
                for h in range(H):
                    grid2[h][y] = WHITE
        r = 0
        for i in range(H):
            for j in range(W):
                if(grid2[i][j] == BLACK):
                    r += 1
        # print(grid2)
        # print(r)
        if r == K:
            res += 1
            # print(tate,yoko)

print(res)

Measured memory_bytes: 73700
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5+5;

long long fin = 3234566667;

set < ll > all;

void go(ll num){
    if(num > fin)
        return;
    all.insert(num);
    if(num)
        go(num * 10 + (num % 10));
    if(num % 10 <= 8)
        go(num * 10 + (num % 10 + 1));
    if(num % 10 > 0)
        go(num * 10 + (num % 10 - 1));
}

int main(){
    for(int i = 1; i <= 9; i++){
        go(i);
    }
    int k;
    cin >> k;
    for(auto v : all){
        k--;
        if(k == 0){
            cout << v << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())

rate = 0
for i in range(1, N+1):
    if i >= K:
        rate += 1/N
        continue
    div = 1
    while i*(2**div) < K:
        div += 1
    rate += 1/N * (1/2)**div

print(rate)


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

int main() {
long int n,m;
string st;
cin>>n>>m;
long int s[m],p[m];
for(int i=0;i<m;i++){
    cin>>p[i]>>st;
    if(st=="AC"){
        s[i]=1;
    }
    else if(st=="WA") {
     s[i]=0;   
    }
}
long int penly=0,points=0;
unordered_map<int,int> done,pen;
for(int i=0;i<m;i++){
    if(done[p[i]]==0){
        if(s[i]==0){
            pen[p[i]]++;
        }
        else if(s[i]==1){
            points++;
            done[p[i]]=1;
        }
    }
}
for(int i=0;i<m;i++){
    if(done[p[i]]==1){
        penly+=pen[p[i]];
        done[p[i]]=0;
    }
}
cout<<points<<" "<<penly;
	return 0;
}


Measured memory_bytes: 13112
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

vector<ll> ar;
ll dp[110][2][5];

ll func(ll idx,ll t,ll k)
{
    if(idx<0){
        if(k==0){return 1;}
        else{return 0;}
    }
    if(dp[idx][t][k]==-1){
    ll ans=0;
    int x=t==1?ar[idx]:9;
    for(int i=0;i<=x;++i)
    {
        int nt=t&(i==ar[idx]);
        if(i==0){
            ans+=func(idx-1,nt,k);
        }
        else{
            if(k>0){
                ans+=func(idx-1,nt,k-1);
            }
        }
    }
    dp[idx][t][k]=ans;}
    return dp[idx][t][k];
}

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

    string n;
    cin>>n;
    ll k;
    cin>>k;
    for(ll i=0;i<n.length();++i)
    {
        ar.pb(n[i]-'0');
    }
    reverse(ar.begin(),ar.end());
    ll nn=ar.size();
    memset(dp,-1,sizeof(dp));
    ll ans=func(nn-1,1,k);
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

void merge_sort(double *t1, int left, int right){    //アドレスが渡される
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        merge_sort(t1,left,left+n2-1);
        merge_sort(t1,left+n2,right);

        double t2[n2];
        double t3[n3];
        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
        }

        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                k++;
            }
        }
    }
}

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  double *v=(double *)malloc(sizeof(double)*N);
  rep(i,N){
    scanf("%lf",&v[i]);
  }

  merge_sort(v, 0, N-1);

  long div=2;
  double sum=0;
  rrep(i,N){
    sum+=v[i]/div;
    if(i==1){
      ;
    }
    else{
      div=div*2;
    }
  }

  printf("%f\n", sum);

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

const int N = 100 * 1000 + 5;

int a[N], b[N];
set <pair <int, int> > s;
map <int, set <int> > mp;
int c[N], d[N];
map <int, vector <int> > adj;
map <int, bool> mark;

void dfs(int v) {
	mark[v] = true;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
		}
	}
}


int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[0] ^= a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		b[0] ^= b[i];
		if (a[i] != b[i]) {
			mp[b[i]].insert(i);
			s.insert({a[i], i});
		}
	}
	for (int i = 0; i <= n; i++) {
		c[i] = a[i];
		d[i] = b[i];
	}
	sort(c, c + n + 1);
	sort(d, d + n + 1);
	for (int i = 0; i <= n; i++) {
		if (c[i] != d[i]) {
			cout << -1;
			return 0;
		}
		if (a[i] != b[i]) {
			adj[i].push_back(a[i] + N);
			adj[i].push_back(b[i] + N);
			adj[a[i] + N].push_back(i);
			adj[b[i] + N].push_back(i);
			ans++;
		}
	}
	if (ans == 0) {
		cout << 0;
		return 0;
	}
	if (a[0] != b[0]) {
		ans -= 2;
	}
	else {
		if (adj[a[0] + N].size() != 0) {
			ans--;
		}
	}
	//cout << ans << endl;
	for (int i = 0; i <= n; i++) {
		if (a[i] != b[i] && !mark[i]) {
			dfs(i);
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 73836
# import numpy as np
# import math
# import copy
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from collections import deque


def main():
    H,W = map(int,input().split())
    S = [input().split()[0] for _ in range(H)]

    INF = 1001001001
    res = 0

    di = [-1,0,1,0]
    dj = [0,-1,0,1]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                continue
            dist = [[INF for l in range(W)] for k in range(H)]
            queue = deque([[i,j]])
            dist[i][j] = 0
            maxdist = 0
            while len(queue):
                nowi,nowj = queue.popleft()
                for k in range(4):
                    tari = nowi + di[k]
                    tarj = nowj + dj[k]
                    if (tari<0)|(tari>=H)|(tarj<0)|(tarj>=W):
                        continue
                    if S[tari][tarj] == '#':
                        continue
                    if dist[tari][tarj] == INF:
                        dist[tari][tarj] = dist[nowi][nowj] + 1
                        queue.append([tari,tarj])
                        maxdist = max(maxdist,dist[tari][tarj])
            res = max(res,maxdist)

    print(res)


main()


Measured memory_bytes: 3436
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=2000+10;

int n,m;
char s[N][N];
int h[N][N],L[N],R[N],sta[N],top=0;

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) scanf("%s",s[i]+1);
	for (int i=1;i<n;++i)
		for (int j=1;j<m;++j) {
			int c=(s[i][j]=='#')+(s[i][j+1]=='#')+(s[i+1][j]=='#')+(s[i+1][j+1]=='#');
			if (c&1) h[i][j]=0;
			else h[i][j]=h[i-1][j]+1;
		}
	int ans=max(n,m);
	for (int i=1;i<n;++i) {
		sta[top=1]=0;
		for (int j=1;j<m;++j) {
			while (top&&h[i][sta[top]]>=h[i][j]) --top;
			L[j]=sta[top],sta[++top]=j;
		}
		sta[top=1]=m;
		for (int j=m-1;j;--j) {
			while (top&&h[i][sta[top]]>=h[i][j]) --top;
			R[j]=sta[top],sta[++top]=j;
		}
		for (int j=1;j<m;++j)
			ans=max(ans,(h[i][j]+1)*(R[j]-L[j]));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 23476
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#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 CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int A[SIZE];
int main(){
    int n; R(n);
    FOR(i,1,n)A[i]=1e9;
    FOR(i,1,n-1){
        int x;
        R(x);
        A[i]=min(A[i],x);
        A[i+1]=min(A[i+1],x);
    }
    int an=0;
    FOR(i,1,n)an+=A[i];
    W(an);
    return 0;
}


Measured memory_bytes: 256
/*
	Name: C-排好序的数组 
	Author: RoseKey 
	Date: 14/02/19 16:50
	Description: 模拟 
*/

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ')
using namespace std;
    
template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    
template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n;
LL a[1000005];
int k;
int ans;
bool flag1,flag2;
int flag=-1;

int main()
{
	read(n);
	for(RI i=1;i<=n;++i)
		read(a[i]);

	for(RI i=1;i<=n;++i)
	{
		if(flag==-1 && !flag1 && !flag2)
		{
			++ans;
			flag=a[i];
			continue;
		}
		if(flag!=-1 && !flag1 && !flag2)
		{
			if(flag==a[i]) 
				continue;
			if(flag>a[i]) 
				flag1=1;//不上升 
			else if(flag<a[i]) 
				flag2=1;//不下降 
			flag=a[i];
		}
		else if(flag1)//不上升
		{
			if(a[i]<=flag) 
				flag=a[i];
			else 
			{
				flag=-1;
				flag1=0;
				--i;
			}
		}
		else if(flag2)//不下降
		{
			if(a[i]>=flag) 
				flag=a[i];
			else 
			{
				flag=-1;
				flag2=0;
				--i;
			}
		} 
	}
	print(ans);	
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var KS = Sarray();
            var K = KS[0];
            var S = KS[1];
            var ans = 0L;
            for (var i = 0L; i <= K; ++i)//X
            {
                if (i + 2 * K < S)
                {
                    i += S - 2 * K - 1;
                    continue;
                }
                for (var j = 0L; j <= K; ++j)//Y
                {
                    var Z = S - (i + j);
                    if (Z < 0) 
                        break;
                    if (K < Z)
                    {
                        j += Z - K - 1;
                        continue;
                    }
                    ans += Min(Z, K - j) + 1;
                    break;
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
using System;//外
using System.Linq;//Linq
public class ABC{

    public static void Main(){
        var line = Console.ReadLine();
        var l = line.Split(' ').Select(s => int.Parse(s)).ToArray();//.Split(' ').Select(s => ).ToArray
        int n = l[0];
        int d = l[1];
        int ans = n/(2*d+1);
        if (n%(2*d+1)>0){
            ans++;
        }
        Console.WriteLine(ans);
        }
       
    }



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

using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
program V1501;
 type
  w=array[0..100001] of int64;
 var
  a,b,c,d,e,f:w;
  i,n,p:longint;
 procedure haha(var a:w;l,r:longint);
  var
   o,p,m,t:longint;
  begin
   o:=l;
   p:=r;
   m:=a[(l+r) div 2];
   repeat
    while a[o]<m do inc(o);
    while a[p]>m do dec(p);
    if o<=p then
     begin
      t:=a[o];
      a[o]:=a[p];
      a[p]:=t;
      inc(o);
      dec(p);
     end;
   until o>p;
   if o<r then haha(a,o,r);
   if l<p then haha(a,l,p);
  end;
 begin
  readln(n);
  for i:=1 to n do
   read(a[i]);
  readln;
  a[n+1]:=1008208820;
  haha(a,1,n+1);
  for i:=1 to n do
   read(b[i]);
  readln;
  b[n+1]:=1008208820;
  haha(b,1,n+1);
  for i:=1 to n do
   read(c[i]);
  readln;
  c[n+1]:=1008208820;
  haha(c,1,n+1);
  for i:=1 to n+1 do
   f[i]:=n-i+1;
  p:=1;
  for i:=1 to n do
   begin
    while c[p]<=b[i] do inc(p);
    e[i]:=f[p];
   end;
  e[n+1]:=0;
  for i:=n downto 1 do
   inc(e[i],e[i+1]);
  p:=1;
  for i:=1 to n do
   begin
    while b[p]<=a[i] do inc(p);
    d[i]:=e[p];
   end;
  d[n+1]:=0;
  for i:=n downto 1 do
   inc(d[i],d[i+1]);
  writeln(d[1]);
 end.


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<tuple>
#include<queue>
#define LL long long
#define TT std::tuple<LL,LL,LL>
#define PP std::pair<LL,LL>
std::string S;
int main() {
	int ans = 700;
	std::cin >> S;
	if (S[0] == 'o')ans += 100;
	if (S[1] == 'o')ans += 100;
	if (S[2] == 'o')ans += 100;
	std::cout << ans << std::endl;
	return 0;
}

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

int main () {
    int n;
    bool flag = false;
    cin >> n;
    for (int i=1; i<10; i++) {
        for (int j=1; j<10; j++) {
            if (i*j==n) {
                flag = true;
                break;
            }
        if (flag==true) {
            break;
        }
        }
    }
    if (flag==true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256