akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/















int s[200005],t[200005],c[100005];
int res[200005],tmp[200005];
int main(){
     ll n;
     cin>>n;
     ll cnt=n/50;
     ll rem=n%50;
     cout<<50<<"\n";
     for(int i=0;i<50;i++){
          if(i<rem){
               cout<<(i+cnt+50-rem+1);
          }
          else cout<<(i+cnt-rem);
          cout<<" ";
     }

}



















































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


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}


int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    cout << n%2 + n/2;

    return 0;
}


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

using namespace std;

const int P = 998244353;

long long power(long long x, long long t) {
	long long ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

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

	long long inv = power(2, P - 2);

	vector<vector<long long> > dp(c + 1, vector<long long> (d + 1));
	dp[a][b] = 1;
	for(int i = b; i < d; ++i) {
		dp[a][i + 1] = dp[a][i] * a % P;
	}
	for(int i = a; i < c; ++i) {
		dp[i + 1][b] = dp[i][b] * b % P;
	}
	for(int i = a + 1; i <= c; ++i) {
		for(int j = b + 1; j <= d; ++j) {
			dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i * j + 1 - i - j) % P + P) % P;
		}
	}

	cout << dp[c][d] << '\n';

	return 0;
}

Measured memory_bytes: 73564
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <functional>
#include <utility>
using namespace std;

using cnt = map<int, int>; // Counter
using pii = pair<int, int>;

#define ft first
#define sd second

int n;
int a[100005];

cnt e, o;

struct second_order {
  bool operator()(const pii& x, const pii& y) const {
    return x.sd < y.sd;
  }
};

priority_queue<pii, vector<pii>, second_order> que_e, que_o; // sort

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

    for(int i=0;i<n;++i) {
        if(i%2==0)e[a[i]]++;
        else o[a[i]]++;
    }

    for(auto v : e) que_e.push(v);
    for(auto v : o) que_o.push(v);

    pii me = que_e.top(), mo = que_o.top();
    if(me.ft != mo.ft) cout<<(n - me.sd - mo.sd)<<endl;
	else {
		que_e.pop();que_o.pop();
		pii se = que_e.top(), so = que_o.top();
		int t1 = n - se.sd - mo.sd, t2 = n - me.sd - so.sd;
		if(que_o.empty()) {
			cout<<n/2<<endl;
		}else if(t1<t2)cout<<t1<<endl;
		else cout<<t2<<endl;
	}
	
	return 0;
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int h[n];
	int sum = 0;
	rep(i,0,n){
		cin >> h[i];
		if(k<=h[i]) sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int x,y,min,max,p;
    for(p=0;;p++)
    {
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)
            break;
    min=(x<y)?x:y;
    max=(x>y)?x:y;
    printf("%d %d\n",min,max);
    }

    return 0;
}



Measured memory_bytes: 1932
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main(){
  int n,k;
  vector<long long> h;
  long long box,min = 1000000000;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> box;
    h.push_back(box);
  }
  sort(h.begin(),h.end());
  for(int i = 0; i <= h.size() -k; i++){
    if(h[i+k-1]-h[i] < min)
      min = h[i+k-1]-h[i];
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n; cin >> n;
    vector<vector<int> > adj(n); // 隣接リスト表現
    vector<pair<int,int>> vp;
    rep(i, n-1) {
        int a,b; cin >> a >> b;
        a--; b--;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
        vp.emplace_back(a,b);
    }
    int k = 0;
    map<pair<int,int>, int> m; // (edge, color)

    vector<int> cs(n, 0); //親と接続してる辺の色
    vector<int> used(n, 0); //探索済みかどうか

    queue<int> q;
    q.push(0);
    used[0] = 1;
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        if (k < (int)adj[v].size()) {
            k = adj[v].size();
        }
        int c = 1;
        for(int u: adj[v]) {
            if(used[u])
                continue;
            if(c == cs[v]){
                c++;
            }
            // cout << "(v,u) =(" << v << "," << u << ") -> c =" << c << endl;
            cs[u] = m[make_pair(u,v)] = m[make_pair(v,u)] = c;
            c++;
            used[u] = 1;
            q.push(u);
        }
    }
    cout << k << endl;
    for(auto p:vp) cout << m[p] << endl;
    return 0;
}


