akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


ll n, a;
vector<ll>tree[100010];
ll dp[100010];

void dfs(int v) {
	if (tree[v].size() == 0) {
		dp[v] = 0;
		return;
	}
	vector<P>leaves;
	for (auto u : tree[v]) {
		dfs(u);
		leaves.eb(P(dp[u], u));
	}
	sort(ALLR(leaves));
	int cnt = 1;
	for (auto u : leaves) {
		dp[v] = max(dp[v], dp[u.sc] + cnt);
		cnt++;
	}
	return;
}

int main() {
	cin >> n;
	for (int i = 2;i <= n;i++){
		cin >> a;
		tree[a].pb(i);
	}
	dfs(1);
	cout << dp[1] << endl;
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

	
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 1e9 + 7; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {	 ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 1e6 + 10;

int n, m, nq, nk;
string str;

void task() {
	string str;
	cin >> str;
	int s = 0;
	int ans = 0;
	for (auto x : str) {
		if (x == 'S')  s = 0;
		else s++;
	  ckmax(ans, s);
	}
	cout << ans << endl;
	//Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
 // cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3652
#include <iostream>

using namespace std;
void C_3or2() {
  int n;
  cin >> n; 
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      ans++;
      a = a / 2;
    }
  }
  cout << ans << endl;
}

int main()
{
  C_3or2();
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = {}
for a in A:
    if a not in B:
        B[a] = 1
    else:
        B[a] += 1
count = 0
for i, v in enumerate(sorted(B.values())):
    if len(B) - i <= K:
        break
    count += v
print(count)

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,i,j;
    cin>>n>>k;
    vector<int> a(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<int> play(k+1);
    play[0]=0;
    for(i=1;i<=k;i++)
    {
        int flag=0;
        for(j=0;j<n;j++)
        {
            if(i-a[j]<0)
            {
                break;
            }
            else
            {
                if(play[i-a[j]]==0)
                {
                    flag=1;
                    break;
                }
            }  
        }
        play[i]=flag;
    }
    if(play[k]==0)
        cout<<"Second"<<endl;
    else
    {
        cout<<"First"<<endl;
    }
    

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
	string s, t;
	cin >> s >> t;

	int length;
	length = min(s.size(), t.size());




	for(int i=0; i<s.size(); i++){
		for(int j=0; j<s.size()-1; j++){
			if(s[j]>s[j+1]){
				swap(s[j], s[j+1]);
			}

		}
	}
	for(int i=0; i<t.size(); i++){
		for(int j=0; j<t.size()-1; j++){
			
			if(t[j]<t[j+1]){
				swap(t[j], t[j+1]);
			}

		}
	}
		
	
	
	
	for(int i=0; i<length; i++){
		
		if(s[i]==t[i]){
			if(i==length-1){
				if(s.size()<t.size()){
					cout << "Yes" << endl;return 0;
				}
				else{
					cout << "No" << endl;return 0;
				}

			}
			continue;
		}
		else if(s[i]<t[i]){
			cout << "Yes" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct edge {
	int to; ll cost;
};
vector<edge> G[1 << 17];

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<ll> p(n), c(n), v(n);
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> c[i];
	rep(i, n)cin >> v[i];
	rep(i, m) {
		int a, b; ll c; cin >> a >> b >> c; a--; b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	vector<ll> dist(n, INF);
	dist[0] = 0;
	priority_queue<LP, vector<LP>, greater<LP>> q;
	q.push({ 0,0 });
	while (!q.empty()) {
		LP p = q.top(); q.pop();
		int id = p.second;
		if (p.first > dist[id])continue;
		rep(j, G[id].size()) {
			int to = G[id][j].to;
			ll nd = p.first + G[id][j].cost;
			if (nd < dist[to]) {
				dist[to] = nd;
				q.push({ nd,to });
			}
		}
	}
	vector<ll> val(n);
	priority_queue<LP> que;
	rep(i, n) {
		val[i] = p[i] - dist[i];
		//cout << i << " " << val[i] << endl;
		que.push({ val[i],i });
	}
	while (!que.empty()) {
		LP p = que.top(); que.pop();
		int id = p.second;
		if (p.first < val[id])continue;
		rep(j, G[id].size()) {
			int to = G[id][j].to;
			ll nd = p.first - G[id][j].cost;
			if (nd > val[to]) {
				val[to] = nd;
				que.push({ nd,to });
			}
		}
	}
	//cout << val[0] << endl;
	vector<ll> ans(k, -INF);
	rep(i, n) {
		ans[c[i] - 1] = max(ans[c[i]-1],v[i] - dist[i] + val[i]);
	}
	rep(i, k) {
		cout << ans[i] << endl;
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}




Measured memory_bytes: 23156
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int n, cnt = 0;
    vector< pair<int, int> > v;
    cin >> n;
    rep(i,n){
        int a = i + 1, b;
        cin >> b;
        if(a > b) swap(a, b);
        v.emplace_back(a, b);
    }
    sort(all(v));
    rep(i,v.size() - 1){
        if(v[i].first == v[i + 1].first && v[i].second == v[i + 1].second ){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1400
class Node
  attr_accessor :id, :nexts, :parent_id, :is_reach

  def initialize id
    @id = id.to_i
    @nexts = []
    @parent_id = -1
    @is_reach = false
  end

  def setNexts next_id
    @nexts << next_id
  end

  def setReach
    is_reach = true
  end

  def isReach
    return is_reach
  end
end

$input_map = {}
n = 0
count = 0
line_count = 0
STDIN.each_line {|line|
  if count == 0
    count += 1
    n = line.to_i
    next
  end

  hoge = 0
  array = line.split " "
  id = array[0].to_i
  $input_map[id] = Node.new id
  array.each do |num|
    hoge += 1
    if hoge==1
      next
    elsif hoge==2
      next
    end

    $input_map[id].setNexts num.to_i
  end

  line_count += 1
}

$visited_list = Array.new n + 1
$visited_list.fill (false)
$discover_list = Array.new n + 1
$complete_list = Array.new n + 1
def PrintNode id, time
  $visited_list[id] = true
  $discover_list[id] = time

  if $input_map[id].nexts.empty?
    $complete_list[id] = time + 1
    return $complete_list[id]
  end

  result = 0
  $input_map[id].nexts.each do |child_id|
    if !$visited_list[child_id]
      time += 1
      result = PrintNode child_id, time
      time = time + (result - time)
    end
  end

  end_time = result == 0 ? time + 1 : result + 1

  $complete_list[id] = end_time
  return $complete_list[id]
end

now_time = 0
index = 1
$visited_list.each do |i|
  if ($input_map.has_key? (index)) && (!$visited_list[index])
    now_time += 1
    now_time = PrintNode index, now_time
  end
  index += 1
end

n.times do |i|
  print i + 1, " ", $discover_list[i + 1], " ", $complete_list[i + 1], "\n"
end



Measured memory_bytes: 8872
N = int(input())
a = list(map(int, input().split()))

list = []

if N % 2 == 0:

    for i in reversed(range(0+1,N,2)):
        list.append(a[i])

    for i in range(0, N-1, 2):
        list.append(a[i])

else:
    for i in reversed(range(0,N, 2)):
        list.append(a[i])

    for i in range(1, N-1, 2):
        list.append(a[i])

print(*list)


Measured memory_bytes: 101716
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;

int a[200002], b[200002], n;

ll suma, sumb, mini;
int frq[200002], sm[200002];
vector<pair<int, int> >srt;
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
        suma += a[i];
        sumb += b[i];
        srt.pb({a[i], i});
        srt.pb({b[i], i});
    }
    mini = min(suma, sumb);
    sort(srt.begin(), srt.end());
    ll tot = 0;
    for(int i = 0; i < n; ++i)
    {
        tot += srt[i].fi;
        frq[srt[i].se]++;
        sm[srt[i].se] += srt[i].fi;
    }
    for(int i = 1; i <= n; ++i)
    {
        ll smm = tot;
        int pz = n;
        while(1)
        {
            if(pz - frq[i] == n)
                break;
            smm += srt[pz].fi;
            frq[srt[pz].se]++;
            sm[srt[pz].se] += srt[pz].fi;
            ++pz;
        }
        mini = min(mini, smm - sm[i]);
        for(int x = n; x < pz; ++x)
            frq[srt[x].se]--, sm[srt[x].se] -= srt[x].fi;
    }
    cout << mini;
    return 0;
}


Measured memory_bytes: 3568
ABC = list(map(int, input().split()))

ABC.sort(reverse = True)

step1 = ABC[0] - ABC[1]
step2 = ABC[0] - ABC[2] - step1

if step2 % 2 == 0:
    result  = int(step2 / 2) + step1
else:
    result = int(step2 / 2) + step1 + 2
print(result)

Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10,M=1e2+10;
const int mod=1e9+7;
const int inf=1e9;
int w[M],v[M];
int dp[M][N];

int main(){
    int W,n;
    int val=0;
    cin>>n>>W;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        val+=v[i];
    }
    dp[0][0]=0;
    for(int i=1;i<=val;i++) dp[0][i]=inf;
    for(int j=1;j<=n;j++){
        for(int i=0;i<=val;i++){
            dp[j][i]=dp[j-1][i];
            if(i>=v[j]){
                dp[j][i]=min(dp[j][i],dp[j-1][i-v[j]] + w[j]);
            }
        }
    }
    
    int ans=0;
    for(int i=1;i<=val;i++){
        if(dp[n][i]<=W) ans=i;
    }
    
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 43064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
using namespace std;

string s;

int f(int &pos){
    if(s[pos] == '['){
        vector<int> child;
        pos++;
        while(true){
            child.push_back(f(pos));
            if(s[pos] == ']'){
                pos++;
                break;
            }
        }
        sort(child.begin(), child.end());
        int ret = 0;
        for(int i = 0; i <= child.size()/2; i++)    ret += child[i];
        return ret;
    }else{
        int ret = 0;
        while(isdigit(s[pos]))  ret = ret*10 + (s[pos++]-'0');
        return ret/2+1;
    }
}

int main(){
    int n, pos;
    cin >> n;
    while(n-- > 0){
        cin >> s;
        pos = 0;
        cout << f(pos) << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = K; i < N; i++){
    if(A[i] > A[i - K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4820
#include <stdio.h>
int main(void)
{
	int n,k,a,b,i,j,p,z;
	scanf("%d %d",&n,&k);
	if(n%2==1){
		p=n/2+1;
	}
	else
		p=n/2;
	for(i=0;i!=k;i++){
		scanf("%d%d",&a,&b);
		if(a>p){
			a=n-a;
				a++;
		}
		if(b>p){
			b=n-b;
				b++;
		}
		if(a<b)
			z=a;
		else
			z=b;
		if(z%3!=0)
			printf("%d\n",z%3);
		else
			printf("3\n");
	}
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N,A,B;
  cin>>N>>A>>B;
  long d=B-A;
  if(d%2==0){
    cout<<d/2<<endl;
  }else{
    long i=min(N-B,A-1);
    d+=1;
    cout<<d/2+i<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(ll i=f; i<ll(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

signed main()
{
    int n, m, k;
    cin >> n >> m >> k;
    
    bool ok =false;
    rep(i, n+1) rep(j, m+1){
        ok |= i*j + (n-i)*(m-j) == k;
    }
    
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

//using std::pair;
//typedef std::vector<std::pair<int, int>> vec;
//using std::make_pair;

int n, i;
int qmem[200000][2];
int (*es[100000])[2];
int el[100000];
int color[100000];
int max;

void co(int v, int p, int c){
	int l= el[v], i;
	if(l>max) max=l;
	int j=0;
	for(i=0; i<l; i++){
		if(j==c) j++;
		int r = es[v][i][1];
		if(r!=p){
			color[es[v][i][0]]=j;
			co(r, v, j);
			j++;
		}
	}
}

int a[100000][2];
int main(void){
	scanf("%d", &n);
	for(i=0; i<n-1; i++){
		a[i][0]=nextpint()-1;
		a[i][1]=nextpint()-1;
		el[a[i][0]]++;
		el[a[i][1]]++;
	}
	int ne=0;
	for(int i=0; i<n; i++){
		es[i]=(int(*)[2])qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<n-1; i++){
		int A=a[i][0];
		int B=a[i][1];
		es[A][el[A]][0]=i;
		es[A][el[A]++][1]=B;
		es[B][el[B]][0]=i;
		es[B][el[B]++][1]=A;
	}
	max=0;
	co(0, -1, -1);
	printf("%d\n", max);
	for(i=0; i<n-1; i++){
		printf("%d\n", color[i]+1);
	}
}


Measured memory_bytes: 7168
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((s (coerce (read-line) 'simple-base-string))
         (n (length s))
         (k (read)))
    (declare (uint31 k))
    (labels ((calc-dist (c)
               (if (char= #\a c)
                   0
                   (- 123 (char-code c)))))
      (declare (inline calc-dist))
      (dotimes (i n)
        (let ((dist (calc-dist (aref s i))))
          (when (<= dist k)
            (decf k dist)
            (setf (aref s i) #\a))))
      (setf (aref s (- n 1))
            (code-char (+ 97 (rem (- (+ (char-code (aref s (- n 1))) k) 97) 26))))
      (write-line s))))

#-swank(main)


Measured memory_bytes: 10728
// Problem : F - Enclose All
// Contest : AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_f
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vp vector<pair<int,int>>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
double fin(pair<double,double> p1,pair<double,double> p2)
{
	return sqrt((p1.f-p2.f)*(p1.f-p2.f)*1.0+(p1.se-p2.se)*(p1.se-p2.se)*1.0);
}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double n;
cin>>n;
vector<pair<double,double>> v(n);
double xp=0,yp=0;
for(int i=0;i<n;i++){
cin>>v[i].f>>v[i].se;xp+=v[i].f;yp+=v[i].se;}
xp/=n;yp/=n;
//cout<<xp<<" "<<yp<<"\n";
double c=0.1;
int t=30000;
int index=0;
while(t--)
{
	double dis_max=0;
	for(int i=0;i<n;i++)
	{
		double dis=fin(v[i],{xp,yp});//cout<<dis<<" "<<i<<"\n";
		if(dis>dis_max)
		{
			dis_max=dis;
			index=i;
		}
	}
	xp-=(xp-v[index].f)*c;
	yp-=(yp-v[index].se)*c;
	c*=0.999;
}
//cout<<xp<<" "<<yp<<"\n";
printf("%.10f",fin(v[index],{xp,yp}));
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
i = input()
j = i.split()
num_balls = int(j[0])
num_colors = int(j[1])
product = num_colors
if(num_balls > 1 and num_colors == 1):
  print(0)
else:
  for i in range(1, num_balls):
    product *= (num_colors - 1)
  print(product)

Measured memory_bytes: 9120
n,a=map(int,input().split())
x=list(map(int,input().split()))
dic={}
dic2=dic.copy()
for i in range(n):
  for j in dic:
    if j+x[i]-a in dic2:
      dic2[j+x[i]-a]+=dic[j]
    else:
      dic2[j+x[i]-a]=dic[j]
  if x[i]-a in dic2:
    dic2[x[i]-a]+=1
  else:
    dic2[x[i]-a]=1
  dic=dic2.copy()
if 0 in dic:
  print(dic[0])
else:
  print(0)

Measured memory_bytes: 68732
#ifndef ___Class_RMQ
#define ___Class_RMQ
 
// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>
 
// ------ RMQ Class ------ //
template<typename Type> class RMQ {
private:
	unsigned size_; std::vector<Type> dat;
	inline Type query_(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return std::numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat[k];
		Type lc = query_(a, b, (k << 1), l, (l + r) >> 1);
		Type rc = query_(a, b, (k << 1) + 1, (l + r) >> 1, r);
		return std::min(lc, rc);
	}
public:
	RMQ() : size_(0), dat(std::vector<Type>()) {};
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RMQ(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
		}
	}
	inline Type query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
 
#endif
 
#include<iostream>
#include<limits>
#include<algorithm>
#include<cstdio>
using namespace std;
 
long long D[5500][5500], a[5500], b[220][5500], n, m;
RMQ<pair<long long, long long>> E(5500);
inline void add(long long ax, long long ay, long long bx, long long by, long long c) {
	D[ax][ay] += c; D[bx + 1][by + 1] += c; D[bx + 1][ay] -= c; D[ax][by + 1] -= c;
}
inline void solve(int r, int p, int q) {
	if (p > q)return;
	pair<long long, long long>T = E.query(p, q + 1);
	add(p, T.second, T.second, q, -T.first);
	solve(r, p, T.second - 1);
	solve(r, T.second + 1, q);
}
int main() {
	cin >> n >> m; for (int i = 1; i <= n - 1; i++)cin >> a[i];
	for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++)scanf("%d",&b[j][i]); }
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++)E.update(j, make_pair(-b[i][j], j));
		solve(i, 1, n);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)D[i][j] += D[i][j - 1];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)D[i][j] += D[i - 1][j];
	}
	long long maxn = 0;
	for (int i = 1; i <= n; i++) {
		long long G1 = 0;
		for (int j = i; j <= n; j++) {
			maxn = max(maxn, D[i][j] - G1);
			G1 += a[j];
		}
	}
	cout << maxn << endl;
	return 0;
}

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

int main(){

  string s;
  while(1){
  cin >> s;
  if(s == "#")break;
  int ans = 0;
  int now,cmp = -1;
  for(int i = 0;i < (int)s.size();i++){
    if(s[i] =='q'||s[i] =='w'||s[i] =='e'||s[i] =='r'||s[i] =='t'||s[i] =='a'||s[i] =='s'||s[i] =='d'||s[i] =='f'||s[i] =='g'||s[i] =='z'||s[i] =='x'||s[i] =='c'||s[i] =='v'||s[i] =='b' )now = 1;
    else now = 0;
    if(now != cmp)ans++;
    cmp = now;

}
  cout << ans - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){
		cin >> a[i];
	}

	//

	ll ans = 0;
	ll minisum = a[0];

	PREP(i, 1, n){
		ans += (minisum * a[i]) % MOD;
		ans %= MOD;
		minisum += a[i];
		minisum %= MOD;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
 int main(void){    
 int N,M,i,j,A[1000],c,count[1000],max_count=0,max_game=-1;  
   scanf("%d%d",&N,&M);  
     for(i=0;i<N;i++){  
       scanf("%d",&A[i]);          
   count[i]=0;   
  }    
 for(j=0;j<M;j++){   
      scanf("%d",&c);   
      for(i=0;i<N;i++){     
        if(A[i]<=c){count[i]++;break;}   
      }     
}    
   for(i=0;i<N;i++){        
 if(max_count<count[i]){    
         max_count=count[i];     
        max_game=i;      
   }    
 }      
 printf("%d\n",max_game+1);
return 0;
 } 

Measured memory_bytes: 604
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

int main(){
	migmig;
	int n;
	cin>>n;
	map<string,ll>mp;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll sum=0;
	for(auto i: mp){
	    ll x=(i.second*(i.second-1))/2;
	    sum+=x;
	}
	cout<<sum;
	return 0;
}



Measured memory_bytes: 11264
N=int(input())
a=list(map(int, input().split()))
a.sort()
buf=0
mi=float("inf")
for i in range(a[0],a[N-1]+1):
    for j in range(N):
        buf=buf+pow(a[j]-i,2)
    if buf<mi:
        mi=buf
    buf=0
print(int(mi))

Measured memory_bytes: 38640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  vector<vector<pair<int, int> > > graph(n);
  REP(i, n - 1) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b, i);
    graph[b].emplace_back(a, i);
  }
  vector<int> idx(n);
  iota(ALL(idx), 0);
  sort(ALL(idx), [&](int l, int r) { return graph[l].size() > graph[r].size(); });
  vector<int> ans(n - 1);
  function<void(int, int, int)> dfs = [&](int par, int ver, int par_col) {
    // cout << ver << endl;
    int color = (par_col == 1 ? 2 : 1);
    for (auto &pr : graph[ver]) {
      if (pr.first != par) {
        ans[pr.second] = color;
        dfs(ver, pr.first, color);
        ++color;
        if (color == par_col) ++color;
      }
    }
  };
  dfs(-1, idx[0], -1);
  cout << graph[idx[0]].size() << '\n';
  REP(i, n - 1) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

int main(){
  int A, B;
  cin >> A >> B;

  cout << A * B - (A + B - 1) << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  auto itr = unique(a.begin(),a.end());
  a.erase(itr,a.end());
  n = a.size();
  if(n==1) {
    cout << 1 << endl;
    return 0;
  }
  int c=1;
  bool u = a[0]<a[1];
  repeat(i,1,n) {
    if(u) {
      if(a[i]<a[i-1]) {
        c++;
        if(i+1<n) {
          u = a[i]<a[i+1];
        }
      }
    } else {
      if(a[i]>a[i-1]) {
        c++;
        if(i+1<n) {
          u = a[i]<a[i+1];
        }
      }
    }
  }
  cout << c << endl;
  return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    REP(i, 3){
        if(s[i]=='7'){
            cout << "Yes" << "\n ";
            return 0;
        }
    }
    
    cout << "No" <<"\n";

    return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> str(N);
    for (int i = 0; i < N;i++){
        cin >> str[i];
    }

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (int i = 0; i < N;i++){
        if(str[i]=="AC"){
            ac++;
        }
        else if(str[i]=="WA"){
            wa++;
        }
        else if(str[i]=="TLE"){
            tle++;
        }
        else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re;

    return 0;
}

Measured memory_bytes: 6420
#include <stdio.h>

int main(void) {
	int i,j,n,m,tg[128],sc[128]={0},w,a,b;
	scanf("%d",&n);
	scanf("%d",&m);
	for(i = 1;i <= m;i++){scanf("%d",&tg[i]);}
	for(i = 1;i <= m;i++){
		w = 0;
		for(j = 1;j <= n;j++){
			scanf("%d",&a);
			if(tg[i] == a){sc[j]++;}
			else{w++;}
		}
		b = tg[i];
		sc[b]+=w;
	}
	for(i = 1;i <= n;i++){
		printf("%d\n",sc[i]);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = N / 1000;
        int B = N % 1000 / 100;
        int C = N % 100 / 10;
        int D = N % 10;
        double ANS[] = new double[3];
        String tmp[] = new String[3];
        int ans;
        lavel:
        for (ANS[0] = 1; 2 >= ANS[0]; ANS[0]++) {
            for (ANS[1] = 1; 2 >= ANS[1]; ANS[1]++) {
                for (ANS[2] = 1; 2 >= ANS[2]; ANS[2]++) {
                    ans = (int) (A + (Math.pow(-1, ANS[0])) * B + (Math.pow(-1, ANS[1])) * C + (Math.pow(-1, ANS[2])) * D);
                    if (ans == 7) {
                        break lavel;
                    }
                }

            }
        }
        for (int i = 0; 3 > i; i++) {
            if (ANS[i] == 1) {
                tmp[i] = "-";
            } else {
                tmp[i] = "+";
            }
        }
        System.out.println(A + tmp[0] + B + tmp[1] + C + tmp[2] + D + "=7");
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,dp[200005];
vector<ll>v[200005];
void go(ll x,ll par){
    for(int i=0; i<v[x].size(); i++){
        if(v[x][i] != par){
            go(v[x][i] , x);
            dp[x] ^= dp[v[x][i]] + 1;
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    
    for(int i=1; i<n; i++){
        int x,y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    
    go(1 , 0);
    
    if(dp[1])
        cout << "Alice";
    else
        cout << "Bob";
    
    
    return 0;
}


Measured memory_bytes: 14208
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long int ll;
int main(void){
    string s ;
    cin >> s ;
    string c ;
   
   if(s[2] == s[3] && s[4] == s[5]){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }

    return 0;
}

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

int main(void){
    register int i;
    int n;
    scanf("%d",&n);
    char kind[n][11];
    for(i = 0;i < n;i++)scanf("%s",kind[i]);
    qsort(kind,n,11,strcmp);
    int ans = 1;
    for(i = 1;i < n;i++)if(strcmp(kind[i-1],kind[i]))ans++;
    printf("%d",ans);
}


Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A < B) {
  	cout << N * A << endl;
  } else {
  	cout << B << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 

int32_t main(){
  fast; 
  
    int n; cin>>n; 
    vi a(n); 
    for(int i=0;i<n;i++) cin>>a[i]; 

    SORT(a); 
    
    int loc=0; 
    for(int i=1;i<n;i++){
      if(a[i]==a[i-1]){
        loc=1;break;  
      }
    } 

    if(loc)cout<<"NO"<<endl; 
    else cout<<"YES"; 
}

Measured memory_bytes: 1792
num = int(input())

number = input()
number = [int(x) for x in number.split(" ")]

def two(number,num,flag):
  for i in range(num):
    if number[i] % 2 !=0:
      flag = False
    number[i] /= 2

  return number,flag

flag = True
count = 0
while flag:
  number , flag =two(number,num,flag)
  if flag == True:
    count += 1
 

print(str(count))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
//int freq[1000000+5];


int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int q;
	cin>>q;
	q=(q+1)/2;
	q--;
	cout<<q;
    return 0;
}




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

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

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

    vector<int> A(N);

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

    map<int,int> left,right;

    for (int i=0; i<N; i++){
        if (i == 0) {
            continue;
        }
        else if (i == 1) {
            left[i] = A[0];
        }
        else {
            left[i] = gcd(left[i-1],A[i-1]);
        }
    }
    for (int i=N-1; i>-1; i--){
        if (i == N-1) {
            continue;
        }
        else if (i == N-2) {
            right[i] = A[i+1];
        }
        else {
            right[i] = gcd(right[i+1],A[i+1]);
        }
    }

    int n,max=0;
    for (int i=0; i<N; i++){
        if (i==0) n = right[i];
        else if (i==N-1) n = left[i];
        else n = gcd(left[i],right[i]);

        if (n > max) max = n;
    }

    cout << max << endl;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans = "No";
  if(abs(a-c) <= d) ans = "Yes";
  else if(abs(a-b) <= d && abs(b-c) <= d) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
//B

#include <bits/stdc++.h>

using namespace std;

int main(){
	int x,y;
	cin >> x >> y;

	if ((4*x) >= y && y%2 == 0 && (2*x) <= y) { cout << "Yes" << endl;}
	else { cout << "No" << endl;}


	return 0;
}

Measured memory_bytes: 3636
fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<u32>();
    v.sort();

    if n % 2 != 0 {
        for i in 0..n {
            //println!("{} {} {}", i, v[i], (i as u32 + 1) / 2 * 2);
            if (i as u32 + 1) / 2 * 2 != v[i] {
                println!("0");
                return;
            }
        }
    } else {
        for i in 0..n {
            //println!("{} {} {}", i, v[i], (i as u32 + 2) / 2 * 2);
            if (i as u32 + 2) / 2 * 2 - 1 != v[i] {
                println!("0");
                return;
            }
        }
    }
    let mut ans = 1;
    for _ in 0..n / 2 {
        ans *= 2;
        ans %= 1000000007;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define ll long long
#define pb push_back
#define ull unsigned long long
#define MAX 1000000
int  ar[MAX];

int main()
{
    ll n,k,cnt=0,r;
    cin>>n>>k;
    while(n!=0)
    {
        r=n%k;
        cnt++;
        n/=k;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
eval"_,*A="+gets.split*?,
s=*$<
q=[]
f=->i{s[i]&.chop&.bytes{|x|A[y=s[i].sum-x-75]+=1;q.<<""<<y+65;f[i+1]if~0<A[x-=65]-=1;A[x]+=1;A[y]-=1;q.pop}||puts(:Yes,q)+exit}
f[0]
puts:No

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 1) cout << "Odd" << endl;
  else cout << "Even" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
h, n = map(int, input().split())
ab = []
ma = 0
for i in range(n):
    a, b = map(int, input().split())
    ma = max(ma, a)
    ab.append([a, b])
ab.sort(reverse=True)
INF = 10 ** 9
dp = [[INF for i in range(h + ma + 1)] for j in range(n+1)]
ans = INF
for i, (a, b) in enumerate(ab):
    dp[i + 1][0] = 0
    for j in range(a, h + ma + 1):
        # print(dp[i + 1][j - a] + b)
        dp[i + 1][j] = min(dp[i + 1][j - a] + b, dp[i][j])
        if j >= h:
            ans = min(ans, dp[i + 1][j])
# print(dp)
print(ans)

Measured memory_bytes: 133640
#include <bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
using P=pair<int,int>;
const ll INF=1<<30;
const ll LINF=1LL<<60;
const double EPS=1e-11;
int main(){
    int n,k;cin>>n>>k;
    vector<ll> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    sort(h.begin(),h.end());
    ll ans=LINF;
    for(int i=0;i<n-k+1;i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

int A, B;
int C[2100][2100];
int pre[2100][2100];
int pp[2100][2100];
int dp[2100][2100];
#define P 1000000007

int F(int x, int y) {
    int tmp = 0;
    for (int j = 0; j <= min(x, y); j++)
        tmp = (tmp + 1LL * C[y][j] * dp[x - j][j]) % P;
    return tmp;
}

int main() {
    scanf("%d%d", &A, &B);
    for (int i = 0; i <= 2000; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
        }
        pre[i][0] = C[i][0];
        for (int j = 1; j <= i; j++)
            pre[i][j] = (pre[i][j - 1] + C[i][j]) % P;
    }
    for (int i = 0; i <= 2000; i++) {
        pp[i][0] = pre[i][0];
        for (int j = 1; j <= i; j++)
            pp[i][j] = (pp[i][j - 1] + pre[i][j]) % P;
    }
    for (int i = 0; i <= A; i++)
        for (int j = 0; j <= B; j++)
            // if (i + j == A) 
        {
                if (j == 0)
                    dp[i][j] = 1;
                else {
                    dp[i][j] = 0;
                    if (i <= j - 1)
                        dp[i][j] = pp[j - 1][i];
                    else
                        dp[i][j] = (pp[j - 1][j - 1] + 1LL * pre[j - 1][j - 1] * (i + 1 - (j))) % P;
                    // for (int p = 0; p <= i; p++) {
                        // dp[i][j] = pp[j - 1][min(p, j - 1)];
                    // }
                }
            }
    // printf("%d\n", dp[2][2]);
    int ans = 0;
    for (int p = 0; p <= A; p++) {
        ans = (ans + F(p, B - 1)) % P;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 68352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
	char c=getchar();ll t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
ll a,b,c,d,alfa;
inline ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
int main(){
	a=read(),b=read(),c=read(),d=read();
	alfa=c/gcd(c,d)*d;
	ll lca=a/c,lcb=b/c;
	ll lda=a/d,ldb=b/d;
	ll len=b-a+1;
	if(a%c==0||a%d==0)len--;
	printf("%lld\n",len-(lcb-lca)-(ldb-lda)+(b/alfa-a/alfa));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int N, M;
map<string, int> items;
map<string, vector<string>> recipe;

int dfs(string s){
	int res = 0;
	if(recipe[s].empty()){
		return items[s];
	}
	else{
		REP(i,recipe[s].size()){
			res += min(items[recipe[s][i]], dfs(recipe[s][i]));
		}
		res = min(res, items[s]);
	}
	return res;
}

int main(){
	while(cin >> N && N){
		string s;
		int n;
		REP(i,N){
			cin >> s >> n;
			items[s] = n;
		}
		cin >> M;
		string c, q;
		int k;
		REP(i,M){
			cin >> c >> k;
			vector<string> tmp;
			REP(j,k){
				cin >> q;
				tmp.push_back(q);
			}
			recipe[c] = tmp;
		}
		string goal;
		cin >> goal;
		cout << dfs(goal) << endl;
	}
}

Measured memory_bytes: 1240
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
a=array(N)
N.times do|i|
    a[i]=gets.to_i
end
if a[0].nonzero?
    puts "-1"
    exit
end
(N-1).times do|i|
    unless a[i+1]-a[i]<=1
        puts "-1"
        exit
    end
end
prev=-1
ans=0
kind=Hash.new(0)
kind[-1]=1
N.times do|i|
    if prev==a[i] 
        kind[a[i]]+=1
    elsif prev+1==a[i]
        ans+=(kind[prev]-1)*prev
        kind[a[i]]+=1
        prev=a[i]
    else
        ans+=prev*kind[prev]
        kind=Hash.new(0)
        kind[a[i]]+=1
        prev=a[i]
    end
end
ans+=prev*kind[prev]
puts ans

Measured memory_bytes: 25328