akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,mi,ma,A,B;
int a[100005];
int main()
{
    n=read();mi=n;ma=0;
    reg int i;
    for(i=1;i<=n;++i)
    {
        a[i]=read();
        mi=min(mi,a[i]);
        ma=max(ma,a[i]);
    }
    if(ma!=mi)
    {
        if(ma!=mi+1){puts("No");return 0;}
        for(i=1;i<=n;++i)if(a[i]==mi)A++;else B++;
        if(ma<=A){puts("No");return 0;}
        if(n-A>=2*(ma-A))puts("Yes");else puts("No");
        return 0;
    }
    if(ma==n-1||ma==1){puts("Yes");return 0;}
    if(ma*2<=n){puts("Yes");return 0;}puts("No");
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void print_a (int *, int);
void insertion_sort (int *, int, int, int *);
void shell_sort (int *, int);

int main (void) {
    int n;
    int *a;

    scanf ("%d", &n);

    a = (int *) malloc (sizeof(int) * n);
    for (int i=0; i<n; i++) scanf ("%d", a+i);

    shell_sort (a, n);

    free (a);
    return 0;
}

void print_a (int *a, int n) {
    for (int j=0; j<n; j++) {
            if (j==n-1) printf ("%d\n", a[j]);
            else printf ("%d ", a[j]);
        }
}

void insertion_sort (int *a, int n, int g, int *cnt) {
    for (int i=g; i<n; i++) {
        int v = a[i];
        int j = i-g;
        for (; j>=0 && a[j]>v; j-=g) {
            a[j+g] = a[j];
            *cnt=*cnt+1;
        }
        a[j+g] = v;
    }
}

void shell_sort (int *a, int n) {
    int cnt = 0;
    int m;
    int *g;

    if (n>pow(2, 100)) m=100;
    else if (n%2!=0) m=log2(n)+1;
    else m=log2(n);

    g = (int *) malloc (sizeof(int)*m);

    for (int i=m-1, h=1; i>=0; h*=2, i--) g[i] = h;

    for (int i=0; i<m; i++) insertion_sort (a, n, g[i], &cnt);

    printf ("%d\n", m);
    print_a (g, m);
    printf ("%d\n", cnt);
    for (int i=0; i<n; i++) printf ("%d\n", a[i]);

    free(g);
}



Measured memory_bytes: 5456
H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input() for _ in range(H)]

grid = [[0 for _ in range(W)] for _ in range(H)]
grid[Ch][Cw] = 1

stack1 = [(Ch, Cw)]
stack2 = []

answer = 0

while 1:
    while stack1:
        sh, sw = stack1.pop()
        stack2.append((sh, sw))
        for i, j in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
            nh, nw = sh + i, sw + j
            if 0 <= nh < H and 0 <= nw < W and S[nh][nw] != "#" and grid[nh][nw] == 0:
                if nh == Dh and nw == Dw:
                    print(answer)
                    exit()
                grid[nh][nw] = 1
                stack1.append((nh, nw))
    answer += 1

    while stack2:
        sh, sw = stack2.pop()
        for i in range(-2, 3):
            for j in range(-2, 3):
                nh, nw = sh + i, sw + j
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] != "#" and grid[nh][nw] == 0:
                    if nh == Dh and nw == Dw:
                        print(answer)
                        exit()
                    grid[nh][nw] = 1
                    stack1.append((nh, nw))
    if not stack1:
        print(-1)
        exit()

