akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 998244353;

void main() {
    long n, a, b, k;
    scan(n, a, b, k);

    auto fact = new long[](n + 1);
    fact[0] = 1;
    foreach (i ; 1 .. n + 1) {
        fact[i] = (fact[i-1] * i) % mod;
    }
    auto rfact = new long[](n + 1);
    rfact[n] = powmod(fact[n], mod - 2, mod);
    foreach_reverse (i ; 0 .. n) {
        rfact[i] = (rfact[i+1] * (i + 1)) % mod;
    }

    long comb(long n, long k) {
        return fact[n] * rfact[k] % mod * rfact[n-k] % mod;
    }

    long ans;

    foreach (i ; 0 .. n + 1) {
        if ((k - i*a) % b != 0) continue;
        long j = (k - i*a) / b;
        if (j < 0 || j > n) continue;
        ans += comb(n, i) * comb(n, j) % mod;
        ans %= mod;
    }

    writeln(ans);
}


long powmod(long x, long y, long m) {
    return y > 0 ? powmod(x, y>>1, m)^^2 % m * x^^(y&1) % m : 1;
}





































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 7164
N, M, K = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
ans = 0
j = M
a, b = [0], [0]

for i in range(N):
  a.append(a[i] + As[i])
for i in range(M):
  b.append(b[i] + Bs[i])    

for i in range(N + 1):
  if (a[i] > K):
    break
  k_ = K - a[i]
  while (b[j] > k_):
    j -= 1
  ans = max(ans, i + j)  
print(ans)

Measured memory_bytes: 127048
#include<iostream>
using namespace std;
static const int INF=(1<<21);
static const int WHI=0;
static const int BLA=2;
static const int GR=1;

int n,M[100][100];

