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

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int max = 0;
			String[] codes = new String[n];
			for(int i=0;i<n;i++){
				String s = sc.next();
				String code = "" + s.charAt(0);
				for(int j=0;j<s.length()-1;j++){
					char c = s.charAt(j);
					if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
						code += s.charAt(j+1);
					}
				}
				max = Math.max(max, code.length());
				codes[i] = code;
			}
			
			String ans = "-1";
			for(int i=1;i<=max;i++){
				ArrayList<String> list = new ArrayList<String>();
				for(int j=0;j<n;j++){
					String s = "";
					if(i<codes[j].length()){
						s = codes[j].substring(0, i);
					}else{
						s = codes[j];
					}
					if(list.contains(s)){
						break;
					}else{
						list.add(s);
					}
				}
				if(list.size()==n){
					ans = Integer.toString(i);
					break;
				}
			}
			
			System.out.println(ans);
		}
	}
	
}

Measured memory_bytes: 38896
#include <iostream>

int main()
{
  int N = 0;
  int count = 0;
  int A[201];
  
  std::cin >> N;
  for (int i = 0; i < N; i++)
    std::cin >> A[i];
  
  while(true)
  {
    bool isOdd = false;
    for (int i = 0; i < N; i++)
      if (A[i] % 2) isOdd = true;
    
    if (isOdd)
      break;
    
    for (int i = 0; i < N; i++)
      A[i] /= 2;
    
    count++;
  }
  
  std::cout << count;
  
  return 0;
}

Measured memory_bytes: 3100
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<bool> broken(n + 1, false);
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        broken[b] = true;
    }

    const int modulo = 1e9 + 7;
    vector<long long> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (!broken[i - 1])
            dp[i] += dp[i - 1];
        if (i >= 2 && !broken[i - 2])
            dp[i] += dp[i - 2];

        dp[i] %= modulo;
    }

    cout << dp[n] << '\n';
}


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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int maxTime = (H2 * 60 + M2) - (H1 * 60 + M1);
    int ans = maxTime - K;

    cout << ans;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	int data[101];
	for(int i=0;i<=100;++i)data[i]=0;
	int tmp;
	while(cin>>tmp)data[tmp]++;
	int ans=0;
	for(int i=1;i<=100;++i)ans=max(ans,data[i]);
	for(int i=0;i<=100;++i)
		if(data[i]==ans)cout<<i<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

#include <algorithm>
#include <functional>
#include <iostream>

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main(void)
{
    ll A, B, N;
    ll Z = 0;
    ll Y = 0;
    ll ans = 0;
    cin >> A;
    cin >> B;
    cin >> N;
    ll x = 0;
    if (B > N)
    {
        x = N;
    }
    else
    {
        x = B - 1;
    }
    ans = A * x / B;
    cout << ans;
}


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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  ll ans = 1000;
  int N;
  cin >> N;
  vector<int> A(N+1, 0);
  rep (i, N) {
    cin >> A[i];
  }

  int now = A[0];
  ll items = 0, temp = ans;
  rep(i, 1, N) {
    int feature = A[i];
    if (items > 0) {
      temp += items * now;
      items = 0;
    }
    if (now < feature) {
      items = temp / now;
      temp -= items * now;
    }
    // cout << temp << ", f: " << feature << ", i: " << items << endl;
    now = feature;
  }

  ans = temp + items * now;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define vout(i,n,v) for(int i=0;i<(int)n-1;i++){cout<<v[i]<<" ";}cout<<v[n-1]<<endl;
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long N, std::vector<long long> A){
  map<ll,ll> m{};
  for (ll i = 1; i <= N; i++)
  {
    m.emplace(A[i], i);
  }
  for (ll i = 1; i <= N; i++)
  {
    cout << m[i]+1 << " ";
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
  ll n;
  scanf("%lld",&n);
  vector<ll> a(n*2),sum(n*2+1,0);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    a[n+i] = a[i];
  }
  for(int i=0;i<2*n;i++)sum[i+1] = sum[i] + a[i];

  ll ans = 0;

  int l=0, r=0;
  while(l<n){
    while(r<l+n-1 && 3*(sum[r]-sum[l])<=sum[n])r++; r--;
    if(r-l>1){
      ll cur = sum[r]-sum[l], rem = sum[n]-cur;
      int L=r, R=l+n;
      while(R-L>1){
	ll M = (L+R)/2;
	if(2*(sum[M]-sum[r])<rem)L = M;
	else R = M;
      }
	
      ll minv = 0;
      if(R<l+n && r<R)minv = max(minv, min(sum[R]-sum[r], sum[l+n]-sum[R]));
      if(R-1<l+n && r<R-1)minv = max(minv, min(sum[R-1]-sum[r], sum[l+n]-sum[R-1]));
      minv = min(minv, cur);
      ans = max(ans, minv);
    }
    l++; if(r<l)r++;
  }

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

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  cout << N*(N+1)/2 << endl;
 }

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

