akhauriyash/Code-Regression huggingface dataset:
// problem: "https://atcoder.jp/contests/abc144/tasks/abc144_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll binarySearch(ll l,ll r,vector<ll>&A,vector<ll>&F,ll K)
{
    if(l > r)
        return LLONG_MAX;

    ll i,m,k;
    k = K;
    m = (l+r)/2;

    for(i=0;i!=A.size();i++)
    {
        if(A[i]*F[i] > m)
            k = k - ceil(A[i]-m*1.0/F[i]);

        if(k < 0)
            return binarySearch(m+1,r,A,F,K);
    }

    return min(m,binarySearch(l,m-1,A,F,K));
}

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

    vector<ll>A,F;
    ll i,x;

    for(i=0;i!=n;i++)
    {
        cin>>x;
        A.push_back(x);
    }

    for(i=0;i!=n;i++)
    {
        cin>>x;
        F.push_back(x);
    }

    sort(A.begin(),A.end());
    sort(F.begin(),F.end(),greater<ll>());

    cout<<binarySearch(0,(ll)(1e12),A,F,k);       // define

    return 0;
}


Measured memory_bytes: 4848
#include<stdio.h>

int main() {

	int a;
	int b;
	int c;

	int d;
	int e = 0;
	int count = 0;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b) {
		d = a;
	}
	else {
		d = b;
	}

	while (e < c) {
		e += d;
		count++;
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007


using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
lg n,m,k,ans;
int main()
{
    lg a,b;
    lg len=0;
    bool p=false;
    cin>>n;
    for(lg i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a==b)len++;
        else len=0;
        if(len==3) p=true;
    }
    if(p)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3632
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
d, t, s = M()
if d/s <= t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74504
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

VI solve() {
    int n; scanf("%d", &n);
    VPI xs(n);
    repn(i, n) { scanf("%d", &xs[i].fi); --xs[i].fi; xs[i].se=i; }
    sort(all(xs));

    VI r(n*n, -1);
    for(const auto& x: xs) {
        if(r[x.fi]>=0) return VI();
        r[x.fi]=x.se;
    }
    int i=0;
    for(const auto& x: xs) {
        int pos=x.fi, val=x.se, num=x.se;
        while(num--) {
            while(i<pos && r[i]>=0) ++i;
            if(i>=pos) return VI();
            r[i]=val;
        }
    }
    i=n*n-1;
    reverse(all(xs));
    for(const auto& x: xs) {
        int pos=x.fi, val=x.se, num=n-x.se-1;
        while(num--) {
            while(i>pos && r[i]>=0) --i;
            if(i<=pos) return VI();
            r[i]=val;
        }
    }
    return r;
}

int main() {
    VI r=solve();
    if(r.empty()) {
        printf("No\n");
    } else {
        printf("Yes\n");
        for(int x: r) printf("%d ", x+1);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

vector<int> v;

int k;

int main(void) {
    for(int i = 0;i < 5;i++) {
        int t;
        cin>>t;
        v.push_back(t);
    }

    cin>>k;

    sort(v.begin(),v.end());

    if(v[4] - v[0] > k) {
        cout<<":("<<endl;
    } else {
        cout<<"Yay!"<<endl;
    }


    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

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

int main()
{
	Point a, b, c;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &a.real(), &a.imag(), &b.real(), &b.imag(), &c.real(), &c.imag()) != EOF){
		Point d = 2.0*dot(c-a, b-a)/abs(b-a)/abs(b-a)*(b-a)-(c-a)+a;
		printf("%f %f\n", d.real(), d.imag());
	}
	return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;



int main() {
    ll N, K, Q; cin >> N >> K >> Q;
    vll Toku(N, 0);

    rep(i, Q) {
        int a; cin >> a; a--;
        Toku[a]++;
    }

    rep(i, N) {
        ll ans = K - (Q - Toku[i]);
        cout << (ans > 0 ? "Yes" : "No") << endl;
    }

}




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

int main(void){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;

    string words;
    for(int i=0;i<n;i++){
        words += s[i];
        words += t[i];
    }
    cout << words << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s[105];
	int i=0;
	long k;
	scanf("%s%ld",s,&k);

	for(i=0;i<k;i++){
		if(s[i]!='1'){
			printf("%c",s[i]);
			return 0;
		}
	}

	puts("1");
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int count = 0;
    bool flag = true;
    for (int i = 0; i < s.size(); i++) {
        if (i == 0) {
            if (s[i] != 'A') flag = false;
        }
        else if (2 <= i && i <= (s.size() - 2)) {
            if (s[i] == 'C') count++;
        }
        else if (!('a' <= s[i] && s[i] <= 'z')) flag = false;
    }
    if (count != 1) flag = false;
    if (flag) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

struct edge{
    i64 src, to, cost, t;
    edge(i64 to, i64 cost) : src(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : src(src), to(to), cost(cost) {}
    bool operator <(const edge &u){
        return this->cost < u.cost;
    };
};

using Graph = vector<vector<edge>>;
const i64 INF = numeric_limits<i64>::max();

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }
};


int main(){
    i64 h, w;
    cin >> h >> w;
    vector<vector<i64>> a(h, vector<i64>(w)), b(h, vector<i64>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];
    i64 n = 80 * 80 * 2 + 200;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(n)));
    i64 geta = 80 * 80 + 100;
    dp[0][0][geta + a[0][0] - b[0][0]] = true;
    rep(i, h){
        rep(j, w){
            if(i != h - 1){
                rep(k, n){
                    i64 d = a[i + 1][j] - b[i + 1][j];
                    if(0 <= k + d && k + d <= n) dp[i + 1][j][k + d] = dp[i + 1][j][k + d] || dp[i][j][k]; 
                    if(0 <= k - d && k - d <= n) dp[i + 1][j][k - d] = dp[i + 1][j][k - d] || dp[i][j][k]; 
                }
            }
            if(j != w - 1){
                rep(k, n + 1){
                    i64 d = a[i][j + 1] - b[i][j + 1];
                    if(0 <= k + d && k + d <= n) dp[i][j + 1][k + d] = dp[i][j + 1][k + d] || dp[i][j][k]; 
                    if(0 <= k - d && k - d <= n) dp[i][j + 1][k - d] = dp[i][j + 1][k - d] || dp[i][j][k]; 
                }
            }
        }
    }
    i64 ans = n * 10;
    rep(i, n){
        if(dp[h - 1][w - 1][i]) ans = min(ans, abs(i - geta));
    }
    cout << ans << endl;
}


Measured memory_bytes: 11008
n = int(input())
v = []
ans = 0.0
for _ in range(n):
    x,y = map(int,input().split())
    v.append([x,y])
for x1,y1 in v:
    for x2,y2 in v:
        ans += ((x1-x2)**2 + (y1-y2)**2 ) ** 0.5
print(ans/n)

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

using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  //a[0], a[1], a[2]
  vi lm(n);// lm[i]; iより左にある者たちの中でのmax lm[0]=0 としておく
  vi rm(n);// rm[i]; iより右にある者たちの中でのmax rm[n-1] = 0
  // 求める値は max(lm[i],rm[i]) (i = 0,1,2,...,n-1) の最大値

  for(int i = 1; i < n; i++) lm[i] = max(lm[i-1],a[i-1]);
  for(int i = n-2; i >= 0; i--) rm[i] = max(rm[i+1],a[i+1]);

  rep(i, n) std::cout << max(lm[i], rm[i]) << '\n';
}


