akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	vector< vector< int > > A(3, vector< int >(3));
	rep(i, 3) rep(j, 3) cin >> A[i][j];
	vector< vector< int > > B(3, vector< int >(3, 0));
	cin >> N;
	rep(i, N) {
		int b;
		cin >> b;
		rep(j, 3) rep(k, 3) if (A[j][k] == b) {
			B[j][k] = 1;
		}
	}
	string ans = "No";
	rep(i, 3) if (B[i][0] == 1 && B[i][1] == 1 && B[i][2] == 1) ans = "Yes";
	rep(j, 3) if (B[0][j] == 1 && B[1][j] == 1 && B[2][j] == 1) ans = "Yes";
	if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
		ans = "Yes";
	if (B[2][0] == 1 && B[1][1] == 1 && B[0][2] == 1)
		ans = "Yes";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int a[1100];
int main(int argc,char** argv){
	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}

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

char s[N];
int n,sum[N],f[N],g[1<<26];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) sum[i]=sum[i-1]^(1<<(s[i]-'a'));
	
	memset(f,0x3f,sizeof(f));
	memset(g,0x3f,sizeof(g));
	g[0]=0;
	for (int i=1;i<=n;i++)
	{
		f[i]=min(f[i],g[sum[i]]+1);
		for (int j=0;j<26;j++) f[i]=min(f[i],g[sum[i]^(1<<j)]+1);
		g[sum[i]]=min(g[sum[i]],f[i]);
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 264192
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll x,s=0,i;
cin>>x;
for(i=1;i<=x;i++)
{
    if(i%5==0&&i%3==0)
    {

    }
    else if(i%5==0&&i%3!=0)
    {

    }
    else if(i%5!=0&&i%3==0)
    {

    }
    else
    {
       s+=i;
    }

}
cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int x,y;
cin >> x >> y;

rep(i,105) {
    rep(j,105) {
        if(i+j == x && 2*i+4*j == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
}

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

Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, A: "List[int]"):
    if len(set(A)) == N:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5, mod = 1e9 + 7;
struct e{
    int l, r, x;
    bool operator < (e b) {return x < b.x;}
}a[maxn];
struct e2{
    int t, id;
};
bool operator < (const e2 &a, const e2 &b) {return a.t < b.t;}
set<e2> se2;
int ans[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, q, tx;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i].l >> a[i].r >> a[i].x;
    for (int i = 0; i < q; ++i){
        cin >> tx;
        se2.insert(e2{tx, i});
        ans[i] = -1;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i){
        set<e2>::iterator it = se2.lower_bound(e2{a[i].l - a[i].x, 0});
        while (it != se2.end()){
            //cout << it -> t << " " << it -> id << endl;
            if (it -> t < a[i].r - a[i].x){
                ans[it -> id] = a[i].x;
                se2.erase(it++);
            }else break;
        }
    }
    for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
int h,w,k;
int sx,sy,ex,ey;
const int dx[]={0,-1,0,1};
const int dy[]={-1,0,1,0};

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> h >> w >> k >> sx >> sy >> ex >> ey;
	sx--; sy--; ex--; ey--;
	char grid[h][w];
	vll dist(h*w*4,ll(1e18));
	for(int i=0; i<h; i++)
		for(int j=0; j<w; j++)
			cin >> grid[i][j];
	priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>pq; //dist,pos
	auto getid = [&](int x, int y, int dir){
		return (x*w+y)*4+dir;
	};
	auto push=[&](int x, int y, int dir, ll d){
		int id = getid(x,y,dir);
		if(dist[id]<=d)return;
		dist[id]=d;
		pq.emplace(d,id);
	};
	auto modk=[&](ll x){
		return (x+k-1)/k*k;
	};
	for(int i=0; i<4; i++)push(sx,sy,i,0LL);
	while(!pq.empty()){
		ll dis = pq.top().fi;
		int id = pq.top().se;
		pq.pop();
		if(dist[id]!=dis)continue;
		int dir = id%4;
		int y = ((id-dir)/4)%w;
		int x = ((id-dir)/4-y)/w;
		for(int i=0; i<4; i++)push(x,y,i,modk(dis));
		
		int X = x+dx[dir]; int Y = y+dy[dir];
		if(X<0||X>=h)continue;
		if(Y<0||Y>=w)continue;
		if(grid[X][Y]=='@')continue;
		push(X,Y,dir,(dis+1));
	}
	ll ans = INF;
	for(int i=0; i<4; i++){
		ans=min(ans,dist[getid(ex,ey,i)]);
	}
	if(ans==1e18)ans=-1;
	else ans = modk(ans)/k;
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 43712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    Rep(0, N, n) {
        if (S.substr(n, N-n) == T.substr(0,N-n)) {
            cout << N + n << endl;
            return;
        }
    }

}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m, x = map(int, input().split())
ca = [tuple(map(int, input().split()))for _ in range(n)]
INF = 10**18
ans = INF
proficiency = [0]*m


def dfs(i, cost):
    if i == n:
        global ans
        if cost < ans and all(x <= proficiency[j]for j in range(m)):
            ans = cost
        return 0
    c, *A = ca[i]
    for j in range(m):
        proficiency[j] += A[j]
    dfs(i+1, cost+c)
    for j in range(m):
        proficiency[j] -= A[j]

    dfs(i+1, cost)


dfs(0, 0)
print(ans if ans != INF else -1)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007,n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string a,b,c,aa,bb,cc;cin>>a;aa=a;
    reverse(aa.begin(),aa.end());
    if(aa==a){
        b=a.substr(0,a.length()/2);bb=b;
        reverse(bb.begin(),bb.end());
        if(bb==b){

            c=a.substr((a.length()+3)/2-1,a.length()-((a.length()+3)/2-1));
            cc=c;
            reverse(cc.begin(),cc.end());
            if(cc==c){
                cout<<"Yes"<<endl;
            }
            else
            cout<<"No"<<endl;
        }
        else
        cout<<"No"<<endl;
    }
    else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

class Tree {
    int N; // Graph(Tree)???????????°
    int[][] G; // Graph(Tree)?????£??\???????????¨???
    int[] D; // ????????????root??????????????¢
    int LOG_N; // log2(N)?????????
    int[][] P; // P[k][v] : ??????v???2^k?????????????\?
    void dfs(int prev, int index, int d) {
        P[0][index] = prev;
        D[index] = d;
        for (int i = 0; i < G[index].size; i++) {
            int next = G[index][i];
            if (next == prev) continue;
            dfs(index, next, d + 1);
        }
    }
    this(int[][] G) {
        this.N = G.size;
        this.G = G;
        this.LOG_N = bsr(N) + 1;
        this.P = new int[][](LOG_N, N);
        this.D = new int[N]; D[] = -1;
        dfs(-1, 0, 0);
        for (int k = 0; k < LOG_N - 1; k++) {
            for (int v = 0; v < N; v++) {
                if (P[k][v] < 0) P[k + 1][v] = -1;
                else P[k + 1][v] = P[k][ P[k][v] ];
            }
        }
    }
    // ??????v???n?????????????????????
    int nth_parent(int v, int n) {
        for (int k = 0; k < LOG_N; k++)
            if (n & (1 << k)) v = P[k][v];
        return v;
    }
    // 2??????u??¨v???LCA?????????
    int lca(int u, int v) {
        if (D[u] > D[v]) swap(u, v);
        v = nth_parent(v, D[v] - D[u]);
        if (u == v) return u;
        for (int k = LOG_N - 1; k >= 0; k--) {
            if (P[k][u] != P[k][v]) {
                u = P[k][u];
                v = P[k][v];
            }
        }
        return P[0][u];
    }
    // 2??????u??¨v????????¢?????????
    int dist(int u, int v) {
        int root = lca(u, v);
        return (D[u] - D[root]) + (D[v] - D[root]);
    }
}

void main() {
    int N = readln.chomp.to!int;
    auto G = new int[][N];
    for (int i = 0; i < N; i++) {
        int k; scanf("%d ", &k);
        for (int j = 0; j < k; j++) {
            int c; scanf("%d", &c);
            G[i] ~= c;
        }
    }
    auto t = new Tree(G);
    int Q; scanf("%d", &Q);
    for (int q = 0; q < Q; q++) {
        int u, v; scanf("%d %d", &u, &v);
        writeln(t.lca(u, v));
    }
}

Measured memory_bytes: 20548
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();

		if (a <= 1199) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}

	}
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 N;
  cin >> N;
  vector<double> x(N), y(N);
  REP(i, N) cin >> x[i] >> y[i];
  double res = 0;
  vector<int64> ord(N);
  iota(all(ord), 0);
  do {
    REP(i, N-1) {
      res += sqrt((x[ord[i+1]]-x[ord[i]])*(x[ord[i+1]]-x[ord[i]])+
        (y[ord[i+1]]-y[ord[i]])*(y[ord[i+1]]-y[ord[i]]));
    }
  } while(next_permutation(all(ord)));
  FOR(i, 1, N+1) {
    res /= i;
  }
  cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  rep(i,d){
  if(a>=b){
  b*=2;
  }
    else 
    c*=2;
  }
  YesNo(a<b&&b<c);
}

