akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, m;
  cin >> n >> m;
  vector<PII> p(m);
  REP(i, m) {
    cin >> p[i].second >> p[i].first;
  }
  sort(ALL(p));

  int a = -1;
  int ret = 0;
  REP(i, m) {
    if(p[i].second < a) continue;
    ret++;
    a = p[i].first;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        try {
            main.solve(args);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void solve(String[] args) throws Exception {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        if (A <= C && C <= B) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s,t;
   int count=0;
   cin>>s>>t;
   for(int i=0;i<s.size();i++){
     if(s[i]!=t[i]){
       count++;
     }
   }
   cout<<count<<endl;
}

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

map<string,int> g;

int main()
{
    int n,a;
    cin>>n;
    string s;
    int maxn = 0;
    for (int i = 1;i<=n;i++)
    {
        cin>>s;
        maxn = max(maxn,++g[s]);
    }
    for (auto i :g)
    {
        if (i.second == maxn)
        {
            cout<<i.first<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

struct Edge{
  int src,dst,cost;
  Edge(int src,int dst,int cost) : src(src), dst(dst), cost(cost) {;}
};

vector<Edge> g;
vector<int> pa;
int ans,ns,nl;

void dfs(int p,int use,int dist,vector<int> path) {
  int i;
  //cout<<"now "<<p<<endl;
  if(ans < dist) {
    pa = vector<int>(path);
    ans = dist;
  }
  rep(i,nl) {
    if((use>>i) & 1) continue;
    if(g[i].src == p) {
      vector<int> np(path);
      np.push_back(g[i].dst);
      dfs(g[i].dst, use|(1<<i), dist+g[i].cost,np);
    }else if(g[i].dst == p) {
      vector<int> np(path);
      np.push_back(g[i].src);
      dfs(g[i].src, use|(1<<i), dist+g[i].cost,np);
    }
  }
}

int main() {
  int i,j,k,s,t,d;
  while(cin>>ns>>nl, ns|nl) {
    g.clear();
    ans = 0;
    rep(i,nl) {
      cin>>s>>t>>d;
      s--,t--;
      g.push_back(Edge(s,t,d));
    }

    pa.clear();
    rep(i,ns) {
      vector<int> v(1,i);
      dfs(i,0,0,v);
    }

    cout<<ans<<endl;
    rep(i,pa.size()-1)
      cout<<pa[i]+1<<" ";
    cout<<pa[pa.size()-1]+1<<endl;
  }
}

Measured memory_bytes: 0
#include <map>
#include <cstdio>
using namespace std;
int main(){
	int n, t;
	scanf("%d", &n);
	map<int, int> m;
	for (int i = 0; i < n; i++){
		scanf("%d", &t);
		if (m[t] == 1){
			printf("NO\n");
			return 0;
		}
		m[t] = 1;
	}
	printf("YES\n");
}

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

signed main() {
	string s;
	cin >> s;
	int ans = 0;
	int now = 0;
	for(auto i: s) {
		if(i == 'A' || i == 'T' || i == 'G' || i == 'C') {
			now++;
		}
		else {
			now = 0;
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;	
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1); 
map<int, vector<int>> cosos;
map<int, map<int, int>> casos;
ll conv(string s)
{
	ll mul = 1000000000;
	ll num = 0;
	fore(i, 0, (int)s.size())
	{
		num *= 10;
		num += s[i] - '0';
		mul /= 10;
	}
	return num * mul;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int n;
	cin>>n;
	ll a, b, g;
	ll uni = 0;
	char ch;
	string s, so;
	cin.ignore();
	while(n--)
	{
		getline(cin, so);
		stringstream ss;
		ss << so;
		ss>>a;
		s = "";
		if(ss >> ch)
		{
			ss >> s;
		}
		a = a * 1000000000 + conv(s);
		g = __gcd(a, MOD - 7ll);
		//cout<<a<<' ';
		a /= g;
		b = (MOD - 7) / g;
		//cout<<a<<' '<<b<<'\n';
			cosos[b].pb(a);
		if(b == 1)
			uni++;
	}
	int box;
	for(auto cat : cosos)
	{
		fore(j, 0, (int)cat.s.size())
		{
			//cout<<cat.s[j]<<' ';
			box = cat.s[j];
			for(int k = 1; k * k <= box && k < 10000; k++)
			{
				if(box % k == 0)
				{
					if((int)cosos[k].size() > 0)
						casos[k][cat.f]++;
					if((int)cosos[box / k].size() > 0 && k != box / k)
						casos[box / k][cat.f]++;
				}
			}
		}
	}
	//cout<<'\n';
	ll res = 0, ras = 0;
	for(auto cat : cosos)
	{
		if((int)casos[cat.f].size() > 0)
		fore(j, 0, (int)cat.s.size())
		{
			box = cat.s[j];
			for(int k = 1; k * k <= box; k++)
			{
				if(box % k == 0)
				{
					{
						if(k != box / k)
						res += casos[cat.f][box / k];
						res += casos[cat.f][k];
					}
				}
			}
		}
	}
	cout<<(res - uni) / 2<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2	 			

Measured memory_bytes: 47696
#include <iostream>
#include <string>
#include <cmath>

bool isSquared(long long N);

int main()
{
  std::string a, b;
  std::cin >> a >> b;
  
  int c = std::stoi(a + b);
  
  if(isSquared(c))
  {
    std::cout << "Yes";
  }
  else
  {
    std::cout << "No";
  }
  
  return 0;
}

bool isSquared(long long N)
{
  long long check = (long long)std::floor(std::sqrtl((long double)N));
  return (check * check) == N;
}

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

const int N = (int)1e5 + 5;
const int M = (int)1e9 + 7;

ll powmod(ll a, ll b) {
  if(b == 0) return 1;
  ll ans = powmod(a, b / 2);
  ans = ans * ans % M;
  if(b % 2) ans = ans * a % M;
  return ans;
}

ll f[N], rf[N], n, a[N];

ll c(ll x, ll y) {
  return f[x] * rf[y] % M * rf[x - y] % M;
}

void build() {
  f[0] = 1;
  for(int i = 1 ; i < N ; ++i) f[i] = f[i - 1] * i % M;
  rf[N - 1] = powmod(f[N - 1], M - 2);
  for(int i = N - 2 ; i >= 0 ; --i) rf[i] = rf[i + 1] * (i + 1) % M;
}
void init() {
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) cin >> a[i];
}
void solve() {
  int cc[3] = {0};
  ll ans = 1;
  for(int i = 1 ; i <= n ; ++i) {
    int ccc = 0, k = 0;
    for(int j = 2 ; j >= 0 ; --j) if(cc[j] == a[i]) {
      ccc++;
      k = j;
    }
    cc[k]++;
    ans = ans * ccc % M;
  }
  cout << ans << '\n';
  /*
  sort(cc, cc + 3);
  ans = 0;
  do {
    ans = (ans + (c(n, cc[0]) % M * c(n - cc[0], cc[1]) % M)) % M;
  } while(next_permutation(cc, cc + 3));
  cerr << cc[0] << ' ' << cc[1] << ' ' << cc[2] << '\n';
  cout << ans << '\n';
  */
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  build();
  init();
  solve();
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long solve(string S) {
    string T = "";
    for (auto c : S) if (c != 'x') T += c;
    string T2 = T;
    reverse(T2.begin(), T2.end());
    if (T != T2) return -1;

    int N = T.size();
    vector<long long> nums(N+1, 0);
    int iter = 0;
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == 'x') ++j;
        nums[iter++] = j-i;
        i = j+1;
    }
    //COUT(nums);

    long long res = 0;
    for (int i = 0; i*2 < nums.size(); ++i) {
        res += max(nums[i], nums[(int)nums.size()-1-i]) -
            min(nums[i], nums[(int)nums.size()-1-i]);
    }
    return res;
}

int main() {
    string S;
    while (cin >> S) cout << solve(S) << endl;
}


















Measured memory_bytes: 1408
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count1 = 0;
    int count2 = 0;
    for(int i=0;i<N;i++){
      int a = sc.nextInt();
      if(a%4==0){
        count1++;
      }else if(a%2==0 && (a/2)%2==1){
        count2++;
      }
    }
    if(count1>=N/2){
      System.out.println("Yes");
    }else if(((N/2-count1)*2+N%2)==count2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

string S;
int Q;

// *********************************************************


int main(){

    cin >> S;
    cin >> Q;

    int q, f;
    string c;
    string tmp;
    bool flag=true;

    S.reserve(S.size() + Q);
    for(int i=0; i<Q; ++i){
        cin >> q;
        if(q==1){
            flag = !flag;
        }else{
            cin >> f >> c;
            if(flag){//反転偶数回なのでそのまま演算
                if(f==1){
                    tmp = c + tmp;
                    //S = c + S;
                }else{
                    S += c;
                }
            }else{//反転奇数回なので逆に演算
                if(f==1){
                    S += c;
                }else{
                    tmp = c + tmp;
                    //S = c + S;
                }
            }
        }
    }
    S = tmp + S;
    if(!flag){
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
    


    
    
    return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>
main(){int H,W,a,b;while(1){scanf("%d %d",&H,&W);if(H==0 && W==0){break;}for(a=1;a<=H;a++){for(b=1;b<=W;b++){if(a%2==1){if(b%2==1)printf("#");else printf(".");}else{if(b%2==1)printf(".");else printf("#");}}printf("\n");}printf("\n");}return 0;}

Measured memory_bytes: 572
#include <iostream>

using namespace std;

int main() {
  int w,h,x,y;
  cin >> w;
  cin >> h;
  cin >> x;
  cin >> y;

  cout << (1l*w*h/2.0) << endl;
  
  cout << (x*2 == w && y*2 == h ? 1 : 0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
j=10501
l=[0 for i in range(j)]
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      v=x*x+y*y+z*z+y*x+x*z+z*y
      if(v<j):
        l[v]+=1
for i in range(n):
  print(l[i+1])

Measured memory_bytes: 74368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc158/tasks/abc158_d>
 問題文============================================================
 D - String Formation
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    
    deque<char> Sq;
    for(auto c:S) Sq.push_back(c);
    bool turn = false;

    int Q; cin >> Q;
    while(Q--){
        int T; cin >> T;
        if(T == 1){
            turn = !turn;
        }else{
            int F; char c; cin >> F >> c;
            F--;
            if(turn) F = !F;
            
            if(F){
                Sq.push_back(c);
            }else{
                Sq.push_front(c);
            }
        }
    }
    if(turn) reverse(Sq.begin(),Sq.end());
    res = string(Sq.begin(),Sq.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 0;
  rep(i, n-k) ans += h[i];
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

const double EPS = 1e-8, PI = acos(-1);

inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

using Point = complex< double >;

istream &operator>>(istream &is, Point &p) {
  double a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}

ostream &operator<<(ostream &os, Point &p) {
  os << fixed << setprecision(10) << p.real() << " " << p.imag();
}

Point rotate(double theta, const Point &p) {
  return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag());
}

double radian_to_degree(double r) {
  return (r * 180.0 / PI);
}

double degree_to_radian(double d) {
  return (d * PI / 180.0);
}

double get_angle(const Point &a, const Point &b, const Point &c) {
  const Point v(b - a), w(c - b);
  double alpha = atan2(v.imag(), v.real()), beta = atan2(w.imag(), w.real());
  if(alpha > beta) swap(alpha, beta);
  double theta = (beta - alpha);
  return min(theta, 2 * acos(-1) - theta);
}

namespace std {
  bool operator<(const Point &a, const Point &b) {
    return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
  }
}


struct Line {
  Point a, b;

  Line() {}

  Line(Point a, Point b) : a(a), b(b) {}

  Line(double A, double B, double C) // Ax + By = C
  {
    if(eq(A, 0)) a = Point(0, C / B), b = Point(1, C / B);
    else if(eq(B, 0)) b = Point(C / A, 0), b = Point(C / A, 1);
    else a = Point(0, C / B), b = Point(C / A, 0);
  }

  friend ostream &operator<<(ostream &os, Line &p) {
    return os << p.a << " to " << p.b;
  }

  friend istream &operator>>(istream &is, Line &a) {
    return is >> a.a >> a.b;
  }
};

struct Segment : Line {
  Segment() {}

  Segment(Point a, Point b) : Line(a, b) {}
};

double dot(const Point &a, const Point &b) {
  return real(a) * real(b) + imag(a) * imag(b);
}

Point projection(const Line &l, const Point &p) {
  double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + (l.a - l.b) * t;
}


int main() {
  Line l;
  cin >> l;
  int Q;
  cin >> Q;
  while(Q--) {
    Point p;
    cin >> p;
    p = projection(l, p);
    cout << fixed << setprecision(10) << p.real() << " " << p.imag() << endl;
  }
}



Measured memory_bytes: 3364
#include <stdio.h>

int main(void){
	int i , j , a[4] , b[4] , hit , blow;
	while(scanf("%d %d %d %d" , &a[0] , &a[1] , &a[2] , &a[3])!=EOF){
		hit = 0;
		blow = 0;
		scanf("%d %d %d %d" , &b[0] , &b[1] , &b[2] , &b[3]);
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j) hit++;
					else blow++;
				}
			}
		}
		printf("%d %d\n" , hit , blow);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class NodeRef{
    Node node;
}

enum Color{
    RED,
    BLACK
}

class Node{
    Node left;
    Node right;
    Node next;
    int data;
    int lis;
    int height;
    int size;
    Color color;

    public static Node newNode(int data){
        Node n = new Node();
        n.left = null;
        n.right = null;
        n.data = data;
        n.lis = -1;
        n.height = 1;
        n.size = 1;
        n.color = Color.RED;
        return n;
    }
}

// BST
public class Main {
    public Node addNode(int data, Node head){
        Node tempHead = head;
        Node n = Node.newNode(data);
        if(head == null){
            head = n;
            return head;
        }
        Node prev = null;
        while(head != null){
            prev = head;
            if(head.data < data){
                head = head.right;
            }else{
                head = head.left;
            }
        }
        if(prev.data < data){
            prev.right = n;
        }else{
            prev.left = n;
        }
        return tempHead;
    }

    class IntegerRef{
        int height;
    }

    public int height(Node root){
        if(root == null){
            return 0;
        }
        int leftHeight  = height(root.left);
        int rightHeight = height(root.right);
        return Math.max(leftHeight, rightHeight) + 1;
    }

    public static void preOrder(Node node) {
        if(node != null) {
            System.out.print(" " + node.data);
            preOrder(node.left);
            preOrder(node.right);
        }
    }

    public static void inOrder(Node node) {
        if(node != null) {
            inOrder(node.left);
            System.out.print(" " + node.data);
            inOrder(node.right);
        }
    }

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = "";
        int x = 0;

        Node head = null;
        Main bt = new Main();
        for(int i = 0; i < n; i++) {
            s = sc.next();
            if(s.equals("insert")){
                head = bt.addNode(sc.nextInt(),head);
            } else if(s.equals("print")) {
                inOrder(head);
                System.out.println();
                preOrder(head);
                System.out.println();
            }
        }
        
    }
}



Measured memory_bytes: 235200
N = int(input())
A = list(map(int, input().split()))
left = [0] * (N+1)
right = [0] * (N+1)
for i, a in enumerate(A):
    i = i+1
    if i+a <= N:
        left[i+a] += 1
    if i-a >= 1:
        right[i-a] += 1
ans = 0
for l, r in zip(left, right):
    ans += l * r
print(ans)

Measured memory_bytes: 32376
#include <stdio.h>
int main(int argc, char *argv[])
{
	int S[10000],T[500],n,q,i,j,k,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&S[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	scanf("%d",&T[i]);
	//
	for(i=0;i<q;i++)
	{
		k=T[i];
		for(j=0;j<n;j++)
		if(S[j]==k)
		{
			count++;
			break;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2040
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	map<int, int> m[2];
	for (int i = 0; i < n; ++i) {
		int v;
		cin >> v;
		m[i % 2][v] += 1;
	}
	vector<II> a[2];
	for (int i = 0; i < 2; ++i) {
		for (const auto kv : m[i]) {
			a[i].push_back(II(kv.second, kv.first));
		}
	}
	sort(a[0].rbegin(), a[0].rend());
	sort(a[1].rbegin(), a[1].rend());
	int ans = 1 << 30;
	for (int i = 0; i < min(4, (int)a[0].size()); ++i) {
		for (int j = 0; j < min(4, (int)a[1].size()); ++j) {
			int p = n - a[0][i].first;
			int q = n - a[1][j].first;
			if (a[0][i].second != a[1][j].second) {
				p -= a[1][j].first;
				q -= a[0][i].first;
			}
			ans = min({ ans, p, q });
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6140
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;

const int MN = 1e5 + 5;
char str[MN];
int result[MN];
int main()
{
	scanf("%s", str);
	int temp = 0, len = strlen(str);
	for (int i = 0; i < len; i++)
	{
		if(str[i] == 'R') temp++;
		if (str[i] == 'R' && str[i + 1] == 'L')
		{
			result[i] += (temp + 1) / 2;
			result[i + 1] += temp / 2;
			temp = 0, i++;
		}
	}
	temp = 0;
	for (int i = len - 1; i >= 0; i--)
	{
		if(str[i] == 'L') temp++;
		if (str[i] == 'L' && str[i - 1] == 'R')
		{
			result[i] += (temp + 1) / 2;
			result[i - 1] += temp / 2;
			temp = 0, i--;
		}
	}
	for (int i = 0; i < len; i++) printf("%d ", result[i]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size()
typedef unsigned long long ull;
typedef long long  ll;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	// freopen("input.txt","r",stdin);
	string str,str2;
	cin >> str >> str2;
	int cnt=0;
	for(int i=0;i<siz(str);++i)
		if (str[i]!=str2[i])
			++cnt;
		cout << cnt <<"\n";	






 return 0;
 }


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

struct info {
  int id, p, y;
};

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

  vector<info> v(M);
  rep(i, M) {
    int p, y;
    cin >> p >> y;
    v[i] = {i, p, y};
  }
  sort(v.begin(), v.end(),
       [](auto a, auto b) { return (a.p != b.p) ? a.p < b.p : a.y < b.y; });

  vector<pair<int, int>> ans(M);
  int prev = -1, cnt = 0;
  rep(i, M) {
    auto c = v[i];
    if (c.p != prev)
      prev = c.p, cnt = 0;
    ans[c.id] = make_pair(c.p, ++cnt);
  }

  rep(i, M) printf("%06d%06d\n", ans[i].first, ans[i].second);
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

signed main() {
  string s;
  cin >> s;
  int n = 0;
  rep (i, s.size()) {
    if (s[i] == '+') {
      n++;
    } else {
      n--;
    }
  }

  cout << n << endl;

  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pil;
ll ans=0;
vector<pil> BC;
int N;
bool sortrule (const pil &BC1,const pil &BC2)
{
  return (BC2.second<BC1.second);
}

class Work
{
public:
  ll time,deadline;
  Work(ll _t,ll _d):time(_t),deadline(_d){}
  bool operator < (const Work &a) const{
    return (deadline<a.deadline);
  }
};
int main(void)
{
  cin >> N;
  vector<Work> works;
  for (int i = 0; i < N; i++)
  {
    ll t,d;
    cin >> t >> d;
    works.push_back(Work(t,d));
  }
  sort(works.begin(),works.end());
  ll now=0;
  for (int i = 0; i < N; i++)
  {
    now+=works[i].time;
    if(now>works[i].deadline)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 6384
<?php
$N = fgets(STDIN);
$P = fgets(STDIN);
$arrayP = explode(" ", $P);

$result = 1;
$min = $arrayP[0];
for($i=1;$i<$N;$i++){
    if($min >= $arrayP[$i]){
        $min = $arrayP[$i];
        $result++;
    }
}
echo $result;

Measured memory_bytes: 40180
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TemplateAlgorithm
{
    class Program
    {
        public const long Inf = (long)1e18;
        public const double eps = 1e-6;
        public const string alfa = "abcdefghijklmnopqrstuvwxyz";
        public const string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const int MOD = 1000000007;
        

        static void Main(string[] args)
        {
            
            int n = IO.ReadInt();
            int count = 0;
            for (var i = 1; i <= n; i++)
            {
                if (i.ToString().ToCharArray().Count() % 2 != 0)
                {
                    count++;
                }
            }
            IO.Cout(count);
        }

        static int ToInt(char c) => c - '0';

        #region MIN,MAX

        /// <summary>
        /// 最大値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MaxValue<T>(params T[] vals) => vals.Max();

        /// <summary>
        /// 最小値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MinValue<T>(params T[] vals) => vals.Min();
        #endregion
    }

    #region IO

    /// <summary>
    /// IO
    /// </summary>
    public class IO
    {
        public static string ReadStr(bool isTrim = false) => (isTrim) ? Console.ReadLine().Trim() : Console.ReadLine();
        public static int ReadInt() => int.Parse(ReadStr());
        public static uint ReadUInt() => uint.Parse(ReadStr());

        public static long ReadLong() => long.Parse(ReadStr());
        public static ulong ReadULong() => ulong.Parse(ReadStr());

        public static decimal ReadDecimal() => decimal.Parse(ReadStr());
        public static double ReadDouble() => double.Parse(ReadStr());
        public static string[] ReadStrArr(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] ReadIntArr() => Array.ConvertAll(ReadStrArr(), int.Parse);
        public static long[] ReadLongArr() => Array.ConvertAll(ReadStrArr(), long.Parse);

        public static ulong[] ReadULongArr() => Array.ConvertAll(ReadStrArr(), ulong.Parse);

        public static decimal[] ReadDecimalArr() => Array.ConvertAll(ReadStrArr(), decimal.Parse);
        public static double[] ReadDoubleArr() => Array.ConvertAll(ReadStrArr(), double.Parse);
            
        public static void Cout<T>(T value) => Console.WriteLine(value);
        public static void CoutJoin<T>(T[] values, string separator = " ") => Cout(string.Join(separator, values));
    }

    #endregion    
}


Measured memory_bytes: 15312
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main{ 
    
    public static void main(String[] args)throws IOException{
	try{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String line;
	 int tyo=0;int hisi=0;

	while((line=br.readLine())!=null){
	    StringTokenizer st =new StringTokenizer(line,",");
	    int a=Integer.parseInt(st.nextToken());
	    int b=Integer.parseInt(st.nextToken());
	    int x=Integer.parseInt(st.nextToken());
	   	    if((a*a+b*b)==x*x&&a!=b)
		tyo++;
	    else
	    if(a==b&&(a+b)>x)
		hisi++;
	}
	System.out.println(tyo);
	System.out.println(hisi);
	}catch(java.lang.NumberFormatException e){
	    System.out.println(e);
	}
    }
}

Measured memory_bytes: 16980
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if ((a <= 8) && (b <= 8)) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }

  }
}

Measured memory_bytes: 35644
N,K = map(int, input().split())
P = list(map(int,input().split()))

li = [0] * (N - K + 1)

max = max(P)
dict = {}
sumList = [0] * max

sumList[0] = 1
dict[1] = 1

for i in range(1, max):
    sumList[i] = sumList[i - 1] + (i + 1)
    dict[i+1] = sumList[i] / (i + 1)

for i in range(K):
    li[0] = li[0] + dict.get(P[i])

#一番大きな数を含む並び順を求める
for i in range(1, N - K + 1):
    li[i] = li[i - 1] - dict.get(P[i - 1]) + dict.get(P[i + K - 1])

#print(li)
print(sorted(li, reverse=True)[0])

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,M;
deque<pair<int,pi>> cur;
map<int,vi> adj[MX];
map<int,int> dist[MX];

int getDist(int a, int b) {
    if (dist[a].count(b)) return dist[a][b];
    return MOD;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    F0R(i,M) {
        int p,q,c; cin >> p >> q >> c;
        adj[p][c].pb(q);
        adj[q][c].pb(p);
    }
    dist[1][0] = 0; cur.pb({0,{1,0}});
    while (sz(cur)) {
        auto a = cur.front(); cur.pop_front();
        if (a.f != dist[a.s.f][a.s.s]) continue;
        
        // cout << a.s.f << " " << a.s.s << "\n";
        if (a.s.f == N) {
            cout << a.f;
            exit(0);
        }
        
        if (a.s.s == 0) {
            for (auto& x: adj[a.s.f]) if (a.f+1 < getDist(a.s.f,x.f)) {
                dist[a.s.f][x.f] = a.f+1; cur.pb({a.f+1,{a.s.f,x.f}});
            }
        } else {
            for (auto& x: adj[a.s.f][a.s.s]) if (a.f < getDist(x,a.s.s)) {
                dist[x][a.s.s] = a.f; cur.push_front({a.f,{x,a.s.s}});
            }
            if (a.f < getDist(a.s.f,0)) {
                dist[a.s.f][0] = a.f; cur.push_front({a.f,{a.s.f,0}});
            }
        }
    }
    cout << -1;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 72448
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N = 2005, MOD = 1000000007;
typedef long long i64;

i64 f[MAX_N][MAX_N], fac[MAX_N * MAX_N], ifac[MAX_N * MAX_N], inv[MAX_N * MAX_N];

i64 binom(int x, int y) {
  if (x < y) return 0;
  return fac[x] * ifac[y] % MOD * ifac[x - y] % MOD;
}

int main() {
  int N, K, tot;
  
  scanf("%d%d", &N, &K), tot = N * K;
  if (K == 1) {
    printf("%d\n", 1);
    return 0;
  }
  fac[0] = ifac[0] = inv[1] = 1;
  
  for (int i = 1; i <= tot; ++i) fac[i] = fac[i - 1] * i % MOD;
  for (int i = 2; i <= tot; ++i) inv[i] = -(MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i <= tot; ++i) ifac[i] = ifac[i - 1] * inv[i] % MOD;

  f[0][0] = 1;
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= i; ++j) {
      if (i > 0) f[i][j] = f[i - 1][j];
      if (j > 0) f[i][j] = (f[i][j] + f[i][j - 1] * binom(N * K - i - (j - 1) * (K - 1) - 1, K - 2) % MOD) % MOD;
    }

  f[N][N] = f[N][N] * fac[N] % MOD;
  printf("%lld\n", (f[N][N] + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 125696
a,b,i,j,N,p,P,t[36],c[36],T[36],C[36];
Q(int *a,int *b){
    for(i=0;i<N;printf("%c%d%s",a[i],b[i],i==N-1?"\n":" "),i++);
}
B(){
    for(i=0;i<N;i++)
    for(j=N-1;j>0;j--)
        if(t[j-1]>t[j]){
            t[j]^=t[j-1]^=t[j]^=t[j-1];
            c[j]^=c[j-1]^=c[j]^=c[j-1];
        }
    Q(c,t);
    puts("Stable");
}
S(){
    for(i=0;i<N;i++){
        for(j=p=i;j<N;j++)if(T[j]<T[p])p=j;
        P=T[p];T[p]=T[i];T[i]=P;
        P=C[p];C[p]=C[i];C[i]=P;
    }
    Q(C,T);
    for(i=p=0;i<N;i++)if(c[i]==C[i]&&t[i]==T[i])p++;
    puts(p==N?"Stable":"Not stable");
}

int main(){
    for(scanf("%d",&N);i<N;scanf(" %c%d",&c[i],&t[i]),T[i]=t[i],C[i]=c[i],i++);
    B();S();

}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;
const int INF = 1000000;

int main()
{
  string s;
  auto split = [](string s, char d) {
    vector<string> elems;
    int p, cnt = 0;
    while ((p = s.find(d)) != s.npos)
    {
      elems.push_back(s.substr(0, p));
      s = s.substr(p + 1);
    }
    if (s.size())
      elems.push_back(s);
    return elems;
  };
  vector<string> ans;
  vector<string> field;
  while (cin >> s, s != "#")
  {
    vector<string> t = split(s, '/');
    field.clear();
    for (int i = 0; i < t.size(); ++i)
    {
      string tmp = "";
      for (int j = 0; j < t[i].size(); ++j)
      {
        if (t[i][j] == 'b')
          tmp += 'b';
        else
          for (int k = 0; k < t[i][j] - '0'; ++k)
            tmp += '.';
      }
      field.push_back(tmp);
    }
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string str = "";
    swap(field[a - 1][b - 1], field[c - 1][d - 1]);
    for (int i = 0; i < field.size(); ++i)
    {
      int cnt = 0;
      for (int j = 0; j < field[i].size(); ++j)
      {
        if (field[i][j] != 'b')
        {
          cnt++;
        }
        else
        {
          if (cnt != 0)
          {
            str += (char)(cnt + '0');
            cnt = 0;
          }
          str += 'b';
        }
      }
      if (cnt != 0)
        str += (char)(cnt + '0');
      str += '/';
    }
    str.pop_back();
    ans.push_back(str);
  }

  for (auto &e : ans)
    cout << e << endl;

  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;using L = long long;using V= pair<L,L>;
#define F first
#define S second
#define I XH[i]
#define R for(L i=0;i<N;i++)
L N,D,A,n=0,r=0,t;V XH[200005];queue<V>P;
int main() {cin>>N>>D>>A;R{cin>>I.F>>I.S;}sort(XH,XH+N);R{while(!P.empty()&P.front().F<I.F){n-=P.front().S;P.pop();}I.S-=n;if(I.S>0){t=(I.S+A-1)/A;r+=t;P.push({I.F+2*D,t*A});n+=t*A;}}cout<<r;} 

Measured memory_bytes: 4992
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 count = 1;
		while(n >= k){
			n /= k;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    memset(dp, 0, sizeof dp);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            if(s[i]==t[j])
                dp[i+1][j+1]=dp[i][j]+1;
            else
                dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
    }
    int len=dp[n][m];
    string ans="";
    for(int i=n-1,j=m-1;i>=0 and j>=0 and len>=0;)
    {
        if(s[i]==t[j]){ans+=s[i];i--,j--;len--;}
        else if(dp[i+1][j]>dp[i][j+1])j--;
        else i--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<"\n";




}

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

struct node
{
	int key;
	node* lc, * rc, * p;
};

node* root = 0;

void insert(int x)
{
	node* pre = root;        //设当前节点为根，以根为起点
	node* temp = pre;        //用来保存当前节点的临时指针

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = 0;
	in->rc = 0;
	in->p = 0;

	while (pre != 0)        //找到将要插入的节点的父节点(当前节点)
	{
		temp = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}
	pre = temp;

	if (pre == 0)           //插入
		root = in;
	else
	{
		if (in->key < pre->key)
			pre->lc = in;
		else
			pre->rc = in;
		in->p = pre;
	}
}

node* Findlater(node* f)
{
	if (f->rc != 0)
	{
		f = f->rc;
		while (f->lc != 0)
			f = f->lc;

		return f;
	}
	else
	{
		while (true)
		{
			if (f->p->key > f->key)
				return f->p;
			else
				f = f->p;
		}
	}
}

void Delete(int de)
{
	node* find = root;             
	node* De;              //将要删除的节点
	node* c;               //De的子节点  

	while (find != 0)
	{
		if (de < find->key)
			find = find->lc;
		else if (de > find->key)
			find = find->rc;
		else
		{
			if (find->lc == 0 || find->rc == 0)           //确认将要删除的节点
				De = find;
			else
				De = Findlater(find);

			if (De->lc != 0)                      //确认De的子节点
				c = De->lc;
			else
				c = De->rc;

			if (c != 0)
				c->p = De->p;

			if (De->p == 0)
				root = c;
			else
			{
				if (De == De->p->lc)
					De->p->lc = c;
				else
					De->p->rc = c;
			}

			if (De != find)
				find->key = De->key;

			break;
		}
	}
}

bool Find(int f)
{
	bool fin = false;

	node* pre = root;
	while (pre != 0)
	{
		if (f < pre->key)
			pre = pre->lc;
		else if (f > pre->key)
			pre = pre->rc;
		else
		{
			fin = true;
			break;
		}

	}

	return fin;
}

void Inorder(node* r)
{
	if (r->lc != 0)
		Inorder(r->lc);

	cout << " " << r->key;
	
	if (r->rc != 0)
		Inorder(r->rc);
}

void Preorder(node * r)
{
	cout << " " << r->key;

	if (r->lc != 0)
		Preorder(r->lc);
	if (r->rc != 0)
		Preorder(r->rc);
}

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

	int n, x;
	string p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p;

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else if (p == "find")
		{
			cin >> x;
			if (Find(x))
				cout << "yes\n";
			else
				cout << "no\n";
		}
		else if (p == "delete")
		{
			cin >> x;
			Delete(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 21928
a = int(input())
b = int(a/10)
a -= b*10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
    print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
elif a == 3:
    print("bon")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    long long a,b;
    cin >>a>>b;
    long long  g = __gcd(a,b);
    long long ans = a*b/g;
    cout << ans <<endl;
}

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


int main(void)
{
	int mati, miti;
	
	cin >> mati >> miti;
	int test[100];
	int ans = 0;

	for (int i=0 ; i < miti * 2;i++) {
		cin >> test[i];
	}
	for (int k = 1; k <= mati; k++) {
		
		for(int j = 0; j < miti * 2; j++) {
			if (test[j] == k) 
				ans++;
			
		}
		cout << ans << endl;
		ans = 0;
	}




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vector<int> c(n, 0);
  for (int i = 0; i < m; i++) {
    c[a[i]]++;
    c[b[i]]++;
  }

  for (int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
int A[101010],B[101010],C[101010];
int D[101010],E[101010];
vector<int> ev[101010];

int minm;
int sum[101010];
int num[101010];
int ng[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i]>>B[i];
	FOR(i,N+1) cin>>C[i];
	sort(C,C+N+1);
	
	FOR(i,N) {
		B[i]=min(A[i],B[i]);
		A[i]=lower_bound(C,C+N+1,A[i])-C;
		B[i]=lower_bound(C,C+N+1,B[i])-C;
		if(B[i]<A[i]) ev[B[i]].push_back(i);
	}
	
	minm=N+2;
	FOR(i,N+1) sum[i]=-1;
	FOR(i,N) sum[A[i]]++;
	
	priority_queue<pair<int,int>> P;
	vector<vector<int>> seg;
	int ret=N;
	FOR(i,N+1) {
		if(i) sum[i]+=sum[i-1], ng[i]+=ng[i-1];
		FORR(e,ev[i]) P.push({A[e],e});
		while(sum[i]<0 && P.size()) {
			int x=P.top().second;
			P.pop();
			sum[i]++;
			sum[A[x]]--;
			seg.push_back({i,A[x]});
			ret--;
		}
		if(sum[i]==-1) {
			minm=min(minm,i);
			ng[i]++;
		}
		if(sum[i]<-1) minm=-1;
	}
	
	int minL=N+2;
	for(i=seg.size()-1;i>=0;i--) {
		if(ng[seg[i][1]-1]==((seg[i][0])?ng[seg[i][0]-1]:0) && seg[i][1]<=minL) {
			num[seg[i][0]]++;
			minL=seg[i][0];
		}
	}
	
	for(i=N+1;i>=0;i--) num[i]+=num[i+1];
	cin>>Q;
	FOR(i,Q) {
		cin>>x>>y;
		x=lower_bound(C,C+N+1,x)-C;
		y=lower_bound(C,C+N+1,y)-C;
		//cout<<x<<y<<" : ";
		int rx=(minm<x)?-1:(N-seg.size()+(num[x]+1));
		int ry=(minm<y)?-1:(N-seg.size()+num[y]);
		
		cout<<max(rx,ry)<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 15152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ll gcd(ll a,ll b) {
    while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
    }
    return a;
}

int main(){
    ll N;
    cin >> N;
    ll X;
    cin >> X;
    vector<ll> x(N,0);
    for(ll i=0;i<N;i++)cin>>x[i];
    vector<ll> y(N,0);
    for(ll i=0;i<N;i++)y[i]=llabs(x[i]-X);
    ll ans=y[0];
    for(ll i=0;i<N;i++){
        ans=gcd(ans,y[i]);
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define sci(a) scanf("%d", &a)
#define scii(a, b) scanf("%d %d", &a, &b)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define pb(a) push_back(a)
#define ll long long
#define oo 1000000007
#define maxN
using namespace std;
int n, m;

int main() {
    //freopen("159A.inp", "r", stdin);
    //freopen("159A.out", "w", stdout);
    scii(n, m);
    int res = (n*(n-1))/2 + (m*(m-1))/2;
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,s;
int solve(int i,int c,int sum){
  if(i<=0){
    if(sum==s) return 1;
    else return 0;
  }
  int res=0;
  for(int j=c;j<10;j++){
    res+=solve(i-1,j+1,sum+j);
  }
  return res;
}
int main(void){
  while(1){
    scanf("%d %d",&n,&s);
    if(!n && !s) break;
    printf("%d\n",solve(n,0,0));
  }
}

Measured memory_bytes: 0