akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define NAME "data"
using namespace std;
typedef long long LL;
typedef double DB;
typedef pair <LL, LL> pLL;
const int NMAX = 1e5+3;
const LL MOD = 1e9+7;

int n, a[NMAX*2];
LL f[NMAX*2], res;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(NAME".inp", "r", stdin);
    //freopen(NAME".out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= 2*n; ++i) {
        char c;
        cin >> c;
        if(c == 'B') a[i] = 1;
        else a[i] = 0;
    }
    if(a[1] == 0) {
        cout << 0;
        return 0;
    }
    int sum = 1, cnt = 1;
    for(int i = 2; i <= 2*n; ++i) {
        if(sum == a[i]) a[i] = -1;
        else a[i] = 1;
        sum = (sum + a[i] + 2) % 2;
        cnt += (a[i] == 1);
    }
    if(cnt != n) {
        cout << 0;
        return 0;
    }
    cnt = 0;
    res = 1;
    for(int i = 1; i <= n; ++i) res = res * i % MOD;
    for(int i = 2*n; i >= 1; --i) {
        if(a[i] == -1) cnt++;
        if(a[i] == 1) {
            res = res * cnt % MOD;
            cnt--;
        }
    }
    cout << res;
    return 0;
}


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

using namespace std;
string n;
int main(){
	cin>>n;
	int l=0,r=n.length()-1;
	while(l<=r){
		if(n[l]!=n[r]){
			cout<<"No";
			return 0;
		} 
		r--;
		l++;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

  if ( a < b )
    std::cout << "a < b" << std::endl;
  else if ( a > b )
    std::cout << "a > b" << std::endl;
  else
    std::cout << "a == b" << std::endl;

  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int inp(){
	int Ans;char C;bool O=false;
	while((C=getchar())<'0'||C>'9')if(C=='-')O=true;Ans=C-48;
	while((C=getchar())>='0'&&C<='9')Ans=(Ans<<3)+(Ans<<1)+C-48;
	return O==true?-Ans:Ans;
}

int n;
string s;
int cnt;

int main(){
	n=inp();
	cin>>s;
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  if(S == "AAA" || S == "BBB"){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
    
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
ans = A * X + B * Y
for z in range(0, 2*max(X, Y)+1, 2):
    a = C*z + A * max(0,X - z//2) + B * max(0, Y - z//2)
    ans = min(ans, a)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A,B,C,D;
	string S;
	scan(N>>A>>B>>C>>D>>S);
	A--; B--; C--; D--;
	int flag=1;
	for(int i=A;i<C;i++){
		if(S[i]=='#'&&S[i+1]=='#') flag=0;
	}
	for(int i=B;i<D;i++){
		if(S[i]=='#'&&S[i+1]=='#') flag=0;
	}
	if(C>D){
		int oooexist=0;
		for(int i=B-1;i<=D-1&&i+2<=N-1;i++){
			if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.') oooexist=1;
		}
		if(oooexist==0) flag=0;
	}
	if(flag) prin("Yes");
	else prin("No");
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
// #include<algorithm>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
  	if (a%3==0 || b %3==0 || (a+b) %3 ==0) cout<<"Possible"
<<endl;
    else cout<<"Impossible"<<endl; 
    return 0;
}


Measured memory_bytes: 384
/*
 * main.c
 *
 *  Created on: 2018/10/05
 *      Author: londo
 */


#include<stdio.h>

int main (){
	int N; scanf("%d",&N);
	while(1){
		int a = N%10;
		int b = N/100;
		int c = (N-b*100)/10;
		if((a==b)&&(b==c))break;
		N++;
	}
	printf("%d\n",N);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
 

void func()
{
   ll n;
   cin>>n;
   ll curr=1000;
   while(curr<n) curr+=1000;
   cout<<curr-n<<endl;
}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
       func();
    }
     
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef pair<int, int> pii;
typedef double lf;
typedef long long ll;
#define int long long
const int inf=0x3f3f3f3f, mod=1000000007;
pii a[200200];

inline int read()
{
    int x=0,f=1; char ch=getchar();
    for (; ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') f=-1;
    for (; ch>='0' && ch<='9'; ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

multiset<int> A, B;
int calc(){return (*A.rbegin()-*A.begin())*(*B.rbegin()-*B.begin());}

signed main()
{
    int n=read();
    for (int i=1; i<=n; i++) 
    {
        int x=read(), y=read(); if (x>y) swap(x, y);
        A.insert(x); B.insert(y);
        a[i].first=x; a[i].second=y;
    }
    int ans=calc();
    sort(a+1, a+n+1);
    for (int i=1; i<=n; i++)
    {
        int x=a[i].first, y=a[i].second;
        A.erase(A.find(x)); A.insert(y);
        B.erase(B.find(y)); B.insert(x);
        ans=min(ans, calc());
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 0
//#define int ll
using namespace std;
// set of vertices
using vgrp_t = std::vector<int>;

// graph (adjacency list)
using graph_t = std::vector<vgrp_t>;

graph_t reverse_graph(graph_t const &g) {
    graph_t rg(g.size());
    for (int i = 0; i < static_cast<int>(g.size()); i++) {
        for (int to : g[i]) rg[to].push_back(i);
    }
    return rg;
}

std::vector<std::pair<int, int>> make_numbering(graph_t const &g) {
    // std::pair<int, int> = { order in postorder DFS, vertex number }
    // order | -1 => not yet visited
    //       | -2 => now searching
    std::vector<std::pair<int, int>> numbering(g.size(),
                                               std::make_pair(-1, 0));

    std::function<int(int, int)> dfs = [&](int v, int num) {
        // if v is already visited, do nothing.
        if (numbering[v].first != -1) return num;
        numbering[v].first = -2;
        for (int to : g[v]) num = dfs(to, num);
        numbering[v] = std::make_pair(num, v);
        return num + 1;
    };

    int num = 0;
    for (int i = 0; i < static_cast<int>(g.size()); i++) {
        if (numbering[i].first == -1) num = dfs(i, num);
    }

    return numbering;
}

class strongly_connected_components_t {
  private:
    std::vector<int> scc_of_;
    int size_;

  public:
    strongly_connected_components_t(std::vector<int> scc_of, int size)
        : scc_of_(scc_of)
        , size_(size) {}
    int size() const { return size_; }
    int scc_of(int v) const { return scc_of_[v]; }
};

strongly_connected_components_t
decompose_impl(graph_t const &rg,
               std::vector<std::pair<int, int>> const &numbering) {
    std::vector<int> scc_of(rg.size(), -1);

    // mark a strongly connected components beginning from vertex v with
    // `num`.
    std::function<void(int, int)> dfs = [&](int v, int num) {
        scc_of[v] = num;
        // add not yet decomposed vertices in adjacent vertices
        for (int to : rg[v]) {
            if (scc_of[to] != -1) continue;
            dfs(to, num);
        }
    };

    int num = 0;
    for (auto const &p : numbering) {
        int v = p.second;
        if (scc_of[v] == -1) dfs(v, num++);
    }
    return strongly_connected_components_t(scc_of, num);
}

strongly_connected_components_t decompose_into_sccs(graph_t const &g) {
    auto numbering = make_numbering(g);
    std::sort(numbering.begin(), numbering.end(),
              std::greater<std::pair<int, int>>());
    return decompose_impl(reverse_graph(g), numbering);
}

signed main() {
    int V,E,Q,s,t;
    cin >> V >> E;
    graph_t ss(V);
    rep(i,E) {
        cin >> s >> t;
        ss[s].push_back(t);
    }
    auto setted = decompose_into_sccs(ss);
    cin >> Q;
    rep(i,Q) {
        cin >> s >> t;
        if(setted.scc_of(s) == setted.scc_of(t)) puts("1");
        else puts("0");
    }
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int change( string target )
{
	int a = 1;
	int sum = 0;

	for( int i = 0;i < target.size();i++ ){
		if( target[i] == 'r' ) target[i] = 0;
		else if( target[i] == 'g' ) target[i] = 1;
		else if( target[i] == 'b' ) target[i] = 2;
		
		sum += target[i] * a;
		a *= 3;
	}

	return sum;
}

		

int bfs( string target )
{
	set<int> history;
	queue<string> data;
	map<string,int> dist;

	data.push( target );
	dist[target] = 0;

	while( !data.empty() ){
		const string u = data.front();
		if( count( u.begin(), u.end(), 'r' ) == u.size() || count( u.begin(), u.end(), 'g' ) == u.size() || count( u.begin(), u.end(), 'b' ) == u.size() ) return dist[u];

		for( int i = 0;i < u.size() - 1;i++ ){
			if( u[i] != u[i + 1] ){
				string hoge = u;
				hoge[i] = hoge[i + 1] = ( 'r' + 'g' + 'b' ) - ( hoge[i] + hoge[i + 1] );
				int piyo = change( hoge );
				if( history.count( piyo ) ) continue;
				history.insert( piyo );
				data.push( hoge );
				dist[hoge] = dist[u] + 1;
			}
		}

		data.pop();
	}
	return -1;

}

int main(int argc, char const* argv[])
{
	string target;

	while( cin >> target && target != "0" ){
		int answer = bfs( target );
		if( answer != -1 ) cout << answer << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 2200
package main

import "fmt"

func ReadInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func main() {
	K, A, B := ReadInt(), ReadInt(), ReadInt()
	b, c := 1, false

	if B-A <= 2 {
		fmt.Println(K + 1)
		return
	}

	for i := 0; i < K; i++ {
		if c {
			b += B
			c = false
		} else if b >= A && i != K-1 {
			b -= A
			c = true
		} else {
			b++
		}
	}

	fmt.Println(b)
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))

cur = H[0]

f = True
for hi in H[1:]:
  if cur <= hi:
    cur = hi
  elif cur <= hi + 1:
    cur = hi + 1
  else:
    f = False

if f:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define fprintf(...) void(0)

using namespace std::string_literals;

std::vector<std::string> ops={"|", "^", "&", "+-", "*"};

intmax_t parse(const std::string& s, size_t &i, size_t preced) {
  if (i == s.length()) throw 10;
  if (preced == ops.size()) {
    if (s[i] == '(') {
      intmax_t res=parse(s, ++i, 0);
      if (s[i] != ')') throw 0;
      ++i;
      return res;
    }
    if (s[i] == '0') throw 1;
    if (isdigit(s[i])) {
      intmax_t res=s[i]-'0';
      while (++i < s.length() && isdigit(s[i]))
        res = res*10+s[i]-'0';
      return res;
    }
    // fprintf(stderr, "%s[%zu]\n", s.c_str(), i);
    throw 2;
  }

  intmax_t res=parse(s, i, preced+1);
  while (i < s.length()) {
    intmax_t op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    intmax_t tmp=parse(s, ++i, preced+1);
    if (op == '*') res *= tmp;
    if (op == '+') res += tmp;
    if (op == '-') res -= tmp;
    if (op == '&') res &= tmp;
    if (op == '^') res ^= tmp;
    if (op == '|') res |= tmp;
    if (op == '(' || op == ')' || isdigit(op)) throw 9;
  }
  return res;
}

void validate(const std::string& s) {
  size_t i=0;
  parse(s, i, 0);
  if (i != s.length()) throw 1;
}

intmax_t optimize(const std::string& s, int n, int k) {
  if (s.empty()) throw -1;

  if (k == n) {
    size_t j=0;

    intmax_t res=parse(s, j, 0);
    if (j != s.length()) throw 3;
    fprintf(stderr, "< %s (%jd)\n", s.c_str(), res);
    return res;
  }

  intmax_t res=(k%2? 1e18:-1e18);
  auto opt=[=](intmax_t x, intmax_t y) {
             return k%2? std::min(x, y):std::max(x, y);
           };

  std::string u=".";
  u += s;
  for (char c='1'; c<='9'; ++c) {
    u[0] = c;
    if (k == 0) fprintf(stderr, "--- %s\n", u.c_str());
    try {
      validate(u);
      res = opt(res, optimize(u, n, k+1));
    } catch (int e) {}
  }

  // (1+2+3)
  //       ^

  for (size_t i=0; i<s.length(); ++i) {
    // insertible?
    u[i] = s[i];

    for (char c: "*+-&^|0123456789"s) {
      u[i+1] = c;
      try {
        if (k == 0) fprintf(stderr, "--- %s\n", u.c_str());
        validate(u);
        res = opt(res, optimize(u, n, k+1));
      } catch (int e) {}
    }
  }

  std::string t=s.substr(1);
  for (size_t i=0; i<s.length(); ++i) {
    // removable?
    try {
      if (k == 0) fprintf(stderr, "--- %s\n", t.c_str());
      validate(t);
      res = opt(res, optimize(t, n, k+1));
    } catch (int e) {}
    if (i < t.length()) t[i] = s[i];
  }

  return res;
}

int testcase_ends() {
  int N;
  char buf[16];
  scanf("%d %s", &N, buf);
  std::string s=buf;

  if (N == 0 && s == "#") return 1;

  N %= 2;
  if (!N) N += 2;
  fprintf(stderr, "> %s\n", s.c_str());

  printf("%jd\n", optimize(s, N, 0));
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
}

Measured memory_bytes: 35764
#define N 100
#include<stdio.h>

int main()
{
  int i,j,key;
  /*数値を格納する配列*/
  int A[N];
  /*入力数字数*/
  int sum;
  /*入力数字数input*/
  scanf("%d",&sum);
  /*数字input*/
  for(i=0;i<sum;i++)
    scanf("%d",&A[i]);

  /*昇順にソートする*/
  for(i=0;i<sum;++i){
    key=A[i];
    j=i-1;
while(j>=0&&A[j]>key){
A[j+1]=A[j];
j--;
A[j+1]=key;
   
}
 /*各ステップ表示*/
 for(j=0;j<sum;j++){

   if(j>0)printf(" ");
   printf("%d",A[j]);}

printf("\n");}

return 0;
}

  



Measured memory_bytes: 2712
#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))
//-------------------------------------------------------

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<ll,20> bt;

int N,Q;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) {
		cin>>x;
		bt.add(i,x);
	}
	FOR(i,Q) {
		cin>>j>>x>>y;
		if(j==0) {
			bt.add(x,y);
		}
		else {
			cout<<bt(y-1)-bt(x-1)<<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);
	cout.tie(0); solve(); return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vi l(N), r(N);
    priority_queue<int> lefts, rights;
    for (int i = 0; i < N; i++) {
        cin >> l[i] >> r[i];
        lefts.push(-r[i]);
        rights.push(l[i]);
    }

    lefts.push(0);
    rights.push(0);

    ll ans = 0, cur = 0;
    for (int k = 0; k <= N; k++) {
        cur += 2 * (rights.top() + lefts.top());
        rights.pop();
        lefts.pop();
        ans = max(ans, cur);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2044
import math

n = int(input())

nontax = math.floor(n / 1.08)

if math.floor(nontax * 1.08) == n:
    print(nontax)
elif math.floor((nontax + 1) * 1.08) == n:
    print(nontax+1)
else:
    print(':(')

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& poRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(poRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(poRoot);
      cout << endl;
      fnPreOrder(poRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26600
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000;
int H,W,h,w;
int main()
{
	cin>>H>>W>>h>>w;
	if (H%h==0&&W%w==0)
	{
		cout<<"No";
		return 0;
	}
	else
	{
		cout<<"Yes"<<endl;
		int t=(H/h)*(W/w);
		int x=t+1,y=(t+1)*(h*w-1)+1;
		for (int i=1;i<=H;i++)
			for (int j=1;j<=W;j++)
			{
				if (i%h==0&&j%w==0) printf("%d",-y);
				else printf("%d",x);
				if (j<W) printf(" ");
				else printf("\n");
			}
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
string s;
int dp[MAXN];
void Solve() {
    cin >> s;
    dp[0] = 1;
    for(int i = 1 ; i <= s.length() ; ++i) {
	if(i >= 5) {
	    dp[i] |= (dp[i - 5] && s.substr(i - 5,5) == "dream");
	    dp[i] |= (dp[i - 5] && s.substr(i - 5,5) == "erase");
	}
	if(i >= 6) {
	    dp[i] |= (dp[i - 6] && s.substr(i - 6,6) == "eraser");
	}
	if(i >= 7) {
	    dp[i] |= (dp[i - 7] && s.substr(i - 7,7) == "dreamer");
	}
    }
    if(dp[s.length()]) puts("YES");
    else puts("NO");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 500005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#else
#endif
    scanf("%d", &n);
    bool flag = false;
    while (n) {
        if (n % 10 == 7) {
            flag = true;
            break;
        }
        n /= 10;
    }
    printf("%s\n", flag ? "Yes" : "No");
    return 0;
}

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

#define int long long int
#define MOD 1000000007

int dp[100005][5] ;

int32_t main()
{
    
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
       int n ;
       cin >> n ;
       int a[n][3] ;
       for(int i = 0 ; i < n ; i++)
       {
           for(int j = 0 ; j < 3 ; j++)
           {
               cin >> a[i][j] ;
               dp[i+1][j] = a[i][j] ;
           }
       }
       for(int i = 1 ; i <= n ; i++)
       {
           for(int j = 0 ; j < 3 ; j++)
           {
               if(j == 0)
               {
                   dp[i][j] = dp[i][j] + max(dp[i-1][1], dp[i-1][2]) ;
               }
               else if(j == 2)
               {
                   dp[i][j] = dp[i][j] + max(dp[i-1][0], dp[i-1][1]) ;
               }
               else
                   dp[i][j] = dp[i][j] + max(dp[i-1][0], dp[i-1][2]) ;
           }
       }
       int ans = 0 ;
       for(int i = 0 ; i < 3 ; i++)
           ans = max(ans, dp[n][i]) ;
       cout << ans << endl ;       
    }
    return 0 ;
}

Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[305][305],d2[305][305];
pair<int,pii> ps[SZ];
int main()
{
	scanf("%d",&n);
	int pn=0;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			d2[i][j]=(i==j)?0:(1e9+100);
	for(int i=1; i<=n; ++i)
	{
		for(int j=1; j<=n; ++j)
		{
			scanf("%d",&a[i][j]);
		}
	}
	ll ans=0;
	for(int i=1; i<=n; ++i)
	{
		for(int j=1; j<=n; ++j)
		{
			bool r=0;
			for(int k=1; k<=n; ++k)
			{
				if(k==i||k==j) continue;
				if(a[i][j]>a[i][k]+a[k][j])
				{
					puts("-1");
					return 0;
				}
				if(a[i][j]==a[i][k]+a[k][j])
					r=1;
			}
			if(!r) ans+=a[i][j];
		}
	}
	cout<<ans/2<<"\n";
}


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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var tmp = new long[n];
            var aa = a.OrderByDescending(x => x).ToArray();
            long ans = 0;
            for (int i = 0; i < n - 1; i++)
            {
                if (n == 0)
                {
                    ans += aa[0];
                }
                ans += aa[(i + 1) / 2];
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 52832
#include <bits/stdc++.h>
 
int64_t gcd(int64_t a, int64_t b)
{
  int64_t m = std::abs(std::max(a, b)), n = std::abs(std::min(a, b));
  return (n == 0) ? m : gcd(n, m % n);
}
 
int main()
{
  int64_t N, X;
  std::cin >> N >> X;
  
  std::vector<int64_t> x(N);
  for (int64_t n = 0; n < N; ++n) {
    std::cin >> x[n];
    
    x[n] -= X;
  }
  
  int64_t y = gcd(x[0], x[0]);
  for (int64_t n = 1; n < N; ++n) {
    y = gcd(x[n], y);
  }
  std::cout << y << std::endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int ans=40;
  for(int i=0;i<N;i++){
  int x;
    cin>>x;
    int sum=0;
    for(int j=x; ; j/=2){
    if(j%2==0) 
      sum++;
      else
        break;
    } if(sum<=ans)
      ans=sum;
  
  }cout<<ans<<endl;
  
  
   return 0;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

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


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};


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

    n--;
    m--;


    vector<ll> x_s(n, 0);
    vector<ll> y_s(m, 0);

    {
        {
            ll before_x;
            cin >> before_x;
            for (ll x = 0; x < n; x++) {
                ll next_x;
                cin >> next_x;
                x_s[x] = next_x - before_x;
                before_x = next_x;
            }
        }
        {
            ll before_y;
            cin >> before_y;
            for (ll y = 0; y < m; y++) {
                ll next_y;
                cin >> next_y;
                y_s[y] = next_y - before_y;
                before_y = next_y;
            }
        }
    }

    mint x_sum = 0;

    for (ll x = 0; x < n; x++) {
        ll left = x + 1;
        ll right = n - x;
        ll k = left * right;
        ll s = x_s[x] * k;
        x_sum += s;
    }

    mint y_sum = 0;
    for (ll y = 0; y < m; y++) {
        ll left = y + 1;
        ll right = m - y;
        ll k = left * right;
        ll s = y_s[y] * k;
        y_sum += s;
    }

    mint sum = x_sum * y_sum;

    cout << sum.x << endl;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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

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

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

    int n, m;
    cin >> n >> m;

    int l = 1;
    int r = n;
    for (int i = 0; i < m; ++i) {
        int tl, tr;
        cin >> tl >> tr;
        l = max(l, tl);
        r = min(r, tr);
    }
    int ans = r - l + 1;
    if (ans < 0) ans = 0;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	long long x,k,d;
	cin>>x>>k>>d;

	if(x>=0)
	{
		long long op=x/d;
		if(op>=k)
		{
			cout<<(x-k*d);
		}

		else
		{
			k=k-op;
			x=x-op*d;

			if(k%2)
				cout<<abs(x-d);

			else
				cout<<x;
		}
	}

	else
	{
		x=-1*x;
		long long op=x/d;
		if(op>=k)
		{
			cout<<(x-k*d);
		}

		else
		{
			k=k-op;
			x=x-op*d;

			if(k%2)
				cout<<abs(x-d);

			else
				cout<<x;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
n=int(input())
l=[list(map(int,input().split()))for _ in[0]*n]
dp=l[0]
for i,s in enumerate(l):
    if not i:continue
    d=[]
    for i,t in enumerate(s):
        d.append(max(t for j,t in enumerate(dp)if i!=j)+t)
    dp=d
print(max(dp))

Measured memory_bytes: 31348
#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() {
    ll d,t,s;
    cin >> d >> t >> s;
    if(d <= t*s){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(){
    int n;
    while(cin >>  n && n){
        int a=0,t1,t2;
        for(int i=1;i<n/2+3;i++){
            t1=2*i+1,t2=i+1;
            while(t1<n){
                t2++;
                t1+=t2;
            }
            if(t1==n)
                a++;
        }
        cout<<a<<endl;
    }
}

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

#define int  int

int N;
long long unsigned int t[100];

long long unsigned int gcd(long long unsigned int a, long long unsigned int b){
    long long unsigned int r, tmp;
    if(a < b){
        tmp = a; a = b; b = tmp;
    }
    while(b > 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
long long unsigned int lcm(long long unsigned int a, long long unsigned int b){
    return a/gcd(a,b)*b;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> t[i];
    long long unsigned int mul = t[0];
    for(int i = 1; i < N; i++)
        mul = lcm(mul, t[i]);

    cout << mul;
    return 0;
}

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

using namespace std;

int main(){
	int n, l; cin >> n >> l;
	
	int ans, eat, left = l, right = l + n - 1, m = n * l + (n*n+n)/2 - n;
	if(left > 0) eat = left;
	else if(right < 0) eat = right;
	else eat = 0;
	
	ans = m - eat;
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	vector<pair<pair<string,int>,int>> data(n);
	rep(i, n) {
		string s;
		int p;
		cin >> s >> p;
		pair<string, int> now1 = make_pair(s, -p);
		pair<pair<string, int>, int> now = make_pair(now1, i + 1);
		data[i] = now;
	}
	sort(data.begin(), data.end());
	for (auto c : data) {
		cout << c.second << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

	if (A * C <= B) {
		cout << C << endl;
	}
	else {
		cout << B / A << endl;
	}
}

Measured memory_bytes: 3536
#include <iostream>
#include <sstream>

int main() {
    int stack[300];
    int *ptr = stack;

    std::string input;
    std::getline(std::cin, input);
    std::stringstream sin(input);

    std::string val;
    while (sin >> val) {
        if (val == "+") {
            ptr[-2] = ptr[-2] + ptr[-1];
            ptr--;
        } else if (val == "-") {
            ptr[-2] = ptr[-2] - ptr[-1];
            ptr--;
        } else if (val == "*") { 
            ptr[-2] = ptr[-2] * ptr[-1];
            ptr--;
        } else {
            ptr[0] = std::atoi(val.c_str());
            ptr++;
        }
    }

    std::cout << ptr[-1] << std::endl;
}



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

int main() {
  vector<char> A(3), B(3);
  for (int i = 0; i < 3; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < 3; i++) {
    cin >> B.at(i);
  }

  if ((A.at(0) == B.at(2)) && (A.at(1) == B.at(1)) && (A.at(2) == B.at(0))) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,q,a[N],ans;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
		ans+=x;
	}
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		ans+=(c-b)*a[b];
		a[c]+=a[b];
		a[b]=0;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
    COUT("GREATER");
    return 0;
  }

  if (A.size() < B.size()) {
    COUT("LESS");
    return 0;
  }

  rep(i, A.size()) {
    ll a = A[i] - '0';
    ll b = B[i] - '0';
    if (a == b) continue;
    if (a > b) {
      COUT("GREATER");
      return 0;
    } else {
      COUT("LESS");
      return 0;
    }
  }
  COUT("EQUAL");
  return 0;
}

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

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

  int64_t eucA = A;
  int64_t eucB = B;
  int64_t euc = 0;

  while(eucA % eucB != 0){
    euc = eucA % eucB;
    eucA = eucB;
    eucB = euc;
  }
  
  int64_t CD = eucB;

  int ans = 1; //1

  if(CD > 1){
    int64_t D = CD;
    for(int64_t i=2; i*i<=D; i++){
      if(D % i == 0){
        ans++;
        while(D % i == 0){
          D /= i;
        }
      }
      if(D <= 1){
        break;
      }
    }
    if(D > 1){
      ans++;
    }
  }
  
  cout << ans << endl;
}

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

#define DEBUG(x) cerr << #x << " = " << x << endl

int main() {
    int t; cin >> t;
    vector<double> expect;
    while(t--) {
        int n, m; cin >> n >> m;
        double s = 0;
        double u = 0;
        while(m--) {
            double v, r; cin >> v >> r;
            s += v * r;
            u += r;
        }
        expect.push_back(s / u);
    }

    int p, q; cin >> p >> q;
    double e = 0;
    double u = 0;
    for(int i = 0; i < q; i++) {
        double v, r; cin >> v >> r;
        e += v * r;
        u += r;
    }

    e /= u;

    bool ok = false;
    for(auto& es : expect) {
        ok |= (es > e + 0.0000001);
    }
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1256
# AGC 025: A – Digits Sum
n = int(input())
answer = 999999999

for i in range(1, n // 2 + 1):
    num_A = str(i)
    num_B = str(n - i)

    sum_digits_A = sum([int(j) for j in num_A])
    sum_digits_B = sum([int(j) for j in num_B])

    answer = min(answer, sum_digits_A + sum_digits_B)

print(answer)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	b := scanInt()
	c := scanInt()
	fmt.Fprintln(wr, min(c, b/a))
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type graph struct {
	friend []int
	index int
}
func main() {
	scan_init()
	n := scanInt()
	m := scanInt()
	a := make([]int, m)
	b := make([]int, m)
	graphs := make([]graph, n)
	groups := [][]int{}
	for i:= 0; i<n; i++ {
		graphs[i].friend = []int{}
		graphs[i].index = i
	}
	for i:= 0; i<m; i++ {
		a[i] = scanInt()-1
		b[i] = scanInt()-1
		graphs[a[i]].friend = append(graphs[a[i]].friend, b[i])
		graphs[b[i]].friend = append(graphs[b[i]].friend, a[i])
	}
	checkers := make([]bool, n)
	que := []int{}
	groupIndex := 0
	for i:= 0; i<n; i++ {
		if checkers[i] {
			continue
		}
		groups = append(groups, []int{})
		que = append(que, i)
		for len(que) > 0 {
			var value int
			value,que = shift(que)
			if checkers[value] {
				continue
			}
			checkers[value] = true
			groups[groupIndex] = append(groups[groupIndex], value)
			que = append(que, graphs[value].friend...)
		}
		groupIndex++
	}
	ans := 0
	for i:= 0; i<len(groups); i++ {
		if ans < len(groups[i]) {
			ans = len(groups[i])
		}
	}
	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}
func shift(slice []int) (int, []int) {
	n := len(slice)
	value := slice[0]
	popSlice := slice[1:n]
	return value, popSlice
}

Measured memory_bytes: 44548
<?php

[$N, $D] = explode(' ', trim(fgets(STDIN)));
$squareD = pow($D, 2);
$cnt = 0;

for($i = 0; $i < $N; $i++) {
  [$x, $y] = explode(' ', trim(fgets(STDIN)));
  if((pow($x, 2) + pow($y, 2)) <= $squareD) $cnt++;
}

echo $cnt, "\n";


Measured memory_bytes: 16104
from itertools import permutations as pr

n=int(input())
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]

fir = sorted(list(pr(p)))
sec = sorted(list(pr(q)))

for i in range(len(fir)):
    fir[i] = list(fir[i])
    sec[i] = list(sec[i])

a = fir.index(p)
b = sec.index(q)

print(abs(a-b))


Measured memory_bytes: 21560
///******* In the name of Allah *******///

#include<bits/stdc++.h>
using namespace std;

int main ()
{
    long long int c,m,n,i,j,k,l,ans_c;
    double ans_a,ans_b,a,b;
    cin>>a>>b;
    for(i=1;i<=10000013;i++)
    {
        ans_a = a*i;
        ans_b = ans_a/b;
        if(ans_b==(int)ans_b)
        {
            ans_c = ans_a;
            cout<<ans_c<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
people = int(input())
rates = list(map(int, input().split(' ')))
colors = [0 for i in range(8)]

color_var = 0
for i in range(people):
    if rates[i] // 400 <= 7:
        if colors[rates[i] // 400] == 0 :
            colors[rates[i] // 400] += 1
    else:
        color_var += 1
        
min_colors = max(colors.count(1), 1)
max_colors = colors.count(1) + color_var

print(min_colors, max_colors)

Measured memory_bytes: 3188
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var robots = new Tuple<long, long>[n];
        for(int i = 0; i < n; i++)
        {
            var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            robots[i] = new Tuple<long, long>(inputs[0] - inputs[1], inputs[0] + inputs[1]);
        }

        // 終点が最短になるよう貪欲法
        robots = robots.OrderBy(x => x.Item1).OrderBy(x => x.Item2).ToArray();

        int ans = 1;
        long t = robots[0].Item2;       // 選択した区間の中で一番後ろの点
        for(int i = 1; i < n; i++)
        {
            if(t <= robots[i].Item1)
            {
                ans++;
                t = robots[i].Item2;
            }
        }

        Console.WriteLine(ans);
    }
}

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

#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

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

    if (n % k == 0) {
        cout << 0;
    }
    else {
        cout << 1;
    }
}


Measured memory_bytes: 256