Measured memory_bytes: 3968
#include<stdio.h>
int N,k=10000;
void counting(int *,int *,int);
int main(){
  int i;
  scanf("%d",&N);
  int A[N],B[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i+1]);
  }
  counting(A,B,k);
  return 0;
}

void counting(int A[],int B[],int h){
  int i,j,s;
  int C[h];
  for(i=0;i<=h;i++){
    C[i]=0;
  }
  for(j=1;j<=N;j++){
    C[A[j]]++;
  }
  for(i=1;i<=h;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=N;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  printf("%d",B[1]);
  for(s=2;s<=N;s++){
    printf(" %d",B[s]);
  }
  printf("\n");

}



Measured memory_bytes: 17432
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
    int N,D;
    cin >> N >> D;

    int can = 2*D+1;

    if(N%can != 0){
        cout << N/can + 1 << endl;
    }else{
        cout << N/can << endl;
    }

    return 0;
}


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007
#define MAXN 1000007

int n;
double dp[307][307][307];
double solve(int a, int b, int c)
{
    if(a<0 || b<0 || c<0) return 0;
    if(dp[a][b][c] != -1) return dp[a][b][c];
    double A=a, B=b, C=c;
    double currans = 0;
    currans = (A/n * solve(a-1,b,c)) + (B/n * solve(a+1,b-1,c)) + (C/n * solve(a,b+1,c-1)) + 1;
    currans *= n;
    currans /= (a+b+c);
    dp[a][b][c] = currans;
    return dp[a][b][c];
}

