akhauriyash/Code-Regression huggingface dataset:
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> C;
    std::vector<int64_t> S;
    std::vector<int64_t> F;

    for (decltype(N) i = 0; i < N-1; ++i) {
        int64_t c, s, f;
        std::cin >> c >> s >> f;
        C.push_back(c);
        S.push_back(s);
        F.push_back(f);
    }


    for (int64_t sta = 0; sta < N; ++sta) {
        int64_t ans = 0;
        for (int64_t i = sta; i < N-1; ++i) {
            // 出発時刻
            if (ans <= S[i]) {
                ans = S[i];
            }
            else {
                auto s = ans - S[i];
                s = ceil(s, F[i]) * F[i];
                ans = S[i] + s;
            }
            // かかる時刻
            ans += C[i];
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a, b;
	cin >> a >> b;
	string ans;
	if(a.size() > b.size()) ans = "GREATER";
	else if(a.size() < b.size()) ans = "LESS";
	else if(a > b) ans = "GREATER";
	else if(a < b) ans = "LESS";
	else ans = "EQUAL";
	cout << ans << endl;
}


Measured memory_bytes: 256
require "prime"
a, b, k = gets.split(" ").map(&:to_i)

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

a_dev = divisors(a)
b_dev = divisors(b)

ab_dev = a_dev & b_dev

puts ab_dev[-k]

Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] weeks = { "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" };
        String S = sc.next();
        int ans = 0;
        for(int i = 0; i < weeks.length; i++) if(weeks[i].equals(S)) ans = i + 1;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main(){
  string str;
  char ch;
  cin>>str;
  for(int i=0;i<(int)str.size();i++){
    ch=str[i];
    ch-=3;
    if(ch<'A')ch+=26;
    cout<<ch;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <algorithm>

#define fin stdin
#define fout stdout

int main() {
    int a, b, c;
    long long ans = 0;

    fscanf(fin, "%d%d%d", &a, &b, &c);

    if (a % 2 + b % 2 + c % 2 == 3)
        ans = std::min(1LL * a * b, std::min(1LL * a * c, 1LL * b * c));

    fprintf(fout, "%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main (String[] args){
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int[] a = new int[n];
	int[] b = new int[n];
	int max = 0;
	for (int i = 0; i < n; i++) {
	    a[i] = scan.nextInt();
	    max = Math.max(max, a[i]);
	}
	CountingSort(a, b, max);
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < n; i++) {
	    sb.append(b[i]).append(' ');
	}
	System.out.println(sb.toString().trim());
    }
    static void CountingSort (int[] a, int[] b, int k) {
	int n = a.length;
	int[] c = new int[k+1];
	for (int j = 0; j < n; j++) {
	    c[a[j]]++;
	}
	for (int i = 1; i <= k; i++) {
	    c[i] = c[i] +c[i-1];
	}
	for (int j = n - 1; j >= 0; j--) {
	    b[c[a[j]]-1] = a[j];
	    c[a[j]]--;
	}
    }
}

Measured memory_bytes: 534692
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1e9 + 10;

int xs[5001], ys[5001];
int sum[5100][5100];

int main() {

  int N, M; cin >> N >> M;
  vector<int> X, Y;
  rep(i, N) {
    scanf("%d%d", &xs[i], &ys[i]);
    X.push_back(xs[i]); Y.push_back(ys[i]);
  }

  random_shuffle(all(X)), random_shuffle(all(Y));
  sort(X.begin(), X.end()); X.erase(unique(all(X)), X.end());
  sort(Y.begin(), Y.end()); Y.erase(unique(all(Y)), Y.end());

  rep(i, N) {
    sum[upper_bound(all(Y), ys[i]) - Y.begin()][upper_bound(all(X), xs[i]) - X.begin()] ++;
  }

  rep(i, Y.size() + 10) rep(j, X.size() + 10) {
    if(i && j) sum[i][j] -= sum[i-1][j-1];
    if(i) sum[i][j] += sum[i-1][j];
    if(j) sum[i][j] += sum[i][j-1];
  }

  rep(i, M) {
    int rx1, ry1, rx2, ry2; scanf("%d%d%d%d", &rx1, &ry1, &rx2, &ry2);
    int x1 = lower_bound(all(X), rx1) - X.begin();
    int y1 = lower_bound(all(Y), ry1) - Y.begin();
    int x2 = upper_bound(all(X), rx2) - X.begin();
    int y2 = upper_bound(all(Y), ry2) - Y.begin();
    printf("%d\n", sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1]);
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    string S;
    cin >> S;
    int res = 0;
    for (auto&& c : S) {
        if (c == '+') ++res;
        if (c == '-') --res;
    }
    cout << res << endl;
    return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	lli r, g, b, n, cnt = 0;
	cin >> r >> g >> b >> n;
	
	for (int i = 0; r*i <= n; ++i) {
		for (int j = 0; r*i+g*j <= n; ++j) {
			if ( ( n - (r*i+g*j) ) % b == 0 ) {
				cnt++ ;
			}
		}
	}
	
	cout << cnt << '\n';
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
A[10000],B[10000];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i<n?"No":"Yes")){
for(i=0;i<n;i++)scanf("%d",A+i);
qsort(A,n,4,z);
for(i=0;i<n;i++)scanf("%d",B+i);
for(i=0;i<n;i++){for(j=0;j<n;j++)if(B[j])A[i]--,B[j]--;if(A[i])break;}
}exit(0);}

