akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;


int main(){
	
	string s;
	
	while(getline( cin,s)){
		while (s.find("the")==-1&&s.find("this")==-1&&s.find("that")==-1) {
			for (int i=0; i<s.size(); i++) {
				if (s[i]>='a'&&s[i]<'z') {
					s[i]++;
				}
				else if(s[i]=='z')
					s[i]='a';
			
			}
		}
		cout << s <<endl;
	}
	
	return 0;
}
 

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << (CEIL(c, b) <= CEIL(a, d) ? "Yes\n" : "No\n");

    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool kaibun = true;
    rep(i,(n-1)/2) {
        if (s[i] != s[n-i-1]) kaibun = false; 
    }
    bool kaibun_ = true;
    rep(i,(n-1)/2) {
        if (s[i] != s[(n-1)/2-1-i]) kaibun_ = false;
    }
    bool kaibun__ = true;
    rep(i,(n-1)/2) {
        if (s[i+(n+3)/2-1] != s[n-i-1]) kaibun__ = false;
    }
    if (kaibun && kaibun_ && kaibun__) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e5;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int x,y,n,m,k;
vp a;

int main(){
	cin>>x>>y>>n>>m>>k;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.push_back({x,0});
	}
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		a.push_back({x,1});
	}
	sort(a.rbegin(),a.rend());
	int tmp[2]={x,y};
	vl b(x+y+1);
	ll sum=0,I=0;
	for(int i=0;i<n+m;i++){
		int id=a[i].second;
		if(tmp[id]){
			tmp[id]--;
			sum+=a[i].first;
			I++;
			b[I]=sum;
		}
	}
	vi c(k);
	for(int	i=0;i<k;i++) cin>>c[i];
	sort(c.rbegin(),c.rend());
	ll res=0;
	sum=0;
	for(int i=x+y;i>=0;i--){
		res=max(res,b[i]+sum);
		if(x+y-i<k) sum+=c[x+y-i];
		else break;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3568
n=1<<18;N,m;L[1<<18],p;F[1<<18],X[1<<18];i;
long D[1<<20],Z[1<<20],A[1<<18],x,z;
long f(a,b,k,l,r){
	D[k]+=z=Z[k];
	Z[2*k+1]+=z;
	Z[2*k+2]+=z;
	Z[k]=0;
	return a<=l&r<=b?D[k]+(Z[k]=x):l<b&a<r?D[k]=fmax(
		f(a,b,2*k+1,l,(l+r)/2),
		f(a,b,2*k+2,(l+r)/2,r)
	):D[k];
}
main(j){
	for(gets(A);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];
	for(;i++<n;)for(f(i,i+1,0,0,n),p=F[i];p;p=X[p])x=A[p],x=f(L[p],i+1,0,0,n);
	printf("%ld",x);
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int X; cin >> X;

	if(X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}


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

int main(){
char b;
cin >> b;
if(b=='A') cout << "T" << endl;
else if(b=='C') cout << "G" << endl;
else if(b=='G') cout << "C" << endl;
else  cout << "A" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int color[9]={};
  int mn=0;
  int mx=0;
  REP(i,n){
    int a;cin>>a;
    if(1<=a && a<400)color[0]++;
    if(400<=a && a<800)color[1]++;
    if(800<=a && a<1200)color[2]++;
    if(1200<=a && a<1600)color[3]++;
    if(1600<=a && a<2000)color[4]++;
    if(2000<=a && a<2400)color[5]++;
    if(2400<=a && a<2800)color[6]++;
    if(2800<=a && a<3200)color[7]++;
    if(3200<=a)color[8]++;
  }
  REP(i,8){
    if(color[i]>0)mn++;
  }
  mx=mn+color[8];
  cout<<max(1,mn)<<" "<<mx<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    string a;
    int L;
    while(cin >> a >> L, L) {
        vector<string> record;
        string b = a;

        int retj = 0, ai = 0, retij = 0;
        for(int i=1; ; ++i) {
            record.push_back(b);
            b += string(L-b.size(), '0');
            string c = b;
            sort(begin(b), end(b));
            sort(begin(c), end(c), greater<char>());
            b = to_string(stoi(c) - stoi(b));

            bool finished = false;
            for(int j=0; j<record.size(); ++j) {
                if(b == record[j]) {
                    retj = j;
                    ai = stoi(b);
                    retij = i-j;
                    finished = true;
                }
            }
            if(finished) {
                break;
            }
        }
        cout << retj << " " << ai << " " << retij << endl;
    }
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#include <queue>
#include<map>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define PI 3.14159265358979323846264338327950


int main() {
	ll d, t, s, max=0, ans=0;

	cin >> d >> t >> s;

	ans = d / s;
	if (d%s != 0)ans++;
	if (ans > t){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <climits>
#include <queue>
#include <cmath>
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long int lli;
 
int memo[1000010] = { 0,0,1 };
double PI = 3.14159265359;
 
int N, A, B, C, D;
vvi graph;
vi flag;
vi flag_length;
 
 
//bool operator< (const pi& lhs, const pi& rhs) { return bool(lhs.first < rhs.first); }
 
//何行何列に飴が何個あるか
int cntX[100010], cntY[100010];
//飴がそえじ個ある列が何個あるか
int sumX[100010], sumY[100010];
 
int h[100010], w[100010];
 
//combination n+mCn  (n+m)!/(n!*m!)
 
long long int MOD = pow(10,9)+7;
 
//a^(p-2) mod p
 
lli powmod(lli a,lli p,lli m){
    
    if(p == 0)
        return 1;
    if(p == 1)
        return a;
    
    lli tmp = powmod(a,p/2,m);
    tmp%=m;
    tmp*=tmp;
    tmp%=m;
    
    if(p % 2 == 1){
        tmp *= a;
        tmp %= m;
        return tmp;
    }else{
        return tmp;
    }
}

#define MAX_N 1009
lli dp[MAX_N][MAX_N],ncr[MAX_N][MAX_N],dp2[MAX_N],kaijo[MAX_N],dp3[MAX_N][MAX_N];

int main(void){
    // Here your code !
    cin >> N >> A >> B >> C >> D;
    ncr[0][0]=ncr[1][0]=ncr[1][1]=1;
    
    for(int i = 2; i < N+2; i++){
		ncr[i][i]=1;
		ncr[i][0]=1;
		for(int j = 1; j < i; j++ ){
			ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%MOD;
		}
	}
	
	
	kaijo[0] = 1;
	for(int i = 1; i < MAX_N; i++) kaijo[i] = (kaijo[i-1] * i) % MOD;
	
	
	for(int i = 0; i < MAX_N; i++){
	    dp2[i] = powmod(kaijo[i],MOD-2,MOD);
	}
	
	for(int i = 0; i < MAX_N; i++){
	    for(int j = 0; j < MAX_N; j++)
	        dp3[i][j] = powmod( powmod(kaijo[i],j,MOD) ,MOD-2,MOD);
	}
	
	dp[0][0] = 1;
	for(int i = A; i <= B; i++){
    	dp[i-1][0] = 1;
	    for(int j = 0; j <= N; j++){
	        lli tmp = 0;
	        
	        
	        tmp = dp[i-1][j];
	        tmp %= MOD;
	        for(int k = C; k <= D; k++){
	            if(j-i*k < 0) break;
	            
	            lli tmp2 = dp[i-1][j-i*k] % MOD;
	            //tmp2 = tmp2 * ((kaijo[N-j+i*k] * powmod(kaijo[N-j],MOD-2,MOD)) % MOD );
	            tmp2 = tmp2 * ((kaijo[N-j+i*k] * dp2[N-j]) % MOD );
	            tmp2 %= MOD;
	            tmp2 = tmp2 * dp2[k];
	            tmp2 %= MOD;
	            //tmp2 = tmp2 * powmod( powmod(kaijo[i],k,MOD) ,MOD-2,MOD);
	            tmp2 = tmp2 * dp3[i][k];
	            tmp2 %= MOD;
	            tmp += tmp2;
	        }
	        
	        tmp %= MOD;
	        dp[i][j] = tmp;
	    }
	}
	/*
    for(int i = 0; i <= B; i++){
        for(int j = 0; j <= N; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    
    cout << dp[B][N] << endl;
}


Measured memory_bytes: 23040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {

		// --- input ---
		int num = Integer.parseInt(in.readLine());
		long[] vals = getNums(in.readLine().split(" "), num*3);
		in.close();

		Arrays.parallelSort(vals);
		long sum = 0;
		for(int i=num; i < num*3; i+=2) {
			sum+=vals[i];
		}

		// --- resolv ---
		System.out.println(sum);
	}
	public static long[] getNums(String[] vals, int num) {
		long[] vAry = new long[num];
		for(int i=0; i < num; i++) {
			vAry[i] = Integer.parseInt(vals[i]);
		}
		return vAry;
	}
}


Measured memory_bytes: 64644
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	VE l(n + 1), r(n + 1);
	rep(i, n)l[i + 1] = gcd(l[i], a[i]);
	for (int i = n - 1; i >= 0; i--) {
		r[i] = gcd(r[i + 1], a[i]);
	}
	int ans = 0;
	rep(i, n) {
		chmax(ans, gcd(l[i], r[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = List.sort compare @@ Array.to_list @@ Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d" @@ fun a -> a

let rec take res n acc = match (n, acc) with
  | (_, []) | (0, _) -> List.rev res
  | (i, x :: xs) -> take (x :: res) (n - 1) xs
let take = take []

let rec drop n acc = match (n, acc) with
  | (0, acc) -> acc
  | (_, []) -> []
  | (n, x :: xs) -> drop (n - 1) xs

let sum = List.fold_left (+) 0

let solve_1 () = 
  let left, right = take (n / 2) a, drop (n / 2) a in
  let head_r, tail_l = List.hd right, List.hd (List.rev left) in
  (sum right - sum left) * 2 - head_r + tail_l

let solve_2 () = 
  let left, right = take (n / 2) a, drop (n / 2 + 1) a in
  let mid_l, mid, mid_r = 
    List.hd (drop (n / 2 - 1) a),
    List.hd (drop (n / 2) a),
    List.hd (drop (n / 2 + 1) a)
  in
  max 
    ((sum right - sum left) * 2 - mid + mid_l)
    ((sum right - sum left) * 2 - mid_r + mid)

let () = Printf.printf "%d\n" @@ (if n mod 2 = 0 then solve_1 else solve_2) ()

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, q; cin >> n >> q;
  string s; cin >> s;

  vector<int> v;
  rep(i, n-1) {
    if(s[i] == 'A' && s[i+1] == 'C') {
      v.push_back(i);
    }
  }
  rep(i, q) {
    int l, r; cin >> l >> r;
    int ans = (lower_bound(v.begin(), v.end(), r-1) - lower_bound(v.begin(), v.end(), l-1));
    cout << ans << endl;
  }
}


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

int main(){
	int s=0;
int a=0,b=INT_MAX;
int c;
for(int d=0;d<4;d++){
	scanf("%d",&c);
	a+=c;
	b=min(b,c);
}
a-=b;
b=INT_MAX;
for(int d=0;d<2;d++){
	scanf("%d",&c);
	a+=c;
	b=min(b,c);
}
printf("%d\n",a-b);
}

Measured memory_bytes: 3176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var a = ReadLine();
		var r = a.Count(x => x == 'R');
		var w = a.Select((x, i) => new { x, i }).Where(x => x.i < r).Count(x => x.x == 'W');
		WriteLine(w);
	}
}


Measured memory_bytes: 23088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define time v[i].second
#define due v[i].first
int main(){
	ll N, now = 0;
	cin >> N;
	vector <pair<ll,ll>> v(N);
	for(ll i = 0; i < N; i++)
		cin >> time >> due;
	sort(v.begin(),v.end());
	// for(int i = 0; i < N; i++)
	// 	cout << due << ";" << time << endl;
	for(int i = 0; i < N; i++){
		now += time;
		if(now > due){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

typedef long long ll;

int n;

int a[101010];

ll s;
ll c1, c2;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    s = 0;
    for (int i = 1; i <= n; i++) {
        s += a[i];
        if (i%2 == 0 && s >= 0) {
            c1 += s+1;
            s = -1;
        } else if (i%2 == 1 && s <= 0) {
            c1 += -s+1;
            s = 1;
        }
    }
    s = 0;
    for (int i = 1; i <= n; i++) {
        s += a[i];
        if (i%2 == 1 && s >= 0) {
            c2 += s+1;
            s = -1;
        } else if (i%2 == 0 && s <= 0) {
            c2 += -s+1;
            s = 1;
        }
    }
    cout << min(c1,c2) << "\n";
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	string s;
	cin>>n>>s;
	string t;
	for(int i=0; i<(int)s.size(); ++i) {
		int c = (int)s[i] - 'A';
		c = (c+n)%(26);
		t += (char)c+'A';
	}
	cout<<t;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //整数の入力
    int A = sc.nextInt();
    int B = sc.nextInt();
    //条件分岐と出力
    if (A==1 && B==1) {
      System.out.println("Draw");
    } else if (A==1) {
      System.out.println("Alice");
    } else if (B==1) {
      System.out.println("Bob");
    } else {
      if (A==B) {
      	System.out.println("Draw");
      } else if (A > B) {
        System.out.println("Alice");
      } else {
        System.out.println("Bob");
      }
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int l = (n + x - 1)/x;
    cout << l*t << endl;
}

Measured memory_bytes: 3548
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
 
var a, b, c, hoji;
a = parseInt(lines[0], 10);
b = parseInt(lines[1], 10);
c = parseInt(lines[2], 10);
hoji = 0;
 
if(a > b){
    hoji = a;
    a = b;
    b = hoji;
}
if(b > c){
    hoji = b;
    b = c;
    c = hoji;
}
if(a > b){
    hoji = a;
    a = b;
    b = hoji;
}
     
console.log(a +" "+ b +" "+ c);
});

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int N;
    cin >> N;

    cout << "ABC" <<N<< endl;

   return 0;
}

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

using namespace std;

const int OfLen = 0;
const int OfRin = 1;

struct Point {
  int x, y;
  Point(){}
  Point(int x, int y):x(x), y(y){}
};

struct TPoint {
  Point Len, Rin;
  TPoint(){}
  TPoint(Point Len, Point Rin):Len(Len), Rin(Rin){}
};

int W, H;
string room[2][55];

bool isInRoom(int whose, Point p)
{
  if(0 <= p.x && p.x < W && 0 <= p.y && p.y < H && room[whose][p.y][p.x] != '#') return true;
  return false;
}

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

bool used[55][55][55][55];

bool isOpenGate(TPoint twinspos)
{
  memset(used, false, sizeof(used));

  queue<TPoint> que;
  que.push(twinspos);  

  while(!que.empty()) {
    TPoint tp = que.front(); que.pop();
    Point len = tp.Len, rin = tp.Rin;

    if(used[len.x][len.y][rin.x][rin.y]) continue;

    used[len.x][len.y][rin.x][rin.y] = true;

    if(room[OfLen][len.y][len.x] == '%' && room[OfRin][rin.y][rin.x] == '%') return true;
    if(room[OfLen][len.y][len.x] == '%' || room[OfRin][rin.y][rin.x] == '%') continue;

    for(int i = 0; i < 4; i++) {
      Point nextLen = len, nextRin = rin;

      Point IfLenMove = Point(len.x + dx[i], len.y + dy[i]);
      if(isInRoom(OfLen, IfLenMove)) nextLen = IfLenMove;
      
      Point IfRinMove = Point(rin.x - dx[i], rin.y + dy[i]);
      if(isInRoom(OfRin, IfRinMove)) nextRin = IfRinMove;

      if(used[nextLen.x][nextLen.y][nextRin.x][nextRin.y]) continue;      

      que.push(TPoint(nextLen, nextRin));
    }
  }
  return false;
}
  

int main()
{
  while(cin >> W >> H, W || H) {
    TPoint twinspos;
    for(int i = 0; i < H; i++) {
      cin >> room[OfLen][i] >> room[OfRin][i];
      for(int j = 0; j < W; j++) {
	if(room[OfLen][i][j] == 'L') twinspos.Len = Point(j, i);
	if(room[OfRin][i][j] == 'R') twinspos.Rin = Point(j, i);
      }
    }
    cout << (isOpenGate(twinspos) ? "Yes":"No") << endl;
  }
}

Measured memory_bytes: 11880
#include "bits/stdc++.h"
using namespace std;
char Str[20];

int main(){
    scanf( "%s" , Str );
    int Win = 0 , Loss = 0;
    int N = strlen( Str );

    for( int i = 0 ; i < N ; ++i ){
        if( Str[i] == 'o' ) ++Win;
        else ++Loss;
    }

    if( 15 - ( Win + Loss ) + Win >= 8 ) puts( "YES" );
    else puts( "NO" );
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import Counter

H, W, N = map(int, input().split())

# 3*3マスの処理用リスト
dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1],
       [-1, 0], [-1, -1], [0, -1], [1, -1]]

# そのマスを中心とする3*3グリッドに含まれる黒マスの数
dict = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    for dy, dx in dir:
        # 3*3グリッドは、H*Wの中に完全に含まれていなければならないことに注意
        if 2 <= a + dy <= H - 1 and 2 <= b + dx <= W - 1:
            dict[(a + dy, b + dx)] += 1

c = Counter(dict.values())
ans = [0 for _ in range(10)]

# ans[1], ans[2], ..., ans[9]を確定させる（ans[0]は後述）
for k, v in c.items():
    if v > 0:
        ans[k] = v

# 全体で作れる3*3グリッドは(H-2)*(W-2)個
# ans[1],...,ans[9]の総和を引くとans[0]になる
ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for i in range(10):
    print(ans[i])


Measured memory_bytes: 164428
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {

    int x, n, a[101]; cin >> x >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    int j = find(a, a+n, x)-a;
    if (j == n) cout << x << endl;
    else {
        int k = 1;
        while (j-k >= 0 && j+k < n) {
            if (j-k >= 0 && a[j-k] != x-k) {
                cout << x-k << endl;
                return 0;
            }
            else if (j+k < n && a[j+k] != x+k) {
                cout << x+k << endl;
                return 0;
            }
            k++;
        }
        if (j-k < 0 || (j-k >= 0 && a[j-k] != x-k)) cout << x-k << endl;
        else cout << x+k << endl;
    }

}



Measured memory_bytes: 3636
# ABC109b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
words = set()
lastWord = ''
for i in range(n):
    word = input()[:-1]
    if (i != 0 and word[0] != lastWord[-1] or word in words):
        print('No')
        exit()
    lastWord = word
    words.add(word)
print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	bool flag = true;
	ii info(0, 0);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (info.first + 1 == a[i]) {
			if (info.first == 0) ans += i - info.second;
			else ans += i - info.second - 1;
			info.first = a[i];
			info.second = i;
			flag = false;
		}
	}
	ans += n - info.second - 1;
	if (flag) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 1152
Public Class Program
  Shared Sub Main()
    Dim nr As Integer() = Cin.IntArr()
    Dim n As Integer = nr(0)
    Dim r As Integer = nr(1)
    Dim ans As Integer = r + (100 * (10 - n))
    If n >= 10 Then ans = r
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 13268
from collections import deque


A = input()
N = len(A)
a = ord('a')

edge = [[N + 1] * 26 for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
    for j in range(26):
        edge[i][j] = edge[i + 1][j]
    c = ord(A[i]) - a
    edge[i][c] = i + 1  # 文字cの直後の頂点


recon = [None] * (N + 2)  # DP復元用。(直前の頂点, 文字)を格納する。
q = deque()
q.append(0)  # 頂点
while q:
    i = q.popleft()
    if i == N + 1:  # 頂点N+1に到達したら処理終了
        break
    for j in range(26):
        ni = edge[i][j]
        if recon[ni] is None:  # その頂点に最短で到達した場合のみ次の処理を継続
            recon[ni] = (i, chr(a + j))
            q.append(ni)

i = N + 1
ans = []
while i > 0:
    pi, c = recon[i]
    ans.append(c)
    i = pi

print(''.join(reversed(ans)))


Measured memory_bytes: 126028
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1000000007;


int main() {
	int n, m;
	cin >> n >> m;
	vl p(n + 1);
	map<int, int> a;

	REP(i, m) {
		int t;
		cin >> t;
		a[t] = 1;
	}

	p[0] = 1;
	if (a.find(1) == a.end()) {
		p[1] = 1;
	}
	else {
		p[1] = 0;
	}
	FOR(i, 2, n + 1) {
		if (a.find(i) == a.end()) {
			p[i] = (p[i - 1] + p[i - 2]) % mod;
		}
		else {
			p[i] = 0;
		}
	}
	cout << p[n] << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	char a[10005],b[10005];
	cin>>a;
	cin>>b;
	int n=strlen(a);
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

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

int main() {
    ll n;
    cin>>n;
    n%=10;
    if(n==0)cout<<"pon"<<endl;
    if(n==1)cout<<"pon"<<endl;
    if(n==2)cout<<"hon"<<endl;
    if(n==3)cout<<"bon"<<endl;
    if(n==4)cout<<"hon"<<endl;
    if(n==5)cout<<"hon"<<endl;
    if(n==6)cout<<"pon"<<endl;
    if(n==7)cout<<"hon"<<endl;
    if(n==8)cout<<"pon"<<endl;
    if(n==9)cout<<"hon"<<endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A, B, C = sc.nextInt

  val z = if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    if (A == B && B == C) -1
    else {
      var a = A
      var b = B
      var c = C
      var i = 0

      while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        i += 1
        val a2 = a / 2
        val b2 = b / 2
        val c2 = c / 2
        a = b2 + c2
        b = a2 + c2
        c = a2 + b2
      }

      i
    }
  } else 0
  println(z)
}


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


int main(){
	int N,v,j;
	cin >> N;

	vector <int> A(N, 0);

	for (int i = 0; i < N; i++){
		cin >> A[i];
	}//????´???°N??????????????????????????£???

	for (int i = 0; i < N ; i++){
	
		v = A[i];//A[N-2]
		j = i - 1;//j=N-3

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

		for (int k = 0; k < N; k++){
			cout << A[k];
			if (k != N - 1)cout << " ";
		}cout << endl;

	
	}



	return 0;
}

Measured memory_bytes: 1196
H, W = map(int, input().split())
A = [input() for _ in range(H)]

U = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if A[h][w] == '#':
            U[h][w] = 0
            L[h][w] = 0
        else:
            U[h][w] = 1 + (U[h - 1][w] if h > 0 else 0)
            L[h][w] = 1 + (L[h][w - 1] if w > 0 else 0)

        y = H - h - 1
        x = W - w - 1
        if A[y][x] == '#':
            D[y][x] = 0
            R[y][x] = 0
        else:
            D[y][x] = 1 + (D[y + 1][x] if y < H - 1 else 0)
            R[y][x] = 1 + (R[y][x + 1] if x < W - 1 else 0)

ans = 0
for h in range(H):
    for w in range(W):
        if A[h][w] == '.':
            ans = max(ans, U[h][w] + D[h][w] + L[h][w] + R[h][w] - 3)
print(ans)


Measured memory_bytes: 179076
import Control.Applicative

main :: IO ()
main = solve <$> readLn >>= putStrLn

solve :: Int -> String
solve n
  | d == 3 = "bon"
  | d `elem` [0, 1, 6, 8] = "pon"
  | otherwise = "hon"
  where
    d = n `mod` 10


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define PB(x) push_back(x)
#define xx first
#define yy second
typedef long long ll;
typedef pair<int,int>PI;
typedef pair<pair<int,int>,int>PII;

int dirx[]= {1,0,-1,0},diry[]= {0,1,0,-1};
string x;
vector<int>xseq,yseq;
int destx,desty;
int main()
{
    cin>>x;
    cin>>destx>>desty;
    int cnt=0,seq=0,iff=1;;
    for(char n:x)
    {
        if(n=='F' && iff)
        {
            destx--;
        }
        else if(n=='F')
        {
            cnt++;
        }
        else if (!seq)
        {
            iff=0;
            if(cnt)xseq.PB(cnt);
            cnt=0;
            seq=1;
        }
        else
        {
            if(cnt)yseq.PB(cnt);
            cnt=0;
            seq=0;
        }
    }
    if(cnt)
    {
        if (!seq)
        {
            if(cnt)xseq.PB(cnt);
            cnt=0;
            seq=1;
        }
        else
        {
            if(cnt)yseq.PB(cnt);
            cnt=0;
            seq=0;
        }
    }
   // for(int i:xseq)cout<<i<<" ";
    //enl;
    //for(int j:yseq)cout<<j<<" ";
    //enl;
    set<int>xx,yy;
    if(xseq.size())
    {
        xx.insert(0);
        for(int i=0; i<xseq.size(); i++)
        {
            vector<int>v;
            for(int j:xx)
            {
                v.PB(j+xseq[i]);
                v.PB(j-xseq[i]);
            }
            xx.clear();
            for(int j:v)
                xx.insert(j);
        }
    }
    else xx.insert(0);
    if(yseq.size())
    {
        yy.insert(0);
        for(int i=0; i<yseq.size(); i++)
        {
            vector<int>v;
            for(int j:yy)
            {
                v.PB(j+yseq[i]);
                v.PB(j-yseq[i]);
            }
            yy.clear();
            for(int j:v)
                yy.insert(j);
        }
    }
    else yy.insert(0);
   // for(int j:xx)cout<<j<<" ";
    //enl;
    //for(int j:yy)cout<<j<<" ";
    //enl;
    if(xx.find(destx)!=xx.end() &&  yy.find(desty)!=yy.end())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> t(n),a(n);
  for(int i=0;i<n;i++){
    cin >> t[i] >> a[i];
  }
  for(int i=0;i<n-1;i++){
    if(t[i+1]<t[i]||a[i+1]<a[i]){
      long long m=max((t[i]+t[i+1]-1)/t[i+1],(a[i]+a[i+1]-1)/a[i+1]);
      t[i+1]*=m;
      a[i+1]*=m;
    }
  }
  cout << t[n-1]+a[n-1] << endl;
}

Measured memory_bytes: 256
while true
  m, n_min, n_max = gets.split.map(&:to_i)
  break if m + n_min + n_max == 0
  scores = Array.new(m) { gets.to_i }
  ans = 0
  gap_max = -1

  n_min.upto(n_max) do |n|
    gap = scores[n - 1] - scores[n]

    unless gap < gap_max
      gap_max = gap

      ans = n
    end
  end

  puts ans
end

Measured memory_bytes: 8784
fn main() {
    let r = std::io::stdin();
    let mut sc = Scanner::new(r.lock());

    let v = sc.read_line();
    let (a, b, c) : (i32, i32, i32) = (v[0].parse().unwrap(), v[1].parse().unwrap(), v[2].parse().unwrap());

    if (a == b && a != c) || (a == c && a != b) || (b == c && b != a){
        println!("Yes");
    } else {
        println!("No");
    }

}

pub struct Scanner<R: std::io::Read> (std::io::BufReader<R>);
 
impl<R: std::io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner (std::io::BufReader::new(r))
    }
 
    pub fn read_line(&mut self) -> Vec<String> {
        use std::io::BufRead;
        let mut line = String::new();
        self.0
            .read_line(&mut line)
            .unwrap();
 
        line.split_whitespace()
            .map(|b| b.to_string())
            .collect::<Vec<String>>()
    }
}

Measured memory_bytes: 4352
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	map<string,string> m;
	string s;
	m["ARC"] = "ABC";
	m["ABC"] = "ARC";
	cin >> s;
	cout << m[s];
}

Measured memory_bytes: 3572
n,h,w=map(int,input().split())
a=[0]*n
b=[0]*n
ans=0
for i in range(n):
    a[i],b[i]=map(int,input().split())
for j in range(n):
    if a[j]>=h and b[j]>=w:
        ans+=1
print(ans)

Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    ll n;
    cin >> n;

    ll ans = 0;
    for(int i = 1; i < n; i++){
        ans += i;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
while 1:
    try:
        s=input()
        n=[]
        for i in s:
            n.append(int(i))
        ans=n[0]+n[1]*9+n[2]*6+n[3]*4+n[4]*6+n[5]*6+n[6]*4+n[7]*6+n[8]*9+n[9]
        print(ans%10)
    except:break


Measured memory_bytes: 5588
k = int(input())
row = [1] * 8
col = [1] * 8
dpos = [1] * 15
dneg = [1] * 15
X = [['.' for j in range(8)] for i in range(8)]
for i in range(k):
    r, c = map(int, input().split())
    row[r] = col[c] = dpos[r+c] = dneg[r-c+7] = 0
    X[r][c] = 'Q'

def solve(i):
    while i < 8 and not row[i]:i += 1        
    if i == 8:
        for i in range(8):
            print(''.join(X[i]))
    for j in range(8):
        if not col[j] or not dpos[i+j] or not dneg[i-j+7]: continue
        row[i] = col[j] = dpos[i+j] = dneg[i-j+7] = 0
        X[i][j] = 'Q'
        solve(i+1)
        row[i] = col[j] = dpos[i+j] = dneg[i-j+7] = 1
        X[i][j] = '.'
solve(0)


Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int a, b, t; cin >> a >> b >> t;
	cout << t / a * b << endl;
	return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int n,m;
int cnt=0;

int a[4000000],b[4000000],c[4000000];

int main() 
{

int data[100];
data[0]=1;
int pi=1;
rep(i,6){
  pi*=6;
  data[i+1]=pi;
}
pi=1;
rep(i,5){
  pi*=9;
  data[i+7]=pi;
}
sort(data,data+12);

int n;
cin>>n;
int ans=0;
ll dp[100000]={0};
rep(i,n+1) dp[i]=INF;
dp[0]=0; dp[1]=1;
rep(j,12){
for(int i=data[j];i<=n;++i){
dp[i]=min(dp[i-data[j]]+1,dp[i]);
}
}
cout<<dp[n]<<endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll N,K,R,S,P;

ll score(char c){
	if(c == 'r')return P;
	if(c == 's')return R;
	if(c == 'p')return S;
	return 0;
}

int main(){
	cin>>N>>K>>R>>S>>P;
	string T; cin>>T;
	vector<bool> possible(1001000,true);
	ll ans = 0;
	rep(i,N){
		if(!possible[i])continue;
		ans += score(T[i]);
		if(T[i] == T[i+K])possible[i+K] = false;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());

  int nump = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a.at(i)) {
      nump++;
      x -= a.at(i);
    } else {
      break;
    }
  }
  if (nump == n && x) --nump;
  cout << nump << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b,t;
    cin>>a>>b>>t;
    t=(int)((t+0.5)/a);
    cout<<t*b;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "iostream"
#include "string"
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b;
  scanf("%d %d", &a,&b);
  int ans = -1;
  if (1<=a&&a<=9&&1<=b&&b<=9) {
    ans = a*b;
  }

  cout << ans << "\n";
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S[0] != S[1] && S[0] != S[2] && S[1] != S[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int dp[10][1001];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	dp[0][0] = 1;
	for(int i = 0; i <= 100; i++) {
		for(int j = 1000; j >= i; j--) {
			for(int k = 9; k > 0; k--) {
				dp[k][j] += dp[k-1][j-i];
			}
		}
	}

	int n, s;
	while(cin >> n >> s, n) {
		cout << dp[n][s] << endl;
	}
	return 0;
}


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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ');
        var s = l[0]; var t = l[1];
        var l2 = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var a = l2[0]; var b = l2[1];
        var u = Console.ReadLine();
        if (u == s) a--;
        else b--;
        Console.WriteLine($"{a} {b}");
    }
}

Measured memory_bytes: 13396
c = []
for i in range(3):
    c.append(list(map(int, input().split())))

def main():
    # tate
    dif = [[0,0,0],[0,0,0]]
    for i in range(2):
        for j in range(3):
            dif[i][j] = c[i+1][j] - c[i][j]

    if (dif[0][0] != dif[0][1] or dif[0][0] != dif[0][2]) or\
       (dif[1][0] != dif[1][1] or dif[1][0] != dif[1][2]):
        return "No"

    # yoko
    dif = [[0,0],[0,0],[0,0]]
    for i in range(3):
        for j in range(2):
            dif[i][j] = c[i][j+1] - c[i][j]

    if (dif[0][0] != dif[1][0] or dif[0][0] != dif[2][0]) or\
       (dif[0][1] != dif[1][1] or dif[0][1] != dif[2][1]):
        return "No"

    return "Yes"

print(main())

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

using namespace std ;

vector<int>vc;

int main ( ) {
int j = 0 , n , m = 0 , x ;
cin >> n >> x ;
for ( int i = 0 ; i < n ; i ++ ){
    cin>>m;
    vc.push_back ( m ) ;
    j += m ;
}
sort(vc.begin(),vc.end());
if( j < x and x - j > vc[0]){
    cout<<n+((x-j)/vc[0]);
}
else if (j==x){
    cout<<n;
}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  string s;cin>>s;
  s[0]++;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256