akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 1e16;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return 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;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

string s;
int n, k;
signed main() {
	cin >> s >> k;
	n = s.size();
	rep(i, n) {
		if (s[i] == 'a') continue;
		if (26 - (s[i] - 'a') <= k) {
			k -= 26 - (s[i] - 'a');
			s[i] = 'a';
		}
	}
	k %= 26;
	rep(i, k) {
		if (s[n - 1] == 'z') s[n - 1] = 'a';
		else s[n - 1] = (char)(s[n - 1] + 1);
	}
	cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> data(n);
    rep(i,0,n){
        cin >> data[i];
    }
    sort(data.begin(),data.end());
    int sum = 0;

    rep(i,0,k){
        sum += data[i];
    }
    cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N); vector<vector<int>> A(N, vector<int>(M));
    rep(i, 0, N) {
        cin >> C[i];
        rep(j, 0, M)cin >> A[i][j];
    }

    int sum = 2000000;

    for (int bit = 0; bit < (1 << N); bit++) {
        vector<int> algo(M, 0);
        int tmp_sum = 0;
        rep(i, 0, N) {
            if (bit & (1 << i)) {//i番目の参考書を買う
                tmp_sum += C[i];
                rep(j, 0, M)algo[j] += A[i][j];
            }
        }

        bool flag = true;
        rep(i, 0, M) {
            if (algo[i] < X) {
                flag = false;
                break;
            }
        }

        if (flag) {
            sum = less(sum, tmp_sum);
        }

    }

    if (sum != 2000000)cout << sum << endl;
    else cout << (-1) << endl;


    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

static int MOD;

ll modmul(ll x, ll y) {
	return x * y % MOD;
}

// power(mod) x^n
ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = modmul(res, x);
		x = modmul(x, x);
		n >>= 1;
	}
	return res;
}

// inverse(mod) x^(-1)
ll inv(ll x) {
	return modpow(x, MOD - 2);
}

ll moddiv(ll x, ll y) {
	return modmul(x, inv(y));
}

// factorial(mod) n!
ll fact(ll n) {
	ll res = 1;
	while (n > 1) {
		res = modmul(res, n);
		n--;
	}
	return res;
}

// permutation(mod) nPr
ll permu(ll n, ll r) {
	if (r < 0 || n < r) return 0;
	else {
		ll res = fact(n);
		res = moddiv(res, fact(n - r));
		return res;
	}
}

// combination(mod) nCr
ll combi(ll n, ll r) {
	ll res = permu(n, r);
	res = moddiv(res, fact(r));
	return res;	
}

ll sumcombi(int r, int c) {
	return combi(r + c + 2, r + 1) - 1;
}

int main () {
	MOD = 1000000007;
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	int ans = sumcombi(r2, c2);
	ans = (ans + (MOD - sumcombi(r1 - 1, c2))) % MOD;
	ans = (ans + (MOD - sumcombi(r2, c1 - 1))) % MOD;
	ans = (ans + sumcombi(r1 - 1, c1 - 1)) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <strstream>
#include <string>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
    string mas[3];
    for (string & str : mas) {
        cin >> str;
    }
    string ans;
    for (UINT index = 0; index < 3; index++) {
        ans += mas[index][index];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <cassert>
using namespace std;
using lint = long long;
const long mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    int sum[N];
    sum[0] = 0;
    for(int i = 0; i < N - 1; i++){
        sum[i + 1] = sum[i] + (S.substr(i, 2) == "AC");
    }
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << sum[r - 1] - sum[l - 1] << endl;
    }
}


Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = (int)S.size();
    const int MOD = 1e9 + 7;
    vector<vector<long long>> dp(3, vector<long long> (N));
    long long size = 1;
    if(S[0] == 'A') dp[0][0] = 1;
    else if(S[0] == '?'){
        dp[0][0] = 1;
        size = 3;
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < 3; j++){
            if(S[i] == 'A'){
                if(j == 0) dp[j][i] = dp[j][i - 1] + size;
                else dp[j][i] = dp[j][i - 1];
            }
            else if(S[i] == 'B'){
                if(j == 1) dp[j][i] = dp[j][i - 1] + dp[j - 1][i - 1];
                else dp[j][i] = dp[j][i - 1];
            }
            else if(S[i] == 'C'){
                if(j == 2) dp[j][i] = dp[j][i - 1] + dp[j - 1][i - 1];
                else dp[j][i] = dp[j][i - 1];
            }
            else {
                if(j == 0) dp[j][i] = dp[j][i - 1] * 3 + size;
                else if(j == 1) dp[j][i] = dp[j][i - 1] * 3 + dp[j - 1][i - 1];
                else if(j == 2) dp[j][i] = dp[j][i - 1] * 3 + dp[j - 1][i - 1];
            }
        }
        for(int j = 0; j < 3; j++) dp[j][i] %= MOD;
        if(S[i] == '?') size *= 3;
        size %= MOD;
    }
    cout << dp[2][N - 1] << endl;
}

