akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}

int setHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;
  return H[u] = max(h1, h2);
}

int getSibling(int u){
  int p = T[u].p;
  if(p == NIL) return NIL;
  else{
    if(T[p].l != u && T[p].l != NIL) return T[p].l;
    else if(T[p].r != u && T[p].r != NIL) return T[p].r;
    else return NIL;
  }
}

int getDegree(int u){
  int deg = 0;
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  return deg;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));
  printf("degree = %d, ", getDegree(u));
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].p == NIL) printf("root");
  else if(getDegree(u) == 0) printf("leaf");
  else printf("internal node");

  printf("\n");
}

int main(){
  cin >> n;

  rep(i, n) T[i].p = NIL;
  rep(i, n){
    int u, l, r;
    cin >> u >> l >> r;
    T[u].l = l;
    T[u].r = r;
    if(l != NIL) T[l].p = u;
    if(r != NIL) T[r].p = u;
  }

  int root;
  rep(i, n) if(T[i].p == NIL) root = i;
  
  setDepth(root, 0);
  setHeight(root);

  rep(i, n) print(i);

  return 0;
}



Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String str = scanner.next();

		if (str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		scanner.close();
	}

}


Measured memory_bytes: 35824
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; string str; cin>>n;
  unordered_set<string> st;
  for(int i=1;i<=n;i++){
    cin>>str; st.insert(str);}
  cout<<st.size();
  return 0;
}

Measured memory_bytes: 17656
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;


ll N;
ll dp[1001001];
ll rui_dp[1001001];
ll ans;
int main(){
  cin >> N;
  dp[0] = 1;
  dp[1] = 1;
  rui_dp[0] = 1;
  rui_dp[1] = 1;
  for(int i=1;i<N;i++){
    dp[i+1] += rui_dp[i]+1;
    if(i>=1) dp[i+1] = (dp[i+1]-dp[i-1]+MOD)%MOD;
    rui_dp[i+1] = (rui_dp[i+1]+dp[i+1] + rui_dp[i]) % MOD;
    //cerr << dp[i] << " " << rui_dp[i] << endl;
  }
  if(N==2){
    cout << "4" << endl;
    return 0;
  }
  ll tmp  = ((N-1)*(N-1))%MOD;
  ans =(tmp + N)%MOD;
  tmp = (tmp * rui_dp[N-2])%MOD;
  ans =(ans + tmp) %MOD;
  cerr << ans << endl;
  tmp = ((N-1) * rui_dp[N-1])%MOD;
  ans =(ans + tmp) % MOD;

  cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int ans, k;
vector<vi> e;
int rec(int c, int depth){
	int mx = 0;
	for(int i : e[c]) mx = max(mx, rec(i, depth+1));
	//dbg(c, mx, depth);
	if(depth > 1 && mx == k - 1){
		ans++;
		return 0;
	}
	return mx + 1;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n >> k;
	e.resize(n);
	rep(i, n){
		int a; cin >> a;
		if(i == 0){
			if(a != 1) ans++;
		}
		else{
			e[a - 1].pb(i);
		}
	}
	rec(0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
//smartphone
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

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

    lint n,s=0;cin>>n;
    vector<int> a(n),b(n);
    lint ans=-INT_MAX;
    rep(i,n)cin>>a[i],s+=a[i];
    rep(i,n)cin>>b[i];s+=b[n-1];
    rep(i,n){
        ans=max(ans,s);
        if(i!=n-1){s-=a[n-1-i],s+=b[n-2-i];}
    }co(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int l;
	cin>>l;
	cout<<fixed<<setprecision(12);
	double v = l;
	v/=3;
	v=v*v*v;
	cout<<v<<"\n";
}

Measured memory_bytes: 256
import math
N,M=map(int,input().split())
l=[]
for i in range(1,int(math.sqrt(M))+1):
  if M%i==0:
    l.append(i)
    if i!=M//i:
      l.append(M//i)
l=sorted(l,reverse=False)
while l:
  v=l.pop(-1)
  tot=M//v
  if tot<N:
    pass
  else:
    print(v)
    break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll INTF = 1e9 + 7;

map<int, list<int>> g;

pair<ll, ll> dfs(int nd ,int parent)
{
  ll white = 1;
  ll black = 1;
  for(auto adj: g[nd])
  {
    if(adj != parent)
    {
      pair<int, int> pr= dfs(adj , nd);
      white = (pr.first*white + pr.second*white)%INTF;
      black = (black*pr.first )%INTF;
    }
  }
  return make_pair(white, black);
}

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

    for(int i=0,x,y; i<n-1; i++)
    {
      cin >> x >> y;
      --x, --y;
      g[x].push_back(y);
      g[y].push_back(x);
    }

    pair<ll, ll> pr = dfs(0, 0);
    cout<<(pr.first + pr.second)%INTF;

  return 0;
}


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

typedef struct node{
  char moji;
  int value;
}Node;

void bubbleSort(Node *,int);
void selectionSort(Node *,int);

int cnt=0;

int main(){
  int i,n,flg=0;
  Node array[36],bubble[36],select[36];
  scanf("%d",&n);
  if(n<1 || n>100) exit(2);
  for(i=0;i<n;i++){
    scanf(" %c%d",&array[i].moji,&array[i].value);
    bubble[i] = select[i] = array[i];
  }
  selectionSort(select,n);
  bubbleSort(bubble,n);
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%c%d",bubble[i].moji,bubble[i].value);
  }
  printf("\nStable\n");
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%c%d",select[i].moji,select[i].value);
    if(select[i].moji != bubble[i].moji || select[i].value != bubble[i].value)flg=1;
  }
  if(flg==0) printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}

void bubbleSort(Node arr[],int n){
  int i,j,tmp;
  Node change;
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(arr[j-1].value > arr[j].value){
	change = arr[j];
	arr[j] = arr[j-1];
	arr[j-1] = change;
      }
    }
  }
}

