akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean flag = false;
	    S = S.replaceAll("eraser","");              
	    S = S.replaceAll("erase","");
	    S = S.replaceAll("dreamer","");
	    S = S.replaceAll("dream","");
	    if(S.isEmpty()) flag = true;
		if(flag) System.out.println("YES");
		else System.out.println("NO");
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 30124
#include <iostream>
#include <string>
using namespace std;

int N;
string S,T;

bool equal(int n, char animal){
	if(animal=='S' && S[n]=='o' || animal=='W' && S[n]=='x') return true;
	else return false;
}

char is_it(int n){
	if(equal(n,T[n])) return T[n-1];
	else{
		if(T[n-1] == 'S') return 'W';
		else return 'S';
	}
}

int main(){
	cin >> N;
	cin >> S;
	T = S;
	T[0] = 'S';
	bool judge = false;
	if(S[0]=='o'){
		for(int i=1;i<=2;i++){
			if(i==1){
				T[1] = 'S';
				T[N-1] = 'S';
			}else{
				T[1] = 'W';
				T[N-1] = 'W';
			}
			for(int j=2;j<=N-2;j++){
				T[j] = is_it(j-1);
			}
			if(T[N-1]==is_it(N-2) && T[0]==is_it(N-1)){
				judge = true;
				break;
			}
		}
	}else{
		for(int i=1;i<=2;i++){
			if(i==1){
				T[1] = 'S';
				T[N-1] = 'W';
			}else{
				T[1] = 'W';
				T[N-1] = 'S';
			}
			for(int j=2;j<=N-2;j++){
				T[j] = is_it(j-1);
			}
			if(T[N-1]==is_it(N-2) && T[0]==is_it(N-1)){
				judge = true;
				break;
			}
		}
	}
	if(!judge){
		T[0] = 'W';
		if(S[0]=='x'){
			for(int i=1;i<=2;i++){
				if(i==1){
					T[1] = 'S';
					T[N-1] = 'S';
				}else{
					T[1] = 'W';
					T[N-1] = 'W';
				}
				for(int j=2;j<=N-2;j++){
					T[j] = is_it(j-1);
				}
				if(T[N-1]==is_it(N-2) && T[0]==is_it(N-1)){
					judge = true;
					break;
				}
			}
		}else{
			for(int i=1;i<=2;i++){
				if(i==1){
					T[1] = 'S';
					T[N-1] = 'W';
				}else{
					T[1] = 'W';
					T[N-1] = 'S';
				}
				for(int j=2;j<=N-2;j++){
					T[j] = is_it(j-1);
				}
				if(T[N-1]==is_it(N-2) && T[0]==is_it(N-1)){
					judge = true;
					break;
				}
			}
		}
	}
	if(judge) cout << T << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    string S,T;
    cin >> S >> T;
    string SS = S + S;
    ll N = S.size();
    ll M = T.size();
    vector<vector<ll>> v(26);
    rep(i,SS.size()){
        v[SS[i]-'a'].push_back(i+1);
    }
    ll ans = 0;
    ll cur = 0;
    rep(i,M){
        ll c = T[i] - 'a';
        auto itr = upper_bound(v[c].begin(), v[c].end(), cur);
        if(itr == v[c].end()){
            cout << -1 << endl;
            return 0;
        }
        ll pos = *itr;
        ans += pos - cur;
        cur += pos - cur;
        if(cur > N){
            cur -= N;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5868
type burger =
  | Level0
  | LevelL of int * int * burger

let patties = function
  | Level0 -> 1
  | LevelL (p, _, _) -> p

let stratos = function
  | Level0 -> 1
  | LevelL (_, s, _) -> s

let rec mkburger = function
  | 0 -> Level0
  | l ->
      let b = mkburger (l - 1) in
      LevelL (2 * patties b + 1, 2 * stratos b + 3, b)

let rec solve x = function
  | Level0 -> min 1 x
  | LevelL (_, _, b) ->
      if x <= 1 then 0
      else if x - 1 <= stratos b then solve (x - 1) b
      else if x - 1 - stratos b <= 1 then patties b + 1
      else patties b + 1 + solve (x - stratos b - 2) b

let () = Scanf.scanf "%d %d" @@ fun n x ->
  Printf.printf "%d\n" @@ solve x @@ mkburger n


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll a[N],prfx[N],dp[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];
    prfx[1]=a[1];
    for(ll i=3;i<=n;i+=2)prfx[i]=prfx[i-2]+a[i];
    for(ll i=2;i<=n;i++){
        if(i&1)dp[i]=max(dp[i-1],dp[i-2]+a[i]);
        else dp[i]=max(prfx[i-1],a[i]+dp[i-2]);
    }
    cout<<dp[n];
}


Measured memory_bytes: 8292
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    char a[10];
    int count=0,max=0;
    scanf("%s",a);
    fr(i,0,3) {
        if(a[i] == 'R') {
            count++;
        } else {
            count = 0;
        }
        if (count > max) {
            max = count;
        }
    }
    printf("%i",max);
    return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <cctype>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int i;
	for (i=min(a,b);i>=0 && k;i--)
		if (a%i==0 && b%i==0) k--;
	cout<<i+1;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (ll &x : A) cin >> x;
    sort(A.rbegin(), A.rend());
    ll sum = accumulate(A.begin(), A.end(), 0ll);
    int res = 1;
    for (int i = 1; i < N; i++) {
      sum -= A[i - 1];
      if (A[i - 1] <= 2 * sum) {
        ++res;
      } else {
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    string s;
    vector<vector<int>> v(H, vector<int>(W, 0)), y(H, vector<int>(W, 0)), x(H, vector<int>(W, 0));
    for ( int i = 0; i < H; i++ ) {
        cin >> s;
        int l = 0;
        for ( int j = 0; j < W; j++ ) {
            if ( s[j] == '#' ) {
                v[i][j] = 1;
                for ( int k = l; k < j; k++ ) {
                    x[i][k] = j-l;
                }
                l = j+1;
            }
        }
        for ( int k = l; k < W; k++ ) {
            x[i][k] = W-l;
        }
    }

    for ( int j = 0; j < W; j++ ) {
        int l = 0;
        for ( int i = 0; i < H; i++ ) {
            if ( v[i][j] == 1 ) {
                for ( int k = l; k < i; k++ ) {
                    y[k][j] = i-l;
                }
                l = i+1;
            }
        }
        for ( int k = l; k < H; k++ ) {
            y[k][j] = H-l;
        }
    }

    int ans = 0;
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            int b = x[i][j] + y[i][j] - 1;
            if ( ans < b ) ans = b;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int n, m;
vector<P3> es;

int kruskal(){
    sort(es.begin(), es.end());
    UnionFindTree g;
    g.init(n);
    vector<int> ls;
    for(auto e : es){
        int u = e.second.first, v = e.second.second;
        if(!g.is_same(u, v)){
            g.unite(u,v);
            ls.push_back(e.first);
        }
    }
    sort(ls.begin(), ls.end());
    return ls[n/2-1];
}

int main() {
    while(cin >> n >> m, n){
        es.clear();
        for(int i=0;i<m;i++){
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            es.push_back({c,{a,b}});
        }
        cout << kruskal() << endl;
    }
    return 0;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
bool dp[111][11111];
int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    dp[0][0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10000; j++) {
            if (dp[i][j]) {
                dp[i+1][j] = dp[i][j];
                if (j + s[j] <= 10000) dp[i + 1][j + s[i]] = dp[i][j];
            }
        }
    }
    for (int i = 10000; i >= 0; i--) {
        if (i % 10 == 0) continue;
        if (dp[n][i]) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int64_t solve(int n, int k, vector<int64_t> h) {
    // sort values in { h_i | i } + { 0 }
    h.push_back(0);
    vector<int> order(n + 1);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return h[i] < h[j]; });
    order.erase(unique(ALL(order), [&](int i, int j) { return h[i] == h[j]; }), order.end());
    vector<int> lookup(n);
    REP (i, n) {
        lookup[i] = find_if(ALL(order), [&](int j) { return h[j] == h[i]; }) - order.begin();
    }

    // dp
    auto cur = make_table<int64_t>(k + 1, order.size(), INT64_MAX);
    cur[0][lookup[0]] = h[0];
    if (1 <= k) {
        REP (j, order.size()) {
            cur[1][j] = h[order[j]];
        }
    }
    REP (i, n - 1) {
        auto nxt = make_table<int64_t>(k + 1, order.size(), INT64_MAX);
        REP (cnt, k + 1) {
            int64_t acc = INT64_MAX;
            REP (j, order.size()) {
                if (acc != INT64_MAX and j - 1 >= 0) {
                    acc += h[order[j]] - h[order[j - 1]];
                }
                chmin(acc, cur[cnt][j]);
                int ncnt = cnt + (h[order[j]] != h[i + 1]);
                if (ncnt <= k) {
                    chmin(nxt[ncnt][j], acc);
                }
            }
            acc = INT64_MAX;
            REP_R (j, order.size()) {
                chmin(acc, cur[cnt][j]);
                int ncnt = cnt + (h[order[j]] != h[i + 1]);
                if (ncnt <= k) {
                    chmin(nxt[ncnt][j], acc);
                }
            }
        }
        cur = nxt;
    }

    // summarize
    int64_t answer = INT64_MAX;
    REP (cnt, k + 1) {
        REP (j, order.size()) {
            chmin(answer, cur[cnt][j]);
        }
    }
    return answer;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int64_t> h(n);
    REP (i, n) {
        cin >> h[i];
    }
    cout << solve(n, k, h) << endl;
    return 0;
}


Measured memory_bytes: 1744
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <1200:
        print("ABC")
    elif a[0] < 2800:
        print("ARC")
    else:
        print("AGC")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    ll q = sqrt(n), b = sqrt(n-1);
    int counter = 0;
    for(ll i = 1; i<=b; i++){
        if((n-1)%i == 0){
            if((n-1)/i == i) counter++;
            else counter += 2;
        }
    }
    for(ll i = 2; i<=q; i++){
        if(n%i == 0){
            if(n/i == i) counter++;
            else{
                ll a = n/i;
                while(a%i == 0) a/=i;
                if(a%i == 1) counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
list1 = list(map(int,input().split()))
list2 = set()
list1.sort()
list1.reverse()
a,b = 0,0
for i in list1:
	if i in list2:
		if i > a:
			a = i
			list2.remove(i)
		else:
			b = i
			break
	else:
		list2.add(i)
print('{0}'.format(a*b))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int> > v;
    vector<string> k;
    for(int i = 0; i < n; i++){
        string s;
        int score;
        cin >> s >> score;
        v.push_back(make_pair(make_pair(s,-score),i+1));
    }
    sort(v.begin(),v.end());
    for(int i = 0; i < n; i++){
        cout << v[i].second << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <array>

using namespace std;

const int maxn=1e5+5, Log=20;


int n;
vector < int > ms[maxn];
int dep[maxn];
int parent[maxn][Log];
bitset < maxn > bio;
int x, y;

void root(int x, int d){
	dep[x]=d;
	bio[x]=1;
	for(int i=0; i<ms[x].size(); i++){
		if(!bio[ms[x][i]]){
			parent[ms[x][i]][0]=x;
			root(ms[x][i], d+1);
		}
	}
}

void build(){
	parent[y][0]=y;
	for(int i=1; i<Log; i++){
		for(int j=0; j<n; j++){
			parent[j][i]=parent[parent[j][i-1]][i-1];
		}
	}
}

int digni(int a, int b){
	int raz=dep[b]-dep[a];
	for(int i=Log-1; i>-1; i--){
		if(raz&(1<<i)){
			b=parent[b][i];
		}
	}
	return b;
}

int siri(int y){
	int poc=y;
	while(true){
//		cout << "to infinity" << endl;
//		cout << y << endl;
		for(int i=0; i<ms[y].size(); i++){
			if(dep[ms[y][i]]>dep[y] && digni(ms[y][i], x)==ms[y][i]){
				y=ms[y][i];
				break;
			}
		}
		if(dep[y]-dep[poc]>dep[x]-dep[y]){
			return y;
		}
	}
}

pair < int, int > naj(int x){
	pair < int, int > p;
	pair < int, int > sol=make_pair(dep[x], x);
	for(int i=0; i<ms[x].size(); i++){
		if(dep[ms[x][i]]>dep[x]){
			p=naj(ms[x][i]);
			if(p.first>sol.first){
				sol=p;
			}
		}
	}
	return sol;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	cin >> x >> y;
	x--;
	y--;
	int a, b;
	for(int i=0; i<n-1; i++){
		cin >> a >> b;
		a--;
		b--;
		ms[a].push_back(b);
		ms[b].push_back(a);
	}
	root(y, 0);
	build();
	int z;
/*	for(int i=0; i<n; i++){
		cout << "next " << i << " " << parent[i][0] << endl;
	}*/
	z=siri(y);
	int k=naj(z).second;
	if(k==z){
		if(ms[k][0]==y){
			cout << 0 << '\n';
		}
		else{
			cout << 1 << '\n';
		}
	}
	else{
		if(dep[z]==dep[x]-dep[z]+1 || dep[z]==dep[x]-dep[z]){
			cout << dep[k]-dep[z]+dep[x]-dep[z] << '\n';
		}
		else{
			cout << dep[k]-dep[z]+dep[x]-dep[z]+1 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 19072
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;


#define MAX_N 10000
int prime[MAX_N];
bool is_prime[MAX_N+1];
int sieve(int n){
	int p=0;
	memset(is_prime,true,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(MAX_N);
	vector<int> p;
	for(int i=2;i<=MAX_N-2;i++)
		if(is_prime[i]&&is_prime[i+2])p.push_back(i+2);
	int n;
	while(cin>>n&&n){
		int a=upper_bound(p.begin(),p.end(),n)-p.begin();
		cout<<p[a-1]-2<<' '<<p[a-1]<<endl;
	}
	return 0;
}

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


int main() {

    int n;
    cin>>n;

    vector<int> p(n);
    for(int i=0;i<n;i++){
      cin>>p.at(i);
    }

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

    int64_t sum=0;
    for(int i=0;i<n;i++){
      if(i<n-1)
        sum+=p.at(i);
      else
        sum+=p.at(i)/2;
      
    }

    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    int t=q-k+1;
    vector<int> a(n,0);
    rep(i,q){
        int f;
        cin >> f;
        a.at(f-1)++;
    }
    rep(i,n){
        if (a.at(i)>=t) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
(* charのlistをstringに *)
let string_of_chars chars = 
  let buf = Buffer.create 16 in
  List.iter (Buffer.add_char buf) chars;
  Buffer.contents buf

let n = read_int ()
let s = read_line () |> explode
let z = int_of_char 'Z'

let rec get_added chr i =
  if int_of_char chr + i > int_of_char 'Z' then get_added 'A' (i - (z - int_of_char chr)-1)
  else char_of_int (int_of_char chr + i)

let rec loop lst =
  match lst with
  | [] -> []
  | first :: rest -> get_added first n :: loop rest

let _ = print_endline @@ string_of_chars @@ loop s


Measured memory_bytes: 1920
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    q = deque([(A[0], 1)])

    ans = 0
    for i in range(1, N):
        a = A[i]

        b, c = q.popleft()
        ans += b

        if c == 0:
            q.appendleft((b, 1))

        q.append((a, 0))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32512
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)

using namespace std;

const int N0 = 100010;
const int N = 410;

int x[N0], y[N0];
bool g[N][N], v[N];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	Rep(i, m) scanf("%d%d", &x[i], &y[i]);
	Rep(i, n) {
		g[i][i] = true;
		for (int j = m; j; j --) {
			if (!g[i][x[j]] && !g[i][y[j]]) continue;
			if (g[i][x[j]] && g[i][y[j]]) v[i] = true;
			else g[i][x[j]] = g[i][y[j]] = true;
		}
	}
	
	int ans = 0;
	
	Rep(i, n) if (!v[i]) 
		Rep(j, i - 1) if (!v[j]) {
			bool flag = false;
			Rep(k, n) if (g[i][k] && g[j][k]){ flag = true; break;}
			if (!flag) ans ++;
		}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
#include<vector>
#define fr first
#define sc second
#define mp(a,b) make_pair(a,b)
using namespace std;typedef pair<int,int> pa;
const int N=57,inf=1e9;
int n,i,j,a[N],pos=-1,mx=-inf,mxid=-1;vector<pa>d;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n,i=1;i<=n;++i){
		cin>>a[i];
		if(abs(a[i])>mx)mx=abs(a[i]),mxid=i;
	}
	d.push_back(mp(mxid,n));d.push_back(mp(mxid,n));a[n]+=a[mxid];a[n]+=a[mxid];
	if(a[n]>0){
		for(i=1;i<n;++i)d.push_back(mp(n,i)),d.push_back(mp(n,n));
	}else if(a[n]<=0){
		for(i=n-1;i;--i)d.push_back(mp(i+1,i)),d.push_back(mp(i+1,i));
	}
	cout<<d.size()<<endl;
	for(auto&x:d)cout<<x.fr<<" "<<x.sc<<endl;
	return 0;
}

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


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    val N = sc.nextInt()
    val list = mutableListOf<Int>();
    list.add(0)
    for (i in 1..N) {
        val Ai = sc.nextInt()
        list.add(Ai)
    }
    list.add(0)
    var now = 0
    val diff = mutableListOf<Int>()
    for (i in 1..(N + 1)) {
        val a = list[i]
        diff.add(Math.abs(now - a))
        now = a
    }
    var sum = diff.sum()

    for (i in 1..N) {
        val a = list[i - 1]
        val b = list[i]
        val c = list[i + 1]

        val d = Math.abs(a - b) + Math.abs(b - c) - Math.abs(a - c)
        println(sum - d)
    }


    //println(brues)
    //println(sum)

}



Measured memory_bytes: 71096
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=4e5+5;
int a[N],b[N];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	while(k--){
		int flag=1;
		for(int i=1;i<=n;i++){
			if(a[i]!=n)
			flag=0;
		}
		if(flag){
			break;
		}
		for(int i=1;i<=n;i++){
			b[max(i-a[i],1)]++;
			b[i+a[i]+1]--;
		}
		for(int i=1;i<=n;i++){
			a[i]=b[i];
			a[i]+=a[i-1];
			b[i]=0;
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d ",a[i]);
	}
}


Measured memory_bytes: 6064
import sys

import re

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver(a):
    m = re.findall("[a-z]", a)
    if len(m)==0:
        print('A')
    else:
        print('a')

def main():
    a = L()
    #print(a)

    solver(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9868
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
 
int K;
char S[20];
int ans=0;
signed main(){
    scanf("%s",S);
    rep(i,strlen(S)){
        if(S[i]=='o'){
            ans++;
        }
    }
    if(15-strlen(S)+ans>7)printf("YES\n");
    else printf("NO\n");
}

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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> sorted(N);
    int p = 0;
    int q = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
        sorted[i] = i + 1;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> Q[i];
    }
    long long count = 0;
    bool flagp = false;
    bool flagq = false;
    do
    {
        count++;
        if (P == sorted)
        {
            p = count;
        }
        if(Q == sorted)
        {
            q = count;
        }
    if(p != 0 && q != 0){
        break;
    }
    } while (next_permutation(sorted.begin(), sorted.end()));

    cout << abs(p - q) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    int c[1111];
    memset(c,0,sizeof(c));
    vector<P> v(n);
    int M=1<<29,y,x;
    for(int i=0; i<n; i++) {
      int j;
      for(j=0;j*a[i]<=m;j++) {
        if(j*a[i]>M||j*a[i]==M&&a[i]>=y) break;
      }
      x=j*a[i];
      if(x>m) x-=a[i];
      if(x<M) {
        M=x;
        y=a[i];
      } else if(x==M&&a[i]<y) y=a[i];
      v[i]=P(x,a[i]);
    }
    M=1<<29;
    for(int i=0; i<n; i++) {
      if(v[i].first<M) {
        M=v[i].first;
        y=v[i].second;
        x=i+1;
      } else if(v[i].first==M&&v[i].second<y) {
        y=v[i].second;
        x=i+1;
      } else if(v[i].first==M&&v[i].second==y) x=n;
    }
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 1208
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    S = input()
    for c in S:
        write(chr((ord(c)-ord('A')+N)%26+ord('A')))
    write('\n')





if __name__ == '__main__':
    main()

Measured memory_bytes: 40560
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int ans=0;
    cin >> a >> b >> c >> d;
    if(a>b) ans +=b;
    else ans += a;
    if(c>d) ans +=d;
    else ans += c;
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef unsigned long long ull;
#define mp make_pair
#define pb push_back
#define inf 1e9
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

// struct

// data
int r;

void solve() { printf("%d\n", r * r); }

int main() {
  int k, kase = 0;
  // scanf("%d", &k);
  k = 1;
  while (k--) {
    scanf("%d", &r);
    solve();
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int s = sc.nextInt();
			if ((a | b | s) == 0) {
				break;
			}
			int max = 0;
			for (int xk = 1; xk <= 1000; xk++) {
				for (int yk = 1; yk <= 1000; yk++) {
					int xValue = xk * (100 + a) / 100;
					int yValue = yk * (100 + a) / 100;
					if (xValue + yValue == s) {
						int xNValue = xk * (100 + b) / 100;
						int yNValue = yk * (100 + b) / 100;
						max = Math.max(max, xNValue + yNValue);
					}
				}
			}

			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20500
import heapq
n = int(input())
a = list(map(int, input().split()))
dic = {}; ans = []
for i in range(n+1)[1:]:
    dic.setdefault(a[i-1],[]).append(i)
heapq.heapify(a)
for i in range(n):
    res = heapq.heappop(a)
    ans.append(dic[res][0])
print(*ans)

Measured memory_bytes: 29832
n = int(input())
s = input()
passwords = []

firsts = []
firsts_seconds = [[]*10 for _ in range(10)]
firsts_seconds_thirds = [[]*10 for _ in range(100)]

for i in range(n-2):
    if len(firsts) == 10:
        break
    first =  s[i]
    if first in firsts:
        continue
    firsts.append(first)
    for j in range(i+1,n-1):
        if len(firsts_seconds[int(first)]) == 10:
            break
        second = s[j]
        first_second = first + second
        if first_second in firsts_seconds[int(first)]:
            continue
        firsts_seconds[int(first)].append(first_second)
        for k in range(j+1, n):
            password = first_second + s[k]
            if password not in firsts_seconds_thirds[int(first_second)]:
                firsts_seconds_thirds[int(first_second)].append(password)
                passwords.append(password)

print(len(passwords))



Measured memory_bytes: 43548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

struct Node *root,*NIL;

struct Node* find(struct Node *u,int k){
  while(u != NIL && k != u -> key){
    if(k < u -> key) u = u -> left;
    else u = u -> right;
  }
  return u;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node*)malloc(sizeof(struct Node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    } else{
      x = x -> right;
    }
  }
  z -> parent = y;
  if(y == NIL){
    root= z;
  } else{
    if(z -> key < y -> key){
      y -> left = z;
    } else{
      y -> right = z;
    }
  }
}

void inorder(struct Node *u){
  if(u == NIL) return ;
  inorder(u -> left);
  printf(" %d",u -> key);
  inorder(u -> right);
}

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

int main(){
  int n,i,x;
  char str[7];
  struct Node *t;
  
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s",str);
    if(strcmp(str,"find") == 0){
      scanf("%d",&x);
      t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(str,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(str,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
 

typedef pair < int, int > P;
vector < P > v[5];
int sx, sy, gx, gy;
int memo[5][5][1111];

int dist(P a, P b){
  return abs(a.F - b.F) + abs(a.S - b.S);
}

int solve(int cnt, int now, int idx){
  
  if(cnt == 4) return dist(v[now][idx], P(gx, gy));
  if(~memo[cnt][now][idx]) return memo[cnt][now][idx];
  
  int ans = INF, next = (now+1)%5, cost;
  for(int i=0;i<v[next].size();i++){
    cost = cnt?dist(v[now][idx], v[next][i]):dist(P(sx, sy), v[next][i]);
    ans = min(ans, solve(cnt+1, next, i) + cost);
  }
 
  return memo[cnt][now][idx] = ans;
}
 
int main(){
 
  int w, h;
  char c;
 
  while(cin >> w >> h, w){
 
    for(int i=0;i<5;i++) v[i].clear();
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c;
	if(c == '.') continue;
	else if(c == 'S') sx = j, sy = i;
	else if(c == 'G') gx = j, gy = i;
	else  v[c-'1'].push_back( P(j,i) );
      }
    }
    
    int a, b = INF;
    memset(memo, -1, sizeof(memo));
    for(int i=0;i<5;i++) if(b > solve(0,i,0)) a = i+1, b = solve(0,i,0);
    
    if(b == INF) cout << "NA\n";
    else cout << a << " " << b << endl;
    
  }
}

Measured memory_bytes: 1360
#include <iostream>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;
 
int N;
int a[100010];
ll dp[10010][2][110];
 
int main(){
    string K;
    int D;
    cin >> K >> D;
    int N = K.size();
    dp[0][1][0] = 1;
    for(int i=0;i<N;++i){
        for(int tight=0; tight<2; ++tight){
            int x = (tight ? K[i]-'0' : 9);
            for(int j=0; j<=x; ++j){
                for(int d=0; d<=D; ++d){
                    dp[i+1][tight && x==j][(d+j)%D] += dp[i][tight][d]%MOD;
                }
            }
        }
    }
    cout << (dp[N][0][0] + dp[N][1][0] - 1)%MOD << endl;
    return 0;
}

Measured memory_bytes: 17408
import java.util.Scanner;

class Main {
	
	static int bin_search(int[] a,int key,int n){
		int left=0; int right=n-1;
		
		while(left<=right){
			int mid=(left+right)/2;
			
			if(a[mid] == key)
				return 1;
			if(a[mid] > key)
				right=mid-1;
			if(a[mid] < key)
				left=mid+1;
			
		}
		
		return 0;
		
	}
	
	
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int n=scan.nextInt();
		int[] a=new int[n];
		int cnt=0;
		for(int i=0;i<n;i++)
			a[i]=scan.nextInt();
			
		int q=scan.nextInt();
		for(int i=0;i<q;i++)
			cnt+=bin_search(a,scan.nextInt(),n);
			
		System.out.println(cnt);
	}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

//-----------------------------------------
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    if(i%3 == 0){
      cout << " " << i; 
    }
    else{
      int j = i;
      while(j){
        if(j % 10 == 3){
          cout << " " << i;
          break;
        }
        else j /= 10;
      }
    }
  }
cout <<endl;

  return 0;
}






Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
using namespace std;
int main(){
    int n, r;
    cin >> n >> r;
    if(n<10){
        cout << r + 100*(10-n) << endl;
    }else{
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 888
import sys
input = sys.stdin.readline
from math import sqrt

N,D=(int(x) for x in input().rstrip('\n').split())
res = 0
for i in range(N):
  x,y = (int(x) for x in input().rstrip('\n').split())
  if sqrt(x**2+y**2)<=D:
    res += 1
print(res)

Measured memory_bytes: 68752
import java.util.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1235();
	}
	
	class AOJ1235{
		int N,C;
		int[][] t;
		final int INF=1<<29;
		final int[] vx={-1,-1,0,1,1,0}, vy={0,-1,-1,0,1,1};
		AOJ1235(){
			while(true){
				N=sc.nextInt();
				C=sc.nextInt();
				if(N==0)	break;
				t=new int[N][N];
				for(int x=0; x<N; ++x)for(int y=0; y<N; ++y)	t[x][y]=-1;
				for(int y=0; y<N; ++y)for(int x=0; x<=y; ++x)	t[x][y]=sc.nextInt();
				// debug
//				for(int y=0; y<N; ++y){
//					for(int x=0; x<=y; ++x)	System.out.print(t[x][y]+" ");
//					System.out.println();
//				}
				solve();
			}
		}
		void solve(){
			int ans=-INF;
			boolean[][] vtd=new boolean[N][N];
			for(int y=0; y<N; ++y)for(int x=0; x<=y; ++x)if(t[x][y]==0){
				for(int i=0; i<N; ++i)for(int j=0; j<N; ++j)	vtd[i][j]=false;
				t[x][y]=C;
				int cand = 0;
				boolean m1=true;
				for(int v=0; v<6; ++v){
					int sx=x+vx[v], sy=y+vy[v];
					if(!(0<=sx&&sx<N && 0<=sy&&sy<N))	continue;
					if(t[sx][sy]==C || t[sx][sy]==0)	m1=false;
					if(t[sx][sy]<=0 || vtd[sx][sy])	continue;
					vtd[sx][sy]=true;
					zero=false;
					int ret = dfs(sx, sy, vtd);
					cand += (zero? 0 : (t[sx][sy]==C? -ret : ret));
				}
				// debug
//				System.out.println("cand"+cand);
				ans = max(ans, cand+(m1? -1:0));
				t[x][y]=0;
			}
			System.out.println(ans);
		}
		boolean zero;
		int dfs(int x,int y,boolean[][] vtd){
			int ret=1;
			for(int v=0; v<6; ++v){
				int xx=x+vx[v], yy=y+vy[v];
				if(!(0<=xx&&xx<N && 0<=yy&&yy<N))	continue;
				if(vtd[xx][yy])	continue;
				if(t[xx][yy]<0)	continue;
				if(t[xx][yy]==0){
					zero=true;
					continue;
				}
				if(t[xx][yy]!=t[x][y])	continue;
				vtd[xx][yy]=true;
				ret += dfs(xx,yy,vtd);
			}
			return ret;
		}
	}
}

Measured memory_bytes: 20492
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::BTreeMap;

fn main(){
    input!{
        n: u64,
        s:[String;n]
    }
    let mut map = BTreeMap::new();
    let mut flug :bool = false;
    for i in s.iter(){
        let count = map.entry(i).or_insert(0);
        *count += 1;
    }
    let mut max:u64 = 0;
    for (k, v) in &map {
        if max < *v {max = *v;}
    }
    for (k, v) in &map {
        if max == *v {
            println!("{}", k);
        }
    }
}


Measured memory_bytes: 22396
S = input()
N = len(S)
INF = N+1
nex = [[INF]*26 for _ in range(N+1)]
for i,c in enumerate(S[::-1]):
    ic = ord(c) - ord('a')
    for j in range(26):
        nex[N-i-1][j] = N-i-1 if j==ic else nex[N-i][j]

dp = [N] * (N+3)
dp[INF] = dp[INF+1] = 0
for i in range(N,-1,-1):
    tmp = INF
    for j in range(26):
        tmp = min(tmp, dp[nex[i][j]+1]+1)
        if tmp == 1: break
    dp[i] = tmp

ans = []
i = 0
for v in range(dp[0]-1,-1,-1):
    for j in range(26):
        if dp[nex[i][j]+1] != v: continue
        ans.append(chr(j + ord('a')))
        i = nex[i][j]+1
        break

print(''.join(ans))

Measured memory_bytes: 106784
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,k,q,x,f[N];
int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=0;i<q;i++)
	{
		scanf("%d",&x);
		f[x]++;
	}

	for(int i=1;i<=n;i++)
	{
		if(k-(q-f[i])>0) printf("Yes");
		else printf("No");
		printf("\n");
	}
}

Measured memory_bytes: 1024
const main = input => 
    ((m, a, b, c, d) => m.find(x => x[0](a, b, c, d))[1](a, b, c, d))(
        [
            [
                // 1. a <= b <= c <= d
                (a, b, c, d) => b <= c,
                (a, b, c, d) => 0,
            ],
            [
                // 2. a <= c <= b <= d
                (a, b, c, d) => a <= c && c <= b && b <= d,
                (a, b, c, d) => b - c,
            ],
            [
                // 3. a <= c <= d <= b
                (a, b, c, d) => a <= c && d <= b,
                (a, b, c, d) => d - c,
            ],
            [
                // 4. c <= a <= d <= b
                (a, b, c, d) => c <= a && a <= d && d <= b,
                (a, b, c, d) => d - a,
            ],
            [
                // 5. c <= a <= b <= d
                (a, b, c, d) => c <= a && b <= d,
                (a, b, c, d) => b - a,
            ],
            [
                // 6. c <= d <= a <= b
                (a, b, c, d) => d <= a,
                (a, b, c, d) => 0,
            ],
        ],
        ...input.trim().split(' ').map(x => +x)
    );

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll i,n;
    cin >> n;
    ll a[n+1];
    for(i=1;i<=n;i++){
        cin >> a[i];
    }
    ll dp[n+1];
    dp[1] = 0;
    dp[2] = abs(a[2]-a[1]);
    for(i=3;i<=n;i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n] << endl;

}

//    cout << fixed << setprecision(12);


Measured memory_bytes: 5116
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    string a,b,c,d;
    a = "maerd", b = "remaerd", c = "esare", d = "resare";
    int len = s.length();
    string t;
    for(int i = len-1; i >= 0; i--){
        t += s[i];
        if(t == a || t == b || t == c ||t == d) t = "";
    }
    if(t.length() == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m, x;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll mul = 1;
  x = n;
  while(x<=m){
    // cout << x << endl;
    ++ans;
    x = n * (mul *= 2);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N,M;
  cin>>N>>M; 
  int n=N;
  int m=M;
  int mod=1000000007;
  if(abs(N-M)>1){
    cout<<0<<endl;
  }
  else{
    
    long a=1;
    while(N--){
      a=a*(N+1)%mod;
    }
    long b=1;
    while(M--){
      b=b*(M+1)%mod;
    }
    if(n!=m){
      cout<<a*b%mod<<endl;
    }
    else{
      cout<<2*a*b%mod<<endl;
    }
  }
}





Measured memory_bytes: 256
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let _: usize = read().trim().parse().unwrap();
    let mut v: Vec<f64> = read()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());
    let ans = v.iter().fold(v[0], |x, &y| (x + y) / 2.0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum += v[i];
    }
    if(sum % 10 == 0){
        sort(v.begin(), v.end());
        for(int i = 0; i < n; i++){
            if(v[i] % 10 != 0){
                sum -= v[i];
                break;
            }
        }
    }
    if(sum % 10 == 0) sum = 0;
    cout << sum << endl;

}

Measured memory_bytes: 256