void dijkstra(){
  int minv;
  int a[100],color[100];
  for (int i=0;i<n;i++){
    a[i]=INF;
    color[i]=WHI;
  }

  
  color[0]=GR;
  a[0]=0;
  while(1){
    minv=INF;
    int e =-1;
    for (int i=0;i<n;i++){
      if(minv>a[i]&&color[i]!=BLA){
	minv=a[i];
	e=i;
      }
    }
    
    if(e==-1)break;
    color[e]=BLA;
    for(int v=0;v<n;v++){
      if(color[v]!=BLA && M[e][v]!=INF){
	if(a[v]>a[e]+M[e][v]){
	  a[v]=a[e]+M[e][v];
	  color[v]=GR;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(a[i]==INF ? -1 : a[i]) << endl;
  }
}

int main(){
  int k,m,e,v;
  
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INF;
    }
  }
  for(int i=0;i<n;i++){
    cin>>e>>k;
    for(int j=0;j<k;j++){
      cin>>v>>m;
      M[e][v]=m;
      
    }
  }
  dijkstra();
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
     
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
const ll MOD2 = 1e9 + 7;
const int MOD = 1e9 + 7;
 
const ull infull = numeric_limits<unsigned long long>::max();
 
void fix(int &x, ll MOD) {
    x = (x % MOD);
    if(x < 0) x += MOD;
    return;
}
 
ll lgput(ll a, ll b, ll MOD) {
    ll ret = 1;
    a %= MOD;
    while(b) {
        if(b&1) ret = ret*a % MOD;
        a = a*a % MOD;
        b >>= 1;
    }
 
    return ret;
}
 
ll inv(ll a, ll MOD) {
    return lgput(a, MOD-2, MOD);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;
 
int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));
    
    int k;
    cin >> k;

    ll ans = 0;
    for(int i = 1; i <= k; ++i) {
        for(int j = 1; j <= k; ++j) {
            for(int l = 1; l <= k; ++l) {
                ans += __gcd(__gcd(i, j), l);
            }
        }
    }

    cout << ans << '\n';
    return 0; 
}


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

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    YN(n / 100 == 7 || ((n / 10) % 10 == 7) || n % 10 == 7);
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int central = k / 2;

    long ans = 0;
    rep(i, n) {
        if(x[i] <= central) {
            ans += 2 * x[i];
        } else {
            ans += 2 * (k - x[i]);
        }
    }
    cout << ans << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    vector<string> S(H);

    REP(i, H){
        cin >> S[i];
    }

    vector<vector<ll>> A(H, vector<ll>(W, 0));
    vector<vector<ll>> B(H, vector<ll>(W, 0));

    REP(i, H){
        ll count = 0;
        ll start = 0;
        ll end = 0;
        REP(j, W){
            if(S[i][j] == '#'){
                for(ll k=start; k<end; k++){
                    A[i][k] = end-start;
                }
                start = j+1;
                end = j+1;
            }
            else{
                end++;
            }
        }
        if(start < W){
            for(ll k=start; k<end; k++){
                A[i][k] = end-start;
            }
        }
    }

    REP(i, W){
        ll count = 0;
        ll start = 0;
        ll end = 0;
        REP(j, H){
            if(S[j][i] == '#'){
                for(ll k=start; k<end; k++){
                    B[k][i] = end-start;
                }
                start = j+1;
                end = j+1;
            }
            else{
                end++;
            }
        }
        if(start < W){
            for(ll k=start; k<end; k++){
                B[k][i] = end-start;
            }
        }
    }

    ll ans = 0;
    REP(i, H){
        REP(j, W){
            ans = max(ans, A[i][j] + B[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67072
from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


n = int(input())
x = int(input(), 2)

# 事前計算
cnt = popcnt(x)
init_big = x % (cnt + 1)
if cnt == 1:
    init_small = 0
else:
    init_small = x % (cnt - 1)

# 差分計算
result = []
for i in range(n):
    if not (x >> i) & 1:
        result.append((init_big + pow(2, i, cnt + 1)) % (cnt + 1))
    elif x == 1 << i or cnt - 1 == 0:
        result.append("x")
    else:
        result.append((init_small - pow(2, i, cnt - 1)) % (cnt - 1))

ans = []
for x in result[::-1]:
    if x == "x":
        ans.append(0)
    else:
        ans.append(rec(x) + 1)

print(*ans, sep="\n")

Measured memory_bytes: 23012
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	string A, B;
	cin >> A>> B;
	sort(A.begin(), A.end());
	sort(B.begin(), B.end(),greater<char>());
	if (A < B) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';

constexpr int MOD = 1e9+7;

///////////////////////////////////////////////////

int main()
{
    int S;
    io >> S;

    if (S < 3)
    {
        io << 0 << BR;
        return 0;
    }

    vector<int> dp(S+1, 1);
    for (int i = 3; i < S; i++)
    {
        for (int j = i + 3; j <= S; j++)
        {
            dp[j] = (dp[j] + dp[i]) % MOD;
        }
    }

    io << dp[S] << BR;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  mod 1e18
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;
int a[200005],b[200005];
int32_t main()
{
	fast
	int n,m,k,i,j;
	cin>>n>>m>>k;
	
	for(i=1;i<=n;i++)
	{	cin>>a[i];
		a[i]+=a[i-1];
		
	}
	for(j=1;j<=m;j++)
	{	cin>>b[j];
		b[j]+=b[j-1];
		//cout<<b[j]<< " ";
	}
	int ans=0;
	for(i=0;i<=n;i++)
	{

		if(a[i]>k)
			break;
		int rem=k-a[i];
		//cout<<"rem is "<<rem<<" ";

		auto ind=upper_bound(b,b+m+1,rem)-b;
		//cout<<"ind is "<<ind<<endl;
		ans=max(ans,i+ind-1);
	}
	cout<<endl;
	cout<<ans<<endl;

}


Measured memory_bytes: 6692
from collections import defaultdict
def solve():
  d = defaultdict(lambda: 0)
  N = int(input())
  A = list(map(int, input().split()))
  mod = 10**9+7
  d[0] = 3
  ans = 1
  for i in range(N):
    if d[A[i]]==0:
      return 0
    ans *= d[A[i]]
    ans %= mod
    d[A[i]] -= 1
    d[A[i]+1] += 1
  return ans
print(solve())

Measured memory_bytes: 99260
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
using namespace std;

int main() {
	int k, x;
	cin >> k >> x;
	int cnt = 0;
	for (int i = -1000000; i <= 1000000; i++) {
		if (x - k < i&&i < x + k) {
			cnt++;
			if (cnt != 1) {
				cout << " ";
			}
			cout << i;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap; // 優先度付きキュー
use std::collections::HashMap; // 連想配列
use std::collections::HashSet; // 連想配列 キーのみ
use std::collections::VecDeque; // キュー or スタック
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($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() {
    input! {
        n: u64,
        k: u64
    }

    for i in 1..k + 1 {
        // redに対する仕切り
        let red_comb = combination_mod(n - k + 1, i, LARGE_PRIME);

        // redを仕切る青の組み合わせの数
        let blue_comb = combination_mod(k - 1, i - 1, LARGE_PRIME);

        println!("{}", red_comb * blue_comb % LARGE_PRIME);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
fn power_mod(base: u64, exp: u64, modulo: u64) -> u64 {
    if exp == 0 {
        return 1;
    } else if exp & 1 == 0 {
        return (power_mod(base, exp / 2, modulo) % modulo).pow(2) % modulo;
    } else {
        return power_mod(base, exp - 1, modulo) % modulo * base % modulo;
    }
}

fn inverse_mod(element: u64, modulo: u64) -> u64 {
    // フェルマーの小定理からpが素数なら a^(p-1) = 1
    // よってa*a^(p-2) = 1 より a^(p-2)がaの逆元
    power_mod(element, modulo - 2, modulo) % modulo
}

fn combination_mod(m: u64, n: u64, modulo: u64) -> u64 {
    // m C n = m! / ( n! * (m - n)! )
    //       = m*(m-1)*(m-2)*...*(m-n+1)/n!
    //       = m*(m-1)*(m-2)*...*(m-n+1) * (n!)^-1
    let mut numerator = 1;
    for i in 0..n {
        numerator *= m - i;
        numerator %= modulo;
    }

    // n!
    let mut element = 1;
    for j in 1..(n + 1) {
        element *= j;
        element %= modulo;
    }
    numerator * inverse_mod(element, modulo) % modulo
}


Measured memory_bytes: 8572
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n,m; cin>>n>>m;
	vector<int> a(n);
	int all = 0;
	REP(i,n){
		cin>>a[i];
		all+=a[i];
	}
	int cnt = 0;
	REP(i,n){
		if(a[i]*4*m>=all) cnt++;
	}
	if(cnt>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c, k;
    int n = 0;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    
    for(;;){
        if(a >= b){
            b *= 2;
            n++;
        }else{
            break;
        }
    }
    for(;;){
        if(b >= c){
            c *= 2;
            n++;
        }else{
            break;
        }
    }
    
    if(n <= k){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
//#define F first
//#define S second

struct info{
	int n;
	vector<string> tree;

	info(string s) {
		n = s.size();
		tree = vector<string>(4*n);
		string dummy = init(1,0,n-1,s);
	}

	string init(int node, int l, int r, string& s) {
		if(l == r) {
			return tree[node] = s[l];
		}
		int m = (l+r)/2;
		string t = init(node*2, l, m, s) + init(node*2+1, m+1, r, s);
		return tree[node] = mycal(t);
	}

	string query(int node, int s, int e, int l, int r) {
		if(r < s || e < l) 
			return "";
		if(l <= s && e <= r) 
			return tree[node];
		int m = (s+e)/2;
		string t = query(node*2, s, m, l, r) + query(node*2+1, m+1, e, l, r);
		return mycal(t);
	}

	string query(int l, int r) {
		return query(1, 0, n-1, l, r);
	}

	string mycal(string t) {
		int n = sz(t);
		
		if(n <= 1) return t;
		
		if(n == 2) {
			if(t[0] != t[1]) return "";
			if(t[0] == t[1]) {
				return (t[0] == 'A' ? "B" : "A");
			}
		}

		rep(i,0,n-1) {
			if(t[i] != t[i+1]) {
				string ret = "";
				if(i>0) 
					ret += t.substr(0,i);
				if(i+2<n) 
					ret += t.substr(i+2);
				return ret;
			}
		}

		rep(i,0,n-2) {
			if(t[i] == t[i+1] && t[i+1] == t[i+2]) {
				string ret = "";
				if(i > 0) 
					ret += t.substr(0,i);
				if(i+3 < n) 
					ret += t.substr(i+3);
				return ret;
			}
	}

	return t;
	}
};

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	string S, T;

	cin >> S;
	cin >> T;

	int n = sz(S);
	int m = sz(T);

	info myS(S);
	info myT(T);
	int q;
	cin >> q;
	rep(i,0,q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		string ss = myS.query(a,b);
		string tt = myT.query(c,d);
		if(ss == tt) {
			cout << "YES" << '\n';
		} else {
			cout << "NO" << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 23760
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(true){

        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static final int DAY = 5;
    public static final int TIME = 2;
    public static final int PART_OF_TIMES = DAY * TIME + 1;//[0, 10]で11個

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[][][] f = new int[N][TIME][DAY];
        int[][] p = new int[N][PART_OF_TIMES];
        for (int i = 0; i < f.length; i++) {
            f[i] = new int[TIME][DAY];
            for (int j = 0; j < f[i].length; j++) {
                f[i][j] = new int[DAY];
                for (int k = 0; k < f[i][j].length; k++) {
                    f[i][j][k] = in.nextInt();
                }
            }
        }
        for (int i = 0; i < p.length; i++) {
            p[i] = new int[PART_OF_TIMES];
            for (int j = 0; j < p[i].length; j++) {
                p[i][j] = in.nextInt();
            }
        }
        int ans = solve(N, f, p);
        System.out.println(ans);
        in.close();
    }

    //営業予定openに対しお店sが共通して開店している時間帯の数を返す
    static int getC(int[][] open, int[][] s) {
        int ret = 0;
        for (int i = 0; i < open.length; i++) {
            for (int j = 0; j < open[i].length; j++) {
                if (open[i][j] * s[i][j] == 1) {
                    ret++;
                }
            }
        }
        return ret;
    }

    static int getTotalOpen(int[][] open) {
        int ret = 0;
        for (int i = 0; i < open.length; i++) {
            for (int j = 0; j < open[i].length; j++) {
                ret += open[i][j];
            }
        }
        return ret;
    }

    static int getProfit(int[][] open, final int N, final int[][][] f, final int[][] p) {
        int ret = 0;
        for (int i = 0; i < N; i++) {
            int c = getC(open, f[i]);//お店iとの重なりを調べる
            ret += p[i][c];
        }
        return ret;
    }

    static int[][] copy2Darray(int[][] from) {
        int[][] to = new int[from.length][];
        for (int i = 0; i < from.length; i++) {
            to[i] = Arrays.copyOf(from[i], from[i].length);
        }
        return to;
    }

    static int getMaxProfit(int[][] open, int t,
                            final int N, final int[][][] f, final int[][] p) {
        if (t == 10) {
            return getTotalOpen(open) > 0 ? getProfit(open, N, f, p) : Integer.MIN_VALUE;
        }
        int ret = Integer.MIN_VALUE;
        int ni = t / DAY, nj = t % DAY;
        if (ni < open.length && nj < open[ni].length) {
            int[][] nextOpen = copy2Darray(open);
            int[][] nextClose = copy2Darray(open);
            nextOpen[ni][nj] = 1;
            ret = Math.max(
                    getMaxProfit(nextOpen, t + 1, N, f, p),
                    getMaxProfit(nextClose, t + 1, N, f, p));
        }
        return ret;
    }

    static int solve(final int N, final int[][][] f, final int[][] p) {
        int[][] open = {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0}
        };
        int ans = getMaxProfit(open, 0, N, f, p);
        return ans;
    }

}


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


int main() {
	
	int N;
	cin >> N;
	vector<vector<int>> a(2, vector<int>(N));
	for(auto &i : a){
		for(auto &j : i) cin >> j;
	}
	int summax = 0;
	for(int i=0; i<N; i++){
		int sum = 0;
		for(int j=0; j<N; j++){
			if(j<=i) sum += a.at(0).at(j);
			if(j>=i) sum += a.at(1).at(j);
		}
		summax = max(sum, summax);
	}
	cout << summax << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

int b[100000];

int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int a;
	cin>>a;
	f(i,a){
		cin>>b[i];
	}
	sort(b,b+a);
	int ans=0,ansans=0;
	int y;
	y=b[(a-1)/2];
	f(i,a-1){
		if(i%2==0){
			ans+=abs(y-b[a-1-i/2]);
			y=b[a-1-i/2];
		}
		else{
			ans+=abs(y-b[i/2]);
			y=b[i/2];
		}
	}
	ansans=ans;
	ans=0;
	y=b[a/2];
	f(i,a-1){
		if(i%2==1){
			ans+=abs(y-b[a-1-i/2]);
			y=b[a-1-i/2];
		}
		else{
			ans+=abs(y-b[i/2]);
			y=b[i/2];
		}
	}
	ansans=max(ansans,ans);
	cout<<ansans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%1000000007
#define mod 1000000007
#define N 1000000000
#define ll long long
//#define file
using namespace std;

struct type{int x,tp;} a[200001];
struct Type{int x,y;} b[200001];
int tr[7000001][2],X[200001],Y[200001],tot,n,m,i,j,k,l,len;
ll Tr[7000001],ans,s;

bool cmp(type a,type b) {return a.x<b.x;}
bool Cmp(Type a,Type b) {return a.x<b.x || a.x==b.x && a.y>b.y;}

void New(int t,int x) {if (!tr[t][x]) tr[t][x]=++len;}
void change(int t,int l,int r,int x,ll s)
{
	int mid=(l+r)/2;
	add(Tr[t],s);
	if (l==r) return;
	
	if (x<=mid) New(t,0),change(tr[t][0],l,mid,x,s);
	else New(t,1),change(tr[t][1],mid+1,r,x,s);
}
ll find(int t,int l,int r,int x,int y)
{
	int mid=(l+r)/2;
	ll ans=0;
	if (x<=l && r<=y) return Tr[t];
	
	if (x<=mid && tr[t][0]) add(ans,find(tr[t][0],l,mid,x,y));
	if (mid<y && tr[t][1]) add(ans,find(tr[t][1],mid+1,r,x,y));
	return ans;
}

int main()
{
	#ifdef file
	freopen("arc101f.in","r",stdin);
	#endif
	
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%d",&j),a[++tot]={j,0};
	fo(i,1,m) scanf("%d",&j),a[++tot]={j,1};
	
	sort(a+1,a+tot+1,cmp);
	l=0;
	fo(i,1,tot)
	if (a[i].tp)
	l=a[i].x; else X[i]=l?(a[i].x-l):0;
	l=0;
	fd(i,tot,1)
	if (a[i].tp)
	l=a[i].x; else Y[i]=l?(l-a[i].x):0;
	
	l=0;
	fo(i,1,tot) if (X[i] && Y[i]) b[++l]={X[i],Y[i]};
	tot=l;
	sort(b+1,b+tot+1,Cmp);
	l=0;
	fo(i,1,tot) if (b[i].x!=b[i-1].x || b[i].y!=b[i-1].y) b[++l]=b[i];
	tot=l;
	
	len=1;
	change(1,1,N,N,1);
	fd(i,tot,1)
	{
		s=find(1,1,N,b[i].y,N);
		if (b[i].y==1) add(ans,s);
		else change(1,1,N,b[i].y-1,s);
	}
	add(ans,Tr[1]);
	printf("%lld\n",ans);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 25392
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

void q17() {
	vector<string> hints;
	hints.push_back("the");
	hints.push_back("this");
	hints.push_back("that");

	vector< vector<string> > shiftHints;
	for (int i = 0; i < 26; i++) {
		vector<string> iShiftHints;
		for (int j = 0; j < hints.size(); j++) {
			string tmp = "";
			for (int k = 0; k < hints[j].length(); k++) {
				tmp += ((hints[j][k] - 'a' + i) % 26) + 'a';
			}
			iShiftHints.push_back(tmp);
		}
		shiftHints.push_back(iShiftHints);
	}

	string str;
	for (; getline(cin, str);) {
		int s;
		bool flag = false;
		for (s = 0; s < 26; s++) {
			for (int i = 0; i < hints.size(); i++) {
				if (str.find(shiftHints[s][i]) != -1) {
					flag = true;
				}
			}
			if (flag) break;
		}

		string ans = "";
		for (int i = 0; i < str.length(); i++) {
			ans += isalpha(str[i]) ? (str[i] - 'a' - s + 26) % 26 + 'a' : str[i];
		}
		cout << ans << endl;
	}
}

int main() {
	q17();
	return 0;
}

Measured memory_bytes: 3200
N=int(input())
A=list(map(int,input().split()))

A.sort()

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

r=max(B)
if r in A:
    print(m,r)
else:
    print(m,m-r)

Measured memory_bytes: 63340
#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                   :output t :error t :input t))))

(defun solve (n h)
  (declare (optimize speed))
  (let ((memo (make-array n :initial-element -1)))
    (labels ((dp (x h)
               (let (cost)
                 (cond
                   ((= x 0) 0)
                   ((< x 0) (expt 10 5))
                   ((= x 1) (abs (- (aref h 1) (aref h 0))))
                   ((/= (aref memo x) -1) (aref memo x))
                   (t   (setq cost (min (+ (dp (- x 1) h) (abs (- (aref h x)
                                                                  (aref h (- x 1)))))
                                        (+ (dp (- x 2) h) (abs (- (aref h x)
                                                                  (aref h (- x 2)))))))
                        (setf (aref memo x) cost)
                        cost)))))
      (dp (1- n) h))))

(defun main ()
  (let* ((n (read))
         (h (make-array n :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")")))))
    (princ (solve n h))
    (fresh-line)))

(main)


Measured memory_bytes: 41664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100000000
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n,x,y,z;
	string s,t;
	cin>>n;
	x=n*n;y=x*n;
	cout<<n+x+y;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = a * b;

		if (c%2 == 0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}

	}
}

Measured memory_bytes: 23636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 10;
char h[N][N];

int main(){
    fastIO;
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    for(int i = 1 ; i <= n; i ++ ){
        for(int j = 1 ; j <= m ; j ++ ){
            cin >> h[i][j];
            cnt += (h[i][j]=='#');
        }
    }
    int ci=1,cj=1;
    int dir = 0;
    int vis = 1;
    while(ci!=n || cj!=m){
        dir = 0;
        dir += (h[ci+1][cj] == '#');
        dir += (h[ci][cj+1] == '#');
        vis ++ ;
        if(dir!=1){
            cout << "Impossible\n";
            return 0;
        }
        if(h[ci+1][cj] == '#')
            ci++;
        else if(h[ci][cj+1] == '#')
            cj++;
    }
    if(ci==n && cj == m && cnt == vis)
        cout << "Possible\n";
    else
        cout << "Impossible\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void solve()
{
	int n, k;
	while (cin >> n >> k, n || k)
	{
		vector<int> card(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> card[i];
		}
		int Ck = 0;
		int a = 1;
		for (int i = 0; i < k; ++i)
		{
			a *= card[i];
		}
		Ck = max(Ck, a);
		for (int i = k; i < n; ++i)
		{
			a /= card[i - k];
			a *= card[i];
			Ck = max(Ck, a);
		}
		int maxCk = 0;
		for (int i = 0; i < n - 1; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				if (card[i] == card[j])
				{
					continue;
				}
				int temp = card[i];
				card[i] = card[j];
				card[j] = temp;
				int CkNow = 0;
				int b = 1;
				for (int l = 0; l < k; ++l)
				{
					b *= card[l];
				}
				maxCk = max(maxCk, b);
				for (int l = k; l < n; ++l)
				{
					b /= card[l - k];
					b *= card[l];
					maxCk = max(maxCk, b);
				}
				card[j] = card[i];
				card[i] = temp;
			}
		}
		if (maxCk < Ck)
		{
			cout << "NO GAME" << endl;
		}
		else
		{
			cout << maxCk - Ck << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2005;
string s[N];
int cells[N][N], hor[N][N], ver[N][N];

int get_sum(int xl, int yl, int xr, int yr, int a[N][N]) {
    return a[xr][yr] - a[xr][yl - 1] - a[xl - 1][yr] + a[xl - 1][yl - 1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

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

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (s[i][j] == '1' && s[i][j - 1] == '1')
                hor[i + 1][j + 1]++;
        }
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '1' && s[i - 1][j] == '1') {
                ver[i + 1][j + 1]++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '1') {
                cells[i + 1][j + 1]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cells[i][j] += cells[i - 1][j] + cells[i][j - 1] - cells[i - 1][j - 1];
            ver[i][j] += ver[i - 1][j] + ver[i][j - 1] - ver[i - 1][j - 1];
            hor[i][j] += hor[i - 1][j] + hor[i][j - 1] - hor[i - 1][j - 1];
        }
    }

    for (int i = 0; i < q; i++) {
        int xl, yl, xr, yr;
        cin >> xl >> yl >> xr >> yr;

        cout << get_sum(xl, yl, xr, yr, cells) 
            - get_sum(xl, yl + 1, xr, yr, hor)
            - get_sum(xl + 1, yl, xr, yr, ver) << "\n";
    }

    return 0;
}

Measured memory_bytes: 53120
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll N,a[100000];

int main()
{
	cin>>N;
	rep(i,N) cin>>a[i];
	ll ans=1;
	ll b=-1;
	rep(now,N-1){
		if(b==-1){
			if(a[now]<a[now+1]){
				b=1;
			}
			else if(a[now]>a[now+1]){
				b=0;	
			}
		}
		else if(b==1){
			if(a[now]>a[now+1]){
				ans++;
				b=-1;
			}
		}
		else{
			if(a[now]<a[now+1]){
				ans++;
				b=-1;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
R,G,B,N=map(int,input().split())

ans=[]

count=0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        
        if (N-r*R-g*G)%B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, b * d), max(b * c, a * d)) << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%lld",&n);
	printf("%lld", n * 800 - (n / 15) * 200);
}

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

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


Measured memory_bytes: 256
function main(input) {
  const inputs = input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const Ai = inputs[1].split(' ').map(Number)
  
  let en = Array.from(new Array(N)).map(e => 0)
  for(let i = 0; i < N - 1; i ++) {
    const id = Ai[i] - 1
    if (!en[id]) {
      en[id] = 0
    }
    en[id] += 1
  }
  console.log(en.join('\n'))
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int main(){
  string s,t; cin >>s >>t;
  int ans = t.size();
  for(int pos = 0; pos<=s.size()-t.size(); pos++){
    int diff = 0;
    rep(i,t.size()){
      if(t[i]!=s[pos+i]) diff++;
    }
    ans = min(ans, diff);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
// Binary Search Tree I
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, nil;

//  二分探索木へkを挿入 //
void insert(int k){
  Node y = nil; // x の親
  Node x = root; // T の根
  Node z;
  
  //z->parent = y;
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = nil;
  z->right = nil;

  while(x != nil){
    y = x;   // 親を設定
    if(z->key < x->key)x = x->left; // 左の子へ移動
    else x = x->right;            // 右の子へ移動
  }
  z->parent = y;

  if(y == nil)root = z; // T が空の場合
  else if(z->key < y->key)y->left = z; // z を y の左の子にする
  else y->right = z; // z を y の右の子にする
}

// 再帰を使って中間順巡回(Inorder)で表示
void printInorder(Node u){
  if(u == nil)return;
  printInorder(u->left);
  printf(" %d", u->key);
  printInorder(u->right);
}

// 再帰を使って先行順巡回(Preorder)で表示
void printPreorder(Node u){
  if(u == nil)return;
  printf(" %d", u->key);
  printPreorder(u->left);
  printPreorder(u->right);
}

int main(){
  int n, i, x;
  char com[10];
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){ // 挿入の時
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){ // 出力の時
      printInorder(root); // 先行順巡回で表示
      printf("\n");
      printPreorder(root); // 中間順巡回で表示
      printf("\n");
    }
  }
  return 0;
}


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

using namespace std;
int dp[100001];
vector<int> l[100001];
int ans(int i)
{
    if(dp[i]!=-1) return dp[i];
    else
    {
        if(l[i].empty()) return 0;
        else
        {
            for(auto it=l[i].begin();it!=l[i].end();it++)
            {
                dp[i]=max(dp[i],1+ans(*it));
            }
            return dp[i];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,i,j,x,y,ma=-1;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        l[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        ma=max(ma,ans(i));
    }
    cout<<ma;
    return 0;
}


Measured memory_bytes: 7552
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)
long long binpow(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
long long mod(long long x){
return ((x%M+M)%M);
}

long long add(long long a, long long b){
return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b){
return mod(mod(a)*mod(b));
}

int main()
{
  ll n;
  cin>>n;
  ll arr[n];
  ll sum=0;
   inc(i,0,n)
  {
     cin>>arr[i];
     sum=sum+arr[i];
  }
  ll ans=0;
  inc(i,0,n)
  {
     sum=sum-arr[i];
     ans=add(ans,mul(arr[i],sum));
  }
  cout<<ans<<endl;
  
  
   return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll n;
    cin >> n;
    // output
    if (n < 9) {
        cout << n << endl;
    } else if (n < 100) {
        cout << 9 << endl;
    } else if (n < 1000) {
        cout << 9 + n - 99 << endl;
    } else if (n < 10000) {
        cout << 909 << endl;
    } else if (n < 100000) {
        cout << 909 + n - 9999 << endl;
    } else {
        cout << 90909 << endl;
    }
    return 0;
}

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

char s[100];

int check()
{
    int n=strlen(s);
    if(n>9) return 0;
    int pre=0,now=0;
    char prec='0';
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A') now++;
        else if(s[i]=='K')
        {
            if(now-pre>1||prec!='0') return 0;
            pre=now;
            prec=s[i];
        }
        else if(s[i]=='I')
        {
            if(now-pre>0||prec!='K') return 0;
            pre=now;
            prec=s[i];
        }
        else if(s[i]=='H')
        {
            if(now-pre>0||prec!='I') return 0;
            pre=now;
            prec=s[i];
        }
        else if(s[i]=='B')
        {
            if(now-pre>1||prec!='H') return 0;
            pre=now;
            prec=s[i];
        }
        else if(s[i]=='R')
        {
            if(now-pre>1||prec!='B') return 0;
            pre=now;
            prec=s[i];
        }
        else return 0;
    }

    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            if(n-i>2) return 0;
            else break;
        }
        if(i==0) return 0;
    }

    return 1;
}

int main()
{
    scanf("%s",s);
    if(check()) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,cnt=0;
	string s;
	cin>>n>>s;
	rep(i,n-2){
	    if(s.substr(i,3)=="ABC")cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Nim
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int s = sc.nextInt();
			int[] m = new int[2*n];
			for(int i=0;i<2*n;i++)m[i]=sc.nextInt();
			//0: Undefine 1:Lose 2:win
			int[][] dp = new int[2*n][s+1];
			for(int i=0;i<2*n;i++)dp[i][1] = 1;
			for(int j=2;j<=s;j++)for(int i=0;i<2*n;i++){
				boolean win = false;;
				for(int p=1;p<=m[i];p++){
					if(j-p<=0)break;
					if(dp[(i+1)%(2*n)][j-p]==1)win=true;
				}
				dp[i][j] = win?2:1;
			}
			System.out.println(dp[0][s]==2?1:0);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100110;
int n,m;
vector<int> d[MAX];
int kol[MAX];
void dfs(int a,int b){
  if(kol[a] != 0){
    if(kol[a] != b){
      cout << n * (n-1) / 2 - m << "\n";
      exit(0);
    }
    return;
  }
  kol[a] = b;
  for(int el:d[a])dfs(el,3 - b);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  R(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    d[a].PB(b);
    d[b].PB(a);
  }
  dfs(0,1);
  int il = 0;
  R(i,n){
    if(kol[i] == 1)il++;
  }
  cout << il * (n - il) - m << "\n";
}


Measured memory_bytes: 7424
use proconio::input;
use proconio::marker::Usize1;
use smallvec::alloc::collections::VecDeque;

#[proconio::fastout]
pub fn main() {
    input! {
    n:usize,
    ab:[(Usize1,Usize1)],
    }
    let mut g: Vec<Vec<usize>> = vec![Default::default(); n];
    for &(a, b) in &ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut que: VecDeque<usize> = VecDeque::new();
    let mut ans: Vec<Option<usize>> = vec![None; n];
    que.push_back(0);
    while !que.is_empty() {
        let v = que.pop_front().unwrap();
        for &to in &g[v] {
            if ans[to].is_none() {
                ans[to] = Some(v);
                que.push_back(to);
            }
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i].unwrap() + 1);
    }
}


Measured memory_bytes: 18108
S = input()
N = len(S)
out = "AC"
if S[0]!="A":
    out = "WA"
cnt = 0
for i in range(2,N-1):
    if S[i]=="C":
        cnt+=1
if cnt!=1:
    out = "WA"

al=[chr(ord('a') + i) for i in range(26)]

for i in range(1,N-1):
    if S[i]!="C" and S[i] not in al:
        out = "WA"
if S[N-1] not in al:
    out = "WA"

print(out)


Measured memory_bytes: 38384