void selectionSort(Node arr[],int n){
  int i,j,tmp,min;
  Node change;
  for(i=0;i<n-1;i++){
    min=i;
    for(j=i+1;j<n;j++){
      if(arr[min].value > arr[j].value) min=j;
    }
      change = arr[i];
      arr[i] = arr[min];
      arr[min] = change;
  }
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
#define P pair<ll, ll>

int main(){
  ll N;cin>>N;
  vector<ll> v1(N),v2(N);
  rep(i,N){
    ll x,y;cin>>x>>y;
    v1[i] = x-y,v2[i]=x+y;
  }
  ll ans = 0;
  sort(all(v1),greater<ll>());
  sort(all(v2),greater<ll>());
  ans = max(v1[0]-v1[N-1], v2[0]-v2[N-1]);
  //cout << v1[0]-v1[N-1] << " " << v2[0]-v2[N-1] << endl;
  cout << ans << endl;
}

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

#define LL long long
using namespace std;


int main(void){

    bool flg = true;

    int a, b;
    int result = 0;

    cin >> a >> b;

    if(a < b){
        result += b;
        b--;
        if(a < b){
            result += b;
        }else{
            result += a;
        }
    }else{
        result += a;
        a--;
        if(b < a){
            result += a;
        }else{
            result += b;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vi v(n);
    rep(i,0,n)cin >> v[i];
    vi klo = v;
    sort a(klo);
    rep(i,0,n){
        if(v[i]!=klo[n-1]){
            cout << klo[n-1] << '\n';
        }else{
            cout << klo[n-2] << '\n';
        }
    }
}

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

#define MOD 998244353
#define int long long

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

  std::vector<std::vector<int> > dp(c+1, std::vector<int>(d+1, 0));
  dp[a][b] = 1;

  for(int i = a+1; i <= c; i++) {
    dp[i][b] = (b*dp[i-1][b])%MOD;
  }

  for(int i = b+1; i <= d; i++) {
    dp[a][i] = (a*dp[a][i-1])%MOD;
  }

  for(int i = a+1; i <= c; i++) {
    for(int j = b+1; j <= d; j++) {
      dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
      dp[i][j] = (dp[i][j] + ((j-1)*dp[i-1][j])%MOD + (i-1)*dp[i][j-1] - ((i-1)*(j-1)*dp[i-1][j-1])%MOD + 2*MOD)%MOD;
    }
  }

  std::cout << dp[c][d] << std::endl;
  return 0;
}


Measured memory_bytes: 73652
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int NICO = 3000 + 10;
vector<int> vec[NICO];
int a[NICO], n;
int sg[NICO];

void dfs(int x, int par)
{
    sg[x] = 0;
    for(int i=0;i<vec[x].size();i++)
    {
        int cur = vec[x][i];
        if(cur == par || a[cur] >= a[x]) continue;
        dfs(cur, x);
        if(!sg[cur]) sg[x] = 1;
    } 
}

int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(int i=1;i<n;i++)
    {
        int u, v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
    {
        dfs(i, 0);
        if(sg[i]) printf("%d ", i);
    }
} 

Measured memory_bytes: 512
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/	
	
	string s; cin >> s;
	
	long long n = ll(s.size());
	
	if(n & 1){
		string a = s.substr(0, n / 2), b = s.substr(n / 2 + 1, n / 2);
		string x = a, y = b, z = s;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(s.begin(), s.end());
		if(x == a && y == b && z == s) return cout << "Yes", 0;	
	}
	
	cout << "No";
	
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int ans = 0;
    while (n != 1) {
      if (n & 1) n = 3 * n + 1;
      else n >>= 1;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>

int main() {
	int n, m, k, max, min;
	scanf("%d%d%d", &n, &m, &k);

	max = (n > m) ? n : m;
	min = (n < m) ? n : m;

	for (int i = 0; i <= max; i++)
	{
		for (int j = 0; j <= min; j++)
		{
			if (i*min + j*max - i*j * 2 == k)
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
s = input()
c = Counter(s)
ans = float("inf")
for i in c.keys():
    t = list(s)
    while t != [i]*len(t):
        u = []
        for j in range(len(t)-1):
            if t[j] == i or t[j+1] == i:
                u.append(i)
                continue
            u.append(t[j])
        t = u
    ans = min(ans,len(s)-len(t))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int ruijou(int n, int k) {
  int ret = 1;
  for(int i =0; i < k;i++){
    ret *= n;
  }
  return ret;
}

int main() {
  int H;
  int W;
  int K;
  cin >> H;
  cin >> W;
  cin >> K;
  int count = 0;
  
  vector<vector<char>> vect(H,vector<char>(W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> vect.at(i).at(j);
    }
  }
  
  for(int k = 0; k < ruijou(2,H); k++) {
    for(int l = 0; l < ruijou(2,W); l++) {
    int black = 0; 
    for(int i = 0; i < H;i++){
      if((k / ruijou(2,i)) %2 ==0){
        
          for(int j = 0; j < W; j++) {
           if((l / ruijou(2,j))%2 == 0) {
             if(vect.at(i).at(j)=='#') {
               black++;
             }
           }
          }
        }
      }
      if(black == K){
        count++;
      }
    }
  }
    
  
  cout << count << endl;
  
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (s == u) {
		cout << a - 1 << ' ' << b << endl;
	}
	else {
		cout << a << ' ' << b - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
    
def myfunc(L, X):
    if L==0:
        return 1 if X>0 else 0
    elif X==1:
        return 0
    elif 1<X and X<=a[L-1]+1:
        return myfunc(L-1, X-1)
    elif X==a[L-1]+2:
        return p[L-1]+1
    else:
        return p[L-1]+1+myfunc(L-1, X-a[L-1]-2)

print(myfunc(N, X))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32964
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int g[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> g[i][j];
        }
    }
    int a[3], b[3];
    a[0] = 0;
    rep(i, 3) b[i] = g[0][i];
    a[1] = g[1][0] - b[0];
    a[2] = g[2][0] - b[0];

    bool fg = true;
    for(int i=1; i<3; i++){
        for(int j=1; j<3; j++){
            if(a[i]+b[j] != g[i][j]) fg = false;
        }
    }
    
    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int c = 0;
    string A, B;
    cin>> A;
    cin>> B;
    for(int i = 0; i < A.size(); i++)
        if(A[i] != B[i])
            c++;
    cout<< c;
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数
long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,k,h,x,y,xcmp=0,ycmp=0;

string s,w;

vector<int> z;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
    
   cin >> s >> w;
   if(s.size()==w.size()){
       for(int i=0;i<s.size();i++){
           cout << s[i] << w[i];
       }
       cout << endl;
   }else{
       for(int i=0;i<w.size();i++){
           cout << s[i] << w[i];
       }
       cout << s[s.size()-1] << endl;
   }
return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let (a, b) = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace();
        (
            i32::from_str(it.next().unwrap()).unwrap(),
            i32::from_str(it.next().unwrap()).unwrap(),
        )
    };

    if a > 8 || b > 8 {
        println!(":(");
        return
    }
    println!("Yay!");
}


Measured memory_bytes: 2120
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let ks = read_vec::<i32>();
    let mut ans = 0;
    for j in 0..ks[0]+1{
        for k in 0..ks[0]+1{
            let z = ks[1] - j - k;
            if 0 <= z && z <= ks[0] { ans += 1;}
        }
    }
    println!("{}",ans );
}

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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(s.begin(),s.end());
  r = getPositions();
  rep(i,k) r[i] = n-1-r[i];
  reverse(s.begin(),s.end());

  vector<int> lastL(n+1, -1);
  rep(i,k) lastL[l[i]+1] = i;
  rep(i,n) {
    if (lastL[i+1] == -1) lastL[i+1] = lastL[i];
  }
  vector<int> lastR(n+1, -1);
  rep(i,k) lastR[r[i]] = i;
  for (int i = n-1; i >= 0; --i) {
    if (lastR[i] == -1) lastR[i] = lastR[i+1];
  }

  rep(i,n) {
    if (s[i] == 'x') continue;
    int li = lastL[i];
    int ri = lastR[i+1];
    int cnt = 0;
    if (li != -1) cnt += li+1;
    if (ri != -1) cnt += ri+1;
    if (li != -1 && ri != -1 && r[ri]-l[li] <= c) {
      --cnt;
    }
    if (cnt >= k) continue;
    printf("%d\n", i+1);
  }
  return 0;
}


Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::string S, std::string T)
{
    ll g = lcm(N, M);
    map<ll, char> m;

    for (int i = 0; i < N; i++)
    {
        ll tmp = (g / N) * i;
        if (!m[tmp])
        {
            m[tmp] = S[i];
        }else{
            if(m[tmp] != S[i]){
                cout << -1 << endl;
                return;
            }            
        }
    }

    for (int i = 0; i < M; i++)
    {
        ll tmp = (g / M) * i;
        if (!m[tmp])
        {
            m[tmp] = T[i];
        }else{
            if(m[tmp] != T[i]){
                cout << -1 << endl;
                return;
            }            
        }
    }

    cout << g << endl;
    return;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, M, S, T);
    return 0;
}


Measured memory_bytes: 11008
N = int(input())

# import math
#
# def sieve_of_eratosthenes(n):
#     candidate = [i for i in range(2, n+1)]
#     prime = []
#     limit = math.sqrt(n) + 1
#
#     while True:
#         p = min(candidate)
#         if limit <= p:
#             prime.extend(candidate)
#             break
#         prime.append(p)
#
#         candidate = [i for i in candidate if i % p != 0]
#
#     return prime
#
#
# if N == 1:
#     print(0)
#     exit()
#
# rn = math.ceil(math.sqrt(N))
# L = sieve_of_eratosthenes(rn)
# print('hoge')
#
# n = N
# c = 0
# used = {}
#
# for l in L:
#     if n % l == 0:
#         i = 1
#         l2 = l
#         while n % l2 == 0:
#             c += 1
#             i += 1
#             used[l2] = True
#             n = n // l2
#             l2 = l ** i
#
# if c == 0:
#     print(1)
# else:
#     if n != 1:
#         # x = sieve_of_eratosthenes(n)
#         if n not in used:
#             c += 1
#     print(c)

# if N == 1:
#     print(0)
#     exit()
#
# ans = 0
# used = {}
#
# n = N
# i = 1
# p = 2
# while n % p == 0:
#     ans += 1
#     n = n // p
#     used[p] = True
#     i += 1
#     p = 2**i
#
#
# i = 1
# p = 3
# k = p
# while p * p <= N:
#     while n % k == 0:
#         if k in used:
#             i += 1
#             k = k ** i
#         else:
#             ans += 1
#             i += 1
#             n = n // k
#             used[k] = True
#             k = k ** i
#     i = 1
#     p += 2
#     k = p
#
# if n not in used and n != 1:
#     ans += 1
# print(ans)

def factorize(n):
    a = []
    # 2で割り切れるまでnを割り続ける
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    # 3からはじめて各奇数で割り切れるまでnを割り続ける
    # nの最大約数は√nなので、f*fで計算
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

fs = factorize(N)

from collections import Counter
c = Counter(fs)

ans = 0
i = 1
for k, v in c.items():
    k2, v2 = k,v
    while v2 >= i:
        ans += 1
        v2 -= i
        i += 1
    i = 1

print(ans)


Measured memory_bytes: 9452
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100];
bool dp[100][100][9][3];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i], A[i]--;
  rep(i, N) dp[i][i][A[i]][1] = 1;
  for (int len=2; len<=N; len++) {
    rep(l, N) {
      int r = l+len-1;
      if (r >= N) break;
      rep(j, 9) {
        rep(k, 3) {
          for (int t=l; t<=r-1; t++) {
            // [l, t] + [t+1, r]
            for (int s1=0; s1<=2; s1++) for (int s2=0; s2<=2; s2++) {
              dp[l][r][j][min(s1+s2, 2)] |= dp[l][t][j][s1] & dp[t+1][r][j][s2];
            }
          }
        }
        dp[l][r][j][0] |= dp[l][r][j][2];
      }
      bool ok = false;
      rep(j, 9) ok |= dp[l][r][j][0];
      rep(j, 9) dp[l][r][j][0] |= ok;
    }
  }

  bool b = 0;
  rep(i, 9) b |= dp[0][N-1][i][0];
  cout << (b?"yes":"no") << "\n";
  return 0;
}

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