int main()
{
    FastIO
    rep(i,0,307)
    {
        rep(j,0,307)
        {
            rep(k,0,307)
                dp[i][j][k] = -1;
        }
    }
    dp[0][0][0] = 0;
    cin >> n;
    vector<int> cnt(4,0);
    int x;
    rep(i,0,n)
    {
        cin >> x;
        cnt[x]++;
    }
    cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]);
    return 0;
}

Measured memory_bytes: 226432
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N;
	LL a, b, sum = 0;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		LL x;
		scanf("%lld", &x);
		if (i == 1) a = x;
		else if (i == 2) b = x;
		else sum ^= x;
	}
	LL cnt = a + b - sum;
	if (cnt % 2 == 1 || ((cnt / 2) & sum) != 0 || cnt / 2 > a) printf("-1\n");
	else {
		LL a2 = cnt / 2;
		LL b2 = cnt / 2 + sum;
		for (int i = 41; i >= 0; i--) {
			cnt = (1LL << i);
			if ((sum & cnt) != 0) {
				if (a2 + cnt <= a) {
					a2 += cnt;
					b2 -= cnt;
				}
			}
		}
		if (a2 == 0) printf("-1\n");
		else printf("%lld\n", a - a2);
	}
}

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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n;
    ll d1,d2;
    bool check=false;
    ll count=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> d1 >> d2;
        if(d1==d2)
        {
            count+=1;
            if(count>=3)
            {
                check=true;
            }
        }
        else
        {
            count=0;
        }
    }
    if(check)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int n = Integer.parseInt(strArr[0]);
            int m = Integer.parseInt(strArr[1]);
            int st[][] = new int[n][2];
            for (int i = 0; i < n; i++) {
                String strArr2[] = br.readLine().split(" ");
                st[i][0] = Integer.parseInt(strArr2[0]);
                st[i][1] = Integer.parseInt(strArr2[1]);
            }
            int check[][] = new int[m][2];
            for (int i = 0; i < m; i++) {
                String strArr2[] = br.readLine().split(" ");
                check[i][0] = Integer.parseInt(strArr2[0]);
                check[i][1] = Integer.parseInt(strArr2[1]);
            }
            for (int i = 0; i < n; i++) {
                int min = -1;
                int ansTemp = 0;
                for (int j = 0; j < m; j++) {
                    int xNum = st[i][0] - check[j][0];
                    if (xNum < 0) {
                        xNum = xNum * -1;
                    }
                    int yNum = st[i][1] - check[j][1];
                    if (yNum < 0) {
                        yNum = yNum * -1;
                    }
                    int temp = xNum + yNum;
                    if (j == 0 || min > temp) {
                        min = temp;
                        ansTemp = j + 1;
                    }
                }
                System.out.println(ansTemp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
char p[4],op[3],a[3];

void dfs(int i, int sum){
  if(i==3){
    if(sum==7) REP(ii,3) a[ii]=op[ii];
    return;
  }
  op[i]='+';
  dfs(i+1,sum+(p[i+1]-'0'));
  op[i]='-';
  dfs(i+1,sum-(p[i+1]-'0'));        
}

int main(){
  REP(i,4) cin>>p[i];
  dfs(0,p[0]-'0');
  REP(i,3) cout<<p[i]<<a[i];
  cout<<p[3]<<"=7"<<endl;
}

Measured memory_bytes: 256
S = input()

a = int(S[:2])
b = int(S[2:])

if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif 0 < a <= 12:
    print("MMYY")
elif 0 < b <= 12:
    print("YYMM")
else:
    print("NA")


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

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
    {
        cout << "Yes" << endl;
    }
    else if (s[1] == s[2] && s[3] == s[0] && s[2] != s[3])
    {
        cout << "Yes" << endl;
    }
    else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

A, B, Q = map(int, input().split())
INF = 10**12
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for _ in range(Q):
    x = int(input())
    si = bisect_left(s,x)
    ti = bisect_left(t,x)
    sl = [s[si-1],s[si]]
    tl = [t[ti-1],t[ti]]
    ans = INF
    for i in range(2):
        for j in range(2):
            ans = min(ans, abs(x-sl[i])+abs(sl[i]-tl[j]), abs(x-tl[j])+abs(tl[j]-sl[i]))
    print(ans)

Measured memory_bytes: 91284
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> s;
	x = y = 0;
	for(i=0;i<s.size();i++) {
		if (s[i]=='0') x++;
		else y++;
	}
	ans = min(x , y) * 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3756
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let md = 1_000_000_007;
    let n = get!(usize);
    let m = get!();
    let mut cur = 0;
    let mut dp = vec![0; n+3];
    dp[cur] = 1;
    for _ in 0..m {
        let a = get!(usize);
        if cur == a {
            println!("0");
            return;
        }
        for i in cur..a {
            dp[i+1] = (dp[i+1] + dp[i]) % md;
            dp[i+2] = (dp[i+2] + dp[i]) % md;
        }
        cur = a + 1;
    }
    for i in cur..n {
        dp[i+1] = (dp[i+1] + dp[i]) % md;
        dp[i+2] = (dp[i+2] + dp[i]) % md;
    }
    println!("{}", dp[n]);
}

Measured memory_bytes: 4352
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf  1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
//*//signed main(){
//    int n,s;cin>>n>>s;
//    for(int i=2;i*i<=n;i++){
//        int count=0;
//        int t=n;
//        while(t){
//            count+=t%i;
//            t/=i;
//        }
//        if(count==s){
//            cout<<i<<endl;
//            return 0;
//        }
//    }
//    for(int i=1;i*i<=n;i++){
//        int h=(n-s)/i+1;
//        int count=0;
//        int t=h;
//        while(t){
//            count+=t%h;
//            t/=h;
//        }
//        if(count==s){
//            cout<<h<<endl;
//            return 0;
//        }
//    }
//    cout<<-1<<endl;
//    return 0;
//            }
//signed main(){
//    int n,d;cin>>d>>n;
//    if(n!=100)rep(i,0,d)n*=100;
//    else if(d==0)n=101;
//    else if(d==1)n=10001;
//    else n=1000000;
//    cout<<n<<endl;
//    return 0;
//}
//signed main(){
//    int n;cin>>n;
//    int ans=0;
//    rep(i,0,n){
//        int a;cin>>a;
//        while(a%2==0){
//            ans++;a/=2;
//        }
//    }
//    cout<<ans<<endl;
//    return 0;
//}
signed main(){
    int n,m;cin>>n>>m;
    int a[1005],b[1005],c[1005];
    rep(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<int>key;
    int ans=0;
    rep(i,0,2){
        rep(j,0,2){
            rep(k,0,2){
                key.clear();
                rep(l,0,n){
                    int h=(i==0?-1:1)*a[l]+(j==0?-1:1)*b[l]+(k==0?-1:1)*c[l];
                    key.push_back(h);
                }
                sort(key.begin(),key.end());
                reverse(key.begin(),key.end());
                int sum=0;
                rep(l,0,m)sum+=key[l];
                if(i==1||j==1||k==1)ans=max(ans,sum);
                else ans=sum;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
int main()
{
  std::string strA,strB,strPassWord;
  std::cin >> strA;
  std::cin >> strB;
  int index = 0;
  strPassWord.reserve(strA.size()*2);
  for(auto&& Achar : strA)
  {
    strPassWord.push_back(Achar);
    if(index < strB.size())
    {
  		strPassWord.push_back(strB[index++]);
    }
  }
  std::cout << strPassWord <<std::endl;

  return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
llong ANS = 0;
int C[10][10] = { 0 };
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int j = i % 10;
		int k = i;
		while (k >= 10) {
			k /= 10;
		}
		C[j][k]++;
	}
	for (int j = 0; j < 10; j++) {
		for (int k = 0; k <= 10; k++) {
			ANS += C[j][k] * C[k][j];
		}
	}
	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;




signed main(){
	IOS;
	ll n, m;
	cin >> n >> m;
	vi h(n + 1);
	for (int i = 1; i <= n; i++){
		cin >> h[i];
	}
	vvi vec(n + 1, vi() );
	for (int a, b , i = 1; i <= m; i++){
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	ll res = 0;
	ll ctr = 1;
	for (int i = 1; i <= n; ++i){
		ctr = 1;
		for (auto el : vec[i]){
			if (h[el] >= h[i])ctr = 0;
		}
		res += ctr;
	}
	cout << res; 
	getchar();
	getchar();

	return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		puts("Yes");
	} else {
		puts("No");
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length() / 2; ++i)
		if (s[i] != s[s.length() - 1 - i])
			++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int N = NextInt(), T = NextInt();
        Tuple<int, int>[] tp = new Tuple<int, int>[N];
        for (int i = 0; i < N; i++)
        {
            int A = NextInt(), B = NextInt();
            tp[i] = new Tuple<int, int>(A, B);
        }
        var v = tp.OrderBy(x => x.Item1);
        int[] dp = Enumerable.Repeat(-INF, 6010).ToArray();
        dp[0] = 0;
        foreach (var e in v)
        {
            //Time
            for (int x = T - 1; x >= 0; x--)
            {
                if (dp[x] != -INF)
                {
                    if (x + e.Item1 <= T) { dp[x + e.Item1] = Math.Max(dp[x + e.Item1], dp[x] + e.Item2); }
                    else { dp[T] = Math.Max(dp[T], dp[x] + e.Item2); }
                    //dp[x + e.Item1] = Math.Max(dp[x + e.Item1], dp[x] + e.Item2);
                }
            }
        }
        int ans = 0;
        for (int i = T; i >= 0; i--)
        {
            ans = Math.Max(ans, dp[i]);
            //Console.WriteLine(i + " : " + dp[i]);
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }

}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13552
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());

		if(N ==1) {
			System.out.println("Hello World");
			return;
		}

		st = new StringTokenizer(br.readLine());
		int A = parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int B = parseInt(st.nextToken());


		System.out.println(A+B);


	}




}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000



int main(){
  int n;
  while(scanf("%d", &n), n){
    vector<int> k(n);
    rep(i,n){
      scanf("%d", &k[i]);
    }
    char s[103];
    scanf("%s", s);

    int len=strlen(s);
    rep(i,len){
      if(s[i]>='a' && s[i]<='z'){
	s[i]=s[i]-k[i%n];
	if(s[i]<'a'){
	  s[i]+='Z'-'a'+1;
	  if(s[i]<'A') s[i]+='z'-'A'+1;
	}
      } else {
	s[i]=s[i]-k[i%n];
	if(s[i]<'A'){
	  s[i]+='z'-'A'+1;
	  if(s[i]<'a') s[i]+='Z'-'a'+1;
	}
      }
    }

    cout<<s<<endl;

  }
  return 0;
}

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

int main()
{
	int n, m;
    cin >> n >> m;
    vector<bool> red_ball(n, false);
    vector<long long> num_ball(n, 1);
    red_ball[0] = true;
    int x, y;
    for(int i = 0;i < m;i++){
        cin >> x >> y;
        x--;
        y--;
        num_ball[x]--;
        num_ball[y]++;
        if(red_ball[x]){
            red_ball[y] = true;
        }
        if(num_ball[x] == 0){
            red_ball[x] = false;
        }
    }

    int red_count = 0;
    for(int i = 0;i < n;i++){
        if(red_ball[i]){
            red_count++;
        }
    }

    cout << red_count << endl;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0;//, sign = 1;
        // while(check(), notDigits[(int)buf[idx]]){ idx++; }
        // if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        check(), idx++;
        return /*sign **/ ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    // for(int i = 1; i <= lim; i++){
    //     accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) >> 1]);
    // }
    for(int i = 1; i <= lim; i += 2){
        accs[i] = prime[i] && prime[(i + 1) >> 1];
    }
    for(int i = 1; i <= lim; i++){
        accs[i] += accs[i - 1];
    }
    // printd(accs[lim]);
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    ans.reserve(4 * q);
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    cout << ans;
    // write(1, ans.data(), ans.size());
}


Measured memory_bytes: 1536
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main implements Runnable {

    private static List<List<Integer>> permutations(int N) {
        List<List<Integer>> lst = new ArrayList<>();
        boolean[] used = new boolean[N];
        int[] acm = new int[N];
        for (int i = 0; i < N; i++) {
            acm[0] = i;
            used[i] = true;
            dfs(lst, N, 1, used, acm);
            used[i] = false;
        }
        return lst;
    }

    private static void dfs(List<List<Integer>> lst, int N, int idx, boolean[] used, int[] acm) {
        if (idx >= N) {
            lst.add(Arrays.stream(acm).boxed().collect(Collectors.toList()));
            return;
        }

        for (int i = 0; i < N; i++) {
            if (used[i]) continue;

            acm[idx] = i;
            used[i] = true;
            dfs(lst, N, idx+1, used, acm);
            used[i] = false;
        }
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    @Override
    public void run() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] px = new int[N];
        int[] py = new int[N];
        IntStream.range(0, N).forEach(i -> {
            px[i] = sc.nextInt();
            py[i] = sc.nextInt();
        });

        List<List<Integer>> routes = permutations(N);
        List<Double> distances = routes.stream().map(route ->
                IntStream.range(1, N).asDoubleStream().reduce(0, (r, i) -> {
                    int x1 = px[route.get((int)i)];
                    int y1 = py[route.get((int)i)];
                    int x2 = px[route.get((int)i-1)];
                    int y2 = py[route.get((int)i-1)];
                    double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
                    return r + distance;
                })
        ).collect(Collectors.toList());

        Double sum = distances.stream().reduce(0.0, Double::sum);

        System.out.println(sum / distances.size());
    }
}

Measured memory_bytes: 55976
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N, H;
  bool ans=true;
  int h=0;
  cin >> N;

  for (int i=0; i<N; i++) {
    cin >> H;
    if (H > h) {
      H--;
      h=H;
    } else if (H == h) {
      continue;
    } else {
      ans=false;
      break;
    }
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second

#define ll      long long
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
int A[10000000+200];
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        A[j]++;
    }
    

    long long s=0;
    for(int i=1;i<=n;i++)
    {
        //test2(i,A[i]);
        s+=(i*1LL*A[i]);
    }
    cout<<s;
return 0;
}

Measured memory_bytes: 42704
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
}

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

