akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s,t;
int main(){
	cin>>s>>t;
	cout<<t<<s; 
	re 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n,k,a[200009],i;
#define rp for(i=0;i<n;i++)
int main(){
  int n,k,a[200009];
  cin>>n>>k;
  if(k>=42||k>=n){rp cout<<n<<' ';return 0;}
  rp cin>>a[i];
  while(k--){
    int b[200009]={0},s=0;
    rp{
      b[(i-a[i]>0?i-a[i]:0)]++;
      b[(n-1>i+a[i]?i+a[i]:n-1)+1]--;
    }
    rp{s+=b[i];a[i]=s;}
  }
  rp cout<<a[i]<<' ';
  return 0;
}

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

long long N, H, a[100009], b[100009], maxn, ret = (1LL << 60); vector<long long>P;

long long solve(long long p, long long q) {
	if (p < 0)return 0;
	return (p + q - 1) / q;
}

int main() {
	cin >> N >> H;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i]; P.push_back(b[i]);
		maxn = max(maxn, a[i]);
	}
	sort(P.begin(), P.end()); reverse(P.begin(), P.end());
	long long L = 0;
	for (int i = 0; i <= N; i++) {
		ret = min(ret, i + solve(H - L, maxn));
		if (i != N) L += P[i];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

// common
#define X real()
#define Y imag()

using Vector2 = complex<double>;
using Line = pair<Vector2, Vector2>;
using Segment = pair<Vector2, Vector2>;
const double EPS = 1e-10;
const double PI = 3.14159265359;

bool equals(double a, double b){
    if(abs(a - b) < EPS){
        return true;
    }
    else{
        return false;
    }
}

// struct

struct Circle{
    Vector2 c;
    double r;
    Circle(Vector2 c, double r){
        this->c = c;
        this->r = r;
    }
};

// Vector2
Vector2 polar(double rad){
    return Vector2(cos(rad), sin(rad));
}

double abs(Vector2 v){
    return sqrt(norm(v));
}

double dot(Vector2 a, Vector2 b){
    return (a.X * b.X + a.Y * b.Y);
}

double cross(Vector2 a, Vector2 b){
    return (a.X * b.Y - a.Y * b.X);
}

pair<Vector2, Vector2> crossPoints(Circle c1, Circle c2){
    double d = abs(c1.c - c2.c);
    double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
    double t = arg(c2.c - c1.c);
    return make_pair(c1.c + c1.r * polar(t + a), c1.c + c1.r * polar(t - a));
}

int main(){

    int cx1, cy1, r1;
    cin >> cx1 >> cy1 >> r1;
    Circle c1(Vector2(cx1, cy1), r1);
    
    int cx2, cy2, r2;
    cin >> cx2 >> cy2 >> r2;
    Circle c2(Vector2(cx2, cy2), r2);

    auto ans = crossPoints(c1, c2);
    Vector2 ansMin, ansMax;
    if(equals(ans.first.X, ans.second.X)){
        if(ans.first.Y < ans.second.Y){
            ansMin = ans.first;
            ansMax = ans.second;
        }
        else{
            ansMin = ans.second;
            ansMax = ans.first;
        }
    }
    else{
        if(ans.first.X < ans.second.X){
            ansMin = ans.first;
            ansMax = ans.second;
        }
        else{
            ansMin = ans.second;
            ansMax = ans.first;
        }
    }

    cout << fixed << setprecision(8) << ansMin.X << " " << ansMin.Y << " " << ansMax.X << " " << ansMax.Y << endl;

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<class V> struct MaxFlow { // Dinic O(V^2E)
    struct edge { int to, reve; V cap; edge(int t, int r, V c) : to(t), reve(r), cap(c) {} };
    int MV; vector<vector<edge>> E; vector<int> itr, lev;
    MaxFlow(int n) { init(n); } MaxFlow() { }
    void init(int n){MV=n;itr=vector<int>(MV),lev = vector<int>(MV); E = vector<vector<edge>>(MV); }
    void add_edge(int x, int y, V cap, bool undir = false) {
        E[x].push_back(edge(y, (int)E[y].size(), cap));
        E[y].push_back(edge(x, (int)E[x].size() - 1, undir ? cap : 0));}
    void bfs(int cur) {rep(i, 0, MV) lev[i] = -1; queue<int> q; lev[cur] = 0; q.push(cur);
        while (q.size()) {int v = q.front(); q.pop();
        for (auto e : E[v]) if (e.cap>0 && lev[e.to]<0) lev[e.to] = lev[v] + 1, q.push(e.to);}}
    V dfs(int from,int to,V cf){if(from==to)return cf;for(; itr[from]<E[from].size(); itr[from]++) {
        edge* e = &E[from][itr[from]]; if (e->cap>0 && lev[from]<lev[e->to]) {
        V f = dfs(e->to, to, min(cf, e->cap));if(f>0){e->cap-=f;E[e->to][e->reve].cap+=f;return f; }}
        } return 0;}
    V maxflow(int from, int to) {V fl = 0, tf;while (1) {bfs(from); if (lev[to]<0) return fl;
        rep(i,0,MV)itr[i]=0; while ((tf = dfs(from, to, numeric_limits<V>::max()))>0) fl += tf;}}};
vector<int> enumdiv(int n) { 
    vector<int> S;
    for (int i = 1; 1LL*i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
    sort(S.begin(), S.end());
    return S;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




typedef long long ll;
int N, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i + 1];

    MaxFlow<ll> mf;
    mf.init(N + 10);

    ll MA = INT_MAX;

    int s = 0, t = N + 1;
    rep(i, 1, N + 1) mf.add_edge(s, i, MA - 0);
    rep(i, 1, N + 1) mf.add_edge(i, t, MA - A[i]);

    rep(i, 1, N + 1) {
        auto e = enumdiv(i);
        fore(j, e) if (i != j) mf.add_edge(i, j, MA);
    }

    ll ans = MA * N - mf.maxflow(s, t);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(1){
    if(x -> left == NIL) break;
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(1){
    if(x -> right == NIL) break;
    x = x-> right;
  }
  return x;
  

}

Node treeSearch(Node u, int k){
  Node a,b;
  
  if(u == NIL) return u;
  if(k == u -> key) return u;

  a = treeSearch(u->left,k);
  b = treeSearch(u->right,k);
  if(k < u->key) return a;
  else return b;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(1){
    if(y == NIL && x != y->right) break;
      x = y;
      y = y->parent;
    }

  return y;  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == NIL) y = z;
  if(x->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(1){
    if(x == NIL) break;
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  
    z->parent = y;
    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else (y->right = z);
  }




void inorder(Node u){
  if(u == NIL) return;
  inorder(u -> left);
  printf(" %d", u -> key);
  inorder(u -> right);
  
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d", u -> key);
  preorder(u -> left);
  preorder(u -> right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25128
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cassert>//1回カウントした交点を2度カウントしない要潤
#define EPS 1e-10
#define F first
#define S second
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
using namespace std;
struct P{
  double x,y;
  P(double x=0,double y=0):x(x),y(y){}
  P operator + (P p){return P(x+p.x,y+p.y);}
  P operator - (P p){return P(x-p.x,y-p.y);}
  P operator * (P p){return P(x*p.x,y*p.y);}
  P operator / (P p){return P(x/p.x,y/p.y);}

  bool operator == (const P &p) const{
    return (fabs(x-p.x) < EPS && fabs(y-p.y) < EPS);
  }

  bool operator < (const P &p) const{
    return x!=p.x?fabs(x-p.x)<EPS:fabs(y-p.y)<EPS;
  }

};

typedef pair<P,P> Segment;

double dot(P a,P b){
  return a.x*b.x+a.y*b.y;
}

double cross(P a,P b){
  return a.x*b.y-a.y*b.x;
}

double norm(P p){
  return p.x*p.x+p.y*p.y;
}

double abs(P p){
  return sqrt(norm(p));
}

int ccw(P p,P q,P r){
  P a = q-p;
  P b = r-p;
  if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS)return CLOCKWISE;
  if(dot(a,b) < -EPS)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool isIntersect(P p1,P p2,P p3,P p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0 && ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0);
}


P crosspoint(P p1,P p2,P p3,P p4) {
  double A = cross(p2 - p1, p4 - p3);
  double B = cross(p2 - p1, p2 - p3);
  //if (abs(A) < EPS && abs(B) < EPS) return p3; 
  //if (abs(A) < EPS) assert(false); 
  P pro = p4-p3;
  pro.x = pro.x*(B/A);
  pro.y = pro.y*(B/A);
  return p3 + pro;
}




int main(){
  int n,xx,yy,xxx,yyy,field;
  vector<Segment> pos;
  Segment pesh;//真夜中の要潤
  vector<P> exist;
  
  P xp; //x(corss)point

  while(cin >> n && n){
    field = 1;
    pos.clear();
    for(int i=0;i<n;i++){
      cin >> xx >> yy >> xxx >> yyy;
      pesh.F.x = xx;pesh.F.y = yy;
      pesh.S.x = xxx;pesh.S.y = yyy;
      pos.push_back(pesh);
  
      int x_counter=0;
      bool new_x = true;
      exist.clear();
      for(int i=0;i<pos.size()-1;i++){
	new_x=true;
	if(isIntersect(pos[i].F,pos[i].S,pos[pos.size()-1].F,pos[pos.size()-1].S)){
	  xp = crosspoint(pos[i].F,pos[i].S,pos[pos.size()-1].F,pos[pos.size()-1].S);
	
	  if(100-fabs(xp.x) < EPS || 100-fabs(xp.y) < EPS)continue;	 
	
	  for(int j=0;j<exist.size();j++){
	   
	    if(exist[j]==xp){
	      new_x = false;
	      break;
	    }
	  }
	  if(new_x){
	    x_counter++;
	    exist.push_back(xp);
	  }
	}
      }
      field += x_counter+1;
    }
    cout << field << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    
    int n;
    string s,t;
    cin>>n>>s>>t;
    int m=0;
    for(int i=0;i<n;++i)
    {
        bool flag=true;
        for(int j=0;j<i+1;++j)
        {
            if(s[n-1-j]!=t[i-j])
            {
                flag=0;
                break;
            }
        }
        if(flag==1)
        m=i+1;
    }
    cout<<2*n-m;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string S, dream = "dream", dreamer = "dreamer", erase = "erase", eraser = "eraser";
	vector<bool> dp;

	cin >> S;
	dp.resize((int)S.size()+1, false);
	dp[0] = true;

	for(int i = 5; i <= (int)S.size(); i++){
		string check5 = "", check6 = "", check7 = "";
		if(dp[i-5]){
			check5 = S.substr(i-5,5);
			if(check5 == dream || check5 == erase)
				dp[i] = true;
		}
		if(i >= 6 && dp[i-6]){
			check6 = S.substr(i-6,6);
			if(check6 == eraser)
				dp[i] = true;
		}
		if(i >= 7 && dp[i-7]){
			check7 = S.substr(i-7,7);
			if(check7 == dreamer)
				dp[i] = true;
		}

	}

	if(dp[(int)S.size()])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	a[i]/=2;
    }
    ll maki=a[0];
    ll num=0,sum;
    while(maki%2==0)maki/=2,num++;
    sum=num;
    for(int i=1;i<n;i++){
    	maki=a[i];
    	num=0;
    	while(maki%2==0)maki/=2,num++;
    	if(num!=sum){
    		cout <<0<<endl;
    		return 0;
    	}
    }
    ll g=1;
    for(int i=0;i<n;i++){
    	g=(g*a[i])/__gcd(g,a[i]);
    	if(g>m){
    		cout<<0<<endl;
    		return 0;
    	}
    }
    m/=g;
    cout << (m+1)/2 <<endl;
    return 0;
}


Measured memory_bytes: 1024
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,R,S,P; string T;
	cin>>N>>K>>R>>S>>P>>T;
	int ans = 0;
	for(int i=0; i<N; ++i){
		if(T[i] == 'r') ans += P;//win:r->p
		else if(T[i] == 's') ans += R;//win:s->r
		else ans += S;//win:p->s

		if(i-K < 0) continue;

		if(T[i-K] == T[i]){//fore
			if(T[i] == 'r') ans -= P;//win:r->p -> draw: -p
			else if(T[i] == 's') ans -= R;//win:s->r -> draw: -r
			else ans -= S;//win:p->s -> draw: -s

			if(i+K >= N) continue;

			if(T[i] == T[i+K])//back
				if(T[i] == 'r') T[i] = 's';//lose:r->s
				else if(T[i] == 's') T[i] = 'p';//lose:s->p
				else T[i] = 'r';//lose:p->r
		}
	}
	cout<< ans <<endl;
}

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

int main() {
    int N;
    cin>>N;
    vector<int> H(N, 0);
    bool dec = false;
    REP(i, 0, N) cin >> H[i];
    
    string judge = "Yes";
    REP(i, 0, N-1){
        if (H[i] - H[i+1] >= 2) judge = "No";
        if(H[i] > H[i+1]){
            if(dec) judge = "No";
            else dec = true;
        }else if(H[i] < H[i+1]) dec = false;
    }
    cout << judge << endl;
}

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

using namespace std;

int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) A[i] = 1 << (S[i] - 'a');
  while (Q--) {
    int q;
    cin >> q;
    if (q == 1) {
      int i;
      char c;
      cin >> i >> c;
      A[i - 1] = 1 << (c - 'a');
    } else {
      int l, r;
      cin >> l >> r;
      int t = 0;
      for (int i = l - 1; i < r; ++i) t |= A[i];
      cout << __builtin_popcount(t) << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repd(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto& a:x)
#define all(c) c.begin(), c.end()
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX 100007
 
typedef vector<int> vi;
typedef pair<int,int> pii;


int32_t main()
{
  int n=3,val;
  vi v;
  rep(i,n)
  {
    cin>>val;
    v.pb(val);
  }
  sort(all(v));
  cout<<abs(v[2]-v[0]);
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
const int INF=INT_MAX;

int main()
{
	int n;cin>>n;
	int k;cin>>k;
	int arr[n];
	for (int i=0;i<n;i++)cin>>arr[i];
	
	int dp[n];
	for (int i=0;i<n;i++)dp[i]=INF;
	dp[0]=0;
	
	for (int i=0;i<n;i++)
	{
		for (int j=i-1;j>=i-k;j--)
		{
			if (j>=0)
				dp[i]=min(dp[i],abs(arr[j]-arr[i])+dp[j]);
		}
	}
	cout<<dp[n-1];
}




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

#define fo(i,a,b) for(i=a;i<=b;i++)

using namespace std;
#define ll long long
const int maxn=100000+10;
int x[maxn],xx[maxn],w[maxn];
int i,j,k,l,r,s,t,n,m;
ll c;

int read() {
  int ans = 0, c, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  do ans = ans * 10 + c - '0';
  while (isdigit(c = getchar()));
  return ans * f;
}
int main()
{
    n=read(),l=read(),t=read();
    fo(i,1,n)
        x[i]=read(),w[i]=read();
    fo(i,1,n)
    {
        if (w[i]==2) w[i]=-1;
        r=x[i]+w[i]*t;
        if (r>0) (c+=r/l)%=n;
        else if (r<0) (c+=(r+1)/l-1)%=n;
        xx[i]=(r%l+l)%l;
    }
    sort(xx+1,xx+n+1);
    c=(c+n)%n;
    fo(i,c+1,n)
        printf("%d\n",xx[i]);
    fo(i,1,c) printf("%d\n",xx[i]);
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
ll n,p=1000000007;
ll dp[3006][3006],sm[3006][3006];
char c[3006];
int main ()
{
  cin>>n;
  for(ll i=2;i<=n;i++)
  {
    cin>>c[i];
  }
  dp[1][1]=1;
  sm[1][1]=1;
  for(ll i=2;i<=n;i++)
  {
    for(ll j=1;j<=i;j++)
    {
      if(c[i]=='<')
      {
        dp[i][j]=sm[i-1][j-1]%p;
      }
      if(c[i]=='>')
      {
        dp[i][j]=(sm[i-1][i-1]-sm[i-1][j-1]+p)%p;
      }
    }
    for(ll j=1;j<=n;j++)
    {
      sm[i][j]+=sm[i][j-1]+dp[i][j];
      sm[i][j]%=p;
    }
  }
  cout<<sm[n][n];
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

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

void solve() {
  ll N;
  cin >> N;
  size_t m = 1000;
  for(ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      string s = to_string(N / i);  
      string t = to_string(i);
      m = min(m, max(s.size(), t.size()));
    }
  }
  cout << m << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h[] = new int[N];
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;

		for(int height:h) {
			if(height>=K) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 49844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <functional>
using ll = long long;
const ll mod = 1000000007;

using namespace std;

typedef std::pair<std::string,double> P;

struct less {
	bool operator()(const P& x, const P& y) const {
        if(x.second==y.second){
            return x.first < y.first;
        }
		return x.second > y.second;
	}
};

int main() {
    int N; cin >> N;
    vector<int> v;
    v.push_back(0);
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
    }
    v.push_back(0);
    int S=0;
    for(int i=0; i<v.size()-1; ++i){
        S +=abs(v[i+1]-v[i]);
    }
    for(int i=1; i<v.size()-1; ++i){
        cout << S + abs(v[i-1]-v[i+1]) - ( abs(v[i-1]-v[i])+abs(v[i]-v[i+1]))<< endl;
    }
    return 0;
    
}

Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int x,y;
	ll ans=0;
	cin>>x>>y;
	if(x==1 && y==1)
		ans+=400000;
	switch(x)
	{
		case 1:
		ans+=100000;
		case 2:
		ans+=100000;
		case 3:
		ans+=100000;
	}
	switch(y)
	{
		case 1:
		ans+=100000;
		case 2:
		ans+=100000;
		case 3:
		ans+=100000;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair



int main(){
    int N; cin>>N;
    ll a[N]; CINA(a,N); sort(a,a+N);
    ll temp = 0;
    int x = 0;
    REP(i,N-1){
        temp += a[i];
        if(temp*2<a[i+1]){
            x = i+1;
        }
    }
    cout << N - x << "\n"; 
}

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

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 500010
#define MOD 1000000007

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    string s;
    cin >> s;  

    for (int i = 0; i < s.size(); ++i)
    {
        s[i] = 'A' + ((s[i] - 'A' + n) % 26); 
    }

    cout << s;
    return 0;
}

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

int main(){
    vector<int> w(3);
    cin >> w[0] >> w[1] >> w[2];
    sort(w.begin(),w.end());
    if (w[0] == 5 && w[1] == 5 & w[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 X;
  cin >> X;
  if (30 <= X)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

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

    int64_t m = n + 1; // m >= 2
    int s[200], k = 0;
    int i0 = 100, i1 = 100;
    int64_t x = 1;
    int j;
    for (j = 63; j >= 0; j--) if (m >> j & 1) break;
    for (j--; j >= 0; j--) {
        x *= 2;
        s[i1++] = k++;
        if (m >> j & 1) {
            x += 1;
            s[--i0] = k++;
        }
    }
    if (n != x - 1) throw;

    cout << (i1 - i0) * 2 << '\n';
    for (int i = 0; i < i1 - i0; i++) {
        cout << i + 1 << " ";
    }
    for (int i = i0; i < i1; i++) {
        cout << s[i] + 1 << " \n"[i == i1 - 1];
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=105;
const int M=1e5+10;
ll w[N],v[N],dp[M];
int main()
{
	int n,W,i,j;
	scanf("%d%d",&n,&W);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
	}
	j=1;
	for(i=1;i<=n;i++)
	{
		for(j=W;j>=w[i];j--)
		{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}	
	}
	printf("%lld\n",dp[W]);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    int ans = 0;
    for (int i = m-1; i >= 0; i--) {
        for (int b : jobs[i]) {
            q.push(b);
        }
        if (!q.empty()) {
            ans += q.top(); q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 220;
int a[maxn];
int main()
{
    int k;
    for(int i=0;i<5;i++)cin>>a[i];
    int t;
    cin>>k;
    int max_v =0;
    for(int i=0;i<5-1;i++){
        for(int j=i+1;j<5;j++)
        {
            t = a[j] - a[i];
            if(t>max_v)max_v = t;
        }
    }
    if(max_v > k)puts(":(");
    else puts("Yay!");
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,X,Y=gets.chomp.split.map(&:to_i)
x=gets.chomp.split.map(&:to_i).sort
y=gets.chomp.split.map(&:to_i).sort

flag = false
(x[-1]+1).upto(y[0]) do |i|
    if X < i && i <= Y
        flag = true
        break
    end
end

puts flag ? "No War" : "War"

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
int main()
{
    long long a,b,x;
    scanf("%lld%lld%lld",&a,&b,&x);
    long long num=b/x-a/x;
    if(a%x==0)
        num++;
    printf("%lld\n",num);
    return 0;
}


Measured memory_bytes: 128
s = input()
t = ''
divide = ['dream','dreamer','erase','eraser']
#後ろから見るために文字列を反転
s = s[::-1]
for i in range(4):
    divide[i] = divide[i][::-1]
i = 0
while i < len(s):
    ends = False
    for j in range(4):
        div_str = divide[j]
        if s[i:i+len(div_str)] == div_str:
            t += s[i:i+len(div_str)]
            i += len(div_str)
            break
        elif j == 3:
            ends = True
    if ends:
        break
if t == s:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
n, k, q = map(int,input().split())
lst = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    lst[a - 1] = lst[a - 1] + 1

for i in range(n):
    lst[i] = k - (q - lst[i])

for i in range(n):
    if (lst[i] > 0):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 12704
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
h = list(li())

cost = [float("inf")]*(n)
cost[0] = 0

for i in range(n-1):
    cnt = 1
    while i+cnt < n and cnt <= k:
        cost[i+cnt] = min(cost[i+cnt],
                          cost[i] + abs(h[i+cnt]-h[i]))
        
        cnt += 1
             
print(cost[-1])

Measured memory_bytes: 56096
n=int(input())
x=[]
y=[]
for i in range(n):
    a,b=input().split()
    x.append(float(a))
    y.append(b)
for i in range(n):
    if y[i]=='BTC':
        x[i]=x[i]*380000.0
print(sum(x))            

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
k=sum(a)
cnt=0
cn=0
for i in range(100):
	for i in range(n):
		if a[i]!=0:
			a[i]-=1
			cn+=1
		elif cn>0:
			cn=0
			cnt+=1
	if cn>0:
		cnt+=1
	cn=0
	if sum(a)==0:
		break
print(cnt)	

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

using namespace std;

int main() {
	int n, a[200],ans=0;
	cin >> n;
	for (int i = 0; i < n * 2; i++) cin >> a[i];
	sort(a, a + 2 * n);
	for (int i = 0; i < 2 * n; i += 2)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Node { int p, l, r; };
const int MAX = 100005;
const int NIL = -1;
Node T[MAX];
int n, D[MAX];
void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].l == NIL)cout << "leaf, ";
	else cout << "internal node, ";
	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i)cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}
void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL)rec(T[u].r, p);
	if (T[u].l != NIL)rec(T[u].l, p + 1);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++)T[i].p = T[i].l = T[i].r = NIL;
	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}
	rec(r, 0);
	for (i = 0; i < n; i++)print(i);
	return 0;
}

Measured memory_bytes: 7772
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		int ans = 0;
		ans += a[2] - a[1];
		a[0] += ans;
		if((a[2] - a[0]) % 2 == 0)
			ans += (a[2]-a[0])/2;
		else
			ans += (a[2]-a[0] + 1)/2 + 1;
		System.out.println(ans);

	}

}

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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	
	int s1 = 0, s2 = 0;
	for(auto &c : s){
		if(c == 'A')
			s1++;
		else
			s2++;
	}
	
	if(s1 == 0 || s2 == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from heapq import heapify, heappush, heappop
INF = float("inf")
def MAIN():
    n = int(input())
    G = [[i, INF] for i in range(n)]
    G[0][1] = 0
    m = {}
    for _ in range(n):
        A = list(map(int, readline().split()))
        m[A[0]] = {}
        for i in range(2, len(A), 2):
            m[A[0]][A[i]] = A[i + 1]
    dp = [(0, 0)]
    while dp:
        cost, u = heappop(dp)
        for v, c in m[u].items():
            if G[v][1] > G[u][1] + c:
                G[v][1] = G[u][1] + c
                heappush(dp, (G[v][1], v))
    print("\n".join(" ".join(map(str, a)) for a in G))
MAIN()



Measured memory_bytes: 49928
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> cards;
const int MAX=300000;
int maxim[MAX+1];
int search(int number){
	int maxer=0,v=MAX;
	while(v>0 && maxer!=number-1){
		maxer=max(maxer,maxim[v]%number);
		v=maxim[v]-maxim[v]%number-1;
	}
	return maxer;
}
int main() {
	// your code goes here
	int n,q,query;
	cin >> n >> q;
		for(int i=0;i<n;i++){
			cin >> query;
			maxim[query]=query;
		}
	for(int i=1;i<=300000;i++)
		maxim[i]=max(maxim[i],maxim[i-1]);
	for(int j=0;j<q;j++){
			cin >> query;
			cout << search(query) << endl;
	}
	return 0;
}

Measured memory_bytes: 2332
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize, M: usize,
        A: [chars; N],
        B: [chars; M],
    }
    let mut ans = false;

    'super_outer: for i in 0..N-M+1 {
        for j in 0..N-M+1 {

            let mut flag = true;

            'outer: for k in 0..M {
                for l in 0..M {
                    if A[i+k][j+l] != B[k][l] {
                        flag = false;
                        break 'outer;
                    }
                }
            }

            if flag {
                ans = true;
                break 'super_outer;
            }
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
use proconio::input;
use proconio::marker::Chars;
 
fn main(){
  input!{
    s:Chars,
    t:Chars
  }
  let mut dp = vec![vec![0;t.len()+1];s.len()+1];
  for (i,sl) in s.iter().enumerate(){
    for (j,tl) in t.iter().enumerate(){
      if sl==tl{
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=dp[i][j+1].max(dp[i+1][j]);
      }
    }
  }
  let mut ans=String::new();
  let mut len_s:usize=s.len();
  let mut len_t:usize=t.len();
  while dp[len_s][len_t]>0{
      if dp[len_s][len_t]==dp[len_s-1][len_t]{
          len_s-=1;
      }else if dp[len_s][len_t]==dp[len_s][len_t-1]{
          len_t-=1;
      }else{
          ans.insert(0,s[len_s-1]);
          len_s-=1;
          len_t-=1;
      }
  }
  print!("{}",ans);
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;

const int len = 1005, inf = 1e9;
int dis[len][len];
char str[len][len];
int n, m, dr[] = {0, 1, 0, -1}, dc[] = {1, 0, -1, 0};
queue<ii> myq;

bool check(ii u){
    return (0 <= u.fi && u.fi < n && 0 <= u.se && u.se < m && dis[u.fi][u.se] == inf);
}

int main(){
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", str[i]);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++){
            dis[i][j] = inf;
            if (str[i][j] == '#')
                dis[i][j] = 0, myq.push(mp(i, j));
        }

    int ans = 0;
    while (!myq.empty()){
        ii u = myq.front();
        myq.pop();

        ans = max(ans, dis[u.fi][u.se]);

        for (int j = 0; j < 4; j++){
            ii v = u;
            v.fi += dr[j];
            v.se += dc[j];
            if (check(v))
                dis[v.fi][v.se] = dis[u.fi][u.se]+1, myq.push(v);
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 13328
#include <stdio.h>

int main(void)
{
  int h = 0;
  int n = 0;
  int input = 0;
  int total = 0;

  scanf("%d %d",&h,&n);

  
  for(int i = 0; i < n; i++){
    scanf("%d",&input);
    total = total + input;
  }
  
  if(h > total){
    printf("No");
  }else{
    printf("Yes");
  }
}

Measured memory_bytes: 128
N = int(input())
A = [int(a) for a in input().split()]
order = [None] * N
for i in range(N):
    order[i] = (A[i], i + 1)
order.sort()
ans = [None] * N
for i in range(N): ans[i] = order[i][1]
print(" ".join(map(str, ans)))

Measured memory_bytes: 70124
c=[p]*gets.to_i
l=$<.map{|t|n,*a=t.split.map &:to_i;[n,a.select{|i|i>=0&&c[i]=[i,n]+(a-[i])}]}.sort
f=->n,d{c[n][3,0]=[(t=l[n][1]).size,d,h=(t.map{|i|f[i,d+1]}.max||-1)+1,d<1?:root:h<1?:leaf:"internal node"];h}
c[n=c.index(p)]=[n,-1,-1]
f[n,0]
puts c.map{|i|%w(node\ %d:\ parent sibling degree depth height %s)*" = %d, "%i}

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

using namespace std;

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

  	vector <string> grid(H);
    for (int row = 1; row <= H; row++)
        cin >> grid[row - 1];

    vector <vector<int>> DP(H, vector<int>(W));
    DP[0][0] = 1;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            if ((j + 1) < W && grid[i][j + 1] == '.')
                DP[i][j + 1] = (DP[i][j + 1] + DP[i][j]) % 1000000007;
            if ((i + 1) < H && grid[i + 1][j] == '.')
                DP[i + 1][j] = (DP[i + 1][j] + DP[i][j]) % 1000000007;
        }

    cout << DP[H - 1][W - 1];

    return 0;
}

Measured memory_bytes: 5248
sx, sy, tx, ty = map(int,input().split())
dx = tx - sx
dy = ty - sy
a = 'R'*dx + 'U'*dy
b = a.replace('R','L').replace('U','D')
c = 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
d = 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(a+b+c+d)

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

int main () {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
int color[200005];
vector<pair<int,int> > v[200005];

void dfs(int node,int par){
    //cout<<node<<" "<<par<<endl;
    for(auto it:v[node]){
        if(it.first!=par){
            if((it.second)%2==0)
                color[it.first] = color[node];
            else
                color[it.first] = !color[node];
            dfs(it.first,node);
        }
    }
}

int main(){
    fast;

    int n,x,y,w;
    cin>>n;

    f(i,0,n-1){
        cin>>x>>y>>w;
        v[x].pb(mp(y,w));
        v[y].pb(mp(x,w));
    }

    color[1] = 1;
    dfs(1,0);

    f(i,1,n+1)
        cout<<color[i]<<"\n";
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
vector<vector<int> > data;
int INF = 1e18;
int dfs(int vertex, int last, int d){
    int ans = 0;
    for (int i=0;i<data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to==last) continue;
        ans += dfs(to, vertex, d+1);
    }
    if (s[vertex] == '1') ans += d;
    return ans;
}
pair<int, int> dfs2(int vertex, int last){
    int kv = (s[vertex] == '1');
    int sum = 0, mx = 0;
    for (int i=0;i<data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to == last) continue;
        pair<int, int> p = dfs2(to, vertex);
        kv += p.second;
        int res = p.first;
        sum += res;
        mx = max(mx, res);
    }
    if (sum % 2 == 0){
        if (mx <= sum/2) return {kv, kv};
        return {2*mx-sum+kv, kv};
    }
    if (mx <= sum/2) return {kv+1, kv};
    return {2*mx-sum+kv, kv};
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    cin >> s;
    data.resize(n, {});
    for (int i=0; i < n-1; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        data[u].push_back(v);
        data[v].push_back(u);
    }
    int ans = INF;
    for (int i=0; i < n; i++){
        int sum=0;
        int mx=0;
        int wh=-1;
        for (int j=0; j < data[i].size(); j++){
            int to = data[i][j];
            int S = dfs(to, i, 1);
            sum += S;
            if (S > mx){
                mx = S;
                wh = to;
            }
        }
        //cout << i << " " << sum << " " << mx << endl;
        if (sum % 2 != 0) continue;
        if (mx > sum/2){
            int C = dfs2(wh, i).first;
            if (C <= sum-mx) ans = min(ans, sum/2);
            else continue;
        }
        else{
            ans = min(ans, sum/2);
        }
    }
    if (ans == INF) cout << -1;
    else cout << ans;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a=0,b=0,c,h,i,j,k,l,m,n;
	ll		ans = 0;
	string	s;
	cin >> s;
	char x,y;
	x = '0'; y = '1';
	for(i=0;i<s.size();i++) {
		if (s[i]!=x) a++;
		if (s[i]!=y) b++;
		swap(x , y);
	}
	ans = min(a , b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3760
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

print(" ".join(map(str, b)))


Measured memory_bytes: 29128
def modpow(a, n, mod):
    res=1
    while n>0:
        if n & 1:
            res = res * a % mod
        n = n>>1
        a = a * a % mod
    return res


L = input()
n1 = L.count('1')

m=0
d=[]
for i, c in enumerate(reversed(L)):
    if c=='1':
        m+=1
        d.append((i, n1-m))

mod = 10**9+7
s = modpow(2, n1, mod)
for dd in d:
    s += (modpow(3,dd[0],mod) * modpow(2,dd[1],mod)) % mod

print(s % mod)


Measured memory_bytes: 16628
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(dead_code)]
const MOD: i32 = 1e9 as i32 + 7;

fn main() {
    input!(t: String);
    let mut t: String = t.clone();
    let mut t1: Vec<char> = t.chars().collect();
    let mut t2: Vec<char> = t.chars().collect();
    for i in 1..t1.len() {
        if t1[i - 1] == '?' && t1[i] == 'D' {
            t1[i - 1] = 'P';
        } else if t1[i - 1] == '?' && t1[i] == '?' {
            t1[i - 1] = 'P';
            t1[i] = 'D';
        } else if t1[i - 1] == 'P' && t1[i] == '?'{
            t1[i] = 'D';
        }
    }
    for i in 0..t1.len() {
        if t1[i] == '?' {
            t1[i] = 'D';
        }
    }
    let ans:String = t1.iter().collect();
    println!("{}", ans);
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    string s; cin >> s;
    rep(i, s.size()) {
        if (s[i] == ',') {
            cout << ' ';
        } else {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

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

#define ll long long

ll not_div(ll r, ll c, ll d){
    return (r - (r/c) - (r/d) + (r / ((c * d) / __gcd(c, d))));
}


int main()
{
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll res = not_div(b, c, d) - not_div(a-1, c, d);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256