int main() 
{
    string s;
    cin >> s;
    int sum = 0;
    
    for(int i=0;i<s.size();i++){
        sum+=(s[i]-'0');
        sum%=9;
    }
    
    if(sum==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

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

        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind uf = UnionFind(n);
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        uf.unite(x - 1, y - 1);
    }

    int t = 0;
    for (int i = 0; i < n; i++) {
        if (uf.isSame(i, p[i])) {
            t++;
        }
    }

    cout << t << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < N; i++) {
    cout << S.at(i) << T.at(i);
  }
  cout << endl;
  
}

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

using namespace std;


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

 int x,y;
  cin >> x >> y;
 
 int res=(max(0,4-x)+max(0,4-y))*100000;
 if(res==600000) res+=400000;

 cout << res << endl; 
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if ((a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a;
	ld b;
	cin >> a >> b;
	ll c = b * 100 + EPS;
	co(a * c / 100);

	return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

void display(vector<int> ary) {
  for (int i = 0; i < ary.size(); i++) {
    if (i > 0) cout << " ";
    cout << ary[i];
  }

  cout << endl;
}

void selection_sort_and_display(vector<int> ary) {
  int min_idx, len, count = 0;
  len = ary.size();
  for (int i = 0; i < len; i++) {
    min_idx = i;
    for (int j = i; j < len; j++) {
      if (ary[min_idx] > ary[j]) {
        min_idx = j;
      }
    }

    if (min_idx != i) {
      swap(ary[i], ary[min_idx]);
      count++;
    }
  }

  display(ary);
  cout << count << endl;
}

int main(void) {
  int len;
  vector<int> ary;
  char s[200];

  cin >> len;

  for (int i = 0; i < len; i++) {
    cin >> s;
    ary.push_back(atoi(s));
  }

  selection_sort_and_display(ary);

  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
#define countbits __builtin_popcount
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n,m,dis[200005];
int que[200005],l,r;
vector<int>g[200005];
int main() {
	n=readint();m=readint();
	memset(dis,-1,sizeof(dis));
	rep(i,1,m) {
		int u=readint(),v=readint();
		g[u].pb(v);g[v].pb(u);
	}
	dis[1]=0;
	que[r++]=1;
	while (l<r) {
		int x=que[l++];
		if (x==n) {
			break;
		}
		rep(i,0,(int)g[x].size()-1) {
			int nw=g[x][i];
			if (!~dis[nw]) {
				dis[nw]=dis[x]+1;
				que[r++]=nw;
			}
		}
	}
	if (dis[n]==2) {
		printstr("POSSIBLE");
	} else {
		printstr("IMPOSSIBLE");
	}
	return 0;
}


Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) cerr<<"[("<<__LINE__<<") "<<#x<< "]: "<<x<<"\n"
constexpr long long INF {LLONG_MAX};
#define float long double
#define int long long
#define endl "\n"

main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.setf(ios::fixed);
#ifndef ONLINE_JUDGE
	freopen("test", "r", stdin);
#endif
	string s,t;
	cin>>s>>t;
	if (t.substr(0,s.size()) == s){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N, M, I[100001], dp[100001];
vector<int> S, G[100001];

void tpsrt(){
	for(int i = 1; i <= N; i++)
		for(int j = 0; j < (int)G[i].size(); j++) I[G[i][j]]++;
	queue<int> que;
	for(int i = 1; i <= N; i++)
		if(I[i] == 0) que.push(i);
	while(!que.empty()){
		int elm = que.front();
		que.pop();
		S.push_back(elm);
		for(int i = 0; i < (int)G[elm].size(); i++)
			if(--I[G[elm][i]] <= 0) que.push(G[elm][i]);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
	}
	tpsrt();
	S.insert(S.begin(), 0);
	int mx = 0;
	for(int i = 1; i < (int)S.size(); i++){
		for(int j = 0; j < (int)G[S[i]].size(); j++) dp[G[S[i]][j]] = max(dp[G[S[i]][j]], dp[S[i]] + 1);
		mx = max(mx, dp[S[i]]);
	}
	cout << mx << "\n";
	return 0;
}


Measured memory_bytes: 7032
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int  N=2e5+10;

int n,w[N],v[N],len,ans[N];
struct edge{int y,next;}a[N<<1]; int Len,last[N];
void ins(int x,int y) {a[++Len]=(edge){y,last[x]};last[x]=Len;}

void dfs(int x,int f) {
	int t=len+1,val=0; bool flag=0;
	if(w[len]<v[x]) w[++len]=v[x],flag=1;
	else t=lower_bound(w+1,w+len+1,v[x])-w,val=w[t],w[t]=v[x];
	ans[x]=len;
	for(int k=last[x],y;k;k=a[k].next) 
		if((y=a[k].y)^f) dfs(y,x);
	w[t]=val;
	len-=flag;
}

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&v[i]);
	for(int i=1,x,y;i<n;i++)
		scanf("%d%d",&x,&y),ins(x,y),ins(y,x);
	dfs(1,0);for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 21580
read n

(( n > 10000 )) && M=16384 || M=32768

while read t1 x1 y1; do
    (( RANDOM < M )) &&
    (( d = (t1-t2) - (x1>x2 ? x1-x2 : x2-x1) - (y1>y2 ? y1-y2 : y2-y1),
       d < 0 || d % 2 )) && echo No && exit
    read t2 x2 y2 || break
    (( RANDOM < M )) &&
    (( d = (t2-t1) - (x1>x2 ? x1-x2 : x2-x1) - (y1>y2 ? y1-y2 : y2-y1),
       d < 0 || d % 2 )) && echo No && exit
done
echo Yes

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

void Main(){
    
}

int main() {
	int h, w;
	while (cin >> h >> w,h) {
		rep(i, h) {
			rep(j, w)cout << "#";
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int N,M;cin>>N>>M;
    UnionFind tree(N);
    rep(i,M) {
        int x,y,z;cin>>x>>y>>z;
        x--;y--;
        tree.merge(x,y);
    }
    set<int> se;
    rep(i,N) {
        se.emplace(tree.root(i));
    }
    cout<<se.size()<<endl;
}

Measured memory_bytes: 9496
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int a =2;

		double result = 0;

		for(int i=1; i<=n; i++){
			a=2;

			if(i<=k-1) {
				while(a*i<k) {
					a= a*2;


				}
				double b2 = (double)1/n/a;
				result += b2;
			}else {
				//double b1 = a1.divide(aa, 15, BigDecimal.ROUND_HALF_UP).doubleValue();
				double b1 = (double)1/n;
				result += b1;
			}
			// System.out.println(result); 
		}
		System.out.println(result); 
	}
}

Measured memory_bytes: 22740
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  
  dsu uf(N);
  rep(i,M){
    ll a,b; cin>>a>>b; a--; b--;
    uf.merge(a,b);
  }
  
  cout<<uf.groups().size()-1<<'\n';
  
  
  
  return 0;
}

Measured memory_bytes: 9012
#include<iostream>
int main() {
    int i,j,A,B,C,D;
    std::cin >> A >> B >> C >> D;
    if (A <= B)
      i = A;
      else
      i = B;
   if (C <= D)
     j = C;
   else
   j = D;
    std::cout << i+j;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 1005;

int bz[10005];
int n, p[N], p0;

int main() {
	fo(i, 2, 1e4) {
		if(p0 >= 1000) break;
		if(!bz[i]) p[++ p0] = i;
		for(int j = i; j <= 1e4; j += i) bz[j] = 1;
	}
	p[0] = 1;
	scanf("%d", &n);
	fo(i, 1, n) {
		fo(j, 1, n) {
			if((i + j) & 1) {
				int x = (i + j) / 2, y = (i - j + n) / 2 + n;
				pp("%d ", p[x] * p[y]);
			} else {
				int x = i + j, y = i - j + n + 2 * n; 
				pp("%lld ", (ll) p[x + 1 >> 1] * p[x - 1 >> 1] * p[y + 1 >> 1] * p[y - 1 >> 1] + 1);
			}
		}
		hh;
	}
}

Measured memory_bytes: 3200
N = int(input())

h = list(map(int,input().split()))

cost = [0] * (N)

for i in range(0,N-1):
    if i==0:
        cost[i+1] = cost[i]+abs(h[i+1]-h[i])
    else:
        cost[i+1] = min(cost[i]+abs(h[i+1]-h[i]),cost[i-1]+abs(h[i+1]-h[i-1]))

print(cost[N-1])

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int k,n;cin>>k>>n;
    VI a(n);
    REP(i, n) cin >> a[i];

    int m = 0;

    REP(i,n-1){
        int t=a[i+1]-a[i];
        m = max(m,t);
    }
    int t = (k-a[n-1])+a[0];
    m = max(m,t);

    cout<<k-m<<endl;
    
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1024