akhauriyash/Code-Regression huggingface dataset:
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T 
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn dfs(i: usize, n_info: (usize, usize), m:usize, state: &mut Vec<usize>, reps: &mut Vec<(usize, usize, usize, usize)>) -> usize {
    let mut temp = 0;

    if n_info.0 < n_info.1 {
        for temp_i in i..=m {
            state.push(temp_i);
            temp = max(temp, dfs(temp_i, (n_info.0 + 1, n_info.1), m, state, reps));
            state.pop().unwrap();
        }
    } else if n_info.0 == n_info.1 {
        for &(a, b, c, d) in reps.iter() {
            if state[b-1] - state[a-1] == c {
                temp += d;
            }
        }
    } else {
        panic!("temp");
    }
    temp
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let n = in_vec[0];
    let m = in_vec[1];
    let q = in_vec[2];

    // $B0lC6(B 10 $B=E%k!<%W$G5a$a$F$_$k(B
    let mut reps = Vec::<(usize, usize, usize, usize)>::new();
    for _i in 0..q {
        let in_vec: Vec<usize> = read_line();
        reps.push((in_vec[0], in_vec[1], in_vec[2], in_vec[3]));
    }

    let mut state: Vec<usize> = Vec::new();
    let res = dfs(1, (0, n), m, &mut state, &mut reps);

    println!("{}", res);

    // let mut res = 0;
    // for l0 in 1..m+1 {
    //     for l1 in l0..=m {
    //         for l2 in l1..=m {
    //             for l3 in l2..=m {
    //                 for l4 in l3..=m {
    //                     for l5 in l4..=m {
    //                         for l6 in l5..=m {
    //                             for l7 in l6..=m {
    //                                 for l8 in l7..=m {
    //                                     for l9 in l8..=m {
    //                                         let mut temp = 0;
    //                                         let state = vec![l0, l1, l2, l3, l4, l5, l6, l7, l8, l9];
    //                                         for &(a, b, c, d) in reps.iter() {
    //                                             if state[b-1] - state[a-1] == c {
    //                                                 temp += d;
    //                                             }
    //                                         }
    //                                         res = max(res, temp);
    //                                     }
    //                                 }
    //                             }
    //                         }
    //                     }
    //                 }
    //             }
    //         }
    //     }
    // }

    // println!("{}", res);
}


Measured memory_bytes: 2084
N = input()
l = len(N)
# print(len(N))


ans = 0

if l % 2 == 0:  # 偶数

    for i in range(1, l, 2):
        ans += 9*(10**(i-1))
        # print("i", i)
    print(ans)

else:
    for i in range(1, l, 2):
        ans += 9*(10**(i-1))
        # print("i", i)
    ans += int(N) - 10**(l-1) + 1
    print(ans)


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

int main()
{
  int N, Y;
  cin >> N >> Y;

  bool ok = false;
  for (int x = 0; x <= N; ++x)
  {
    for (int y = 0; y <= N; ++y)
    {
      if (x + y > N) break;
      int z = N - (x + y);
      if (x * 10000 + y * 5000 + z * 1000 == Y)
      {
        cout << x << " " << y << " " << z << endl;
        ok = true;
        goto LOOP_END;        
      }
    }
  }

LOOP_END:
  if (!ok) cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD = 1000000007;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    ll N,K;
    cin >> N >> K;
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        mp[a] += b;
    }
    int ans = 0;
    for(const auto& key : mp){
        ans = key.first;
        if((K-key.second) <= 0){
            break;
        }
        K -= key.second;
    }
    cout << ans << endl;
}


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

int main(){
    int n,m,k,a;
    cin>>n>>m;
    bool b[m][n];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            b[i][j]=false;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a;
            b[a-1][i]=true;
        }
    }
    int ans=0;
    for(int i=0;i<m;i++){
        bool is_liked=true;
        for(int j=0;j<n;j++){
            if(b[i][j]==false){
                is_liked=false;
            }
        }
        if(is_liked){
            ++ans;
        }
    }
    cout<<ans<<endl;
}


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

int main(void){
    int H, W;
    vector<string> a(100);

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

    for(int i = 0; i < W + 2; i++){
        putchar('#');
    }
    putchar('\n');

    for(int i = 0; i < H; i++){
        putchar('#');
        cout << a[i];
        putchar('#');
        putchar('\n');
    }

    for(int i = 0; i < W + 2; i++){
        putchar('#');
    }
    putchar('\n');

    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ret = w * (h / 2);
  if (h % 2) ret += (w + 1) / 2;
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {FIN

	ll n, w, i, j;
	cin >> n >> w;
	vvll dp(n + 1, vll(w + 1));
	vll ws(n), vs(n);

	for (i = 0; i < n; i++)
		cin >> ws[i] >> vs[i];

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= w; j++) {
			dp[i][j] = dp[i - 1][j];
			if (ws[i - 1] <= j)
				dp[i][j] = max(dp[i][j], vs[i - 1] + dp[i - 1][j - ws[i - 1]]);
		}
	}

	cout << dp[n][w] << "\n";

	return 0;
}