Measured memory_bytes: 3796
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

string s;
int k;

int main() {
    while (cin >> s) {
        cin >> k;
        int n = s.size();
        for (int i = 0; i < n; i++) {
            char &c = s[i];
            if (c == 'a') continue;
            int a = 'z' - c + 1;
            if (k >= a) {
                c = 'a';
                k -= a;
            }
        }
        k %= 26;
        for (int i = 0; i < k; i++) {
            if (s.back() == 'z') {
                s.back() == 'a';
            } else {
                s.back()++;
            }
        }

        cout << s << endl;
    }

}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

char str[1002], cp[1002];

char p[1002];

int q;

char f[10];
int a, b;

int main(){
	cin.tie(0);
	
	cin>>str;
	cin>>q;
	
	int l = strlen(str);
	
	rep(ii, q) {
	    cin>>f>>a>>b;
	    if(f[2]=='i') {
	        for_(i, a, b+1)cout<<str[i];
	        cout<<endl;
	    }else if(f[2]=='v') {
	        rep(i, l)cp[i] = str[i];
	        rep(i, b-a+1)cp[a+i] = str[b-i];
	        rep(i, l)str[i] = cp[i];
	    }else {
	        cin>>p;
	        rep(i, b-a+1)str[a+i] = p[i];
	    }
	}

	return 0;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<int> H(6,0);
	REP(i,N){
		int V = in<double>();
		if(V<165) H[0]++;
		else if(V<170) H[1]++;
		else if(V<175) H[2]++;
		else if(V<180) H[3]++;
		else if(V<185) H[4]++;
		else H[5]++;
	}
	
	REP(i,6){
		cout<< i+1 << ':';
		REP(j,H[i]) cout << '*';
		out();
	}
	return 0;
}



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

