akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int def(vector<int> s) {
	int si = s.size();
	if (si <= 1) {
		return 1;
	}
	else {
		int x = s[si - 1];
		int d = 0;
		for (int i = 0; i < si - 1; i++) {
			if (s[i] == x) {
				d = 1;
			}
		}
		if (d == 1) {
			return 0;
		}
		else {
			vector<int> t(si - 1);
			for (int i = 0; i < si - 1; i++) {
				t[i] = s[i];
			}
			return def(t);
		}
	}
}
int rui(int a, int b) {
	if (b == 0) {
		return 1;//aのb
	}
	else {
		return rui(a, b - 1)*a;
	}
}
int ke(int a, int b) {
	if (b < 10) {
		return a * 10 + b;
	}
	else {
		return a * 100 + b;
	}
}
int main()
{
	int az = 0;
	while (az == 0) {
		int n, k; int ans = 0;
		cin >> n >> k;
		if (n*n + k * k == 0) {
			az = 1;
		}
		else {
			vector<int> su(rui(n,k),0);
			int siz = 0;
			vector<int> ca(n);
			for (int i = 0; i < n; i++) {
				cin >> ca[i];
			}
			for (int i = 0; i < rui(n, k); i++) {
				vector<int> na(k);
				int j = i;
				for (int x = 0;  x< k; x++) {
					na[x] = j % n;
					j = j / n;
				}
				if (def(na) == 1) {
					int si = 0;
					for (int x = 0; x < k; x++) {
						si = ke(si, ca[na[x]]);
					}
					su[siz] = si;
					siz++;
				}
			}
			sort(su.begin(), su.end());
			reverse(su.begin(), su.end());
			int ba = -1;
			for (int i = 0; i < siz; i++) {
				if (ba != su[i]) {
					ans++;
					ba = su[i];
				}
			}
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 3184
#include <iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int start, end;
  if (A < C) {
    start = C;
  } else {
    start = A;
  }
  if (B < D) {
    end = B;
  } else {
    end = D;
  }
  if (start < end) {
    cout << (end - start);
  } else {
    cout << 0;
  }
  
  return 0;
}

Measured memory_bytes: 256
def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(key=lambda x: -abs(x))
    kouho = []
    minus = 0
    last_plus = None
    last_minus = None
    if k == 1:
        print(max(a))
        return
    for i in range(k):
        kouho.append(a[i])
        if a[i] >= 0:
            last_plus = a[i]
        if a[i] < 0:
            minus += 1
            last_minus = a[i]
    if minus % 2 == 0:
        ans = 1
        for i in kouho:
            ans = ans*i % mod
        print(ans)
        return
    change_plus = None
    change_minus = None
    if last_plus != None:
        # マイナスを追加する
        for i in range(k, n):
            if a[i] <= 0:
                change_plus = a[i]
                break
    if last_minus != None:
        # マイナスを追加する
        for i in range(k, n):
            if a[i] >= 0:
                change_minus = a[i]
                break

    # print(kouho)
    #print(last_plus, change_plus)
    #print(last_minus, change_minus)

    if change_plus == None and change_minus == None:
        ans = 1
        for i in range(k):
            ans = ans*a[-i-1] % mod
    elif change_plus == None:
        ans = change_minus
        for i in kouho:
            ans = ans*i % mod
        ans = ans*pow(last_minus, mod-2, mod) % mod
    elif change_minus == None:
        ans = change_plus
        for i in kouho:
            ans = ans*i % mod
        ans = ans*pow(last_plus, mod-2, mod) % mod
    else:
        if abs(change_plus*last_minus) < abs(change_minus*last_plus):
            ans = change_minus
            for i in kouho:
                ans = ans*i % mod
            ans = ans*pow(last_minus, mod-2, mod) % mod
        else:
            ans = change_plus
            for i in kouho:
                ans = ans*i % mod
            ans = ans*pow(last_plus, mod-2, mod) % mod
    print(ans)


main()


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> c(26);
  vector<int> cand = {'M'-'A', 0, 'R'-'A', 2, 'H'-'A'};
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    c[s[0]-'A']++;
  }
  long long res = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        res += (long long)c[cand[i]] * c[cand[j]] * c[cand[k]];
      }
    }
  }
  cout << res << '\n';
  return 0;
}

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