Measured memory_bytes: 6668
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=1,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vs SV(n);
  VIN(SV)
  SORT(SV);
  REP(i,n-1){
    if(SV[i]!=SV[i+1]) c++;
  }
  if(c==3) OUT("Three");
  else OUT("Four");
}


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

	/*
	 * 122A
	 * 
	 * To read a character we can read it as a string and do .charAt(0) for it to be a character
	 * A <--> T
	 * C <--> G
	 * When you get one character output the other one
	 * Can be done with if statements like below
	 * 
	 * Time Complexity O(1), Memory Complexity O(1)
	 */
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(0) == 'A') {
			System.out.println('T');
		}
		else if(s.charAt(0) == 'T') {
			System.out.println('A');
		}
		else if(s.charAt(0) == 'G') {
			System.out.println('C');
		}
		else {
			System.out.println('G');
		}
	}

}


Measured memory_bytes: 35568
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int a,b;
		String op;

		Scanner stdIn = new Scanner(System.in);

		a = Integer.parseInt(stdIn.next());
		b = Integer.parseInt(stdIn.next());

		if (a == b) {
			op = " == ";
		} else if (a > b) {
			op = " > ";
		} else {
			op = " < ";
		}

		System.out.println("a" + op + "b");

		stdIn.close();
	}

}

