akhauriyash/Code-Regression huggingface dataset:
#define de puts("#")
#define bug(x) cout<<#x<<" : "<<x<<endl
#define cha1 printf("L : %d,R : %d,x : %d,l : %d,r : %d,rt : %d\n",L,R,x,l,r,rt)
#define cha2 printf("L : %d,R : %d,l : %d,r : %d,rt : %d\n",L,R,l,r,rt)
#define cha3 printf("pos : %d,x : %d,l : %d,r : %d,rt : %d\n",pos,x,l,r,rt)
#define lcha1 printf("L : %lld,R : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,x,l,r,rt)
#define lcha2 printf("L : %lld,R : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,l,r,rt)
#define lcha3 printf("pos : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",pos,x,l,r,rt)
#define huge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%d ",a[i][j]);puts("");}puts("")
#define lhuge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%lld ",a[i][j]);puts("");}puts("")
#define lowbit(x) (x&(-x))
#define IN freopen("in.txt","r",stdin)
#define OUT1 freopen("out1.txt","w",stdout)
#define OUT2 freopen("out2.txt","w",stdout)
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	printf("%d\n",n*n*3);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long int N,i,ans=0;
	scanf("%lld",&N);
	long long int A[N+1];
	long long int B[N];
	for(i=0;i<N+1;i++){
		scanf("%lld",&A[i]);
	}
	for(i=0;i<N;i++){
		scanf("%lld",&B[i]);
	}
	for(i=0;i<N;i++){
		if(A[i]>=B[i]){
			ans=ans+B[i];
		}else if(A[i]+A[i+1]>=B[i] && A[i]<B[i]){
			ans=ans+B[i];
			A[i+1]=A[i+1]-(B[i]-A[i]);
		}else if(A[i]+A[i+1]<=B[i]){
			ans=ans+A[i]+A[i+1];
			A[i+1]=0;
		}
	}
	printf("%lld",ans);
	
	return 0;
}


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

using namespace std;

double dp[305][305][305];
double p[305][305][305];
int cnt[4];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

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

    p[cnt[1]][cnt[2]][cnt[3]]=1;
    for (int c=n;c>=0;c--)
        for (int b=n;b>=0;b--)
        for (int a=n;a>=0;a--)
    {
        if (a==0 && b==0 && c==0)
            continue;
        if (a+b+c>n)
            continue;

        double pr=(double)(n-(a+b+c))/n;
        double ex_v=pr/(1-pr)+1;
        dp[a][b][c]+=ex_v*p[a][b][c];

        if (a!=0)
        {
            double p_g=(double)a/(a+b+c);
            dp[a-1][b][c]+=dp[a][b][c]*p_g;
            p[a-1][b][c]+=p[a][b][c]*p_g;
        }

        if (b!=0)
        {
            double p_g=(double)b/(a+b+c);
            dp[a+1][b-1][c]+=dp[a][b][c]*p_g;
            p[a+1][b-1][c]+=p[a][b][c]*p_g;
        }

        if (c!=0)
        {
            double p_g=(double)c/(a+b+c);
            dp[a][b+1][c-1]+=dp[a][b][c]*p_g;
            p[a][b+1][c-1]+=p[a][b][c]*p_g;
        }
    }

    cout <<fixed << setprecision(10) << dp[0][0][0];
}


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

#define ll long long
#define N 50005
#define INF 100000000000000000L



ll Solve(int n,const std::vector< ll >& h){
  std::vector< ll > dp(n+1);
  dp[n] = 0,dp[n-1] = 0,dp[n-2] = std::abs(h[n-1] - h[n-2]);
  for(int i = n - 3; i >= 0; i--) 
    dp[i] = std::min( dp[i + 1] + std::abs(h[i] - h[i + 1]),
                      dp[i + 2] + std::abs(h[i] - h[i + 2]));
  return(dp[0]);
}


