akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int k,s;
    int i,j,z=0,count=0;
    cin>>k>>s;
    for( i=0;i<=k;i++){
        for( j=0;j<=k;j++){
            z=s-i-j;
            if(i>=0 && j>=0 && z>=0 && z<=k)
            count+=1;
        }
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n)  for (int i = 0; i < (int)(n); i++)

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N+1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N+1, -1),michi(N+1,-1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
          if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            michi[nv]=v;
            que.push(nv);

        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    //for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
  cout << "Yes"<<endl;
  rep(v,N-1) cout <<michi[v+2]<<endl;
}


Measured memory_bytes: 10228
N = int(input())
a = [list(map(int,input().split())) for i in range(2)]
b = []
for i in range(0,N):
    s = 0
    v = 0
    for j in range(0,i+1):
        s += a[0][j]
    for j in range(i,N):
        v += a[1][j]
    b.append(s+v)
print(max(b))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define ll long long
#define mid ((l+r)>>1)
using namespace std;
const int maxn = 2e5 + 5;
int root[maxn],dep[maxn],f[maxn][20],n,q,cnt,lg[maxn];
struct node{int l,r,num; ll sum;}e[maxn*40];
struct ege{int to,w,col;};
vector<ege> g[maxn];
void update(int &x,int y,int l,int r,int pos,ll val){
    x = ++cnt;
    e[x] = e[y];
    e[x].num++;
    if(l == r){
        e[x].sum += val;
        return ;
    }
    if(pos<=mid) update(e[x].l,e[y].l,l,mid,pos,val);
    else update(e[x].r,e[y].r,mid+1,r,pos,val);
    e[x].sum = e[e[x].l].sum + e[e[x].r].sum;
}

ll qsum(int x,int y,int l,int r,int pos){
    if(l == r) return e[x].sum - e[y].sum;
    if(pos <= mid) return qsum(e[x].l,e[y].l,l,mid,pos);
    else return qsum(e[x].r,e[y].r,mid+1,r,pos);
}

ll qnum(int x,int y,int l,int r,int pos){
    if(l == r) return e[x].num - e[y].num;
    if(pos <= mid) return qnum(e[x].l,e[y].l,l,mid,pos);
    else return qnum(e[x].r,e[y].r,mid+1,r,pos);
}

void dfs(int u,int fa){
    dep[u] = dep[fa] + 1;
    f[u][0] = fa;
    for(int i=1;(1<<i)<=dep[u];i++)
        f[u][i] = f[f[u][i-1]][i-1];

    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].to;
        int w = g[u][i].w;
        int col = g[u][i].col;
        if(v == fa) continue;
        update(root[v],root[u],1,n,col,w);
        dfs(v,u);
    }
}