Measured memory_bytes: 86448
H,W=gets.split.map &:to_i
A=H.times.map{gets.chop}
r=Array.new(H){"."*W}
b=Array.new(H){"."*W}
H.times{|i|r[i][0]=b[i][-1]=?#}
0.step(H-1,2){|i|(W-1).times{|j|r[i][j]=?#}}
1.step(H-1,2){|i|1.upto(W-1){|j|b[i][j]=?#}}
H.times{|i|W.times{|j|r[i][j]=b[i][j]=?# if A[i][j]==?#}}
puts r*"\n", "", b*"\n"

Measured memory_bytes: 3964
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define G() Cr=getchar()
int Xr;char Cr;
inline int  rd(){
	Xr=0;G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<1)+(Xr<<3)+Cr-'0',G();
	return Xr;
}
int n,Ma,Mb,ans=99999999;
int dp[405][405];
int a[100],b[100],c[100];
int suma[100],sumb[100];
int main(){
	n=rd(),Ma=rd(),Mb=rd();
	for(int i=1;i<=n;i++)
		a[i]=rd(),b[i]=rd(),c[i]=rd(),suma[i]=suma[i-1]+a[i],sumb[i]=sumb[i-1]+b[i];
	
	for(int i=0;i<=400;i++)
		for(int j=0;j<=400;j++)
			dp[i][j]=99999999;
	dp[0][0]=0;	
	
	for(int k=1;k<=n;k++)
		for(int i=suma[k];i>=a[k];i--)
			for(int j=sumb[k];j>=b[k];j--)
				dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);		
				
			
	for(int i=1;i<=suma[n];i++)
		for(int j=1;j<=sumb[n];j++)
			if(i*Mb==j*Ma)
				ans=min(ans,dp[i][j]);
	
	printf("%d\n", (ans==99999999)?-1:ans );		
}


Measured memory_bytes: 896
N, M = map(int, input().split())
if N == M == 1:
    print("1")
elif N == 1:
    print(max(0, M - 2))
elif M == 1:
    print(max(0, N - 2))
else:
    print(max(N * M - (N - 1) * 2 - (M - 1) * 2, 0))

Measured memory_bytes: 3060
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  long long pAns,nAns,Ans;
  pAns = 2;
  nAns = 1;
  if(N==1) printf("1\n");
  else{
    for(int i = 2; i <= N; i++){
      Ans = nAns + pAns;
      pAns = nAns;
      nAns = Ans;
    }
    printf("%lld\n",Ans);
  }
  return 0;

}


Measured memory_bytes: 256
array = Array.new

while val = gets do
    array.push(val.chomp)
end

n = array[0].to_i
s = array[1]

alphabets = ('A'..'Z').to_a
strings = ''

if n > 0
    for i in 1..s.length do
        char = s.slice(i-1)
        index = alphabets.index(char)
        strings += alphabets[(index + n) % 26]
    end
else
    strings = s
end

puts(strings)

Measured memory_bytes: 34192
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int[] x = new int[n];
			int[] y = new int[n];
			for(int i=0;i<n;i++) {
				x[i] = sc.nextInt();
			}
			for(int i=0;i<n;i++) {
				y[i] = sc.nextInt();
			}
			double[] m_d = new double[4];
			for(int i=0;i<n;i++) {
				m_d[0] += Math.abs(x[i]-y[i]);
				m_d[1] += Math.pow(Math.abs(x[i]-y[i]),2);
				m_d[2] += Math.pow(Math.abs(x[i]-y[i]),3);
				m_d[3] = Math.max(m_d[3], Math.abs(x[i]-y[i]));
			}
			
			System.out.println(m_d[0]);
			System.out.println(Math.sqrt(m_d[1]));
			System.out.println(Math.cbrt(m_d[2]));
			System.out.println(m_d[3]);
		}
	}
}


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

using namespace std;
using ll = long long;


bool check(const vector<int> &a, int k, int sz)
{
    int cnt = 0;
    for (auto x: a) {
        cnt += (x-1)/sz;
    }
    return cnt <= k;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &it: a) cin >> it;

    int mx = a[0];
    for (auto x: a) mx = max(mx, x);
    if (k == 0) {
        cout << mx << '\n';
        return 0;
    }

    int lo = 1, hi = mx+11, mid;
    while (lo < hi) {
        mid = lo + (hi-lo)/2;
        if (check(a, k, mid)) {
            hi = mid;
        } else {
            lo = mid+1;
        }
    }
    cout << lo << '\n';
    return 0;
}


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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    string S;

    cin>>S>>S;

    cout<<"A"<<S[0]<<"C"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			int k = scan.nextInt();
			if(n == 0 && k == 0){
				break;
			}
			int[] d = new int[n];
			for(int i = 0;i < n;i++){
				d[i] = scan.nextInt();
			}
			int sum = 0;
			int max = 0;
			for(int i = 0;i < n-k+1;i++){
				sum = 0;
				for(int j = i;j < i+k;j++){
					sum += d[j];
				}
				if(max < sum){
					max = sum;
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 64164
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/////////////////////

int const N = 1e5 + 41;

int n, a[N];
vector<pii> b;

void pushb(){
	sort(a, a+n);
	reverse(a, a+n);
	int q = 1;
	fi(1, n){
		if(a[i] != a[i-1]){
			b.pb(mp(a[i-1], q));
			q = 1;
		}else{
			++q;
		}
	}
	b.pb(mp(a[n-1], q));
}

void solve(){
	pushb();
	int w = 0;
	priority_queue<ll, vector<ll>, greater<ll> > t;
	ll add = 0;
	int q = b[0].second;
	fi(1, sz(b)){
		int h = b[i-1].first - b[i].first;
		add += h;
		w = (h % 2 == 0 ? 0 : 1);
		int w0 = (b[i].second % 2 == 1 ? 0 : 1);
		if(w == 1 && w0 == 0 || w == 0 && w0 == 1){
			//nothing
		}else{
			if(w == 1){
				t.push(q + add);
			}else{
				t.push(q - 1 + add);
			}
		}
		w = 0;
		q += b[i].second;
	}
	if(b.back().first != 1){
		w = ((b.back().first - 1) % 2 == 0 ? 0 : 1);
		add += b.back().first - 1;
	}
	while(sz(t)){
		ll x = t.top();
		if(x - add < 0){
			t.pop();
		}else break;
	}
	if(sz(t) == 0){
		if(w){
			if( (n - 1) % 2 == 0){
				printf("First\n");
			}else{
				printf("Second\n");
			}
		}else{
			if( (n - 1) % 2 == 1){
				printf("First\n");
			}else{
				printf("Second\n");
			}
		}
	}else{
		ll x = t.top() - add;
		--x;
		x = max(x, 0LL);
		if(x % 2 == 0){
			printf("First\n");
		}else{
			printf("Second\n");
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d",&n);
	fi(0, n) scanf("%d",&a[i]);

	solve();



	return 0;
}

Measured memory_bytes: 2164
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long double ldb;
typedef complex<ldb> P;

ldb eps = 1e-8;
// 誤差を考慮した比較 sig(a-b) のように使う
// ret<0 なら a<b, ret>0 なら a>b, ret=0 なら a=b
int sig(ldb a) {return (a<-eps)?-1:(a>eps)?1:0;}
// 誤差を考慮した比較
bool eq(ldb a,ldb b){return abs(a-b)<eps;}
// 内積
ldb dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// 外積
ldb cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 多角形の面積
ldb area(vector<P> g) {
  ldb res = 0.0;
  for(int i = 0; i < int(g.size()); i++) {
    res += cross(g[i], g[(i+1)%(g.size())])/2;
  }
  return abs(res);
}

int main(void)
{
  vector<P> g;
  double a,b;
  while(scanf("%lf,%lf",&a,&b) == 2) {
    g.push_back(P(a,b));
  }
  printf("%Lf\n",area(g));
  return 0;
}

Measured memory_bytes: 1084
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var a = nextInt();
  var b = nextInt();
  myout(a ^ b);
}


Measured memory_bytes: 31072
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
	int N,red,blue;
	cin>>N>>blue;
	red=N-blue;
	vector<vector<int>>arr(N+1,vector<int>(N+1,0));
	arr[0][0]=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=i;j++){
			if(j==0 || j==i)
				arr[i][j]=1;
			else
				arr[i][j]=(arr[i-1][j]+arr[i-1][j-1])%mod;
		}
	}
	// cout<<"\n";
	// for(int j=1;j<=blue;j++){
	// 	cout<<arr[red+1][j]<<" ";
	// }
	cout<<endl;
	for(int j=1;j<=blue;j++){
		cout<<(1l*arr[red+1][j]*arr[blue-1][j-1])%mod<<"\n";
	}
	return 0;
}