Measured memory_bytes: 26032
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
char map[200010];
int main()
{
	int n, a, b, c, d;
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	int xx = 0;
	for (int i = 1; i <= n; i++)
		scanf(" %1c", &map[i]);
	for (int i = a; i <= c; i++) {
		if (map[i] == '#')xx++;
		else xx = 0;
		if (xx > 1) {
			puts("No");
			return 0;
		}
	}
	xx = 0;
	for (int i = b; i <= d; i++) {
		if (map[i] == '#')xx++;
		else xx = 0;
		if (xx > 1) {
			puts("No");
			return 0;
		}
	}
	if (c < d) {
		puts("Yes");
		return 0;
	}
	int cnt = 0,cnt1=0;
	for (int i = b - 1; i <= d + 1; i++) {
		if (map[i] == '#') {
			cnt = 0;
		}
		else
			cnt++;
		if (cnt >= 3) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int N[4];
int calc(int op1, int op2, int op3) {
    return N[0] + N[1] * (op1 == 0 ? 1 : -1) + N[2] * (op2 == 0 ? 1 : -1) + N[3] * (op3 == 0 ? 1 : -1);
}
int main() {
    char n[5], op[] = "+-";
    cin >> n;
    for (int i = 0; i < 4; i++) N[i] = n[i] - '0';
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++)
            for (int k = 0; k < 2; k++)
                if (calc(i, j, k) == 7) {
                    cout << n[0] << op[i] << n[1] << op[j] << n[2] << op[k] << n[3] << "=7" << endl;
                    return 0;
                }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22) puts("bust");
	else puts("win");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int ans=0,most=-1,tmp,t1,t2;
		for(int i=0;i<n;i++){
			cin>>tmp>>t1>>t2;
			if(most<t1+t2){
				most=t1+t2;
				ans=tmp;
			}
		}
		cout<<ans<<" "<<most<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = 110;
#define debug(x) cout << #x << ": " << x << endl
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
int N;
vector<int> G[MAX_N];
int solve()
{
    vector<int> dist(N + 1, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));
    dist[0] = 0;
    while(que.size())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        if(v == N) break;
        for(auto &&u : G[v])
        {
            if(G[v].size() >= 2)
            {
                int cost = (u == v + 1 ? 1 : 0);
                if(p.first + cost < dist[u])
                {
                    dist[u] = p.first + cost;
                    que.push(P(dist[u], u));
                }
            }
            else
            {
                if(p.first < dist[u])
                {
                    dist[u] = p.first;
                    que.push(P(dist[u], u));
                }
            }
        }
    }
    return dist[N];
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) G[i].push_back(i + 1);
    vector<string> line(N);
    map<string, int> mp;
    for(int i = 0; i < N; i++)
    {
        string s; cin >> s;
        if(s != "goto")
        {
            s.pop_back();
            mp[s] = i;
        }
        else
        {
            string t; cin >> t;
            line[i] = s + ' ' + t;
        }
    }
    for(int i = 0; i < N; i++)
    {
        string s = line[i];
        int pos = -1;
        for(int j = 0; j < s.size(); j++) if(s[j] == ' ') pos = j;
        if(pos != -1)
        {
            string s = line[i].substr(pos + 1);
            s.pop_back();
            int v = mp[s];
            if(v == i + 1) continue;
            G[i].push_back(v);
        }
    }
    cout << solve() << endl;
    return 0;
}




Measured memory_bytes: 3256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double[]c1 = {scan.nextDouble(), scan.nextDouble(), scan.nextDouble()};
		double[]c2 = {scan.nextDouble(), scan.nextDouble(), scan.nextDouble()};
		scan.close();
		double[]ans = getCrossPoint(c1, c2);
		if(ans[0] > ans[2]) {
			System.out.printf("%10.8f %10.8f %10.8f %10.8f\n", ans[2], ans[3], ans[0], ans[1]);
		}else if(ans[0] == ans[2]) {
			if(ans[1] > ans[3]) {
				System.out.printf("%10.8f %10.8f %10.8f %10.8f\n", ans[2], ans[3], ans[0], ans[1]);
			}else {
				System.out.printf("%10.8f %10.8f %10.8f %10.8f\n", ans[0], ans[1], ans[2], ans[3]);
			}
		}else {
			System.out.printf("%10.8f %10.8f %10.8f %10.8f\n", ans[0], ans[1], ans[2], ans[3]);
		}
	}

	static double arg(double[]v) {
		return Math.atan2(v[1], v[0]);
	}
	static double[] polar(double a, double r) {
		double[]p = {Math.cos(r) * a, Math.sin(r) * a};
		return p;
	}
	static double[] getCrossPoint(double[]c1, double[]c2) {
		double[]u = {c1[0], c1[1]};
		double[]v = {c2[0], c2[1]};
		double d = abs(vec(u, v));
		double a = Math.acos((c1[2] * c1[2] + d * d - c2[2] * c2[2]) / (2 * c1[2] * d));
		double t = arg(vec(u, v));
		double[]k1 = polar(c1[2], t + a);

		double[]k2 = polar(c1[2], t - a);
		double[]k = {add(u, k1)[0], add(u, k1)[1], add(u, k2)[0], add(u, k2)[1]};
		return k;
	}
	static double[] add(double[]p1 , double[]p2) {
		double[]p = {p1[0] + p2[0], p1[1] + p2[1]};
		return p;
	}
	static double[] sub(double[]p1, double[]p2) {
		double[]p = {p1[0] - p2[0], p1[1] - p2[1]};
		return p;
	}
	static double[] getCrossPoints(double[]c, double[]p1, double[]p2) {
		double[]p3 = {c[0], c[1]};
		double[]h = project(p1, p2, p3);
		double[]e = vec(p1, p2);
		double l = abs(e);

		double base = Math.sqrt(c[2] * c[2] - norm(vec(p3, h)));
		e[0] *= base / l;
		e[1] *= base / l;
		double[]a = {h[0] + e[0], h[1] + e[1], h[0] - e[0], h[1] - e[1]};
		return a;
	}
	static double[] project(double[]p1, double[]p2, double[]p3) {
		double[]base = vec(p1, p2);
		double[]u = vec(p1, p3);
		double r = dot(u, base) / norm(base);
		double x = p1[0] + base[0]  * r;
		double y = p1[1] + base[1]  * r;
		double[]h = {x, y};
		return h;
	}
	static double abs(double[]p) {
		return Math.sqrt(norm(p));
	}
	static double norm(double[]p) {
		return p[0] * p[0] + p[1] * p[1];
	}
	static double[] vec(double[]p1, double[]p2) {
		double[]u = {p2[0] - p1[0], p2[1] - p1[1]};
		return u;
	}
	static double dot(double[]u, double[]v) {
		return u[0] * v[0] + u[1] * v[1];
	}
	static double cross(double[]u, double[]v) {
		return u[0] * v[1] - u[1] * v[0];
	}
}