int main() {
  int n;
  std::cin >> n;
  std::vector< ll > h(n);
  for(int i = 0; i < n; i++) std::cin >> h[i]; 
  std::cout << Solve(n,h) << "\n";    
  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
#ARC101C
import sys

#n= int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))
tmp = input().split()
x = list(map(lambda a: int(a), tmp))

ans=max(abs(x[n-1]), max(abs(x[0]),abs(x[n-1]-x[0])+abs(x[0])))
for i in range(0,n-k+1):
	distancel=abs(x[i]-x[i+k-1])+abs(x[i+k-1])
	distancer=abs(x[i]-x[i+k-1])+abs(x[i])
	ans=min(ans,min(distancel,distancer))
print(ans)


Measured memory_bytes: 14564
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
map<int,int>mp;


void divide(int k){
int p=2;
while(k!=1){

    if(k%p==0){
        k/=p;
        mp[p]++;
    }
    else{
        p++;
    }
}
return;



}

int main(){

int N;
cin>>N;


for(int i=2;i<=N;i++){
    divide(i);
}

long long ans=1;
for(int i=2;i<=N;i++){
    ans*=(mp[i]+1);

    if(ans>=mod)ans%=mod;
}

cout<<ans<<endl;
 return 0;
}
/*


*/


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

#define rep(i,n) for (int i=1;i<(n+1);++i)

signed main()
{
    int n; cin >> n;
    vector<int> ans(10010);

    rep(x,100){
        rep(y,100){
            rep(z,100){
                ll a=x*x+y*y+z*z+x*y+y*z+z*x;
                if (a>10000L) break;
                ans[a]++;
            }
        }
    }

    rep(i,n)
        cout << ans[i] << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

int main() {
    int a,b; cin >> a >> b;
    FOR(i, 1, 4) {
        if(a != i && b != i) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}



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

const int MAX_N = 110000;

int dp[MAX_N]; // dp[i] が i についての答え

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

    // 初期化
    for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF の気持ち
    dp[0] = 0;

    // 貰う DP --- dp[n] に遷移を集める
    for (int n = 1; n <= N; ++n) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            dp[n] = min(dp[n], dp[n - pow6] + 1);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            dp[n] = min(dp[n], dp[n - pow9] + 1);
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    int ans = 1 << 26;

    for (int i = 0; i < 100; i++) {
        for (int k = 0; k < 100; k++) {
            for (int j = 0; j < 100; j++) {
                int a0 = a[0] + 2 * i;
                int a2 = a[2] - k;

                int a1 = a[1] + 2 * j;

                if (a0 == a1 && a1 == a2) {
                    ans = min(ans, i + j + k);
                }

                a1 = a[1] - j;

                if (a0 == a1 && a1 == a2) {
                    ans = min(ans, i + j + k);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N;
    string sign;
    string lis[100];
    cin>>N;
    cin>>sign;
    for(int i=0;i<N;i++)cin>>lis[i];
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<lis[i].size()-1;j++){
            int aho=0;
            for(int k=j+1;k<lis[i].size();k++){
                if(lis[i][j]==sign[0]&&lis[i][k]==sign[1]){
                    int flag=1;
                    for(int l=0;l<sign.size();l++){
                        if(lis[i][j+(k-j)*l]!=sign[l])flag=0;
                    }
                    if(flag){
                        ans++;
                        aho=1;
                        break;
                    }
                }
            }
            if(aho==1)break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

ll modpow(ll x, ll n){
  if(n == 0) return 1;
  else if(x == 1) return 1;
  else if(n == 1) return x % MOD;
  else if(n % 2 == 0) return modpow(x * x % MOD, n / 2) % MOD;
  else return modpow(x * x % MOD, (n - 1) / 2) * x % MOD;
}

ll ncr(ll n, ll r){
  ll de = 1;
  ll nu = 1;
  REP(i, r){
    nu *= (n - i) % MOD;
    de *= (r - i) % MOD;
    nu = nu % MOD;
    de = de % MOD;
  }
  return (nu * modpow(de, MOD-2));
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  VI fac;
  cin >> n >> m;
  int tar = m;
  for(int i = 2; i * i <= m; i++){
    if(tar % i == 0){
      int count = 0;
      while(tar % i == 0){
        tar = tar / i;
        count++;
      }
      fac.push_back(count);
    }
  }
  if(tar != 1) fac.push_back(1);
  ll ans = 1;
  for(auto f : fac){
    ans *= ncr(f + n - 1, f) % MOD;
    ans = ans % MOD;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int x = 0;
    x = N % 10;
    if(x == 3){
      System.out.println("bon");
    }else if(x == 0 || x == 1 || x == 6 || x == 8){
      System.out.println("pon");
    }else{
      System.out.println("hon");
    }
  }
}

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

int  main()
{
	// ifstream in("in/02-random-00.txt");
	// cin.rdbuf(in.rdbuf());
	int n,m;
	cin >> n >> m;
	int s[m],c[m];
	vector<set<int> > st(n+1);
	int ans = 0;
	st[0].insert(-1);
	rep(i, m)
	{
		cin >> s[i] >> c[i];
		st[s[i]].insert(c[i]);
		if (st[s[i]].size() > 1)
			ans = -1;
		if (n != 1 && s[i] == 1 && c[i] == 0)
			ans = -1;
	}
	if (ans == -1)
	{
		cout << -1 << endl;
		return 0;
	}
	int sum = 0;
	for(int i = 1;i <= n ; i++)
	{
		if (!st[i].empty())
		{
			rep(j, 10)
			{
				if (st[i].count(j))
				{
					sum *= 10;
					sum += j;
					// cout << j;
					break;
				}
			}
		}
		else
		{
			if (i == 1 && n != 1)
			{
				sum *= 10;
				sum += 1;
				// cout << 1;
			}
			else
			{
				sum *= 10;
				sum += 0;
				// cout << 0;
			}
		}
	}
	cout << sum << endl;
	return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	4005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int f[MAXN][MAXN];
void update(int &x, int y) {
	x = (x + y) % P;
}
int main() {
	int n, m, k;
	read(n), read(m), read(k);
	int t = (n + m - 1) / (k - 1);
	f[0][0] = 1;
	for (int i = 0; i <= k - 1; i++)
		f[1][i] = 1;
	for (int i = 1; i <= t; i++)
	for (int j = 0; j <= n; j++)
	for (int l = 0; l <= k - 1 && l + j <= n; l++)
		update(f[i + 1][j + l], f[i][j]);
	int ans = 0;
	for (int i = 0; i < t; i++)
	for (int j = 0; j < n; j++) {
		int tmp = i * (k - 1) - j;
		if (tmp < m) update(ans, f[i][j]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, q;
	cin >> a >> b >> q;
	vector<ll> s, t, xvec;
	rep(i, a) {
		ll d;
		cin >> d;
		s.push_back(d);
	}
	rep(i, b) {
		ll d;
		cin >> d;
		t.push_back(d);
	}
	rep(i, q) {
		ll x;
		cin >> x;
		xvec.push_back(x);
	}
	
	sort(ALL(s));
	sort(ALL(t));
	
	for (ll x: xvec) {
//		cout << x << endl;
		int lefts = upper_bound(ALL(s), x) - s.begin() - 1;
		int leftt = upper_bound(ALL(t), x) - t.begin() - 1;
		int rights = lower_bound(ALL(s), x) - s.begin();
		int rightt = lower_bound(ALL(t), x) - t.begin();
//		cout << lefts << " " << leftt << " " << rights << " " << rightt << endl;
		
		ll ans = (ll) (1e18);
		if (lefts != -1 and leftt != -1) {
			ll bothleft = x - min(s[lefts], t[leftt]);
			ans = min(bothleft, ans);
		}
		if (lefts != -1 and rightt != b) {
			ll leftright = min(x - s[lefts], t[rightt] - x) * 2 + max(x - s[lefts], t[rightt] - x);
			ans = min(leftright, ans);
		}
		if (leftt != -1 and rights != a) {
			ll leftright = min(x - t[leftt], s[rights] - x) * 2 + max(x - t[leftt], s[rights] - x);
			ans = min(leftright, ans);
		}
		if (rights != a and rightt != b) {
			ll bothright = max(s[rights], t[rightt]) - x;
			ans = min(bothright, ans);
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3828
//
// Created by file on 18/05/26.
//


#include <iostream>

using namespace std;

int A;
int B;
int SUM;
int diff;
int product;
int MAX;

int main(){

    std::cin>>A;
    std::cin>>B;
        //calculate
    SUM = A+B;
    diff = A- B;
    product = A*B;
    //judge

    MAX = SUM;
    if(MAX<diff){
        MAX = diff;
    }
    if(MAX<product){
        MAX =product;
    }


    std::cout<<MAX;
}


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

int main() {
    int N, D; cin >> N >> D;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        --a[i];
        b[i] = a[i] % (D + 1);
    }

    long long sum = 0;
    for (int i = 0; i < N; ++i) sum ^= b[i];
    if (!sum) puts("Second");
    else puts("First");
}


Measured memory_bytes: 4840
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i,j in enumerate(a):
    if x - j < 0:
        print(i)
        break
    else:
        x = x - j
else:
    if x == 0:
        print(i + 1)
    else:
        print(i)

Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include <map>
#include <string>
using namespace std;
map<string, int> table;
int dir[4] = { 1,-1,4,-4 };
void bfs()
{
	string st = "01234567";
	table[st] = 1;
	queue<string> s;
	s.push(st);
	while (s.size())
	{
		st = s.front();
		s.pop();
		int num = st.find('0');
		for (int i = 0; i <= 3; ++i)
		{
			int tn = num + dir[i];
			if (tn < 0 || tn>7 || num == 3 && dir[i] == 1 || num == 4 && dir[i] == -1)
				continue;
			string tmp = st;
			swap(tmp[tn], tmp[num]);
			if (!table[tmp])
			{
				s.push(tmp);
				table[tmp] = table[st] + 1;
			}
		}
	}
}
int main()
{
	char x;
	string str;
	bfs();
	while (cin>>x)
	{
		str.push_back(x);
		for (int i = 1; i <= 7; ++i)
		{
			cin >> x;
			str.push_back(x);
		}
		cout << table[str]-1 << endl;
		str.clear();
	}
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 m;
    cin >> m;
    vector<int64> cnt(10,0);
    REP(i,m){
        int64 d, c;
        cin >> d >> c;
        cnt[d] += c;
    }
    queue<pii> que;
    int64 ans = cnt[0];
    FOR(i,1,10){
        if(cnt[i] > 0)
            que.push(pii(i,cnt[i]));
    }
    while(!que.empty()){
        int64 d,c;
        tie(d,c) = que.front();
        que.pop();
        if(d == 0){
            ans += c;
            continue;
        }
        if(c == 1){
            if(que.empty()){
                ANS(ans);
                return 0;
            }else{
                int64 d2,c2;
                tie(d2,c2) = que.front();
                que.pop();
                if(d + d2 >= 10){
                    que.push(pii((d+d2)/10,1));
                    que.push(pii((d+d2)%10,1));
                }else{
                    que.push(pii(d + d2,1));
                }
                ans++;
                c2--;
                if(c2 > 0){
                    que.push(pii(d2,c2));
                }
            }
        }else{
            if(d * 2 >= 10){
                que.push(pii((d*2)/10,c/2));
                que.push(pii((d*2)%10,c/2));
            }else{
                que.push(pii(d*2,c/2));
            }
            ans += c/2;
            if(c % 2 == 1){
                que.push(pii(d,1));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 11664
#include <stdio.h>

int data[10];
int sp = 0;
int read;

int top()
{
 return data[sp-1];
}

void pop()
{
 sp--;
}

void push(int v)
{
 data[sp] = v;
 sp++;
}

int main()
{
 while(scanf("%d",&read) != EOF)
 {
  if(read == 0)
  {
   printf("%d\n",top());
   pop();
  }
  else
  {
   push(read);
  }
 }
 return 0;
}

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


int getdigit(ll num){
    int digit = 0;
    while(num!=0){
        num/=10;
        digit++;
    }
    return digit;
}

int f(ll a, ll b){
    int ans = max(getdigit(a),getdigit(b));
    return ans;
}

int main(){
    ll n; cin >> n;
    int ans = INT_MAX;
    for(ll a = 1; a <= sqrt(n); a++){
        if(n % a == 0){
            ll b = n / a;
            ans = min(ans, f(a,b));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define dumpitr(c) for (auto itr=c.begin();itr!=c.end();++itr){cout << *itr << " "; } cout << endl;
#define rep(i, n) for (int i=0;i<(int)(n);i++)

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> A(M), B(M);
    vector<bool> NG(N, true);
    int ans = 0;

    rep(i, N) cin >> H[i];
    rep(i, M){
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
        if(H[A[i]] <= H[B[i]]) NG[A[i]] = false;
        if(H[B[i]] <= H[A[i]]) NG[B[i]] = false;
    }
    
    //dumpitr(NG);
    rep(i, N){
        if(NG[i] == true) ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4584
n = int(input())
h_stack = list(map(int, input().split()))
flag = True
pre_h = 10 ** 9
while h_stack:
  h = h_stack.pop()
  if h > pre_h + 1:
    flag = False
    break
  elif h == pre_h + 1:
    h -= 1
  pre_h = h
if flag:
  print('Yes')
else:
  print('No')

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
//typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

// https://atcoder.jp/contests/arc102/submissions/3123383
// https://betrue12.hateblo.jp/entry/2018/09/02/094954
int main() {
    int j, k;
    int l, n = 0;
    cin >> l;
    while (1 << n <= l) n++;
    vector<vector<int>> ans;
    for (int i = 1; i < n; i++) {
        ans.push_back({i, i + 1, 1 << (i - 1)});
        ans.push_back({i, i + 1, 0});
    }

    int now = (1 << (n - 1)) - 1;

    for (int i = n - 1; i >= 1; i--) {
        if (now == l - 1) break;
        int gain = 1 << (i - 1);
        if (now + gain <= l - 1) {
            ans.push_back({i, n, now + 1});
            now += gain;
        }
    }

    int m = ans.size();
    cout << n << ' ' << m << endl;
    for (auto &v : ans) {
        printf("%d %d %d\n", v[0], v[1], v[2]);
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> list(n);
  for(int i=0; i<n; i++) {
    cin >> list.at(i);
  }
  sort(list.begin(),list.end());
  int ans=0;
  for(int i=0; i<k; i++) {
    ans += list.at(i);
  }
  cout << ans << endl;
}

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

struct P
{
    int x,y;

    /*bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }*/

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

int o[222221];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[100333];
stack<int> s;
//set<int> s[222][22];
priority_queue<int> q;
//queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[222253];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;p[n]++,q.push(n),t++)
        scanf("%d",&n);
    for(;q.size();q.pop())
    if(p[q.top()])
    {
        p[q.top()]--;
        for(i=1;i<=q.top();i*=2);
        if(p[i-q.top()]) p[i-q.top()]--,k++;

    }
    printf("%d",k);
}






Measured memory_bytes: 19828
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n, k;
	cin >> n >> k;

	int ans = (n + 1) / 2;
	if (ans >= k) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

void func()
{
    ll x;
    cin>>x;
    loop(i,-1000,1001)
    {
        loop(j,-1000,1001)
        {
            ll t=pow(i,5)-pow(j,5);
            if(t==x){
                cout<<i<<" "<<j<<"\n";
                return;
            }
        }
    }
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
main(){
  int x1,y1,x2,y2,h,w;
  cin>>x1>>y1>>x2>>y2;
  w=x2-x1;
  h=y2-y1;
  cout<<x2-h<<" "<<y2+w<<" "<<x1-h<<" "<<y1+w;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    vector<int>a(m);

    int ans = n;
    rep(i, m){
        cin >> a[i];
        ans -= a[i];
    }
    if(ans < 0)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3604
alphabets={}
for i in range(97,97+26):
    alphabets[str(chr(i))]=0
while True:
    try:S=input()
    except:break
    for s in S:
        if s.lower() in alphabets:
            s=s.lower()
            alphabets[s]+=1

for key,value in alphabets.items():
    print(key +' : ' + str(value))


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

int main() {
  int H, W;
  cin >> H >> W;

  for ( int i = 0; i < W + 2; i++ ) cout << "#";
  cout << endl;

  for ( int i = 0; i < H; i++ ) {
    cout << "#";
    for ( int j = 0; j < W; j++ ) {
      char c;
      cin >> c;
      cout << c;
    }
    cout << "#" << endl;
  }

  for ( int i = 0; i < W + 2; i++ ) cout << "#";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int ans;

int min(int a,int b){
	if(a>=b)return b;
	else return a;
}

int main(){

	int n,m;
	long long int dp[256];
	long long int nextDp[256];
	int next;

	while(cin>>n>>m){
		ans = 1000000000000;
		if(n==0 && m==0){
			break;
		}
		int *c;
		int *x;
		c = new int[m];
		x = new int[n];

		for(int i=0;i<m;i++){
			cin>>c[i];
		}
		for(int i=0;i<n;i++){
			cin>>x[i];
		}
		for(int i=0;i<256;i++){
			dp[i]=ans;
			nextDp[i]=ans;
		}

		for(int i=0;i<m;i++){
			next = 128+c[i];
			if(next>=255)next=255;
			if(next<=0)next = 0;
			dp[next] = (x[0]-next)*(x[0]-next);
		}
		/*
		for(int i=0;i<256;i++){
			cout<<dp[0][i]<<" ";
		}
		cout<<endl;
		*/
		for(int i=1;i<n;i++){
			for(int j=0;j<256;j++){
				for(int k=0;k<m;k++){
					next = j+c[k];
					if(next>=255)next=255;
					if(next<=0)next = 0;
					//dp[next] = min(dp[next],dp[j]+(x[i]-next)*(x[i]-next));
					nextDp[next] = min(nextDp[next],dp[j]+(x[i]-next)*(x[i]-next));
				}
			}
			for(int j=0;j<256;j++){
				dp[j]=nextDp[j];
				nextDp[j]=ans;
			}
		}
		for(int i=0;i<256;i++){
			ans = min(ans,dp[i]);
		}


		cout<<ans<<endl;

	}

	return 0;

}

Measured memory_bytes: 3348
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int N;
    while (~scanf("%d", &N)) {
          int ans = 0;
          int cur, cnt = 1;
          scanf("%d", &cur);
          for (int i = 0; i < N - 1; i++) {
              int tmp;
              scanf("%d", &tmp);
              if (tmp == cur) cnt++;
              else {
                   cur = tmp;
                   ans += (cnt / 2);
                   cnt = 1;
              }
          }
          ans += (cnt / 2);
          printf("%d\n", ans);
    }
    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> d1(n),d2(n); rep(i,n) cin >> d1[i] >> d2[i];

  bool exist = false;
  rep(i,n-2){
    if(d1[i] == d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2]) exist = true;
  }

  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1&&b==2) printf("3");
	if(a==2&&b==1) printf("3");
	if(a==1&&b==3) printf("2");
	if(a==3&&b==1) printf("2");
	if(a==2&&b==3) printf("1");
	if(a==3&&b==2) printf("1");
	return 0;
}

Measured memory_bytes: 128
import math

def canMakeTriangle(a, b, c):
    return abs(b - c) < a

N = int(input())
L = list(map(int, input().split()))
L.sort()

res = 0
for i in range(1, N):
    for j in range(i + 1, N):
        a = 0
        b = i
        c = 0
        while b - a >= 1:
            c = (a + b) / 2
            if canMakeTriangle(L[math.floor(c)], L[i], L[j]):
                b = c
            else:
                a = c

        c = math.floor(c)

        if canMakeTriangle(L[c], L[i], L[j]):
            res += i - c
        else:
            res += i - c - 1

print(res)

Measured memory_bytes: 74280
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

bool isPrime(int n){
    if(n==1)return false;
    if(n==2)return true;
    for(int i=2;i<sqrt(n)+1;i++){
        if((n%i)==0)return false;
    }
    return true;
}


int main(){
    
    while(true)
    {
        int n;
        cin>>n;
        if(n==0)
        {
            break;
        }
        
        int ans=0;
        for(int i=2;i<=n/2;i++)
        {
            if(isPrime(i)&&isPrime(n-i))ans++;
        }
        
        cout<<ans<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 2984
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int n;
  int e=0;
  int w=0;
  string s;
  cin>>n>>s;
  for(int i=0; i<n; i++) {
    if(s[i]=='W')
      w++;
    else
      e++;
  }
  int m = e;
  int ce=e;
  int cw=0;
  for(int i=0; i<n; i++) {
    if(s[i]=='W') {
      m = min(ce+cw, m);
      cw++;
    } else {
      m = min(max(ce-1, 0)+cw, m);
      ce--;
    }
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 900
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] kosu=new int[100001];
		long[][] aa=new long[M][3];
		for(int i=0; i<=100000; i++) {
			kosu[i]=0;
		}
		for(int i=0; i<M; i++) {
			long a=sc.nextLong();
			long b=sc.nextLong();
			kosu[(int)a]++;
			aa[i][0]=a*10000000000L+b;
			aa[i][1]=i;
		}
		for(int i=1; i<=100000; i++) {
			kosu[i]=kosu[i-1]+kosu[i];
		}
		quick_sort(aa,0,M-1);
		for(int i=0; i<M; i++) {
			aa[i][2]=i+1;
		}
		long[][] ansss=new long[M+1][2];
		for(int i=0; i<M; i++) {
			ansss[(int)aa[i][1]][0]=aa[i][0];
			long ban=aa[i][0]/10000000000L;
			ansss[(int)aa[i][1]][1]=aa[i][2]-kosu[(int)ban-1];
		}
		String unti="";
		String buri="";
		for(int i=0; i<M; i++) {
			long aaaa=ansss[i][0]/10000000000L;
			unti=String.format("%06d", (int)(aaaa));
			buri=String.format("%06d", (int)(ansss[i][1]));
			System.out.println(unti+buri);
		}
	}
	static void quick_sort(long[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		long p = d[(left+right)/2][0];
		int l = left, r = right;
		long tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

Measured memory_bytes: 170504
input_data = []
hum = int(input())
for i in range(5):
    input_data.append(int(input()))
    
diff = int(hum/min(input_data))
amari= int(hum%min(input_data))
if diff == 1 and amari==0:
    diff=0 
elif amari==0:
    diff-=1
print(5+diff)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n; cin >> a >> b >> n;
    if (n >= b) cout << (a * (b - 1)) / b << "\n";
    else cout << (a * n) / b << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>());
    int u, k;
    REP(i, n) {
        cin >> u >> k;
        u--;
        int v;
        REP(j, k) {
            cin >> v;
            v--;
            g[u].emplace_back(v);
        }
    }

    vector<int> d(n, 0);
    vector<int> f(n, 0);
    int count = 0;
    function<void(int)> dfs = [&](int c) {
        if (d[c] == 0) d[c] = count;
        for (auto t : g[c]) {
            if (d[t] != 0) continue;
            count++;
            dfs(t);
        }
        count++;
        f[c] = count;
    };
    REP(i, n) if (d[i] == 0) {
        count++;
        dfs(i);
    }

    REP(i, n) cout << i + 1 << " " << d[i] << " " << f[i] << endl;
}



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

int main(){
	
	while(1){
		
		string kazu;
		cin>>kazu;
		
		if(kazu == "0"){
		 break;
		}
			int sum=0;
		for(int i=0;i<(int)kazu.size();i++){
			
			sum += kazu[i]-'0';
			
		}
			cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.Arrays;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int L[] = new int[N];
 
    for(int i = 0; i < N; i++){
      L[i] = Integer.parseInt(sc.next());
    }
 
    Arrays.sort(L);
    int count = 0;
    for(int i = 0; i < N - 2; i++){
      for(int j = i + 1; j < N - 1; j++){
        for(int k = j + 1; k < N; k++){
            if(L[k] < L[i] + L[j]){
              count++;
            }
        }
      }
    }
 
    System.out.println(count);
  }
}

Measured memory_bytes: 26768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            if (S.Length <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                Console.WriteLine(S.Substring(0, K) + "...");
            }
        }
    }
}


Measured memory_bytes: 17628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int total = 0;
        for(int i = 1; i <= N; i++) {
            int sum = findSumOfDigists(i);
            if(sum >= A && sum <= B) {
                total += i;
            }
        }
        System.out.println(total);
    }

    public static int findSumOfDigists(int n) {
        int sum = 0;
        while(n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
}


Measured memory_bytes: 23252
import sys,math,itertools
import numpy as np

n=int(sys.stdin.readline())
a=np.array([sys.stdin.readline().split() for _ in range(n)],dtype='int64')

to=0
num=0
b=np.zeros((n,n))

for i in range(n-1):
    for j in range(i+1,n):
        b[i,j]=((a[i,0]-a[j,0])**2+(a[i,1]-a[j,1])**2)**(1/2)


for i in itertools.permutations(range(n)):
    f=0
    num+=1
    for j in i:
        if f==0:
            c=j
            f=1
        else:
            if c>j:
                to+=b[j,c]
            else:
                to+=b[c,j]
            c=j


print(to/num)
        


Measured memory_bytes: 14456
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int N;
    int b[10002];
    int dp[2][5002][2];//[A][B][C]=A??????????????????C???????????¨???1??????????????§???Bmm?????£?????????????????????????????????????°????
class DividingSnacks{
    public:
    int solve(){
        scanf("%d",&N);//N%2=0
        rep(i,N-1){
            scanf("%d",&b[i]);
        }
        b[N-1]=0;//?????????????????????????????????????????¨??????
        fill(dp[0][0],dp[2][0],INF);
        rep(i,N){
            rep(j,N/2+1){
                //rep(k,2){
                    if(i==0){
                        //?????????1mm???A?????¨???
                        if(j==1)dp[i%2][j][0]=0;
                        else dp[i%2][j][0]=INF;
                        dp[i%2][j][1]=INF;
                    }else{//i=1,2,3???
                        //i+1mm??????????????????????????????????????????????????????????????????i-1>0???
                        //??????????????????????????§????????¨???
                        //A?????????
                        //j=0???????????????????????§INF?????????
                        if(j>0)dp[i%2][j][0]=dp[(i-1)%2][j-1][1]+b[i-1];
                        //B?????¨???
                        dp[i%2][j][1]=dp[(i-1)%2][j][0]+b[i-1];
                        
                        //??????????????¨???
                        if(j>0)dp[i%2][j][0]=min(dp[i%2][j][0],dp[(i-1)%2][j-1][0]);
                        dp[i%2][j][1]=min(dp[i%2][j][1],dp[(i-1)%2][j][1]);
                    }
                //}
            }
        }
       
        int ans=min(dp[(N-1)%2][(N/2)][0],dp[(N-1)%2][(N/2)][1]);
        return (int)ans;
    }
};

signed main(void){
    DividingSnacks ans;
    printf("%d\n",ans.solve());
}

Measured memory_bytes: 2832
import java.util.*;

class Main{
    public static void main(String[] args){
        int N = 3;
        int[]a = new int[N];
        Scanner sc = new Scanner(System.in);
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        Arrays.sort(a);
        System.out.println(a[0] * a[1] / 2);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (i=(x);i<(y);i++)
#define REPJ(x,y)	for (j=(x);i<(y);i++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;

string S;
int i,n,w;

int main() {
	cin >> S;
	n = S.size();
	REPI(1,S.size()) {
		if (S[i] != S[i-1]) {
			w = MAX(i,S.size()-i);
			n = MIN(w,n);
		}
	}
	cout << n;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;

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

  long long n, ans = INF;
  cin >> n;
  for(ll i = 1; i <= sqrt(n); i++){
    if(n%i == 0){
      ans = min(ans, i-1 + n/i-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
n = int(input())
v = [[tuple(map(int, input().split()))for i in range(int(input()))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = [False] * n
    xy = []
    for j in range(n):
        if (i >> j) & 1:
            f[j] = True
            xy.append(v[j])
    flag = True
    for xyi in xy:
        for x, y in xyi:
            if f[x - 1] is not bool(y):
                flag = False
                break
    if flag:
        ans = max(ans, len(xy))
print(ans)


Measured memory_bytes: 9120
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, n, ans=0;
  cin >> n;
  ans=n/100000+(n%100000)/10000+(n%10000)/1000+(n%1000)/100+(n%100)/10+n%10;
  if(ans==1) ans=10;
  cout << ans;
  return 0;
}


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

using namespace std;

const long long oo = 1e18;

int n, W;
int w[105], v[105];
long long dp[105][100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> W;
    int V = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= V; j++)
        {
            dp[i][j] = oo;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= V; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i])
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= V; i++)
    {
        if (dp[n][i] <= W)
        {
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define max(a,b) (a>b? a:b)
#define min(a,b) (a<b? a:b)
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#pragma GCC Optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment (linker,"/stack:200000000")

typedef long long ll;

bool Finish_read;

template<class T>inline void read(T &x){Finish_read=0;x=0;T f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}

unsigned CostA,CostB,CostC,sum=0;
int X,Y;

int main() {
    read(CostA),read(CostB),read(CostC),read(X),read(Y);
    CostC <<= 1;
    while(X>0||Y>0) {
        if(CostC<CostA+CostB&&X>0&&Y>0)
            --X,--Y,sum+=CostC;
        else if(X>0&&CostA>CostC)
            --X,sum+=CostC;
        else if(Y>0&&CostB>CostC)
            --Y,sum+=CostC;
        else if(X>0)
            --X,sum+=CostA;
        else if(Y>0)
            --Y,sum+=CostB;
    }
    writeln(sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    bool ok = false;
    ll init_a = a;
    ll init_b = b;
    rep(i,t) {
        if(init_a<init_b) {
            a += v;
            b += w;
            if(a>=b) {
                ok = true;
                break;
            }
        } else {
            a -= v;
            b -= w;
            if(a<= b) {
                ok = true;
                break;
            }
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3636
import sys

tmp = '#.' * 151

def draw(H, W):
    odd = tmp[:W]
    even = tmp[1:W + 1]
    print((odd + '\n' + even + '\n') * (H // 2) + (odd  + '\n' if H % 2 else ''))
    
for line in sys.stdin:
    H, W = map(int, line.split())
    if H == W == 0:
        break
    draw(H, W)

Measured memory_bytes: 6816