Measured memory_bytes: 20084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n);
  vector<ll> visited(n,-1);
  rep(i,n){
    cin >> t1;
    t1--;
    vec[i] = t1;
  }
  visited[0] = 0;
  ll piv = 0;
  ll t = 0;
  while(k > 0){
    piv = vec[piv];
    t++;
    if(visited[piv] != -1){
      t1 = t - visited[piv];
      t2 = k / t1;
      k -= t1 * t2;
      if(k == 0){
        k += t1;
      }
    }
    visited[piv] = t;
    k--;
  }
  cout << piv + 1 << endl;
}

Measured memory_bytes: 6428
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int N, W;
  cin >> N >> W;
  int V = pow(10, 5) + 1;
  vector<vector<int>> dp(N + 1, vector<int>(V + 1, INF<int>));
  dp[0][0] = 0;
  REP(i, N) {
    int w, v;
    cin >> w >> v;
    REP(j, V) {
      if (j - v >= 0) {
        chmin(dp[i + 1][j], dp[i][j - v] + w);
      }
      chmin(dp[i + 1][j], dp[i][j]);
    }
  }
  int ans = 0;
  REP(i, V) {
    if (dp[N][i] <= W) {
      chmax(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 40192
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

const int mod=1000000007;
string A,B,C;
ll memo[50][2];

ll DFS(int dig,int carry){
	if(dig==-1) return carry==0;
	
	ll &res=memo[dig][carry];
	if(res!=-1) return res;
	res=0;
	REP(a,0,10) REP(b,0,10){
		if(A[dig]!='?'&&A[dig]!='0'+a) continue;
		if(B[dig]!='?'&&B[dig]!='0'+b) continue;
		if(dig==0&&(a==0||b==0)) continue;

		int c=(a+b+carry)%10,d=(a+b+carry)/10;
		if(C[dig]!='?'&&C[dig]!='0'+c) continue;

		res+=DFS(dig-1,d);
		res%=mod;
	}
	
	return res;
}

void Solve(){
	while(true){
		cin >> A; if(A[0]=='0') break;
		cin >> B >> C;

		fill_n((ll*)memo,50*2,-1);
		cout << DFS(A.size()-1,0) << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char A[M][L];
int getChar(char a){
  if(a == 'A') return 1;
  else if(a == 'C') return 2;
  else if(a == 'G') return 3;
  else if(a == 'T') return 4;
  return 0;
}
long long gK(char x[]){
  long long sum = 0, p = 1, i;
  for(i = 0; i < strlen(x); i++ ){
    sum += p*(getChar(x[i]));
    p *= 5;
  }
  return sum;
} 
int h1(int x){ 
  return x % M;
}
int h2(int x){ 
  return 1 + (x % (M - 1));
}
  
int f(char x[]){   
  long long key, i, h;   
  key = gK(x);   
  for ( i = 0;; i++){       
    h = (h1(key) + i * h2(key)) % M;     
    if( strcmp(A[h],x) == 0 )
      return 1;  
    else if(strlen(A[h]) == 0)
      return 0;
  }
  return 0; 
}
  
int insert(char x[]){
   
  long long key, i, h;   
  key = gK(x);   
  for ( i = 0; ; i++ ){     
    h = (h1(key) + i * h2(key)) % M;    
    if( strcmp(A[h],x) == 0 )
      return 1;
    else if(strlen(A[h]) == 0){
      strcpy(A[h],x);
      return 0;
    }
  }
  return 0;
}
  
int main(){
    int i, n, h;
    char x[L], com[9];
    for(i = 0; i < M; i++ ) A[i][0] = '\0';
      
    scanf("%d", &n);
      
    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, x);
      
    if(com[0] == 'i' ){
        insert(x);
    } else {
        if(f(x)==1){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }
    return 0;
}

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

int main(){
string S,T;
  cin>>S>>T;
  
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());

  if(S<T){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 384
//C99 or C++98
#include <stdio.h>
int A[100][100],B[20][100][100];
int main(){
	const int INF=1<<29;
	int n,m,c,s,g;
	for(;scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n;){
		//?????¢??????????????????
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			A[i][j]=INF;
			for(int k=0;k<c;k++)B[k][i][j]=INF;
		}
		//?????????????????¨????§??????????????????¢????±???????
		for(int i=0;i<m;i++){
			int x,y,d,c;
			scanf("%d%d%d%d",&x,&y,&d,&c);
			x--,y--,c--;
			if(B[c][x][y]>d)B[c][x][y]=d;
			if(B[c][y][x]>d)B[c][y][x]=d;
		}
		int p[c];
		for(int x=0;x<c;x++){
			scanf("%d",&p[x]);
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
				if(B[x][i][j]>B[x][i][k]+B[x][k][j]){
					B[x][i][j]=B[x][i][k]+B[x][k][j];
				}
			}
		}
		//??¨???????????¢????§???????????????????????????????
		for(int k=0;k<c;k++){
			int x=p[k],q[x],r[x];
			q[0]=0;
			for(int i=1;i<x;i++)scanf("%d",&q[i]);
			for(int i=0;i<x;i++)scanf("%d",&r[i]);
			for(int i=0;i<n;i++)for(int j=0;j<i;j++)if(B[k][i][j]<INF){
				int y=x-1;
				for(;B[k][i][j]<q[y];y--);
				int v=r[y]*(B[k][i][j]-q[y]);
				for(y--;y>=0;y--)v+=r[y]*(q[y+1]-q[y]);
				if(A[i][j]>v)A[i][j]=A[j][i]=v;
			}
		}
		//?§??????????????????????????±???????
		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			if(A[i][j]>A[i][k]+A[k][j]){
				A[i][j]=A[i][k]+A[k][j];
			}
		}
		printf("%d\n",A[s-1][g-1]>=INF ? -1 : A[s-1][g-1]);
	}
	return 0;
}

Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;   //m[3]=5;
vector<int> v;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		int x;
		cin>>x;
		if(m[x]==0)v.push_back(x);
			//m.count(x)==0
		++m[x];
	}
	int ans=0;
	for(int i=0;i<v.size();++i){
		if(v[i]>m[v[i]])ans+=m[v[i]];
		else if(v[i]<m[v[i]])
			ans+=m[v[i]]-v[i];
	}
		
	cout<<ans<<"\n";
	return 0; 
}

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

int n;
vector<int> p;

signed main(){
  
  cin>>n;

  p.push_back(0);
  
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    p.push_back(a);
  }
  
  p.push_back(0);
  
  int sum = 0;
  
  for(int i=1;i<p.size();i++) sum += abs( p[i] - p[i-1] );

  for(int i=1;i<(int)p.size()-1;i++){
    int a = abs( p[i] - p[i-1] );
    int b = abs( p[i+1] - p[i] );
    int c = abs( p[i+1] - p[i-1] );
    cout<<sum - a - b + c<<endl;
  }

  return 0;
}


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