Measured memory_bytes: 82952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string ac="AC",wa="WA",tle="TLE",re="RE";
  int c1=0,c2=0,c3=0,c4=0;
 ll t;cin>>t;
  while(t--){
    string s; cin>>s;
    if(s.compare(ac)==0)c1++;
    else if(s.compare(wa)==0)c2++;
    else if(s.compare(tle)==0)c3++;
    else c4++;
  }
  cout<<ac<<" x "<<c1<<endl;
  cout<<wa<<" x "<<c2<<endl;
  cout<<tle<<" x "<<c3<<endl;
  cout<<re<<" x "<<c4;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;


void solve(long long R){

    
    cout << 2*M_PI*R << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long R;
    scanf("%lld",&R);
    solve(R);
    return 0;
}


Measured memory_bytes: 3844
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,cnt=0,x;
  cin >> n;
  while(true) {
    x=n,cnt=0;
    for(int j=2; j*j<=x; j++) {
      if(x%j==0) {
        cnt++;
      }
    }
    if(cnt==0) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin>>A>>B;
  if(A==1)A+=13;
  if(B==1)B+=13;
  if(A<B)cout<<"Bob";
  else if(A>B)cout<<"Alice";
  else cout<<"Draw";
}

Measured memory_bytes: 256
s=input()
a=s[::-1]
n=len(s)

if s!=a:
    print('No')
    exit()

b=s[:int((n-1)/2)]
c=b[::-1]

if b!=c:
    print('No')
    exit()

d=s[int((n+3)/2)-1:]
e=d[::-1]   

if d!=e:
    print('No')
    exit()

print('Yes')  

Measured memory_bytes: 3064
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_B&lang=jp
# Binary Search Tree II: python3
# 2018.11.27 yonezawa

import sys
input = sys.stdin.readline
import cProfile

class node:
    def __init__(self,nodeid):
        self.parent = None
        self.c_left = None
        self.c_right = None
        self.nodeid = nodeid

    def setChild(self,n,cn=None):
        if (cn == None):
            cn = self
        if ( cn.nodeid < n):
            if (cn.c_right == None):
                cn.c_right = node(n) 
                cn.c_right.parent =  cn 
            else:
                self.setChild(n,cn.c_right)
        else:
            if (cn.c_left == None):
                cn.c_left = node(n) 
                cn.c_left.parent =  cn 
            else:
                self.setChild(n,cn.c_left)

    def getPreorder(self,r1=[]):
        r1.append(self.nodeid)
        if (self.c_left != None):
            r1 = self.c_left.getPreorder(r1)
        if (self.c_right != None):
            r1 = self.c_right.getPreorder(r1)
        return r1       
    def getInorder(self,r1=[]):
        if (self.c_left != None):
            r1 = self.c_left.getInorder(r1)
        r1.append(self.nodeid)
        if (self.c_right != None):
            r1 = self.c_right.getInorder(r1)
        return r1       
    def getPostorder(self,r1=[]):
        if (self.c_left != None):
            r1 = self.c_left.getPostorder(r1)
        if (self.c_right != None):
            r1 = self.c_right.getPostorder(r1)
        r1.append(self.nodeid)
        return r1       

    def find(self,n):
        if self.nodeid == n:
            return True
        if self.nodeid > n:
            if (self.c_left == None ):
                return False
            return self.c_left.find(n)
        else:
            if  (self.c_right == None):
                return False
            return self.c_right.find(n)
    
    def getRoot(self):
        if (self.parent == None):
            return self
        return self.parent.getRoot()

def main():
    n = int(input())
    root = None
    for i in range(n):
        l = list(map(str,input().split()))
        if (l[0] == "print" and root != None):
            print("",*root.getInorder([]))
            print("",*root.getPreorder([]))
        elif (l[0] == "insert"):
            d = int(l[1])
            if ( root == None):
                root = node(d)
            else:
                root.setChild(d)
        elif (l[0] == "find"):
            d = int(l[1])
            r = root.find(d)
            if (r == True):
                print ("yes")
            else:
                print ("no")

if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


