akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first<y.first)
    return true;
    else if(x.first>y.first)
    return false;
    if(x.second<=y.second)
    return true;
    return false;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m,q;
    cin>>n>>q;
    vector<pair<ll,pair<ll,ll> > > temp;
    for(i=0;i<n;i++)
    {
        ll s,t,x;
        cin>>s>>t>>x;
        t--;
        temp.pb(mp(x,mp(s,t)));
    }
    vector<pair<ll,ll> > v(q);
    for(i=0;i<q;i++)
    {
        cin>>v[i].first;
        v[i].second=i;
    }
    sort(all(v));
    sort(all(temp));
    vector<pair<ll,ll> > vv[q+1];
    for(i=0;i<n;i++)
    {
        ll st=temp[i].second.first;
        ll en=temp[i].second.second;
        ll x=temp[i].first;
        st-=x;
        en-=x;
        auto it = lower_bound(v.begin(),v.end(),mp(st,0),comp)-v.begin();
        auto it1 = upper_bound(v.begin(),v.end(),mp(en,q-1),comp)-v.begin();
        it1--;
        if(it>it1)
        continue;
        //trace3(i,it,it1)
        vv[it].pb(mp(x,0));
        vv[it1].pb(mp(x,1));
    }
    ll ans[q]={0};
    multiset<ll> s;
    for(i=0;i<q;i++)
    {
        for(auto x : vv[i])
        {
            if(x.second==0)
            {
                s.insert(x.first);
            }
        }
        if(s.size()>0)
        {
            ll tp=(*s.begin());
            ans[v[i].second]=tp;
        }
        else
        {
            ans[v[i].second]=-1;
        }
        for(auto x : vv[i])
        {
            if(x.second==1)
            {
                s.erase(s.find(x.first));
            }
        }
    }
    for(i=0;i<q;i++)
    cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 34156
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)

Measured memory_bytes: 46932
#include <stdio.h>
#include <math.h>
int main(void){     
    int n,i;     
    while(scanf("%d",&n),n>0){
        double avg,sum=0.0,var1=0.0,var2=0.0,dev,date[1001];  
        for(i=0;i<n;i++){                     
            scanf("%lf",&date[i]);                     
            sum+=date[i];
            avg=sum/n;
        }
        for(i=0;i<n;i++){
            var1+=(date[i]-avg)*(date[i]-avg);
            var2=var1/n;
        }
        dev=sqrt(var2);
        printf("%.8f\n",dev); 
    }
    return 0;
}


Measured memory_bytes: 2044
N = gets.to_i
a_list = N.times.map { gets.to_i }
list = []
a_list.each do |a|
  i = list.bsearch_index { |b| a <= b }
  if i
    if i == 0
      list.unshift(a)
    else
      list[i - 1] = a
    end
  else
    if list.empty?
      list.push(a)
    else
      list[-1] = a
    end
  end
end
puts list.size


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

using namespace std;
int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  int count = 0;
  for (int i = 0; i < s1.length(); i++)
  {
    if (s1[i] != s2[i])
      count++;
  }
  cout << count << endl;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           M                           100009
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           bug(i)                      cout<<"akhane bug nai  "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;


 main()
{  fast
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5])
   {
         cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }












































return 0;

}





Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"10"# => r#"5"#,
r#"50"# => r#"13"#,
r#"10000000019"# => r#"10000000018"#,
r#"10000000020"# => r#"202826"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: u64,
    }
    let mut ans = 1_000_000_000_000;

    for i in 1..((n as f64).sqrt() as u64) + 1 {
        if i * i > n {
            break;
        }

        if n % i != 0 {
            continue;
        }

        let j = n / i;

        if j < i {
            break;
        }

        ans = std::cmp::min((i - 1) + (j - 1), ans);
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e6+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
n,s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s+1) for i in range(n+1)]
for i in range(n):
  dp[i][0] = 1
for i in range(n):
  for j in range(s+1):
    dp[i+1][j] += dp[i][j]
    dp[i+1][j] %= mod
    if j >= a[i]:
      dp[i+1][j] += dp[i][j-a[i]]
      dp[i+1][j] %= mod
ans = list()
for i in dp:
  ans.append(i[-1])
ans = ans[1:]
print(sum(ans)%mod)


Measured memory_bytes: 112092
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// The Great Summer Contest
// 2012/12/04
public class Main{
	Scanner sc=new Scanner(System.in);