int LCA(int u,int v){
    if(dep[u] < dep[v]) swap(u,v);
    while(dep[u] > dep[v]) u = f[u][lg[dep[u] - dep[v]]];
    if(u == v) return u;
    int len = lg[dep[u]];
    for(int i=len;i>=0;i--){
        if(f[u][i] != f[v][i]){
            u = f[u][i];
            v = f[v][i];
        }
    }
    return f[u][0];
}
int main()
{
    lg[0] = -1;
    for(int i=1;i<maxn;i++) lg[i] = lg[i>>1] +1;
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n-1;i++){
        int u,v,w,col;
        scanf("%d %d %d %d",&u,&v,&col,&w);
        g[u].push_back({v,w,col});
        g[v].push_back({u,w,col});
    }
    dfs(1,0);

    while(q--){
        int x,y,u,v;
        scanf("%d %d %d %d",&x,&y,&u,&v);
        int lca = LCA(u,v);
        ll ans = e[root[u]].sum + e[root[v]].sum - (2*e[root[lca]].sum) - qsum(root[u],root[lca],1,n,x) - qsum(root[v],root[lca],1,n,x);
        ans += 1ll*(qnum(root[u],root[lca],1,n,x) + qnum(root[v],root[lca],1,n,x))*y;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 71552
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e6;
//------------------------------------------------------------
ll N,K;
void solve() {
  cin>>N>>K;

  vector<bool> bl(N,false);
  
  rep(i,0,K)
  {
    ll d; cin>>d;
    vector<ll> v(d);
    rep(j,0,d)
    {
      cin >> v[j];
      bl[v[j]-1]=true;
    }
  }

  ll count=0;
  rep(i,0,N) if(!bl[i]) ++count;

  print(count);

  return;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    int one=0,two=0,four=0;
    rep(i,n){
        int a;
        cin >> a;
        if(a%4 == 0) four++;
        else if(a%2 == 0) two++;
        else one++;
    }
    assert(one+two+four == n);

    bool flag;
    if(two){
        if(one > four) flag = false;
        else flag = true;
    }else{
        if(one - four > 1) flag = false;
        else flag = true;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n;
    cin >> n;
    bool f[n+1][11];
    int p[n+1][11];

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 10; j++) f[i][j] = false;
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 10; j++){
            int _f;
            cin >> _f;
            if(_f == 1) f[i][j] = true;
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 10; j++) cin >> p[i][j];
    }

    ll ans = LLONG_MIN;
    for(int bit = 1; bit < (1 << 10); bit++){
        ll subAns = 0ll;
        vector<int> c(n+1, 0);
        for(int i = 1; i <= 10; i++) {
            if(bit & (1 << (i-1))) {
                for(int j = 1; j <= n; j++){
                    if(f[j][i]) c[j]++;
                }
            }
        }
        for(int i = 1; i <= n; i++) subAns += (ll)p[i][c[i]];
        ans = max(ans, subAns);
    }
    cout << ans << "\n";
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,sum;
ll num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005];

int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	num = 1;
	sum = 0;
	for(i=0;i<n;i++){
		sum += x[i];
		if(sum * num <= 0){
			a += abs(sum) + 1;
			sum = num;
		}
		//pe(a);
		num *= -1;
	}
	//el;
	num = -1;
	sum = 0;
	for(i=0;i<n;i++){
		sum += x[i];
		if(sum * num <= 0){
			b += abs(sum) + 1;
			sum = num;
		}
		//pe(b);
		num *= -1;
	}
	//el;
	p(min(a,b));
    return 0;
}


Measured memory_bytes: 27648
#include <iostream>
using namespace std;
bool pernah[100];;
int catat[100],n,p;
void cetak(int kedalaman){
	if(kedalaman>n){
		for(int i =1;i<=n;i++){
			cout<<catat[i];
			if(i<n)cout<<" ";
		}
		cout<<endl;
		return;
	}
	else{
		for(int i=1;i<=n;i++){
			if(pernah[i]==false){
				pernah[i]=true;
				catat[kedalaman]=i;
				cetak(kedalaman+1);
				pernah[i]=false;
			}
		}
	}
}
int main(){
	cin>>n;
	cetak(1);
}



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

int main(){
    int N;
    cin >> N;
    string A[N];
    set <string> values;
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    for (int i=0; i<N-1; i++){
        if (A[i].at(A[i].length()-1)!=A[i+1].at(0)){
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i=0; i<N; i++){
        values.insert(A[i]);
    }
    if (values.size()!=N) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define gcakioi
using namespace std;
string a[101];int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
using System;

namespace A___HonestOrDishonest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = input[0];
            var b = input[1];
            if(a=="H"&&b=="H"||a=="D"&&b=="D")
            {
                Console.WriteLine("H");
            }
            else
            {
                Console.WriteLine("D");
            }
        }
    }
}

