akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    char A[30]={0};
    for (char c='a'; c<='z'; c++){
        bool found=false;
        for (int i=0; i<S.length(); i++){
            if (S.at(i)==c) found=true;
        }
        if (!found){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0076
"""
import sys
from math import atan, atan2, degrees, pi, cos, sin


Memo = []
def init_memo(n):
    global Memo
    Memo.append((0, 0))
    Memo.append((1, 0))
    for i in range(n):
        x = Memo[-1][0]
        y = Memo[-1][1]
        rad = atan2(-y, -x)
        rad -= pi / 2
        x += cos(rad)
        y += sin(rad)
        Memo.append((x, y))


def solve(n):
    global Memo
    return Memo[n]


def main(args):
    init_memo(1000)
    while True:
        n = int(input())
        if n == -1:
            break
        result = solve(n)
        print('{:.2f}'.format(result[0]))
        print('{:.2f}'.format(result[1]))

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8288
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Array.new(n + 1, 0)) do |a, h|
  h[a] += 1
end.select { |n| n > 0 }.sort

ans = 0
until counts.size <= k
  ans += counts.shift
end

puts ans


Measured memory_bytes: 21488
N = int(input())
M = [list(map(int, input().split())) for i in range(N)]
Q = [[m[0]-m[1], m[0]+m[1]] for m in M]
Q = list(sorted(Q, key=lambda x: x[1]))
NUM = 0
END = -10**9
for q in Q:
  if q[0] >= END:
    NUM += 1
    END = q[1]
print(NUM)


Measured memory_bytes: 43560
/*
https://atcoder.jp/contests/dp/tasks/dp_h
*/
#include <iostream>
#include <vector>

using namespace std;

const int mod = 1e9 + 7;

int dfs (const vector <vector <char>> &grid, int row, int col,
         vector <vector <int>> &ways) {
    if (row == grid.size() - 1 && col == grid[0].size() - 1) {
        return 1;
    }
    if (row >= grid.size() || col >= grid[row].size() || grid[row][col] == '#') {
        return 0;
    }

    if (ways[row][col] >= 0) {
        return ways[row][col];
    }
    unsigned long count = 0;
    for (const pair <int, int> &next : initializer_list <pair <int, int>> 
                                            {{row + 1, col}, {row, col + 1}}) {
        int r = next.first, c = next.second;
        count = ((count % mod) + (dfs(grid, r, c, ways) % mod));
    }
    ways[row][col] = count % mod;
    return ways[row][col];
}

int  main () {
    int rows, cols;
    cin >> rows >> cols;
    vector <vector <char>> grid(rows, vector <char>(cols, '.'));

    for (int r = 0; r < rows; ++r) {
        for (int c = 0; c < cols; ++c) {
            char ch;
            cin >> ch;
            grid[r][c] = ch;
        }
    }
    vector <vector <int>> ways(rows, vector <int>(cols, -1));
    int result = dfs(grid, 0, 0, ways);
    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class word_cnt{
public:
  int cnt;
  string word;

  word_cnt() {
    cnt = 0;
  }

  bool operator < (const word_cnt& right) const {
    return cnt < right.cnt;
  }

};

int main() {

  vector<word_cnt> words;
  word_cnt add;
  string input;

  int len_max = 0;
  string word_max;

  while(cin >> input) {

    for ( int i = 0; i < input.size(); i++ ) {

      if ( input[i] >= 'A' && input[i] <= 'Z' ) input[i] -= ( 'A' - 'a' );

    }

    bool flag = true;
    for ( int i = 0; i < words.size(); i++ ) {

      if ( words[i].word == input ) {
	words[i].cnt++;
	flag = false;
	break;
      }

    }

    if ( flag ) {

      add.cnt = 1;
      add.word = input;
      words.push_back(add);

    }

    if ( len_max < input.size() ) {
      len_max = input.size();
      word_max = input;
    }

  }

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

  cout << words[ words.size()-1 ].word << " " << word_max << endl;

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <cassert>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
class Trie {
public:
	struct Node {
		Node *next[2];
		int sub;
		int dep;
		Node() : sub(0),dep(0){
			for(int i = 0; i < 2; i++){
				next[i] = nullptr;
			}
		}
	};
	Node* root;
	Trie(){
		root = new Node();
	}
	//Trie木にxを加える
	void add(string& s) {
		Node *curr = root;
		for(int i = 0; i < (int)s.size(); i++){
			int y = s[i] - '0';
			if (!curr->next[y]) {
				curr->next[y] = new Node();
			}
			curr = curr->next[y];
			curr->dep = i+1;
		}
		curr->sub= 1;
	}
    //何らかのクエリ
	set<int> query(Node *curr) {
		if(curr->sub==1){
			set<int>st;
			return st;
		}
		set<int> s,t;	
		if(curr->next[0]){
			s = query(curr->next[0]);	
		}else{
			s.insert(curr->dep+1);
		}
		if(curr->next[1]){
			t = query(curr->next[1]);
		}else{
			t.insert(curr->dep+1);
		}
		if(s.size()>t.size()){
			swap(s,t);
		}
		for(auto x:s){
			if(t.count(x)){
				t.erase(x);
			}else{
				t.insert(x);
			}
		}
		return t;
	}
	set<int> query() {
		return query(root);
	}
};

void B(){
	cout << "Bob" << endl;	
}

void A(){
	cout << "Alice" << endl;	
}

signed main(){
	ll n,l;
	cin >> n >> l;
	Trie tr;
	rep(i,n){
		string s;
		cin >> s;
		tr.add(s);
	}
	set<int> res = tr.query();
	res.erase(l+1);
	set<ll,greater<ll> > a;
	for(auto x:res){
		a.insert(l-x+1);
	}
	// for(auto x:a){
	// 	cout << x << endl;
	// }
	bool flag = 1;
	while(!a.empty()){
		ll k = *(a.begin());
		if(k%2==1){
			if(k==1)break;
			a.erase(k);
			if(a.count(1)){
				a.erase(1);
			}else{
				a.insert(1);
			}
			continue;
		}
		ll p = 1;
		for(int i=0;i<60;i++){
			if(k%(p*2)==0){
				p*=2;
			}else{
				break;
			}
		}
		if(k==p){
			break;
		}else{
			a.erase(k);
			if(a.count(p)){
				a.erase(p);
			}else{
				a.insert(p);
			}
		}
	}
	if(a.size()!=0){
		A();
	}else{
		B();
	}
	return 0;
}

Measured memory_bytes: 34652
a, b, x = gets.split.map(&:to_i)
if x <= a * a * b / 2.0
	puts 90 -  Math.atan(x * 2.0 / (a * b * b)) * 180 / Math::PI
else
	puts Math.atan((a * a * b - x) * 2.0 / (a ** 3)) * 180 / Math::PI
end	

Measured memory_bytes: 1788
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		cnt += (a % 2);
	}
	bool ans = cnt % 2;
	cout << (ans ? "NO" : "YES") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int l[n];
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	sort(l, l+n);
	int ans = 0;
	for(int i=n-1; i>=n-k;i--){
		ans = ans + l[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 1e6 + 5;

Modint fact [MAX_N];
Modint invfact [MAX_N];

Modint choose (int n, int k) {
  return fact[n] * invfact[n - k] * invfact[k];
}

// # of ways to use k machines to get it all-black
Modint ways [MAX_N];

int main () {
  fact[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = fact[i - 1] * Modint(i);
  }

  for (int i = 0; i < MAX_N; i++) {
    invfact[i] = inv(fact[i]);
  }
  
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }

  for (int l = 0; n - 2 - 2 * l >= 0; l++) {
    ways[n - 1 - l] = choose(n - 2 - 2 * l + l, l);
  }

  for (int k = 0; k < n; k++) {
    ways[k] *= fact[k];
  }

  for (int k = n - 1; k > 0; k--) {
    ways[k] -= ways[k - 1] * Modint(n - k);
  }

  Modint ans (0);
  for (int k = 0; k < n; k++) {
    ans += Modint(k) * ways[k] * fact[n - 1 - k];
  }

  cout << ans << endl;
}


Measured memory_bytes: 23680
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int A, B, X;
    cin >> A >> B >> X;

    if(X<A || A+B < X){
        p("NO");
    }else{
        p("YES");
    }
    
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int multipleTest = 0;
const int N = 300000 + 7;
const int inf = 1000000007;


map<int, int> st;

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u;scanf("%d", &u);
        st[-u]++;
    }
    ll a = 0, b = 0;
    
    for (auto it : st) {
        if (it.second > 1) {
            if (it.second > 3 && a == 0) {
                cout << 1ll * it.first * it.first << '\n';
                return;
            }
            if (a == 0) a = it.first;
            else if (b == 0) b = it.first;
        }
    }
    cout << 1ll * a * b;
    
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
    
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (int)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        string s="";
        while(n!=0)
        {
            ll z=(n-1)%26;
            s.pb(char(z+'a'));
            n=(n-1)/26;
        }
        reverse(all(s));
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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;}

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

  int N; scanf("%d",&N);
  vi A(N); REP(i,N) scanf("%d",&A[i]);

  set<int> written;
  REP(i,N) {
    if (!written.count(A[i])) {
      written.insert(A[i]);
    }
    else {
      written.erase(A[i]);
    }
  }

  cout << written.size() << endl;
}

Measured memory_bytes: 5248
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#include <numeric>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
constexpr int maxd = 10;
int n, m, q;
vector<int> v, d, c;
vector<vector<int>> g, dp;

void peint(int ve, int di, int num) {
    if (dp[ve][di] != q) return;
    dp[ve][di] = num;
    if (di) {
        peint(ve, di - 1, num);
        for (int u: g[ve]) peint(u, di - 1, num);
    }
    return;
}

int main() {
    cin >> n >> m;
    g = vector<vector<int>>(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b); g[b].push_back(a);
    }
    cin >> q;
    v = d = c = vector<int>(q);
    rep(i, q) {
        cin >> v[i] >> d[i] >> c[i];
        --v[i];
    }
    
    dp = vector<vector<int>>(n, vector<int>(maxd + 1, q));
    for (int i = q - 1; i >= 0; --i) peint(v[i], d[i], i);
    
    rep(i, n) {
        if (dp[i][0] == q) cout << 0 << "\n";
        else cout << c[dp[i][0]] << "\n";
    }
    return 0;
}


Measured memory_bytes: 18804
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> t(n);
  for(int _=1;_<n;_++){
    int u,v;
    cin>>u>>v;
    u--;
    v--;
    t.at(max(u,v)).push_back(min(u,v));
  }
  vector<int64_t> c(n);
  c[0]=1;
  for(int i=1;i<n;i++){
    c[i]=c[i-1]+i+1;
    for(int x:t.at(i))
      c[i]-=x+1;
  }
  int64_t s=0;
  for(int i=0;i<n;i++)
    s+=c[i];
  cout<<s<<endl;
}

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

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

void alpha(){

	ll n, m;
	cin>>n>>m;

	if(n==m) cout<<"Yes";
	else cout<<"No";

	
	return;

}

int main(){

	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int[] res;
    ArrayList<Integer>[] tree;
    int[] ans;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        out.println(main.solve());
        out.flush();
    }
    void solve(){
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for(int i=1; i<=n; i++){
            a[i] = sc.nextInt();
        }
        tree = new ArrayList[n+1];
        for(int i=0;i<=n;i++) tree[i] = new ArrayList<>();
        for(int i=1;i<=n-1;i++){
            int u = sc.nextInt(), v = sc.nextInt();
            tree[u].add(v);
            tree[v].add(u);
        }
        res = new int[n+1];
        ArrayList<Integer> list = new ArrayList<>();
        dfs(1,-1,list,a);
        for(int i=1; i<=n;i++){
            out.println(res[i]);
        }
    }
    void dfs(int cur, int from, ArrayList<Integer> arr, int[] a){
        // suppose that arr is at least size = 1
        // keep arr strictly increasing
        if(arr.size()==0||a[cur]> arr.get(arr.size()-1)){
            arr.add(a[cur]);
            res[cur] = arr.size();
            for(int to:tree[cur]){
                if(to==from) continue;
                dfs(to,cur,arr,a);
            }
            arr.remove(arr.size()-1);
        } else {
            int idx = binary(arr, a[cur]);
            int backup = arr.get(idx);
            arr.set(idx, a[cur]);
            res[cur] = arr.size();
            for (int to : tree[cur]) {
                if (to == from) continue;
                dfs(to, cur, arr, a);
            }
            arr.set(idx, backup);
        }
    }
    int binary(ArrayList<Integer> list, int val){
        // already know that val <= list[size-1]
        // return the least idx s.t. list[idx]>=val
        int n = list.size();
        if(list.get(0)>=val) return 0;
        int lo = 0, hi = n-1;
        while(hi>lo+1){
            int mid = (hi+lo)/2;
            if(list.get(mid)==val) return mid;
            if(list.get(mid)>val) hi = mid;
            else lo = mid;
        }
        return hi;
    }
}



Measured memory_bytes: 159180
/*! if g++ -g alds_1_7_c.cpp -o alds_1_7_c.out; then ./alds_1_7_c.out < alds_1_7_c.test; fi
 */


#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class node{
public:
  int id, left, right, parent;
  node(): id(-1), left(-1), right(-1), parent(-1){}

};

vector<node> tree(0);

void dfs(int id){
  node& nd = tree[id];
  cout << " " << id;
  if(nd.left >= 0) dfs(nd.left);
  if(nd.right >= 0) dfs(nd.right);  
}

void inorder(int id){
  node& nd = tree[id];
  if(nd.left >= 0) inorder(nd.left);
  cout << " " << id;
  if(nd.right >= 0) inorder(nd.right);
}

void postorder(int id){
  node& nd = tree[id];
  if(nd.left >= 0) postorder(nd.left);
  if(nd.right >= 0) postorder(nd.right);
  cout << " " << id;
}


int main(){
  int n;
  cin >> n;
  tree.resize(n);
  for (int i = 0; i < n; i++) {
    int id, l, r;
    cin >> id >> l >> r;
    node& nd = tree[id];
    nd.id = id;
    nd.left = l;
    nd.right = r;
    if(l >= 0) tree[l].parent = id;
    if(r >= 0) tree[r].parent = id;
  }
  int rt = 0;
  for (int i = 0; i < n; i++) {
    if(tree[i].parent == -1){
      rt = i;
      break;
    }
  }
  cout << "Preorder" << endl;
  dfs(rt); cout << endl;
  cout << "Inorder" << endl;
  inorder(rt); cout << endl;
  cout << "Postorder" << endl;
  postorder(rt); cout << endl;  
  
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    rep(i,0,6){
        if(s[i] == '1') ans++;
    }
    print(ans);
}


Measured memory_bytes: 256
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1


def nck(n, k, mod):
    bunbo = bunshi = 1
    for i in range(k):
        bunshi = (bunshi * (n-i)) % mod
        bunbo = (bunbo * (i+1)) % mod
    return (bunshi * pow(bunbo, mod-2, mod)) % mod


print((ans - nck(n, a, mod) - nck(n, b, mod)) % mod)


Measured memory_bytes: 3060
if __name__ == '__main__':
  x, y = map(int, input().split())
  priceX = priceY = 0
  if(x >= 1 and x <= 205 and y >= 1 and y<= 205):
    if(x == 1):
      priceX = 300000
    elif(x == 2):
      priceX = 200000
    elif(x == 3):
      priceX = 100000
    else:
  	  priceX = 0

    if(y == 1):
      priceY = 300000
    elif(y == 2):
  	  priceY = 200000
    elif(y == 3):
   	  priceY = 100000
    else:
   	  priceY = 0
    
    if(x == 1 and y == 1):
   	  print(400000 + priceX + priceY)
    else:
   	  print(priceX + priceY)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
    int n, m;
    char buf[1000];

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

    if (n % 2 == 1 && m % 2 == 1)
        printf("Odd");
    else
        printf("Even");

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans = gcd(a, ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a <= c && c <= b)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int>a(n),b(n);
    int ai = 0,bi = 0;
    for(int i=0;i<2*n;i++){
        if(s[i]=='a'){
            a[ai] = i;
            ai++;
        }else{
            b[bi] = i;
            bi++;
        }
    }
    bool flag = 0;
    vector<pair<int,int> >v;
    vector<pair<int,char> > qqq;
    vector<int> pa,pb;
    rep(i,n){
        if(a[i]>b[i]){
            flag = 1;
            v.push_back(MP(b[i],i));
            qqq.push_back(MP(a[i],'a'));
            qqq.push_back(MP(b[i],'b'));
            pa.push_back(a[i]);
            pb.push_back(b[i]);
        }
    }
    
    if(!flag){
        string res;
        res += "ab";
        int p = b[0];
        while(1){
            int k = lower_bound(a.begin(),a.end(),p)-a.begin();
            if(k==n){
                break;
            }else{
                res += "ab";
                p = b[k];
            }
        }
        cout << res << endl;
        return 0;
    }
    sort(qqq.begin(),qqq.end());
    string ps;
    rep(i,qqq.size())ps.push_back(qqq[i].second);
    int m = ps.size()/2;
    vector<int> nxt(m,m);
    for(int i=m-1;i>=0;i--){
        auto x = upper_bound(pb.begin(),pb.end(),pa[i]);
        x--;
        int k = x-pb.begin();
        nxt[i] = k;
    }
    for(int i=m-1;i>=0;i--){
        nxt[i] = nxt[nxt[i]];
    }
    vector<pair<string,int> > d(m);
    rep(i,m){
        int aid = 0;
        int bid = 0;
        string c;
        rep(j,2*m){
            if(ps[j]=='a'){
                if(aid>=i&&aid<=nxt[i]){
                    c.push_back('a');
                }
                aid++;
            }else{
                if(bid>=i&&bid<=nxt[i]){
                    c.push_back('b');
                }
                bid++;
            }
        }
        d[i] = MP(c,-i);
    }
    sort(d.rbegin(),d.rend());
    int cc = -1;
    string res;
    rep(i,m){
        if(cc >=-d[i].second)continue;
        else{
            res += d[i].first;
            cc = nxt[-d[i].second];
        }
    }
    int p = pa[m-1]+1;
    while(1){
        int k = lower_bound(a.begin(),a.end(),p)-a.begin();
        if(k==n){
            break;
        }else{
            res += "ab";
            p = b[k];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
#include <math.h>

int main(){
	int n,m;
	if(scanf("%d%d*c", &n, &m)==EOF){return 0;}
	int s,c;
	int num[n];
	for(int i =0; i<n; i++){num[i]=0;}
	
	for(int i =0; i<m; i++){
		if(scanf("%d%d*c", &s, &c)==EOF){return 0;}
		
		//"0"の可能性がある場合は-1として区別
		if(n == 1 && s == 1 && c == 0){c = -1;}
		//それ以外で最上の桁が0となることはない
		if(n != 1 && s == 1 && c == 0){printf("-1\n");return 0;}
		//未入力であれば代入して良い
		else if(num[s-1]==0 || num[s-1]==c){num[s-1]=c;}
		else{	printf("-1\n");return 0;}
	}
	
	//result
	
	//if(n==1 && num[0]== -1){printf("0\n"); return 0;}	
	//else{printf("%d\n", num[0]); return 0;}

	if(n ==1){
		if(num[0]== -1){num[0]= 0;}	//一桁の場合
		printf("%d\n", num[0]); 
		return 0;
	}
	
	int ans = 0;
	if(num[0]== 0){num[0]= 1;} //最上の桁が未入力の場合
	
	for(int i =0; i<n; i++){
		ans += pow(10, n-1-i)*num[i];
	}
	printf("%d\n",ans);	
	return 0;

}

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

int n, y;
bool f = false;

int main(){
	scanf("%d %d", &n, &y);
	for(int i=y/10000; i>=0; --i){
		if(f) break;
		for(int j=(y-i*10000)/5000; j>=0; --j){
			if(y==10000*i+5000*j+1000*(n-i-j)){
				printf("%d %d %d\n", i, j, n-i-j);
				f = true;
				break;
			}
		}
	}
	if(!f) printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
n = int(input())
sn = str(n)
k = len(sn)
c = int(sn[0])
if sn == str(c) + "9" * (len(sn) - 1):
    print(c + 9 * (k - 1))
else:
    print(c + 9 * (k - 1) - 1)


Measured memory_bytes: 9160
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;;i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0 ) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        
        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
vector<string> v;
int vis[100005];
int main() {
    string s;
    cin >> s;
    s = " " + s;
    int n = s.size() - 1;
    int beg = 1;
    for (int i = 1;i <= n;i++) {
        if (s[i-1] == 'L' && s[i] == 'R') {
            v.push_back(s.substr(beg,i-1-beg+1));
            beg = i;
        }
    }
    if (n>=beg+1)
        v.push_back(s.substr(beg,n-beg+1));
    beg = 1;
    for (string str : v) {
        int R = 0,div;
        for (int i = 0;i < str.size();i++)
            if (str[i] == 'R') R++;
            else {
                div = i+beg;
                break;
            }
        vis[div] = str.size() - str.size() / 2;
        vis[div-1] = str.size() / 2;
        if (R % 2) swap(vis[div],vis[div-1]);
        beg += str.size();
    }
    for (int i = 1;i <= n;i++)
        printf("%d%c",vis[i],i == n ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, x, y = 0, z = 0, h, w, ans = 0, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;
  bool ok=true;
  cin >> s;
  x = s.size();
  while(x > 0){
    if(s.substr(x-5,5)=="dream" || s.substr(x-5,5)=="erase"){
      x -= 5;
    }
    else if(s.substr(x-6,6)=="eraser"){
      x -= 6;
    }
    else if(s.substr(x-7,7)=="dreamer"){
      x -= 7;
    }
    else{
      ok=false;
      break;
    }
  }
  if(ok)
    pri("YES");
  else
    pri("NO");
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}
int main(void){
    int N;
    int *A,*B;
    scanf("%d", &N);
    A = (int *)calloc(N, sizeof(int));
    B = (int *)calloc(N, sizeof(int));
    for(int i=0; i<N; i++)
        scanf("%d", &A[i]);
    for(int i=0; i<N; i++)
        B[i]=A[i];
    quick_sort(A,0,N);
    for(int i=0; i<N; i++){
        int max = A[N];
        if(B[i]==max){
            max = A[N-1];
        }
        printf("%d\n", max);
    }
    return 0;
}

Measured memory_bytes: 3072
from collections import deque
S = input()
q = deque()
for s in list(S):
    q.append(s)
Q = int(input())
direction = True
for _ in range(Q):
    line = input()
    if line[0] == '1':
        direction = not direction
    else:
        if (direction and line[2] == '1') or (not direction and line[2] == '2'):
            q.appendleft(line[4])
        else:
            q.append(line[4])
print("".join(q) if direction else "".join(reversed(q)))


Measured memory_bytes: 14440
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main() {
  int N, L;
  cin >> N >> L;
  int m = 1<<29;
  int ans = -1;
  int org = 0;
  for (int j = 0; j < N; j++) {
    org += L + j;
  }
  for (int i = 0; i < N; i++) {
    int s = 0;
    for (int j = 0; j < N; j++) {
      if (i != j) {
        s += L + j;
      }
    }
    int x = abs(org - s);
    if (x < m) {
      ans = s;
      m = x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n,k;
	string s;
	cin>>n>>s>>k;
	for(ll i=0;i<n;i++)
	if(s[i]!=s[k-1])
	s[i]='*';
	cout<<s;
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N],dpos[2*N-1] , dneg[2*N-1];
bool X[N][N];
 
void initialize() {
  int i;
  for(i = 0;i<N;i++) {row[i] = FREE, col[i] = FREE;}
  for(i=0;i<2*N-1;i++) {dpos[i] = FREE; dneg[i] = FREE;}
}

void printBoard() {
  int i,j;
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      if(X[i][j]) {
        if(row[i] != j) return;
      }
    }
  }
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      printf("%s", (row[i] == j) ? "Q":"." );
    }
    printf("\n");
  }
}

void recursive(int i) {
  if(i == N) {
    printBoard();
    return;
  }
  
  int j;
for(j=0;j<N;j++) {
  if(NOT_FREE == col[j] ||
     NOT_FREE == dpos[i+j] ||
     NOT_FREE  == dneg[i-j+N-1]) continue;
  
  row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
  
  recursive(i+1);
     row[i] = col[j]=dpos[i+j] = dneg[i-j+N-1] = FREE;
     
 }
}

int main() {
  initialize();
  int i,j;
  for(i = 0;i<N;i++) {
    for(j=0;j<N;j++) {
      X[i][j] = false;
    }
  }
  int k; scanf("%d\n", &k);
  for(i = 0;i<N;i++) {
    int r,c; scanf("%d%d\n", &r,&c );
    X[r][c] = true;
  }
  
  recursive(0);
  
  return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<vector>
#include<algorithm>
#define N (int)1e6
using namespace std;

int main(){
  int n,tmp,dp[N+1],dp_odd[N+1];
  vector<int> plc;

  for(int i=0;i<=N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(int i=1;;i++){
    plc.push_back(tmp);
    tmp *= i+3; tmp /= i;
    if(tmp>N)break;
  }

  for(int i=(int)plc.size()-1;i>=0;i--){
    for(int j=0;j+plc[i]<=N;j++){
      if(dp[j]>N)continue;
      tmp = j+plc[i];
      dp[tmp] = min(dp[tmp],dp[j]+1);
    }
    if(plc[i]&1){
      for(int j=0;j+plc[i]<=N;j++){
	if(dp_odd[j]>N)continue;
	tmp = j+plc[i];
	dp_odd[tmp] = min(dp_odd[tmp],dp_odd[j]+1);
      }
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
}

Measured memory_bytes: 8500
import java.util.Scanner;
public class Main{
	
	public void solve(){
        Scanner sc = new Scanner(System.in);
		
		int k;
		int dou=0;
		int izyo=1;
		int n = sc.nextInt();
		
	    while(n!=0){
			for(int i=0;i<n;i++){
				k = sc.nextInt();
				
				if(k>=2){
					izyo++;
				}
				if(k==1){
					dou++;
				}
			}
			if(izyo>=2){
				System.out.println(dou+izyo);
			}else{
				System.out.println("NA");
			}
			
			izyo = 1;
			dou = 0;
			n = sc.nextInt();
	    }
	}
			
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 158380
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         10000000000000000000LL
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265


void solve()
{
    string s; cin>>s;
    string k="keyence";
    if(s.find(k)!=string::npos)
    {
        if(s.find(k)==0)
        {
            cout<<"YES"; exit(0);
        }
        if(sz(s)==s.find(k)+7) { cout<<"YES"; }
        else { cout<<"NO"; exit(0); }
    }
    rep(i,1,7)
    {
        string s1=k.substr(0,i);
        string s2=k.substr(i,7-i);
        ll p1=s.find(s1);
        if(p1==0)
        {
            if(s.rfind(s2)+7-i==sz(s)) { cout<<"YES"; exit(0); }
        }
    }
    cout<<"NO";
}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
N=int(input())
card_list=list(map(int,input().split()))
#各自が自分の数字を最大化するように選択するのが前提なのでAliceが確実に勝つ。
#Aliceは１番目、３番目、５番目、７番目・・・に取っていく
#Bobは２番目、４番目、６番目、８番目・・・に取っていく
#sort関数には、「reverse」という引数が存在します。reverseをTrueに指定することで「降順」を示すことになります。

card_list.sort(reverse=True)
#print(card_list)

card_list_Alice=card_list[::2]
#print(card_list_Alice)
Alice_score=sum(card_list_Alice)
#print(Alice_score)
Bob_score=sum(card_list)-Alice_score
#print(Bob_score)
#Alice_score=card_list[1]+card_list[3]+
#Bob_score=card_list[2]+card_list[4]+

print(Alice_score-Bob_score)


Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
const ll mod = 1e9 + 7;
int n, m;
int l[N], r[N];
multiset<int>mst;
typedef pair<int, int>pii;
set<pii>st;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)scanf("%d%d", &l[i], &r[i]);
	for (int i = 1; i <= m; i++)st.insert({ i,i }), mst.insert(0);
	for (int i = 1; i <= n; i++) {
		auto it = st.lower_bound({ l[i],0 });
		int tmp = 0;
		while (it != st.end() && (*it).first <= r[i]) {
			tmp = max(tmp, (*it).second);
			mst.erase(mst.find((*it).first - (*it).second));
			it = st.erase(it);
		}
		if (tmp) {
			st.insert({ (r[i] + 1 <= m ? r[i] + 1 : INF),tmp });
			mst.insert((r[i] + 1 <= m ? r[i] + 1 : INF) - tmp);
		}
		int ans = *mst.begin();
		printf("%d\n", ans < m ? ans + i : -1);
	}
	return 0;
}

Measured memory_bytes: 24004
N = int(input())
INFO = [list(map(int,input().split())) for i in range(N)]

flag = False
flag2 = True
firsst = True
for x in range(0,101):
    for y in range(0,101):
        flag = False
        flag2 = True
        first = True
        for i in range(0,N):
            if INFO[i][2] == 0:
                flag = True
                continue
            if first:
                first = False
                elseH = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            H = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            if H != elseH:
                flag2 = False
                break
        if flag:
            for i in range(0,N):
               if max(elseH - abs(x-INFO[i][0]) - abs(y-INFO[i][1]),0) != INFO[i][2]:
                   flag2 = False
        if flag2:
            break
    if flag2:
        break
print(x,y,H)

Measured memory_bytes: 3064
sx, sy, tx, ty = gets.split.map(&:to_i)

a = []

xd = tx - sx
yd = ty - sy

xd.times { a.push "R" }
yd.times { a.push "U" }
xd.times { a.push "L" }
yd.times { a.push "D" }
a.push "L"
(yd + 1).times { a.push "U" }
(xd + 1).times { a.push "R" }
a.push "D"
a.push "R"
(yd + 1).times { a.push "D" }
(xd + 1).times { a.push "L" }
a.push "U"

puts a.join


Measured memory_bytes: 2428
#include <stdio.h>

int main()
{
  int input_number;
  int ans = 0;

  scanf("%d", &input_number);

  while(-1){
    if(input_number < ans*ans){
      break;
    }
    ans++;
  }
  ans--;
  printf("%d\n", ans*ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    int k; cin >> k;
    string ans = "";

    rep(i, k) {
        ans += "ACL";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	
	VI A(N);
	
	REP(i,N)cin>>A[i];
	
	VI dp(N+1);
	dp[0]=0;
	
	FOR(i,1,N){
		dp[i]=INF;
		
		for(int k=1;k<=K && i-k>=0;k++){
			dp[i]=min(dp[i-k]+abs(A[i]-A[i-k]),dp[i]);
		}
	}
	cout<<dp[N-1]<<endl;
	
	return 0;
}




















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

using namespace std;
using ll = long long;

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

int main() {
  int p, q, r;
  cin >> p >> q >> r;
  int ans = p + q + r;
  ans -= max(p, max(q, r));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

int A[3050], B[3050], dp[3050][3050], N, T;


int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> T;
  for(int i = 0;i < N;i++) {
    cin >> A[i] >> B[i];
  }

for(int i = 0 ;i < N;i++) {
  for(int j = 0;j < N-i-1;j++) {
    if(A[j] >= A[j+1]) {
      swap(A[j], A[j+1]);
      swap(B[j+1], B[j]);
    }
  }
}


  for(int j = 0;j < T;j++) {
    dp[N-1][j] = B[N-1];
  }

  for(int i = N-2;i >= 0;i--) {
    for(int j = T-1;j >= 0;j--) {
        dp[i][j] = dp[i+1][j];
        if((j+A[i]) < T) {
          dp[i][j] = max(dp[i][j], dp[i+1][j+A[i]] + B[i]);
        } else {
          dp[i][j] = max(dp[i][j], B[i]);
        }
    }
  }

  cout << dp[0][0] << endl;

  return 0;
}


Measured memory_bytes: 35968
import java.util.*;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[][][] building = new int[4][3][10];
		
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<3;j++)
			{
				Arrays.fill(building[i][j],0);
			}
		}
		
		for(int i=0;i<n;i++)
		{
			int b = stdIn.nextInt();
			int f = stdIn.nextInt();
			int r = stdIn.nextInt();
			int v = stdIn.nextInt();
			
			building[b-1][f-1][r-1] += v;
		}
		
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<3;j++)
			{
				for(int k=0;k<10;k++)
				{
					System.out.print(" "+building[i][j][k]);
				}
				System.out.println();
			}
			if(i!=3)
			{
				System.out.println("####################");
			}
		}
		
	}
}

Measured memory_bytes: 20676