Measured memory_bytes: 28196
N, A, B, C = map(int, input().split())
inputs = tuple(tuple(input()) for _ in range(N))

dic = {
    "A": A,
    "B": B,
    "C": C
}

ans = [0] * N
depth = 0
while depth < N:
    key1, key2 = inputs[depth]
    if dic[key1] < dic[key2]:
        dic[key1] += 1
        dic[key2] -= 1
        ans[depth] = key1
    elif dic[key1] > dic[key2]:
        dic[key2] += 1
        dic[key1] -= 1
        ans[depth] = key2
    else:
        if not dic[key1]:
            break
        elif dic[key1] == 1 and depth + 1 < N:
            next_key1, next_key2 = inputs[depth + 1]
            common_key, *_ = {key1, key2} & {next_key1, next_key2}
            else_key, *_ = {key1, key2} - {common_key}
            dic[common_key] += 1
            dic[else_key] -= 1
            ans[depth] = common_key
        else:
            dic[key1] += 1
            dic[key2] -= 1
            ans[depth] = key1
    depth += 1
else:
    print("Yes")
    print(*ans, sep="\n")
    quit()
print("No")


Measured memory_bytes: 18456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
const int N = 2010;

int high[N], low[N], cnt[N], a[N], x, y, n;
vector<int> g[N];
string s;

void dfs(int u,int fa){
	if(fa && g[u].size()==1){
		cnt[u] = a[u];
		low[u] = high[u] = 0;
		return;
	}
	int maxi = 0, mod2 = 0, sum = 0;
	for(auto x:g[u])if(x!=fa){
		dfs(x,u);
		cnt[u] += cnt[x];
		high[x] += cnt[x], low[x] += cnt[x];
		high[u] += high[x];
		mod2 ^= high[x]&1;
		if(low[x]>low[maxi]) maxi=x;
		sum += high[x];
	}
	sum -= high[maxi];
	low[u] = max(mod2, low[maxi]-sum);
	cnt[u] += a[u];
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	cin>>s;
	rep(i,1,n) a[i]=s[i-1]-48;
	rep(i,1,n-1){
		cin>>x>>y;
		g[x].PB(y);g[y].PB(x);
	}
	int ans = 1e9;
	rep(i,1,n){
		memset(cnt,0,sizeof cnt);
		memset(low,0,sizeof low);
		memset(high,0,sizeof high);
		dfs(i,0);
		if(low[i]==0) ans = min(ans, high[i]/2);
	}
	cout<<(ans==1e9?-1:ans)<<endl;
	return 0;
}