Measured memory_bytes: 9044
#include<string>
#include<algorithm>
#include<iostream>
#include<memory.h>
#include<cmath>
#define f(i,j,n) for(i=j;i<=n;i++)
using namespace std;
int x,y;
int main(){
    cin>>x>>y;
    if(x>0)cout<<"Positive";
		else if(x==0||(x<0&&y>0))cout<<"Zero";
			else if((abs(y)-abs(x))%2!=0)cout<<"Positive";
				else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll r, d, x;
    cin >> r >> d >> x;
    for(int i = 2001; i <= 2010; i++) {
        x = r * x - d;
        printf("%lld\n", x); 
    }
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

int main(int argc, char const* argv[])
{
	uint64_t N{};
	std::vector<uint64_t> v{};
	uint64_t sum{};
	std::cin >> N;
	std::copy(std::istream_iterator<uint64_t> (std::cin),
			  std::istream_iterator<uint64_t>(),
			  std::back_inserter(v));
	v.resize(N+1,0);
	for (uint64_t i = 0; i < N; i++) {
		auto& current = v.at(i);
		auto& next   = v.at(i+1);
		sum += current / 2;
		if (current % 2 != 0 && next >= 1) {
			next--;
			sum++;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 1400
n = int(input())

X = [int(x) for x in range(1,n+1,2)]

ans = 0
for x in X:
    a = 0
    for i in range(1,n+1):
        if x % i == 0:
            a += 1
    if a == 8 :
        ans += 1 
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
int fact(int a){
    if(a<=1) return 1;
    return a*fact(a-1);
}
void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    int n;
    cin>>n;
    vector<int> n1(n);
    vector<int> n2(n);
    int l1=0,l2=0;
    int lg=0;
    rep(i,0,n) cin>>n1[i];
    rep(i,0,n) cin>>n2[i];
    rep(i,0,n){
        //cout<<l1<<endl;
        lg = 0;
        rep(j,i+1,n) if(n1[i]>n1[j]) lg++;
        l1+=(lg)*fact(n-1-i);
    }
    rep(i,0,n){
        lg = 0;
        rep(j,i+1,n) if(n2[i]>n2[j]) lg++;
        l2+=(lg)*fact(n-1-i);
    }
    cout<<abs(l1-l2)<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b, c) make_pair(make_pair(a, b), c)

int H, W;
char S[20][20];
bool visited[20][20];

int len(int hh, int ww) {
	int ret = 0;
	queue<pair<pair<int, int>, int>> q;

	rep(i, H) rep(j, W) visited[i][j] = false;

	q.push(p(hh, ww, 0));
	visited[hh][ww] = true;

	while (!q.empty()) {
		pair<pair<int, int>, int> item = q.front(); q.pop();
		int h = item.first.first;
		int w = item.first.second;
		int c = item.second;

		ret = max(ret, c);
		
		if (h - 1 >= 0 && !visited[h - 1][w] && S[h - 1][w] != '#') {
			q.push(p(h - 1, w, c + 1));
			visited[h - 1][w] = true;
		}
		if (h + 1 < H && !visited[h + 1][w] && S[h + 1][w] != '#') {
			q.push(p(h + 1, w, c + 1));
			visited[h + 1][w] = true;
		}
		if (w - 1 >= 0 && !visited[h][w - 1] && S[h][w - 1] != '#') {
			q.push(p(h, w - 1, c + 1));
			visited[h][w - 1] = true;
		}
		if (w + 1 < W && !visited[h][w + 1] && S[h][w + 1] != '#') {
			q.push(p(h, w + 1, c + 1));
			visited[h][w + 1] = true;
		}
	}

	return ret;
}

int main()
{
	int ans = 0;

	cin >> H >> W;
	rep(i, H) rep(j, W) cin >> S[i][j];

	rep(i, H) rep(j, W) {
		if (S[i][j] != '#') ans = max(ans, len(i, j));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class WithIndex<T>
{
    public T Value;
    public int Index;
    public WithIndex(T value, int index)
    {
        this.Value = value;
        this.Index = index;
    }
}

static class Template
{
    public static int LineToInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static string[] LineToStrings()
    {
        return Console.ReadLine().Split();
    }

    public static int[] LineToInts()
    {
        return LineToStrings()
            .Select(s => int.Parse(s))
            .ToArray();
    }

    public static int[] LinesToInts(int n)
    {
        var value = new int[n];
        foreach (var i in Enumerable.Range(0, n))
        {
            value[i] = LineToInt();
        }
        return value;
    }


    public static int[,] LinesToIntTable(int lineCount, int columnCount)
    {
        var value = new int[lineCount, columnCount];
        foreach (var y in Enumerable.Range(0, lineCount))
        {
            var ints = LineToInts();
            foreach (var x in Enumerable.Range(0, columnCount))
            {
                value[y, x] = ints[x];
            }
        }
        return value;
    }

    public static IEnumerable<WithIndex<T>> WithIndex<T>(this IEnumerable<T> sequence)
    {
        int index = 0;
        foreach (var item in sequence)
        {
            yield return new WithIndex<T>(item, index);
            index++;
        }
    }

    static int digit(int n)
    {
        return (n == 0) ? 1 : ((int)Math.Log10(n) + 1);
    }

    static void Main(string[] args)
    {
        var n = LineToInt();
        var heights = LineToInts();
        var current = heights.Last();
        for (int i = n - 1; i >= 0; i--)
        {
            if (current < heights[i])
            {
                heights[i]--;
            }
            if (current < heights[i])
            {
                Console.WriteLine("No");
                return;
            }
            current = heights[i];
        }
        Console.WriteLine("Yes");
    }
}



Measured memory_bytes: 32348
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 200000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,head[MN+5],cnt=0,vis[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
vector<int> ans[2];
void dfs(int x,int v)
{
	vis[x]=1;ans[v].push_back(x);
	for(int i=head[x];i;i=e[i].next)
		if(!vis[e[i].to]) return dfs(e[i].to,v);	
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i) ins(read(),read());
	dfs(1,0);dfs(1,1);
	printf("%d\n",ans[0].size()+ans[1].size()-1);
	for(int i=ans[0].size()-1;~i;--i) printf("%d ",ans[0][i]);
	for(int i=1;i<ans[1].size();++i) printf("%d ",ans[1][i]); 
	return 0;
}

Measured memory_bytes: 7740
#include <iostream>
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
using ll = long long;
using namespace std;

int grundy(int a, int k) {
    while (a % k != 0) {
        ll delta = a / k + 1;
        if ((a - delta) / k != a / k) {
            a -= delta;
        } else {
            REP_R (i, 30) {  // binary search
                ll na = a - (delta << i);
                if (na >= 0 and na / k == a / k) {
                    a = na;
                }
            }
        }
    }
    return a / k;
}

int main() {
    int n; cin >> n;
    int g = 0;
    while (n --) {
        int a, k; cin >> a >> k;
        g ^= grundy(a, k);
    }
    cout << (g ? "Takahashi" : "Aoki") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String o = sc.next();
		String e = sc.next();
		
		// 計算
		String result = "";
		int n = o.length() + e.length();
		char[] c = new char[n];
		for(int i = 0; i < o.length(); i++){
		    c[i*2] = o.charAt(i);
		}
		for(int i = 0; i < e.length(); i++){
		    c[i*2+1] = e.charAt(i);
		}
		result = new String(c);
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 22604
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, dist[200010], a, b, c;
vector<pi> e[200010], em;
bool vis[200010];
unordered_set<int> inr[200010], m;

int main()
{
	while(~scanf("%d %d",&N,&M))
	{
		memset(vis, false, sizeof(vis));
		memset(dist, 63, sizeof(dist));
		Forn(i, 200005)
			e[i]=em, inr[i]=m;
		while(M--)
		{
			a=in(), b=in(), c=in();
			e[a].eb(mp(b, c));
			e[b].eb(mp(a, c));
		}
		priority_queue<pi> q;
		dist[1]=0;
		vis[1]=true;
		q.push(mp(0, 1));
		while(!q.empty())
		{
			int st=q.top().s, cost=-q.top().f;
			q.pop();
			vis[st]=true;
			if(cost>dist[st])
				continue;
			foreach(it, e[st])
			{
				int ed=it->f, c=it->s, d=dist[st]+(!inr[st].count(c));
				if(vis[ed]||dist[ed]<d)
					continue;
				if(dist[ed]>d)
				{
					dist[ed]=d;
					q.push(mp(-d, ed));
					inr[ed].clear();
				}
				inr[ed].insert(c);
			}
		}
		if(dist[N]>INF)
			puts("-1");
		else
			printf("%d\n", dist[N]);
	}
	return 0;
}

Measured memory_bytes: 33268
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std; 
int main()
{
	char a; cin>>a;
	if(a=='A'){
		cout<<"T";
	}else if(a=='T'){
		cout<<"A";
	}else if(a=='C'){
		cout<<"G";
	}else if(a=='G'){
		cout<<"C";
	}
	return 0;
}

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

using namespace std;

int main(){
    ios:: sync_with_stdio(0);

    int n, abc[100005][3], dp[100005][3];
    cin >> n;

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

    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];

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

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n-1][2]) );
}


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

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  sort(A.rbegin(), A.rend());
  long long ans = 0;
  rep(i, N) ans += A[i / 2];
  cout << ans - A[0] << endl;
}


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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>
#define L 26

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

struct graph
{
    int n;
    vector<vector<pair<int, int>>> adj;
    graph(int n)
    {
        this -> n = n;
        adj.resize(n);
    }
    
    void add_edge(int u, int v, int w)
    {
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll total = 1, one = 1, two = 1;
    for(int i = 1; i <= n; i++)
        total = (total * 10) % R;
    for(int i = 1; i <= n; i++)
        one = (one * 9) % R;
    for(int i = 1; i <= n; i++)
        two = (two * 8) % R;
    cout << (total + (R - one) + (R - one) + two) % R << '\n';

    // cout << "        __.....__\n";
    // cout << "     .-'         '-.\n";
    // cout << "   .'               '.\n";
    // cout << "  /                   \\\n";
    // cout << " /        |\\           \\\n";
    // cout << ";        |V \\_          ;\n";
    // cout << "|        |  ' \\         ;\n";
    // cout << ";        )   ,_\\        |\n";
    // cout << ";       /    |          ;\n";
    // cout << " \\     /      \\         /\n";
    // cout << "  \\    |       \\       /\n";
    // cout << "   '.   \\       \\    .'\n";
    // cout << "     '-._|       \\.-'\n";
    // cout << "         | |\\     |    \n";
    // cout << "_________/ |_'.   /_______  \n";
    return 0;
    
}


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

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	int n=s.size();
	int o=0,x=0;
	for(int i=0;i<n;i++){
		if(s[i]=='o')o++;
		else x++;
	}
	if(x<=7){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

char a[4],b[4],c[4];


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

  cout<<a[0]<<b[1]<<c[2]<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = []

for i in S:
    ord_s = ord(i)
    if ord_s + N > 90:
        ans.append(chr(65 + ((ord_s + N)) - 91))
    else:
        ans.append(chr(ord_s + N))


print(''.join(ans))

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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans=0;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n; j++) {
      int k=n-i*r-j*g;
      if (k>=0 && k%b==0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int dfs(vector<vector<int>> &gr, int v, vector<int> &memo) {
    if (memo[v] != -1) return memo[v];
    int ret = 0;
    for (auto u : gr[v]) {
        ret = max(ret, dfs(gr, u, memo) + 1);
    }
    memo[v] = ret;
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> gr(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        gr[x].push_back(y);
    }
    vector<int> memo(n, -1);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, dfs(gr, i, memo));
    }
    cout << ans << endl;
    return 0;
}


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



int main(){
    int a,b;
	cin>>a>>b;
	if(b==1||b==0)
        cout<<"0";
	else if(b<=a)
        cout<<"1";
    else{
        int count=1;
        int total=a;
        while(total<b){
            total=total+(a-1);
            ++count;
        }
        cout<<count;
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N,T,c[100],t[100],i,min = 99999;
    scanf("%d %d",&N,&T);
    for (i = 0;i < N;i++) {
        scanf("%d %d",&c[i],&t[i]);
    }
    for (i = 0;i < N;i++) {
        if (t[i] <= T && c[i] < min) {
            min = c[i];
        }
    }
    if (min == 99999) {
        printf("TLE\n");
    } else {
        printf("%d\n",min);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n+1),b(m+1);
    a[0]=0,b[0]=0;
    rep(0,i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    rep(0,i,m){
        cin>>b[i+1];
        b[i+1]+=b[i];
        //cout<<b[i+1]<<endl;
    }
    ll ans=0;
    rep(0,i,n+1){
        if(k-a[i]<0)continue;
        auto itr=upper_bound(b.begin(),b.end(),k-a[i]);
        //cout<<ans<<" "<<*itr<<endl;
        ans=max(ans,i+(ll)(itr-b.begin()-1));
    }
    cout<<ans;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
#define in std::cin
#define ou std::cout
int main() {
    int N,M;
    in >> N >> M;
    int s[M], c[M];
    int cur = 1;
    rep(i, N-1) {
        cur *= 10;
    }
    
    int end = cur * 10;
    if(cur == 1)
        cur = 0;
    rep(i, M)
        in >> s[i] >> c[i];
    bool b = true;
    while(cur < end){
        for(int i = 0; i < M; i++){
            std::string str = std::to_string(cur);
            if(str[s[i]-1] - '0' != c[i]) {
                b = false;
                break;
            }
            
        }
        if(b){
            ou << cur;
            return 0;
        }
        b = true;

        ++cur;
    }
    ou << "-1";
    return 0;
}

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

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);
    int x, y, z;
    for(int i = 0; i < M; i++){
        cin >> x >> y >> z;
        tree.unite(x-1, y-1);
    }


    ll cnt = 0;
    for(int i = 0; i < N; i++){
        if( !tree.same(0,i) ){
            tree.unite(0, i);
            cnt++;
        }
    }

    cout << cnt + 1 << endl;
 

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[maxn];
bool vis[maxn];
int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i = 1;i <= n;++i){
        scanf("%d",&a[i]),vis[a[i]]=1;
    }
    int mi = -1,id = 0;
    for(int i = 0;i <= 200;++i){
        if(!vis[i]){
            if(mi==-1){
                mi = abs(m-i);
                id = i;
            }
            else if(abs(m-i)<mi){
                mi = abs(m-i);
                id = i;
            }
        }
    }
    cout<<id<<endl;
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  string s;
  int count0=0, count1=0;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    if(s[i] == '0')
      count0++;
    else if(s[i] == '1')
      count1++;
  }
  int a = min(count0, count1);
  cout << 2*a;
  return 0;
}
      
      

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    200256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );

using namespace std;
ll m, k, z;

void solve()
{
    sc( "%I64d%I64d", &m, &k );
    z = ( 1LL << m );
    
    if( k >= z )
    {
        pr( "-1" );
        rt;
    }
    if( m == 1 )
    {
        if( k )
        {
            pr( "-1" );
            rt;
        }
        else pr( "0 0 1 1" );
        rt;
    }
    if( !m )
    {
        if( k )
        {
            pr( "-1" );
            rt;
        }
        else pr( "0 0" );
        rt;
    }
    for( ll i = 0; i < z; i ++ )
        if( i != k )pr( "%I64d ", i );
    pr( "%I64d ", k );
    for( ll i = z - 1; i >= 0; i -- )
        if( i != k )pr( "%I64d ", i );
    pr( "%I64d", k );
}

int main()
{
    int tt = 1;
    //sc( "%d", &tt );
    for( int i = 1; i <= tt; i ++ )
        solve();
}












Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++) ans += a[i]*a[j];
	}
	cout<<ans<<"\n"; 
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3624
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> k ;
ll ans = 0;
n = 100;
while(n<k)
{
	ll tmp = n/100;
	n += tmp;
	ans++;
}
cout << ans;
  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> G(n);
    x--;
    y--;
    repi(i, n, 1)
    {
        G[i - 1].push_back(i);
        G[i].push_back(i - 1);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    vector<ll> ans(n - 1, 0);
    repi(i, n, 0)
    {
        vector<int> dist(n, INF);
        queue<int> q;
        dist[i] = 0;
        q.push(i);
        while (!q.empty())
        {
            for (int child : G[q.front()])
            {
                if (dist[child] > dist[q.front()] + 1)
                {
                    dist[child] = dist[q.front()] + 1;
                    q.push(child);
                }
            }
            q.pop();
        }
        for (int d : dist)
        {
            if(d == 0)continue;
            ans[d - 1]++;
        }
    }
    for (int a : ans)
    {
        cout << a / 2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int A, B, C; 
long long int K; 
cin >> A >> B >> C >> K; 
if(K % 2 == 0) {
cout << A-B << endl;
}
if(K % 2 == 1) {
cout << B-A << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define Vi vector<vector<int>>
#define ll long long
#define P pair<int,int>
#define vp  vector<P>
#define mod 1000000009
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
		if(s[i]!=t[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int solve(int n, int m) {
    vector<long long> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    long long ans = -1;
    REP(i, n) {
        REP(j, n) {
            if (i == j) continue;
            if (m < a[i] + a[j]) continue;
            ans = max(ans, a[i] + a[j]);
        }
    }

    cout << (ans == -1 ? "NONE" : to_string(ans)) << endl;
}

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        solve(n, m);
    }
    return 0;
}


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

string classify(double weight) {
    if(weight > 91.00) return("heavy");
    if(weight > 81.00) return("light heavy");
    if(weight > 75.00) return("middle");
    if(weight > 69.00) return("light middle");
    if(weight > 64.00) return("welter");
    if(weight > 60.00) return("light welter");
    if(weight > 57.00) return("light");
    if(weight > 54.00) return("feather");
    if(weight > 51.00) return("bantam");
    if(weight > 48.00) return("fly");
    return("light fly");
}

int main(void) {
    double input;
    while(cin >> input) {
        cout << classify(input) << endl;
    }
    return(0);
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int m;

int main() {
	cin >> m;
	cout << 24 + (24 - m) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int M=1e5+5;
const int MO=13;
const int MOD=1e9+7;

char s[M];
int dp[2][MO];

int main()
{
	dp[1][0]=1;
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<MO;j++)
			dp[i&1][j]=0;
		if(s[i]=='?')
		{
			for(int j=0;j<MO;j++)
				for(int k=0;k<10;k++)
					dp[i&1][(j*10%MO+k)%MO]=(dp[i&1][(j*10%MO+k)%MO]+dp[(i+1)&1][j])%MOD;
		}
		else
		{
			for(int j=0;j<MO;j++)
				dp[i&1][(j*10%MO+s[i]-'0')%MO]=(dp[i&1][(j*10%MO+s[i]-'0')%MO]+dp[(i+1)&1][j])%MOD;
		}
		// for(int j=0;j<MO;j++)
		// 	cout<<dp[i&1][j]<<" ";
		// cout<<endl;
	}
	printf("%d\n",dp[(n+1)&1][5]);
	return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<int> card(N, 0);
    for(int i=0; i<M; i++) {
        int L, R;
        cin >> L >> R;
        card[L-1]++;
        if(R<N) card[R]--;
    }
    
    int count=0;
    if(card[0]==M) count++;
    for(int i=1; i<N; i++) {
        // cout << i << ", card " << card[i] << endl;
        card[i] += card[i-1];
        // cout << i << ", card " << card[i] << endl << endl;
        if(card[i]==M) count++;
    }
    
    cout << count << endl;

    return 0;
    
}

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

using namespace std;

int main() {

	int a, b;
	cin >> a >> b;
	int ans1 = a + a - 1;
	int ans2 = a + b;
	int ans3 = b + b - 1;
	cout << max(ans1, max(ans2, ans3)) << '\n';
	return 0;
}

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

int main(){
    string O,E;
    cin >> O >>E;
    for (int i = 0; i < E.length(); i++) {
        cout << O[i] << E[i];
    }
    if (O.length()-E.length()==1) cout << O.back();
    cout << "" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.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;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, ans;

int DFS(ll num, int three, int five, int seven){
  if (num > N) return 0;
  if (three * five * seven > 0) ans++;

  DFS(num*10+3, 1, five, seven);
  DFS(num*10+5, three, 1, seven);
  DFS(num*10+7, three, five, 1);

  return 0;
}

int main(){
  cin >> N;
  DFS(0,0,0,0);
  cout << ans << endl;

  return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

ll n,m;
int main(){
  cin >> n >> m;
  ll ans;
  if(2*n >= m){
    ans = m/2;
  }else{
    ans = n+(m-2*n)/4;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256