akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100000

int parent[MAX], left[MAX], right[MAX];
int n, D[MAX];

int getDepth(int u);

void setDepth(int u, int p);

void printChildren(int u);

int main(){
  int i, j, a, b, c, l, r;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)
    parent[i] = left[i] = right[i] = -1;
  for( i = 0 ; i < n ; i++){
    scanf("%d", &b);
    scanf("%d", &a);
    for( j = 0 ; j < a ; j++){
      scanf("%d", &c);
      if( j == 0 ) left[b] = c;
      else right[l] = c;
      l = c;
      parent[c] = b;
    }
  }
  for(i = 0; i < n; i++){
    if(parent[i] == -1) r = i;
  }

  setDepth(r, 0);

  for(i = 0; i < n; i++) printChildren(i);

  return 0;
}

int getDepth(int u){
  int a = 0;
  while(parent[u] != -1){
    u = parent[u];
    a++;
  }
  return a;
}

void setDepth(int u, int p){
  D[u] = p;
  if(right[u] != -1){
    setDepth(right[u], p);
  }
  if(left[u] != -1){
    setDepth(left[u], p+1);
  }
}

void printChildren(int u){

  int i, c;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("depth = %d, ", getDepth(u));

  if(parent[u] == -1) printf("root, ");
  else if(left[u] == -1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  c = left[u];
 for(i = 0; c != -1; i++, c = right[c]){

    if(i) printf(", ");
    printf("%d", c);
  }


  printf("]\n");
}




Measured memory_bytes: 6416
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

int main()
{
	int a = 0, b = 0, k = 0;
	std::vector<int> m;
	std::cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i + a >= a && i + a <= b) {
			m.push_back(i + a);
		}
		if (b - i >= a && b - i <= b) {
			m.push_back(b - i);
		}
	}
	std::sort(m.begin(), m.end());
	m.erase(std::unique(m.begin(), m.end()), m.end());

	for (int i = 0; i < m.size(); i++) {
		std::cout << m[i] << std::endl;
	}
}

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

#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

ll gcm(ll a, ll b){
	if(!b) return a;
	else return gcm(b, a%b);
}

