akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int mx = max(x, y);
    ll ans = 1e18;
    for (int i = 0; i <= 2 * mx; i += 2) {
        ll tmp = 0;
        tmp += c * i;
        int x2 = max(x - i / 2, 0);
        int y2 = max(y - i / 2, 0);
        tmp += a * x2 + b * y2;
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 256
import sys


def slove():
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    mt = 0
    ans = 0
    for i in range(n):
        t = min(a[i], a[-1]-a[i])
        if mt < t:
            ans = a[i]
            mt = t
    print(a[-1], ans)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 62704
#include <iostream>
#include <cstdio>

using namespace std;

#define INF (1 << 30)
#define MAX_E 1000
#define MAX_V 100

struct edge{
	int from;
	int to;
	int cost;
};

edge es[MAX_E];
int d[MAX_V];
int V, E;// V???????????°???E????????°

// O(VE)??§????????????????????????????????§??????

void shortest_path(int s){
	for(int i = 1; i <= V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	while(true){
		bool update = false;
		for(int i = 0; i < E; i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update){
			break;
		}
	}
}

int main(){
	
	int a1, b1, c1, d1, p, q, r, s;
	
	int ans1, ans2;
	
	cin >> V >> E;
	
	for(int i = 0; i < E; i++){
		scanf("%d,%d,%d,%d", &a1, &b1, &c1, &d1);
		es[2 * i].from = a1;
		es[2 * i].to = b1;
		es[2 * i].cost = c1;
		es[2 * i + 1].from = b1;
		es[2 * i + 1].to = a1;
		es[2 * i + 1].cost = d1;
	}
	
	E *= 2;
	
	scanf("%d,%d,%d,%d", &p, &q, &r, &s);
	
	shortest_path(p);
	ans1 = d[q];
	shortest_path(q);
	ans2 = d[p];
	printf("%d\n", r - s - ans1 - ans2);
	
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll cnt = 0;
    if(s[0] == '1') cnt++;
    if(s[1] == '1') cnt++;
    if(s[2] == '1') cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S;
    cin >> S;
    if (S.size() % 2) {
        cout << "No" << endl;
        return 0;
    }

    int i = 0;

    bool flag = true;
    REP(c, S.size()) {
        if (S[2*i] != 'h' || S[2*i + 1] != 'i') flag = false;
        ++i;
        if (2*i >= S.size()) break;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    if(a+b<=2*c) cout<<x*a+y*b<<endl;
    else{
        ll ans=min(x,y)*2*c;
        if(x<=y){
            if(b<=2*c) ans+=b*(y-x);
            else ans+=2*c*(y-x);
        }else{
            if(a<=2*c) ans+=a*(x-y);
            else ans+=2*c*(x-y);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 171
//B - Mix Juice / 
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> p(n);
    REP(i, n) cin >> p[i];

    sort(ALL(p));

    int ans=0;
    REP(i,k){
        ans+=p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long int ll;


int main()
{
	ll x;
	cin>>x;
	for(ll i = 0; i < 1000000; i++){
		if( x <= i*(i+1)/2){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}



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

int main() {
	int A, B, C, D, P;
	int Xnum=0, Ynum=0;

	cin >> A >> B >> C >> D >> P;
	Xnum = A * P;
	if (P <= C) {
		Ynum = B;
	}
	if (P > C) {
		Ynum = B + D * (P - C);
	}

	if (Xnum >= Ynum) {
		cout << Ynum <<endl;
	}
	else if (Xnum < Ynum) {
		cout << Xnum << endl;
	}
	
	return 0;
} 


Measured memory_bytes: 3092
#include<iostream>

using namespace std;

void sort(int a[],int n)
{
	int i = 0,j = n-1;
	int pivot = a[(i+j)/2];

	while(true)
	{
		while(a[i] > pivot)i++;
		while(a[j] < pivot)j--;

		if(i >= j)break;

		int hold = a[i];
		a[i] = a[j];
		a[j] = hold;

		i++;
		j--;
	}

	if(i > 1)sort(a,i);
	if(n-j-1>1)sort(a+j+1,n-j-1);
}

int main()
{
	int a[110];
	int Alice = 0,Bob = 0;
	int N;

	cin >> N;

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

	sort(a,N);

	for(int i=0;i<N;i++)
	{
		if(i%2==0)
		{
			Alice += a[i];
		}
		else
		{
			Bob += a[i];
		}
	}

	cout << Alice - Bob << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
using namespace std;
bool b[105][105];
char a[105][105];
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
int n,m,res;
int init()
{
    for (int i=0;i<n;i++)
    {
        scanf("%s",a[i]);
    }
}
void dfs(int p1,int p2)
{
    b[p1][p2]=1;
    for (int i=0;i<4;i++)
    {
        int d1=p1+dx[i],d2=p2+dy[i];
        if (d1>=0 && d1<n && d2>=0 && d2<m && b[d1][d2]==0 && a[d1][d2]==a[p1][p2])
            dfs(d1,d2);
    }
}
void solve()
{
    memset(b,0,sizeof(b));res=0;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            if (!b[i][j])
            {
                ++res;
                dfs(i,j);
            }
        }
    }
}
int main()
{
    while (scanf("%d%d",&n,&m)==2 && n!=0 && m!=0)
    {
        init();
        solve();
        printf("%d\n",res);
    }
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vll a(q), b(n);
    rep(i, q) {
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    rep(i, n) {
        if (k-(q-b[i]) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 2176
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
ll dp[2000000];
main(){
    vector<pair<string,int>> v;
    int n=in();
    rep(i,n){
        string s;
        cin>>s;
        v.pb({s,in()});
    }
    int a[200];
    rep(i,n){
        a[i]=i;
    }
    sort(a,a+n,[&](int x,int y){
        if(v[x].first==v[y].first){
            return v[x].second>v[y].second;
        }
        else{
            return v[x].first<v[y].first;
        }
    });
    rep(i,n){
        cout<<a[i]+1<<endl;
    }
}



Measured memory_bytes: 256
import java.util.*;

//文字操作

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int n=sc.nextInt();
		while(n--!=0){
			char[] val=sc.next().toCharArray();
			Arrays.sort(val);
			int min=Integer.parseInt(String.copyValueOf(val));
			char[] rev=new char[val.length];
			for(int i=0;i<rev.length;i++){
				rev[i]=val[rev.length-1 -i];
			}
			int max=Integer.parseInt(String.copyValueOf(rev));
			ln(max-min);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll n=s.size();
    if(s[n-1]=='s'){
        s.push_back('e');
        s.push_back('s');
    }else {
        s.push_back('s');
    }
    cout << s << endl;
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n==1||n==2){
        cout << n << endl;
        return 0;
    }
    while(n>0){
        for(int i=1;;i++){
            if((i+1)*i/2>=n){
                if(n-i<=2){
                    printf("%d %d\n", i, n-i);
                    n=0;
                    break;
                }else{
                    printf("%d ", i);
                    n = n-i;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
Query=[list(map(int,input().split())) for i in range(Q)]
mod=10**9+7

EDGELIST=[dict() for i in range(N+1)]
for x,y,c,l in EDGE:
    EDGELIST[x][y]=(c,l)
    EDGELIST[y][x]=(c,l)
    
# LCA(オイラーツアー＋Segment tree)

DEPTH=[-1]*(N+1)
DEPTH[1]=0

from collections import deque
QUE = deque([1])
QUE2 = deque()
EULER=[]#(i,j)で,(1からツアーで辿った点の深さ,そのindex)

USED=[0]*(N+1)
while QUE:
    x=QUE.pop()
    EULER.append((DEPTH[x],x))
    if USED[x]==1:
        continue
    for to in EDGELIST[x]:
        
        if USED[to]==0:
            DEPTH[to]=DEPTH[x]+1
            QUE2.append(to)
        else:
            QUE.append(to)
    QUE.extend(QUE2)
    QUE2=deque()
 
    USED[x]=1

MINP=[1<<30]*(N+1)
MAXP=[-1]*(N+1)

for ind,(depth,p) in enumerate(EULER):
    MINP[p]=min(MINP[p],ind)
    MAXP[p]=ind

LEN=len(EULER)

seg_el=1<<(LEN.bit_length())#Segment treeの台の要素数
SEG=[(1<<30,0)]*(2*seg_el)#1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(LEN):#Dを対応する箇所へupdate
    SEG[i+seg_el]=EULER[i]

for i in range(seg_el-1,0,-1):#親の部分もupdate
    SEG[i]=min(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el):#A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1#子ノードへ
    
    while i!=0:
        SEG[i]=min(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):#区間[l,r)に関するminを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=(1<<30,0)

    while L<R:
        if L & 1:
            ANS=min(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=min(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

def LCA(l,r):
    return getvalues(min(MINP[l],MINP[r]),max(MAXP[l],MAXP[r])+1)

N_q=[[] for i in range(N+1)]
for ind,(c,pl,x,y) in enumerate(Query):
    N_q[x].append([ind,c,pl,1])
    N_q[y].append([ind,c,pl,1])
    N_q[LCA(x,y)[1]].append([ind,c,pl,0])

ANS=[0]*Q

LENG=0
C_LENGTH=[0]*N
C_SUM=[0]*N

for i in range(1,len(EULER)):
    ind=EULER[i][1]
    c,l=EDGELIST[EULER[i-1][1]][ind]
    if EULER[i][0]>EULER[i-1][0]:
        LENG+=l
        C_LENGTH[c]+=l
        C_SUM[c]+=1

        for que,c,pl,boo in N_q[ind]:
            if boo==1:
                ANS[que]+=LENG+C_SUM[c]*pl-C_LENGTH[c]

            else:
                ANS[que]-=(LENG+C_SUM[c]*pl-C_LENGTH[c])*2
            
    else:
        LENG-=l
        C_LENGTH[c]-=l
        C_SUM[c]-=1

for ans in ANS:
    print(ans)


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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

struct unionfind {
    vector<int> d;
    unionfind(int n) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    array<int, 4> di = {1, 0, -1, 0}, dj = {0, 1, 0, -1};

    unionfind uf(h * w);
    auto idx = [&](int i, int j) { return i * w + j; };

    rep(i, h) rep(j, w) {
        rep(k, 4) {
            int ni = i + di[k], nj = j + dj[k];
            if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            if (s[i][j] == s[ni][nj]) continue;
            uf.unite(idx(i, j), idx(ni, nj));
        }
    }

    auto cnt = make_vec<ll>({h, w, 2}, 0);
    rep(i, h) rep(j, w) {
        int x = uf.find(idx(i, j));
        int ni = x / w, nj = x % w;
        cnt[ni][nj][s[i][j] == '#']++;
    }

    ll ans = 0;
    rep(i, h) rep(j, w) ans += cnt[i][j][0] * cnt[i][j][1];
    cout << ans << '\n';
}


Measured memory_bytes: 12688
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var gates = new Tuple<int, int>[m];
        for (int i = 0; i < gates.Length; i++)
        {
            var lr = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            gates[i] = Tuple.Create(lr[0], lr[1]);
        }

        var l = gates.Max(x => x.Item1);
        var r = gates.Min(x => x.Item2);
        Console.WriteLine(Math.Max(0, r - l + 1));
    }
}


Measured memory_bytes: 21824
#ABC056 A - HonestOrDishonest
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b = map(str, input().split())
if a == 'H':
    if b == 'H':
        print('H')
    else:
        print('D')
else:
    if b == 'H':
        print('D')
    else:
        print('H')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll X;
    cin >> X;
    for (ll a = -200; a <= 200; a++) {
        for (ll b = -200; b <= 200; b++) {
            if (a*a*a*a*a - b*b*b*b*b == X) {
                cout << a << " " << b << "\n";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<=b&&b<=c)printf("%d %d %d\n",a,b,c);
else if(a<=c&&c<=b)printf("%d %d %d\n",a,c,b); 
else if(b<=a&&a<=c)printf("%d %d %d\n",b,a,c);
else if(b<=c&&c<=a)printf("%d %d %d\n",b,c,a);
else if(c<=a&&a<=b)printf("%d %d %d\n",c,a,b);
else if(c<=b&&b<=a)printf("%d %d %d\n",c,b,a);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int calc(string s,string t)
{
	for(int i=min(s.size(),t.size());i>=0;i--){
		bool ok=true;
		for(int j=0;j<i;j++)
			if(s[s.size()-i+j]!=t[j])
				ok=false;
		if(ok)
			return t.size()-i;
	}
	return t.size();
}

int main()
{
	for(int n;cin>>n && n;){
		vs ss(n);
		rep(i,n) cin>>ss[i];
		
		{
			vi in(n);
			rep(i,n) rep(j,n) if(i!=j)
				if(ss[i].find(ss[j])!=string::npos)
					in[j]=1;
			vs t;
			rep(i,n) if(!in[i])
				t.push_back(ss[i]);
			ss=t;
			n=ss.size();
		}
		
		vvi add(n,vi(n));
		rep(i,n) rep(j,n)
			add[i][j]=calc(ss[i],ss[j]);
		
		vvi dp(n,vi(1<<n,INFTY));
		rep(i,n) dp[i][1<<i]=ss[i].size();
		repi(i,1,1<<n) rep(j,n) rep(k,n) if((i>>j&1) && !(i>>k&1))
			dp[k][i|1<<k]=min(dp[k][i|1<<k],dp[j][i]+add[j][k]);
		
		int res=INFTY;
		rep(i,n) res=min(res,dp[i].back());
		cout<<res<<endl;
	}
}

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

int main()
{
	int a, b, x;
	cin >> a >> b >> x;

	if (a <= x && x <= a + b)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B, C;
	cin >> A >> B >> C;

	int v = A;
	while (v <= A * B)
	{
		if (v%B == C)
		{
			cout << "YES" << endl;
			return 0;
		}
		v += A;
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
cards = []
cards.append( input() )
cards.append( input() )
cards.append( input() )

dict_str_index = { 'a':0, 'b':1, 'c':2 }

persons = [ 'A', 'B', 'C' ]

index = 0
num_of_cards = 10000000
while True:
	if ( len( cards[index] ) == 0 ) :
		print( persons[index] )
		exit()
	next_person = cards[index][0]
	cards[index] = cards[index][1:]
    
	index = dict_str_index[next_person]
    
    
	

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

struct ModInt {
    static ll mod;
    ll val;
    ModInt(ll v = 0) : val(v % mod) {}
    ModInt operator-() const { return ModInt(val ? mod - val : val); }
    ModInt &operator+=(ModInt a) {
        if ((val += a.val) >= mod) val -= mod;
        return *this;
    }
    ModInt &operator-=(ModInt a) {
        if ((val -= a.val) < 0) val += mod;
        return *this;
    }
    ModInt &operator*=(ModInt a) {
        val = (__uint128_t(val) * a.val) % mod;
        return *this;
    }
    ModInt &operator/=(ModInt a) {
        ll u = 1, v = a.val, s = 0, t = mod;
        while (v) {
            ll q = t / v;
            swap(s -= u * q, u);
            swap(t -= v * q, v);
        }
        a.val = (s < 0 ? s + mod : s);
        val /= t;
        return (*this) *= a;
    }
    ModInt inv() const { return ModInt(1) /= (*this); }
    bool operator<(ModInt x) const { return val < x.val; }
};
ll ModInt::mod = 1e9 + 7;

ostream &operator<<(ostream &os, ModInt a) {
    os << a.val;
    return os;
}
ModInt operator+(ModInt a, ModInt b) { return a += b; }
ModInt operator-(ModInt a, ModInt b) { return a -= b; }
ModInt operator*(ModInt a, ModInt b) { return a *= b; }
ModInt operator/(ModInt a, ModInt b) { return a /= b; }
ModInt pow(ModInt a, ll e) {
    ModInt x(1);
    for (; e > 0; e /= 2) {
        if (e % 2 == 1) x *= a;
        a *= a;
    }
    return x;
}

ModInt comb(int n, int k) {
    ModInt x = 1, y = 1;
    rep(i, k) {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

const int MAX = 200001;
long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long mod_comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n, k;
    cin >> n >> k;
    comb_init();
    ModInt res = 0;
    rep(i, min(n, k) + 1) res += mod_comb(n, i) * mod_comb(n - 1, n - i - 1);
    cout << res << endl;
}

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

int n, s, value[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, ans;

void dfs(int i, int count, int sum)
{
	if (n == count) {
		if (0 == sum) ans++;
	}else if (i >= 0) {
		dfs(i-1, count, sum);
		dfs(i-1, count+1, sum - value[i]);
	}
}
int main(void)
{
	while (cin >> n >> s) {
		if (n == 0 && s == 0) break;
		ans = 0;
		dfs(9, 0, s);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
num = map(int, raw_input().split())

flg=1
while flg==1:
    flg=0
    for i in range(2):
        if num[i]>num[i+1]:
            box = num[i]
            num[i]=num[i+1]
            num[i+1]=box
            flg=1

print "%d %d %d" % (num[0],num[1],num[2])

Measured memory_bytes: 6396
# include "cstdio"
# include "iostream"
# include "algorithm" 

using namespace std;
const int  maxn=100+10; 

int number[maxn],ans, 
	n; 
 
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&number[i]);
	}
	for(register int i=2;i<=n;i++){
		if(number[i-1]==number[i]){
			ans++;
			i++; 
		} 
	} 
	printf("%d",ans); 
	return 0; 
} 

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return accumulate(all(v),0LL);}
#pragma endregion template

void solve(ll N, vector<ll> T, ll M, vector<ll> P, vector<ll> X) {
  ll all_time = sum(T);
  for (int i = 0; i < M; i++) printf("%lld\n", all_time - T.at(P.at(i) - 1) + X.at(i));
}

int main() {
  ll N;
  ignore_ret(scanf("%lld",&N));
  vector<ll> T(N);
  for(int i = 0 ; i < N ; i++){
    ignore_ret(scanf("%lld",&T[i]));
  }
  ll M;
  ignore_ret(scanf("%lld",&M));
  vector<ll> P(M);
  vector<ll> X(M);
  for(int i = 0 ; i < M ; i++){
    ignore_ret(scanf("%lld",&P[i]));
    ignore_ret(scanf("%lld",&X[i]));
  }
  solve(N, move(T), M, move(P), move(X));
  return 0;
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define ll long long
	#define ld long double
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		T=1;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			int ar[3];
			cin>>ar[0]>>ar[1]>>ar[2];
			if(ar[0]==ar[1] && ar[0]!=ar[2])
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			else if(ar[0]==ar[2] && ar[0]!=ar[1])
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			else if(ar[1]==ar[2] && ar[1]!=ar[0])
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			cout<<"No"<<endl;

		}
		return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3+5;
const long long INF = (long long)1e13;
 
int n;
 
int a[N];
long long dp[N][N];
 
long long f (int i, int j) {
	if ((i + 1) == j) {
		dp[i][j] = abs(a[i] - a[j]);
		return dp[i][j];
	}
	if (i == j) {
		dp[i][j] = a[i];
		return a[i];
	}
	if (dp[i][j] != -INF) {
		return dp[i][j];
	}
	long long beg = f(i + 1, j);
	long long lst = f(i, j - 1);
	if ((a[i] - beg) > (a[j] - lst))
		dp[i][j] = a[i] - beg;
	else
		dp[i][j] = a[j] - lst;
	return dp[i][j];
}
 
int main () {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			dp[i][j] = -INF;

		
	cout << f(0, n - 1) << "\n";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    cout << n-i+1 << endl;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,M,a,b,n;
  int pathes = 0;
  cin >> N >> M;
  
  vector<vector<int> > vvi(N+1);
  vector<bool> visited(N+1);
  queue<int> connected;
  vector<int> path(N+1);
  

  REPI(N+1){
    visited[i] = false;
    path[i] = -1;
  }

  REPI(M)
  {
    cin >> a >> b;
    vvi[a].push_back(b);
    vvi[b].push_back(a);
  }

  connected.push(1);

  while(!connected.empty ())
  {
    n = connected.front();
    connected.pop ();
    if (visited[n])
      continue;
    
    visited[n] = true;
    for (auto i = vvi[n].begin(); i != vvi[n].end (); i++)
    {
      if (path[(*i)] != -1) 
        continue;
      
      path[(*i)] = n;
      pathes++;
      connected.push((*i));
    }
  }

  if (pathes < N-1)
    cout << "No" << endl;
  else
  {
    cout << "Yes" << endl;

    for(int i=2;i<=N;i++)
      cout << path[i] << endl;
  }    
  
  return 0;
}

Measured memory_bytes: 10368
package main


import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a)
	fmt.Scan(&b)

	fmt.Printf("%d\n", solve(a, b))
}

func solve(a, b string) int {
	ai, _ := strconv.Atoi(a)
	bi, _ := strconv.Atoi(b)
	if bi % ai == 0 {
		return ai + bi
	}else{
		return bi - ai
	}
}

Measured memory_bytes: 1836
#include <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int s = 0;
	for (int i = 0; i < 3; i++)
		s += in() << i;
	outl(s == 4 || s == 3 ? "Open" : "Close");
}


Measured memory_bytes: 2640
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final String str = sc.next();
			
			if("AAA".equals(str) || "BBB".equals(str)) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076
using System;
using System.Text;

namespace ABC048B
{
    static class Program
    {
        static void Main()
        {
            long[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long height = nbrs[0];
            long width = nbrs[1];

            StringBuilder res = new StringBuilder();
            for(int i = 0; i < height; i++)
            {
                string text = Console.ReadLine();
                res.Append(text + "\n");
                res.Append(text + "\n");
            }
            Console.WriteLine(res.ToString());
        }
    }
}

Measured memory_bytes: 11228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define ALL(a) begin(a), end(a)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    bool vis[26] = {};
    for (char c : s)
        vis[c - 'a'] = 1;
    for (int i = 0; i < 26; ++i)
        if (!vis[i]) {
            cout << (char)('a' + i) << '\n';
            return 0;
        }
    cout << "None\n"; 
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

char s[N];
int n,q,l,r,sum[N];
int main(){
	scanf("%d%d%s",&n,&q,s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='C'&&s[i-1]=='A')sum[i]++;
	for(int i=1;i<=n;i++)
		sum[i]+=sum[i-1];
	while(q--){
		scanf("%d%d",&l,&r);
		int ans=sum[r]-sum[l-1];
		if(s[l]=='C'&&s[l-1]=='A')ans--;
		printf("%d\n",ans);
	}
}

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

    #define ll long long

    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      
      
     string a,b;
     cin>>a>>b;
     ll i,j,m=a.length(), n=b.length();
     int dp[m+1][n+1];
     memset(dp,0,sizeof dp);
     for(i=1;i<=m;i++)
     {
      for(j=1;j<=n;j++)
      {
        if(a[i-1]==b[j-1])
          dp[i][j]=dp[i-1][j-1]+1;
        else
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
     }
     // cout<<dp[m][n];
     i=m;j=n;
     vector<char> out;
     while(i>0&&j>0&&dp[i][j]>0)
     {
      if(dp[i][j]==dp[i-1][j])i--;
      else if(dp[i][j]==dp[i][j-1])j--;
      else{
        i--; j--;
        out.push_back(a[i]);
      }
     }
     for(i=out.size()-1;i>=0;i--)
      cout<<out[i];
      return 0;
    } 

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < (int)(n);i++)
int main() {
  string s, t, ans;cin >> s >> t;
  int m = s.size(), n = t.size();
  vector<vector<int>> dp(m+1, vector<int>(n+1, 0));
  rep(i, m) rep(j, n){
    if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
    else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
  }
  int l = dp[m][n];
  m--;n--;
  while(l > 0){
    if(s[m] == t[n]){
      ans = s[m] + ans;
      m--;
      n--;
      l--;
    } else if(dp[m+1][n+1] == dp[m][n+1]) {
      m--;
    } else {
      n--;
    }
  }
  cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)3e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        string s;
        cin>>s;
        for(i=0;i<s.sz;i++){
                if(s[i]==','){
                        cout<<" ";
                }else{
                        cout<<s[i];
                }
        }
              
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  
  int l = s.length();
  int result = 0;
  for (int i = 0; i < l; i++) {
    if (s[i] != t[i]) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3916
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define INF 999999999

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int t, n;

int main()
{
	cin >> t;
	for (int i = 0; i < t; i++) {
		cin >> n;
		int h[150];
		for (int j = 0; j < n; j++) {
			cin >> h[j];
		}
		int upmax = 0, downmax = 0;
		for (int j = 1; j < n; j++) {
			int k = h[j] - h[j - 1];
			if (k < 0) {
				downmax = max(downmax,-k);
			}
			else upmax = max(upmax, k);
		}
		cout << upmax << " " << downmax << endl;
	}

	return 0;
}

Measured memory_bytes: 3120
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int m, n;
int b[550], r[550];

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

long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b;
}

struct edge { int to, cap, rev; };

const int MAX_SIZE = 2000;

vector<edge>G[MAX_SIZE];

void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}

bool used[MAX_SIZE];
int dfs(int p, int t, int f) {
	if (p == t)return f;
	used[p] = true;

	for (int i = 0; i<G[p].size(); i++) {
		edge &e = G[p][i];
		if (used[e.to] || e.cap == 0)continue;
		int _f = dfs(e.to, t, min(f, e.cap));
		if (_f) {
			e.cap -= _f;
			G[e.to][e.rev].cap += _f;
			return _f;
		}
	}

	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while (true) {
		REP(i, MAX_SIZE)used[i] = false;
		int f = dfs(s, t, INF);
		if (f)flow += f;
		else return flow;
	}
}

int main() {
	int s = 1234, t = 1235;
	while (cin >> m >> n&&m&&n) {

		REP(i, MAX_SIZE) {
			G[i].clear();
		}

		REP(i, m) {
			cin >> b[i];
			add_edge(s, i, 1);
		}
		REP(i, n) {
			cin >> r[i];
			add_edge(m + i, t, 1);
		}
		REP(i, m) {
			REP(j, n) {
				if (gcd(b[i], r[j]) != 1)add_edge(i, j + m, 1);
			}
		}
		cout << max_flow(s, t) << endl;
	}
}


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

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, M, i, j, k;
	scanf("%d%d", &N, &M);
	int **A = (int **)malloc(sizeof(int *) * N);
	int **B = (int **)malloc(sizeof(int *) * N);
	int *p = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		A[i] = (int *)malloc(sizeof(int) * M);
		B[i] = (int *)malloc(sizeof(int) * M);
		p[i] = 0;
		for(j = 0; j < M; j++){
			scanf("%d", &A[i][j]);
			A[i][j]--;
			B[i][A[i][j]] = j;
		}
	}
	int *count = (int *)malloc(sizeof(int) * M);
	int maxnum, thenval, ans = N;
	for(k = 1; k < M; k++){
//		printf("\nk = %d\n", k);
		for(j = 0; j < M; j++){
			count[j] = 0;
		}
		for(i = 0; i < N; i++){
			count[A[i][p[i]]]++;
		}
/*		for(j = 0; j < M; j++){
			printf("count[%d] = %d\n", j, count[j]);
		}
*/		maxnum = 0;
		for(j = 0; j < M; j++){
			if(count[j] > maxnum){
				maxnum = count[j];
				thenval = j;
			}
		}
//		printf("maxnum = %d\n", maxnum);
//		printf("thenval = %d\n", thenval);
		ans = min(ans, maxnum);
		for(i = 0; i < N; i++){
			A[i][B[i][thenval]] = -1;
/*			int l;
			for(l = 0; l < M; l++){
				printf("%d ", A[i][l]);
			}
			printf("\n");
*/			while(A[i][p[i]] == -1){
				p[i]++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896