	long a0, b0, c0;

	void run(){
		for(;;){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			int d=sc.nextInt();
			int e=sc.nextInt();
			int f=sc.nextInt();
			if((a|b|c|d|e|f)==0){
				break;
			}
			a0=a+d;
			b0=b+e;
			c0=c+f;
			println(max(count1(a0, b0, c0), count2(a0, b0, c0))+"");
		}
	}

	long count1(long a, long b, long c){
		long res=0;
		long min=min(a, min(b, c));
		res+=min;
		a-=min;
		b-=min;
		c-=min;
		res+=a/3;
		res+=b/3;
		res+=c/3;
		a%=3;
		b%=3;
		c%=3;
		if(a+b+c>=4){
			if(a==0){
				if(a0>=3){
					res++;
				}
			}else if(b==0){
				if(b0>=3){
					res++;
				}
			}else if(c==0){
				if(c0>=3){
					res++;
				}
			}
		}
		return res;
	}

	long count2(long a, long b, long c){
		long res=0;
		res+=a/3;
		res+=b/3;
		res+=c/3;
		a%=3;
		b%=3;
		c%=3;
		long min=min(a, min(b, c));
		res+=min;
		a-=min;
		b-=min;
		c-=min;
		if(a+b+c>=4){
			if(a==0){
				if(a0>=3){
					res++;
				}
			}else if(b==0){
				if(b0>=3){
					res++;
				}
			}else if(c==0){
				if(c0>=3){
					res++;
				}
			}
		}
		return res;
	}