using namespace std;

int main(){

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

  vector<long long> dp(n,10000000007);

  dp[0]=a[0];

  for(int i=1;i<n;i++){
    if(a[i]>dp[i-1])dp[i]=a[i];
    else{
      dp[lower_bound(dp.begin(),dp.end(),a[i])-dp.begin()]=a[i];
    }
  }

  for(int i=n-1;i>=0;i--){
    if(dp[i]!=10000000007){
      cout << i+1 << endl;
      break;
    }
  }

}


Measured memory_bytes: 4412
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll a,b; cin >> a >> b;
  
  if(abs(a-b) >= 2){
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = 1;
 
    rep(i,a){
      ans *= i+1;
      ans = mod(ans);
    }
    rep(i,b){
      ans *= i+1;
      ans = mod(ans);
    }
  
  if(abs(a-b) == 1){
    cout << ans << endl;
  }
  else cout << mod(ans*2) << endl;
  
  
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

#define f first 
#define s second 
#define mp make_pair
#define pb push_back

typedef long long ll;

const int mod=1e9+7;
const int INF=INT_MAX;

int main(){
    int n;
    cin>> n;
    cout << 180*(n-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
	cin >> n;
    ll res = 1;
    ll mod = 1e9+7;
	rep(i, 1, n + 1)
        res = (res * i) % mod;
    cout << (ll)res;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinArr()
	N, _ := strconv.Atoi(list[0])
	M, _ := strconv.ParseFloat(list[1], 64)
	n := N
	m := int(math.Round(M * 100))
	fmt.Printf("%d\n", (n*m)/100)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
#define largest_diget 100000
int main()
{
	int n;
	int o;
	int Min=100000;
	int j;
	int s;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		j=n-i;
		s=0;
		for(o=1;o<100000;o=o*10)
		{
			if(i>=o)
			{
				s+=i/o%10;
				if(j>=o)
				{
					s+=j/o%10;
				}
			}
			else if(j>=o)
			{
				s+=j/o%10;
			}
			else
			{
				break;
			}
		}
		//test:printf("  s=%d  i=%d  j=%d  \n",s,i,j);
		if(s<Min)
		{
			Min=s;
		}
	}
	printf("%d",Min);
	return 0;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

朴素 DP 设 f[i][j] 表示 n, m 分别为 i, j 时的答案。
考虑每个 f[i][j] 对最后 f[n][m] 的贡献，
设 g[n][m] 表示所有 i != j 的 f[i][j] 对 f[n][m] 的贡献和，
假设 n > m ，由 f 的递推式可以得出 g[n][m] = g[n][m - 1] ，
进一步的，g[n][m] = max(n, m) 。

那么现在的问题是计算每个 f[i][i] 对 f[n][m] 的贡献。
不难发现每条转移路径上的 f[i][i] 的贡献是 1 / 2 ，
那么 f[i][i] 的贡献就是 1 / 2 乘上转移到 f[i][i] 的系数，即概率，
而这个概率就是经过 f[i][i] 的转移上的路径数除以总路径数。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 500005, mod = 998244353;
lolong fac[maxn << 1];

inline lolong power(lolong x, int k) {
	if(k < 0) k += mod - 1;
	lolong res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

inline lolong C(int n, int m) {
	return fac[n] * power(fac[m], -1) % mod * power(fac[n - m], -1) % mod;
}

int main() {
	int n = input(), m = input();
	fac[0] = 1;
	for(int i = 1; i <= n + m; i ++)
		fac[i] = fac[i - 1] * i % mod;
	lolong ans = 0;
	for(int i = 1; i <= n and i <= m; i ++)
		debug("%lld\n", ans),
		ans += C(i << 1, i) * C(n + m - (i << 1), n - i) % mod;
	ans %= mod;
	(ans *= power(2 * C(n + m, n) % mod, -1)) %= mod;
	 ans += std::max(n, m);
	printf("%lld\n", ans);
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 1e9 + 7;


int main() {
    int W, H;
    cin >> W >> H;
    vector<vector<int>> u(W, vector<int>(H));
    vector<vector<int>> d(W, vector<int>(H));
    vector<vector<int>> r(W, vector<int>(H));
    vector<vector<int>> l(W, vector<int>(H));
    vector<string> g(W);
    for (int i = 0; i < W; i++) cin >> g[i];
    
    for (int i = 0; i < W; i++) {
        int cnt = 0;
        for (int j = 0; j < H; j++) {
            l[i][j] = cnt;
            if (g[i][j] == '#') cnt = 0;
            else cnt++;
        }
        cnt = 0;
        for (int j = H-1; j >= 0; j--) {
            r[i][j] = cnt;
            if (g[i][j] == '#') cnt = 0;
            else cnt++;
        }
    }

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = 0; j < W; j++) {
            u[j][i] = cnt;
            if (g[j][i] == '#') cnt = 0;
            else cnt++;
        }
        cnt = 0;
        for (int j = W - 1; j >= 0; j--) {
            d[j][i] = cnt;
            if (g[j][i] == '#') cnt = 0;
            else cnt++;
        }
    }
    int ans = 0;
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (g[i][j] == '#') continue;
            ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j]);
        }
    }

    cout << ans+1;
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        int a=s[i]-'0';
        n = (n+a)%9;
    }
    if(n==0) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int dp[55][55][2510];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, A; cin >> n >> A;
	VE x(n); rep(i, n)cin >> x[i];
	int X = A;
	rep(i, n)chmax(X, x[i]);
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n * X; k++) {
				if (i == 0 && j == 0 && k == 0)dp[i][j][k] = 1;
				else if (i >= 1 && k < x[i - 1])dp[i][j][k] = dp[i - 1][j][k];
				else if (i >= 1 && j >= 1 && k >= x[i - 1]) {
					dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
				}
				else {
					dp[i][j][k] = 0;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[n][i][i*A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 55424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for(int i = 1; i <= N; i++) A[i] = sc.nextInt();
        // dp[i][j]：先頭がｉ番目、末尾がｊ番目から始まる時のＸ－Ｙ（後手の時はＹ－Ｘ）
        long[][] dp = new long[N+1][N+1];
        // len：のこりの要素数
        for(int len = 1; len <= N; len++){
            // i：残り要素の先頭位置
            for(int i = 1; len +i -1 <= N; i++){
                int j = len +i -1;
                if(len == 1){
                    dp[i][j] = A[i];
                }else{
                    // 現在取れる要素から、それ以降の相手の得点
                    // （厳密には先手視点ではＹ－Ｘ，後手視点ではＸ－Ｙ）を引いた結果のうち、
                    // より大きくなるほうを選択する
                    dp[i][j] = Math.max(A[i] - dp[i+1][j], A[j] - dp[i][j-1]);
                }
            }
        }
        System.out.println(dp[1][N]);
        sc.close();

    }

}


Measured memory_bytes: 130460
import java.util.Scanner;

class Main{
	public static void main (String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int c;
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		if(a>=13)
			c = b;
		else if(a<=5)
			c = 0;
		else
			c = b/2;
		System.out.print(c);
	}
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  int cnt(0),maxi(0);
  for(int i(0);i<N;i++){
    int a,b;
    cin>>a>>b;
    if(a == b) {
      cnt++;
      maxi = max(maxi, cnt);
    }else{
      cnt = 0;
    }
  }
  if(maxi >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3600
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define MOD 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define loop(x,y,z) for(int x=y;x<z;x++)
ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a/gcd(a, b))*b;
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    ll a[x];
    mll m;
    f(i,x){
        cin>>a[i];
        m[a[i]]++;
    }
    ll ans=0;
    f(i,x){
        ll flg=0;
        for(ll j=1;j*j<=a[i];j++){
            if(a[i]%j==0){
                ll k=j;
                ll k1=a[i]/k;
                if(m.find(k)!=m.end() && k!=a[i]){
                    flg=1;
                    break;
                }
                if(m.find(k1)!=m.end() && k1!=a[i]){
                    flg=1;
                    break;
                }
                if(k1==a[i] && m[k1]>1){
                    flg=1;
                    break;
                }
            }
        }
        if(flg==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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


using namespace std;
using ll = long long;


int main() {
    ll n, d;
    cin >> n >> d;
    ll res = 0;
    for(int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        auto ok = (d*d >= a*a + b*b);
        res += ok;
    }
    cout << res << "\n";




    return 0;
}



Measured memory_bytes: 3632
n = int(input())
a = [int(_) for _ in input().split()] 
c = 0
for i in range(1,n-1):
    if a[i-1]<a[i] and a[i]<a[i+1]:
        c += 1
    elif a[i]<a[i-1] and a[i+1]<a[i]:
        c += 1
print(c)
    

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

int main()
{
	string x,y;
	cin >> x >> y;
	if(x > y){
		cout << ">" << endl;
	}else  if(x < y){
		cout << "<" << endl;
	}else{
		cout << "=" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Bibary search tree
#include <stdio.h>
#include <string.h>
#define N 500001
 
 typedef struct node {
   int key;
   struct node* left;
   struct node* right;
 } NODE;

void insert(NODE*, NODE*);
NODE* find(NODE*, int);
void printInorder(NODE*);
void printPreorder(NODE*);

 int main() {
   int i, j;
   char order[10];
   int m, key;
   NODE node[N];
   NODE *z;
   int k;

   // input
   scanf("%d", &m);
   
   for(i = 0; i < m; i++) {
     scanf("%s", order);
     if(strcmp(order, "insert") == 0) {
       scanf("%d", &key);
       if(i == 0) {
	 node[i].key = key;
	 node[i].left = NULL;
	 node[i].right = NULL;
       }
       else {
	 node[i].key = key;
	 node[i].left = NULL;
	 node[i].right = NULL;
	 insert(node, &node[i]);
       }
     }
     else if(strcmp(order, "print") == 0) {
       printInorder(&node[0]);
       printf("\n");
       printPreorder(&node[0]);
       printf("\n");
     }
     else if(strcmp(order, "find") == 0) {
       scanf("%d", &k);
       if(find(&node[0], k) == NULL) {
	 printf("no\n");
       }
       else {
	 printf("yes\n");
       }
     }
     else printf("error\n");
   }

   return 0;
 }

void insert(NODE* tree, NODE* node) {
  int i = 0;
  NODE *x;
  NODE *y;

  y = NULL;
  x = &tree[0];
  while(x != NULL) {
    y = x;
    if(node->key < x->key) x = x->left;
    else x = x->right;
  }
  if(node->key < y->key){
    y->left = node;
  }
  else{
    y->right = node;
  }
}
 
void printInorder(NODE* node) {
  if(node != NULL) {
    printInorder(node->left);
    printf(" %d", node->key);
    printInorder(node->right);
  }
}

void printPreorder(NODE* node) {
  if(node != NULL) {
    printf(" %d", node->key);
    printPreorder(node->left);
    printPreorder(node->right);
  }
}

NODE* find(NODE* node, int k) {
  if((node == NULL)||(k == node->key)) {
    return node;
  }
  if(k < node->key) {
    return find(node->left, k);
  }
  else {
    return find(node->right, k);
  }
}



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

int main(){
    ll n , k ;
    cin >> n >> k ;
    vector<ll> A(n) ;
    rep(i,n) cin >> A.at(i) ;
    rep(i,n) A.at(i)-- ;
    map<ll,ll> where ;
    ll now = 0 ;//今いる場所
    ll count=0 ;//カウント
    ll two = 0 ;//二週目に入ったときの回数
    ll three=0 ;//三週目に入ったときの回数
    where[now] = 1 ;
    bool flag =true ;
    while(1){
        if( count == k ){
            cout << now + 1 << endl ;
            return 0 ;
        }//移動回数が十分小さい場合には，この段階で出力する．
        now = A[now] ;
        where[now]++ ;
        count++ ;
        if(where[now] == 2 & flag ){
            two = count ;
            flag = false ;
        } 
        if(where[now]==3){ 
            three = count ;
            break ;
        }
    }
    ll amari = ( k - two )%( three - two ) ;
    //周期移動の開始時点から周期移動を考慮すること
    rep(i,amari){
        now = A[now] ;
    }
    cout << now + 1 << endl ;
}


Measured memory_bytes: 14812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;
 
//const ll mod = 1e9+7;
 
void setIO(string name) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
 
//setIO("sleepy");


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//setIO("swap");
	ll n;
	cin >> n;
	unordered_map <string,ll> mapp;
	for (int z=0;z<n;z++){
		string a;
		cin >> a;
		mapp[a]++;
	}
	ll maxi = 0;
	vector <string> ans;
	for (auto it = mapp.begin();it !=mapp.end();it++){
		if (it->second > maxi){
			maxi = it->second;
			ans.clear();
			ans.push_back(it->first);
		}
		else if (it->second == maxi){
			ans.push_back(it->first);
		}
	}
	sort(ans.begin(),ans.end());
	for (string i : ans){
		cout << i << endl;
	}
}

Measured memory_bytes: 25284
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL q,h,s,d,n;
int main() {
	cin>>q>>h>>s>>d>>n;
	h=min(h,2*q);
	s=min(s,min(2*h,4*q));
	d=min(d,min(min(2*s,4*h),8*q));
	LL ans=n/2*d;
	n=n%2;
	if(n==1)ans+=s;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
numbers = list(map(int, input().split()))

print(' '.join(str(x) for x in numbers))
for i in range(1, n):
    key = numbers[i]
    j = i - 1
    while 0 <= j and key < numbers[j]:
        numbers[j+1] = numbers[j]
        j -= 1
    numbers[j+1] = key
    print(' '.join(str(x) for x in numbers))

Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;

long long modpow(long long a, long long n,long long mod=MOD){
    long long i=1,ret=1,p=a;
    while(i<=n){
        if(i&n) ret=(ret*p)%mod;
        i=(i<<1);
        p=(p*p)%mod;
    }
    return ret;
}
vector<long long> fac(3030),two(3030),inv(3030);

LL modcomb(LL a, LL b){
    if(a==0 and b==-1){
        return 1;
    }else if(a<b){
        return 0;
    }else{
        return (fac[a]*inv[b]%MOD)*inv[a-b]%MOD;
    }
}
LL pow2(LL a){
    if(a==-1)return 1;
    else return two[a];
}

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

    int n,k;
    cin >> n >> k;
    fac[0]=1;
    two[0]=1;
    const int lim=3030;
    for(int i=1; i<lim; ++i){
        fac[i]=fac[i-1]*i%MOD;
        two[i]=two[i-1]*2%MOD;
    }
    inv[lim-1]=modpow(fac[lim-1],MOD-2);
    for(int i=lim-2; i>=0; --i){
        inv[i]=inv[i+1]*(i+1)%MOD;
    }

    vector<vector<LL>> dp (k+1,vector<LL>(k+1));
    for(int i=1; i<k; ++i){
        dp[k-1][i]=1;
    }
    for(int i=k-2; i>=1; --i){
        dp[i][1]=(dp[i+1][1]+dp[i+1][2])%MOD;
        for(int j=2; j<=i; ++j){
            //dp[i][j]=sum(dp[i+1][1]~dp[i+1][j+1])
            dp[i][j]=(dp[i][j-1]+dp[i+1][j+1])%MOD;
        }
    }
    dp[0][0]=dp[1][1];
    LL ans=0;
    if(k==1){
        cout << pow2(n-2)<<"\n";
        return 0;
    }else if(k==n){
        ans=dp[0][0]%MOD;
    }else{
        for(int m=n; m>=n-k+1; --m){
            ans=(ans+((modcomb(m-2,n-k-1)*pow2(n-k-1)%MOD)*dp[m-(n-k+1)][m-(n-k+1)])%MOD)%MOD;
        }
    }

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



Measured memory_bytes: 31744
// CODEFESTIVAL2017 final C - Time Gap
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var n int
	count := make([]int, 13)
	n, _ = strconv.Atoi(nextLine())
	inputLine := strings.Split(nextLine(), " ")
	for i := 0; i < n; i++ {
		a, _ := strconv.Atoi(inputLine[i])
		count[a]++
	}
	count[0]++
	var use, cand []int
	use = append(use, 0, 24)
	for i, v := range count {
		if (v >= 2 && (i == 0 || i == 12)) || v >= 3 {
			fmt.Println(0)
			return
		}

		if v == 2 {
			use = append(use, i)
			use = append(use, 24-i)

		} else if v > 0 && i != 0 {
			cand = append(cand, i)
		}
	}
	ans := 0

	for i := 0; i < 1<<uint(len(cand)); i++ {
		nowUse := use
		for j, v := range cand {
			if ((i >> uint(j)) & 1) == 1 {
				nowUse = append(nowUse, v)
			} else {
				nowUse = append(nowUse, 24-v)
			}
		}
		sort.Sort(sort.IntSlice(nowUse))
		tempMin := 12
		for i := 0; i < len(nowUse)-1; i++ {
			distance := nowUse[i+1] - nowUse[i]
			if distance < tempMin {
				tempMin = distance
			}
		}
		if tempMin > ans {
			ans = tempMin
		}
	}
	fmt.Println(ans)

}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  int n=s.size();

  ll ans=0,count=0;
  rep(i,0,n){
    if(s[i]=='A')count++;
    else if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
      ans+=count;
      i++;
    }else count=0;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

class Project
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        int i, count = 0;
        char s, t;
        for (i = 0; i < S.Length; i++)
        {
            s = S[i];
            t = T[i];
            if(s != t)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    } 
}

Measured memory_bytes: 27456
n, k = list(map(int, input().split()))
a = []
for i in range(n):
    ai = list(map(int, input().split()))
    a.append(ai)
    
a.sort(key = lambda x: x[0])

cnt = 0
for ai in a:
    cnt += ai[1]
    if cnt >= k:
        print(ai[0])
        break

Measured memory_bytes: 29144
from collections import deque
N,M=map(int,input().split())
L=[[] for i in range(M)]
for i in range(N):
  for j,k in enumerate(input().split()):
    if j==0:
      continue
    L[int(k)-1].append(i)
G=[[] for i in range(N)]
for l in L:
  if len(l)>=2:
    for i in range(len(l)-1):
      if l[i+1] not in G[l[i]]:
        G[l[i]].append(l[i+1])
        G[l[i+1]].append(l[i])

V=[False]*N
n=1
dfs_stack=deque([0])
while dfs_stack:
  a=dfs_stack.popleft()
  if not V[a]:
    n+=1
    for b in G[a]:
      if not V[b]:
        dfs_stack.append(b)
  V[a]=True
if V==[True]*N:
  print("YES")
else:
  print("NO")
  


Measured memory_bytes: 67888
import java.util.*;

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> xs = new ArrayList<>();
        List<Integer> ys = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            xs.add(sc.nextInt());
            ys.add(sc.nextInt());
        }

        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; ++i) arr[i] = i;
        double res = 0;
        int cnt = 0;
        do {
            for (int i = 0; i < n - 1; ++i) {
                res += Math.sqrt(Math.pow(xs.get(arr[i]) - xs.get(arr[i + 1]), 2) +
                        Math.pow(ys.get(arr[i]) - ys.get(arr[i + 1]), 2));
            }
            ++cnt;
        } while (nextPermutation(arr));

        System.out.println(res / cnt);
    }
}