using namespace std;

const int N=1e4+10;

int p[N],son[N],d[N],h[N];

vector<int> G[N];

void init(int n)
{
    memset(p,-1,sizeof(p));
    memset(son,0,sizeof(son));
    memset(d,0,sizeof(d));
    memset(h,0,sizeof(h));

    for(int i=0;i<n;i++)
    {
        G[i].clear();
    }
}

int dfs(int root, int depth)
{
    d[root]=depth;

    int height=0;

    for(int i=0;i<G[root].size();i++)
    {
        height=max(height,dfs(G[root][i],depth+1));
    }

    return 1+(h[root]=height);
}

void display(int x)
{
    char s[100];

    if(p[x]==-1)
    {
        strcpy(s,"root");
    }else if(!G[x].size())
    {
        strcpy(s,"leaf");
    }else
    {
        strcpy(s,"internal node");
    }
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",x,p[x],(p[x]==-1)?-1:son[p[x]]-x,G[x].size(),d[x],h[x],s);
}

int main()
{
    int n;

    while(scanf("%d",&n)!=EOF)
    {
        int a,b,c;

        init(n);
        for(int i=0;i<n;i++)
        {
            scanf("%d %d %d",&a,&b,&c);

            if(b!=-1)
            {
                p[b]=a; G[a].push_back(b);
            }

            if(c!=-1)
            {
                p[c]=a; G[a].push_back(c);

            }

            son[a]=b+c;
        }

        int root;

        for(int i=0;i<n;i++)
        {
            if(p[i]==-1)
            {
                root=i;
                break;
            }
        }

        dfs(root,0);

        for(int i=0;i<n;i++)
        {
            display(i);
        }
    }




    return 0;
}



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