Measured memory_bytes: 732
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
	if(x-r<0 || x+r>W || y-r<0 || y+r>H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
    //freopen("tttt.out", "w", stdout) ;
    //freopen("tttt.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long a,fr,sc,th,bef1=0,bef2=0,bef3=0,ov1,ov2,ov3;
    cin>>a;
    for(int i=0;i<a;i++)
    {
        cin>>fr>>sc>>th;
        ov3=max(bef1,bef2)+th;
        ov2=max(bef1,bef3)+sc;
        ov1=max(bef3,bef2)+fr;
        bef1=ov1;
        bef2=ov2;
        bef3=ov3;
    }
    cout<<max(ov1,max(ov2,ov3));
    return 0;
}

Measured memory_bytes: 256
require 'pp'

h, w, k = gets.split.map(&:to_i)
mat = []
h.times do |i|
    r = gets.chomp!.chars
    mat[i] = r
end

ans = 0
0.upto(h) do |i|
    y = (0..(h-1)).to_a.combination(i).to_a
    y.each do |t1|
        0.upto(w) do |j|
            x = (0..(w-1)).to_a.combination(j).to_a
            
            x.each do |t2|
                count = 0
                t1.each do |h1|
                    t2.each do |w1|
                        if mat[h1][w1] == "#"
                            count += 1
                        end
                    end
                end

                if count == k
                    ans += 1
                end
            end

        end
    end
end

puts ans


Measured memory_bytes: 14528
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long int ll;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//A
	ll N;
	cin>>N;
	map<ll,string>m;
	m[2]=m[4]=m[5]=m[7]=m[9]="hon";
	m[0]=m[1]=m[6]=m[8]="pon";
	m[3]="bon";
	N=N%10;
	cout<<m[N];
}

Measured memory_bytes: 3644
import fractions
import functools

def gcd_list(numbers):
    return functools.reduce(fractions.gcd, numbers)

N,X0=map(int,input().split())
X=list(map(int,input().split()))

X.append(X0)
X.sort()
between = []
for i in range(N):
    sa = X[i+1] - X[i]
    between.append(sa)
print(gcd_list(between))

Measured memory_bytes: 16280
// ref: https://yamakasa.net/atcoder-abc-087-d/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

struct edge{
    int to;
    int cost;
};