int main(void){
	ll a, b;
	cin >> a >> b;

	ll n = gcm(a, b), ans = 1;
	//cout << n << endl;
	for(ll i = 2; i*i <= n; i++){
		if(!(n%i)){
			ans++;
			while(!(n%i)) n /= i;
		}
	}
	if(n != 1) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cout<<a[0][0]<<a[1][1]<<a[2][2];
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
using namespace std;

long long int par[1000000], rank1[1000000];

void init(long long int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}

long long int find(long long int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(long long int x,long long int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank1[x] < rank1[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank1[x] == rank1[y])rank1[x]++;
	}
}

bool same(long long int x,long long int y) {
	return find(x) == find(y);
}

int main() {
	long long int Y=0,P[1000000],a,b,N, M;
	cin >> N>>M;
	init(N+1);
	for (long long int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (long long int i = 0; i < M; i++) {
		cin >> a >> b;
		unite(a, b);
	}

	for (long long int i = 0; i < N; i++) {
		if (same(P[i], i + 1))Y++;
	}
	cout << Y << endl;
}



Measured memory_bytes: 7808
a = [1]
p = [1]
N,X = map(int,input().split())
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def f(n,x):
    if n == 0:
        return 0 if x <= 0 else 1
    if x <= 1:
        return 0
    elif x <= a[n-1]+1:
        return f(n-1,x-1)
    else:
        return f(n-1,x-2-a[n-1])+p[n-1]+1
print(f(N,X))

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()


def main():
    sx, sy, tx, ty = map(int, input().split())
    dx, dy = tx - sx, ty - sy
    ans = ""
    for _ in range(dx): ans += "R"
    for _ in range(dy): ans += "U"
    for _ in range(dx): ans += "L"
    for _ in range(dy): ans += "D"
    ans += "D"
    for _ in range(dx + 1): ans += "R"
    for _ in range(dy + 1): ans += "U"
    ans += "L"
    ans += "U"
    for _ in range(dx + 1): ans += "L"
    for _ in range(dy + 1): ans += "D"
    ans += "R"
    print(ans)

    """
    x, y = sx, sy
    for c in ans:
        if c == "U": y += 1
        if c == "D": y -= 1
        if c == "R": x += 1
        if c == "L": x -= 1
        print(x, y)
    """

if __name__ == "__main__":
    main()


Measured memory_bytes: 73128
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Tubtet(i, k) for (k = (i - 1) & i; k; k = (k - 1) & i)
#define Subset(i, k) for (k = i; k; k = (k - 1) & i)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
const int N = 17, M = 405, C = (1 << 15) + 5, PYZ = 1e9 + 7;
int n, m, g[N][N], f[3][C], c[C], d[C], Cm, p[M], ans;
int main() {
	int i, j, k, x, y; n = read(); m = read(); p[0] = 1;
	For (i, 1, m) x = read(), y = read(), g[x][y]++, p[i] = 2ll * p[i - 1] % PYZ;
	Cm = (1 << n) - 1; For (i, 0, Cm) For (j, 1, n) For (k, 1, n) if (g[j][k]) {
		if (((i >> j - 1) & 1) && ((i >> k - 1) & 1)) c[i] += g[j][k];
		if (((i >> j - 1) & 1) || ((i >> k - 1) & 1)) d[i] += g[j][k];
	}
	For (k, 1, 2) For (i, 0, Cm) {
			if (!((i >> k - 1) & 1)) continue; f[k][i] = p[c[i]]; Tubtet(i, j) {
				if (!((j >> k - 1) & 1)) continue;
				f[k][i] = (f[k][i] - 1ll * f[k][j] * p[c[i - j]] % PYZ + PYZ) % PYZ;
			}
		}
	ans = p[m]; For (i, 0, Cm) {
		if (!(i & 1) || ((i >> 1) & 1)) continue; Subset(Cm - i, j) {
			if (!((j >> 1) & 1) || c[i] + c[j] < c[i + j]) continue;
			ans = (ans - 1ll * f[1][i] * f[2][j] % PYZ *
				p[m - d[i + j]] % PYZ + PYZ) % PYZ;
		}
	}
	cout << ans << endl; return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m=-1;
    int ans;
    for(int i=n;i>=1;i--)
    {
        int mid=(int)log2(n);
        mid=(int)pow(2,mid);
        for(int j=mid;j>=1;j/=2)
        {
            if(i%j==0)
            {
                if(log2(j)>m)
                {
                    ans=i;
                    m=log2(j);
                }
                break;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  vector<int> a(0);
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(ALL(a));
  int left = 0;
  int right = 0;
  int result = 1;
  while(left < N){
    int max = a.at(left) + 2;
    int d = 0;
    while(right < N && a.at(right) <= max){
      right++;
    }
    right--; //１つ行きすぎた分を戻す
    d = right - left + 1;
    if(d > result) result = d;
    if(right == left) right++;
    left++;
  }
  cout << result << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    graph G(N);
    int col[N];
    for(int i = 0; i < N; i++){
        G[i] = vector<ll>(0);
        col[i] = -1;
    }

    ll d[N][N];
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        for(int j = 0; j < N; j++){
            if(s[j] == '1'){
                G[i].push_back(j);
                d[i][j] = 1;
            }else{
                d[i][j] = 1ll << 60;
            }
        }
    }

    col[0] = 0;
    queue<ll> q = queue<ll>();
    q.push(0);
    while(!q.empty()){
        ll current = q.front();q.pop();
        for(int i = 0; i < G[current].size(); i++){
            ll tmp = G[current][i];
            if(col[tmp] != -1){
                continue;
            }
            col[tmp] = 1 - col[current];
            q.push(tmp);
        }
    }

    bool isBiG = true;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < G[i].size(); j++){
            if(col[i] == col[G[i][j]]){
                isBiG = false;
            }
        }
    }
    if(!isBiG){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        d[i][i] = 0;
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                if(j == k){
                    continue;
                }
                d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
                d[k][j] = d[j][k];
            }
        }
    }


    ll M = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            M = max(M,d[i][j]);
        }
    }
    cout << M + 1 << endl;
}


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

using namespace std;

const int N = 2 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

long long n, k;

bool read() {
    if (!(cin >> n >> k))
        return false;

    return true;
}