int main(){
    int x,y,z;
    
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if(x > y){
            cout << y << " " << x <<endl;
        }else if (x <= y){
            cout << x << " " << y << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}

void Splus(string S,string pS, ll i, ll sum, ll &ans){
  pS += S.at(i);
  if(S.size()-1 == i){
    ans += sum + stoll(pS);
    return;
  }
  Splus(S, pS, i+1, sum, ans);
  sum += stoll(pS);
  pS = "";
  Splus(S, pS, i+1, sum, ans);
}

int main() {
  IN(string, S);
  ll ans = 0;
  Splus(S, "", 0, 0, ans);
  OUT(ans);
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <stdio.h>
using namespace std;

// Prime Number(0009(
int main()
{
	const int MAX = 1000000 + 1000;
	static bool prime[MAX];
	for (int i = 0; i < MAX; ++i)
		prime[i] = true;
	prime[0] = prime[1] = false;

	for (int i = 2; i < MAX; ++i) {
		if (prime[i]) {
			for (int j = i+i; j < MAX; j += i)
				prime[j] = false;
		}
	}

	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = 2; i <= n; ++i) {
			if (prime[i])
				++ans;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n), cp(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
        cp[i] = v[i];
    }
    sort(cp.begin(), cp.end());
    int c1 = cp[n/2-1], c2 = cp[n/2];
    for(int i=0; i<n; i++){
        if(v[i] <= c1) cout << c2 << endl;
        else cout << c1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

  /* code */


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])
  cout<<"Yes\n";
  else
  cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int ans = 0;
    REP(i, n) {
        if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])
            ans += 2;
        else if (a[i] != b[i] || b[i] != c[i] || c[i] != a[i])
            ans++;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, x, i, j, k, count = 0;

    for(;;){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(i = 1; i <= n; i++){
            for(j = i + 1; j <= n; j++){
                for(k = j + 1; k <= n; k++){
                    if(i + j + k == x) count++;
                }
            }
        }
        cout << count << endl;
        count = 0;
    }
}


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

int main() {
  int N;
  cin >> N;
  
  int count = 0;
  
  for(int i=0; i<8; i++)
  {
    int k1 = pow(10,i);
    int k2 = pow(10,i+1);
    int val = floor((N%k2) / k1);
    count += val;
  //  cout << val << endl;
  }
  
  if(N%count == 0)
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int size,ans=0;
  size=s.size();
  for(int i=0;i<size;i++){
    if(s.at(i)!=t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    sum += a[i];
  }
  std::cout << sum - n << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#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 long double ld;
const ld eps=1e-8;
int main() {
    int n; cin >> n;
	ll dp[201][201] = {};
	dp[0][0] = 1;
	vector<char> v;
	rep(i, n) {
		char t;cin >> t;
		if (t != '-')v.push_back(t);
	}
	int len = v.size();
	rep(i, len) {
		rep(j, len+1) {
			if (v[i] == 'U') {
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= MOD;
				dp[i + 1][j] += dp[i][j] * j;
				dp[i + 1][j] %= MOD;
			}
			else {
				dp[i + 1][j] += dp[i][j] * j;
				dp[i + 1][j] %= MOD;
				if (j - 1 >= 0) {
					dp[i + 1][j - 1] += dp[i][j] * j*j;
					dp[i + 1][j - 1] %= MOD;
				}
			}
		}
	}
	cout << dp[len][0] << endl;
	return 0;
}


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

int n;
int a[1010][1010];
int idx[1010][1010];
//a[j][idx[i][j]]=i
//idx[i][j]=jの人のリストの何番目にiの人が登場するか
int dp[1010][1010];

int dfs(int i,int j){
	if(j<0)return 0;
	if(dp[i][j]==-1){
		puts("-1");
		exit(0);
	}
	if(dp[i][j])return dp[i][j];
	dp[i][j]=-1;
	return dp[i][j]=max(dfs(i,j-1),dfs(a[i][j],idx[i][a[i][j]]-1))+1;
}

int main(){
	scanf("%d",&n);
	rep(i,0,n)rep(j,0,n-1){
		scanf("%d",&a[i][j]);
		a[i][j]--;
		idx[a[i][j]][i]=j;
	}
	int ans=0;
	rep(i,0,n)ans=max(ans,dfs(i,n-2));
	printf("%d",ans);
}


Measured memory_bytes: 12288
n = int(input())
h = list(map(int, input().split()))
h.append(99999999)
h.append(99999999)
dp = [999999999] * (n + 2)
dp[0] = 0

for i in range(n):
    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]))
print(dp[n - 1])


Measured memory_bytes: 13980
n = int(input())
al = list(map(int, input().split()))
bl = [0]*(n+1)
acc = [0]*(n+2)
for i in range(n+1):
    acc[i+1] = al[i]+acc[i]