Measured memory_bytes: 96136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		double ans;
		ans = ((double)l/3) * ((double)l/3) * ((double)l/3);
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long L_MAX = 20000000000;
int main()
{
  int a,b,q,i,iis,iit;
  long long tt,x,res;
  vector<long long> s,t;
  decltype(s)::iterator is,it;
  long long tm[8];
  cin >> a >> b >> q;
  for(i=0;i<a;i++){
    cin >> tt;
    s.push_back(tt);
  }
  for(i=0;i<b;i++){
    cin >> tt;
    t.push_back(tt);
  }
  for(i=0;i<q;i++){
    cin >> x;
    fill(tm,tm+8,L_MAX);
    is=lower_bound(s.begin(),s.end(),x);
    if(is!=s.end()){
      it=lower_bound(t.begin(),t.end(),*is);
      if(it!=t.end())
        tm[0]=(*it)-x;
      if(it!=t.begin()){
        iit=(int)distance(t.begin(),it);
        tm[1]=(*is)*2-x-t[iit-1];
      }
    }
    if(is!=s.begin()){
      iis=(int)distance(s.begin(),is);
      it=lower_bound(t.begin(),t.end(),s[iis-1]);
      if(it!=t.end())
        tm[2]=x+(*it)-s[iis-1]*2;
      if(it!=t.begin()){
        iit=(int)distance(t.begin(),it);
        tm[3]=x-t[iit-1];
      }
    }
    it=lower_bound(t.begin(),t.end(),x);
    if(it!=t.end()){
      is=lower_bound(s.begin(),s.end(),*it);
      if(is!=s.end())
        tm[4]=(*is)-x;
      if(is!=s.begin()){
        iis=(int)distance(s.begin(),is);
        tm[5]=(*it)*2-x-s[iis-1];
      }
    }
    if(it!=t.begin()){
      iit=(int)distance(t.begin(),it);
      is=lower_bound(s.begin(),s.end(),t[iit-1]);
      if(is!=s.end())
        tm[6]=x+(*is)-t[iit-1]*2;
      if(is!=s.begin()){
        iis=(int)distance(s.begin(),is);
        tm[7]=x-s[iis-1];
      }
    }
    res=*min_element(tm,tm+8);
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[3][100005];
int main(){
    int n;
    scanf("%d",&n);
    ll i1=0,i2=0,i3=0,sum=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<3;i++){
        sort(a[i],a[i]+n);

    }

    while(i2<n){
        while(a[1][i2]>a[0][i1]&&i1<n) i1++;
        while(a[1][i2]>=a[2][i3]&&i3<n) i3++;
       // printf("%lld %lld %lld = %lld\n",i1,i2,i3,(n-i3)*i1);
        sum+=(n-i3)*i1;
        i2++;
    }
    printf("%lld",sum);


}


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

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


int main(){
    long long sum=0;
  //  cin >> N;
/*
    while(N){
        d = N % (long)10;
        cout << d << endl;
        sum += d;
//      cout << sum << endl;
        N = N/(long long)10;
    }
*/

    string M;
    cin >> M;
//    int t;
    char c;
   // cout << M.length() << endl;
    rep(i,M.length()){
        c = M[i];
        sum += atoi(&c);
   //     cout << c << endl;
   //     cout << sum << endl;
        if(sum>=9) sum = sum%9;
    }

    
 //  cout << sum << endl;

    if(sum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

using namespace std;

int main(){
    int N;
    cin >> N;

    int C[N-1], S[N-1], F[N-1];
    for(int i = 0; i < N-1; i++)cin >> C[i] >> S[i] >> F[i];

    long ans[N];
    for(int i = 0; i < N; i++)ans[i] = 0;

    for(int i = 0; i < N-1; i++){
        ans[i] = C[i] + S[i];
        for(int j = 0; j < i; j++){
            if(S[i] >= ans[j])ans[j]= ans[i];
            else if((ans[j] - S[i])%F[i] == 0)ans[j] += C[i];
            else ans[j] += C[i] + F[i] - (ans[j] - S[i])%F[i];
        }
    }
    
    for(int i = 0; i < N; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

        
if B < C:
    while(B < D):
        if S[B] == '.' and S[B-2] == '.':
            while(A < C):
                #print("1こ先")
                if S[A] == '.':
                    S[A] = 'A'
                    S[A-1] = '.'
                else:
                    #print('2こ先')
                    if A+1 < N and S[A+1] == '.':
                        S[A+1] = 'A'
                        S[A-1] = '.'
                        A += 1
                    else:
                        break
                A += 1
        
                #print(S)
        
        if S[B] == '.':
            S[B] = 'B'
            S[B-1] = '.'
        else:
            if S[B+1] == '.' and B+1 < N:
                S[B+1] = 'B'
                S[B-1] = '.'
                B += 1
            else:
                break
        
        B += 1
        
        #print(S)
    
    #print("B end")
    while(A < C):
        #print("1こ先")
        if S[A] == '.':
            S[A] = 'A'
            S[A-1] = '.'
        else:
            #print('2こ先')
            if A+1 < N and S[A+1] == '.':
                S[A+1] = 'A'
                S[A-1] = '.'
                A += 1
            else:
                break
        A += 1
        
        #print(S)
        
elif B > C:
    while(A < C):
        if S[A] == '.' and S[A-2] == '.':
            while(B < D):
                #print("1こ先")
                if S[B] == '.':
                    S[B] = 'B'
                    S[B-1] = '.'
                else:
                    #print('2こ先')
                    if B+1 < N and S[B+1] == '.':
                        S[B+1] = 'B'
                        S[B-1] = '.'
                        B += 1
                    else:
                        break
                B += 1
        
                #print(S)
        
        if S[A] == '.':
            S[A] = 'A'
            S[A-1] = '.'
        else:
            if S[A+1] == '.' and A+1 < N:
                S[A+1] = 'A'
                S[A-1] = '.'
                A += 1
            else:
                break
        
        A += 1
        
        #print(S)
    
    #print("A end")
    while(B < D):
        #print("1こ先")
        if S[B] == '.':
            S[B] = 'B'
            S[B-1] = '.'
        else:
            #print('2こ先')
            if B+1 < N and S[B+1] == '.':
                S[B+1] = 'B'
                S[B-1] = '.'
                B += 1
            else:
                break
        B += 1
        
        #print(S)
    
    
        
if A == C and B == D:
    print('Yes')
else:
    print('No')

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

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

int main(){
    ll n, x;
    cin >> n >> x;
    cout << 3 * (n - gcd(n, x)) << endl;;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); sc.nextLine();
		int[] to = new int[n+2];
		to[0] = 1;
		String[][] com = new String[n][];
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		for(int i=0;i<n;i++) {
			com[i] = sc.nextLine().split(" ");
			if( com[i].length == 1 ) {
				map.put(com[i][0].substring(0, com[i][0].length()-1), i+1);
				to[i+1] = i+2;
			}
			else to[i+1] = -1;
		}
		
		for(int i=0;i<n;i++) if(to[i+1] == -1) {
			to[i+1] = map.get(com[i][1].substring(0, com[i][1].length()-1));
		}
//		debug(to);
		PriorityQueue<P> q = new PriorityQueue<P>();
		q.add(new P(0, 0));
		int[] mem = new int[n+2]; fill(mem, INF);
		mem[0] = 0; 
		for(;;) {
			P cur = q.remove();
//			debug(cur.p, cur.c);
			if( to[cur.p] == 0 ) {
				System.out.println(cur.c);
				break;
			}
			if( mem[cur.p] != cur.c ) continue;
			if( to[cur.p] != cur.p + 1 && mem[cur.p+1] > cur.c+1 ) {
				q.add(new P(cur.p+1, cur.c+1));
				mem[cur.p+1] = cur.c+1; 
			}
			if(mem[to[cur.p]] > cur.c) {
				q.add(new P(to[cur.p], cur.c));
				mem[to[cur.p]] = cur.c;
			}
		}
	}
	
	class P implements Comparable<P>{
		int p, c;
		P(int p, int c) {
			this.p = p;
			this.c = c;
		}
		@Override
		public int compareTo(P arg0) {
			// TODO 自動生成されたメソッド・スタブ
			return c-arg0.c;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

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

int main(){
ll x;
cin >> x;
ll ans=0, m=100;
while(1){
    ans++;
    m += m/100;
    if(m>=x) break;
}

cout << ans << endl;

}

Measured memory_bytes: 3636
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int A,B;
  cin >> A >> B;
  if(A>=10 || B >=10){
    cout << "-1" << endl;
  }
  else{
  cout << A*B << endl;
  }
}


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>
#include<tuple>
#include<bitset>
#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
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string s;
	scan(s);
	int ans=INF;
	rep(k,26){
		int dismax=0;
		int count=0;
		rep(i,s.size()){
			if(s[i]!='a'+k) count++;
			else{
				dismax=max(dismax,count);
				count=0;
			}
			if(i==s.size()-1) dismax=max(dismax,count);
		}
		ans=min(dismax,ans);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 ll INF = 1LL << 60;


int main(){
	ll N,W;
	cin >> N >> W;
	
	vector<ll> w(N),v(N);
	REP(i,N) cin >> w[i] >> v[i];
	
	ll dp[105][100010];
	REP(i,105) REP(j,100010) dp[i][j] = INF;
	
	dp[0][0] = 0;
	REP(i,N){
		for(ll sumv=0; sumv<=1000*N; ++sumv){
			if(sumv - v[i]>=0) chmin(dp[i+1][sumv], dp[i][sumv-v[i]]+w[i]);
			chmin(dp[i+1][sumv], dp[i][sumv]);
		}
	}

	for(ll i = 1000*N; i>=0; --i){
		if(dp[N][i] <= W){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define PB emplace_back

using namespace std;

const int N = 1e3+100, mod = 1e9+7;

long long int dp[N][N];

char c[N][N];

int main () {
    long long int h, w;
    cin >> h >> w;
    for(int i = 0 ; i < h ; i++ ) {
        for(int j = 0 ; j < w ; j++ ) {
            cin >> c[i][j];
        }
    }
    dp[0][0]=1;
    for(int i = 0 ; i < h ; i++ ) {
        for(int j = 0 ; j < w ; j++ ) {
            if(c[i+1][j]!='#') dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            if(c[i][j+1]!='#') dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
        }
    }
    cout << dp[h-1][w-1];
}


Measured memory_bytes: 10368
from fractions import gcd
a,b,c,d = map(int,input().split())
aa = (a-1)-(a-1)//c-(a-1)//d+(a-1)//int(c*d/gcd(c,d))
bb = b-b//c-b//d+b//int(c*d/gcd(c,d))
print(bb-aa)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using P = pair<int, ll>;
void prp(P& p) {cout << p.first << " " << p.second << endl;}

int n, k;
vector<int> p;
P getK(vector<int> b, int bit){
    int cnt = 0;
    ll cost = 0;
    int maxheight = 0;
    FOR(i, 1, n+1){
        if(maxheight < b[i]) cnt++;
        else if(bit>>(i-1)&1){
            cost += (ll)maxheight - b[i] + 1;
            b[i] = maxheight + 1;
            cnt++;
        }
        chmax(maxheight, b[i]);
    }
    // cout << bitset<15>(bit) << endl;
    // prvec(b);
    return {cnt, cost};
}

int main()
{
    cin >> n >> k;
    p.resize(n+1);
    p[0] = 0;
    rep(i, n) cin >> p[i+1];
    ll ans = INFL;
    rep(i, 1<<n){
        P K = getK(p, i);
        if(K.first >= k) chmin(ans, K.second);
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long N = cin.nextLong();
            long ans = long.MaxValue;
            for (long i = 1; i < Math.Pow(N, 0.5) + 1; i++)
            {
                if (N % i == 0)
                {
                    long j = N / i;
                    ans = Math.Min(ans, i + j - 2);
                }
            }

            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
struct po{int x,y,dis;};
int h,w;
string mp[20],str;
int D[21][21];

void bfs(po s){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) D[i][j] = 10000000;
  D[s.y][s.x] = 0;
  queue<po> Q;
  Q.push((po){s.x,s.y,0});
  while(!Q.empty()){
    po t=Q.front();Q.pop();
    int dx[]={0,0,-1,1};
    int dy[]={1,-1,0,0};
    for(int i=0;i<4;i++){
      int nx = t.x+dx[i];
      int ny = t.y+dy[i];
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!='.'||D[ny][nx]<=t.dis+1)continue;
      Q.push((po){nx,ny,t.dis+1});
      D[ny][nx]=t.dis+1;
    }
  }
}

void move(po s){
  po ima,ans;
  ima.x=s.x,ima.y=s.y;
  if(D[ima.y][ima.x]==0)ans.x=ima.x,ans.y=ima.y,ans.dis=0;
  else ans.dis = 10000000;
  int visited[21][21]={};
  int dx[]={0,-1,1,0};
  int dy[]={1,0,0,-1};
  int cnt=0;
  while(1){
    visited[ima.y][ima.x]=1;
    for(int i=0;i<str.size();i++){
      cnt++;
      int j = (str[i]-'0')/2-1;
      int nx=ima.x+dx[j];
      int ny=ima.y+dy[j];
      if(nx<0||ny<0||nx>=w||ny>=h||str[i]=='5')nx=ima.x,ny=ima.y;
      ima.x=nx,ima.y=ny;
      if(ans.dis>cnt && cnt>=D[ny][nx]) ans.x=ima.x,ans.y=ima.y,ans.dis=cnt;
    }
    if(cnt>5000)break;
  }
  if(ans.dis==10000000 || ans.dis>1000) cout <<"impossible"<<endl;
  else cout<< ans.dis<<" " << ans.y <<" "<< ans.x<<endl;
}
 

int main() {

  while(1){
    cin >> h >> w;
    if(h==0 && w==0)break;
    for(int i=0;i<h;i++) cin >> mp[i];
    cin>> str;
    
    po A,B;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(mp[i][j] == 'A') A.y=i ,A.x=j;
	if(mp[i][j]=='B') B.y=i,B.x=j;
      }

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(mp[i][j] == 'A'||mp[i][j]=='B') mp[i][j] = '.';
  
    bfs(A);
    move(B);
  }
  return 0;
}

Measured memory_bytes: 1228
N = int(input())
li = [ int(it) for it in input().split() ]
go = [ (li[i],i) for i in range(N)]
go.sort( key= lambda x:x[0])
po = [0]*N
for i in range(N):
  if (i < N//2):
    po[go[i][1]] = (go[N//2][0])
  else:
    po[go[i][1]] = (go[N//2-1][0])
for i in range(N):
  print ( po[i] )

Measured memory_bytes: 107604
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, S, T;
int A[3000], B[3000];
int dp[3010][3010];

int main() {
	cin >> N >> T >> S;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	dp[0][0] = 0;
	if (B[0] <= S && B[0] < T)dp[B[0]][1] = A[0];

	for (int i = 0; i <= T ; i++) {
		for (int j = 0; j < N; j++) {
			if(i != T) dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
			dp[i][j + 1] = max(dp[i][j], dp[i][j + 1]);
			if (i + B[j] <= T && ((i <= S && i + B[j] <= S) || (S <= i)))
				dp[i + B[j]][j + 1] = max(dp[i + B[j]][j + 1], dp[i][j] + A[j]);
		}
	}
	cout << dp[T][N] << endl;
	return 0;
}

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

int main(){
    int n , m , l;
    cin >> n >> m >> l;
    int A[n][m],B[m][l],C[n][l];
    int w,h;
    for(h = 0; h < n; h++){
        for(w = 0; w < m; w++){
            cin >> A[h][w];
            // cout << A[h][w] <<" ";
        }
        // cout << endl;
    }
    for(h = 0; h < m;h++){
        for(w = 0; w < l; w++){
            cin >> B[h][w];
            // cout << B[h][w] << " ";
        }
        // cout << endl;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            long long c = 0LL;
            for(int k = 0; k < m; k++){
                c += A[i][k] * B[k][j];
            }
            cout << c;
            if(j < l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

int phi(int n) {
    int i, r;
    
    for (i=2,r=n; i*i<=n; i++) {
        if (n%i == 0) {
            while (n%i == 0) n /= i;
            r -= r / i;
        }
    }
    if (n > 1) r -= r / n; 
    return r; 
} 

int main() {
    int n;
    scanf("%d ", &n);
    printf("%d\n", phi(n));
    return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using tup = pair<pair<int, int>, int>;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<tup> E;
    for(int i=0; i<N; ++i) {
        int S, T, X;
        cin >> S >> T >> X;
        E.push_back({{S - X, 1}, X});
        E.push_back({{T - X, -1}, X});
    }
    sort(begin(E), end(E));

    vector<int> D(Q);
    for(int i=0; i<Q; ++i) cin >> D[i];

    set<int> S;

    int cur = 0;
    for(int i=0; i<Q; ++i) {
        while(cur < 2*N && E[cur].first.first <= D[i]) {
            if(E[cur].first.second == 1) S.insert(E[cur].second);
            else S.erase(E[cur].second);
            ++cur;
        }

        if(S.empty()) cout << -1 << endl;
        else cout << *begin(S) << endl;
    }
}

Measured memory_bytes: 16108
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int case1 = Math.max(0, b - (a + w));
        int case2 = Math.max(0, a - (b + w));
        int result = Math.max(case1, case2);

        // 出力
        System.out.println(result);
    }
}


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


int main() {
	int N;
	cin >> N;
	string c;
	cin >> c;

	int nr = 0;
	for (char ci : c) if (ci == 'R') ++nr;

	int ans = 0;
	for (int i = nr; i < N; ++i) if (c[i] == 'R') ++ans;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
long long a,b,n;
cin>>a>>b>>n;
if(n<=b-1)cout <<floor(a*n/b)-a*floor(n/b);
else cout <<floor(a*(b-1)/b)-a*floor((b-1)/b);

    
}

Measured memory_bytes: 3784
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;

class Dice
{
public:
	Dice(int num[6]);
	int check_R(int t, int f);
	int check_same(Dice d);
	int T, F, R;
	int _num[6];
private:
	int _pattern[6][6];
};

//?????????????????????
Dice::Dice(int num[6])
{
	for (int i = 0; i < 6; i++){
		_num[i] = num[i];
	}

	T = _num[0];
	F = _num[1];
	R = _num[2];

	int buf[6][6] = { { 1, 2, 3, 5, 4, 6 }, { 2, 6, 3, 1, 4, 5 }, { 3, 2, 6, 5, 1, 4 }, { 4, 2, 1, 5, 6, 3 }, { 5, 1, 3, 6, 4, 2 }, { 6, 5, 3, 2, 4, 1 } };
	for (int i = 0; i < 6; i++){
		for (int j = 0; j < 6; j++){
			_pattern[i][j] = _num[buf[i][j]-1];
		}
	}
}

int Dice::check_same(Dice d){
	//????????????0???d ??????????????????????????????????????????
	//???????????£?????? ans = 1;

	int ti = -1, fi = -1, ri = -1, ans = 0;


	for (int i = 0; i < 6; i++){
		if (_pattern[0][0] == d._pattern[i][0] && _pattern[0][5] == d._pattern[i][5]){
			for (int j = 1; j < 5; j++){
				if (_pattern[0][1] == d._pattern[i][j]){
					for (int k = 0; k < 3; k++){
						int jk = 1 + (j + k ) % 4;
						if (_pattern[0][k+2] != d._pattern[i][jk]){
							ans = 0;
							break;
						}
						ans = 1;
					}
					if (ans == 1){
						return ans;
					}
				
				}

			}
		}

	}

	return ans;

}

int main(){

	int n, num[6];
	bool ans = true;
	vector <Dice> dices;

	cin >> n;

	for (int k = 0; k < n; k++){
		for (int i = 0; i < 6; i++){
			cin >> num[i];
		}
		Dice d(num);
		dices.push_back(d);
	}

	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			if (dices[i].check_same(dices[j]) == 1){
				ans = false;
				break;
			}
		}
		if (ans == false)break;
	}

	cout << (ans ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 1244
import java.lang.Math.*

private fun readln() = readLine()!!.trim()
private fun readlnInt() = readln().toInt()
private fun readlnStrings() = readln().split(' ')
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }

fun check(A:Long, B:Long, C:Long): Long{
    val s = min(B, C)
    val l = max(B, C)
    if (A <= s) {
        return s - A
    } else if (A <= l){
        return l - A
    } else {
        return 0
    }
}

fun solve() {
    val N = readlnInt()
    val S = readln()
    var cntA = 0L
    var cntB = 0L
    var cntC = 0L
    var ttl = 1L
    val MOD = 998244353
    for (i in 0 until 3*N){
        val ch = S[i]
        if (ch=='R'){
            cntA += 1
            val r = check(cntA, cntB, cntC)
            ttl = ttl * (r+1) % MOD
        } else if (ch=='G') {
            cntB += 1
            val r = check(cntB, cntA, cntC)
            ttl = ttl * (r+1) % MOD
        } else {
            cntC += 1
            val r  = check(cntC, cntA, cntB)
            ttl = ttl * (r+1) % MOD
        }
    }
    for (i in 1..N){
        ttl = ttl * i % MOD
    }
    println(ttl)
}


fun main(args: Array<String>) {
//    val queryNum = readlnInt()
//    for (queryIdx in 1..queryNum) {
//        println("Case #$queryIdx:")
        solve()
//    }
}


Measured memory_bytes: 36696
use std::collections::VecDeque;
use std::collections::HashSet;

fn main(){
  loop {
    let wh: Vec<usize> = read_vec();
    let w = wh[0];
    let h = wh[1];
    
    if w == 0 && h == 0 { break; }

    let xys: Vec<usize> = read_vec();
    let sp: (usize, usize) = (xys[0]-1, xys[1]-1);
    let xyg: Vec<usize> = read_vec();
    let gp: (usize, usize) = (xyg[0]-1, xyg[1]-1);
    let n: usize = read();

    let mut fv:Vec<Vec<usize>> = vec![vec![0;w];h];

    for _ in 0 .. n {
      let cdxy: Vec<usize> = read_vec();
      let c = cdxy[0];
      let d = cdxy[1];
      let x = cdxy[2] - 1;
      let y = cdxy[3] - 1;

      if d == 0 {
        fv[y][x] = c;
        fv[y][x+1] = c;
        fv[y][x+2] = c;
        fv[y][x+3] = c;
        fv[y+1][x] = c;
        fv[y+1][x+1] = c;
        fv[y+1][x+2] = c;
        fv[y+1][x+3] = c;
      } else {
        fv[y][x] = c;
        fv[y][x+1] = c;
        fv[y+1][x] = c;
        fv[y+1][x+1] = c;
        fv[y+2][x] = c;
        fv[y+2][x+1] = c;
        fv[y+3][x] = c;
        fv[y+3][x+1] = c;
      }
    }

    let sc: usize = fv[sp.1][sp.0];
    let gc: usize = fv[gp.1][gp.0];

    let mut ans: &str = "NG";
    
    if sc != 0 && gc != 0 && sc == gc {
      let mut que: VecDeque<(usize, usize)> = VecDeque::new();
      let mut hs: HashSet<(usize, usize)> = HashSet::new();
      
      que.push_back(sp);
      hs.insert(sp);
      
      
      loop {
        match que.pop_front() {
          None => { break; },
          Some((bx, by)) => {
            if gp == (bx, by) {
              ans = "OK";
              break;
            }
      
            if bx + 1 < w && fv[by][bx+1] == sc && !hs.contains(&(bx+1, by)) {
              que.push_back((bx+1, by));
              hs.insert((bx+1, by));
            }
            if bx > 0 && fv[by][bx-1] == sc && !hs.contains(&(bx-1, by)) {
              que.push_back((bx-1, by));
              hs.insert((bx-1, by));
            }
            if by + 1 < h && fv[by+1][bx] == sc && !hs.contains(&(bx, by+1)) {
              que.push_back((bx, by+1));
              hs.insert((bx, by+1));
            }
            if by > 0 && fv[by-1][bx] == sc && !hs.contains(&(bx, by-1)) {
              que.push_back((bx, by-1));
              hs.insert((bx, by-1));
            }
          },
        }
      }
    }
    println!("{}", ans);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N, x = 0, max = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') x++;
    else x--;
    if (x > max) max = x;
  }
  cout << max << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
}Roll;

void kock(int n,Roll p1,Roll p2){
  Roll s,t,u;
  if(n==0)return; 
  
  s.x = (2*p1.x+1*p2.x)/3;
  s.y = (2*p1.y+1*p2.y)/3;
  t.x = (1*p1.x+2*p2.x)/3;
  t.y = (1*p1.y+2*p2.y)/3;
  u.x = (t.x-s.x)/2-(t.y-s.y)/2*sqrt(3)+s.x;
  u.y = (t.x-s.x)/2*sqrt(3)+(t.y-s.y)/2+s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);
}

int main(){
  Roll p1={0.0,0.0},p2={100.0,0.0};
  int n;

  scanf("%d\n",&n);
  printf("%f %f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  
  return 0;
}

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

int main(void){
    int n,s1,s2,min;
    s1=0;
    s2=0;
    min=10000;
    scanf("%d",&n);
    
    int w[n];
    for(int i=0; i<n; i++){
        scanf("%d",&w[i]);
        s1+=w[i];
    }
    for(int i=n-1; i>0; i--){
        s1-=w[i];
        s2+=w[i];
        
        if(abs(s1-s2)<min)
            min=abs(s1-s2);
    }
    printf("%d",abs(min));
}


Measured memory_bytes: 128
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, i;
	cin >> N >> i;

	O(N - i + 1);

	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

b = {i:0 for i in range(1, n+1)}
for i in a:
    b[i] += 1

for i in range(1, n+1):
    print('Yes' if k - q + b[i] > 0 else 'No')



Measured memory_bytes: 19104
#include <stdio.h>
#include <string.h>

int main() {
  char ans[4][50] = {
    "Christmas",
    "Christmas Eve",
    "Christmas Eve Eve",
    "Christmas Eve Eve Eve"};
  int d;
  scanf("%d", &d);
  printf("%s\n", ans[25-d]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,sum;
  long long min,max;
  
  while(1){
    cin >> y >> x;
    if(x == 0 && y == 0)break;
    for (int i = 0; i < y; i++) {
          for (int j = 0; j < x; j++) {
  	  		cout << "#";
    	  } 
  	  cout << endl;
    } 
      	  cout << endl;
  }
}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	cout << s.x << " " << s.y << endl;
	koch(n - 1, s, u);
	cout << u.x << " " << u.y << endl;
	koch(n - 1, u, t);
	cout << t.x << " " << t.y << endl;
	koch(n - 1, t, b);
}

int main() {
	Point a, b;
	int n;

	cin >> n;

	// 初期値(0, 0) and (100, 0)
	a.x = 0; a.y = 0;
	b.x = 100; b.y = 0;

	cout << fixed << setprecision(8);
	cout << a.x << " " << a.y << endl;
	koch(n, a, b);
	cout << b.x << " " << b.y << endl;

	return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[1000005];
char s[1000005];


void solve(ll k){
	ll d=0,m=0,dm=0;
	ans = 0;
	for(i=0;i<n;i++){
		if(s[i] == 'D')d++;
		if(s[i] == 'M'){
			m++;
			dm += d;
		}
		if(s[i] == 'C'){
			ans += dm;
		}
		num = i-k+1;
		if(num < 0)continue;
		if(s[num] == 'D'){
			dm -= m;
			d--;
		}
		if(s[num] == 'M'){
			m--;
		}
	}
	p(ans);
}
			


int main(){
	cin >> n;
	cin >> s;
	cin >> c;
	for(int i=0;i<c;i++){
		cin >> k;
		solve(k);
	}
	


	return 0;

}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	string c;
	cin >> c;
	if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o")
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	
	return 0;
}


Measured memory_bytes: 256