bool BFS(vector<int>& vDist, const vector<vector<edge>>& vGraph, int begin){
    vDist[begin] = 0; // cost
    queue<int> que; que.push(begin); // index (from)
    while(que.size()!=0){
        int u = que.front(); que.pop(); // index (from)
        for(int i=0; i<(int)vGraph[u].size(); ++i){
            int v    = vGraph[u][i].to; // u to v
            int cost = vGraph[u][i].cost;
            
            if(vDist[v]!=INT_MAX && vDist[v]!=vDist[u]+cost){ return false; }
            if(vDist[v]==INT_MAX){
                vDist[v] = vDist[u]+cost; // cost of u to v.
                que.push( v );
            }
        }
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M; cin >> N >> M;
    vector<vector<edge>> vGraph(N);
    for(int i=0; i<M; ++i){
        int L, R, D; cin >> L >> R >> D; --L; --R;
        vGraph[ L ].push_back( edge{R, D} );
        vGraph[ R ].push_back( edge{L,-D} );
    }
    
    vector<int> vDist(N, INT_MAX);
    for(int i=0; i<N; ++i){
        if(vDist[i]!=INT_MAX){ continue; }
        if(! BFS(vDist, vGraph, i)){ cout << "No" << endl; return 0; }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 9344
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
}
map<ll,ll> used;
int main()
{
	ll ans=1;
	int n;
	cin >> n;
	ll a[n];
	for(int i = 0;i<n;i++)
	{
		cin >> a[i];
		if(a[i]==0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a[i] <=1000000000000000000/ ans ){
			ans *=a[i];
		}else
		{
			cout << -1 << endl;
			return 0;
		}
	}
		cout << ans << endl;

	return 0;
}

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

long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }
long long num(long long n, long long c, long long d) {
    long long G = GCD(c, d);
    long long L = c / G * d;
    return n - n / c - n / d + n / L;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << num(b, c, d) - num(a-1, c, d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(v[x - 1] == 0){
            cnt++;
        }
        v[x - 1]++;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    if(cnt <= k){
        cout << 0;
    }else{
        for(int i = 0; i < n; i++){
            if(cnt == k){
                break;
            }
            if(v[i] != 0){
                ans += v[i];
                cnt--;
            }
        }
         cout << ans;
    }
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/
vector<int> arr[1009];
map<pair<int,int>,int> m;
struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;

int main(){
    double a,n;

    cin >> n;

    double ans = 0;
    for(int i = 0;i < n;i++){
        cin >> a;
        ans += (1 / a);
    }
    cout << fixed << setprecision(5)<< 1 / ans;

}














Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[21],sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<n;i++)
		if(max(a[i-1],a[i+1])>a[i]&&min(a[i-1],a[i+1])<a[i])
			sum++;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pi acos(-1)

using namespace std;

int main() {
    nl // Bazzi - Paradise

    int a, b;
    cin >> a >> b;
    cout << 6-a-b;   

    return 0;
}

Measured memory_bytes: 3608
// DFSを用いたトポロジカルソート
// 計算量 O(V + E) 
// reference Programming Contest Challenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_4_B

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

template<typename T> struct edge {
  int to;
  edge(int to_) : to(to_) {}
};

template<typename T,template <typename ELEM> class EDGE> struct AdListGraph {
  vector<vector<EDGE<T>>> G;
  vector<bool> used;
  vector<bool> is_ancetor;
  int V;//0,...,|V|-1

  AdListGraph (int V_) {
    Init(V_);
  }

  void Init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);
  }

  // https://faithandbrave.hateblo.jp/entry/20080310/1205149207
  template <typename FROM, class... Args>
  void AddEdge(FROM from, Args&&... arg) {
    G[from].emplace_back(arg...);
  }

  bool DFSForTopologicalSort (int i, vector<int>& sorted) {
    if (is_ancetor[i]) return false;
    if (used[i]) return true;

    used[i] = true;
    is_ancetor[i] = true;

    for(const auto& v : G[i]) {
      if(!DFSForTopologicalSort(v.to, sorted)) return false;
    }

    is_ancetor[i] = false;
    sorted.emplace_back(i);//dfsの帰りがけの順

    return true;
  }

  template<typename ID_TYPE>
  bool TopologicalSort (vector<ID_TYPE>& sorted) { // 成功ならtrue 失敗(DAG出ない)ならfalseを返す
    used.clear();
    used.resize(V,false);
    is_ancetor.clear();
    is_ancetor.resize(V, false);

    sorted.clear();

    rep (i,V) {
      if(!DFSForTopologicalSort(i, sorted)) {
        return false;
      }
    }

    reverse(sorted.begin(),sorted.end());

    return true;
  }

};