res = 0
for d in range(n+1):
    if d==0:
        res += 1
        bl[0] = 1 - al[0]
    else:
        r1 = 2*bl[d-1] - al[d]
        r2 = acc[-1] - acc[d+1]
        bl[d] = min(r1,r2)
        res += al[d]+bl[d]
    if bl[d]<0:
        print(-1)
        exit()

print(res)

Measured memory_bytes: 22316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class A500YenCoins {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int k = s.nextInt();
            int x = s.nextInt();
            if (k * 500 >= x)
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23380
n,k,c=map(int,input().split())
s=list(input())
p=[-1]*n
i=0
f=0
while i<n:
    if s[i]=='o':
        p[i]=f
        f+=1
        i+=c+1
    else:
        i+=1
i=0
f=0
q=[-1]*n
while i<n:
    if s[n-i-1]=='o':
        q[n-i-1]=f
        f+=1
        i+=c+1
    else:
        i+=1
for i in range(n):
    if p[i]>=0 and q[i]>=0 and p[i]+q[i]==k-1:
        print(i+1)

Measured memory_bytes: 63216
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    MOD = 10**9 + 7
    N, M = read_int_array()
    dp = [0]*(N+1)
    dp[0] = dp[1] = 1

    for _ in range(M):
        dp[read_int()] = -1

    if dp[0] < 0:
        dp[0] = 0
    if dp[1] < 0:
        dp[1] = 0
    for i in range(2, N+1):
        if dp[i] == -1:
            dp[i] = 0
            continue
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
        if not dp[i] and not dp[i-1]:
            print(0)
            return
    print(dp[-1] % MOD)



# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

read = input
read_int = lambda: int(input())
read_array = lambda sep=None, maxsplit=-1: input().split(sep, maxsplit)
read_int_array = lambda: [int(a) for a in read_array()]

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 35100
#include <iostream>

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

   int add = A + B;
   int sub = A - B;
   int mul = A * B;

   int max = add;
   if(max<sub) max = sub;
   if(max<mul) max = mul;
   std::cout << max << std::endl;

   return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int main(){
  string S;
  cin >> S;
  vector<bool> cnt(26, false);
  if(S.length() != 26){
    REP(i, S.length()){
      cnt[S[i] - 'a'] = true;
    }
    REP(i, 26){
      if(cnt[i] == false){
        cout << S << (char)(i+'a') << endl;
        return 0;
      }
    }
  }
  REPR(i, S.length()-2){
    if(S[i] < S[i+1]){
      int mini = i+1;
      char mins = S[i+1];
      FOR(j, i+2, S.length()){
        if(S[i] < S[j] && S[j] < mins){
          mini = j;
          mins = S[j];
        }
      }
      char tmp = S[i];
      S[i] = S[mini];
      S[mini] = tmp;
      // sort(S.begin()+i+1, S.end());
      S.erase(S.begin()+i+1, S.end());
      cout << S << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

using namespace std;

int main() {
	//入力
	int in = 0;
	cin >> in;

	vector<int> ABCD(4);
	int div = 1000;
	for (int i = 0; i < 4; ++i) {
		ABCD[i] = in / div;
		in %= div;
		div /= 10;
	}
	
	int n = 3;
	vector<char> op(3);
	//処理
	for (int bit_op = 0; bit_op < (1 << n); ++bit_op) {
		int ans = ABCD[0];
		for (int i = 0; i < n; ++i) {
			if (bit_op & (1 << i)) {
				op[i] = '+';
				ans += ABCD[i + 1];
			}
			else {
				op[i] = '-';
				ans -= ABCD[i + 1];
			}
		}
		if (ans == 7) {
			cout << ABCD[0] << op[0] << ABCD[1] << op[1] << ABCD[2] <<
				op[2] << ABCD[3] << "=7" <<endl;
			return 0;
		}
	}


	//出力
	
}

Measured memory_bytes: 256
N,K=map(int,input().split())

point=0
ans=0
toss_cnt=0

for i in range(1,N+1):
    point=i
    toss_cnt=0
    if point>K:
        ans+=1/N
    else:
        while point<K:
            point*=2
            toss_cnt+=1
        else:
            ans+=(1/N)*(1/2)**toss_cnt
            
            
print(ans)
    

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

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

  double l = (double)L;
  cout << fixed;
  cout << setprecision(8) << l*l*l/27 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
void print_v(vector<int> v)
{
    for (auto it = v.begin(); it != v.end() - 1; it++)
    {
        cout << *it << ' ';
    }
    cout << v.back() << endl;
}
void InsertionSort(vector<int> A, int N)
{
    for (int i = 1; i < N; i++)
    {
        int v = A.at(i);
        int j = i - 1;

        while (j >= 0 && A.at(j) > v)
        {
            A.at(j + 1) = A.at(j);
            j--;
        }
        A.at(j + 1) = v;
        print_v(A);
    }
}
int main()
{
    vector<int> A;
    int N;
    cin >> N;
    A.reserve(N);
    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        A.push_back(n);
    }

    print_v(A);

    InsertionSort(A, N);
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	if (n == 1) {
		dunk(0);
		return 0;
	}
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0 && i != 1) {
			if (ll(n / (i - 1)) == n % (i - 1)) ans += i - 1;
			if (i * i != n) {
				ll a = n / i;
				if (ll(n / (a - 1)) == n % (a - 1)) ans += a - 1;
			}
		}
		if (i == 1) {
			ll a = n / i;
			if (ll(n / (a - 1)) == n % (a - 1)) ans += a - 1;
		}
	}
	dunk(ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (){
	int A;
	int B;
	char str1[100];
	int hasil;
	
	scanf("%d %d", &A,&B);
	char str[(A+B)+1];
	scanf("%s", &str);
	
	for(int i=0;i<A+B+1;i++){
	if(i!=A){
		if(str[i]>='0'&&str[i]<='9'){
			hasil++;
		}
	}else if(str[i]=='-'){
			hasil++;
	}
	}
		
		if(hasil==A+B+1){
			printf("Yes");
		}else{
			printf("No");
		}
	return 0;
}

Measured memory_bytes: 1732
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=0;i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=0;i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){
  int i;
  pair<T1, pair<T2, T3> > *arr;
  walloc1d(&arr, N, &mem);
  for(i=0;i<(N);i++){
    arr[i].first = a[i];
    arr[i].second.first = b[i];
    arr[i].second.second = c[i];
  }
  sort(arr, arr+N);
  for(i=0;i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second.first;
    c[i] = arr[i].second.second;
  }
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(double &x){
  scanf("%lf",&x);
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(double x){
  printf("%.15f",x);
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
char memarr[96000000];
int N;
double X[200];
double Y[200];
double t[100];
int main(){
  double res=0, sx, sy;
  int i, j, k;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
    }
  }
  for(i=0;i<(N);i++){
    t[i] = atan2(Y[i],X[i]);
  }
  sortA_L(N, t, X, Y);
  for(i=0;i<(N);i++){
    X[i+N] = X[i];
  }
  for(i=0;i<(N);i++){
    Y[i+N] = Y[i];
  }
  for(i=0;i<(N);i++){
    sx = sy = 0;
    for(j=0;j<(N);j++){
      sx += X[i+j];
      sy += Y[i+j];
      chmax(res,pow2_L(sx)+pow2_L(sy));
    }
  }
  res = sqrt(res);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190901-1 [beta]

// --- original code ---
// int N;
// double X[200], Y[200];
// double t[100];
// {
//   int i, j, k;
//   double sx, sy, res = 0;
//   
//   rd(N,(X,Y)(N));
//   rep(i,N) t[i] = atan2(Y[i],X[i]);
//   sortA(N, t, X, Y);
// 
//   rep(i,N) X[i+N] = X[i];
//   rep(i,N) Y[i+N] = Y[i];
// 
//   rep(i,N){
//     sx = sy = 0;
//     rep(j,N){
//       sx += X[i+j];
//       sy += Y[i+j];
//       res >?= sx**2 + sy**2;
//     }
//   }
// 
//   res = sqrt(res);
//   wt(res);
// }


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n, ma, mb;
vi a, b, c;

int dp[50][1010][1010];
int dfs(int i = 0, int A = 0, int B = 0) {
	if (i == n) {
		if (A == B && A == 0) return inf;
		return (A * mb == B * ma ? 0 : inf);
	}

	int &ret = dp[i][A][B];
	if (~ret) return ret;

	ret = min(dfs(i + 1, A + a[i], B + b[i]) + c[i], dfs(i + 1, A, B));

	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin >> n >> ma >> mb;
	rep(i, n) { a.pb(in()); b.pb(in()); c.pb(in()); }

	int ans = dfs();
	cout << (ans == inf ? -1 : ans) << endl;
}


Measured memory_bytes: 199424