void solve() {
    auto res = (n / k) * (n / k) * (n / k);

    if (k % 2 == 0 && n >= k / 2) {
        auto x = n - k / 2;
        res += (1 + x / k) * (1 + x / k) * (1 + x / k);
    }

    cout << res << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dp[1<<15],n,m,c[15];
int qpow(int a,int b){
	int ans=1,tmp=a;
	for(;b;b>>=1,tmp=1ll*tmp*tmp%mod)
		if(b&1)ans=1ll*ans*tmp%mod;
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0,u,v;i<m;++i)
		scanf("%d%d",&u,&v),c[u-1]|=1<<v-1;
	dp[0]=1;
	for(int i=1;i<(1<<n);++i)if((i&3)==3||(i&3)==0){
		for(int j=i;;j=(j-1)&i)if((j&3)==3||(j&3)==0){
			int k=i^j,l=0,z=dp[j];
			for(int p=0;p<n;++p)if((1<<p)&k)
				l+=__builtin_popcount(j&c[p]);
			z=1ll*z*qpow(2,l)%mod;
			
			for(int p=0;p<n;++p)if((1<<p)&j)
				z=1ll*z*(qpow(2,__builtin_popcount(k&c[p]))+mod-1)%mod;
		//	printf("<%d,%d>",j,z);
			dp[i]=(dp[i]+z)%mod;
			if(!j)break;
		}
	//	printf("[%d:%d]",i,dp[i]);
	}
	printf("%d",(qpow(2,m)-dp[(1<<n)-1]+mod)%mod);
}

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