int main() {
  int N,M,same=0,length=0;
  cin >> N >> M;
  vector<int> X(M),delta(M-1);
  for(int i=0;i<M;i++){
  	cin >> X.at(i);
  }
  if(N>=M){
  	cout << 0 << endl;
  }
  else{
  sort(X.begin(),X.end());
  for(int i=0;i<M-1;i++){
  	delta.at(i)=X.at(i+1)-X.at(i);
  }
  sort(delta.begin(),delta.end());
  for(int i=0;i<M-N;i++){
  	length+=delta.at(i);
  }
  cout << length << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int N; cin >> N;
	ll A[10][10] = { 0 };
	rep(i, N) {
		string s = to_string(i+1);
		int a = s[0] - '0';
		int b = s[s.length() - 1] - '0';
		A[a][b]++;
		

	}
	int ans = 0;
	rep(i, 10) {
		rep(j, 10) {
			ans += A[i][j] * A[j][i];
		}
	}
	cout << ans << endl;


}




	
	





	
	


	


	


		






Measured memory_bytes: 256
S=str(input())
S=S[::-1]
while True:
    if S[:5]=='maerd':
        S=S[5:]

    elif S[:7]=='remaerd':
        S=S[7:]
    elif S[:5]=='esare':
        S=S[5:]
    elif S[:6]=='resare':
        S=S[6:]
    elif len(S)==0:
        print('YES')
        exit()
    else:
        print('NO')
        exit()


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

int main() {
    int A,B,C,D;
    cin>>A>>B>>C;
    D=A-B;
    if(A-B==0){
        cout<<C<<endl;
    }else if((A-B)>=C){
        cout<<0<<endl;
    }else{
        cout<<C-(A-B)<<endl;
    }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
ll N;
ll dp[100][3];
int main(){
	cin>>N;
	dp[61][0]=1;
	dp[61][1]=0;
	dp[61][2]=0;
	for(int i=60;i>=0;i--){
		int x=(N>>i)%2;
		//cout<<x<<"aa"<<endl;
		ll a=dp[i+1][0],b=dp[i+1][1],c=dp[i+1][2];
		if(x==0){
			dp[i][0]=(a+b)%MOD;
			dp[i][1]=b;
			dp[i][2]=(b+(3*c)%MOD)%MOD;
		}else{
			dp[i][0]=(a)%MOD;
			dp[i][1]=(a+b)%MOD;
			dp[i][2]=((2*b)%MOD+(3*c)%MOD)%MOD;
		}
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	cout<<((dp[0][0]+dp[0][1])%MOD+dp[0][2])%MOD<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000009;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<vector<int>> children;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
void hukasa(vector<vector<int>> s,vector<vector<int>> table,int &ans,pii frm,int n,int m){
  int x,y;
  tie(x,y) = frm;
  set<pii> se;
  if(x-1 >= 0)se.insert(pii(x-1,y));
  if(x+1 < n)se.insert(pii(x+1,y));
  if(y-1 >= 0)se.insert(pii(x,y-1));
  if(y+1 < m)se.insert(pii(x,y+1));
  for(auto t:se){
    int tx,ty;
    tie(tx,ty) = t;
    if(s.at(tx).at(ty) && table.at(tx).at(ty) == -1){
      table.at(tx).at(ty) = table.at(x).at(y) + 1;
      ans = max(ans,table.at(tx).at(ty));
      hukasa(s,table,ans,t,n,m);
      table.at(tx).at(ty) = -1;
    }
  }
}
void daiku(int frm,vector<vector<pii>> g,vector<int> &cost,int n){
  priority_queue<pii,vector<pii>,greater<pii>> q;
  q.push(pii(cost.at(frm),frm));
  vector<bool> kakutei(n,false);
  while(!q.empty()){
    pii now = q.top();
    q.pop();
    int n1,n2;
    tie(n1,n2) = now;
    if(kakutei.at(n2))continue;
    kakutei.at(n2) = true;
    for(auto t:g.at(n2)){
      int tx,ty;
      tie(tx,ty) = t;
      if(cost.at(tx) > n1 + ty){
        cost.at(tx) = n1 + ty;
        q.push(pii(cost.at(tx),tx));
      }
    }
  }
}
int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(s*t >= d)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    // Your code here!
    int N,K;
    int p[1000];
    int ans = 0;
    
    scanf("%d%d",&N,&K);
    
    for(int i = 0; i < N; i++){
        scanf("%d",&p[i]);
    }
    
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > i; j--){
            if(p[j] < p[j-1]){
                int tmp = p[j];
                p[j] = p[j-1];
                p[j-1] = tmp;
            }
        }
    }
    
    for(int i = 0; i < K; i++){
        ans += p[i];
    }
    
    printf("%d\n",ans);
    
}

Measured memory_bytes: 1732
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,ans;
    ans=0;
    cin>>a;
    
c=0;
    for(i=0;i<a;i++){
        cin>>b;
        if(i==0)
        continue;
        
        if(c-b>0){
            cout<<"No"<<endl;
            return 0;
        }
        if(c<b)
        c=b-1;
    }
 
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a, reverse=True)
all = sum(a)