	void println(String s){
		System.out.println(s);
	}

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

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e18;

ll A[100005];
ll B[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N + 1) {
        cin >> A[i];
    }
    memset(B, 0, sizeof(B));
    for (ll i = N - 1; i >= 0; --i) {
        B[i] += B[i + 1];
        B[i] += A[i + 1];
    }
    ll p = 1;
    ll ans = 1;
    REP(i, N + 1) {
        p -= A[i];
        if (p < 0) {
            cout << -1 << endl;
            return 0;
        }
        p *= 2LL;
        p = std::min(p, B[i]);
        ans += p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
        int N;
	string s,t;
	
	cin>>N>>s>>t;
	int ans=2*N;
	REP(i,N){
	    bool check=true;
	    for(int j=i;j<N;j++){
	        if(s[j]!=t[j-i])check=false;
	    }
	    if(check){
	       ans=i+N;
	       break;
	    }
        }
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
{-# LANGUAGE RankNTypes #-}
import Control.Monad.State
import Control.Monad.ST
import Data.Array.ST
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = getLine >> readLine >>= print . solve

solve :: [Int] -> Int
solve vs = check as bs
    where
        check xxs@((an, al) : xs) yys@((bn, bl) : ys)
            | an /= bn = n - al - bl
            | otherwise = min (check xs yys) $ check xxs ys
        check ((_, al) : _) _ = n - al
        check _ ((_, bl) : _) = n - bl 
        check _ _ = n

        as = count es
        bs = count os 

        n = length vs

        count = sortBy cmpf . map mf . group . sort
            where
                cmpf lhs rhs = comparing snd rhs lhs `mappend` comparing fst lhs rhs
                mf = (,) <$> head <*> length 

        (es, os) = fst $ foldr ff (([], []), True) vs
            where
                ff v ((acc, bcc), f)
                    | f = ((v : acc, bcc), not f)
                    | otherwise = ((acc, v : bcc), not f)

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

type Table s a b = STArray s a (Maybe b)
type Memo s a b = a -> StateT (Table s a b) (ST s) b

evalMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s b
evalMemo f k = evalStateT (memoizeFix f k)

memoizeFix :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> forall s. Memo s a b
memoizeFix f k = get >>= (\arr -> lift (readArray arr k) >>= maybe (f (memoizeFix f) k >>= ((<$) <*> (lift . writeArray arr k . Just))) return)

Measured memory_bytes: 20860
#include <stdio.h>

#define swap(a,b) do{int temp = a; a = b; b = temp;}while(0)

int main(void){
    int a,b,c;
    int n;
    scanf("%d",&n);
    while(n--){
        scanf("%d %d %d", &a,&b,&c);
        if(b<a) swap(a,b);
        if(c<b)
            if(a<c) swap(b,c);
            else{
                swap(a,c);
                swap(c,b);
            }
        if(a * a + b * b == c * c) puts("YES");
        else puts("NO");
    }
    return(0);
}

Measured memory_bytes: 580
#include<iostream>

using namespace std;

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

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

long long mem[110][110][4];

int main() {
  long long h, w, n;
  string m[110];
  while (true) {
    cin >> h >> w >> n;
    if (h == 0 && w == 0 && n == 0) break;
    rep (i, h) cin >> m[i + 1];
    m[0] = m[h + 1] = "";
    rep (i, w) m[0] += "#";
    rep (i, w) m[h + 1] += "#";
    rep (i, h + 2) m[i] = "#" + m[i] + "#";
    h += 2;
    w += 2;
    int x, y, d;
    rep (i, h) rep (j, w) {
      if (m[i][j] == 'E') d = 0;
      if (m[i][j] == 'S') d = 1;
      if (m[i][j] == 'W') d = 2;
      if (m[i][j] == 'N') d = 3;
      if (isalpha(m[i][j])) {
	x = j;
	y = i;
      }
    }
    rep (i, 110) rep (j, 110) rep (k, 4) mem[i][j][k] = -1;
    rep (i, n) {
      int xx = x + dx[d], yy = y + dy[d];
      while (m[yy][xx] == '#') {
	d = (d + 1) % 4;
	xx = x + dx[d];
	yy = y + dy[d];
      }
      x = xx;
      y = yy;
      if (mem[y][x][d] != -1) {
	long long k = i - mem[y][x][d];
	long long a = (n - i) / k;
	if (a > 1) i += (a - 1) * k;
      } else {
	mem[y][x][d] = i;
      }
    }
    cout << y << " " << x << " " << "ESWN"[d] << endl;
  }
  return 0;
}

Measured memory_bytes: 1620
/* author   : mpily :-()
title : Competing.cpp
time :Sat Apr 18 13:22:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
int main(){
	long long ans = 0;
	long long n, k;
	cin>>n>>k;
	for(long long i = k; i <= n+1; ++i){
		long long small = i*(i-1);
		long long big = i*(n + (n-i+1));
		small/=2;
		big/=2;
		//cout << " for "<<i<<" small "<<small<<" big "<<big<<"\n";
		ans+=(big-small+1);
		ans%=mod;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  string a;
  cin >> a;

  string b;
  cin >> b;

  cout << b << a << endl;
}


Measured memory_bytes: 256
from collections import deque


def main():

    def f(hi, wi):
        return hi * w + wi

    h, w = map(int, input().split())
    sh, sw = map(int, input().split())
    gh, gw = map(int, input().split())

    s = [input() for _ in range(h)]
    INF = 10 ** 9

    sh -= 1
    sw -= 1
    gh -= 1
    gw -= 1

    dq = deque([f(sh, sw)])
    dist = [[INF] * w for _ in range(h)]
    dist[sh][sw] = 0

    while dq:
        i = dq.popleft()
        hi, wi = divmod(i, w)

        for dh in range(-2, 3):
            for dw in range(-2, 3):
                nh = hi + dh
                nw = wi + dw
                if 0 <= nh <= h - 1 and 0 <= nw <= w - 1 and s[nh][nw] == ".":
                    if abs(dh) + abs(dw) == 1:
                        if dist[hi][wi] < dist[nh][nw]:
                            dist[nh][nw] = dist[hi][wi]
                            dq.appendleft(f(nh, nw))
                    else:
                        if dist[hi][wi] + 1 < dist[nh][nw]:
                            dist[nh][nw] = dist[hi][wi] + 1
                            dq.append(f(nh, nw))

    ans = dist[gh][gw]
    if ans == INF:
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int xdir[5]={1,0,-1,0},ydir[5]={0,1,0,-1};
    int h,w,n;
    int x,y,col;
    int arr[10005];
    int paint[105][105]={};
    queue<tuple<int,int,int> > q;//y,x,color
    scanf("%d%d%d",&h,&w,&n);
    for(int i =1 ; i <= n ;i++){
        scanf("%d",&arr[i]);
    }
    q.push( make_tuple(0,0,1) );
    while(!q.empty()){
        tie(y,x,col)=q.front();
        q.pop();
        paint[y][x]=col;
        if( !(--arr[col]) ){
            col++;
        }
        if(col>n){
            break;
        }
        for(int i =0 ; i < 4 ;i++){
            if(y + ydir[i]>=0 && y + ydir[i]<h && x + xdir[i]>=0 && x + xdir[i]<w && !paint[y + ydir[i]][x + xdir[i]]){
                q.push( make_tuple(y+ydir[i],x+xdir[i],col) );
                break;
            }
        }
    }
    for(int i = 0 ; i < h ; i++){
        for(int j =0 ; j < w ; j++){
            printf("%d ",paint[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int Q,A,B,L,R,i,j,k;

int main(){
	scanf("%d",&Q);
	while (Q--){
		scanf("%d%d%d%d",&A,&B,&L,&R);
		if (abs(A-B)<=1) {
			if (B>A) for(i=L;i<=R;i++) putchar('A'+(i&1));
			else for(i=L;i<=R;i++) putchar('A'+(i&1^1));
		} else {
			ll s;
			if (A>B) s=(A+B)/(B+1);
			else s=(A+B)/(A+1);
			ll c1=(s*A-B+1+(s*s-1-1))/(s*s-1)-1;
			ll c2=(s*B-A+1+(s*s-1-1))/(s*s-1)-1;
			ll res1=A-c1*s-c2,res2=B-c1-c2*s;
			for(i=L;i<=R;i++) 
				if (i<=c1*(s+1)) putchar('A'+(i%(s+1)==0)); else 
				if (A+B-i+1<=c2*(s+1)) putchar('B'-((A+B-i+1)%(s+1)==0)); else {
					if (i-c1*(s+1)<=res1) putchar('A');
					else putchar('B');
				}
		}
		putchar('\n');
	}
}

Measured memory_bytes: 1652
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += a[i] + min(a[i+1], b[i] - a[i])
    a[i+1] = max(0, a[i+1] - (b[i] - a[i]))
    
  else:
    cnt += b[i]

print(cnt)

  



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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define ll long long int

int main() {

	IOS

	ll n, k;
	cin >> n >> k;

	ll m = n%k;
	cout << min(m, k-m) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i=0; i < (int)(N); i++)
 
int main() {
  int N;
  cin >> N;
  int f = 0;
  
  int temp = N;
  
  while (temp > 0) {
    f += temp % 10;
    temp /= 10;
  }
  if ((N % f) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int x,y,a,b;
	scanf("%d %d",&x,&y);
	if(x<y)	swap(x,y);
	while(1)	{
		b=x%y;
		if(b==0)	break;
		else {
			x=y;
			y=b;
		}
	}
	printf("%d\n",y);
	return 0;
}



Measured memory_bytes: 2756
def main():

    s = input()
    if len(s) == 2:
        if s[0] == s[1]: return 1, 2
        else: return -1, -1

    for i in range(len(s)-2):
        if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
            return i+1, i+3
    return -1, -1

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    vector<vector<int>> b(h,vector<int>(w,-1));
    queue<P> q;
    vector<int> di={-1,0,1,0},dj={0,-1,0,1};
    rep(i,h) {
        rep(j,w) {
            if (a[i][j]=='#') {
                b[i][j]=0;
                q.push({i,j});
            }
        }
    }
    while(!q.empty()) {
        P pp=q.front();
        int i=pp.first,j=pp.second;
        q.pop();
        rep(k,4) {
            int ni=i+di[k],nj=j+dj[k];
            if (ni>=0 && ni<h && nj>=0 && nj<w) {
                if (b[ni][nj]<0) {
                    b[ni][nj]=b[i][j]+1;
                    q.push({ni,nj});
                }
            }
        }
    }
    int ans=0;
    rep(i,h) {
        rep(j,w) ans=max(ans,b[i][j]);
    }
    cout << ans << endl;

    return 0; 
}


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

using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if( a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y= sc.nextInt();
		int r = sc.nextInt();
		if(x<0 || y<0){
			System.out.println("No");
		}else if((x+r)<=W && (y+r)<=H){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

int N, M, X, C[15], A[15][15], S[15];

int rec(int n) {
  if(n == N) {
    int cost = 0, x[15];
    for(int i = 0; i < M; i++) {
      x[i] = 0;
    }
    for(int i = 0; i < N; i++) {
      if (S[i] == 1) {
		cost += C[i];
        for(int j = 0; j < M; j++) {
          x[j] += A[i][j];
        }
      }
    }
    for(int i = 0; i < M; i++) {
      if (x[i] < X) return INT_MAX;
    }
    return cost;
  }
  int minCost = INT_MAX;
  S[n] = 0;
  minCost = min(rec(n + 1), minCost);
  S[n] = 1;
  minCost = min(rec(n + 1), minCost);
  return minCost;
}

int main() {
  cin >> N >> M >> X;
  for(int i = 0; i < N; i++) {
    cin >> C[i];
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
    S[i] = 0;
  }
  int cost = rec(0);
  if (cost == INT_MAX) {
    cout << -1 << endl;
    return 0;
  }
  cout << cost << endl;
  return 0;
}

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

int n,q;
vector<int> A,m;

int main()
{
    int n;
    cin >> n;
    int a, b;
    a = n / 500;
    b = (n % 500) / 5;
    cout << 1000*a + 5*b << endl;
}


Measured memory_bytes: 256
S=gets.chomp
K=gets.chomp.to_i
subs=[]
S.length.times do |i|
    l=0
    while l<K && i+l < S.length do
        subs.push(S[i..(i+l)])
        l+=1
    end
end
puts subs.sort.uniq[K-1]


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

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

  vector<pair<long long, long long>> right_left(N);
  for(int i = 0; i < N; i++){
    long long x, l;
    cin >> x >> l;
    right_left[i] = make_pair(x + l, x - l);
  }
  sort(right_left.begin(), right_left.end());

  long long ok = -2e9;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int right = right_left[i].first, left = right_left[i].second;
    if(left >= ok){
      ans++;
      ok = right;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;

int main()
{

   string s;
   cin>>s;
   bool flg=false;
   if(s[0]=='7' ||s[1]=='7'||s[2]=='7')
        cout<<"Yes"<<endl;
   else cout<<"No"<<endl;







    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N;
  cin >> N;
  int D, X;
  cin >> D >> X;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int ans = X;
  rep(i, N) { ans += (D - 1) / A[i] + 1; }
  cout << ans << endl;
}

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

const int Maxn = 200005;

int n;
int a[Maxn];
int b[Maxn];
int res;
int c[Maxn];

int Solve(int x)
{
	int A = 1 << x + 1;
	int B = 3 * (1 << x);
	int C = 1 << x;
	for (int i = 0; i < n; i++)
		c[i] = b[i] % A;
	sort(c, c + n);
	int res = 0;
	for (int i = 0; i < n; i++) {
		int ind = lower_bound(c, c + n, C - a[i] % A) - c;
		res = (res + ind) % 2;
		ind = lower_bound(c, c + n, A - a[i] % A) - c;
		res = (res - ind % 2 + 2) % 2;
		ind = lower_bound(c, c + n, B - a[i] % A) - c;
		res = (res + n - ind) % 2; 
	}
	return res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (int i = 0; i <= 28; i++)
		if (Solve(i)) res |= 1 << i;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
string p;
int main(){
  cin>>p;
  for(int i=0;i<p.length();i++){
    if(p[i]=='A')cout<<"T";
    if(p[i]=='T')cout<<"A";
        if(p[i]=='C')cout<<"G";
        if(p[i]=='G')cout<<"C";
  }
  cout<<endl;
}

Measured memory_bytes: 256
import itertools
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
a=list(itertools.accumulate(a))
b=list(itertools.accumulate(b))
ans=0
for i in range(m+1):
  x=k-b[i]
  y=bisect.bisect_right(a,x)
  z=i+y
  if x<0:
      z=0
  ans=max(ans,z)
print(ans)

Measured memory_bytes: 134184
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		n := nextInt(sc)
		if n == 0 {
			break
		}
		s := make([]float64, n)
		var sum float64
		for i := int64(0); i < n; i++ {
			s[i] = nextFloat(sc)
			sum += s[i]
		}
		m := sum / float64(n)

		var t float64
		for i := int64(0); i < n; i++ {
			t += math.Pow(s[i]-m, 2.0)
		}
		fmt.Println(math.Sqrt(t / float64(n)))
	}
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextFloat(sc *bufio.Scanner) float64 {
	i, err := strconv.ParseFloat(nextString(sc), 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1136
import math
a, b, C = map(int, raw_input().split())
S = 0.5 * a * b * math.sin(math.radians(C))
c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(C)))
print("%8f" %(S))
print("%8f" %(a + b + c))
print("%8f" %(S / a * 2))

Measured memory_bytes: 4424
N, M = map(int, input().split())
min_value = 0
max_value = N  
for i in range(M):
    l, r = list(map(int, input().split()))
    if min_value < l:
        min_value = l
    if max_value > r:
        max_value = r
print(max(0, max_value-min_value+1))

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

int main(){
    string s;
    cin >> s;
    vector<int> tmp;
    int cnt = 0;
    char now = '<';
    for (int i = 0; i < s.size(); i++){
        if (s[i] != now){
            if (now == '<'){
                tmp.push_back(cnt);
                cnt = 1;
                now = '>';
            }
            else {
                tmp.push_back(cnt);
                cnt = 1;
                now = '<';
            }
        }
        else cnt++;
    }
    tmp.push_back(cnt);
    long long ans = 0;
    for (int i = 0; i < tmp.size(); i++){
        if (i % 2 == 0){
            ans += (long long)tmp[i] * (tmp[i] + 1) / 2;
        }
        else {
            ans += (long long)tmp[i] * (tmp[i] + 1) / 2;
            if (tmp[i] > tmp[i - 1]) ans -= tmp[i - 1];
            else ans -= tmp[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x: ans += 1

print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        for (int i = 0; i < m; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        int start = l[0];
        int end = r[0];
        for (int i = 1; i < m; i++) {
            if (l[i] > start) {
                start = l[i];
            }
            if (r[i] < end) {
                end = r[i];
            }
        }
        System.out.println(Math.max(0, end - start + 1));
    }

}


Measured memory_bytes: 78688
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    double R;
    cin >> R;
    cout << 2 * R * 3.1415926535 << endl;
    
    return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    vector<int> vec;

    for(int a = 1; a <= N; a++){
        int x;
        cin >> x;
        vec.push_back(x - a);
    }

    sort(allof(vec));

    int mid = vec[vec.size() / 2];

    ll ans = 0;
    for(int i : vec){
        ans += abs(i - mid);
    }

    cout << ans;
}


Measured memory_bytes: 1400
#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 map<int, ll> mill;
typedef vector<mill> vmill;

int main() {FIN
	
	ll n, i, m, j, res = -1000000000000000000;
	cin >> n;
	m = n / 2;
	vll ns(n);
	for (i = 0; i < n; i++)
		cin >> ns[i];
	
	vmill dp(n);
	dp[0][1] = ns[0];
	dp[1][1] = ns[1];
	if (m == 1)
		res = max(ns[0], ns[1]);
	for (i = 2; i < n; i++) {
		j = ((i + 2 <= n ? (n - i) : 0) + 1) / 2;
		if (j + 1 >= m) {
			dp[i][1] = ns[i];
			if (m == 1)
				res = max(res, ns[i]);
		}
		for (auto it = dp[i - 2].begin(); it != dp[i - 2].end(); it++) {
			if (j + 1 + it->first >= m) {
				auto jt = dp[i].find(it->first + 1);
				if (jt != dp[i].end())
					jt->second = max(jt->second, ns[i] + it->second);
				else
					dp[i][it->first + 1] = ns[i] + it->second;
				if (m == it->first + 1)
					res = max(res, dp[i][it->first + 1]);
			}
		}
		if (i - 3 >= 0) {
			for (auto it = dp[i - 3].begin(); it != dp[i - 3].end(); it++) {
				if (j + 1 + it->first >= m) {
					auto jt = dp[i].find(it->first + 1);
					if (jt != dp[i].end())
						jt->second = max(jt->second, ns[i] + it->second);
					else
						dp[i][it->first + 1] = ns[i] + it->second;
					if (m == it->first + 1)
						res = max(res, dp[i][it->first + 1]);
				}
			}
		}
		if (i - 4 >= 0) {
			for (auto it = dp[i - 4].begin(); it != dp[i - 4].end(); it++) {
				if (j + 1 + it->first >= m) {
					auto jt = dp[i].find(it->first + 1);
					if (jt != dp[i].end())
						jt->second = max(jt->second, ns[i] + it->second);
					else
						dp[i][it->first + 1] = ns[i] + it->second;
					if (m == it->first + 1)
						res = max(res, dp[i][it->first + 1]);
				}
			}
		}
		
	}
	
	cout << res << "\n";
	
	return 0;
}


Measured memory_bytes: 45440
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
  
bool pal(string s)
{
  int n=s.size();
  for(int i=0;i<n/2;i++)if(s[i]!=s[n-i-1])return false;

  return true;
}

int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {

  double l;
  cin>>l;

  cout<<fixed<<setprecision(12);

  double ans=l/3;
  ans*=(ans*ans);

  cout<<ans;

    //while loop ending 
  }


  return 0;
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		System.out.println(w * (double) h / 2);
		boolean bool = w == x * 2 && h == y * 2;
		System.out.println(bool ? 1 : 0);
	}
}


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

bool check(vector<int> v, vector<int> w){
  for(int i=0; i<v.size(); i++){
    if(v[i]!=w[i]) return false;
  }
  return true;
}
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
  }
  for(int i=0; i<N; i++){
    cin >> Q[i];
  }
  
  vector<int> per(N);
  for(int i=0; i<N; i++){
    per[i]=i+1;
  }
  int a,b;
  int now=1;
  do{
    if(check(per,P)) a=now;
    if(check(per,Q)) b=now;
    now++;
  }while(next_permutation(per.begin(), per.end()));
  int ans=abs(a-b);
  cout << ans <<endl;
}

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


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n = int(input())
    s = input()

    x = 0
    ans = 0
    for i in range(n):
        if s[i] == 'I':
            x += 1
        elif s[i] == 'D':
            x -= 1
        ans = max(ans, x)
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
for(int i = 1;;i++){
int x = sc.nextInt();
if(x == 0){
break;
}
System.out.printf("Case %d: %d\n",i,x);
}
sc.close();
}
}


Measured memory_bytes: 62296
INF = 1e10
n, w = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(n)]
data = [[INF, INF]] + data

max_value = n * 1000
# i番目に価値の総和がj以上となるように選んだときの重さの最小値 双対問題？
dp = [[INF] * (max_value + 1) for _ in range(n + 1)]

dp[0][0] = 0

for i in range(1, n + 1):
    for j in range(max_value + 1):
        wi, vi = data[i][0], data[i][1]
        # i番目の品物を入れる場合
        take = dp[i - 1][j - vi] + wi if j - vi >= 0 else INF
        # 入れない場合
        dismiss = dp[i - 1][j]
        dp[i][j] = min(take, dismiss)


result = dp[-1]
for j in reversed(range(max_value + 1)):
    if result[j] <= w:
        print(j)
        break



Measured memory_bytes: 237556
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);


int main(){
	int n;
	cin>>n;
	vi v(n);
	rep(i, n) cin>>v[i];

	vi a(n), b(n), d(n);
	int one = 0;
	rep(i, n) if(v[i] == 1) one = i;
	rep(i, n){
		d[v[i]-1] = i - one;
	}
	rep(i, n) a[i] = i;
	rep(i, n) b[i] = d[i] - a[i];

	REP(i, 1, n){
		if(a[i] <= a[i-1]){
			int e = a[i-1] - a[i] + 1;
			a[i] += e;
			b[i] -= e;
		}
		if(b[i] >= b[i-1]){
			int e = b[i] - b[i-1]+1;
			a[i] += e;
			b[i] -= e;
		}
	}
	int m = 0;
	rep(i, n) m = min(m, b[i]);
	rep(i, n) {
		if(i!= 0) cout<<" ";
		cout<<a[i]-m+1;
	}
	cout<<endl;
	rep(i, n){
		if(i!= 0) cout<<" ";
		cout<<b[i]-m+1;
	}
	cout<<endl;

	// rep(i, n) cout<<" "<<a[v[i]-1]+b[v[i]-1];
	// cout<<endl;
}

Measured memory_bytes: 896
ABC = sorted(list(map(int, input().split())))

diff_12 = ABC[1] - ABC[0]
middle = ABC[1]
mx = ABC[2]

ans = 0
ans += (diff_12+1) // 2
if (diff_12 % 2) == 1:
    ans += 1
ans += mx - middle

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n;
  cin>>n;
  int ans = 0;
  if(n<10){
    ans = n;
    cout<<ans<<endl;
    return 0;
  }else if(n<100){
    cout<<9<<endl;
    return 0;
  }else if(n<1000){
    ans = 9 + (n-100+1);
  }else if(n<10000){
    ans = 909;
  }else if(n<100000){
    ans = 909 + (n-10000+1);
  }else{
    ans = 90909;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> struct Segtree {
    inline T merge(const T &a, const T &b) { return min(a, b); }
    inline void act(T &a, const T &b) { a = b; }
    int n, e;
    vector<T> dat;
    Segtree(int n_, int e) : e(e) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        dat.resize(2 * n, e);
    }
    void set(int k, const T &x) {
        k += n;
        act(dat[k], x);
        k >>= 1;
        while (k > 0) {
            dat[k] = merge(dat[k << 1], dat[k << 1 | 1]);
            k >>= 1;
        }
    }
    T get(const int &a, const int &b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return e;
        }
        if (a <= l && r <= b) {
            return dat[k];
        }
        return merge(get(a, b, k << 1, l, (l + r) >> 1),
                     get(a, b, k << 1 | 1, (l + r) >> 1, r));
    }
    inline T get(const int &a, const int &b) { //[a,b)
        if (a >= b) {
            return e;
        }
        return get(a, b, 1, 0, n);
    }
    int find(const int &a, const int &b, const T &x, int k, int l, int r) {
        if (b <= l || r <= a || dat[k] > x) {
            return -1;
        }
        if (k >= n) {
            return k - n;
        }
        int il = find(a, b, x, k << 1, l, (l + r) >> 1);
        if (il != -1) {
            return il;
        }
        return find(a, b, x, k << 1 | 1, (l + r) >> 1, r);
    }
    inline int find(const int &a, const int &b, const T &x) {
        if (a >= b) {
            return -1;
        }
        return find(a, b, x, 1, 0, n);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    Segtree<int> seg(n, (1LL << 31) - 1LL);
    for (int i = 0; i < q; i++) {
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 0) {
            seg.set(l, r);
        } else {
            ++r;
            cout << seg.get(l, r) << "\n";
        }
    }
}


Measured memory_bytes: 3912
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    int h, w; cin >> h >> w;
    vector<string> v;
    REP(i, h) {
        string tmp; cin >> tmp;
        v.push_back(tmp);
    }
    int dp[110][110];
    memset(dp, 0, sizeof(dp));

    REP(i, h) {
        REP(j, w) {
            if (i == 0 && j == 0) {
                continue;
            }
            if (i == 0) {
                if (v[i][j] == v[i][j-1]) {
                    dp[i][j] = dp[i][j-1];
                } else {
                    dp[i][j] = dp[i][j-1] + 1;
                }
            } else if (j == 0) {
                if (v[i][j] == v[i-1][j]) {
                    dp[i][j] = dp[i-1][j];
                } else {
                    dp[i][j] = dp[i-1][j] + 1;
                }
            } else {
                int addr = 0;
                int addl = 0;
                if (v[i][j] != v[i-1][j]) {
                    addr = 1;
                }
                if (v[i][j] != v[i][j-1]) {
                    addl = 1;
                }
                dp[i][j] = min(dp[i][j-1]+addl, dp[i-1][j]+addr);
            }
        }
    }
    if (v[0][0] == '.' && v[h-1][w-1] == '.') {
        cout << dp[h-1][w-1] / 2 << endl;
    } else {
        cout << dp[h-1][w-1] / 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll k; cin >> k;
  queue<ll> q;
  for (int i = 1; i < 10; i++) q.push(i);
  rep(i, k-1) {
    ll x = q.front(); q.pop();
    if (x % 10 != 0) q.push(x * 10 + (x % 10 - 1));
    q.push(x * 10 + x % 10);
    if (x % 10 != 9) q.push(x * 10 + (x % 10 + 1));
  }
  outl(q.front());
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1792
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_a"

#include<iostream>
#include<string>

using namespace std;

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

    s[k-1] = s[k-1]+32;
    cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y)x>y?x:y
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a-b>c)printf("0\n");
	else printf("%d\n",c-(a-b));
	return 0;
}

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

using namespace std;

std::string const YES = "YES";
std::string const NO = "NO";

int64_t solve(int64_t /*a*/, int64_t /*b*/, int64_t /*c*/) { return 0; }

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::array<int64_t, 3> as;
  std::cin >> as[0];
  std::cin >> as[1];
  std::cin >> as[2];
  std::sort(as.begin(), as.end());
  if (as[0] == 5 && as[1] == 5 && as[2] == 7) {
    std::cout << YES << std::endl;
  } else {
    std::cout << NO << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (b-a+1 < 2*k) {
    for (int i = a; i <= b; i++) cout << i << endl;
    return 0;
  }
  
  for (int i = a; i <= a + (k-1); i++) {
    cout << i << endl;
  }
  for (int i = b - (k-1); i <= b; i++) {
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256