akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	as := make([]int, n)
	dm := make(map[int]int)
	for i := 0; i < n; i++ {
		as[i] = nextInt()

		ps := primeFactorization(as[i])
		for p := range ps {
			dm[p]++
		}
	}

	gg := make([]int, n+1)
	for i := 0; i < n; i++ {
		gg[i+1] = gcd(gg[i], as[i])
	}

	if gg[n] != 1 {
		fmt.Println("not coprime")
		return
	}

	for k, v := range dm {
		if k == 1 {
			continue
		}
		if v > 1 {
			fmt.Println("setwise coprime")
			return
		}
	}

	fmt.Println("pairwise coprime")
}

func primeFactorization(n int) map[int]int {
	ps := make(map[int]int)
	for n%2 == 0 {
		ps[2]++
		n /= 2
	}
	for i := 3; i*i <= n; i += 2 {
		for n%i == 0 {
			ps[i]++
			n /= i
		}
	}
	if n != 1 {
		ps[n]++
	}

	return ps
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 31604
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
 
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
 
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
 
int main(void)
{
    cin.sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> As(N);
    REP(n,N) cin >> As[n];
    map<ll, set<ll>> mnts;
    ll remain = 0LL;
    REP(n,N) {
        mnts[As[n]].insert(n);
        remain += As[n];
    }

    vector<ll> keys;
    for (auto k : mnts) keys.pb(k.first);
    reverse(ALL(keys));

    ll seen = 0;
    vector<ll> ans(N);
    ll rep = 1e9;
    REP(i, SIZE(keys)) {
        auto height = keys[i];
        auto& mnt_idxes = mnts[height];
        seen += SIZE(mnt_idxes);
        if (mnt_idxes.count(0)) {
            ans[0] = remain;
            break;
        }
        auto val = (keys[i] - keys[i+1]) * seen;
        rep = min(rep, *mnt_idxes.begin());
        ans[rep] += val;
        remain -= val;
    }
    for (auto a : ans) cout << a << endl;
    
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int i;
  long long ans = 1;
  for(i = 1; i <= n; i++)
  {
    ans *= i;
    if(ans >= 1000000007)
    {
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
function main(input){
  const lines = input.split('\n');
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const K = lines[0].split(' ').map(x => parseInt(x))[1];
  const A = lines[1].split(' ').map(x => parseInt(x)).sort();

  const size_sorted_A = [];
  var count = 1;
  for(var i = 1;i<=A.length;i++){
//console.log([A[i-1],A[i]]);
    if(A[i-1]==A[i]){
      count++;
    }else{
      size_sorted_A.push(count);
      count=1;
    }
  }
//console.log('---')
//console.log(size_sorted_A)

  size_sorted_A.sort((a, b) => a - b);
//console.log(size_sorted_A)

  var result = 0;

  if(size_sorted_A.length <= K){
    console.log(result);
    return;
  }

  for(var i=0;i<size_sorted_A.length;i++){
    var size = size_sorted_A[i];
    result+=size;
    if(size_sorted_A.length-(i+1) <= K){
      console.log(result);
      return;
    }
//console.log(size_sorted_A)
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

//console.log([ 13, 3, 3, 3, 3, 1 ].sort(x => x));


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

int main() {

  int H , W ;

  while (1) {

    cin >> H >> W ;

    if (H == 0 && W == 0) break ;

    for (int i  = 0; i < H; i++) {

      for (int j = 0; j < W; j++) {

	if(i != 0 && i != H-1 && j != 0 && j != W-1) {

	  printf(".");

	} else {

	  printf("#");

	}

      }

      printf("\n");

    }

    printf("\n");

  }

  return 0;

}

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

using namespace std;

typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	int m;
	cin>>n>>x;
	int a=1100;
	int b=0;
	REP(i, n){
		cin>>m;
		a=min(a, m);
		b+=m;
	}
	cout<<n+(x-b)/a<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int A = sc.nextInt();

		int B = sc.nextInt();

		int[] P = new int[N];

		for(int i=0;i<N;i++) {

			P[i] = sc.nextInt();
		}

		Arrays.sort(P);

		int p1 = 0;//A以下

		int p2 = 0;//Aより大きくB以下

		int p3 = 0;

		int index = 0;

		while(P[index]<=A) {

			p1++;

			index++;

			if(index>=N)break;

		}


		if(index<N) {
			while(P[index]<=B) {


			p2++;

			index++;

			if(index>=N)break;
			}
		}

		p3 = N - p1 - p2;

		int ans = 0;

		ans = Math.min(p1, p2);

		ans = Math.min(ans, p3);

		System.out.println(ans);

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, X, T;
    cin >> N >> X >> T;
    cout << (N + X - 1) / X * T << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	string s;
	cin>>s;
	int n = s.length();

	int c = 1;
	for(int i = 0; i<n; i++) {
		if(c&1) {
			if(s[i] != 'R' and s[i] != 'U' and s[i] != 'D') {
				cout<<"No"<<endl;
				return;
			}
		}
		else {
			if(s[i] != 'L' and s[i] != 'U' and s[i] != 'D') {
				cout<<"No"<<endl;
				return;
			}
		}
		c++;
	}

	cout<<"Yes"<<endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int m,n,a[110],b[110];
int main(){
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	int m=n;
	for (int i=1;i<=n;i++){
		for (int j=m;j>=1;j--){
			if (a[j]==j){
				b[i]=j;
				for (int k=j+1;k<=m;k++)a[k-1]=a[k];
				m--;
				break;
			}
			if (j==1){puts("-1");return 0;}
		}
	}
	for (int i=n;i>=1;i--) cout<<b[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#define gc getchar()
#define lint long long
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
#define N 300010
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int a[N];char ss[N*12],tt[20];int ssl,ttl;
inline int show(int x)
{
	if(!x) ss[++ssl]='0';
	ttl=0;while(x) tt[++ttl]=x%10+'0',x/=10;
	while(ttl--) ss[++ssl]=tt[ttl+1];ss[++ssl]='\n';
	return 0;
}
int main()
{
//	freopen("data.in","r",stdin),freopen("std.out","w",stdout);
	int k=inn(),n=1<<k;
	for(int i=0;i<n;i++) a[i]=inn();
	for(int i=1,ans=0,mx,se;i<n;i++)
	{
		mx=a[0],se=0;
		for(int j=i;j;j=(j-1)&i)
			if(a[j]>mx) se=mx,mx=a[j];
			else se=max(se,a[j]);
		show(ans=max(ans,mx+se));
	}
	return fwrite(ss+1,sizeof(char),ssl,stdout),0;
}

Measured memory_bytes: 7552
#include<iostream>
    #include<algorithm>
    #include<string>
    #include<string.h>
    using namespace std;
    string i;
    int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>a>>b;
    if(a==1) a=14;
    if(b==1) b=14;
    if(a>b) cout <<"Alice\n";
    if(a<b) cout <<"Bob\n";
    if(a==b) cout <<"Draw\n";
    return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=11;
char s[MAXN];
int N;
int visit[MAXN];
bool check(){
    if(N==1)return true;
    memset(visit,0,sizeof(visit));
    int max_num=0;
    bool isok=true;
    for(int i=1;i<N;++i){
        if(s[i]-'a' == max_num+1)max_num++;
        else if(s[i]-'a'<max_num+1);
        else isok=false;
    }
    return isok;
}

void dfs(int h){
    if(h==N){
        s[N+1]='\0';
        if(check()){
            printf("%s\n",s);
        }
        return ;
    }
    for(int i='a';i<='a'+h;++i){
        s[h]=i;
        dfs(h+1);
    }
}

int main(){
    scanf("%d",&N);
    dfs(0);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b + c <= a)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << c - (a - b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <math.h>

using namespace std;
typedef long long LL;
const int maxn = 1500005;
const int mod = 924844033;

int ehead[maxn],ecnt;
struct edge {
	int u,v,next;
}edg[maxn];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;
}
int fac[maxn],inc[maxn];
int n,L,cnt[maxn],g[maxn],h[maxn],sz[maxn];
namespace FFT {
	int o[maxn],w[maxn],rv[maxn];
	LL fpm(LL p,LL k) {
		LL res=1ll;
		while (k) {
			if (k&1) (res*=p)%=mod;
			(p*=p)%=mod;k>>=1;
		}
		return res;
	}
	void prepare(int L) {
		o[0]=1;LL w0=fpm(5,(mod-1)/L);
		for (int i=1;i<L;i++) o[i]=o[i-1]*w0%mod;
		for (int i=1;i<L;i++) rv[i]=rv[i>>1]>>1|(i&1?L>>1:0);
	}
	int plu(int u,int v) {
		return u>=mod-v?v-mod+u:u+v;
	}
	int dec(int u,int v) {
		u-=v;return u<0?u+=mod:u;
	}
	void ntt(int *f,int idft=0)
	{
		for (int i=0;i<L;i++)
			if (i<rv[i]) swap(f[i],f[rv[i]]);
		for (int p=2;p<=L;p<<=1)
		{
			int s=L/p;w[0]=o[0];
			if (idft) for (int i=1,t=L-s;i<p>>1;i++,t-=s) w[i]=o[t];
			else for (int i=1,t=s;i<p>>1;i++,t+=s) w[i]=o[t];
			for (int i=0;i<L;i+=p) {
				int *c=w;
				for (int j=i;j<i+(p>>1);j++)
				{
					int u=f[j],v=(LL)f[j+(p>>1)]*(*c++)%mod;
					f[j]=plu(u,v);f[j+(p>>1)]=dec(u,v);
				}
			}
		}
		if (idft) {
			int inc=fpm(L,mod-2);
			for (int i=0;i<L;i++)
				f[i]=(LL)f[i]*inc%mod;
		}
	}
}
using namespace FFT;

void dfs(int u,int fa) {
	sz[u]=1;
	for (int v,j=ehead[u];j;j=edg[j].next)
	if ((v=edg[j].v)!=fa) {
		dfs(v,u);sz[u]+=sz[v];cnt[sz[v]]++;
	}
	if (sz[u]!=n) cnt[n-sz[u]]++;
}
LL comb(int n,int m) {
	return (LL)fac[n]*inc[m]%mod*(LL)inc[n-m]%mod;
}
int main()
{
	#ifdef Amberframe
		freopen("agc005f.in","r",stdin);
		freopen("agc005f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int u,v,i=1;i<n;i++)
		scanf("%d %d",&u,&v),add(u,v);
	dfs(1,0);
	
	fac[0]=inc[0]=1;
	for (int i=1;i<=n;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[n]=fpm(fac[n],mod-2);
	for (int i=n;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	
	L=1;while (L<=n<<2) L<<=1;
	for (int i=1;i<=n;i++) h[i]=(LL)cnt[i]*fac[i]%mod;
	for (int i=0;i<=n;i++) g[n-i]=inc[i];
	
	prepare(L);ntt(g);ntt(h);
	for (int i=0;i<L;i++) h[i]=(LL)h[i]*g[i]%mod;
	ntt(h,1);
	
	for (int i=1;i<=n;i++)
	{
		int ans=comb(n,i)*n%mod;
		ans-=(LL)h[i+n]*inc[i]%mod;
		printf("%d\n",ans<0?ans+mod:ans);
	}
	return 0;
}

Measured memory_bytes: 57216
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAXN = 543;

ll dist[MAXN][MAXN];
int n;

void solve() {
	cin >> n;
	ll answ = 0;

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

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < i; ++j) {
			int found = 0;

			for(int mid = 0; mid < n; ++mid) {
				if(mid == i || mid == j) {
					continue;
				}

				ll alt = dist[i][mid] + dist[mid][j];

				if(alt < dist[i][j]) {
					cout << "-1\n";
					return;
				} else if(alt == dist[i][j]) {
					found = 1;
				}
			}

			if(!found) {
				answ += dist[i][j];
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1536
/*  -*- coding: utf-8 -*-
 *
 * 2823.cc: JAG Practice Contest
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;

/* typedef */

/* global variables */

int vs[MAX_M];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n, m;
    scanf("%d%d", &n, &m);
    if (n == 0) break;

    memset(vs, 0, sizeof(vs));

    for (int i = 0; i < n; i++) {
      int di, vi;
      scanf("%d%d", &di, &vi);
      di--;
      if (vs[di] < vi) vs[di] = vi;
    }

    int sum = 0;
    for (int i = 0; i < m; i++) sum += vs[i];
    printf("%d\n", sum);
  }
  return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H + 2; i++) {
    vector<char> line(W + 2);
    for (int j = 0; j < W + 2; j++) {
      if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
        line.at(j) = '#';
      }
      else {
        cin >> line.at(j);
      }
      cout << line.at(j);
    }
  cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
int n;
scanf("%i",&n);
vector<int> a(n),dp(n,0);
for(int &i:a) scanf("%i",&i);
for(int i=1;i<n;i++) 
{
dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
if(i>1) 
dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
}
printf("%i\n",dp.back());
return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int getmax(const int arr[], const bool rev) {
    int m = 0;
    for (int i = 0; i < 201; i++) {
        if (m < arr[i] != rev) {
            m = arr[i];
        }
    }
    return m;
}

int main()
{
    int x[201];
    int y[201];
    int n;
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};

    while (cin >> n, n) {
        fill_n((int *)x, 201, 0);
        fill_n((int *)y, 201, 0);
        for (int i = 1; i < n; i++) {
            int n, d;
            cin >> n >> d;
            x[i] = x[n] + dx[d];
            y[i] = y[n] + dy[d];
        }
        cout << 1 + getmax(x, false) - getmax(x, true) << " " << 1 + getmax(y, false) - getmax(y, true) << endl;
    }
    return 0;
}

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

#define N 500000

int n;

struct Tree{
	int key;
	struct Tree *parent,*left,*right;
};
struct Tree *NILL,*root;

void find(struct Tree *root,int key){
	int flag =0;
	while(root!=NILL){
		if(root->key > key)root = root->left;
		else if(root->key == key) {
			printf("yes\n");
			flag =1;
			break;
		}
		else root = root->right;
	}
	if(!flag)printf("no\n");
}

void insert(struct Tree *z){
	struct Tree *x,*y;
	y = NILL;
	x = root;
	while(x != NILL){
		y = x;
		if(z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if(y == NILL)  {
		root = z;
	}
	else if(z->key < y->key) y->left = z;
	else y->right = z;
}

void mid(struct Tree *root){
	if(root == NILL) return;
	mid(root->left);
	printf(" %d", root->key);
	mid(root->right);
}

void inorder(struct Tree *root){
	if(root == NILL) return;
	printf(" %d",root->key);
	inorder(root->left);
	inorder(root->right);
}

void print(){
	struct Tree *r;
	r = root;
	mid(r);
	printf("\n");
	inorder(r);
	printf("\n");
}

int main(){
	struct Tree *t;
	scanf("%d",&n);
	int i;
	int key;
	char instruct[7];
	for(i=0;i<n;i++){
		scanf("%s",instruct);
		if(!strcmp(instruct,"insert")){
			scanf("%d",&key);
			t = (struct Tree *)malloc(sizeof(struct Tree));
			t->key = key;
			t->right = NILL;
			t->left = NILL;
			//T[i]->key  = key;
			insert(t);
		}
		else if(!strcmp(instruct,"find")){
			scanf("%d",&key);
			find(root,key);
		}
		else print();
	}
	return 0;
}	

Measured memory_bytes: 21456
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

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

void solve()
{
    IN(n);
    ll ans = (modpow(10, n, MOD) - modpow(9, n, MOD) * 2 + modpow(8, n, MOD)) % MOD;
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a[100];
  int n,m,sum=0;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  if(a[n-m]<float(sum)/(4*m))
    cout<<"No";
  else
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N , K;
  cin >> N >> K;
  vector<long long> H(N);
  for(long long i = 0; i < N; i++){
    cin >> H[i];
  }
  if(K > N){
    cout << 0;
  }
  if(K <= N){
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    for(long long i = 0; i < K; i ++){
      H[i] = 0;
    }
    long long sum = 0;
    for(long long i = 0; i < N; i ++){
      sum = sum + H[i];
    }
    cout << sum;
  }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    int A,B;
    int ans;
    cin >> A >> B;
    ans = max(0,A-2*B);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        int i = 0;
        int txor = 0;
        for(i = 0 ; i < n ; i++){
            arr[i] = in.nextInt();
            txor = txor ^ arr[i];
        }
        for(i = 0 ; i < n ; i++){
            System.out.println(txor ^ arr[i]);
        }

    }
}

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

using namespace std;

int n,i,j,a[100005],b[100005],c[100005];
long long s[100005];

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	for(i = 0; i < n; i++)
	scanf("%d", &b[i]);
	
	for(i = 0; i < n; i++)
	scanf("%d", &c[i]);
	
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	
	int p = 0;
	
	for(i = 0; i < n; i++){
		while(p < n && a[p] < b[i])
		p++;
		
		s[i] = p;
	}
	
	for(i = 1; i < n; i++)
	s[i] += s[i - 1];
	
	long long res = 0;
	
	p = 0;
	
	for(i = 0; i < n; i++){
		while(p < n && b[p] < c[i])
		p++;
		
		if(p - 1 >= 0)
		res += s[p - 1];
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 2176
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n;
    cin>>n;
    ll h=n/30;
    ll m=n%30;
    cout<<h<<" "<<m*2<<endl;
    
    
    return 0;
}



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

int main(void){
    int n;
    
    cin >> n;
    
    int top[n],
        bottom[n];
    
    
    int i;
    for(i = 0; i < n; i++) cin >> top[i];
    for(i = 0; i < n; i++) cin >> bottom[i];
        
    int maxNum = 0,
        currentNum;

    int j;
    for (i = 0; i < n; i++) {
        currentNum = 0;
        for(j = 0; j <= i; j++) currentNum += top[j];
        for(j = i; j < n; j++) currentNum += bottom[j];
        
        if(maxNum < currentNum) maxNum = currentNum;
    }
    
    cout << maxNum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vec;
vec calc(vec a,vec b){
  int n=a.size();
  vec res(n,0);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      res[(i+j)%n]+=a[i]*b[j];
      res[(i+j)%n]%=MOD;
    }
  }
  return res;
}
signed main(){
  int n,m,k;
  cin>>n>>m>>k;
  int p[m];
  for(int i=0;i<m;i++) cin>>p[i];
  vec t(n,0);
  t[0]=1;
  for(int i=0;i<m;i++) t[p[i]%n]++;
  vec ans=t;k--;
  while(k){
    if(k&1) ans=calc(ans,t);
    t=calc(t,t);
    k>>=1;
  }
  for(int i=0;i<n;i++) cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 3232
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >>b;
  cin >>c;
  if((b*10+c)%4==0){
	cout <<"YES" <<endl;
  }else{
	cout << "NO" <<endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();

    vl v1(26), v2(26);
    rep(i, n) {
        v1[s[i] - 'a']++;
        v2[t[i] - 'a']++;
    }
    sort(all(v1));
    sort(all(v2));

    rep(i, 26) {
        if(v1[i] != v2[i]) {
            out("No");
            re0;
        }
    }
    
    out("Yes");
    re0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a-b;
	int e=a*b;
	int f=max(c,d);
	int g=max(f,e);
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x

const int N = 3333;

int n;
vector<double> dp[2];
vector<double> ps;

int main() {
    input(n);
    dp[0] = vector<double>(N * 2, 0);
    dp[1] = vector<double>(N * 2, 0);
    ps = vector<double>(n);
    for (int i = 0; i < n; i++) {
        scanf("%lf", &ps[i]);
    }

    int p = 0;
    dp[0][N] = 1;

    for (int i = 0; i < n; i++) {
        int q = p ^ 1;
        double u = ps[i];

        fill(dp[q].begin(), dp[q].end(), 0);

        for (int j = 0; j < N * 2; j++) {
            if (dp[p][j] > 0) {
                dp[q][j - 1] += dp[p][j] * (1 - u);
                dp[q][j + 1] += dp[p][j] * u;
            }
        }

        p = q;
    }

    double tot = 0;
    for (int i = N + 1; i < N * 2; i++) {
        tot += dp[p][i];
    }

    printf("%.10lf\n", tot); 
    return 0;
}



Measured memory_bytes: 384
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;

int main(void)
{
	ifstream ifs;
	const int MOD = 1000000007;
	int n;
	long long int num = 1;
	int i = 0;
	int prev = 0;
	string s1, s2;

	/*
	ifs.open("test.txt");
	ifs >> n;
	ifs >> s1;
	ifs >> s2;
	*/

	cin >> n;
	cin >> s1;
	cin >> s2;

	//find num of domino
	while (i < n)
	{
		//cout << i << " " << num << endl;
		// "--"
		// "--" prev1
		if (s1[i] == s1[i + 1])
		{
			if (prev == 0)
			{
				num = (num * 6)%MOD;
			}
			else if (prev == 1)
			{
				num = (num * 3)%MOD;
			}
			else
			{
				num = (num * 2)%MOD;
			}
			prev = 1;
			i += 2;
		}
		// "|"
		// "|" prev2
		else
		{
			if (prev == 0)
			{
				num = (num *3)%MOD;
			}
			else if (prev == 1)
			{
				num = num%MOD;
			}
			else
			{
				num = (num*2)%MOD;
			}
			prev = 2;
			i+=1;
		}

	}

	num= num % MOD;
	cout << num << endl;

	return 0;
}

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


int main() {
	vector<pair<ll,ll>>a;
	ll n,m,ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		ll x,z;
		cin>>x>>z;
		a.push_back(make_pair(x,z));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		m-=a[i].second;
		ans+=a[i].second*a[i].first;
		if(m<=0){
			ans-=abs(m)*a[i].first;
			break;
		}
	}
	cout <<ans;
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int n,m,h;
int data[21];
bool solve(int v,int t){

	if(v==h) return true;
	if(v>h || t==n) return false;
	bool ret = solve(data[t]+v,t+1);
	if(!ret) ret = solve(v,t+1);
	return ret;
}
 
int main(){

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

	cin>>m;
	for(int i=0;i<m;i++){
		
		cin>>h;
		cout<< (solve(0,0)? "yes" : "no")<<endl;

	}

		return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  double s, w, h;
  while( scanf("%lf,%lf,%lf", &s, &w, &h) != EOF ) {
    if( w / (h*h) >= 25.0 ) {
      cout << s << endl;
    }
  }
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

struct T {
	ll v;
	T(ll v = 0) : v(v) {}
	T operator+(const T& t) { return T(max(v, t.v)); }
	friend ostream& operator<<(ostream& out, const T& t) {
		out << t.v; return out;
	}
};

struct segtree{
	int n; vector<T> seg;
	void init(int mx) {
		n = 1;
		while(n < mx) n *= 2;
		seg = vector<T>(n * 2);
	}
	segtree(int mx = 0) {
		init(mx);
	}
	void update(int i, T x) {
		i += n - 1;
		seg[i] = x;
		while(i > 0) {
			i = (i - 1) / 2;
			seg[i] = seg[i * 2 + 1] + seg[i * 2 + 2];
		}
	}
	T ga(int a, int b, int k, int l, int r) {
		if(b <= l || r <= a) return T();
		if(a <= l && r <= b) return seg[k];
		else {
			T lv = ga(a, b, k * 2 + 1, l, (l + r) / 2);
			T rv = ga(a, b, k * 2 + 2, (l + r) / 2, r);
			return lv + rv;
		}
	}
	void show() {
		vector<T> tmp;
		rep(i, 0, n) tmp.push_back(get(i, i + 1));
		debug(tmp);
	}
	//edit from here
	T get(int a, int b) { return ga(a, b, 0, 0, n); } //[a, b)
};

int N;
ll H[MAX_N], A[MAX_N];
vl vx;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> H[i];
		vx.pb(H[i]);
	}
	rep(i, 0, N) cin >> A[i];
	sort(all(vx));

	segtree seg(N);

	ll res = 0;
	rep(i, 0, N) {
		ll id = lower_bound(all(vx), H[i]) - vx.begin();
		ll v = seg.get(0, id).v + A[i];
		MAX(res, v);
		seg.update(id, T(v));
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 9712
#include<iostream>
using namespace std;
int main(){
	int n,p,pre,box[60],now;
	while(cin>>n>>p,n||p){
		for(int i=0;i<n;i++)
			box[i]=0;
		pre=p;
		now=0;
		while(1){
			if(pre>0){
				box[now]++;
				if(box[now]==p)
					break;
				pre--;
			}else	if(pre==0){
				pre=box[now];
				box[now]=0;
			}
			now++;
			now%=n;
		}
		cout<<now<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int r1 = a * b;
  int r2 = c * d;
  if (r1 > r2) {
    cout << r1 << endl;
  } else {
    cout << r2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
s = gets.chomp.split('')
ans = 0
0.upto(2 ** (s.size - 1) - 1) do |i|
  sum = s[0].dup
  1.upto(s.size - 1) do |j|
    if i[j - 1].zero?
      sum.to_s.concat(s[j])
    else
      sum.to_s.concat("+").concat(s[j])
    end
  end
  ans += eval(sum)
end
puts ans

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string A, B;
	cin >> A >> B;
	
	if(A == B) cout << "EQUAL";
	else if(A.size() > B.size()) cout << "GREATER";
	else if(A.size() < B.size()) cout << "LESS";
	else{
		REP(i,0, (int) A.size()){
			if(A[i] > B[i]){
				cout << "GREATER";
				exit(0);
			}
			else if(A[i] < B[i]){
				cout << "LESS";
				exit(0);
			}
		}
		cout << "EQAL";
	}
}


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

using namespace std;

int n,p[100000+10],ans=0;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(p[i]!=i)
        {
            continue;
        }
        int j=i;
        while(j+1<=n&&p[j+1]==j+1)
        {
            j++;
        }
        ans=ans+(j-i+2)/2;
        i=j;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{int N,X,S,min,tmp;
int m[1000];
S=0;
cin>>N>>X;
for(int i=0;i<N;i++)
    {cin>>m[i];
    X-=m[i];
    S += 1;}
for(int i=0;i<N;i++)
{
    for(int j=0;j<N-1;j++)
{
    if(m[j]>m[j+1])
    {   tmp=m[j];
        m[j]=m[j+1];
        m[j+1]=tmp;
    }
}
}
cout<<(X/m[0])+S<<endl;





    
    return 0;
} 
 

Measured memory_bytes: 256
<?php
 
fscanf(STDIN, '%d', $n);
for ($count = 0; $count < $n; $count++) {
    $a = explode(' ', rtrim(fgets(STDIN)));
    $b = 0;
    $c = 0;
    for ($i = 0; $i < 10; $i++) {
        if ($a[$i] > $b) {
            $b = $a[$i];
        } elseif ($a[$i] > $c) {
            $c = $a[$i];
            if ($c > $b) {
                $tmp = $b;
                $b = $c;
                $c = $tmp;
            }
        } else {
            break;
        }
    }
 
    echo $i === 10 ? 'YES' : 'NO';
    echo PHP_EOL;
}

Measured memory_bytes: 6588
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int mod=1e9+7;

main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(nullptr);
    int n,k;
    cin>>n>>k;
    int res=0;
    for(int i=k;i<=n+1;i++)
    {
        (res+=i*n-i*(i-1)+1)%=mod;
        //cout<<i*(i-1)/2<<' '<<i*n-i*(i-1)/2<<'\n';
    }
    cout<<res;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define re register
#define SIZE 10005
#define LL long long 
#define MOD 1000000007
using namespace std;
string k;
int d;
int maxn[SIZE],cnt;
LL dp[SIZE][105];
inline LL dfs(int pos,int sta,bool lim)
{
	if(pos>cnt)
		return sta==0?1:0;
	if(!lim && dp[pos][sta]!=-1)
		return dp[pos][sta];
	int up=lim?maxn[pos]:9;
	LL ret=0;
	for(re int i=0;i<=up;++i)
		ret=(ret+dfs(pos+1,(sta+i)%d,lim&&(i==maxn[pos])))%MOD;
	if(!lim)
		dp[pos][sta]=ret;
	return ret;
}
inline LL work()
{
	memset(dp,-1,sizeof(dp));
	cnt=k.size()-1;
	for(re int i=0;i<=cnt;++i)
		maxn[i]=k[i]-'0'; 
	return dfs(0,0,1);
}
int main()
{
	cin>>k;
	cin>>d;
	LL ans=(work()-1+MOD)%MOD;
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 12960
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int a,b;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>a>>b;
	if((a+b)%2==1)cout<<"IMPOSSIBLE\n";
	else cout<<(a+b)/2<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int n, y, x;
vector<string> table;
int calc(int sy, int sx) 
{
    int res = 0;
    int ny = y, nx = x;
    ny += sy;
    nx += sx;
    while(ny >= 0 and ny < n and nx >= 0 and nx < n)
    {
        if(table[ny][nx] == '0') break;
        res++;
        ny += sy;
        nx += sx;
    }
    return res;
}
int search()
{
    int res = 0;
    res = max(res, calc(1, 0) + calc(-1, 0));
    res = max(res, calc(0, 1) + calc(0, -1));
    res = max(res, calc(-1, 1) + calc(1, -1));
    res = max(res, calc(-1, -1) + calc(1, 1));
    return res + 1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n, n)
    {
        table.resize(n);
        for(int i = 0; i < n; i++) cin >> table[i];
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(table[i][j] == '0') continue;
                y = i, x = j;
                ans = max(ans, search());
            }
        }
        cout << ans << "\n";
    }
    return 0;
}




Measured memory_bytes: 3132
S = input()
Sfrom0 = S[::2]
Sfrom1 = S[1::2]
S0_1,S0_0,S1_1,S1_0 = Sfrom0.count('1'),Sfrom0.count('0'),Sfrom1.count('1'),Sfrom1.count('0')
move1 = S0_1 + S1_0
move2 = S0_0 + S1_1
if move1 < move2:
    print(move1)
else:print(move2)

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
using namespace std;

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

Measured memory_bytes: 3628
//file_name:ABC103_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */
int cmp1(const void *a, const void *b){ // 昇順
    // qsort
    // http://www.cc.kyoto-su.ac.jp/~yamada/ap/qsort.html

    return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b){ // 降順
    // qsort
    // http://www.cc.kyoto-su.ac.jp/~yamada/ap/qsort.html

    return *(int*)b - *(int*)a;
}

int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    ll a[m][2];
    rep(i,m){
        scanf("%lld%lld",&a[i][1],&a[i][0]);
    }
    qsort(a, m, sizeof(a[0]), cmp1); // 1列目で昇順ソート

    ll ans = 0;
    int pos = 0;
    rep(i,m){
        if(a[i][1]>=pos){
            pos = a[i][0];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3324