cnt = 0
for num in a:
    if num >= all / (4*m):
        cnt += 1
    if cnt >= m:
        print("Yes")
        break
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const long long mod=1e16+7;
int n,b[15];long long a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		char ch[N];
		scanf("%s",ch);int l=strlen(ch);
		memset(b,0,sizeof(b));
		for(int j=0;j<l;j++)b[j+1]=ch[j]-'a'+1;
		sort(b+1,b+l+1);
		for(int j=1;j<=l;j++)a[i]=(a[i]*88+b[j])%mod;
	}
	sort(a+1,a+n+1);
	long long ans=0,k=1;
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1])k++;else
			ans+=(k-1)*k/2,k=1;
	printf("%lld\n",ans+(k-1)*k/2);
	return 0;
}

Measured memory_bytes: 1024
def AcCepted(s):

    ans = "WA"

    if s[0] == "A" and s[2:-1].count("C") == 1:
        s = s.replace("C" , "c")
        if s[1:].islower():
            ans = "AC"

    return ans

def main():
    s = str(input())
    print(AcCepted(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import deque
N = int(input())
A = deque(sorted(list(map(int, input().split()))))

while True:
    if len(A) == 1:
        break
    while A[0] == 0:
        A.popleft()
    mod = A[0]
    for i in range(1, len(A)):
        A[i] = A[i]%mod
    A = deque(sorted(A))

print(A[0])

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

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
int a,b; cin>>a>>b;
cout<<((a+b)%24);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn=10000+10;
int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return x*f;
}
struct node{
	int r,l,sum;
	int flag;
}tree[maxn];
int len=0;
int a[maxn],b[maxn],c[maxn];
inline void push(int l,int r,int flag){
	tree[++len].l=l;
	tree[len].r=r;
	tree[len].sum=a[l]+b[r];
//	cout<<l<<" "<<r<<endl;
//	cout<<len<<" "<<a[l]<<" "<<b[r]<<endl;
	tree[len].flag=flag;
	int u=len;
	while(tree[u].sum>tree[u/2].sum && u>1){
		swap(tree[u],tree[u/2]);
		u/=2;
	}
	return;
}
inline void pop(){
	tree[1]=tree[len--];
	int u=1;
	while(u*2<=len && tree[u].sum<tree[u*2].sum || u*2+1<=len && tree[u].sum<tree[u*2+1].sum){
		int v=u*2;
		if(v+1<=len && tree[u*2].sum<tree[u*2+1].sum)v++;
		swap(tree[u],tree[v]);
		u=v;
	}
	return;
}
int cmp(int x,int y){
	return x>y;
}
int k,m;
int n[10];
signed main(){
	n[1]=read();n[2]=read();n[3]=read();k=read();
	for(register int i=1;i<=n[1];i++)a[i]=read();
	sort(a+1,a+n[1]+1,cmp);
	for(register int num=2;num<=3;num++){
		for(register int i=1;i<=n[num];i++)b[i]=read();
		sort(b+1,b+n[num]+1,cmp);
		while(len)pop();
		push(1,1,0);
		for(register int j=1;j<=k;j++){
			if(len==0)break;
			//cout<<tree[1].l<<" "<<tree[1].r<<" "<<a[tree[1].l]<<" "<<b[tree[1].r]<<endl;
			c[j]=a[tree[1].l]+b[tree[1].r];
			int flag=tree[1].flag,u=tree[1].l,v=tree[1].r;
			pop();
			//cout<<a[u+1]<<" "<<b[v+1]<<" "<<len<<endl;
			if(b[v+1]!=0)push(u,v+1,1);
			if(!flag && a[u+1]!=0)push(u+1,v,0);
		}
		for(register int j=1;j<=k;j++)a[j]=c[j];
		//for(register int j=1;j<=k;j++)
		//	cout<<j<<" "<<a[j]<<endl;
	}
	for(register int i=1;i<=k;i++)printf("%lld\n",a[i]);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int A, B, C, X;
    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &X);
    int count = 0;
    int a, b, c;

    for(a=0; a<=A; a++) {
        for(b=0; b<=B; b++) {
            for(c=0; c<=C; c++) {
                if(500*a + 100*b + 50*c == X) {
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int            long long
#define endl           '\n'
#define x              first
#define y              second
#define remove         erase
#define pb             push_back
#define mod1           1000000007
#define mod2           998244353
#define xrange(i,s,n)  for(int i=s;i<n;i++)
#define yrange(i,n,s)  for(int i=n;i>=s;i--)
#define deb(x)         cerr<<'\t'<<#x<<" is "<<(x)<<endl
#define usefile        freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define debvec(v)      cerr<<#v<<" is [ ";for(auto el:v)cerr<<el<<" ";cerr<<"]\n";
#define debmap(m)      cerr<<#m<<" is [ ";for(auto p:m)cerr<<"("<<p.x<<","<<p.y<<") ";cerr<<"]\n";
#define tezz           int32_t main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);solve();return 0;}
#define tezzn          int32_t main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int32_t t;cin>>t;while(t--)solve();return 0;}
using namespace std;
// . . . S O L U T I O N . . . B E G I N S . . . F R O M . . . H E R E . . .

int dp[100001][101];

int knapsack (int wt[], int pr[], int w, int n) {
    if (w == 0 || n == 0) return 0;
    if (dp[w][n] != -1) return dp[w][n];
    int currwt = wt[n-1], currpr = pr[n-1];
    if (w < currwt) return dp[w][n] = knapsack(wt, pr, w, n-1);
    else return dp[w][n] = (max(knapsack(wt, pr, w, n-1), currpr + knapsack(wt, pr, w-currwt, n-1)));
}

void solve () {
    int n, w;
    memset(dp, -1, sizeof dp);
    cin >> n >> w;
    int wt[n], pr[n];
    xrange(i, 0, n) cin >> wt[i] >> pr[i];
    cout << knapsack(wt, pr, w, n) << endl;
}
tezz


Measured memory_bytes: 79232
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(3):: s

    read*, s
    if (index(s,'a') > 0 .and. index(s,'b') > 0 .and. index(s,'c') > 0) then
        print'(a)', 'Yes'
    else
        print'(a)', 'No'
    end if
end program main

Measured memory_bytes: 256
N = int(input())
t = [0] * (N + 1)

for i in range(2, N + 1):
    x = i
    p = 2
    
    # Calculate divisor
    while x > 1:
        while x % p == 0:
            t[p] += 1
            x //= p
        p += 1
        
ans = 1
for c in t:
    ans = (ans * (c + 1)) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATenki solver = new ATenki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATenki {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            String a = sc.nextLine();
            String b = sc.nextLine();
            int ans = 0;
            for (int i = 0; i < 3; i++) {
                if (a.charAt(i) == b.charAt(i)) {
                    ans++;
                }
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 23636
<?php
list($n, $k) = ints();
$p = ints();
for ($i = 0; $i < $n; ++$i) --$p[$i];
$c = ints();
$max = PHP_INT_MIN;
for ($i = 0; $i < $n; ++$i) {
    $s = 0;
    $cur = $i;
    $cnt = 0;
    $_max = [PHP_INT_MIN];
    while (true) {
        ++$cnt;
        $cur = $p[$cur];
        $s += $c[$cur];
        $_max[] = max($_max[$cnt - 1], $s);
        if ($cur === $i) break;
    }
    if ($k <= $cnt) {
        $max = max($max, $_max[$k]);
        continue;
    }
    if ($s <= 0) {
        $max = max($max, $_max[$cnt]);
        continue;
    }
    $t = $k % $cnt;
    $tt = intdiv($k - $cnt, $cnt);
    $max = max($max, max($_max[$cnt], $s + $_max[$t]) + $s * $tt);
}
echo $max;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 17280
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split()) #高橋君
B1,B2 = map(int,input().split()) #青木君

# 時間配列
T = [T1]
f = 1
for i in range(3):
    if f:
        Tn = T2
        f = 0
    else:
        Tn = T1
        f = 1
    T.append(T[-1]+Tn)
# print(T)

class runner():
    def __init__(self,v1,v2):
        self.v1 = v1
        self.v2 = v2
        
    def distance(self,t):
        d = t//(T1+T2)*(self.v1*T1 + self.v2*T2)
        tm = t % (T1+T2)
        # print("d",d,"tm",tm)
        if tm < T1:
            d += self.v1 * tm
        else:
            d += self.v2*(tm-T1) + self.v1*T1
        return d

dif = runner(A1-B1,A2-B2)

c = -1
D = 0
DL = [0]
for t in T:
    pD = D
    D = dif.distance(t)
    DL.append(D)
    # print(D)
    if pD*D <= 0:
        c += 1
# print(c)
# print(DL)

if DL[1]*DL[2] > 0:
    print(0)
else:
    if DL[2] == 0:
        print("infinity")
    else:
        a = DL[2]
        if a>0:
            if -DL[1]%a == 0:
                print(-DL[1]//a*2)
            else:
                print(-DL[1]//a*2+1)
        else:
            if -DL[1]%a == 0:
                print(-DL[1]//a*2)
            else:
                print(-DL[1]//a*2+1)

Measured memory_bytes: 3064
package main

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

type task struct {
	requiredTime int
	limit        int
}

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	tasks := make([]*task, n)
	for i := 0; i < n; i++ {
		requiredTime, limit := io.ScanInt2()
		tasks[i] = &task{requiredTime: requiredTime, limit: limit}
	}
	sort.Slice(tasks, func(i, j int) bool {
		return tasks[i].limit < tasks[j].limit
	})
	var curTime int
	for _, task := range tasks {
		curTime += task.requiredTime
		if curTime > task.limit {
			io.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 13024
import sys

a = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
n, *b = map(int, sys.stdin.read().split())
b = set(b)

def main():
    res = [[False] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                res[i][j] = True
    
    for i in range(3):
        for j in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for j in range(3):
        for i in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for i, j in zip(range(3), range(3)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    for i, j in zip(range(3), range(2, -1, -1)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

int main() {
  int a,b,c;cin >> a >> b >> c;
  if(a+b>=c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

const int Maxn=100005;

int n;
int a[Maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x>0) a[x-1]++;
		a[x]++;
		a[x+1]++;
	}
	int Maxt=0;
	for(int i=0;i<Maxn;i++) Maxt=max(Maxt,a[i]);
	printf("%d\n",Maxt);
return 0;
}

Measured memory_bytes: 640
def division_nankai_2(n):
  answer = 0
  while n % 2 == 0:
    answer += 1
    n = n // 2
  return answer
 
total = int(input())
div = []
numbers = map(int, input().split())
for i in numbers:
  div.append(division_nankai_2(i))
print(min(div))


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<double> v(3);
    while (cin >> v[0] >> v[1] >> v[2], v[0])
    {
        int n;
        cin >> n;
        rep(i, n)
        {
            double r;
            cin >> r;
            sort(ALL(v));
            if (sqrt(v[0] * v[0] + v[1] * v[1]) < 2 * r)
                OP("OK");
            else
                OP("NA");
        }
    }

    return 0;
}


Measured memory_bytes: 3244
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> vd;
	for(int i=1; i<=n; i+=2){
		if(n%i==0) vd.push_back(i);
	}
	ll ans=0;
	vector<ll> vc(vd.size());
	for(int i=0; i<vd.size(); i++){
		ll d=n/vd[i];
		ll cnt=0;
		for(int j=0; j<d; j++){
			cnt*=2;
			if(s[j]=='1') cnt++;
			cnt%=MOD;
		}
		string t=s.substr(0, d);
		for(int j=0; j<d; j+=2){
			if(t[j]=='0') t[j]='1';
			else t[j]='0';
		}
		string s2;
		for(int j=0; j<n/d; j++) s2+=t;
		for(int j=0; j<n; j++){
			int l=j/d;
			if((l+(j-l*d))%2==0){
				if(s2[j]=='0') s2[j]='1';
				else s2[j]='0';
			}
		}
		if(s2<=s) cnt++;
		vc[i]=cnt%MOD;
	}
	for(int i=(int)vd.size()-1; i>=0; i--){
		for(int j=i+1; j<vd.size(); j++){
			if(vd[j]%vd[i]==0) (vc[i]+=MOD-vc[j]);
		}
		vc[i]%=MOD;
		(ans+=vc[i]*(2*n/vd[i]))%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1068
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N, X = LIST()

x = LIST()

dx = [abs(i - X) for i in x]

ans = dx[0]
for i in range(1, N):
    ans = fractions.gcd(ans, dx[i])

print(ans)


Measured memory_bytes: 16268
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }
func readDoubles() -> [Double] { readLine()!.split(separator: " ").map { Double($0)! } }

let (a, b) = toTuple(readInts())
print(a * b)

Measured memory_bytes: 13460
gets
*s,(i,j,k)=$<.map{|s|s.split.map &:to_i}.sort_by &:last
101.times{|x|101.times{|y|h=k+(i-x).abs+(j-y).abs
s.all?{|i,j,k|k==[h-(i-x).abs-(j-y).abs,0].max}&&($><<[x,y,h]*" ";exit)}}

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

using namespace std;

const int N = 2000 + 7;
int n, k, mindel[N][N], dep[N][N], under[N], rdp[N];
vector<int> g[N];
bool vis[N];

void dfs(int a) {
  vector<int> kids;
  under[a] = 1;
  vis[a] = 1;
  for (auto &b : g[a]) {
    if (vis[b] == 0) {
      dfs(b);
      rdp[a] = max(rdp[a], rdp[b]);
      under[a] += under[b];
      kids.push_back(b);
    }
  }
  if (kids.empty()) {
    mindel[a][0] = 1;
    for (int i = 1; i <= k; i++) {
      mindel[a][i] = 0;
    }
    return;
  }
  rdp[a]++;
  mindel[a][0] = under[a];
  for (int len = 1; len <= k; len++) {
    mindel[a][len] = (int) 1e9;
    int other = k - len;
    other = min(other, len - 1);
    for (auto &power : kids) {
      int cur = mindel[power][len - 1];
      for (auto &b : kids) {
        if (b != power) {
          cur += mindel[b][other];
        }
      }
      mindel[a][len] = min(mindel[a][len], cur);
    }
  }
  for (int i = 1; i <= k; i++) {
    mindel[a][i] = min(mindel[a][i], mindel[a][i - 1]);
  }
}

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

  cin >> n >> k;
  k++;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  int ans = (int) 1e9;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, mindel[i][k] + n - under[i]);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 17664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}



Measured memory_bytes: 26452
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main () {
	vector<int> min;
	vector<int> cur;

	int n;
	cin >> n;

	for (int i=0; i<n; i++) {
		cur = vector<int> (26, 0);
		string s;
		cin >> s;

		for (char c : s) {
			cur[c-'a']++;
		}

		if (i==0)
			min = cur;
		else {
			for (int j=0; j<26; j++) {
				min[j] = (cur[j] < min[j]) ? cur[j] : min[j];
			}
		}

	}

	for (int i=0; i<26; i++) {
		char c = 'a' + i;
		for (int j=0; j<min[i]; j++)
			cout << c;
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, i, x[1000], y[1000];
    double p2, p3, max = 0;
    double dp1, dp2, dp3;
 
    dp1 = dp2 = dp3 = 0;
    p2 = p3 = 0;
 
    scanf("%d", &n);
    for (i = 0;i < n;i++)
    {
        scanf("%d", &x[i]);
    }
    for (i = 0;i < n;i++)
    {
        scanf("%d", &y[i]);
    }
    for (i = 0;i < n;i++)
    {
        dp1 += abs(x[i] - y[i]);
        p2 += pow((x[i] - y[i]), 2);
        p3 += pow(abs(x[i] - y[i]), 3);
    }
    dp2 = sqrt(p2);
    dp3 = cbrt(p3);
    for (i = 0;i < n;i++)
    {
        if (max < abs(x[i] - y[i]))
        {
            max = abs(x[i] - y[i]);
        }
    }
    printf("%.6f\n %.6f\n %.6f\n %.6f\n", dp1, dp2, dp3, max);
 
    return 0;
}



Measured memory_bytes: 2056
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    if X >= 1800:
        return 1
    elif X >= 1600:
        return 2
    elif X >= 1400:
        return 3
    elif X >= 1200:
        return 4
    elif X >= 1000:
        return 5
    elif X >= 800:
        return 6
    elif X >= 600:
        return 7
    return 8


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 2e3 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;
int cnt[MAXN];

int main()
{
	int i, j, x, y;
	scanf("%d%d%d", &N, &x, &y);
	for (i = 1; i < N; ++i) {
		cnt[i] = N - i;
	}
	for (i = 1; i <y; ++i) {
		for (j = y; j <= N; ++j) {
			int l = (j - i);
			int nl = abs(x - i) + 1 + (j - y);
			if (nl < l) {
				cnt[l]--;
				cnt[nl]++;
			}
		}
		for (j = y - 1; j > i; --j) {
			int l = (j - i);
			int nl = abs(x - i) + 1 + (y - j);
			if (nl < l) {
				cnt[l]--;
				cnt[nl]++;
			}
		}
	}
	for (i = 1; i < N; ++i) printf("%d\n", cnt[i]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

ll solve(vector<pair<int,int>> v){
    int n=v.size();
    for(int i=0;i<n;i++){
        v[i].first=min(v[i].first,n);
    }
    vector<vector<int>> s(n+1);
    for(int i=0;i<n;i++){
        s[v[i].first].push_back(v[i].second);
    }
    ll res=0;
    priority_queue<ll> q;
    for(int i=n;i>=1;i--){
        for(int x:s[i]){q.push(x);}
        if(q.size()){
            res+=q.top();
            q.pop();
        }
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    while(q--){
        int n; cin >> n;
        vector<pair<int,int>> pl,pr;
        ll res=0;
        for(int i=0;i<n;i++){
            int k,l,r; cin >> k >> l >> r;
            int m=min(l,r);
            res+=m;
            l-=m,r-=m;
            if(l>0)pl.push_back({k,l});
            else pr.push_back({n-k,r});
        }
        res+=solve(pl);
        res+=solve(pr);
        printf("%lld\n",res );
    }
}

Measured memory_bytes: 11108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a[80];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	ll ans=1000;
	rep(i,0,n){
		//真に安い日
		int mi=1000;
		for(int j=n-1;j>i;j--)if(a[j]<a[i])mi=j;
		//真に高い日
		int Mi=0;
		for(int j=n-1;j>i;j--)if(a[j]>a[i])Mi=j;
		if(Mi!=0&&Mi<mi){
			ans=ans%a[i]+ans/a[i]*a[Mi];
			i=Mi-1;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    cin>>n;
    vector<string> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        sort(a[i].begin(),a[i].end());
    }
    sort(a.begin(),a.end());
    vector<ll> b;
    ll c=1,d=0;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            c++;
        }else{
            if(c!=1){
                b.push_back(c);
                c=1;
            }
        }
    }
    if(c!=1){
        b.push_back(c);
    }
    rep(i,b.size()){
        d+=b[i]*(b[i]-1)/2;
    }
    cout<<d;
    return 0;
}


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

int main(){
	int N;string S;
	cin>>N>>S;
	int num0=0,num1=0;
	for(int i=0;i<N;i++){
		if(S[i]=='(') num0++;
		if(S[i]==')'){
			if(num0>0) num0--;
			else num1++;
		}
	}
	for(int i=0;i<num1;i++) S.insert(S.begin(),'(');
	for(int i=0;i<num0;i++) S.push_back(')');
	cout<<S<<endl;
}

Measured memory_bytes: 256