int main(){
  int n; 
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  int dif = a[n-1] - a[0];
  cout << dif << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long n;
	cin>>n;
	long long ans=0;
	long long a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i!=j)
			ans+=a[i]*a[j];
		}
	}
	ans/=2;
	cout<<ans<<endl;
}

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

int main(){
  int N;
  int A[3][3];
  vector<bool> C(9,false);
  for(int j=0;j<3;j++){
    for(int i=0;i<3;i++){
      cin>>A[j][i];
    }
  }
  cin>>N;
  int B[N];
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A[j][k]==B[i]){
          C[j+k*3]=true;
        }
      }
    }
  }
  if(C[0]==true && C[1]==true && C[2]==true) cout<<"Yes"<<endl;
  else if(C[3]==true && C[4]==true && C[5]==true) cout<<"Yes"<<endl;
  else if(C[6]==true && C[7]==true && C[8]==true) cout<<"Yes"<<endl;
  else if(C[0]==true && C[3]==true && C[6]==true) cout<<"Yes"<<endl;
  else if(C[1]==true && C[4]==true && C[7]==true) cout<<"Yes"<<endl;
  else if(C[2]==true && C[5]==true && C[8]==true) cout<<"Yes"<<endl;
  else if(C[0]==true && C[4]==true && C[8]==true) cout<<"Yes"<<endl;
  else if(C[2]==true && C[4]==true && C[6]==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, y, z;
	int a, b;
	scanf("%d",&x);
	y = x / 500;
	z = x % 500;
	a = z / 5;
	b = (1000*y) + (5*a);
	printf("%d", b);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    int n = h * w;
    int t = n - 1;

    char c[50 * 50 + 1];
    for (int i = 0; i < h; i++) {
        cin >> c + w * i;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r += c[i] == '.';
    }

    vector<int> v(n, -1);
    v[0] = 0;

    vector<int> q[2];
    q[0].push_back(0);

    for (int k = 1; !q[0].empty(); k++) {
        for (auto& i : q[0]) {
            for (int d : { -w, -1, 1, w }) {
                int j = i + d;
                if (j < 0 || j >= n || (abs(d) <= 1 && j / w != i / w)) continue;
                if (c[j] == '.' && v[j] < 0) {
                    v[j] = k;
                    if (j == t) goto break3;
                    q[1].push_back(j);
                }
            }
        }
        q[0].clear();
        swap(q[0], q[1]);
    }
break3:

    if (v[t] < 0) {
        cout << -1 << endl;
    } else {
        cout << r - (v[t] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    c = input()
    if c.upper() == c:
        print("A")
    else:
        print("a")

    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 9012
#include <stdio.h>
int main(){
  char s0 = getchar();
  char s1 = getchar();
  if (s0 != s1) {
    puts("Yes");
    return 0;
  }
  char s2 = getchar();
  if (s0 != s2) {
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
   int s=0,a,n;
   scanf("%d",&n);

   a=n;
   while(a>0){
     s+= a%10;
     a = a/10;
   }
   if(n%s ==0)
     printf("Yes\n");
   else
     printf("No\n");
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b;
  cin >> a >> b;
  int n = a.length(), ans = 0;
  for (int i=0;i<n;i++) {
    if (a[i]!=b[i]) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3892
import numpy as np

n = int(input())
len_box = []
for _ in input().split():
    len_box.append(int(_))
len_box = np.array(len_box)
len_max = np.max(len_box)
len_sum = np.sum(len_box)
if (len_sum-len_max) > len_max:
    print("Yes")
else:
    print("No")

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

vector <int> dp(100005);

int main()
{
	int n,k;
	cin>>n>>k;
	vector <int> arr(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<=n;i++)
	{
		int j=1;
		int ans=INT_MAX;
		while((i-j)>0 && j<=k)
		{
			if( (abs(arr[i]-arr[i-j])+dp[i-j]) < ans)ans=(abs(arr[i]-arr[i-j])+dp[i-j]);
			j++;
        }
        dp[i]=ans;
	}
	
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 4056
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b;
  int c[4] = {0, 1, 2, 3};
  bool con[4][4] = {};

  for(int i=0;i<3;i++){
    scanf("%d%d", &a, &b);
    a--; b--;
    con[a][b] = con[b][a] = true;
  }

  do{
    bool ok = true;

    for(int i=0;i<3;i++)
      ok &= con[c[i]][c[i+1]];

    if (ok) {
      puts("YES");
      return 0;
    }

  }while(next_permutation(c, c+4));

  puts("NO");

  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる
#define _abs(x) ((x)<0 ? -(x) : (x))
#define _MAX 100000
#pragma endregion

// ABC053 B - A to Z String 
static char s[200001];
int main(void) {
	int i, j, l;

	scanf("%s", s);
	l = strlen(s);

	for (i = 0; i < l; i++)
		if (s[i] == 'A') break;
	for (j = l - 1; j >= 0; j--)
		if (s[j] == 'Z') break;
	
	printf("%d\n",j-i+1);
	return 0;
}


Measured memory_bytes: 1876
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION cout<<fixed; cout<<setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 1e5+10;
const ll bits = 30;
const ll mod = 1e9+7;

ll dp[N][2]; // 1 black , 0 white
vector<ll> adj[N];

void dfs(int node,int par){

    dp[node][0]=dp[node][1]=1;

    for(auto nxt: adj[node]){
        if(nxt!=par){
            dfs(nxt,node);
        }
    }

    for(auto nxt: adj[node]){
        if(nxt!=par){
            dp[node][0]*=(dp[nxt][1]+dp[nxt][0]);
            dp[node][0]%=mod;
            dp[node][1]*=dp[nxt][0];
            dp[node][1]%=mod;
        }
        
    }
}



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

    int u,v;

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

    dfs(1,0);

    cout<<(dp[1][0]+dp[1][1])%mod;

}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
 int r,g,b;
cin>>r>>g>>b;
 int k;
 cin>>k;
 while(g<=r&&k>0){
	g*=2;
	k--;
 }
 while(b<=g&&k>0){
   b*=2;
   k--;
 } 
 if(b>g&&g>r)cout<<"Yes\n";
 else cout<<"No\n";
}


Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long temp;
	if(b-1<=c) temp=b-1;
	else temp=c;
	long long ans;
	ans=(long long)((double)a*temp/b)-a*(long long)((double)temp/b);
	cout<<ans;
	return 0;
}

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

two = 0
four = 0
one = 0
for i in a:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1
    else:
        one += 1

print("Yes" if four + 1 >= one + two % 2 else "No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e6 + 10;
const ll mod = 998244353;

ll qpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int N, n;
int cnt[MAX];

int vis[MAX], prime[MAX], num, mu[MAX];
int f[MAX], g[MAX];
void makeMobius(int siz) {
    mu[1] = 1, num = 0;
    for (int i = 2; i <= siz; i++) {
        if (!vis[i]) prime[++num] = i, mu[i] = -1;
        for (int j = 1; j <= num && i * prime[j] <= siz; j++) {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                mu[i * prime[j]] = 0;
                break;
            }
            mu[i * prime[j]] = mu[i] * mu[prime[j]];
        }
    }
    for (int t = 1; t <= n; t++)
        for (int i = t; i <= n; i += t) {
            f[i] = (f[i] + 1ll * t * mu[t] % mod) % mod;
            g[i] = (g[i] + 1ll * t * cnt[t] % mod) % mod;
        }
}

ll calc(int T) {
    int k = n / T, res = 0;
    for (int i = 1; i <= k; i++)
        res = (res + 1ll * i * cnt[i * T] % mod) % mod;
    return 1ll * res * res % mod;
}

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        int x; scanf("%d", &x);
        cnt[x]++; n = max(n, x);
    }
    makeMobius(n);
    ll ans = 0;
    for (int T = 1; T <= n; T++) {
        ans = (ans + 1ll * calc(T) * f[T] % mod * T % mod) % mod;
        ans = (ans - 1ll * T * cnt[T] % mod + mod) % mod;
    }
    ans = ans * qpow(2ll, mod - 2);
    printf("%lld\n", (ans + mod) % mod);

    return 0;
}

Measured memory_bytes: 21632
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  const char tbl[] = { '0','1','2','3','5','7','8','9' };
  for(;;){
    long long n;
    cin >> n;
    if(n==0) break;
    char buf[20];
    sprintf(buf,"%o",n);
    for(int i=0; i<20; i++){
      if(buf[i] == '\0') break;
      buf[i] = tbl[buf[i] - '0'];
    }
    cout << buf << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const s = input[0];
  const t = input[1];

  let ret = 0;
  if(s[0] === t[0]) ret++;
  if(s[1] === t[1]) ret++;
  if(s[2] === t[2]) ret++;
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

int main() {
    bool flag=false;
    int X,Y;
    cin >> X >> Y;

    rep01(i,100){
        rep01(j,100){
            if(i+j==X && 2*i+4*j==Y){
                flag=true;
                break;
            }
        }
    }

    if(flag){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    

}

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

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

static const int MAX_N = 1e5+7;
static const int INF = 1e9+7;

int N;
int h[MAX_N];
int dp[MAX_N];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

  fill(dp, dp+MAX_N, INF);
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, x := ReadInt(), ReadInt()
	a := ReadInts(N)
	sort.Ints(a)

	ans := 0
	for i := 0; i < N-1; i++ {
		if x >= a[i] {
			ans++
			x -= a[i]
		}
	}
	if x == a[N-1] {
		ans++
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <climits>

using namespace std;

struct Node {
    int to;
    int weight;

    Node(int _to, int _weight) {
        to = _to;
        weight = _weight;
    }
};

vector<Node> adj[101];
int v;
int dis[101][101];

void floyd() {
    for (int k = 0; k < v; ++k) {
        for (int i = 0; i < v; ++i) {
            if (dis[i][k] == INT_MAX) {
                continue;
            }
            for (int j = 0; j < v; ++j) {
                if (dis[k][j] == INT_MAX) {
                    continue;
                }
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
}

int main() {
    int e;
    cin >> v >> e;
    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            dis[i][j] = i == j ? 0 : INT_MAX;
        }
    }

    for (int i = 0; i < e; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        adj[s].emplace_back(t, d);
        dis[s][t] = d;
    }

    floyd();
    for (int i = 0; i < v; ++i) {
        if (dis[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            if (j > 0) {
                cout << " ";
            }
            if (dis[i][j] == INT_MAX) {
                cout << "INF";
            } else {
                cout << dis[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3236
N = int(input())
flag = False
count = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        count += 1
    else :
        count = 0
    if count == 3:
        flag = True

if flag :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 9164
#include <iostream>
#include <stack>

using namespace std;

struct set { int i, sum, k; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k) {
    stack<set> S;
    S.push(set{i, sum, k});

    while (!S.empty()) {
        set u = S.top();
        if (u.k == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.k == 0 && u.sum == 0) { break; }

        if (u.i < 10 && u.k < n) {
            S.push(set{u.i + 1, u.sum, u.k});
            S.push(set{u.i + 1, u.sum + a[u.i], u.k + 1});
        }
        else if (u.i == 10) {
            int tmp = u.k;
            while (S.top().k == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

int main() {
    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

const bool INCREASE = false;
const bool DECREASE = true;
template< typename T >
struct PrioritySumStructure
{
 
  bool order;
  Int k, sz;
  T sum;
  set< pair< T, Int > > add, pend;
  map< Int, T > adding, pending;
 
  PrioritySumStructure(Int k, bool order = INCREASE) : k(k), sum(0), sz(0), order(order) {}
 
  void Sweep()
  {
    while(sz < k && !pend.empty()) {
      auto p = order ? --pend.end() : pend.begin();
      sum += p->first;
      ++sz;
      add.emplace(*p);
      adding.emplace(p->second, p->first);
      pending.erase(p->second);
      pend.erase(p);
    }
    while(sz > k) {
      auto p = order ? add.begin() : --add.end();
      sum -= p->first;
      --sz;
      pend.emplace(*p);
      pending.emplace(p->second, p->first);
      adding.erase(p->second);
      add.erase(p);
    }
  }
 
  T getSum()
  {
    if(sz < k) throw ("get Sum Exception");
    return (sum);
  }
 
  void addElement(Int k, T x)
  {
    if(adding.count(k) || pending.count(k)) {
      throw ("Add Element Exception");
    }
    ++sz;
    add.emplace(x, k);
    adding[k] = x;
    sum += x;
    Sweep();
  }
 
  void deleteElement(Int k)
  {
    if(pending.count(k)) {
      pend.erase({pending[k], k});
      pending.erase(k);
    } else if(adding.count(k)) {
      --sz;
      sum -= adding[k];
      add.erase({adding[k], k});
      adding.erase(k);
      Sweep();
    } else {
      throw ("delete Element Exception");
    }
  }
 
  void incrementSize()
  {
    ++k;
    Sweep();
  }
 
  void decrementSize()
  {
    if(k == 0) throw ("decrement Size Exception");
    --k;
    Sweep();
  }
};
//INSERT ABOVE HERE
signed main(){
  Int n,x;
  cin>>n>>x;
  vector<Int> bs(n),ls(n),us(n);
  for(Int i=0;i<n;i++) cin>>bs[i]>>ls[i]>>us[i];

  Int sum=0;
  for(Int i=0;i<n;i++) sum+=bs[i]*ls[i];
  if(sum==0){
    cout<<0<<endl;
    return 0;
  }
  
  vector<Int> vs;
  for(Int i=0;i<n;i++)
    vs.emplace_back(ls[i]*bs[i]+us[i]*(x-bs[i]));
  sort(vs.rbegin(),vs.rend());

  Int len=0,res=0;
  while(res<sum) res+=vs[len++];  
  assert(0<len&&len<=n);
  
  PrioritySumStructure<Int> ps(len-1,DECREASE);
  for(Int i=0;i<n;i++)
    ps.addElement(i,ls[i]*bs[i]+us[i]*(x-bs[i]));

  Int ans=len*x;
  for(Int i=0;i<n;i++){    
    ps.deleteElement(i);
    Int dif=sum-ps.getSum();
    assert(dif>=0);
    if(ls[i]*bs[i]>=dif){
      Int uku=(dif+ls[i]-1)/ls[i];      
      chmin(ans,(len-1)*x+uku);
    }else{      
      Int uku=(dif-ls[i]*bs[i]+us[i]-1)/us[i];      
      chmin(ans,(len-1)*x+bs[i]+uku);
    }
    ps.addElement(i,ls[i]*bs[i]+us[i]*(x-bs[i]));        
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15860
#include <stdio.h>

int main(void)
{
	int N;
	int i;

	scanf("%d",&N);
	
	int A[N];
	int B[N-1];
	for(i=0;i<N-1;i++){
		scanf("%d",&B[i]);
	}

	A[0]=B[0];
	A[N-1]=B[N-2];	
	for(i=0;i<N-2;i++){
		if(B[i]<B[i+1]){
			A[i+1]=B[i];
		}else{
			A[i+1]=B[i+1];
		}
	}
	int cnt=0;
	for(i=0;i<N;i++){
		cnt+=A[i];
	}
	printf("%d\n",cnt);

	return 0;
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int MOD = 1000000007;
const int INF = 1000000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MAX = 200101;
long long fac[MAX], finv[MAX], inv[MAX];

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

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


int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);
    // for file input
    /* ifstream in("input.txt");
    ifstream in("input.txt"); */

    COMinit();

    int n, k;
    cin >> n >> k;

    int red = n - k, blue = k;
    for (int i = 1; i <= k; ++i) {
        llong res = COM(red + 1, i) * COM(blue - 1, i - 1);
        res %= MOD;
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>
 
using namespace std;
 
typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789
 
 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////
 
////////////////////////////////////////////////
////////////////////////////////////////////////
 
int N;
int A[112345];
int jdg[112345];
int idx = 0;
int ans = 0;
 
int main(){
	
	cin>>N;
	fill( jdg, jdg+N, 0 );
	
	REP( i, N ) scanf("%d", A+i);
	
	REP( i, N ){
		if( jdg[idx] == 1 ){
			ans = -1;
			break;
		}
		jdg[idx] = 1;
		idx = A[idx]-1;
		ans++;
		if( idx == 1 ) break;
	}
	
	
	cout<<ans<<endl;
	
	return 0;
 
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    cin >> n;
    map<int,int> mp;
    int tmp;
    while(n--){
        cin>>tmp;
        mp[tmp-1]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x.second);
    }
    cout << result << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " --> " << (x) << endl
#define pb push_back
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
#define print(v)                       \
    for (auto x : v) cout << x << " "; \
    cout << endl

void solve() {
    int i, j, n, k = 1000;
    cin >> n;
    if (n % k == 0) {
        cout << 0 << endl;
        return;
    }
    int ans = (n / k + 1) * 1000 - n;
    cout << ans << endl;
}

//Fuck Ratings
//Once a Charas always a Charas

int32_t main() {

    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int _t = 1;
    // cin >> _t;
    while (_t--)
        solve();
}

Measured memory_bytes: 3620
/*input
5 2
1 4
2 5
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 100900
#define INF 0x3f3f3f3f

int n , m;
int cmp(PII x , PII y){
    return x.B < y.B;
}
PII x[MAX];
int32_t main(){
    IOS;
    cin >> n >> m;
    REP(i , 1 , m + 1) cin >> x[i].A >> x[i].B , x[i].A ++;
    sort(x + 1 , x + 1 + m , cmp);
    set<int> ans;
    REP(i , 1 , m + 1){
        auto tmp = ans.lower_bound(x[i].A);
        if(tmp == ans.end() || x[i].B < (*tmp)){
            // cout << x[i].B << endl;
            ans.insert(x[i].B);
        }
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

string s;

int main() {
  cin >> s;
  cout << s[0];
  cout << s.size() - 2;
  cout << s[s.size() - 1];
}


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

using namespace std;

const int MX = 5005;
const int MOD = 1000000007;

template<typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template<typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n;
int fst[MX], nxt[MX*2], v[MX*2], lnum;

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	read(n);
	for(int i=1; i<n; i++)
	{
		int a, b;
		read(a), read(b);
		addeg(a, b);
		addeg(b, a);
	}
}

int way[MX], g[MX][MX], ng[MX];
int siz[MX];

void dfs(int x, int f)
{
	siz[x] = 1;
	g[x][1] = 1;
	for(int i=fst[x]; i; i=nxt[i])
	{
		int y = v[i];
		if(y == f) continue;
		dfs(y, x);
		memset(ng, 0, sizeof(ng));
		for(int a=0; a<=siz[y]; a++)
			for(int b=0; b<=siz[x]; b++)
				ng[a+b] = (ng[a+b] + 1ll*g[y][a]*g[x][b]) % MOD;
		memmove(g[x], ng, sizeof(ng));
		siz[x] += siz[y];
	}
	for(int i=0; i<=siz[x]; i++) g[x][0] = (g[x][0] - 1ll*g[x][i]*way[i] + 1ll*MOD*MOD) % MOD;
}

void work()
{
	way[0] = 1;
	for(int i=2; i<=n; i++) way[i] = 1ll * way[i-2] * (i-1) % MOD;
	dfs(1, 0);
	printf("%d\n", (MOD-g[1][0]) % MOD);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 98560
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())


Measured memory_bytes: 9320
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
    public static void Main()
    {
        Console.WriteLine(Console.ReadLine().ToCharArray().Concat(new char[] {'0','1' }).GroupBy(c => c).Select(g => g.Count()).Min() * 2 - 2);
    }
}

Measured memory_bytes: 14560
#include<iostream>
#include<algorithm>
using namespace std;
int N;
string s[500];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>s[i];
	int ans=1e9;
	for(int i=0;i<N;i++)
	{
		bool exs=false;
		int A=0,B=0,C=0;
		for(int j=0;j<N;j++)exs|=s[j][i]=='#';
		if(!exs)
		{
			for(int j=0;j<N;j++)if(s[i][j]=='#')
			{
				C=1;
				break;
			}
			if(!C)continue;
		}
		for(int j=0;j<N;j++)
		{
			if(s[i][j]=='#')
			{
				for(int k=0;k<N;k++)if(s[k][j]=='.')
				{
					A++;
					break;
				}
			}
			else B++;
		}
		ans=min(ans,A+B*2+C);
	}
	cout<<(ans<1e9?ans:-1)<<endl;
}

Measured memory_bytes: 512