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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;

int n, a;

ll ans;
map<ll, ll> m;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> a;
	ll zc = 0;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		x -= a;
		if (x == 0) ++zc;
		else if (x > 0) {
			// WHY DO YOU HAVE TO DO THAT FIRST ONE
			for (auto it = m.rbegin(); it != m.rend();) {
				auto nxt = next(it, 1);
				m[x + it->first] += it->second;
				it = nxt;
			}
			++m[x];
		} else {
			for (auto it = m.begin(); it != m.end();) {
				auto nxt = next(it, 1);
				m[it->first + x] += it->second;
				it = nxt;
			}
			++m[x];
		}
	}
	ans = m[0];
	ans *= powl(2, zc);
	ans += powl(2, zc) - 1ll;
	cout << ans;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,c,d,ans1=0,ans2=0;
  cin >> a >> b >> c;
  rep(i,b){
    cin >> d;
    if(d>c) ans1++;
    else ans2++;
  }
  cout << min(ans1,ans2);
} 


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;
const int mod=1000000007;


int main() {
  int k;
  cin >>k;
  string s;
  rep(i,0,k){
    s+="ACL";
  }
  cout << s << endl;
  return 0;

}


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

typedef pair<int, int> P;

int main() {
	int t, s, x;
	int teams[128] = {0}, rnk[32] = {0};
	bool point[32] = {0};
	while(scanf("%d,%d", &t, &s) && (t || s)){
		point[s] = true;
		teams[t] = s;
	}
	int c = 1;
	for(int i = 30; i >= 0; --i){
		if(point[i]){
			rnk[i] = c;
			c++;
		}
	}
	while(cin >> x){
		cout << rnk[teams[x]] << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
N = gets.to_i
s = gets.chomp

l = 0

stack = []
s.chars{|c|
  if c==')' then
    if stack.size>0 && stack[-1]=='(' then
      stack.pop #ぽっぷしないとだめです
    else
      l+=1
    end
  else
    stack << '('
  end
}
r = stack.size
puts '('*l + s + ')'*r

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    int l = s.length();
    bool flg1 = 0;
    if(s[0]=='A')
        flg1 = 1;

    int cntC = 0;
    for(int i=2;i<l-1;++i)
        if(s[i]=='C')
            cntC++;
    bool flg2 = 0;
    if(cntC==1)
        flg2 = 1;

    int cnt = 0;
    for(int i=0;i<s.length();++i)
        if(isupper(s[i]))
            cnt++;
    bool flg3 = 0;
    if(cnt==2)
        flg3 = 1;

    if(flg1 && flg2 && flg3 )
        cout<<"AC";
    else
        cout<<"WA";
    return 0;
}   

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N;
  string s;
  cin >> N >> s;

  int res = 0;
  rep(i, 1000) {
    string ns = to_string(i);
    if (i == 0)
      ns = "000";
    else if (i < 10)
      ns = "00" + ns;
    else if (i < 100)
      ns = "0" + ns;
    int idx = 0;
    rep(j, N) {
      if (s[j] == ns[idx]) idx++;
    }
    if (idx == 3) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
// #define NMAX 1000000000
int N,M;
string S, T;
vi H;
vvi AB;

ll solve(){

	// cout<<N<<" "<<M<<"\n";
	// puts("---");
	// rp(i,0,N){
	// 	cout<<H[i]<<" ";
	// }
	// puts("");
	// puts("---");
	// rp(i,0,M){
	// 	cout<<AB[i][0]<<" "<<AB[i][1]<<"\n";
	// }
	// puts("---");

	vi ok(N+1, 1); // init ok=1, ng=0

	rp(i,0,M){
		int a = AB[i][0];
		int b = AB[i][1];

		// cout<<" a "<<a;
		// cout<<" b "<<b;
		// cout<<" Ha "<<H[a-1];
		// cout<<" Hb "<<H[b-1];
		// cout<<"\n";

		if(H[a-1] <= H[b-1]){
			// puts("ng a");
			ok[a] = 0;
		}
		if(H[a-1] >= H[b-1]){
			// puts("ng b");
			ok[b] = 0;
		}
		// else{
		// 	ok[a] = 0;
		// 	ok[b] = 0;
		// }
	}

	// rp(i,0,N+1){
	// 	cout<<ok[i]<<" ";
	// }
	// puts("");
	// puts("---");

	ll ans = 0;
	rp(i,1,N+1){
		if(ok[i]){
			ans++;
		}
	}
	return ans;
}

int main(){
	cin>>N>>M;

	H.resize(N);
	rp(i,0,N){
		cin>>H[i];
	}

	AB.resize(M,vi(2));
	rp(i,0,M){
		cin>>AB[i][0]>>AB[i][1];
	}

	cout<< solve() <<endl;
	// printf("%f\n",solve());
	// cout<<cout<<setprecision(10)<<ans<<endl;
	// solve();
}


Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

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

Measured memory_bytes: 3872
k,n=input().split();
a=input().split();
k=int(k);
n=int(n);
by=0;
for i in range(n):
	a[i]=int(a[i]);
for i in range(n-1):
	if a[i+1]-a[i]>by:
		by=a[i+1]-a[i];
if (k-a[n-1])+a[0]>by :
	by=(k-a[n-1])+a[0];
print(k-by);


Measured memory_bytes: 18636
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#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 <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

struct edge {
	int to;
	ll cost;
	edge(int to, ll cost) : to(to), cost(cost) {

	}
};
vector<edge> es[1010];
map<int,bool> used[1010];
ll dis[1010][1010];
ll d[1010];
bool lo[1010];
bool use[1010];
int n, m;
void dija() {

	priority_queue<pll> q;
	q.push(pll(0, 1));

	while (!q.empty())
	{
		pll p = q.top();
		q.pop();
		int v = p.second;
		if (p.first < d[v]) continue;
		for (auto it : es[v]) {

			if (d[it.to] < d[v] + it.cost) {
				d[it.to] = d[v] + it.cost;
				if (used[v][it.to]) {
					lo[it.to] = true;
				}
				else {
					used[it.to] = used[v];
					used[it.to][it.to] = true;
					q.push(pll(d[it.to], it.to));
				}
			}
		}
	}
}

void solv() {
	
	cin >> n >> m;

	for (size_t i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		es[a].push_back(edge(b, c));
	}

	fill(d, d + n + 1, -(INF * 1010));
	d[1] = 0;

	used[1][1] = true;
	dija();
	for (auto it : used[n])
	{
		if (it.second && lo[it.first]) {
			cout << "inf" << endl;
			return;
		}
	}

	cout << d[n] << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 25856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> scores(N);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        scores[a-1] += 1;
    }
    for (int i = 0; i < N; i++) {
        cout << (K - (Q - scores[i]) > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}



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

int main()
{
	int N;
	long long  H=1LL;

	cin >> N ;
		
	for (int i = 1; i <= N; i++) {	
		H = ( i * H ) % (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7);
	}
	
	cout << H  << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char s[11],t[11],u[11];
    int a,b;
    scanf("%s %s %d %d %s",s,t,&a,&b,u);
    if(strcmp(s,u)==0) printf("%d %d",a-1,b);
    else printf("%d %d",a,b-1);
}

Measured memory_bytes: 128
def shorten(s):
    f = 1
    while f:
        l = len(s) // 2
        while f:
            f = 0
            if l % 2 == 0:
                for i in range(l):
                    if s[2 * i:2 * i + 2] != "00" and i % 2:break
                else:
                    f = 1
                    t = ""
                    for i in range(0, l, 2):t += s[2 * i:2 * i + 2]
                    s = t
                    l = len(s) // 2
        for k in range(3, l + 1, 2):
            f = 1
            while f:
                f = 0
                if l % k == 0:
                    for i in range(l):
                        if s[2 * i:2 * i + 2] != "00" and i % k:break
                    else:
                        f = 1
                        t = ""
                        for i in range(0, l, k):t += s[2 * i:2 * i + 2]
                        s = t
                        l = len(s) // 2
    return s

def lcm(a, b):
    p, q = max(a, b), min(a, b)
    while 1:
        if p % q:p, q = q, p % q
        else: return a * b // q

for _ in range(int(input())):
    n = int(input())
    r = [shorten(input()) for _ in range(n)]
    ls = [len(i) // 2 for i in r]
    l = ls[0]
    for i in range(1, n):l = lcm(l, ls[i])
    if l > 1024:print("Too complex.");continue
    a = [0] * l
    for i in range(n):
        d = l // ls[i]
        for j in range(ls[i]):a[d * j] += int(r[i][2 * j: 2 * j + 2], 16)
    s = ""
    for i in a:s += format(i,"02X")
    print(s)


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

int main() {
	int A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
	int swater,sugar;
	swater=0;
	sugar=0;
	float p=0;
	for(int a=0;100*a<=F;a+=A){
		for(int b=0;100*a+100*b<=F;b+=B){
			for(int c=0;100*a+100*b+c<=F;c+=C){
				for(int d=0;100*a+100*b+c+d<=F;d+=D){
					if((a+b)*E>=(c+d)){
						float x=100*a+100*b;
						float y=c+d;
						if(p<=y/(x+y)){
							p=y/(x+y);
							swater=100*a+100*b+c+d;
							sugar=c+d;
						}
					}

				}
			}
		}
	}
	cout<<swater<<' '<<sugar<<endl;
	return 0;
}


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

int main(){

  int N;
  double sum = 0;

  cin >> N;



  for(int i = 1;i <= N;i++){

    double x;

    cin >> x;

    string u;

    cin >> u;

    if(u == "JPY")  sum += x;
    else sum += x*380000.0;

  }

  cout << sum << "\n";

}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    Map<Integer, Integer> fA[] = new Map[N];
    Map<Integer, Integer> lcm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    sc.close();

    for (int i = 0; i < N; i++) {
      fA[i] = f(A[i]);
    }

    for (int i = 0; i < N; i++)
      for (Map.Entry<Integer, Integer> a : fA[i].entrySet())
        lcm.put(a.getKey(), Math.max(lcm.getOrDefault(a.getKey(), 0), a.getValue()));

    long mod = 1000000007;
    long ans = 0;

    long modLcm = 1;
    for (Map.Entry<Integer, Integer> lcm_p : lcm.entrySet()) {
      modLcm = modLcm * modPow(lcm_p.getKey(), lcm_p.getValue(), mod) % mod;
    }

    for (int ai : A) {
      long bi = modDiv(modLcm, ai, mod);
      ans += bi;
      ans %= mod;
    }

    System.out.println(ans);
  }

  private static long modDiv(long a, long b, long mod) {
    return (a % mod) * modInv(b, mod) % mod;
  }

  private static long modInv(long x, long mod) {
    return modPow(x, mod - 2, mod);
  }

  private static long modPow(long b, long e, long mod) {
    long ans = 1;
    long x = b % mod;
    for (long y = e; y != 0; y >>= 1) {
      if ((y & 1) == 1) ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }

  private static Map<Integer, Integer> f(int n) {
    Map<Integer, Integer> f = new HashMap<>();
    int m = n;
    int s = SIEVE[m - 1];
    while (s != 0) {
      f.put(s, f.getOrDefault(s, 0) + 1);
      m /= s;
      s = SIEVE[m - 1];
    }
    return f;
  }

  private static int[] SIEVE = sieve(1000000);

  private static int[] sieve(int n) {
    int [] sieve = new int[n];
    for (int i = 2; i <= n; i += 2) sieve[i - 1] = 2;
    int sqrt = (int) Math.sqrt(n);
    for (int i = 3; i <= n; i += 2) {
      if (sieve[i - 1] == 0) sieve[i - 1] = i;
      if (i <= sqrt)
        for (int j = i * i; j <= n; j += i)
          if (sieve[j - 1] == 0) sieve[j - 1] = i;
    }
    return sieve;
  }
}

Measured memory_bytes: 50256
import heapq
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(a)
bc = sorted(bc, reverse=True, key=lambda x: x[1])
for i in range(M):
    count = 0
    while True:
        t = heapq.heappop(a)
        if t >= bc[i][1] or bc[i][0] <= count:
            heapq.heappush(a,t)
            break
        else:
            count += 1
            heapq.heappush(a,bc[i][1])
print(sum(a))

Measured memory_bytes: 33784
import java.util.Scanner;

public class Main {
	private double x = 0, y = 0, angle = 0;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			int i = str.indexOf(",");
			int step = Integer.parseInt(str.substring(0, i));
			int angle = Integer.parseInt(str.substring(i+1, str.length()));
			
			if ((step | angle) == 0) break;
			
			this.x += step * Math.sin(this.angle * Math.PI / 180);
			this.y += step * Math.cos(this.angle * Math.PI / 180);
			
			this.angle += angle;
		}
		System.out.println((int)this.x);
		System.out.println((int)this.y);
	}
	
	private void debug() {
		System.out.println();
	}

}

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

int main() {
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0; i<=s.size()/2; i++) {
    string t=s.substr(0,i),r=s.substr(i,s.size()-i);
    if(r[0]!='0') {
      int a,b;
      stringstream ss,st;
      if(t=="") a=0;
      else {
	ss << t;
	ss >> a;
      }
      st << r;
      st >> b;
      if((a%2==0 && b%2==0) || (a%2==1 && b%2==1)) {
	if(t.size()==r.size()) {
	  if(a<=b) cnt++;
	} else cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " <<setprecision(15)<< (x) << ", " << #y << " = " <<setprecision(15)<< (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " <<setprecision(15)<< (x) << ", " << #y << " = " <<setprecision(15)<< (y) << ", " << #z << " = " <<setprecision(15)<< (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " <<setprecision(15)<< (x) << ", " << #y << " = " <<setprecision(15)<< (y) << ", " << #z << " = " <<setprecision(15)<< (z) << ", " << #a << " = " <<setprecision(15)<< (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/10/2018
 
 17:15-17:25 analysis
 17:45 1WA
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=50+1;
int N,A,B;
LL V[MAX_N];
LL C[MAX_N][MAX_N];
long double eps=1e-6;
void solve() {
//  sort(V,V+N);
//  REP(i,N) dump2(i,V[i]);
  
  ZERO(C);
  REP(i,MAX_N) {
    C[i][0]=1;
    FORE(j,1,i)C[i][j]=C[i-1][j]+C[i-1][j-1];
  }
  
  long double res1=-1;
  LL res2=0;
  FORE(n,A,B) {
    vector<pair<long double,int>> A(N); REP(i,N) A[i]={(long double)V[i]/n,i};
    sort(A.rbegin(),A.rend());
    LL sum=0;
    REP(i,n) sum+=V[A[i].second];
    long double a=(long double)sum/n;
//    dump2(n,a);
    if(a-res1>eps) { /*dump3(res1,a,a-res1);*/ res1=a,res2=0; }
    if(abs(res1-a)<eps) {
      int l=n-1;
      while(l>=0&&V[A[l].second]==V[A[n-1].second]) --l;
      int k=n-1-l;
      int r=n-1;
      while(r<N&&V[A[r].second]==V[A[n-1].second]) ++r;
      int nn=k+r-n;
//      dump4(res1,nn,k,C[nn][k]);
      res2+=C[nn][k];
    }
  }
  cout<<setprecision(15)<<res1<<endl;
  cout<<res2<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>A>>B;
  REP(i,N) cin>>V[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using ll = long long;
using namespace std;

string s;
int main()
{
    IOS
    cin >>s;
    for (int i = 0; i < (int) s.size(); ++i) {
        if (s[i]=='R' && (i&1)) {
            cout << "No" << endl;
            return 0;
        }
        if (s[i] == 'L' && !(i&1)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N; scanf("%lld",&N);

    if(!N){
        cout << 0 << endl;
        return 0;
    }

    set<int> ans;
    for(int i=0;i<64;i++){
        auto n = abs(N);
        if(n & (1ll<<i)){
            ans.insert(i);
            if(i&1) N+=(1ll<<i);
            else N-=(1ll<<i);
        }
    }

    int mx = *ans.rbegin();
    for(int i=mx;i>=0;i--){
        if(ans.count(i)) cout << 1;
        else cout << 0;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
string s,t;
vector<int> v[130];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
		v[s[i]].push_back(i);
	int cur=-1;
	int rounds=0;
	for(int i=0;i<t.size();i++){
		if(v[t[i]].empty()){
			cout<<-1<<endl;
			return 0;
		}
		if(v[t[i]].back()<=cur){
			rounds++;
			cur=v[t[i]][0];
		}
		else{
			cur=v[t[i]][upper_bound(v[t[i]].begin(),v[t[i]].end(),cur)-v[t[i]].begin()];
		}
	}
	cout<<(long long)(rounds)*(long long)(s.size())+(long long)(cur)+1LL<<endl;
	return 0;
}


Measured memory_bytes: 1228
a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


c=[]
for i in path_list :
    if H_list[i[0]-1]>H_list[i[1]-1] :
        c.append(i[1])
    elif H_list[i[0]-1]<H_list[i[1]-1]  :
        c.append(i[0])
    else :
        c.append(i[0])
        c.append(i[1])
k=list(set(c))
print(N-len(k))

Measured memory_bytes: 105888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    string S;
    cin >> S;
    for (char& c: S) {
        if (c == '?') c = 'D';
    }
    cout << S << "\n";   
}


Measured memory_bytes: 3780
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;

const int N = 100000;
bool brokens[N];
const int MOD = 1e9 + 7;

void add_self(int & x, int y) {
    x += y;
    if(x >= MOD) x -= MOD;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    memset(brokens, 0, sizeof brokens);
    for(int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        brokens[a] = 1;
    }
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 1; i < n + 1; ++i) {
        if(!brokens[i]) {
            add_self(dp[i], dp[i - 1]);
            if(i - 2 >= 0) {
                add_self(dp[i], dp[i - 2]);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1001;
int V, d;

ll f[N + 1];

int main(void) {
    f[0] = 1L; f[1] = 2L;
    for(int i = 2; i <= N; i++) {
        f[i] = (ll) ((f[i - 2] % N) + (f[i - 1] % N)) % N;
    }
    while(~scanf("%d %d", &V, &d)) {
        vector<ll> tmp;
        for(int i = 1; i <= V; i++) {
            tmp.push_back((ll)f[i]);
        }
        int ans = 1; sort(tmp.begin(), tmp.end());
        for(int i = 1; i < (int) tmp.size(); i++) {
            if(tmp[i] - tmp[i - 1] >= d) ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, k;
  string s;
  Solver(LL n, LL k) : n(n), k(k){};

  void solve() {
    cin >> s;
    string t = s;
    sort(t.begin(), t.end());
    if (k >= 16) {
      string ans = "";
      for (int i = 0; i < n; ++i) {
        ans += t[0];
      }
      cout << ans << endl;
    } else {
      int l = 1;
      for (int i = 0; i < k; ++i) {
        l *= 2;
      }
      vector<int> cnt(n);
      for (int i = 0; i < n; ++i) {
        if (s[i] != t[0]) continue;
        for (int j = i; j < n; ++j) {
          if (s[j] == t[0])
            cnt[i]++;
          else
            break;
        }
      }
      vector<int> cnt2(cnt);
      DBG(cnt, cnt2)
      for (int i = 0; i < n; ++i) {
        if (i + cnt[i] == n) {
          cnt[i] *= l;
        } else {
          cnt[i] *= l / 2;
        }
      }
      DBG(cnt, cnt2)
      int ml = *max_element(cnt.begin(), cnt.end());
      vector<string> anss;

      for (int i = 0; i < n; ++i) {
        if (cnt[i] == ml) {
          string tmp = "";
          for (int j = 0; j < min(n, cnt[i]); ++j) {
            tmp += t[0];
          }
          int pos, dir;
          if (cnt2[i] + i == n) {
            pos = i - 1;
            dir = -1;
          } else {
            pos = cnt2[i] + i;
            dir = 1;
          }
          while (tmp.length() < n) {
            tmp += s[pos];
            pos += dir;
            if (pos == n) {
              dir = -1;
              pos = n - 1;
            }
            if (pos == -1) {
              dir = 1;
              pos = 0;
            }
          }
          anss.push_back(tmp);
        }
      }
      sort(anss.begin(), anss.end());
      cout << anss[0] << endl;
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, k;
  std::cin >> n >> k;

  Problem::Solver sol(n, k);
  sol.solve();
  return 0;
}


Measured memory_bytes: 11904
object Main {
  def main(args: Array[String]): Unit = {
    var cuisine_list = Vector.empty[Int]
    cuisine_list = cuisine_list :+ io.StdIn.readInt()
    cuisine_list = cuisine_list :+ io.StdIn.readInt()
    cuisine_list = cuisine_list :+ io.StdIn.readInt()
    cuisine_list = cuisine_list :+ io.StdIn.readInt()
    cuisine_list = cuisine_list :+ io.StdIn.readInt()
    var sum_time      = 0
    var min_last_time = 100

    (0 until cuisine_list.length).foreach { i =>
      val last_time = cuisine_list(i)%10
      if(last_time < min_last_time && last_time != 0) min_last_time = last_time
      sum_time += (cuisine_list(i)/10.0 + 0.9).toInt*10
    }
    if(min_last_time == 100) min_last_time = 10
    println(sum_time - 10 + min_last_time)

  }
}

Measured memory_bytes: 27448
#include <iostream>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int w,d;
	while(cin >> w >> d,w){
		int ans = 0;
		vector<int> a(21,0);
		REP(i,w){
			int tmp;
			cin >> tmp;
			a[tmp]++;
		}
		REP(i,21){ans += i*a[i];}
		REP(i,d){
			int tmp;
			cin >> tmp;
			if(a[tmp] > 0){
				a[tmp]--;
			}else{
				ans += tmp;
			}
		}
		cout << ans << endl;
	}
  return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n,k; cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ans = 0;
  COMinit();
  rep(i,n) {
    ans -= a[i]*(COM(n-i-1,k-1));
    ans %= MOD;
  }
  reverse(all(a));
  rep(i,n) {
    ans += a[i]*(COM(n-i-1,k-1));
    ans %= MOD;
  }

  while(ans < 0) ans += MOD;
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = 0;
    ans = d[N/2] - d[N/2-1];
    cout << ans << endl;
    return 0;
};

Measured memory_bytes: 640
/*input
4 100000
100000 100000 100000 100000
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int const mod = 1e9 + 7 ; 
int n,K;
int a[300];
int dp[101][100001];
signed main() {
	IOS;
	cin>>n>>K;
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		int pre[K+10];
		memset(pre,0,sizeof(pre));
		for(int j=0;j<=K;j++){
			int temp = dp[i][j];
			int start = j;
			int end = a[i]+j;
			if(end>K){
				end = K;
			}
			pre[start]+=temp;
			pre[start]%=mod;
			pre[end+1]-=temp;
			pre[end+1]+=mod;
			pre[end+1]%=mod;
		}
		dp[i+1][0]=pre[0];
		for(int j=1;j<=K;j++){
			pre[j]+=pre[j-1];
			pre[j]%=mod;
			dp[i+1][j]=pre[j];
		}
	}
	cout << dp[n][K] <<endl;
return 0;
}


Measured memory_bytes: 79232
import collections
import time

def main():
    h, n = map(int, input().split())

    INF = 10 ** 20

    dp = collections.defaultdict(lambda : INF)
    dp[0] = 0

    magic = []

    for i in range(n):
        magic.append(list(map(int, input().split())))


    t = time.time()

    que = [0]
    cc = [0]
    m = 0
    c = 0
    while que:
        next_que = set()
        for now_dam in que:
            for a, b in magic:
                dam = now_dam + a
                if dp[dam] > dp[now_dam] + b:
                    dp[dam] = dp[now_dam] + b
                    if h > dam:
                        next_que.add(dam)
        que = list(next_que)
    ans = INF
    # print(time.time() - t)

    for k, v in dp.items():
        if k >= h:
            ans = min([v, ans])

    print(ans)

    # print(time.time() - t)

main()

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N;
    cin>>N;
    long long int A[N];
    for (int i=0;i<N;i++) cin>>A[i];
    sort(A,A+N);
    long long int ans=1;
    long long int limit=1e18;
    bool flag=true;
    for (int i=0;i<N;i++){
        if(A[i]==0){
            ans=0;
            break;
        }
        else if(A[i]>limit/ans){
            flag=false;
            break;
        }    
        else ans*=A[i];
    }
    if(flag) cout<<ans<<"\n";
    else cout<<"-1\n";
 	return 0;
}

Measured memory_bytes: 4424
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      
      	int H = sc.nextInt(), W = sc.nextInt();
      	int h = sc.nextInt(), w = sc.nextInt();
      
      	int result = (H*W) - (h*W) - (H-h)*w;
      	System.out.println(result);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
//#include<inttypes.h>//__int64,__int128..
#define MAX_N 100005
//vector&pair
#define pb push_back
#define mp make_pair
//math
#define sq(x) ((x)*(x))
#define abs(x) ((x)>0?(x):(-(x)))//Regardless of type
//for pair
#define fi first
#define se second
//infinit
#define LL_inf (1LL<<60)
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
//MOD
#define MOD 1000000007LL*/
using namespace std;
//type
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pil;
typedef long double LD;
int main(){
	//write on your code!
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%c\n",(a+b==15)?'+':((a*b==15)?'*':'x'));
	return 0;
}

Measured memory_bytes: 256
N=int(input())
W=list(map(int,input().split()))
n=0
l=[]
while True:
    W1=W[0:n]
    W2=W[n:N]
    souwa1,souwa2,n1,n2=0,0,0,0
    while True:
        if n1==len(W1):
            break
        souwa1+=W1[n1]
        n1+=1
    while True:
        if n2==len(W2):
            break
        souwa2+=W2[n2]
        n2+=1
    l.append(abs(souwa1-souwa2))
    n+=1
    if n==N:
        break
print(min(l))

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

int gcd(int a,int b){
  while(a%b!=0){
    int tmp=a%b;
    a=b;
    b=tmp;
  }
  return b;
}

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

int main(){
  int N,X;
  cin>>N>>X;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    a.at(i)=abs(X-x);
  }
  int ans=a.at(0);
  for(int i=1;i<N;i++){
    ans=gcd(ans,a.at(i));
  }
  cout<<ans<<endl;

}


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

const int nil = -1;
int n;    

class Node{
  public:
    int parent;
    int left;
    int right;

    Node(){
      parent = left = right = nil;
    }
};

void preOrder(int key, Node *tree){
  if(key == nil) return;
  cout << " " << key; 
  preOrder(tree[key].left, tree);
  preOrder(tree[key].right, tree);
}

void inOrder(int key, Node *tree){
  if(key == nil) return;
  inOrder(tree[key].left, tree);
  cout << " " << key; 
  inOrder(tree[key].right, tree);
}

void postOrder(int key, Node *tree){
  if(key == nil) return;
  postOrder(tree[key].left, tree);
  postOrder(tree[key].right, tree);
  cout << " " << key; 
}


int main(){
  cin >> n;
  Node tree[n];
  for(auto i = 0; i < n; i++){
    int id, left, right;
    cin >> id >> left >> right;
    tree[id].left = left;
    tree[id].right = right;
    if(left != nil) tree[left].parent = id;
    if(right != nil) tree[right].parent = id;
  }

  int root;
  for(auto i = 0; i < n; i++) if(tree[i].parent == nil) root = i;

  cout << "Preorder" << '\n';
  preOrder(root, tree);
  cout << '\n';
  cout << "Inorder" << '\n';
  inOrder(root, tree);
  cout << '\n';
  cout << "Postorder" << '\n';
  postOrder(root, tree);
  cout << '\n';

  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int h, n, tmp, ma=0;
  scanf("%d %d", &h, &n);
  rep(i, n) {
    scanf("%d", &tmp);
    ma += tmp;
  }
  if (ma >= h) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int n, k;
pair<int, int> p[50];

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d %d", &p[i].first, &p[i].second);
    sort(p, p + n);
    long ans = 4e18;
    for (int i = 0; i <= n - k; i++) {
        vector<int> y;
        for (int j = i; j < i + k - 1; j++) y.push_back(p[j].second);
        for (int j = i + k - 1; j < n; j++) {
            y.push_back(p[j].second);
            sort(y.begin(), y.end());
            int my = 2e9;
            for (int l = 0; l <= j - i + 1 - k; l++) {
                my = min(my, y[l + k - 1] - y[l]);
            }
            ans = min(ans, static_cast<long>(p[j].first - p[i].first) * my);
        }
    }

    printf("%ld\n", ans);
    return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;

int main ()
{
    int num , cnt = 0 ;
    cin >> num ;
    vector <int> nums1 ;
    vector <int> nums2 ;
    vector <int> res (81) ;

    for (int i = 1 ; i < 10 ; i ++)
    {
        nums1 . push_back (i) ;
        nums2 . push_back (i) ;
    }
    for (int i = 0 , k = 0 ; i < 9 ; i ++)
    {
        for (int j = 0 ; j < 9 ; j ++)
        {
            res[k] = nums1 [i] * nums2 [j] ;
            k ++ ;
        }
    }
    for (int i = 0 ; i < 81 ; i ++)
    {
        if (num == res[i])
        {
            cnt ++ ;
            printf("Yes") ;
            break ;
        }
    }
    if (cnt <= 0)
        printf("No") ;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 2e5 + 5;

int n, h[maxn], a[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    h[0] = 0; a[0] = 0;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    map<int, int> dp;
    for(int i = n; i >= 0; i--)
    {
        auto it = dp.upper_bound(h[i]);
        int sum = a[i];
        if(it != dp.end())
            sum += it -> second;
        dp[h[i]] = sum;
        it = dp.find(h[i]);
        while(it != dp.begin() && prev(it) -> second <= sum)
        {
            dp.erase(prev(it));
            it = dp.find(h[i]);
        }
        
    }
    cout << dp[0] << "\n";
    return 0;
}

Measured memory_bytes: 19200
#標準入力
num_list = input().split(" ")
a = num_list[0]
b = num_list[1]

#メイン実行部
str_1 = a * int(b)
str_2 = b * int(a)

if int(a) > int(b):
    print(str_2)
elif int(a) < int(b):
    print(str_1)
else:
    print(str_1)

Measured memory_bytes: 3060
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };

const int MOD = 1000000007;


int dist[50][50];
string s[50];



int main()
{
    const int INF = 1e9;
	cin.tie(0);
	ios::sync_with_stdio(0);

    int h, w;
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    int whiteCount = 0;
    rep(y, h) rep(x, w) {
        dist[y][x] = INF;
        if (s[y][x] == '.') ++whiteCount;
    }
    dist[0][0] = 1;
    queue<pair<int, int>> q;
    q.push({0, 0});
    while (!q.empty()) {
        int y = q.front().first; int x = q.front().second; q.pop();
        int d = dist[y][x] + 1;
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.' && d < dist[ny][nx]) {
                dist[ny][nx] = d;
                q.push({ny, nx});
            }
        }
    }

    int ans = -1;
    if (dist[h-1][w-1] != INF) {
        ans = whiteCount - dist[h-1][w-1];
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, i;
  string S;
  int cnt = 0;
  cin >> N >> S;
  for (i = 0; i < N-2; i++) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int d=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==1){
      d++;
    }
  }
  if(d%2==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n,k;ll r,s,p;cin>>n>>k>>r>>s>>p;
	string t;cin>>t;
	
	ll point,ans=0;char command,commands[n];

	for(int i=0;i<n;i++){
		if(t[i]=='r'){
			command='p';
			point=p;
		}
		else if(t[i]=='s'){
			command='r';
			point=r;
		}
		else if(t[i]=='p'){
			command='s';
			point=s;
		}

		if(i>=k&&commands[i-k]==command){
			command=' ';
			point=0;
		}

		ans+=point;
		commands[i]=command;
	}

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

Measured memory_bytes: 512
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    cin>>N;

    int L[100];
    for(int i=0;i<N;i++){
        cin>>L[i];
    }

    int c=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k]&&
                   L[i]+L[j]+L[k]-max(L[k],max(L[i],L[j]))>max(L[k],max(L[i],L[j]))){
                    c++;
                }
            }
        }
    }

    cout<<c/6<<endl;
}


Measured memory_bytes: 3144
import sys
input = sys.stdin.readline
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
points=[k-q for _ in range(n)]

for i in range(q):
  points[a[i]-1] += 1

for i in range(n):
  if points[i] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 49372
//
//  main.cpp
//  A - ><
//
//  Created by Hashizo on 2019/11/04.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
    ll ans = 0;
	char hozon;
	
	
    string s;
    cin >> s;

	ll num[s.length()+1];
	
	num[0] = 0;
	hozon = '<';

	REP(i, s.length()) {
		
		if(s[i] == '<') {
			if(hozon == '<') {
				num[i+1] = num[i] + 1;
			}
			else {
				ll j = 0;
				num[i+1] = 1;
				num[i]   = 0;
				while (1) {
					j++;
					if (i < j) {
						break;
					}
					if(s[i-j-1] == '>') {
						num[i-j] = num[i-j+1] + 1;
					}
					else {
						if(num[i-j] <= num[i-j+1]) {
							num[i-j] = num[i-j+1] + 1;
						}
						break;
					}
				}
			}
			
			hozon = s[i];
		}
		else {
			hozon = s[i];
		}
	}
	
	if(s[s.length()-1] == '>') {
		ll j = 0;
		num[s.length()]   = 0;
		while (1) {
			j++;
			if (s.length() < j) {
				break;
			}
			if(s[s.length()-j-1] == '>') {
				num[s.length()-j] = num[s.length()-j+1] + 1;
			}
			else {
				if(num[s.length()-j] <= num[s.length()-j+1]) {
					num[s.length()-j] = num[s.length()-j+1] + 1;
				}
				break;
			}
		}
	}
	
	REP(i, s.length()+1) {
		ans += num[i];
	}
	
	
	
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4740