int main(){
	int n;
	double a[110];
	cin>>n;
	double sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		
	}
	for(int i=1;i<=n;i++){
		sum+=(1/a[i]);
//		cout<<a[i]<<" "<<sum<<endl;
	}
	sum=1/sum;
	printf("%.5lf\n",sum); 
	
	return 0;
} 

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

struct Node{
    int key;
    Node *left,*right,*parent;
};

Node *nill,*root;

void insertkey(int key){
    Node *x,*y,*z;
    x=(Node*)malloc(sizeof(Node));
    x->key=key;
    x->left=nill;x->right=nill;
    y=root;
    z=nill;
    while(y!=nill){
        z=y;
        if(key>y->key)y=y->right;
        else if(key<y->key)y=y->left;
    }
    x->parent=z;
    if(z==nill)root=x;
    else {
        if(key>z->key)z->right=x;
        else z->left=x;
    }
    return;
}
void inorder(Node* node){
    if(node==nill)return;
    inorder(node->left);
    printf(" %d",node->key);
    inorder(node->right);
    return;
}

void preorder(Node* node){
    if(node==nill)return;
    printf(" %d",node->key);
    preorder(node->left);
    preorder(node->right);
    return;
}

bool findkey(int key){
    Node *x=root;
    while(x!=nill){
        if(x->key==key)return true;
        else if(x->key>key)x=x->left;
        else x=x->right;
    }
    return false;
}