int plu(int n){
    if(n<0) return (-1)*n;
    else return n;
}
int main(){
    const ll INF=99999;
    int x,n;
    cin>>x>>n;
    vector<int>p(n);
    vector<int>q(110);
    if(n==0){
         cout<<x<<endl;
         return 0;
    }
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    int k=-2;
    rep(i,104){
        k++;
        bool ok=false;
        rep(j,n){
            if(k==p[j]){
                ok=true;
                break;
            }
        }
        if(!ok)q[i]=k;

    }
    int ans=INF;
    //reverse(q.begin(),q.end());
   // rep(i,q.size()) cout<<q[i]<<" ";
    rep(j,q.size()){
        int cnt=plu(q[j]-x);
        ans=min(ans,cnt);
    }
    rep(i,q.size()){
        if(x+ans==q[i]){
            cout<<x+ans<<endl;
            return 0;
        }
        else if(x-ans==q[i]){
            cout<<x-ans<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;


int main(){
  int data[10];
  string s;cin>>s;
  for(int i=0;i<10;i++){
    data[i]=0;
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      data[i]=1;
    }
  }
  int ans=0;
  int max=0;
  for(int i=0;i<10;i++){
    if(data[i]==1){
      ans++;
      if(max<ans){
        max=ans;
      }
    }
    else{
      ans=0;
    }
  }
  cout<<max<<endl;
}

Measured memory_bytes: 256
a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

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

int main(int argc, char const *argv[])
{
	int m1,d1,m2,d2;
	while(~scanf("%d %d",&m1,&d1)){
		scanf("%d %d",&m2,&d2);
		if ((d2-d1)==1)
		{
			printf("0\n");
		}
		else{
			printf("1\n");
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); 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; }
const ll INF = 1LL << 60;

class Comp{
    public:
    bool operator()(const pair<ll,int> a, const pair<ll,int> b) const{
        return a.second < b.second;
    }
};
int main(){
    int n;
    ll p;
    cin >> n >> p;
    vector<pair<ll,int>> factor;
    for(ll i=2;i*i<=p;i++){
        int ct = 0;
        while(p%i==0){
            p/=i;
            ct++;
        }
        if(ct) factor.emplace_back(i,ct);
    }
    if(p>1) factor.emplace_back(p,1);
    
    sort(factor.begin(),factor.end(),Comp());
    ll ans = 1;
    for(auto f : factor){
        while(f.second>=n){
            f.second-=n;
            ans*=f.first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：円が範囲内か判別する*/

#include<stdio.h>

int main(void)
{
    int W, H, x, y, r;      //出力

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);        //入力

    if (0 <= (x - r) && W >= (x + r) && 0 <= (y - r) && H >= (y + r))       //円内か判別
    {
        printf("Yes\n");        //出力
    }

    else
    {
        printf("No\n");        //出力
    }

    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

// Combination
void COMinit(vector<int64_t>& fac, vector<int64_t>& finv, vector<int64_t>& inv) {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int32_t i = 2; i < (int32_t)fac.size(); i++){
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
  }
  return;
}

int64_t COM(int32_t n, int32_t k, vector<int64_t>& fac, vector<int64_t>& finv) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> fac(2*n, 0);
  vector<int64_t> finv(2*n, 0);
  vector<int64_t> inv(2*n, 0);
  COMinit(fac, finv, inv);

  int64_t res = 0;
  if (k < n) {
    res = 1;
    for (int64_t i = 1; i <= k; i++) {
      int64_t cmb_empty = COM(n, i, fac, finv);
      cmb_empty %= MOD;
      int64_t a = n - i;
      int64_t H = COM(a + i - 1, i, fac, finv);
      H %= MOD;
      res += (H * cmb_empty) % MOD;
      res %= MOD;
    }
  } else {
    res = COM(2*n - 1, n, fac, finv);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 9600
ary = gets.split.map(&:to_i)
width = ary[0]
height = ary[1]
x = ary[2]
y = ary[3]
r = ary[4]

if x > 0 && y > 0
  if (x + r <= width && y + r <= height)
    puts "Yes"
  else
    puts "No"
  end
  
else
  puts "No"
end

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
vector<int> n;
int f[70][2][2][2];
int calc(int x, int jin, int onu, int onv) {
	if (x < 0) return jin == 0;
	int &ans = f[x][jin][onu][onv];
	if (ans != -1) return ans;
	ans = 0;
	for (int a = 0; a <= 1; ++ a) {
		for (int b = 0; b <= 1; ++ b) {
			if (b > a) continue;
			for (int c = 0; c <= 1; ++ c) {
				if (onu && (a ^ b) > n[x]) continue;
				if (((a + b + c) >> 1) != jin) continue;
				if (onv && ((a + b + c) & 1) > n[x]) continue;
				//if (x == 1) printf("a=%d b=%d c=%d  += %d\n", a, b, c, calc(x - 1, c, onu && (a ^ b) == n[x], onv && ((a + b + c) & 1) == n[x]));
				(ans += calc(x - 1, c, onu && (a ^ b) == n[x], onv && ((a + b + c) & 1) == n[x])) %= MOD;
			}
		}
	}
	//printf("%d %d %d %d = %d\n", x, jin, onu, onv, ans);
	return ans;
}
/*int calc2(int x, int jin, int onu, int onv) {
	if (x < 0) return jin == 0;
	int &ans = f[x][jin][onu][onv];
	if (ans != -1) return ans;
	ans = 0;
	for (int a = 0; a <= 1; ++ a) {
		int b = a;
			for (int c = 0; c <= 1; ++ c) {
				if (onv && (a ^ b) > n[x]) continue;
				if (((a + b + c) >> 1) != jin) continue;
				if (onu && ((a + b + c) & 1) > n[x]) continue;
				(ans += calc(x - 1, c, onu && (a ^ b) == n[x], onv && ((a + b + c) & 1) == n[x])) %= MOD;
			}
	}
	return ans;
}*/
int main() {
	long long n;
	cin >> n;
	while (n) {
		::n.push_back(n & 1);
		n >>= 1;
	}
	memset(f, -1, sizeof(f));
	int ans = calc((int) ::n.size() - 1, 0, 1, 1);
	/*memset(f, -1, sizeof(f));
	cout << ans << endl;
	(ans += calc2((int) ::n.size() - 1, 0, 1, 1)) %= MOD;
	cout << ans << endl;
	ans = 1LL * ans * (MOD + 1) / 2 % MOD;*/
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)

using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> dp(n+1, INF);
  dp[0] = 0;

  reps1(i, n+1) {
    chmin(dp[i], dp[i-1] + 1);
    for (int j=6; i-j >= 0; j *= 6) {
      chmin(dp[i], dp[i-j] + 1);
    }

    for (int j=9; i-j >= 0; j *= 9) {
      chmin(dp[i], dp[i-j] + 1);
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3928
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
t = [tuple(map(int, input().split())) for _ in range(N)]
t.sort()
dp = [0] * (T + 1)
for a, b in t:
  for i in range(T - 1, -1, -1):
    if i + a < T: dp[i + a] = max(dp[i + a], dp[i] + b)
    else: dp[-1] = max(dp[-1], dp[i] + b) 
print(max(dp))

Measured memory_bytes: 74664
import math
#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())
D = []
c = 0
d = 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0] == a[1]:
        if c == 0:
            c+= 1
        elif c == 1:
            c+= 1
        elif c == 2:
            d = 1
    else:
        if c > 0:
            c = 0
if d == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

vector<vector<ll>> g(55);
ll n, m;
map<pair<ll, ll>, ll> mp;

ll dfs(ll a, ll b, ll p = -1) {
    ll res = 0;
    for (auto u : g[a])
        if (u != p) {
            if (u == b) {
                res = 1LL << mp[{a, b}];
                return res;
            }
            res = dfs(u, b, a);
            if (res) {
                res |= 1LL << mp[{a, u}];
                break;
            }
        }
    return res;
}

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

    cin >> n;
    rep(i, 1, n) {
        ll a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        mp[{a, b}] = mp[{b, a}] = i - 1;
    }
    cin >> m;
    vector<ll> y(m);
    rep(i, 0, m) {
        ll u, v;
        cin >> u >> v;
        y[i] = dfs(u, v);
    }
    ll ans = 1LL << (n - 1);
    for (ll b = 1; b < (1 << m); b++) {
        ll d = 0;
        ll c = 1;
        rep(i, 0, m) if ((b >> i) & 1) {
            c *= -1;
            d |= y[i];
        }
        ans += c * (1LL << (n - 1 - __builtin_popcountll(d)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
int arr[N+2],mp1[N+2],mp2[N+2],mx1[N+2],mx2[N+2],ans;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  for(int i=1;i<=n;i++)cin>>arr[i];
  for(int i=1;i<=n;i+=2)mp1[arr[i]]++;
  for(int i=2;i<=n;i+=2)mp2[arr[i]]++;

  for(int i=1;i<=N;i++)
    mx1[i]=max(mx1[i-1],mp2[i]);
  for(int i=N;i>=1;i--)
    mx2[i]=max(mx2[i+1],mp2[i]);
  for(int i=1;i<=N;i++)
    ans=max(ans,mp1[i]+max(mx1[i-1],mx2[i+1]));
  cout<<n-ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 2e5 + 10; 
vector<int> adj[N]; 

int dfs(int u, int par = -1) {
	int g = 0; 
	for(int v : adj[u]) if(v - par) 
		g ^= dfs(v, u) + 1; 
	return g; 
}
int main(int argc, char const *argv[]) {
	int n; cin >> n; 
	for(int i = 1; i < n; i++) {
		int u, v; 
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}	
	puts(dfs(1) ? "Alice" : "Bob"); 
}

Measured memory_bytes: 12800
H1,M1,H2,M2,K = map(int,input().split())
T1 = 60 * H1 + M1
T2 = 60 * H2 + M2
W = T2 - T1
if  W >= 0:
    print(W - K)
else:
    print(1440 - T1 + T2 - K)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int ans=1;
	for(int i=1;i<n;++i){
		bool flg=true;
		rep(j,i){
			if(a.at(j)>a.at(i)) flg=false;
		}
		if(flg) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)

Measured memory_bytes: 6724
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main(int argc, char const* argv[]) {
	int N;
	scanf("%d", &N);
	string S[100];
	set<string> arare;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		// cout << S[i] << endl;
		arare.insert(S[i]);
	}
	// cout << arare.size() << endl;
	printf(arare.size() == 4 ? "Four\n" : "Three\n");

	return 0;
}


Measured memory_bytes: 3756
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }

    vector<vector<ll>> doubling;
    doubling.push_back(a);

    ll now = 2;
    while(now <= 1e18){
        vector<ll> next(n, 0);
        vector<ll> tmp = doubling.back();
        for(int i = 0; i < n; i++){
            next[i] = tmp[tmp[i]];
        }
        doubling.push_back(next);
        now *= 2;
    }
    now = 0;
    for(ll i = doubling.size() - 1; i >= 0; i--){
        if(k & (1LL << i)){
            now = doubling[i][now];
        }
    }
    cout << now + 1 << endl;
}


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

int main() {
int n,x,t;
int nx;
double nx_amari;
int nxt;
cin >> n >> x >> t;
nx = n/x;
nxt = nx * t;
nx_amari = n % x;
if(nx_amari != 0){
    nxt += t;
}
 cout << nxt << endl;
} 

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
signed main(){
  int ans=0,count=1,sum=0;
  string S;
  cin>>S;
  char memory=S[0],key='<';
  rep(i,1,S.size()){
    if(S[i]==memory)
      count++;
    else{
      if(memory!=key)
        ans+=max(count,sum);
      ans+=count*(count-1)/2;
      memory=S[i];
      sum=count;
      count=1;
      }
    }
  ans+=count*(count-1)/2;
  if(memory!=key)
    ans+=max(count,sum);
  else
    ans+=count;
  cout<<ans<<endl;
  }

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  if (A * N  > B) {
    cout << B << endl;
  } else if (A * N == B) {
    cout << B << endl;
  } else if (A * N < B) {
    cout << A * N << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    reverse(all(a));
    ll ans = 0;
    n--;
    rep(i,(n-1)/2)ans += 2*a[i+1];
    ans += a[0];
    if(n % 2 == 0)ans += a[(n-1)/2+1];
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

    int n, at;
    cin >> n;
    set<int> a, d;
    for(int i = 0; i < n; ++i) {
        cin >> at;
        if(a.find(at) != a.end()) d.insert(at);
        a.emplace(at);
    }

    int ans = 0, p;

    while(!a.empty()) {
        p = *a.begin();
        if(d.find(p) == d.end()) ans++;
        if(false) {
            for(int b: a) {
                if(b % p == 0) {
                    a.erase(b);
                }
            }
        } else {
            int m = *a.rbegin();
            for(int i = p; i <= m; i += p) {
                if(a.find(i) != a.end()) a.erase(i);
            } 
        }
    }

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

    return 0;
}


Measured memory_bytes: 13012
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a,b;
		a = sc.next();
		b = sc.next();
		String c = a + b;
		int d = Integer.parseInt(c);
		double e = Math.floor( Math.sqrt((double)d) );
		if(e * e == (double)d)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 23764
def f(n,d):
    t=[f(i,d+1)+1 for i in l[n][1]]
    h=0 if t==[] else max(t)
    c[n][3:3]=[len(l[n][1]),d,h,"root" if d<1 else "leaf" if h<1 else "internal node"]
    return h
m=input()
c=[0]*m
l=sorted([map(int,raw_input().split()) for _ in range(m)])
for i in l:
    n,a,b=i
    if a>=0:c[a]=[a,n,b]
    if b>=0:c[b]=[b,n,a]
    i[1:]=[[j for j in i[1:] if j>=0]]
n=c.index(0)
c[n]=[n,-1,-1]
f(n,0)
for i in c:print "node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(*i)

Measured memory_bytes: 4272
#include<iostream>
using namespace std;
int main(){
  int h=0,m=0,s=0;
  cin>> s;
  while(s>=3600){
      h++;
      s-=3600;
    }
  while(s>=60){
      m++;
      s-=60;
    }
  cout<< h<<":"<<m<<":"<<s<< endl;
  return 0;
}

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

struct graph {
    vector<vector<int>> gph;
    vector<int> indeg, outdeg;
    int vertex;
    graph(int N) : vertex(N) {
        gph.resize(vertex);
        indeg.resize(N);
        outdeg.resize(N);
    }
    // 有向グラフの構築
    void directed_update(int in, int out) {
        gph.at(in).emplace_back(out);
        indeg.at(in)++;
        outdeg.at(out)++;
    }
    // 無向グラフの構築
    void undirected_update(int x, int y) {
        gph.at(x).emplace_back(y);
        gph.at(y).emplace_back(x);
    }
};

class DAG {
  private:
    bool done_tsort;
    vector<int> used;
    graph g;

  public:
    vector<int> tsorted;
    vector<vector<int>> parents;
    DAG(const graph &_g)
        : done_tsort(false), g(_g), used(_g.outdeg), parents(_g.vertex) {
        tsorted.reserve(g.vertex);
    }
    void tsort() {
        if (done_tsort)
            return;
        queue<int> que;
        for (int i = 0; i < g.vertex; i++) {
            if (used[i] == 0)
                que.push(i);
        }
        while (!que.empty()) {
            int now = que.front();
            que.pop();
            tsorted.emplace_back(now);
            for (auto &&i : g.gph[now]) {
                used[i]--;
                parents[i].emplace_back(now);
                if (used[i] == 0)
                    que.push(i);
            }
        }
        return;
    }
    bool is_DAG() {
        if (done_tsort)
            return tsorted.size() == g.vertex;
        tsort();
        return is_DAG();
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    auto g = graph(N);

    for (size_t i = 0; i < N + M - 1; i++) {
        int a, b;
        cin >> a >> b;
        g.directed_update(a - 1, b - 1);
    }
    auto dag = DAG(g);
    dag.tsort();
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        int now = dag.tsorted[i];
        int mx  = dag.parents[now].size() == 0
                     ? -1
                     : dag.parents[now][dag.parents[now].size() - 1];
        ans[now] = mx + 1;
    }
    for (auto &&i : ans) {
        cout << i << '\n';
    }

    return 0;
}

Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> l(m),r(m),imos(n+2,0);
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
        imos[l[i]]++;
        imos[r[i]+1]--;
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum+=imos[i];
        imos[i]=sum;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if(imos[i]==m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
N , M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

match = [2,5,5,4,5,6,3,7,6]

dp = [-float('inf')] * (N + 1)

dp[0] = 0
for i in range(1, N+1) :
    maxDigit = -float('inf')
    for a in A :
        if i - match[a - 1] >= 0 :
            maxDigit = max(maxDigit, dp[i - match[a - 1]] + 1)
    dp[i] = maxDigit

maxDigit = dp[-1]

r = N

for _ in range(maxDigit) :
    for a in A :
        if r - match[a - 1] < 0 or r < 0 :
            continue
        if dp[r - match[a - 1]] == dp[r] - 1 :
            print(a, end='')
            r -= match[a - 1]
            break

print('')

Measured memory_bytes: 4200
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    string S, T;  cin >> S >> T;
    int N = S.length(), M = T.length();
    for(int i=N-M; i>=0; i--){
        bool valid = true;
        for(int j=0; j<M; j++){
            if(S[i+j] != '?' && S[i+j] != T[j]){
                valid = false;
                break;
            }
        }
        if(valid){
            string ans = "";
            ans += S.substr(0, i);
            ans += T;
            ans += S.substr(M+i);
            for(int j=0; j<ans.length(); j++){
                if(ans[j] == '?')
                    ans[j] = 'a';
            }
            cout << ans << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> 
void dbg_out(Head H, Tail... T) { 
    cerr << ' ' << H;
     dbg_out(T...); 
}
#define dbg(...) cerr << '(' << #__VA_ARGS__ << ')'<<':', dbg_out(__VA_ARGS__)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define vi vector<int>
#define vll vector<ll>
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>n;
    vi prime(1e6,0),arr(n);
    for(auto &u : arr)cin>>u;
    int cnt=0,gcd=arr[n-1];
    for(i=n-1;i>=0;i--){
        bool coprime=true;
        gcd=__gcd(gcd,arr[i]);
        for(j=2;j*j<=arr[i];j++){
            if(arr[i]%j==0){
                if(prime[j])coprime=false;
                prime[j]=1;
            }
            while(arr[i]%j==0)arr[i]/=j;
        }
        if(arr[i]>1 and prime[arr[i]])coprime=false;
        prime[arr[i]]=1;
        if(coprime)cnt++;
    }
    if(cnt==n)printf("pairwise coprime\n");
    else if(gcd==1)printf("setwise coprime\n");
    else printf("not coprime\n");
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 11172
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
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++)

int main(){
  int n;
  cin >> n;
  int a = 0;
  int sum = 0;
  int k[n];
  rep(i , n){
    cin >> k[i];
    if(k[i]%2 == 0){
      sum++;
      if(k[i]%3 == 0 || k[i]%5 == 0)a++;
    }
  }
  if(a == sum)cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int l;
	cin>>l;
	cout<<fixed<<setprecision(10)<<(l/3.0)*(l/3.0)*(l/3.0);
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n,k;

int main(){
  cin >> n >> k;
  if(n<=k){cout << min(n,k-n);return 0;}
  n%=k;
  cout << min(n,k-n);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a[200];
	char d[200][30];
	scanf("%d%*c", &n);
	for(int i=0;i<n;i++) {
		int t, j=0;
		scanf("%d%*c", &t);
		a[i] = t;
		while(t > 0) {
			d[i][j] = t % 2;
			t /= 2;
			j++;
		}
	}

	int i=0, s=0;
	while(1) {
		for(int j=0;j<n;j++) {
			s += d[j][i];
		}
		if(s > 0) break;
		i++;
	}
	printf("%d", i);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long H; cin >> H;

    if(H%2 != 0 && H != 1){
        H--;
    }

    long long ans = 0;
    long long cnt = 1;

    while(H != 0){
        ans += cnt;
        cnt *= 2;
        H /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def bubbleSort(matrix, N):
  flag = 1
  count = 0
  j = 0
  while flag == 1:
    flag = 0
    for i in reversed(range(j + 1, N)):
      if matrix[i] < matrix[i-1]:
        matrix[i], matrix[i-1] = matrix[i-1], matrix[i]
        flag = 1
        count += 1
    j += 1

  return count

n = int(input())
A = list(map(int, input().split()))
count = bubbleSort(A, n)
print(" ".join(map(str, A)))
print(count)



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
constexpr ll INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    if(n%2==0) {
        ll sum0 = 0, sum1 = 0;
        for(ll i=0; i<n; i+=2) {
            sum0 += a[i];
            sum1 += a[i+1];
        }
        vector<vector<ll>> dp(n, vector<ll>(2, -INF));
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        REP(i, n) REP(j, 2) {
            if(i>=2) chmax(dp[i][j], dp[i-2][j] + a[i]);
            if(i>=3 && j>=1) chmax(dp[i][j], dp[i-3][j-1] + a[i]);
        }
        cout << max({sum0, sum1, dp[n-2][1], dp[n-1][1]}) << endl;
    } else {
        ll sum0 = 0;
        for(ll i=1; i<n; i+=2) sum0 += a[i];
        ll sum1 = 0, mi = INF;
        for(ll i=0; i<n; i+=2) sum1 += a[i], chmin(mi, a[i]);
        sum1 -= mi;
        vector<vector<ll>> dp(n, vector<ll>(3, -INF));
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        REP(i, n) REP(j, 3) {
            if(i>=2) chmax(dp[i][j], dp[i-2][j] + a[i]);
            if(i>=3 && j>=1) chmax(dp[i][j], dp[i-3][j-1] + a[i]);
        }
        cout << max({sum0, sum1, dp[n-1][2], dp[n-2][2]}) << endl;
    }

    return 0;
}

Measured memory_bytes: 15856
#include <iostream>

using namespace std;

int main()
{
    int x1,x2,y1,y2;
    cin >>x1>>y1>>x2>>y2;
    int x=x2-x1; int y=y2-y1;
    cout <<x2-y<< " "<<y2+x<<" "<<x1-y<<" "<<y1+x;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
ll a[114], b[114], c[114];
signed main() {
	ll w, h, n;
	cin >> w >> h >> n;
	rep(i, n)cin >> a[i] >> b[i] >> c[i];
	ll xstart = 0, xend = w, ystart = 0, yend = h;
	rep(i, n) {
		if (c[i] == 1)xstart = max(xstart, a[i]);
		if (c[i] == 2)xend = min(xend, a[i]);
		if (c[i] == 3)ystart = max(ystart, b[i]);
		if (c[i] == 4)yend = min(yend, b[i]);
	}
	cout << max((ll)0, xend - xstart)*max((ll)0, yend - ystart) << endl;
}


Measured memory_bytes: 256
s = input()
if s[0] != 'A':
    print('WA')
    exit()

if s.count('C', 2, -1) != 1:
    print('WA')
    exit()

s2 = s[1:].replace('C', '')
if not s2.islower():
    print('WA')
    exit()

print('AC')





Measured memory_bytes: 2940
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var s = lines[0].split("");
    var t = lines[1].split("");

    s.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));
    t.sort((a, b) => b.charCodeAt(0) - a.charCodeAt(0));

    for (var i = 0; i < Math.min(s.length, t.length); i++) {
        if (s[i].charCodeAt(0) > t[i].charCodeAt(0)) { console.log("No"); return (0) }
        if (s[i].charCodeAt(0) < t[i].charCodeAt(0)) { console.log("Yes"); return (0) }
    }
    if (s.length < t.length) { console.log("Yes"); }
    else { console.log("No"); }
});

Measured memory_bytes: 7628
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 

int main() {
	
string s;
cin>>s;
int p=0;
for(int i=0;i<2;i++)
{
    if(s[i]!=s[i+1])
    p=1;
}
if(p==1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500001

int A[N],H;

int left(int i){return 2*i;}
int right(int i){return 2*i+1;}


void exchange(int i,int j)
{
  int temp;
  temp=A[i];
  A[i]=A[j];
  A[j]=temp;
}

void maxHeapify(int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=H&&A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=H&&A[r]>A[largest])
    largest=r;

  if(largest!=i){
    exchange(i,largest);
    maxHeapify(largest);
  }
  
}


void buildMaxHeap(){
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(i);
}




int main(){
 int i;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  
  return 0;
}



Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int H,A;cin >> H >> A;
  int ans = 0;
  if(H%A == 0) ans = H / A;
  else ans = H / A + 1;
  cout << ans << endl;
	return 0;
}



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

using namespace std;
stack <long long int> t,t2;
long long int n,o=0,u=0,k=0,sum=0,a[300000],sa[300000],ta[300000],x=0;
int main()
{
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i=1; i<=n; i++)
        {
                cin >> a[i];
                if(!t.empty())
                {
                        x=a[i];
                        k=0;
                        while(!t.empty() && t.top()>x)
                        {
                                o=t.top();
                                u=t2.top();
                                ta[u]=k+1;
                                k+=sa[u];
                                t.pop();
                                t2.pop();
                        }
                        sa[i]=k+1;
                        t.push(a[i]);
                        t2.push(i);
                }
                else
                {
                        sa[i]=1;
                        t.push(a[i]);
                        t2.push(i);
                }
        }
        k=0;
        while(!t.empty())
        {
                o=t.top();
                u=t2.top();
                ta[u]=k+1;
                k+=sa[u];
                t.pop();
                t2.pop();
        }
        for(int i=1; i<=n; i++)
        {
                sum+=sa[i]*ta[i]*a[i];
        }
        cout << sum;
}


Measured memory_bytes: 8048