akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<queue>
using namespace std;
char moji,work;
int t[52],at[26],bt[26],ac,bc;
queue < char > a,b,c,d,x,ans;
int ch(char moji){
  if('a'<=moji&&moji<='z')return moji-'a';
  else return moji-'A'+26;
}
void push_down(){
  if(a.empty())a.push(' ');
  if(work!=' ')c.push(work);
  work=a.front();
  a.pop();
  //cout<<1<<endl;
}
void push_right(){
  if(b.empty())b.push(' ');
  if(work!=' ')d.push(work);
  work=b.front();
  b.pop();
  //cout<<2<<endl;
}
int main(){
  while(1){
    ac=bc=0;
    work=' ';
    for(int i=0;i<52;i++)t[i]=0;
    scanf("%c",&moji);
    if(moji=='-')break;
    a.push(moji);
    t[ch(moji)]=1;
    
    while(1){
      scanf("%c",&moji);
      if(moji=='\n')break;
      a.push(moji);
      t[ch(moji)]=1;
    }
    while(1){
      scanf("%c",&moji);
      if(moji=='\n')break;
      b.push(moji);
      t[ch(moji)]=2;
    }
    while(1){
      scanf("%c",&moji);
      if(moji=='\n')break;
      x.push(moji);
    }

    while(!x.empty()){
      moji=x.front();x.pop();
      if(t[ch(moji)]==1){

	while(work!=moji){

	  if(work==' '){
	    push_down();
	  }else{
	    push_right();
	  }
	}

	push_down();

      }else{

	while(work!=moji){
	  push_right();
	}
       
	push_down();
      }
    }
    while(work!=' ')push_right();
    
    while(!d.empty()){
      cout<<d.front();
      d.pop();
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010,mod=998244353;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
inline int qmo(int x){return x+(x>>31?mod:0);}
int n,m,el,head[maxn],to[maxn*2],nxt[maxn*2],w[maxn*2],col[maxn],cnt[3],ecnt;
ll ans;
bool flag;
inline void add(int u,int v,int w_){
	to[++el]=v;nxt[el]=head[u];head[u]=el;w[el]=w_;
}
void dfs(int u){
	cnt[col[u]]++;
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];
		ecnt++;
		if(col[v]==-1) col[v]=(col[u]+w[i]+3)%3,dfs(v);
		else if(col[v]!=(col[u]+w[i]+3)%3) flag=false;
	}
}
int main(){
	n=read();m=read();
	FOR(i,1,m){
		int u=read(),v=read();
		add(u,v,1);add(v,u,-1);
	}
	MEM(col,-1);
	FOR(i,1,n) if(col[i]==-1){
		col[i]=0;
		flag=true;
		cnt[0]=cnt[1]=cnt[2]=ecnt=0;
		dfs(i);
		if(flag){
			if(cnt[0] && cnt[1] && cnt[2]) ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[0]*cnt[2]+1ll*cnt[1]*cnt[2];
			else ans+=ecnt/2; 
		}
		else{
			int tot=cnt[0]+cnt[1]+cnt[2];
			ans+=1ll*tot*tot;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 13092
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int H, W, h, w; cin >> H >> W >> h >> w;
    vector<vll> field(H, vll(W));
    if(h == 1 and w == 1){
        cout << "No" << endl;
        return 0;
    }

    rep(y, H){
        rep(x, W){
            if(y % h == 0 and x % w == 0){
                field[y][x] = (ll)1e9 - 1;
            }
            else if(y % h == h - 1 and x % w == w - 1){
                field[y][x] = -(ll)1e9;
            }
        }
    }

    ll sum = 0LL;
    rep(y, H){
        rep(x, W){
            sum += field[y][x];
        }
    }

    if(sum >= 1LL){
        cout << "Yes" << endl;
        rep(y, H){
            rep(x, W){
                cout << (x == 0 ? "":" ") << field[y][x];
            }
            cout << endl;
        }
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SAT") cout<<"1"<<endl;
	if(s=="SUN") cout<<"7"<<endl;
	if(s=="MON") cout<<"6"<<endl;
	if(s=="TUE") cout<<"5"<<endl;
	if(s=="WED") cout<<"4"<<endl;
	if(s=="THU") cout<<"3"<<endl;
	if(s=="FRI") cout<<"2"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;
int p[501],r[501];
void init(){rep(i,501)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

void Main() {
  int n,m;
  cin >> n >> m;
  PP a[m];
  rep(i,m) cin >> a[i].S.F >> a[i].S.S >> a[i].F;
  sort(a,a+m);
  init();
  int M=0;
  vector<int> v;
  rep(i,m) {
    if(same(a[i].S.F,a[i].S.S)) continue;
    unite(a[i].S.F,a[i].S.S);
    M+=a[i].F;
    v.pb(i);
  }
  int ans=0,cnt=0;
  rep(i,v.size()) {
    init();
    int sum=0;
    rep(j,m) {
      if(v[i]==j) continue;
      if(same(a[j].S.F,a[j].S.S)) continue;
      unite(a[j].S.F,a[j].S.S);
      sum+=a[j].F;
    }
    if(sum!=M) {
      cnt++;
      ans+=a[v[i]].F;
    }
  }
  pr(cnt,ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N, K, S;
    cin >> N >> K >> S;

    vector<int> ret(N, 0);

    rep(i, N) {
        if (i < K) ret[i] = S;
        else {
            if (S == 1000000000) {
                ret[i] = 1;
            } else {
                ret[i] = S + 1;
            }
        }
    }

    rep(i, N) cout << ret[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

struct data_t {
	bool up;
	bool down;
	bool left;
	bool right;
	bool check;
};

int main(void) {
	int w,h;
	cin >> w >> h;

	while( w != 0 || h != 0 ) {

		vector < vector<data_t> > maze(h+2, vector<data_t>(w+2));
		for (int i = 0; i < h+2; i++) {
			for (int j = 0; j < w+2; j++) {
				if (i==0||i==h+1||j==0||j==w+1) {
					maze[i][j].up = false;
					maze[i][j].down = false;
					maze[i][j].left = false;
					maze[i][j].right = false;
					maze[i][j].check= true;
				}
				else {
					maze[i][j].up = true;
					maze[i][j].down = true;
					maze[i][j].left = true;
					maze[i][j].right = true;
					maze[i][j].check= false;

					if ( i == 1 ) {
						maze[i][j].up = false;
					}
					if ( j == 1 ) {
						maze[i][j].left = false;
					}
					if ( i == h ) {
						maze[i][j].down = false;
					}
					if ( j == w ) {
						maze[i][j].right = false;
					}
				}
			}
		}

		bool mode_w = true;
		int temp;
		int count = 1;
		int l = 1;
		for (int i = 0; i < ( ((w-1)*h)+(w*(h-1)) ); i++) {
			cin >> temp;
			if (mode_w) {
				if (temp == 1) {
					maze[l][count].right = false;
					maze[l][count+1].left = false;
				}
				count++;
				if (count == w) {
					count = 1;
					mode_w = false;
				}
			}
			else {
				if (temp == 1) {
					maze[l][count].down = false;
					maze[l+1][count].up = false;
				}
				count++;
				if (count == w+1) {
					count = 1;
					mode_w = true;
					l++;
				}
			}
		}

		std::queue<int> qh,qw,d;
		qh.push(1);
		qw.push(1);
		d.push(1);
		int hn,wn;
		int spl;
		int dn = 1;
		int count_d = 0;
		bool goal = false;

		while ( !(goal) && !(qw.empty()) ) {
			hn = qh.front();
			wn = qw.front();
			dn = d.front();
			qh.pop();
			qw.pop();
			d.pop();
			count_d++;

			maze[hn][wn].check = true;

			if ( hn == h && wn == w ) {
				cout << dn << endl;
				goal = true;
			}

			if ( maze[hn][wn].up && !(maze[hn-1][wn].check) ) {
				qh.push(hn-1);
				qw.push(wn);
				d.push(dn+1);
				maze[hn-1][wn].check = true;
			}
			if ( maze[hn][wn].down && !(maze[hn+1][wn].check) ) {
				qh.push(hn+1);
				qw.push(wn);
				d.push(dn+1);
				maze[hn+1][wn].check = true;
			}
			if ( maze[hn][wn].left && !(maze[hn][wn-1].check) ) {
				qh.push(hn);
				qw.push(wn-1);
				d.push(dn+1);
				maze[hn][wn-1].check = true;
			}
			if ( maze[hn][wn].right && !(maze[hn][wn+1].check) ) {
				qh.push(hn);
				qw.push(wn+1);
				d.push(dn+1);
				maze[hn][wn+1].check = true;
			}
		}

		if (!(goal)) {
			cout << 0 << endl;
		}

		cin >> w >> h;
	}

	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a,b;
signed main()
{
	cin>>a>>b;
	int l=max((a*100+7)/8,b*10);
	int r=min(((a+1)*100+7)/8-1,(b+1)*10-1);
	if(l<=r)
		printf("%lld",l);
	else
		printf("-1");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	string s;
	cin>>s;
	if((int)s.length()%2==1){cout<<"No";return 0;}
	for(int i=0;i<(int)s.length();i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			cout<<"No";
			return 0;
		}
	}	
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    for i,_ in enumerate(S):
        sub = S[i:i+2]
        if sub[0]==sub[-1] and len(sub)==2:
            print(i+1,i+2)
            return
        sub = S[i:i+3]
        if sub[0]==sub[-1] and len(sub)==3:
            print(i+1,i+3)
            return
        
    print(-1,-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5648
# coding: utf-8
# Your code here!

N = int(input())
A = input().split()
pre_a = 0
sum = 0
for i in range(N):
    a = int(A[i])
    if (pre_a != 0 and a < pre_a):
        diff = pre_a - a
        sum += diff
    else:
        pre_a = a
print(sum)


Measured memory_bytes: 25224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}

void extgcd(ll a, ll b, ll& x, ll& y)
{
	if (b != 0) { extgcd(b, a % b, y, x); y -= a / b * x; }
	else { x = 1; y = 0; }
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, k; cin >> n >> k;
	vi v(n); cin >> v;
	ll g = v[0];
	for (auto i : v)
	{
		g = gcd(g, i);
	}
	ll mx = *max_element(ALL(v));
	if (k <= mx && k % g == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int A, B;
	vector<int> ANS;
	cin >> A >> B;

	ANS.push_back(A + B);
	ANS.push_back(A - B);
	ANS.push_back(A * B);
	sort(ANS.begin(), ANS.end());
	
	cout << ANS.back() << endl;

}

Measured memory_bytes: 256
N = int(input())

a = []

# 1
a.append(1)

# 6**n
b = 6
while b <= N:
    a.append(b)
    b *= 6

# 9**n
b = 9
while b <= N:
    a.append(b)
    b *= 9

a.sort()

dp = [N] * (N+1)
dp[0] = 0
for i in range(N):
    for j in a:
        if i+j > N:
            break
        dp[i+j] = min(dp[i]+1, dp[i+j])
print(dp[N])


Measured memory_bytes: 9656
/*
  "Piece of shit. Stupid piece of shit. I'm a real stupid piece
   of shit. But I know I'm a piece of shit. That at least makes
   me better than all the pieces of shit that don't know they're
   pieces of shit. Or is it worse?"
     - BoJack F. Horseman
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>
#include<random>
#include<fstream>
#include<chrono>

#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define maxpq        priority_queue<int>
#define minpq        priority_queue<int,vi,greater<int>>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25);
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9+7;
ld EPS = 1e-12;
const int INF32 = 0x3F3F3F3F;
const int INF = 0x3F3F3F3F3F3F3F3F;
const int crng = rng();

signed main()
{
    VR46 ifstream fin("input.txt"); ofstream fout("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU TEST CASE BNAKE TEST KRLE; CHECK BOUNDS;
    // int t; cin>>t; rep(test,1,t)
    {
        int h, n;
        cin>>h>>n;
        vi a(n);
        for(auto &i:a) cin>>i;
        int sm = 0;
        for(auto i:a) sm += i;
        if( sm>=h ) cout<<"Yes\n";
        else cout<<"No\n";
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;

    // *( hsh.find_by_order(k) ) kth smallest, from 0
    // hsh.order_of_key(k) num of ele str less than k
    // change less to less_equal for multiset pbds
    // Create struct HASH; Use milf(x) for every hashmap; Use CRNG xor;
}

Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n*n) ;
	for(auto &i:a) cin >> i ;
	vvll cnt(n,vll(n,0)) ;
	for(ll i=0;i<n;i++) for(ll j=0;j<n;j++) cnt.at(i).at(j) = min(min(i,n-1-i),min(j,n-1-j)) ;
	vvll ok(n,vll(n,1)) ;
	vll dy = {-1,0,1,0} ;
	vll dx = {0,1,0,-1} ;
	queue<int> q ;
	ll ans = 0 ;
	for(int i=0;i<n*n;i++){
		int y = (a.at(i)-1)/n ;
		int x = (a.at(i)-1)%n ;
		ans += cnt.at(y).at(x) ;
		ok.at(y).at(x) = 0 ;
		q.push(y*n+x) ;
		while(!q.empty()){
			y = q.front()/n ;
			x = q.front()%n ;
			q.pop() ;
			int d = cnt.at(y).at(x)+ok.at(y).at(x) ;
			for(int j=0;j<4;j++){
				int ny = y+dy.at(j) ;
				int nx = x+dx.at(j) ;
				if(ny>=0&&ny<n&&nx>=0&&nx<n&&d<cnt.at(ny).at(nx)){
					cnt.at(ny).at(nx) = d ;
					q.push(ny*n+nx) ;
				}
			}
		}
	}
	cout << ans << endl ;
}


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

int main()
{
  int N, M;cin >> N >> M;
  priority_queue<ll> goods;
  rep(i, N) {
    ll A; cin >> A;
    goods.push(A);
  }

  rep(i, M) {
    ll price = goods.top();
    goods.pop();
    goods.push(price / 2);
  }
  ll ans;
  while (!goods.empty()) {
    ans += goods.top();
    goods.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1400
n=int(input())

stack=['a']
alpahbet=[chr(i) for i in range(97, 97+26)]

if n==1:
    print('a')
else:
    cnt=1
    
    while cnt<n:
        nextstack=[]

        while len(stack):
            curs=stack.pop()
            pat=set()
            for c in alpahbet:
                ret=0
                for j in range(cnt):
                    if curs[j]==c:
                        ret=ret*2
                    else:
                        ret=ret*2+1
                
                if ret in pat:
                    continue

                pat.add(ret) 
                nextstack.append(curs+c)
        
        stack=sorted(nextstack)
        cnt+=1
    
    for s in stack:
        print(s)



Measured memory_bytes: 13516
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define maxn 100010
ll n,a[maxn],b[maxn],m;

int cmp(const void *x,const void *y){
	return (*(ll*)x-*(ll*)y);
}

int chk_id(ll x){
	int l=1,r=n,mid,ans=n+1;
	for(;l<=r;){
		mid=l+r>>1;
		if(x<=a[mid])r=(ans=mid)-1;
		else l=mid+1;
	}
	return ans;
}

int chk(ll mid){
	ll cnt=0;
	int i;
	for(i=1;i<=n;++i)
		cnt+=n+1-chk_id(mid-a[i]);
	if(cnt>=m)return 1;
	else return 0;
}

void solve(){
	int i;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;++i)
		scanf("%lld",a+i);
	qsort(a+1,n,sizeof(ll),cmp);
	
	for(i=1;i<=n;++i)
		fprintf(stderr,"%d ",a[i]);
	fprintf(stderr,"\n");
	for(i=1;i<=n;++i)
		b[i]=b[i-1]+a[i];
	ll mid,l=0,r=(ll)1e15,res=-1;
	for(;l<=r;){
		mid=l+r>>1;
		if(chk(mid))l=(res=mid)+1;
		else r=mid-1;
	}
	
	ll ans=0;
	for(i=1,r;i<=n;++i,m-=r){
		r=n+1-chk_id(res-a[i]);
		ans+=(b[n]-b[n-r])+a[i]*r;
	}
	printf("%lld\n",ans+m*res);
} 
int main(){
	solve();
	
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

struct SegmentTree{
    private:
    int n;
    vector<int> node;
    
    
    public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;while(n < sz)n *= 2;
        node.resize(2*n-1,INF);
        
        for(int i=0;i<sz;i++)node[i+n-1] = v[i];
        for(int i=n-2;i>=0;i--)node[i]=min(node[2*i+1],node[2*i+2]);
    }
    
    //min
    void update(int x,int val){
        //最下段のノードにアクセス
        x+=(n - 1);
        node[x]=val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }
    //[a,b)中の最小の要素
    int getmin(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0)r = n;
        if(r <= a || b <= l)return INF;
        if(a <= l && r <= b)return node[k];
        int vl = getmin(a,b,2*k+1,l,(l+r)/2);
        int vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};
//SegmentTree seg(vector<int>(N,INF));
//最小値を求めたいときは最大値で初期化

int N,Q;
 
signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>Q;
    SegmentTree seg(vint(N,(1ll<<31)-1));
    while(Q--){
        int c,x,y;
        cin>>c>>x>>y;
        if(c==0)seg.update(x,y);
        else cout<<seg.getmin(x,y+1)<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 500006
#define mod 1000000007
#define mod2 998244353
#define inf 1e18

int dp[2][100001];


int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif
    
    int n,W;

    cin >> n >> W;

    
    memset(dp,0,sizeof dp);
    int i,j;
    int w[n+1],v[n+1];
    for(i=1;i<=n;i++)
    {
        cin >> w[i] >> v[i];
    }

    

    for(i=1;i<=n;i++)
    {
        int p=i%2;
        for(j=1;j<=W;j++)
        {
            if(j>=w[i])
            {
                dp[p][j]=max(dp[1-p][j],dp[1-p][j-w[i]]+v[i]);
            }
            else
            {
                dp[p][j]=dp[1-p][j];
            }
        }
    }

    cout << dp[n%2][W] << endl;


}

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

int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (10%p == 0) { // 2,5
    ll ans = 0;
    rep(r,n) {
      if ((s[r]-'0') % p == 0) {
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define se second
#define fi first
bool fun(pair< int,string> p ,pair<int,string> p1 )
{
    if(p.fi != p1.fi )
        return (p.fi < p1.fi);
    else
        return  (p1.se > p.se);
}
int32_t main(){
    
    int n;
    cin>>n;
    vector<string>v;
  unordered_map<string,int>cn;
  string s[n+1];
  int maxx = 0;
  for(int i =0 ; i < n ; i ++){
    //   
      cin>>s[i];
      cn[s[i]]++;
      
      maxx = max(maxx,cn[s[i]]);
    //   if(cn[s]==1)v.pb(s);
  }
  
  
  
  vector<string>res;
  for(int i = 0 ; i < n;i++)
  {
      if(cn[s[i]] == maxx)
        {
            cn[s[i]] =0;
            res.pb(s[i]);
        }
  }
  
  sort(res.begin(),res.end());
  for(int i = 0; i < res.size()  ; i++)
    cout<<res[i]<<endl;
  
  
  
    
}

Measured memory_bytes: 28228
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    vll D;
    ll cnt=0;
    string ans = "No";

    rep(ni,N){
        cin >> A;
        cin >> B;
        D.push_back(A-B);
    }

    rep(ni,N){
        if(D[ni]==0) cnt++;
        else cnt = 0;

        if(cnt==3) ans ="Yes";
    }

    cout << ans << endl;

    

}

Measured memory_bytes: 3684
#pragma GCC optimize("O3", "unroll-loops")

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <limits>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

const int inf = (1 << 30) + 9e8;
const int MAXN = 1e5;
const int MAXN2 = 1e4;
const int P = 131;
const long long MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<bool> vb;

#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define all(a) a.begin(), a.end()
#define pb push_back
#define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define ppb pop_back
#define ppf pop_front
#define fs first
#define sd second
#define eb emplace_back

template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
std::mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    vi h(n);
    cin >> h;
    vi dp(n, inf);
    dp[0] = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (i == n - 2) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
            continue;
        }
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    // for (auto it : dp)
    //     cout << it << ' ';
    // cout << '\n';
    cout << dp[n - 1];
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    FAST;
    int q = 1;
    // cin >> q;
    // int st = clock();
    while (q--) {
        solve();
    }
    // int en = clock();
    // cout << en - st << "ms.";
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sim template < class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
    sim > typename enable_if< sizeof dud< c >(0) x 1, debug & >::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge< c > range(c i, c j) { return rge< c >{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef XOX
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair< b, c > d)
{
    ris << "" << d.first << " --> " << d.second << "";
}
sim dor(rge< c > d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ", "

#define F first
#define S second
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define all(v) (v).begin(), (v).end()
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie();                    \
    cout.tie()
#define min3(x, y, z) (x < y ? (x < z ? x : z) : (y < z ? y : z))
#define max3(x, y, z) (x > y ? (x > z ? x : z) : (y > z ? y : z))
#define MAX_N int(1e6 + 7)
#define MAX_M int(1e6 + 7)
#define MAX_V int(1e6 + 7)
#define oo int(1e9 + 217)
#define MOD int(1e9 + 7)
using ll = long long;
using vi = vector< int >;
using vl = vector< ll >;
using vpii = vector< pair< int, int > >;
using pii = pair< int, int >;

typedef tree<
    int,
    null_type,
    less< int >,
    rb_tree_tag,
    tree_order_statistics_node_update >
    oset;

void solve()
{
}

int main()
{
    fast;
    int t;
    cin >> t;
    if (t == 0)
        cout << 1;
    else
        cout << 0;
}

Measured memory_bytes: 3636
// ABC 055 D
#include<bits/stdc++.h>
 
using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n;
  cin >> n;
  long double ans=0.0;
  REP(i,n){
    long double x;
    str u;
    cin >> x >> u;
    if(u=="BTC") x *= 380000.0;
    ans += x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import(
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)

	if n == "A" {
		fmt.Println("T")
	} else if n == "C" {
		fmt.Println("G")
	} else if n == "G" {
		fmt.Println("C")
	} else if n == "T" {
		fmt.Println("A")
	}
}

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

ll lcm(ll a, ll b){
  return (a*b)/(__gcd(a, b));
}

int main(){
  ll a, b, c, d, div_c, div_d;
  cin >> a >> b >> c >> d;
  div_c = b/c-(a-1)/c;
  div_d = b/d-(a-1)/d;
  ll cnt = div_c + div_d - (b/lcm(c,d))+(a-1)/lcm(c,d);
  cout << b-a+1-cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A;

    int num;
    rep(i, 0, N){
        cin >> num;
        A.push_back(num);
    }

    int min_index = distance(A.begin(), min_element(A.begin(), A.end()));

    int ind_up=min_index;
    int ind_down=min_index;
    int ans = 0;
    if(N==K){
        ans=1;
    }else{
        int nm = N-1;
        int km = K-1;
        ans = (nm + (km-1))/(km);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 892
import re

n = [s for s in input()]
i = 0
renzoku = 0

for j in n:
    if (j == 'R'):
        i += 1 
    else:
        if(renzoku <= i):
            renzoku = i
        i = 0

if(renzoku < i):
   renzoku = i
print(renzoku)
    


Measured memory_bytes: 70396
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())

    a2 = list([ea - i - 1 for i, ea in enumerate(a)])
    a2.sort()
    n2 = n // 2
    r1 = sum([abs(ea2 - a2[n2]) for ea2 in a2])
    r2 = sum([abs(ea2 - a2[n2-1]) for ea2 in a2])
    print(min(r1, r2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 137948
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N)
  {
    cin >> A[i];
  }
  int m = 1000000000;
  rep(i,N-1)
  {
    m = min(m,gcd(A[i],A[i+1]));
  }
  cout << m << endl;
  return 0;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        PrintWriter out = new PrintWriter(System.out);
        out.println(help(s));
        out.flush();
    }
    static String help(String s){
        if(s.equals("zyxwvutsrqponmlkjihgfedcba")) return "-1";
        char[] a = s.toCharArray();
        int[] rec = new int[26];
        Arrays.fill(rec,-1);
        for(int i=0;i<a.length;i++) rec[a[i]-'a']=i;
        if(a.length<26){
            for(int i=0;i<26;i++){
                if(rec[i]==-1) return s+Character.toString((char)(i+'a'));
            }
            return "-1";
        }else{
            for(int start=24;start>=0;start--){
                if(a[start]=='z') continue;
                char cur = a[start];
                for(int i=cur-'a'+1;i<26;i++){
                    if(rec[i]>start){
                        return s.substring(0,start)+Character.toString((char)(i+'a'));
                    }
                }
            }
            return "-1";
        }
    }
}


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = min(A, B); i >= 0; i--) {
        if (A % i == 0 && B % i == 0) K--;
        if (K == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int n;
int m[3];
double dp[301][301][301];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    m[a-1]++;
  }
  for(int k = 0; k <= n; k++){
    for(int j = 0; j <= n; j++){
      for(int i = 0; i + j + k <= n; i++){
        if(i + j + k == 0) continue;
        dp[i][j][k] = (double) n / (i+j+k) + ((i ? i * dp[i-1][j][k] : 0) + (j ? j * dp[i+1][j-1][k] : 0) + (k ? k * dp[i][j+1][k-1] : 0)) / (i + j + k);
      }
    }
  }
  printf("%.16f\n", dp[m[0]][m[1]][m[2]]);

  return 0;
}


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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);

  int res = 0;
  for (int i = 0; i <= 200; ++i)
    if (A <= i && i < B && C <= i && i < D) ++res;

  printf("%d\n", res);
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if((4*B-5*A>=5)||(5*A-4*B>=4)){System.out.println(-1);}
    else{if(5*A-4*B<=0){System.out.println(10*B);}
    else{ int C=25*A%2;
         System.out.println((25*A+C)/2);}
        }
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926

int a[3];

int main(){
    int d;
    cin >> d;
    if(d == 25)
        cout << "Christmas";
    if(d == 24)
        cout << "Christmas Eve";
    if(d == 23)
        cout << "Christmas Eve Eve";
    if(d == 22)
        cout << "Christmas Eve Eve Eve";
    
}
	


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

int main() {
  double pi = acos(-1);
  int a,b,h,m;
  cin >> a>>b>>h>>m;
  double x,y;
  x = 2*pi*(h*60+m)/(12*60);
  y = 2*pi*m/60;
  double diff = abs(x-y);
  double dist = a*a+b*b-2*a*b*cos(diff);
  cout << fixed << setprecision(16);
  cout << sqrt(dist) << endl;
}

Measured memory_bytes: 4188
#include <stdio.h>
#include <stdlib.h>

#define MAX 100

void InsertionSort(int [],int N);

int main(){
  int i,N;
  int *data;
  
  scanf("%d",&N);
  data = (int *)malloc(sizeof(int) * N);

  for (i = 0;i < N;i++)
    scanf("%d",&data[i]);

  InsertionSort(data,N);
  free(data);
  
  return 0;
}

void InsertionSort(int A[],int N){
  int v;
  int i,j,k;

  for (i = 1;i < N;i++){
    for (k = 0;k < N;k++){
      if (k)
        printf(" ");

      printf("%d",A[k]);
    }
    
    printf("\n");
    
    v = A[i];
    j = i - 1;

    while (j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }

    A[j + 1] = v;
  }

  for (k = 0;k < N;k++){
    if (k)
      printf(" ");

    printf("%d",A[k]);
  }
    
  printf("\n");
  
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int n,m;
  cin>>n>>m;
  if(n*2>=m)cout<<m/2;
  else{
    int x=(m-2*n)/2;
    cout<<x/2+n<<endl;
  }
}


Measured memory_bytes: 3632
// abc087_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


template< typename T >
struct WeightedUnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> size; // size[i]: iが親なら連結成分の数
    vector<T> weight; // weight[i]: i -> iの根までの重み

    WeightedUnionFind(int N) : par(N), rank(N, 0), size(N, 1), weight(N, 0) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) {par[i] = i;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;

        // 親への重みを追加しながら根まで走査
        int rx = find(par[x]);
        weight[x] += weight[par[x]];
        return par[x] = rx;
    }

    bool unite(int x, int y, T w) { // x -> y の重みが w
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return false; //xとyの根が同じ(=同じ木にある)時はそのまま

        w = -weight[x] + w + weight[y];

        // rank[rx] <= rank[ry] となるように rx と ry を swap
        if(rank[rx] > rank[ry]) { swap(rx, ry); w *= -1;  }

        // 同じ高さだったならばまとめたことによって高さ +1
        if(rank[rx] == rank[ry]) ++rank[ry];

        // rx -> ryの重みをセット
        weight[rx] = w;

        par[rx] = ry; // root ry に rx の木をつなぐ
        size[ry] += size[rx];
        size[rx] = 0;

        return true;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

    int get_size(int x){
        int rx = find(x);
        return size[rx];
    }

    T diff(int x, int y) { // x -> yの重みを返す
        find(x);
        find(y);
        return weight[x] - weight[y];
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    WeightedUnionFind<ll> uf(N);

    REP(i, M){
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;

        if (uf.same(l, r)){

            if (uf.diff(l, r) != d){
                print("No");
                return 0;
            }

        } else {
            uf.unite(l, r, d);
        }
    }
    print("Yes");

    return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> count(n+1);
	FOR(i,0,n+1)count[i] = 0;
	FOR(i,0,n){
		int a;
		cin >> a;
		count[a]++;
	}
	sort(ALL(count));
	int ans = 0;
	FOR(i,0,n+1-k)ans += count[i];
	ANS(ans);
	return 0;
}


Measured memory_bytes: 1024
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t = int(input())
    t_list.append(t)
t_list = sorted(t_list)
bus = 1
pas = 0
time = t_list[0]
for i in range(1, n):
    if t_list[i] - time <= k:
        pas += 1
    else:
        pas = 0
        bus += 1
        time = t_list[i]
    if pas >= c:
        pas = 0
        bus += 1
        time = t_list[i]
print(bus)


Measured memory_bytes: 8284
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
int n,a[100005],sum,m;
priority_queue<int> q;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> m >> n ;
for(int i=1;i<=n;i++){
   cin >> a[i];
}
sort(a+1,a+n+1);
if(m>=n){
   cout << 0 << endl;
   return 0;
}
m--;
for(int i=1;i<n;i++){
   q.push(a[i+1]-a[i]);
}
while(m>0){
   q.pop();
   m--;
}
while(!q.empty()){
   sum+=q.top();q.pop();
}
cout << sum << endl;

return 0;}
///....



Measured memory_bytes: 2168