int main(){
    int n,key;cin>>n;
    char s[10];
    rep(i,n){
        scanf("%s",s);
        if(s[0]=='i'){
            scanf("%d",&key);
            insertkey(key);
        }
        if(s[0]=='f'){
            scanf("%d",&key);
            if(findkey(key))printf("yes\n");
            else printf("no\n");
        }
        if(s[0]=='p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 21960
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(){
    int n,m; cin >> n >> m;
    vector<P> path(m);
    REP(i,m){
        int a,b; cin >> a >> b; a--; b--;
        path[i] = make_pair(a,b);
    }
    int ans=0;
    REP(i,m){
        UnionFind UF(n);
        REP(j,m){
            if(i!=j){
                UF.unionSet(path[j].first, path[j].second);
            }
        }
        bool con = false;
        REP(j,n-1){
            if(!UF.findSet(j,j+1)){
                con = true;
                break;
            }
        }
        if(con){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
local n,m=io.read("n","n")
local s={}
for i=1,m do
    local k=io.read("n")
    s[i]={}
    for j=1,k do
        s[i][j]=io.read("n")-1
    end
end
local p={}
for i=1,m do
    p[i]=io.read("n")
end

local counter=0
for bit=0,(1<<n)-1 do
    local checker=true
    for i=1,m do
        local onoff=0
        for _,v in pairs(s[i]) do
            onoff=onoff+(bit&(1<<v)>0 and 1 or 0)
        end
        if onoff%2~=p[i] then
            checker=false
        end
    end
    counter=counter+(checker and 1 or 0)
end
print(counter)

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		boolean match = false;

		String[] goodCondition = { "keyence", "k.+eyence", "ke.+yence", "key.*ence", "keye.+nce", "keyen.+ce",
				"keyenc.+e" };

		for (String cond : goodCondition) {
			if (str.matches(cond)) {
				match = true;
			}
		}

		if (match) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll s;
  cin >> s;
  ll a, b;
  if(s==1000000000000000000){
    cout << "0 0 1000000000 0 0 1000000000 ";
    return 0;
  }
  a = (ll)s / 1000000000 + 1;
  b = 1000000000 - s % 1000000000;
  cout << "0 0 1000000000 1 " << b << " " << a << "\n";
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
   input!{
       a:i32, b:i32, c:i32,
   }
   let Min = min(a, min(b, c));
   let Max = max(a, max(b, c));
   println!("{} {}", Min, Max);

}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 9068