Measured memory_bytes: 24344
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N;
    cin >> N;
    int W[N];
    int sum1 = 0,sum2 = 0,diff = 10000000;
    REP(i,N){cin >> W[i]; sum1 += W[i];}
    REP(i,N){
        sum2 += W[i];
        sum1 -= W[i];
        diff = min(diff,abs(sum2-sum1));
    }
    fin(diff);
    return 0;
}

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

typedef long long ll;
#define ABSOL(a) (a<0 ? (a*(-1)) : a)
#define rep(i, a, b) for(i = a; i < b; i++)
#define REP(i, a, b) for(i = a; i <= b; i++ )
#define scanstr(str) getline(cin, str)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, sum = 0;
	
	cin >> n;
	
	int takoyaki[n];
	
	rep(i, 0, n){
		cin >> takoyaki[i];
	}
	
	rep(i, 0, n){
		rep(j, i+1, n){
			sum += takoyaki[i] * takoyaki[j];
		}
	}
	
	cout << sum << endl;
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    vector<LL> A(N);
    map<LL, LL> L, R;
    REP0 (i, N)
    {
        cin >> A[i];
        L[i - A[i]]++;
        R[i + A[i]]++;
    }
    LL ans = 0;
    for (auto l : L)
    {
        if (R[l.first])
        {
            ans += l.second * R[l.first];
        }
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 39008
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



void test_case()
{
    
   ll n,a,b;
	cin>>n;
	vec v,w;
	ll ar[n][2];
	rep(i,n)
	{	cin>>a>>b;
		ar[i][0]=a,ar[i][1]=b;
		v.pb(a+b);
		w.pb(a-b);
	}
	sort(all(v));
	sort(all(w));
	ll ans=max(v[n-1]-v[0],w[n-1]-w[0]);
	// ans=max(ans,max(w[n-1]-w[0],v[n-1]-v[0]));
	cout<<ans<<endl;

   

   



   
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 9800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

const ll N=1e5+10;
mat dp(N,vec(4));
ll n;
string s;

int main() {
  cin >> s;
  n=s.size();
  dp[n][3]=1;
  string abc="ABC";
  for(ll i=n;i;i--) {
    for(ll j=3;j>-1;j--) {
      if(j==3) {
        ll m=1;
        if(s[i-1]=='?') m=3;
        dp[i-1][j]=m*dp[i][j];
      }
      else {
        ll m=1;
        if(s[i-1]=='?') m=3;
        dp[i-1][j]=m*dp[i][j];
        m=0;
        if(s[i-1]=='?'||s[i-1]==abc[j]) m=1;
        dp[i-1][j]+=m*dp[i][j+1];
      }
      dp[i-1][j]%=mod;
    }
  }
  cout << dp[0][0] << endl;
}

Measured memory_bytes: 7552
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

ll a,b,k;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>a>>b>>k;
    if (k >= a) { k -= a; a = 0; }
    else { a -= k; k = 0; }
    if (k >= b) { b = 0; }
    else { b -= k; }
    cout << a << ' ' << b << '\n';

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1 ) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int a[100000+10],sum[100000+10];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		sum[a[i]-1]=i+1;
	for(int i=0;i<n;i++)
		cout<<sum[i]<<" ";

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    int l=0;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    
    for(int i=0;i<n;i++){
        if(h[i]>=k){
            l++;
        }
    }
    cout<<l;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
namespace xxx{
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define CaseT int T;cin >> T;for(int cas=1;cas<=T;cas++)
#define TCase int T;scanf("%d",&T);for(int cas=1;cas<=T;cas++)
#define clr(a,b) memset(a,b,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define _1s __builtin_popcountll
#define sqr(x) ((x)*(x))
#define upd(a,b) (a%b?a/b+1:a/b)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define fst first
#define sec second
#define MAIN int main
#define GG exit(0)
#define bug cout << "!!!" << endl;
#define bugc(x) cout << "! " << (x) << endl;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;

inline ll rd(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
 
}using namespace xxx;
const int N = 1e5+20;

MAIN(){
	int op;
	cin >> op;
	if(op==1) puts("Hello World");
	else {
		int a, b;
		cin >> a >> b;
		cout << a+b << endl;
	}
	GG;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;


int main(int argc, char *argv[])
{
	ll n;
	cin >> n;
	ll ret=0;

	if (n%2==0)
	{
		for(n/=2;n>0;n/=5)
		{
			ret+=(n/5);
		}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    static int[] A = new int[50];
    static int n;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
            A[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        for(int i = 0; i < q; i++){
            int M = sc.nextInt();
            if(solve(0,M)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }

    public static boolean solve(int i, int m){
        if(m == 0) return true;
        if(i >= n) return false;
        boolean res = (solve((i + 1), m)) || (solve((i + 1), (m - A[i])));
        return res;
    }
}


Measured memory_bytes: 26896
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll X, A;
    cin >> X >> A;
    if ( X < A) print(0);
    else print(10);
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

llint n;
vector<llint> G[200005];
vector<llint> vec[3];
int color[200005];
int ans[200005];
int pos, neg;

int dfs(int v, int p, int c)
{
	color[v] = c;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v, -c);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i = 1; i <= n; i++){
		vec[i%3].push_back(i);
	}
	
	dfs(1, -1, 1);
	
	for(int i = 1; i <= n; i++){
		if(color[i] == 1) pos++;
		else neg++;
	}
	if(neg > pos){
		swap(pos, neg);
		for(int i = 1; i <= n; i++) color[i] *= -1;
	}
	if(neg < vec[1].size()){
		for(int i = 1; i <= n; i++){
			if(color[i] == -1){
				ans[i] = vec[0].back();
				vec[0].pop_back();
			}
		}
		vec[0].insert(vec[0].end(), vec[1].begin(), vec[1].end());
		vec[0].insert(vec[0].end(), vec[2].begin(), vec[2].end());
		
		for(int i = 1; i <= n; i++){
			if(color[i] == 1){
				ans[i] = vec[0].back();
				vec[0].pop_back();
			}
		}
	}
	else{
		for(int i = 1; i <= n; i++){
			if(color[i] == -1){
				if(vec[1].size()){
					ans[i] = vec[1].back();
					vec[1].pop_back();
				}
				else{
					ans[i] = vec[0].back();
					vec[0].pop_back();
				}
			}
			else{
				if(vec[2].size()){
					ans[i] = vec[2].back();
					vec[2].pop_back();
				}
				else{
					ans[i] = vec[0].back();
					vec[0].pop_back();
				}
			}
		}
	}
	
	for(int i = 1; i <= n; i++) cout << ans[i] << " "; cout << endl;
	
	return 0;
}


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

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            const ll mid = (lo + hi) / 2;
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

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

    ll n, k;
    cin >> n >> k;
    vector<ll> w(n);
    REP(i, n){
        cin >> w.at(i);
    }

    ll ans = binary_search(
        1, accumulate(w.begin(), w.end(), 0LL),
        [&](ll p){
            ll count = 0;
            ll rest = 0;
            for(ll v : w){
                if(p < v){ return false; }
                if(rest >= v){
                    rest -= v;
                }else{
                    count++;
                    rest = p - v;
                }
            }
            return count <= k;
        },
        false
    );
    cout << ans << endl;
    return 0;
}



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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int N, a[100005], b[100005];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + N);
    sort(b, b + N, greater<int>() );
    int ans = 0, ans2 = 0;
    for(int i = 0; i < (N + 1) / 2; i++){
        if(i == 0){
            ans += b[i] - a[i];
            if(N > 2)ans += b[i + 1] - a[i];
        }
        else if(N > 3){
            if(i - 1 < N / 2 && i - 1 >= 0){
                ans += b[i - 1] - a[i];
            }
            if(i + 1 < N / 2){
                ans += b[i + 1] - a[i];
            }
        }
    }
    for(int i = 0; i < (N + 1) / 2; i++){
        if(i == 0){
            ans2 += b[i] - a[i];
            if(N > 2)ans2 += b[i] - a[i + 1];
        }
        else if(N > 3){
            if(i - 1 < N / 2 && i - 1 >= 0){
                ans2 += b[i] - a[i - 1];
            }
            if(i + 1 < N / 2){
                ans2 += b[i] - a[i + 1];
            }
        }
    }
    cout << max(ans, ans2) << endl;

    return 0;
}
/*



*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    return 0;
}

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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int t;

LL mygcd(LL a,LL b){
  if(a==b | b == 0)
    return a;
  if(a<b)
    return mygcd(b,a);
  return mygcd(b,a%b);
}

LL min_solve(LL a,LL b,LL c){
  LL q=a/b;
  LL q_c=c/b;
  LL m = a-(q-q_c)*b;
  while(true){
    if(m<=c & m+b>c)
      break;
    if(m<c)
      m+=b;
    else
      m-=b;
  }
  return m;
}

bool solve(LL b,LL c,LL m,LL d){
  if(m > c)
    return false;
  LL q = (c-m)/d;
  m+=q*d;
  if(m+d<b & m+d>c)
    return false;
  return true;
}

int main(){
  LL a,b,c,d;
  cin>>t;
  REP(i,t){
    cin>>a>>b>>c>>d;
    if(a<b | b>d){
      cout<<"No"<<endl;
      continue;
    }
    if(b<=c+1){
      cout<<"Yes"<<endl;
      continue;
    }
    LL del = mygcd(b,d);
    LL mini = min_solve(a,b,c);

    if(solve(b,c,mini,del))
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256