using ll = long long;

int main() {
  ll V,E;
  cin >> V >> E;
  AdListGraph<ll,edge> G(V);
  rep(i,E) {
    ll s,t;
    cin >> s >> t;
    G.AddEdge(s,t);
  }

  vector<int> ans;

  cout << !G.TopologicalSort(ans) << endl;

  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
#define djokovic  freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
ll zero = 0;
ll one = 1;
ll gcd(ll a, ll b) {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b) {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1,};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, x, k, a[MAXN], p[MAXN];
void solve()
{
   ll x,y,z;cin>>x>>y>>z;
   cout<<z<<" "<<x<<" "<<y;
}
signed main()
{
    bolt;
    //djokovic;
    solve();
}








Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vll a(n);
	rep(i, n) cin >> a[i];

	map<ll, int> mp;
	rep(i, n) mp[a[i]]++;
	ll sum = 0;
	for(auto i = mp.begin(); i != mp.end(); i++) {
		ll j = i->second;
		if(j >= 2) {
			sum += j*(j-1)/2;
		}
	}

	rep(i, n) {
		int j = mp[a[i]];
		cout << sum - j*(j-1)/2 + (j-1)*(j-2)/2 << endl;
	}
}


Measured memory_bytes: 11008
/*input
1000000
*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


int main() {
	string s;
	cin >> s;
	ll n = s.size(), ans = n;
	for (ll i = 0; i < n - 1; i++){
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, n - i - 1));
		}
	}

	cout << ans << endl;
	return 0;
}



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    int n; cin >> n;
    double res = 0.0;
    rep(i,n){
        double x; string s;
        cin >> x >> s;
        if(s=="BTC")res+=x*380000.0;
        else res+=x;
    }
    cout << fixed << setprecision(6) << res << endl;
}


Measured memory_bytes: 256
n,t = gets.split.map(&:to_i)
returnable_way_cost = []
c = 0

n.times do
  c, time = gets.split.map(&:to_i)
  if time <= t
    returnable_way_cost.push(c)
  end
end

if returnable_way_cost.length == 0
  puts 'TLE'
else
  puts returnable_way_cost.min
end


Measured memory_bytes: 1788
fun main(args: Array<String>) {
    val o = readLine()!!
    val e = readLine()!!
    val origin = (0 until o.length + e.length).map { i ->
        val index = i shr 1
        if (i % 2 == 0) {
            o[index]
        } else {
            e[index]
        }
    }.joinToString("")
    println(origin)
}


Measured memory_bytes: 31836
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc045/tasks/abc045_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(cards):
    A, B, C = 0, 1, 2
    player = A
    winner = None

    while True:
        if len(cards[player]) == 0:
            winnder = 'ABC'[player]
            break
        played_card = cards[player][0]
        cards[player] = cards[player][1:]
        if played_card == 'a':
            player = A
        elif played_card == 'b':
            player = B
        elif played_card == 'c':
            player = C

    return winnder


def main(args):
    cards = []
    cards.append(input().strip())
    cards.append(input().strip())
    cards.append(input().strip())
    ans = solve(cards)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> s(3);
  rep(i, 3) cin >> s[i];
  rep(i, 3) cout << s[i][i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint v(n);
  REP(i,n)cin>>v[i];
  sort(ALL(v));
  cout<<v[n/2]-v[n/2-1]<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main ( void ) {
	int a , b;
	cin >> a >> b;
	if ( a >= 1 && a <= 9 && b >= 1 && b <= 9 ) 
		cout << a * b << endl;
	else 
		cout << "-1" << endl;
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> B;
    rep(i, N) {
        int A; cin >> A;

        if (i%2 == 0) {
            B.push_back(A);
        } else {
            B.insert(B.begin(), A);
        }
    }

    if (N%2 == 1) reverse(ALL(B));

    rep(i, N) {
        if (i > 0) cout << " ";
        cout << B[i];
    }
    cout << endl;
}

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

binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
for _ in range(N):
    node_input = input()
    id, left, right = map(int, node_input.split())

    binary_tree[id]["left"] = left
    binary_tree[id]["right"] = right

    degree = 0
    if left != -1:
        degree += 1
        binary_tree[left]["parent"] = id
        binary_tree[left]["sibling"] = right
    if right != -1:
        degree += 1
        binary_tree[right]["parent"] = id
        binary_tree[right]["sibling"] = left
    binary_tree[id]["degree"] = degree


def measure_depth_and_height(id, depth):
    H[id] = max(H[id], depth)

    parent_id = binary_tree[id]["parent"]
    if parent_id == -1:
        return depth

    return measure_depth_and_height(parent_id, depth+1)

D = [0 for i in range(N)]
H = [0 for i in range(N)]
for id in range(N):
    depth = measure_depth_and_height(id, 0)
    D[id] = depth


def get_type(node):
    if node["parent"] == -1:
        return "root"
    if node["degree"] == 0:
        return "leaf"
    if node["parent"] == -1:
        return "root"
    return "internal node"

for id in range(N):
    node = binary_tree[id]
    parent_id = node["parent"]
    sibling_id = node["sibling"]
    degree = node["degree"]
    node_type = get_type(node)
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(id, parent_id, sibling_id, degree, D[id], H[id], node_type))


Measured memory_bytes: 5612
input()
a = list(map(int, input().split()))

def merge_and_count(a, b):
    i, j = 0, 0
    count = 0
    m = []
    while i < len(a) and j < len(b):
        if a[i] <= b[j]:
            m.append(a[i])
            i += 1
        else:
            count += len(a)-i
            m.append(b[j])
            j += 1

    if i < len(a):
        m += a[i:]
    else:
        m += b[j:]

    return (count, m)



def sort_and_count(l):
    if len(l) == 1:
        return 0, l
    else:
        a = l[0:len(l)//2]
        b = l[len(l)//2:]
        rA, a_ = sort_and_count(a)
        rB, b_ = sort_and_count(b)
        r, l_ = merge_and_count(a_, b_)
    return (rA+rB+r, l_)

print(sort_and_count(a)[0])

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int ans[2003];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, x, y; gi(n); gi(x), gi(y);
	rep1(i, n)
		iter(j, i+1, n+1)
			ans[min(j-i, abs(j-y)+abs(i-x)+1)]++;
	rep1(i, n-1) {
		print(ans[i]), pc('\n');
	}
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main() {
    long long int n, s=0, a, min=2147483647;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a;
        if(a <= min) {
            min = a;
            s++;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

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

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD7;
        a = a * a % MOD7;
        n >>= 1;
    }
    return res;
}

int main(){
    ll s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll t;
	if(n==1) {cout<<1<<endl;return 0;}
	for(ll i=0;i<=50;i++){
		if((1ll<<i)>n) {t=i;break;} 
	}
	t--;
	ll sum=(1ll<<t)-1;
	cout<<sum+(1ll<<t)<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	string str;
	
	cin>>str;
	
	if(str == "ani") cout<<"square1001"<<endl;
	else cout<<"e869120"<<endl;
	
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	map<string, int> st;
	rep(i, n) {
		sort(all(s[i]));
		st[s[i]]++;
	}
	ll ans = 0;
	for(auto t: st) {
		ll now = t.second;
		ans += now * (now-1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18176
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    bool c = false, d = false;
    string s;
    cin >> s;
    rep(i,s.size()){
        if(c){
            if(s[i]=='F'){
                d = true;
            }
        }
        else{
            if(s[i]=='C'){
                c = true;
            }
        }
    }
    YN(d)
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
  
struct node {
  struct node *ri;
  int key;
  struct node *le;
};
typedef struct node * NodePointer;
  
NodePointer head, tail;
void init(void);
NodePointer makenode(int);
void insert(int,NodePointer);
void preorder(NodePointer);
void inorder(NodePointer);
int find(int,NodePointer);
 
void init(void){
  head=makenode(-1);
  tail=makenode(-1);
  head->ri=tail;
  head->le=tail;
}
  
NodePointer makenode(int k){
  NodePointer x;
  
  x=malloc(sizeof(struct node));
  x->key = k;
  x->le = x->ri = tail;
  
  return x;
}
  
void insert(int k, NodePointer p){
  if(k < p->key){
    if(p->le == tail){
      p->le = makenode(k);
    }else{
      insert(k , p->le);
    }
  }else{
    if(p->ri == tail){
      p->ri = makenode(k);
    }else{
      insert(k , p->ri);
    }
  }
}
  
void preorder(NodePointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->le);
    preorder(node->ri);
  }
}
  
void inorder(NodePointer node){
  if(node != tail){
    inorder(node->le);
    printf(" %d", node->key);
    inorder(node->ri);
  }
}
   
int find(int k,NodePointer node){
  if(node == tail){
    return 0;
  }
  
  if(node->key == k){
    return 1;
  }else if(node->key < k){
    return find(k , node->ri);
  }else{
    return find(k , node->le);
  }
}
int main(){
  char str[10];
  int n,k;
  
  init();
  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,str);
  
    if(str[0] == 'i'){
      scanf("%d" ,&k);
      insert(k, head);
    }else if(str[0] == 'p'){
      inorder(head->ri);
      printf("\n");
      preorder(head->ri);
      printf("\n");
    }else{
      scanf("%d" ,&k);
      if(find(k,head->ri)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
    }
  }
  
  return 0;
}

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

int main()
{
  int n;
  vector<int> v(20);

  cin >> n;

  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> v[i];
  }

  int count = 0;

  for (int i = 1; i < n - 1; i++)
  {
    if(v[i] > v[i-1] && v[i] < v[i+1])
    {
      count++;
    }
    else if (v[i] < v[i - 1] && v[i] > v[i + 1])
    {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

struct P{
	double x,y,z;
};

double dist(P a,P b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	double z = a.z - b.z;
	return x * x + y * y + z * z;
}
int main(){
	int N;
	P p[30];
	while( cin >> N && N){
		for(int i = 0 ; i < N ; i++)
			cin >> p[i].x >> p[i].y >> p[i].z;
		
		double e = 1.0;
		P pos;
		pos.x = 0;
		pos.y = 0;
		pos.z = 0;
		while( e > 1e-8 ){
			double dis = -1;
			int idx = 0;
			for(int i = 0 ; i < N ; i++){
				if( dis < dist(pos,p[i]) ){
					dis = dist(pos,p[i]);
					idx = i;
				}
			}
			double x = p[idx].x - pos.x;
			double y = p[idx].y - pos.y;
			double z = p[idx].z - pos.z;
			pos.x += x * e;
			pos.y += y * e;
			pos.z += z * e;
			e *= 0.998;
		}
		double dis = -1;
		int idx = 0;
		for(int i = 0 ; i < N ; i++){
			if( dis < dist(pos,p[i]) ){
				dis = dist(pos,p[i]);
				idx = i;
			}
		}
		printf("%.8lf\n",sqrt(dis));
	}
}

Measured memory_bytes: 1248
#include <stdio.h>
int isPrime(int n){
    if(n == 1){
        return 0;
    }
    if(n == 2){
        return 1;
    }
    if(n == 3){
        return 1;
    }
    if(n == 5){
        return 1;
    }
    if(n%2 == 0){
        return 0;
    }
    if(n%3 == 0){
        return 0;
    }
    if(n%5 == 0){
        return 0;
    }
    for(int i = 3; i*i <= n; i = i + 2){
        if(n % i == 0){
            return 0;}
    }
    return 1;
}

int main(void){
    int q;
    scanf("%d", &q);
    int l[500000], r[500000];
    int i, j;
    int cnt;
    for(i = 0; i < q; i++){
        scanf("%d%d", &l[i], &r[i]);
    }
    int cumsum[500000];
    cumsum[1] = 0;
    for(i = 3; i <= 500000; i = i + 2){
        if((isPrime(i) == 1) && (isPrime( (i + 1)/ 2) ) ){
            cumsum[i] = cumsum[i-2] + 1;
        }else
        {
            cumsum[i] = cumsum[i-2];
        }
    }
    for(i = 0; i < q; i++){
        if(l[i] == 1){
            printf("%d\n", cumsum[r[i]]);
        }else{
            printf("%d\n", cumsum[r[i]] - cumsum[l[i] - 2]);
        }
    }
    return 0;
}

Measured memory_bytes: 4416
N = int(input())
B = list(map(int, input().split()))

A = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i == N-1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1], B[i])

print(sum(A))

Measured memory_bytes: 3064
#include<iostream>
#include<stack>
#include<string>
using namespace std;

int main() {
	stack<int> sta;
	string str;

	while (cin >> str){
		if (str[0] == '+') {
			int a = sta.top(); 
			sta.pop();
			int b = sta.top();
			sta.pop();
			sta.push(a+b);
		}
		else if (str[0] == '-') {
			int a = sta.top();
			sta.pop();
			int b = sta.top();
			sta.pop();
			sta.push(b - a);
		}
		else if (str[0] == '*') {
			int a = sta.top();
			sta.pop();
			int b = sta.top();
			sta.pop();
			sta.push(a * b);
		}
		else {
			sta.push(stoi(str.c_str()));
		}
	}

	cout << sta.top() << endl;
	return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {

	string S;
	string T;
	string U;
	int A;
	int B;

	cin >> S;
	cin >> T;
	cin >> A;
	cin >> B;
	cin >> U;

	if (U == S) {
		cout << A - 1 << "\t" << B;
	}
	else {
		cout << A << "\t" << B - 1;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s;
			int count = 0;
			while((s = reader.readLine()) != null) {
				int n = Integer.parseInt(s);
				for(int i = 0;i < 10;i++) {
					for(int j = 0;j < 10;j++) {
						for(int k = 0;k < 10;k++) {
							for(int l = 0;l < 10;l++) {
								if(i + j + k + l == n)
									count++;
							}
						}
					}
				}
				System.out.println(count);
				count = 0;
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

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

//const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    fastio(); 

    // int t;
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    long long n;
    cin >> n;
    std::vector<long long> a(n);

    bool inRange = true, hasZero = false;

    for (auto &it: a)
    {
        cin >> it;
        if (it == 0) hasZero = true;
    }
    
    long long res = 1;

    if (hasZero) res = 0;
    else
    {
        for (int i = 0; i < n; ++i)
        {
            if (a[i] > 1000000000000000000LL / (long double) res)
            {
                inRange = false;
                break;
            }
            else res *= a[i];
        }
        
        res = (inRange)? res: -1;
        
    }
    
    cout << res << "\n";
}

Measured memory_bytes: 3968