Measured memory_bytes: 512
line = gets.chomp.chars.map(&:to_i)
first, second, third = 0, 0, 0

(1..7).each do |bit|
	first = (bit>>2 & 1 == 1 ? [1,"+"] : [-1,"-"] )
	second = (bit>>1 & 1 == 1 ? [1,"+"] : [-1,"-"] )
	third = (bit & 1 == 1 ? [1,"+"] : [-1,"-"] )

	if line[0] + line[1]*first[0] + line[2]*second[0] + line[3]*third[0] == 7
		print "#{line[0]}#{first[1]}#{line[1]}#{second[1]}#{line[2]}#{third[1]}#{line[3]}=7"
		exit
	end
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int r, D, x[11], i;
	r = getint();
	D = getint();
	x[0] = getint();
	ROOP(i, 10) {
		x[i + 1] = (x[i] * r) - D;
		showint(x[i+1]);
	}
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int maxc = 26;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int read(){
    int f = 1,x = 0; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - 48;ch = getchar();}
    return f * x;
}
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll qw(ll x,ll y){ll ans = 1;while(y){if(y&1) ans *= x;x *= x;y >>= 1;}return ans;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool is_prime(ll x){if(x <= 1) return 0;for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;	}
string s,t;
int ans;
int main()
{
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	for(int i = 0;i < 3;i++){
		if(s[i] == t[i]) ans++;
	}			
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc067

#include <bits/stdc++.h>
using namespace std;

void print_yes_no(bool cond, string yes = "Possible", string no = "Impossible") { cout << (cond ? yes : no) << endl; }

int main() {
    int a, b;
    cin >> a >> b;
    print_yes_no(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0);
    return 0;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;

int fast(int a,int n)
{
	int ans = 1;
	while(n)
	{
		if(n&1)	ans *= a;
		a*=a;
		n>>=1;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int k1 = 0,k2 = 0;
	while(a >= b*fast(2,k1))
		k1++;
	while(b*fast(2,k1) >= c*fast(2,k2))
		k2++;
	if(k1 + k2 <= k)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    ll a, b, k;
    
    cin >> a >> b >> k;

    if (a >= k) {
        a -= k;
        cout << a << " " << b << endl;
        return 0;
    }
    k -= a;
    a = 0;
    b -= k;
    if (b < 0)b = 0;
    cout << a << " " << b << endl;
   


    return 0;

}

Measured memory_bytes: 3624
n, p = map(int, input().split())
di = {}
for i in range(2, int(p**0.5)+1):
    if p%i==0:
        tmp = 0
        while p%i==0:
            p //= i
            tmp += 1
        di[i] = tmp
    if p==1:
        break
else:
    di[p] = 1
ans = 1
for i, j in di.items():
    ans *= i**(j//n)
print(ans)

Measured memory_bytes: 3064
X = int(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


while(1):
    if is_prime(X):
        print(X)
        break
    else:
        X += 1


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define vecadd emplace_back

typedef pair<int,int> P;

int main(){
  int n,h[100010];
  
  rep(i,100010)h[i]=1000000001;
  
  cin>>n;
  
  rep(i,n)cin>>h[i];
  
  int a=0,temp=0;
  
  rep(i,n){
    if(h[i]>=h[i+1])temp++;
    else{
      if(a<temp)a=temp;
      temp=0;
    }
  }
  
  cout<<a;
    
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
    int t;
   // cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,min1=10000000000000,max2=-100;
  char c;
  cin>>c;
    if(c>=65&&c<=90)
      
    cout<<"A";
      else
        cout<<"a";
    }
 return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int xdis = tx - sx, ydis = ty - sy;
    rep(i,xdis)
    {
        cout << 'R';
    }
    rep(i,ydis)
    {
        cout << 'U';
    }
    rep(i, xdis)
    {
        cout << 'L';
    }
    rep(i, ydis)
    {
        cout << 'D';
    }
    cout << 'L';
    rep(i,ydis+1)
    {
        cout << 'U';
    }
    rep(i,xdis+1)
    {
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    rep(i, ydis + 1)
    {
        cout << 'D';
    }
    rep(i, xdis + 1)
    {
        cout << 'L';
    }
    cout << 'U';
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8
#

import sys

def main(c, x):
    if '0' == x: return True
    msg = 'Case %d: %s' % (c, x)
    print(msg)
    return False
    
if '__main__' == __name__:
    counter = 1
    try:
        while True:
            if main(counter, input().strip()): break
            counter += 1
    except EOFError:
        pass



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

#define int long long
#define N 2100000
#define INF 1000000000000000000LL
class Dinic
{
private:
	int lt[N], nt[N], bi[N], ci[N], tl;
	int nw[N], dis[N], vis[N];
	queue <int> Q;
public:
	int s, e, tot;
	int oppo(int t) {return t & 1? t + 1: t - 1;}
	void build(int a, int b, int c)
	{
		nt[++ tl] = lt[a]; lt[a] = tl; bi[tl] = b; ci[tl] = c;
		nt[++ tl] = lt[b]; lt[b] = tl; bi[tl] = a; ci[tl] = 0;
        // cout << a << " " << b << " " << c << "\n";
	}
	void flow(int p, int d)
	{
		ci[p] -= d; ci[oppo(p)] += d;
	}
	int dfs(int t, int maxl)
	{
		int nowl = 0;
		if (t == e) return maxl;
		for (int &p = nw[t]; p; p = nt[p])
			if (dis[t] + 1 == dis[bi[p]] && ci[p])
			{
				int d = dfs(bi[p], min(ci[p], maxl - nowl));
				flow(p, d); nowl += d;
				if (nowl == maxl) return maxl;
			}
		return nowl;
	}
	void bfs()
	{
		for (int i = 1; i <= tot; ++ i) vis[i] = 0, dis[i] = tot + 1;
		vis[s] = 1; dis[s] = 0; Q.push(s);
		while (!Q.empty())
		{
			int hd = Q.front(); Q.pop();
			for (int p = lt[hd]; p; p = nt[p])
				if (!vis[bi[p]] && ci[p])
				{
					vis[bi[p]] = 1;
					dis[bi[p]] = dis[hd] + 1;
					Q.push(bi[p]);
				}
		}
	}
	int solve()
	{
		int ans = 0;
		while (1)
		{
			bfs();
			if (!vis[e]) return ans;
			for (int i = 1; i <= tot; ++ i) nw[i] = lt[i];
			ans += dfs(s, INF);
		}
	}
	void init()
	{
		for (int i = 1; i <= tot; ++ i) lt[i] = 0;
		for (int i = 1; i <= tl; ++ i) bi[i] = ci[i] = nt[i] = 0;
		s = e = tot = tl = 0;
	}
}F;


int h, w;
int x = 0;
const int P = 1000;
string st[P];
signed main()
{
    cin >> h >> w;
    for (int i = 0; i < h; ++ i) cin >> st[i];

    F.s = h + w + 1; F.e = F.tot = F.s + 1;
    for (int i = 0; i < h; ++ i)
        for (int j = 0; j < w; ++ j)
        {
            if (st[i][j] == 'S') F.build(F.s, i + 1, INF), F.build(F.s, j + h + 1, INF);
            else if (st[i][j] == 'T') F.build(i + 1, F.e, INF), F.build(j + h + 1, F.e, INF);
            else if (st[i][j] == 'o') F.build(i + 1, j + h + 1, 1), F.build(j + h + 1, i + 1, 1);
        }
    int ans = F.solve();
    if (ans >= h * w * 2) ans = -1;
    cout << ans << "\n";
}


Measured memory_bytes: 12544
import sys

N = int(input())

t = [0]
x = [0]
y = [0]

for i in range(N) : 
    a, b, c = map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(N) : 
    T = t[i+1] - t[i]
    R = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]) 
    if T < R or (T + R) % 2 == 1 :
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 11820
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b, k;

  cin >> a >> b >> k;

  int ret;
  int n = 0;

  for (int i = 100; i >= 1; i--){
    if (a % i == 0 && b % i == 0)
      n++;
    if (n == k){
      ret = i;
      break;
    }
  }
  cout << ret << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

long long koyaku_max(long long a,long long b){
    long long r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
long long kobai_min(long long a,long long b){
    long long tmp;
    tmp =  a / koyaku_max(a,b);
    return tmp * b;
}
vll a;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;
    rep(ni,N){
        cin >> ltmp;
        a.push_back(ltmp/2);
    }
    
    sort(a.begin(),a.end());
    ll kobai = a[0];
    for( ll ai = 1 ; ai <=a.size()-1 ; ai++ ){
        kobai = kobai_min(kobai,a[ai]);
    }

    bool flag=true;
    rep(ai,a.size()){
        if((kobai/a[ai])%2==0){
            flag = false;
            break;
        }
    }
    ll cnt=0;
    if(flag){
        ll comp = kobai;
        while(comp<=M){
            cnt++;
            //cout << comp << endl;
            comp += kobai*2; 
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 4272
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>
#include <cmath>

int main() {
  long long X, Y;
  std::cin >> X >> Y;
  long long p = Y / X;
  long long ans = 0;
  while (p) {
    p /= 2;
    ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;


int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    
    int x[N], y[M];
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    for(int i=0; i<M; i++){
        cin >> y[i];
    }
    
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if(x[i]>=y[j]){
                cout<<"War"<<endl;
                return 0;
            }
            
        }
    }
    
    sort(x,x+N);
    sort(y,y+M);
    
    if(Y<=x[N-1] || X>=y[0]-1){
        cout<<"War"<<endl;
        return 0;
    }
    
    cout<<"No War"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct _node {
    int x;
    struct _node *parent;
    struct _node *left;
    struct _node *right;
} Node;

void set(Node *ptr, int x, Node *parent, Node *left, Node *right) {
    ptr->x = x;
    ptr->parent = parent;
    ptr->left = left;
    ptr->right = right;
}

Node *insert(Node *ptr, int x) {
    if(ptr == NULL) {
        Node *new = malloc(sizeof(Node));
        set(new, x, NULL, NULL, NULL);
        return new;
    } else if(x > ptr->x) {
        ptr->right = insert(ptr->right, x);
        ptr->right->parent = ptr;
    } else if(x < ptr->x) {
        ptr->left = insert(ptr->left, x);
        ptr->left->parent = ptr;
    } 

    return ptr;
}

Node *search(Node *ptr, int x) {
    if(ptr == NULL) {
        return NULL;
    } else if(x == ptr->x) {
        return ptr;
    } else if(x > ptr->x) {
        return search(ptr->right, x);
    } else if(x < ptr->x) {
        return search(ptr->left, x);
    }
}

void printPreorder(Node *ptr) {
    if(ptr != NULL) {
        printf(" %d", ptr->x);
        printPreorder(ptr->left);
        printPreorder(ptr->right);
    }
}

void printInorder(Node *ptr) {
    if(ptr != NULL) {
        printInorder(ptr->left);
        printf(" %d", ptr->x);
        printInorder(ptr->right);
    }
}

int main(void) {
    Node *root = NULL;

    int n;
    char buf[32];

    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%d", &n);

    while(n--) {
        fgets(buf, sizeof(buf), stdin);
        if(buf[0] == 'p') {
            printInorder(root);
            puts("");
            printPreorder(root);
            puts("");
        } else {
            char command[8];
            int key;
            sscanf(buf, "%s %d", command, &key);
            if(command[0] == 'i') {
                root = insert(root, key);
            } else if(command[0] == 'f') {
                puts(search(root, key) ? "yes" : "no");
            }
        }
    }

    return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  ll res = 0;
  for (int i = 1; i <= n; i++) {
    int i2 = i;
    vector<int> x;
    while (i2 > 0) {
      x.push_back(i2 % 10);
      i2 /= 10;
    }
    int sum = 0;
    for (int j : x) {
      sum += j;
    }
    if (sum >= a && sum <= b) {
      res += i;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3624
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

long long GCD(long long a, long long b) {
	if (a < b) {
		swap(a, b);
	}
	long long r = -1;
	while (r != 0) {
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main() {
	double R;
	cin >> R;
	cout << setprecision(15) << 2 * R * 3.14159265358979 << endl;
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

ll n, m;
ll ans;

int main()
{
	scanf("%lld%lld", &n, &m);

	if(n<=(m/2)) {
		ans=(n+(m/2))/2;
	} else {
		ans=(m/2);
	}

	printf("%lld\n", ans);

	return 0;
}

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

int main(){
    ll n,k; cin >> n >> k;
    ll ans=0;
    if(k==0){
        cout << (ll)n*n << endl;
        return 0;
    }
    for(int i=k+1;i<=n;i++){
        ans+=(n/i)*(i-k);
        ll p=n%i;
        if(p>=k){
            ans+=(p-k+1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

typedef long long ll;

using namespace std;

ll f(ll x) {
	if (x == 1) {
		return 1;
	}
	return f(x / 2) * 2 + 1;
}

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

	cout << f(H) << endl;

	return 0;
}

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

#define ll long long

using namespace std;

int main(){

 char key[7]={'k','e','y','e','n','c','e'};
 string s;
 cin>>s;
 int po=0;
 if(s.length()<7){ cout<<"NO"<<endl; return 0;}
 if(s.length()==7){ if(s=="keyence") cout<<"YES"<<endl;
                    else cout<<"NO"<<endl;
                    return 0;}
 for(int i=0;i<=7;++i){
   po=0;
   for(int j=0;j<s.length();++j){
     if(j<i||j>=i+s.length()-7){
       if(s[j]==key[po]) po++;
     }
   }
   if(po==7){
     cout<<"YES"<<endl;
     return 0;
   }
 }

   cout<<"NO"<<endl;
 
 return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(n);
        Console.WriteLine(n[2]*10+n[1]+n[0]);

	} 
}

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

int main(){
	
	while(1){
		int N, a[1000], min = 10000000;
		cin>>N;
		if(N == 0)break;
		for(int i = 0; i < N; i++){
			cin>>a[i];
		}
	
		for(int i = 0; i < N - 1; i++){
			for(int j = i + 1; j < N; j++){
				if(fabs(a[i] - a[j]) < min) min = fabs(a[i] - a[j]);
			}
		}
		cout<<min<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3076
N = int(input())
s = input()

def construct(a0, a1):
    a = [None] * N # True: sheep, False: wolf
    a[0] = a0
    a[1] = a1
    for i in range(1, N - 1):
        if a[i]:
            if s[i] == 'o':
                a[i + 1] = a[i - 1]
            elif s[i] == 'x':
                a[i + 1] = not a[i - 1]
        else:
            if s[i] == 'o':
                a[i + 1] = not a[i - 1]
            elif s[i] == 'x':
                a[i + 1] = a[i - 1]
    for i in [0, N - 1]:
        if a[i]:
            if s[i] == 'o' and a[(i + 1) % N] != a[(i - 1) % N]:
                return None
            elif s[i] == 'x' and a[(i + 1) % N] == a[(i - 1) % N]:
                return None
        else:
            if s[i] == 'o' and a[(i + 1) % N] == a[(i - 1) % N]:
                return None
            elif s[i] == 'x' and a[(i + 1) % N] != a[(i - 1) % N]:
                return None
    return a

def solve():
    for a0 in [False, True]:
        for a1 in [False, True]:
            a = construct(a0, a1)
            if a is not None:
                return "".join(map(lambda x: 'S' if x else 'W', a))
    return "-1"

print(solve())

Measured memory_bytes: 5732