Measured memory_bytes: 16000
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

LL dp[4001][4001];
const LL M=998244353;
string S;
int main() {
	cin >> S;
	dp[0][0]=1;
	int a=0;
	int b=0;
	for(int i=0;i<2*S.size();i++){
		if(i<S.size()){
			switch(S[i]){
				case '0':a+=2;break;
				case '1':a++;b++;break;
				case '2':b+=2;break;
			}
		}
		for(int j=0;j<=i;j++){
			if(j+1<=a){
				dp[i+1][j+1]+=dp[i][j];
				dp[i+1][j+1]%=M;
			}
			if(i-j+1<=b){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=M;
			}
		}
	}
	cout << dp[2*S.size()][a] << endl;


	return 0;
}



Measured memory_bytes: 123520
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  s = "Yes";
  ll q,p,r;
  q = p = r = 0;
  rep(i,0,n){
    ll a,b,c;
    cin >> a >> b >> c;
    if(abs(abs(p-b)+abs(r-c)) == 0){
      s = "No";
      break;
    }
    if(abs(q-a) % abs(abs(p-b)+abs(r-c)))s = "No";
    q = a;p = b;r = c;
  }
  print(s);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

void solve(){
    int h,a;
    cin>>h>>a;
    int ans=h/a;
    if(h%a!=0)
        ans++;
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

#define ll long long
#define ld long double
#define endl '\n'
#define With_the_name_of_Allah ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))

using namespace std;

long long mod ;
long long Fast_pow(long long a ,long long b)
{
    if(b==0)
        return 1;

    long long z=Fast_pow(a,b/2);


    if(b%2==0)return ((z%mod)*(z%mod))%mod; else return (((z*z)%mod)*a)%mod;
}



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


bool prime[1000001];

void sieve()
{
    memset(prime , true , sizeof prime);
    prime[0]=prime[1]=0;

    for(int i=2 ; i*i<=1000000; i++)
    {
        if(prime[i]==true)
        for(int j=i*i ; j<=100000 ; j+=i)
        prime[j]=false;
    }
}

ll lcm(ll a, ll b)
{
    return (a*b)/__gcd(a,b);
}
int store[1005][1005] ;
ll r,c;
char a[1005][1005] ;int ans;
const int m=1000000000+7;
ll fn(int i , int j)
{

    if(store[i][j]!=-1) return store[i][j];
    if(i==r-1 && j==c-1)
        return 1;

    else if(a[i][j]=='#')
        return 0;

    else if(i>=r || j>=c)
        return 0;

    else
       ans= (fn(i,j+1)%m+fn(i+1 , j)%m)%m;

       store[i][j]=ans;

    return ans ;
}
int main()
{
    cin>>r>>c;
    for(int i=0; i<r; i++)
        for(int j=0; j<c ; j++)
        cin>>a[i][j];

        memset(store , -1 , sizeof store);


        cout<<fn(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 5248
//  Created by Sengxian on 2017/6/5.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
//  AtCoder Regular Contest 075D DFS
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll power[19];
int pool[2][100], *c1 = pool[0] + 50, *c2 = pool[1] + 50;

ll dfs(int ALL, int n, ll D) {
	if (n == 0) return D == 0;
	if (n == 1) return (D == 0) * (9 + (ALL != 1));
	ll cnt = 0, X = power[ALL - (ALL - n) / 2 - 1] - power[(ALL - n) / 2];
	int *c = n == ALL ? c1 : c2;
	for (int i = -9; i <= 9; ++i) if (c[i]) {
		ll newD = D + i * X;
		if (fabs(newD) < X)
			cnt += c[i] * dfs(ALL, n - 2, newD);
	}
	return cnt;
}

int main() {
	power[0] = 1;
	for (int i = 1; i <= 18; ++i) power[i] = power[i - 1] * 10;
	
	for (int i = 1; i <= 9; ++i)
		for (int j = 0; j <= 9; ++j)
			c1[i - j]++;
	for (int i = 0; i <= 9; ++i)
		for (int j = 0; j <= 9; ++j)
			c2[i - j]++;

	int D;
	cin >> D;
	ll ans = 0;
	for (int i = 1; i <= 18; ++i)
		ans += dfs(i, i, D);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;
  int s1 = 0;
  int s2 = accumulate(vec.begin(), vec.end(), 0);
  int ans = s2 - s1;
  for (int i = 0; i < n; ++i) {
    s1 += vec[i];
    s2 -= vec[i];
    int tmp = abs(s2 - s1);
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
n,k = map(int,input().split())
p = list(map(int,input().split()))
ps = [p[0]] + [0]*(n-1)
for i in range(1,n):
    ps[i] = ps[i-1] + p[i]
maxs = ps[k-1]
for i in range(1,n-k+1):
    maxs = max(maxs,ps[i+k-1]-ps[i-1])

print((maxs+k)/2)

Measured memory_bytes: 32204
a = input()
b = input()

if len(a) == len(b):
    for i in range(0,len(a)):
        print(a[i]+b[i],end='')
else:
    for i in range(0,len(a) - 1):
        print(a[i] + b[i],end='')
    print(a[len(a) - 1])

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,m,n;
	string s;
	cin>>s;
	set<char> p;
	set<char>::iterator it;
	for(i=0;i<s.length();i++) p.insert(s[i]);
	int charnum=0;
	for(it=p.begin();it!=p.end();it++){
		charnum++;
	}
//	cout<<charnum<<endl;
	if(s.length()==charnum)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int main(void) {
 int a, b,c ;
 cin >> a >> b >> c;
  
  	if (a == b) cout << c << endl;
  	else if (b == c) cout << a << endl;
  	else cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	string s, t;
	int n, k;
	cin >> s >> t;
	n = s.length();

	if(s == t){
		puts("Yes");
		return 0;
	}
	loop(i, 1, n){
		int flag1=0, flag2=0;
		if(equal(s.begin()+i, s.end(), t.begin()) == 1)
			flag1 = 1;
		if(equal(s.begin(), s.begin()+(i-1), t.begin()+(n-i)) == 1)
			flag2 = 1;
		if(flag1 == 1 && flag2 == 1){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	reverse(S.begin(), S.end());
	//cout << S;
	string T[4] = { "maerd","remaerd","esare","resare" };
	int j = 0;
	bool flag = false;
	while (j < S.size()) {
		flag = false;
		for (int i = 0; i < 4; i++) {
			if (S.substr(j, T[i].size()) == T[i]) {
				j += T[i].size();
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
// ------------------------------------
// Date:2018/ 2/20
// Problem:AOJ 0582 TriangleTypes 0582.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define POW(n) (n)*(n)

int main()
{
  int acute,right,obtuse;
  acute = right = obtuse = 0;
  vector<int> length(3,0);
  while(scanf("%d %d %d",&length[0],&length[1],&length[2]) != EOF) {
    sort(ALL(length));
    if (length[2] >= length[0] + length[1]) break;
    else if (POW(length[2]) < POW(length[0]) + POW(length[1])) ++acute;
    else if (POW(length[2]) == POW(length[0]) + POW(length[1])) ++right;
    else ++obtuse;
  }
  printf("%d %d %d %d\n", acute+right+obtuse, right, acute, obtuse);
  return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
ll calc(ll x){
    int ans = 0;
    for(ll i=1;;i++){
        if(x>=i) ans++, x -= i;
        else break;
    }
//    cout<<x<<' '<<ans<<endl;
    return ans;
}
int main(){
    ll n; cin>>n;
    ll ans = 0;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int cnt = 0;
            while(n%i==0) cnt++, n /= i;
            ans += calc(cnt);
        }
    }
    if(n!=1) ans += calc(1);
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: String,
        b: String
    }
    println!("{}",
        if a.len() > b.len() { "GREATER" }
        else if a.len() < b.len() { "LESS" }
        else {
            if a > b { "GREATER" }
            else if a < b { "LESS" }
            else { "EQUAL" }
        });
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll N;
v_ll A,B;

vp_ll runlength(const v_ll vec,ll begin,ll end){
  vp_ll ret;
  ll ct=0;
  for (ll i=begin; i<end; i++){
      if ((i+1<end) && (vec[i]==vec[i+1]))ct++;
      else{
        ct++;
        ret.push_back(make_pair(vec[i],ct));
        ct=0;
      }
  }
  return ret;
}

bool comp_s_rev(const p_ll &y,const p_ll &x){
  return x.second<y.second || (x.first<y.first && x.second==y.second) ;
}

int main(){
  cin >>N;

  for (ll i=0;i<N/2;i++){
    ll a,b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }

  sort (A.begin(),A.begin()+N/2);
  sort (B.begin(),B.begin()+N/2);
  vp_ll C=runlength(A,0,N/2);
  vp_ll D=runlength(B,0,N/2);

  sort (C.begin(),C.end(),comp_s_rev);
  sort (D.begin(),D.end(),comp_s_rev);

  C.push_back(make_pair(-1,0));
  D.push_back(make_pair(-1,0));

  if (C[0].first==D[0].first){
    cout << min(N-C[0].second-D[1].second,N-C[1].second-D[0].second) << endl;
    return 0;
  }else{
    cout << N-C[0].second-D[0].second << endl;
  }

}


Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer S = sc.nextInt();
		Integer W = sc.nextInt();
		
		if(W >= S) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}

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

#define N 100001
int a[N], p[N];

int f(int x) {
  if (p[x] == x) p[x] = x;
  else p[x] = f(p[x]);
  return p[x];
}

void u(int x, int y) {
  p[f(x)] = f(y);
}

int main() {
  int n, m;
  cin >> n >> m;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    p[i] = i;
  }

  for(int i=1, x, y; i<=m; i++) {
    cin >> x >> y;
    u(x, y);
  }

  int r=0;
  for(int i=1; i<=n; i++)
    if (f(i) == f(a[i])) r++;
  cout << r << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int i;
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int try(long n, long div){
	return (n % div) ? (n % div == 1) : try(n/div, div);
}

int main(void){
	long n;
	int count = 0;

	scanf("%ld", &n);

	if(n > 1e5) {
		for(long i=2; i*i <= n; i++) {
			if(try(n, i)) {
				count++;
				if(i != n / i && try(n, n/i))
					count++;
			}
		}
		count+=2;
	}else{
		for(int i=2; i <= n; i++) {
			if(try(n, i))
				count++;
		}
	}
	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

string A, B;
vvi DP;


bool in() {
	cin >> A >> B;
	A = " "+A;
	B = " "+B;
	DP.resize(A.sz, vi(B.sz));
	
	return true;
}

ll solve() {
	
	rep(i, 1, A.sz)
		rep(j, 1, B.sz) {
			DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
			if(A[i] == B[j])
				maxe(DP[i][j], DP[i-1][j-1]+1);
		}
	
	int i = A.sz-1;
	int j = B.sz-1;
	vc R;
	
	while(i > 0 && j > 0) {
		if(DP[i][j] == DP[i-1][j])
			--i;
		else if(DP[i][j] == DP[i][j-1])
			--j;
		else {
			R.pb(A[i]);
			--i;
			--j;
		}
	}
	
	reverse(bend(R));
	
	for(auto i : R)
		printf("%c", i);
	printf("\n");
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 35584
N = int(input())
JPY,BTC = [],[]
for i in range(N):
    X,Y = input().split()
    if Y == 'JPY':
        JPY.append(float(X))
    else:
        BTC.append(float(X))
ans = sum(JPY) + sum(BTC) * 380000
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
char first[200000];
char last[200000];
int main() {
	char s[100001], c;
	int q, t, f, turn = 0;
	int fNum = 0, lNum = 0;
	scanf("%s", s);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &t);
		if (t == 1) {
			// turn 0:普通,1:逆
			turn ^= 1;
		} else {
			scanf("%d %c", &f, &c);
			if ((f == 1 && turn == 0) || (f == 2 && turn == 1)) {
				first[fNum] = c;
				fNum++;
			} else {
				last[lNum] = c;
				lNum++;
			}
		}
	}
	if (turn == 0) {
		for (int i = fNum - 1; i >= 0; i--) {
			printf("%c", first[i]);
		}
		printf("%s%s", s, last);
	} else {
		for (int i = lNum - 1; i >= 0; i--) {
			printf("%c", last[i]);
		}
		for (int i = strlen(s) - 1; i >= 0; i--) {
			printf("%c", s[i]);
		}
		printf("%s", first);
	}
	return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;

vector<string> dp;
int N, M;
int mh[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int A[9];

string rec(int n) {
    if (dp[n] != "a") return dp[n];

    string res = "b";

    int sz = 2;
    rep(i, M) {
        if (n < mh[A[i]]) continue;
        string t = rec(n - mh[A[i]]);
        if (sz <= t.size()) {
            sz = t.size();
            res = to_string(A[i]) + t;
        }
    }

    dp[n] = res;
    return res;
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> A[i];
    }
    sort(A, A + M);

    dp.assign(10005, "a");
    dp[0] = "aa";

    string s = rec(N);
    int x = s.size();
    s = s.erase(x - 2);

    cout << s << endl;

}

Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
string s, t;
map<char, int> ds, dt;
int main(void){
	cin >> s >> t;
	int n = s.length();

	vector<int> ns(n), nt(n);
	rep(i, n){
		if(ds.find(s[i]) == ds.end()) ds[s[i]] = i;
		ns[i] = ds[s[i]];
	}

	rep(i, n){
		if(dt.find(t[i]) == dt.end()) dt[t[i]] = i;
		nt[i] = dt[t[i]];
	}

	if(ns == nt) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (t > (int)d / s || ((int) d / s == t && d % s == 0)) {
            cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    int n;
    long int c, k;
    cin >> n >> c >> k;
    long t[n]={0};
    for(int i=0; i<n; i++) cin >> t[i];
    sort(t, t+n);
    int cap = 1, norm = t[0], bus=1;
    for(int i=0; i<n; i++)
    {
        int time_span = norm + k;
        if(time_span >= t[i]) cap++;
        if(time_span < t[i] || cap == c)
        {
            cap = 0;
            norm = t[i];
            bus++;
        }
    }
    cout << bus << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 58) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


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

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int W = sc.nextInt();
			int H = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();

			if (((x+r <= W) && (y+r <= H)) && ((x-r >= 0) && (y-r >= 0))) {
				System.out.println("Yes");
			} else System.out.println("No");
		}
	}
}



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

int main(){
        long long a, b, n, mini;
        cin >> a >> b >> n;
        mini = min(b-1, n); 

        cout << ((a*mini) / b) - (a * (mini/b)) << endl;
        return 0;
}


Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
char s[100050];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<=25;i++){
        int bj=0;
        for(int j=0;j<len;j++)
        if(s[j]==i+'a'){bj=1;break;}
        if(!bj){putchar(i+'a');puts("");return 0;}
    }
    puts("None");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N;
	map<char,int> march;
	march['M']=0,march['A']=1,march['R']=2,march['C']=3,march['H']=4;
	int mnum[5]={0};
	string S[100000];
	ll toori=0;
	scan(N);
	rep(i,N){
		scan(S[i]);
		if(S[i][0]=='M'||S[i][0]=='A'||S[i][0]=='R'||S[i][0]=='C'||S[i][0]=='H'){
			mnum[march[S[i][0]]]++;
		}
	}
	rep(i,5){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				toori+=(ll)mnum[i]*mnum[j]*mnum[k];
			}
		}
	}
	prin(toori);
	return 0;
}


Measured memory_bytes: 6144
n = gets.chomp.to_i
ll = []

n.times do
  x, l = gets.chomp.split.map(&:to_i)
  ll << [x - l, x + l]
end

ll.sort_by!{ |x| x[1]}

ans = 1
prev = ll[0][1]

1.upto(n-1) do |i|
  if prev <= ll[i][0]
    ans += 1
    prev = ll[i][1]
  end
end

p ans


Measured memory_bytes: 12664
sa = input()
sb = input()
sc = input()
a_idx = 0
b_idx = 0
c_idx = 0
next_ = 'a'
while True:
    if next_ == 'a':
        if a_idx >= len(sa):
            print('A')
            break
        next_ = sa[a_idx]
        a_idx += 1
    elif next_ == 'b':
        if b_idx >= len(sb):
            print('B')
            break
        next_ = sb[b_idx]
        b_idx += 1
    elif next_ == 'c':
        if c_idx >= len(sc):
            print('C')
            break
        next_ = sc[c_idx]
        c_idx += 1


Measured memory_bytes: 3064
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
data=[[] for i in range(n+1)]
for u in ab:
    a,b=u
    data[a].append(b)
    data[b].append(a)
for u in data[1]:
    if n in data[u]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 66848
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
a = int(s[0]) - 1 + 9 * (len(s) - 1)
b = sum(map(int, s))
print(max(a, b))

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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

struct edge{
	int u,v,w;
};

vector<edge> edges;

#undef int
int main() {
#define int long long int
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int l; cin>>l;
    int r = (int)log2(l)+1;

    int x=1;
    for(int i=1;i<r;i++){
    	edges.pb({i,i+1,0});
    	edges.pb({i,i+1,x});
    	x=x*2;
    }
    int n=r;

    r=(int)log2(l-x)+1;
    while((l-x)){
    	edges.pb({r,n,x});
    	x=x+power(2,r-1);
    	r=(int)log2(l-x)+1;
    }

    int m=edges.size();
    cout<<n<<" "<<m<<endl;
    for(int i=0;i<m;i++){
    	cout<<edges[i].u<<" "<<edges[i].v<<" "<<edges[i].w<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

inline void print(ll n){
	if(!n) return ;
	ll p = n%26;
	
	if(p) print(n/26);
	else print((n-26)/26),p += 26;
	
	printf("%c",(p-1)+'a');
	return ;
}

int main()
{	
	ll n;
	scanf("%lld",&n);
	print(n);
	return 0;
} 

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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=100005;
//i_am_noob
int n,ans=inf,k1,k2,k;
vector<int> vec1,vec2,vec3;
vector<int> prime;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    n*=2;
    rep2(i,2,inf){
        if(i*i>n) break;
        if(n%i==0) prime.pb(1);
        while(n%i==0){
            n/=i;
            prime.back()*=i;
        }
    }
    if(n>1) prime.pb(n);
    vec1.resize(2),vec2.resize(2),vec3.resize(2);
    vec1[0]=0,vec1[1]=1;
    rep(pow2(sz(prime))){
        k1=k2=1;
        rep1(j,sz(prime)){
            if(pow2(j)&i) k1*=prime[j];
            else k2*=prime[j];
        }
        vec2[0]=k1,vec2[1]=k2;
        rep1(j,2){
            vec3[0]=vec1[0]%vec2[0],vec3[1]=vec1[1]%vec2[1];
            k=crt(vec3,vec2).first;
            if(k<=1) k+=crt(vec3,vec2).second;
            ans=min(ans,k);
            swap(vec1[0],vec1[1]);
        }
    }
    print1(ans-1);
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,N,M;
  cin >> N >> M;
  vector<int>DP(N+1,0),issafe(N+1,1);
  rep(i,0,M){
    cin >> A;
    issafe[A]=0;
  }
  DP[0]=1;
  if(issafe[0])DP[1]=1;
  rep(i,2,N+1){
    if(issafe[i-2])DP[i]+=DP[i-2];
    if(issafe[i-1])DP[i]+=DP[i-1];
    DP[i]%=mod;
  }
  Out(DP[N]);
}

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

int main(){
    int n;
    cin>>n;
    vector<long long> L(n);
    for(int i=0;i<n;++i) cin>>L[i];

    sort(L.begin(),L.end());
    long long ans=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            long long rest=L[i]+L[j];
            int n=lower_bound(L.begin(),L.end(),rest)-L.begin();
            ans+=max(n-j-1,0);
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
from sys import stdin

def partition(cards, start, end):
    p = cards[end]
    p_idx = start
    for i in range(start, end):
        c = cards[i]
        if c[1] <= p[1]:
            cards[i], cards[p_idx] = cards[p_idx], cards[i]
            p_idx = p_idx + 1
    cards[p_idx], cards[end] = cards[end], cards[p_idx]
    return p_idx


# in-place quicksort
def quicksort(cards, start, end):
    if start < end:
        p_idx = partition(cards, start, end)
        quicksort(cards, start, p_idx - 1)
        quicksort(cards, p_idx + 1, end)


def merge(nums, left, mid, right):
    l = nums[left:mid] + [('_', 9999999999)]
    r = nums[mid:right] + [('_', 9999999999 )]
    l_cur = 0
    r_cur = 0
    for i in range(right - left):
        if l[l_cur][1] > r[r_cur][1]:
            nums[left + i] = r[r_cur]
            r_cur = r_cur + 1
        else:
            nums[left + i] = l[l_cur]
            l_cur = l_cur + 1


def mergesort(nums, left, right):
    if right - left <= 1:
        return nums
    else:
        mid = (left + right) // 2
        mergesort(nums, left, mid)
        mergesort(nums, mid, right)
        merge(nums, left, mid, right)


def is_stable_result(orig, result):
    stable_result = orig[:]
    mergesort(stable_result, 0, len(stable_result))
    is_stable = True
    for c1, c2 in zip(stable_result, result):
        if c1 != c2:
            is_stable = False
    return is_stable


def parseLine(l):
    kind, num = l.strip().split(' ')
    return (kind, int(num))


def main():
    _, *lines = stdin.readlines()
    nums = [parseLine(l) for l in lines]

    # sort
    result = nums[:]
    quicksort(result, 0, len(result) - 1)

    # check is stable
    is_stable = is_stable_result(nums, result)
    print('Stable' if is_stable else 'Not stable')
    print('\n'.join([kind + ' ' + str(num) for (kind, num) in result]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 30508
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int A, B, C, D, L, tmp1, tmp2;

int main(){

	cin >> L >> A >> B >> C >> D;

	if (A % C != 0)tmp1 = A / C + 1;
	else tmp1 = A / C;
	if (B % D != 0)tmp2 = B / D + 1;
	else tmp2 = B / D;

	L -= max(tmp1, tmp2);

	cout << L << endl;

	return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int d = Integer.parseInt(sc.next());
        
        if(d == 25){
            System.out.println("Christmas");
        }else if(d == 24){
            System.out.println("Christmas Eve");
        }else if(d == 23){
            System.out.println("Christmas Eve Eve");
        }else{
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 21716