akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>b){
    for(int i=1;i<=a;i++){
      cout<<b;
    }
  }
  else{
    for(int i=1;i<=b;i++){
      cout<<a;
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	public class QuestionA
	{
		public static void Main(string[] args)
		{
			// 文字列の入力
			string s = Console.ReadLine();

			long result = 0;

			if (s.Length == 1) {
				Console.WriteLine(s);
				return;
			}

			for (int i = 0; i < s.Length; ++i) {
				if (i == 0) {
					result += int.Parse(s[i].ToString()) - 1;
				} else {
					result += 9;
				}
			}

			var t = digit_sum(long.Parse(s));
			Console.WriteLine(Math.Max(result, t));
		}

		private static long  digit_sum(long n)
		{
			if (n < 10) return n;
			return digit_sum(n / 10) + n % 10;
		}
	}
}


Measured memory_bytes: 27488
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,k;
    cin >> n >> k;
    k--;
    vector <long> h(n);
    for(long i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    vector <long> diffK(n,-1);
    for(long i = 0; i < n; i++){
        //cout << h[i] << " ";
        if(i>=k){
            diffK[i] = h[i] - h[i-k];
        }
    }
    //cout << endl;
    sort(diffK.begin(),diffK.end());
    for(long i = 0; i < n; i++){
        if(diffK[i]!=-1){
            cout << diffK[i] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4844
N,K = map(int, input().split())
a = list(map(int, input().split()))

b = [0]
for ai in a:
    b.append(b[-1]+ai) 

cond = []
for i in range(N+1):
    for j in range(i+1, N+1):
        cond.append(b[j]-b[i])

ans = 0
for i in reversed(range(40)):
    b = ans + 2**i
    cnt = 0
    for c in cond:
        if c&b==b:
            cnt += 1
    if cnt>=K:
        ans = b

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int total = 0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    total += a[i];
  }
  
  int x = total*0.5;
  int sum = 0;
  for(int i=0; i<n; i++) {
    sum += a[i];
    if(x <= sum) {
      if(sum-x > x-sum+a[i]) {
        sum -= a[i];
      }
      break;
    }
  }
  cout << abs(sum-(total-sum)) << endl;
  return 0;
}

Measured memory_bytes: 3612
def rect(x1,x2,y1,y2):
    dx = x2-x1
    dy = y2-y1
    ddx = -dy
    ddy = dx
    x3 = x2 + ddx
    y3 = y2 + ddy
    x4 = x1 + ddx
    y4 = y1 + ddy
    return [x3,y3,x4,y4]

x1,y1,x2,y2 = map(int,input().split())

print(*rect(x1,x2,y1,y2))

Measured memory_bytes: 3060
x1,y1,x2,y2 = map(int,input().split())
if x1 == x2:
    print(x2+(y1-y2), y2, x2+(y1-y2), y1)
elif y1 == y2:
    print(x2, y2+(x2-x1), x1, y2+(x2-x1))
else:
    print(x2-(y2-y1), y2+(x2-x1), x1-(y2-y1), y1+(x2-x1))


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vector<vi> abc(n, vi(3));
    rep(i, n) rep(j, 3) cin >> abc[i][j];
    vector<vi> dp(n+1, vi(3));
    rep(i, n) rep(j, 3) {
        rep(k, 3) if (k != j) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+abc[i][j]);
        }
    }
    cout << *max_element(all(dp[n])) << endl;
    return 0;
}


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

typedef struct ray{
    char value[3];
}Ray;

void BubbleSort(Ray *C, int N){
    int i, j;
    Ray temp;
    for(i = 0; i < N; i++){
        for(j = N-1; j > i; j--){
            if(C[j].value[1] < C[j-1].value[1]){
                temp = C[j];
                C[j] = C[j-1];
                C[j-1] = temp;
            }
        }
    }
    for(i = 0; i < N-1; i++) printf("%s ", C[i].value);
    printf("%s\nStable\n", C[i].value);
}

void SelectionSort(Ray *D, int N){
    int i, j, minj;
    Ray temp;
    for(i = 0; i < N; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(D[j].value[1] < D[minj].value[1]) minj = j;
        }
        temp = D[i];
        D[i] = D[minj];
        D[minj] = temp;
    }
    for(i = 0; i < N-1; i++) printf("%s ", D[i].value);
    printf("%s\n", D[i].value);
}

void compare(Ray *C, Ray *D, int N){
    int i;
    for(i = 0; i < N; i++){
        if(strcmp(C[i].value, D[i].value) != 0){
            printf("Not stable\n");
            return ;
        }
    }
    printf("Stable\n");
    return ;
}

int main(){
    int i, j, N;
    Ray C[36], D[36];
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%s", C[i].value);
        strcpy(D[i].value, C[i].value);
    } 
    BubbleSort(C, N);
    SelectionSort(D, N);
    compare(C, D, N);
    return 0;
}



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

using ll = long long int;

const int MAX_N = (int)1e5 + 5;
const ll MOD = (ll)1e9 + 7;

struct index_point {ll index, x, y;};
struct edge {ll u, v, cost;};

int n;
vector<index_point> ips;

bool comp(const edge &e1, const edge &e2) {
  return e1.cost < e2.cost;
}

vector<edge> es;
ll vsize, esize;

/////////////////////////////////////////////////////////
ll uf_par[MAX_N];
ll uf_rank[MAX_N];

void uf_init(ll n) {
  for (ll i = 0; i < n; ++i) {
    uf_par[i] = i;
    uf_rank[i] = 0;
  }
}

ll uf_find (ll x) {
  if (uf_par[x] == x) {return x;}
  else {
    return uf_par[x] = uf_find(uf_par[x]);
  }
}

void uf_unite(ll x, ll y) {
  x = uf_find(x);
  y = uf_find(y);

  if (x == y) {return;}
  if (uf_rank[x] < uf_rank[y]) {uf_par[x] = y;}
  else {
    uf_par[y] = x;
    if (uf_rank[x] == uf_rank[y]) uf_rank[x] += 1;
  }
}

bool uf_same(ll x, ll y) {
  return uf_find(x) == uf_find(y);
}
/////////////////////////////////////////////////////////

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    ll x, y;
    index_point ip;
    scanf("%lld", &x);
    scanf("%lld", &y);
    ip.index = i;
    ip.x = x;
    ip.y = y;
    ips.push_back(ip);
  }

  sort(ips.begin(), ips.end(), [](const index_point a, const index_point b) {return a.x < b.x;}); // sort by x
  for (int i = 1; i < ips.size(); ++i) {
    edge e;
    e.u = ips[i - 1].index;
    e.v = ips[i].index;
    e.cost = ips[i].x - ips[i - 1].x;
    es.push_back(e);
  }

  sort(ips.begin(), ips.end(), [](const index_point a, const index_point b) {return a.y < b.y;}); // sort by x
  for (int i = 1; i < ips.size(); ++i) {
    edge e;
    e.u = ips[i - 1].index;
    e.v = ips[i].index;
    e.cost = ips[i].y - ips[i - 1].y;
    es.push_back(e);
  }

  vsize = n;
  esize = es.size();

  sort(es.begin(), es.end(), comp);
  uf_init(vsize);

  ll res = 0;
  for (int i = 0; i < esize; ++i) {
    edge e = es[i];
    if (!uf_same(e.u, e.v)) {
      uf_unite(e.u, e.v);
      res += e.cost;
    }
  }

  printf("%lld\n", res);

  return 0;
}

Measured memory_bytes: 10988
apartment=[[[0]*10 for i in range(3)] for j in range(4)]
n = int(input())

for loop in range(n):
    b,f,r,v = map(int,input().split())
    apartment[b-1][f-1][r-1] += v

x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(apartment[i][a][b]),end = "")
        print()



Measured memory_bytes: 5624
n, s = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
dp = [0]*(s+1)
dp[0] = pow(2, n, MOD)
inv_2 = pow(2, MOD-2, MOD)
for a in A:
    for j in reversed(range(s+1)):
        if s < j+a:
            continue
        dp[j+a] += dp[j]*inv_2 % MOD

print(dp[-1] % MOD)


Measured memory_bytes: 96936
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
string grid[50];
bool used[50][50];
string surrounded[50];
int move_h[4] = {-1, 1, 0, 0};
int move_w[4] = {0, 0, -1, 1};

void dfs_fill(int cur_h, int cur_w, char color, int h, int w){
  surrounded[cur_h][cur_w] = color;
  for(int i = 0; i < 4; i++){
    int next_h = cur_h + move_h[i];
    int next_w = cur_w + move_w[i];
    if(0 <= next_h && next_h < h && 0 <= next_w && next_w < w
        && grid[next_h][next_w] == '.' && surrounded[next_h][next_w] == '.'){
      dfs_fill(next_h, next_w, color, h, w);  
    }
  }
}

char dfs_check(int cur_h, int cur_w, int h, int w){
  used[cur_h][cur_w] = true;
  if(grid[cur_h][cur_w] != '.'){
    used[cur_h][cur_w] = false;
    return grid[cur_h][cur_w];
  }
  char ret = '.';
  bool return_x = false;
  for(int i = 0; i < 4; i++){
    int next_h = cur_h + move_h[i];
    int next_w = cur_w + move_w[i];
    if(0 <= next_h && next_h < h && 0 <= next_w && next_w < w
        && !used[next_h][next_w]){
      char tmp = dfs_check(next_h, next_w, h, w);
      if(tmp == 'x' || (ret != '.' && tmp != '.' && ret != tmp)){
        return_x = true;
      }
      ret = tmp;
    }
  }
  if(return_x){
    return 'x';
  }
  return ret;
}

int main(){
  while(true){
    int w;
    int h;
    cin >> w >> h;
    if(w == 0 && h == 0){
      break;
    }
    for(int i = 0; i < h; i++){
      cin >> grid[i];
    }

    for(int i = 0; i < h; i++){
      surrounded[i] = "";
      for(int j = 0; j < w; j++){
        surrounded[i].push_back('.');
        used[i][j] = false;
      }
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(!used[i][j] && grid[i][j] == '.'){
          char tmp = dfs_check(i, j, h, w);
          if(tmp == 'B' || tmp == 'W'){
            dfs_fill(i, j, tmp, h, w);
          }
        }
      }
    }

    int ans_B = 0;
    int ans_W = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(surrounded[i][j] == 'B'){
          ans_B ++;
        }
        if(surrounded[i][j] == 'W'){
          ans_W ++;
        }
      }
    }
    /*
    for(int i = 0; i < h; i++){
      cout << surrounded[i] << endl;
    }
    */
    cout << ans_B << " " << ans_W << endl;
  }
  return 0;
}

/*
.....W....
....W.W...
...W...W..
....W...W.
.....W...W
......W.W.
BBB....W..
..B..BBBBB
..B..B....
..B..B..W.
*/


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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int ans = 0;
    int a[n + 1]{};
    set<int> s;
    for(int i = 1; i <= n; i++){
         cin >> a[i];
         s.insert(a[i]);
         if(*s.begin() == a[i]) {
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
  int n,d;
  cin>>n>>d;
  int count=0;
  long int x,y;
  long long int d2;
  double d3;
  while(n--){
    cin>>x>>y;
    d2 = x*x + y*y;
    d3 = sqrt(d2);
    if(d3<=(double)d)
      	count++;
  }
  cout<<count;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 107;

int n;

void read() {
  cin >> n;
}


void kill() {
  ll ans = 0;
  ll sum = 0;

  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    if (x == 0) {
      ans += sum / 2;
      sum = 0;
    } else {
      sum += x;
    }
  }

  ans += sum / 2;

  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    int Max = -1;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        Max = max(Max,arr[i]);
    }
    vector<int> sieve(Max+1,0);
    for(int i=0;i<n;i++)
    {
        int curr = arr[i];
        for(int j=curr;j<=Max;j+=curr)
        {
            sieve[j]++;
        }
    }
    int cnt = 0;
    for(int i=0;i<n;i++)
    {
        if(sieve[arr[i]]==1)
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,cnt=0;
  cin>>H>>W;
  for(int i=0;i<H*W;i++){
    char c;
    cin>>c;
    if(c=='#')cnt++;
  }
  if(cnt==H+W-1)puts("Possible");
  else puts("Impossible");
}

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

using namespace std;


int HammingData[1000001] = {0,1};

void judge() {
	int tmp;
	bool flag;

	for (int i = 2; i < 1000001; i++) {
		tmp = i;
		flag = true;
		while (tmp != 1) {
			if (tmp % 2 == 0) {
				tmp /= 2;
			}
			else if (tmp % 3 == 0) {
				tmp /= 3;
			}
			else if (tmp % 5 == 0) {
				tmp /= 5;
			}
			else {
				flag = false;
				break;
			}
		}
		if (flag) {
			HammingData[i] = 1;
		}
	}
}


int main(void) {
	int n, m, sum;

	judge();

	while (cin >> m, m) {
		cin >> n;
		n++;
		sum = 0;
		for (int i = m; i < n; i++) {
			if (HammingData[i] == 1) {
				sum++;
			}
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, m, a, MAX = 100000, ans = 0;
    cin >> n >> m;
    vector<vector<int> > x(m, vector<int> (2,0));
    vector<int> b(MAX + 1, 0);
    for(int i=0;i<n;i++) cin >> a, b[a]++;
    for(int i=1;i<=MAX;i++){
    	x[i % m][1] += b[i] / 2;
    	x[i % m][0] += b[i] & 1;
    }
    for(int i=0;i<=m/2;i++){
    	if(i * 2 == m || i == 0){
    		ans += x[i][0] / 2;
    		ans += x[i][1];
    		continue;
     	}
     	int j = m - i;
     	if(x[i][0] == x[j][0]){
     		ans += x[i][0];
     		ans += x[i][1];
     		ans += x[j][1];
     		continue;
     	}
     	if(x[i][0] < x[j][0]){
     		swap(x[i][0], x[j][0]);
     		swap(x[i][1], x[j][1]);
     	}
     	ans += x[j][0];
     	x[i][0] -= x[j][0];
     	ans += x[i][1];
     	int num = x[j][1] * 2;
     	if(x[i][0] >= num){
     		ans += num;
     	}else{
     	    ans += x[i][0];
     		num -= x[i][0];
     		ans += num / 2;
     	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6144
import math

a, b, h, m = list(map(int, input().split()))
angle_h = 2 * math.pi * ((60 * h + m) / 720)
angle_m = 2 * math.pi * (m / 60)

diff = angle_m - angle_h
d = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(diff))
print(d)

Measured memory_bytes: 62480
#include "bits/stdc++.h"
using namespace std;
int main() {
	int k, n, i;
	int a[200001] = { 0 };
	int diff = 0;
	int diff_max = 0;
	int distance = 0;

	cin >> k >> n;

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

	for (i = 0; i < n; i++) {
		diff = a[i + 1] - a[i];
		if (diff > diff_max) {
			diff_max = diff;
		}
		distance += diff;
	}

	cout << distance - diff_max << endl;
	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int l = 0;
    int x;
    for(int i=0; i<N; i++) {
        cin >> x;
        l += min((2 * x),(2 * abs(K - x)));
    }
    cout << l << endl;
}

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

def main():
    N = int(input())
    ans = 0
    for _ in range(N):
        x,u = input().split()
        if u == "JPY":
            ans += int(x)
        else:
            ans += float(x) * 380000.0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    string ans = "";
    rep(i, s.size()) {
        ans += (s[i] - 'A' + n) % 26 + 'A';
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <bitset>
#include <algorithm>
#include <assert.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define mst(a,b) memset((a),(b),sizeof(a))
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const int mod = 1e9 + 7;
const double Pi = acos(-1.0);
const int maxn = 2e5 + 5;
const int N = 1e3 + 5;
const ULL hashmod = 2908361;
const double eps = 1e-8;
LL a[maxn];
int main() {
#ifdef local
    freopen("input", "r", stdin);
    //freopen("input", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL res = 0;
    int n,T;
    cin>>n>>T;
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    a[n] = 2e9+5;
    for(int i = 0; i < n; i++){
        int j = i;
        while(a[j+1] - a[j] <= T)j++;
        res += a[j] + T - a[i];
        i = j;
    }
    cout<<res<<endl;
    return 0;
}


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

ll binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(ll i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

ll dfs(string t,int x){
  ll ret=0;
  int len=t.size();
  if(t.size()<x){
    return 0LL;
  }
  if(x==0 || t.size()==0)return 1;
  string temp="";
  rep(i,t.size()){
    if(i!=0)temp+=t[i];
  }  
  if(t[0]=='0'){
    return dfs(temp,x);
  }
  ll te=1;
  rep(i,x)te*=9;
  ret+=te/9*binomial(len-1,x-1)*(t[0]-'0'-1);
  ret+=te*binomial(len-1,x);
  return ret+dfs(temp,x-1);
}

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  ll ans=1;
  rep(i,k)ans*=9;
  ll n=s.size();
  cout << dfs(s,k) << endl;
return 0;}

Measured memory_bytes: 256
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
a = 0
b = 0
used_a = [True for i in range(N)]
used_b = [True for i in range(N)]
def cal(x,used):
    n = 0
    for i in range(N):
        if used[i] and x > (i+1):
            n += 1
        else:
            pass
    ret = 1
    p = sum(used) - 1
    while True :
        if p == 0 :
            break
        else:
            ret *= p
            p -= 1
    return ret * n

for i in range(N-1):
    a += cal(P[i],used_a)
    used_a[P[i]-1] = False
    b += cal(Q[i],used_b)
    used_b[Q[i]-1] = False
print(abs(a-b))

Measured memory_bytes: 3064
A,B,C,K=map(int,input().split())


if(K<=A):
    a=K
    print(a)
    exit()
else:
    a=A
    if(A+B>=K):
        print(a)
        exit()
    else:
        if(A+B+C>=K):
            print(a-(K-A-B))
            exit()
        else:
            print(a-C)


Measured memory_bytes: 61620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN=1e5+5;
const ll inf=(1ll<<63-1);
ll a[MAXN];
ll dp[MAXN];
int main()
{
 
    ll n,e,t;
    cin>>n>>e>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,(ll)0x3f3f3f3f,sizeof(dp));
    dp[0]=0;
    ll mn=inf;
    for(int i=1,now=0;i<=n;i++){
        while(t<=2*(a[i]-a[now+1]))
        {
            mn=min(mn,dp[now]-2*a[now+1]);
            now++;
        }
        dp[i]=dp[now]+t;
        dp[i]=min(dp[i],mn+2*a[i]);
 
    }
    cout<<e+dp[n]<<endl;
    return 0;
 
}

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


int main(){
int n,m,mx=0,mn=999999;
  cin>>n>>m;
vector<pair<int,int>> v(m);
  for(int i=0;i<m;i++){
  cin>>v[i].first>>v[i].second;
  mx=max(v[i].first,mx);
  mn=min(v[i].second,mn);
  }
  cout<<max(mn-mx+1,0);
  return 0;
}



Measured memory_bytes: 4028
N, A, B = map(int, input().split())

ans = []


def f(s, d):
    if bin(d).count('1') == 1:
        ans.append(s)
        ans.append(s ^ d)
        return
    else:
        if (s & ~d == B & ~d) and ((s & d) ^ (B & d) != ((1 << N) - 1)):
            d1 = d - (1 << next(i for i in range(N) if s & (1 << i) != B & (1 << i)))
        else:
            d1 = d - (1 << next(i for i in range(N) if (d >> i) & 1))
        # print(s, d, d1)
        f(s, d1)
        t = ans[-1] ^ (d ^ d1)
        d2 = d - (d ^ d1)
        f(t, d2)
        return


if sum((A & (1 << i)) != (B & (1 << i)) for i in range(N)) % 2 == 0:
    print('NO')
else:
    print('YES')
    f(A, ((1 << N) - 1))
    print('\n'.join(map(str, ans)))


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

typedef long long ll;
typedef std::pair<ll, ll> l_l;
typedef std::pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    while (v.size() != 1) {
        double a = v[v.size() - 1];
        v.pop_back();
        double b = v[v.size() - 1];
        v.pop_back();
        double c = (a + b) / 2;
        v.emplace_back(c);
    }
    cout << v[0] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	string s, t;
	cin >> s >> t;
	string ans = "No";
	rep(i, s.size()) {
		int cnt = 0;
		rep(j, s.size()) {
			if (s[(i + j) % s.size()] == t[j]) {
				cnt++;
			}
		}
		if (cnt == s.size()) {
			ans = "Yes";
		}
	}
	cout << ans << endl;

	return 0;
}

//Ctrl+Aを使わない

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

using namespace std;

int main()
{
	bool flag[26];
	string alphabe = "abcdefghijklmnopqrstuvwxyz";
	string s;
	for (int i = 0; i < 26; i++)
	{
		flag[i] = false;
	}


	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		flag[s[i] - 97] = true;
	}

	for (int i = 0; i < 26; i++)
	{
		if (!flag[i])
		{
			cout << alphabe[i] << endl;
			break;
		}
		if (i == 25)
		{
			cout << "None" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c<=21){
    cout<<"win"<<endl;
  }else{
    cout<<"bust"<<endl;
  }
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    set<string> st;
    for(int i=0; i<n; i++){
        string a, b;
      	cin >> a >> b;
        if(a == "insert"){
            st.insert(b);
        }else{
            if(st.find(b) != st.end()){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 32132
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int a[100005];
	for(int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int p = 0,temp=1;
	for(int i = 1;i<=n;i++){
		temp=a[temp];
		p++;
		if(temp==2) break;
	}
	if(temp==2) printf("%d\n",p);
	else printf("-1\n");
}

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

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

    set<int> s;

    s.insert(a);
    s.insert(b);
    s.insert(c);

    if (s.size() == 1 || s.size() == 3)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

inline void swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) {
    swap(a, b);
  }
  if (b > c) {
    swap(b, c);
  }
  if (a > b) {
    swap(a, b);
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner

fun main(args: Array<String>){
	val s = Scanner(System.`in`).nextLine()
	val N  = Integer.parseInt(s)

	var count = N
	
	for(i in 1..20){
		if(count%4 == 0){
			println("Yes")
			break
		}
		else{
			count -= 7
		}

		if(count < 0){
			println("No")
			break
		}
	}

}

Measured memory_bytes: 31268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;

    int N = s.length();

    for (int i = 0; i <= N; i++){
        if (i == 4){
            cout << ' ';
        }
        else if (i < 4){
            cout << s[i];
        }
        else if (i > 4){
            cout << s[i - 1];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
def segmentTree(dat, f, sentinel):
        pad = 2 ** math.ceil(math.log(len(dat),2))
        dat = [0] * pad + dat + [sentinel] * (pad - len(dat))
        for i in range(pad - 1, 0, -1):
            dat[i] = f(dat[i * 2],dat[i * 2 + 1])
        return dat

def get_lr(b,d):
    l = r = 0
    while r < len(b):
        while b[l] + d < b[r]:
            l += 1
        for r in range(r,len(b)):
            if b[l] + d < b[r]:
                r -= 1
                break
        r += 1
        yield l,r
        l += 1
    
import sys
f = sys.stdin

_, d = map(int, f.readline().split())

xyb = []
for line in f:
    xyb.append(tuple(map(int, line.split())))
from operator import itemgetter
xyb.sort(key=itemgetter(2))

x = [xybi[0] for xybi in xyb]
y = [xybi[1] for xybi in xyb]
b = [xybi[2] for xybi in xyb]

xmax = segmentTree(x,max,sentinel = 0)
xmin = segmentTree(x,min,sentinel = 2000000)
ymax = segmentTree(y,max,sentinel = 0)
ymin = segmentTree(y,min,sentinel = 2000000)


pad = len(xmax) // 2
max_size = 0
def create_index(l,r):
    index = []
    ia = index.append
    while l < r:
        if r & 1:
            r -= 1
            ia(r)
        if l & 1:
            ia(l)
            l += 1
        l >>= 1
        r >>= 1
    return index

for l,r in get_lr(b,d):
    l += pad 
    r += pad
    index = create_index(l,r)

    now_xmax = max(xmax[i] for i in index)
    now_ymax = max(ymax[i] for i in index)
    if max_size < now_xmax * now_ymax:
        max_size = max(max_size,((now_xmax - min(xmin[i] for i in index)) * (now_ymax - min(ymin[i] for i in index))))
print(max_size)

Measured memory_bytes: 72328
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import qualified Data.Vector.Unboxed as V

main = do
  [_,capa] <- map (read :: String -> Int) . words <$> getLine
  goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
  print $ V.maximum (resolve capa (V.enumFromStepN 0 0 (capa+1)) goods)

resolve capa capaV ([v,w,m]:xs)
  | null xs   = koushin' m 1 capaV
  | otherwise = resolve capa (koushin' m 1 capaV) xs
  where
    koushin' m x capaV
      | m == 0 || w > capa  = capaV
      | (w*x) > capa        = koushin' m (x-1) capaV
      | x >= m              = koushin capaV [v*m,w*m] (capa-(w*m)) []
      | otherwise = koushin' (m-x) (x*2) (koushin capaV [v*x,w*x] (capa-(w*x)) [])
    koushin capaV [v,w] n koushinList
      | n == 0 && capaV V.! w <= v      = capaV V.// ((w,v):koushinList)
      | n == 0                          = capaV V.// koushinList
      | oldValue == 0                   = next
      | capaV V.! (n+w) >= v + oldValue = next
      | otherwise = koushin capaV [v,w] (n-1) ((n + w, v + oldValue):koushinList)
      where
        oldValue = capaV V.! n
        next     = koushin capaV [v,w] (n-1) koushinList

Measured memory_bytes: 6768
#include <iostream>
#include <vector>

using namespace std;

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

    // ????????´?????\??°
    auto numberOfDaysInYear = [](int y) {
        if (y % 3 == 0) {
            return 20 * 10;
        }
        else {
            return 20 * 5 + 19 * 5;
        }
    };

    // y + 1??´??????999/10/20?????§?????\??°
    vector<int> ym(1001, 0);
    ym[1] = numberOfDaysInYear(1000 - 1);
    for (int i = 2; i < ym.size(); ++i) {
        ym[i] = numberOfDaysInYear(1000 - i) + ym[i - 1];
    }

    auto remainThisYear = [](int y, int m, int d) {
        // 3????????°????????°??????????????????20??\
        if (y % 3 == 0) {
            // ??????????????° + ???????????\??°
            return (10 - m) * 20 + 20 - d;
        }
        else {
            // ?????§??????????????????
            if (m % 2 == 1) {
                return (10 - m) * 20 - ((10 - m) / 2 + 1) + 20 - d;
            }
            else {
                return (10 - m) * 20 - ((10 - m) / 2) + 19 - d;
            }
        }
    };

    auto remainDays = [&remainThisYear, &ym](int y, int m, int d) {
        // ?????´??????????????\??° + ??\??´???1/1??????999/10/20?????§?????\??° + 1??\
        return remainThisYear(y, m, d) + ym[1000 - y - 1] + 1;
    };

    for (int i = 0; i < n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << remainDays(y, m, d) << endl;
    }
}

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

int main(){
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        int count = 0;
        if(i % 2 != 0){
            for(int j = 1; j <= N; j++){
                if(i % j == 0){
                    count++;   
                }
            }
            if(count == 8){
                ans++;
            }
        }
    }
    cout << ans << endl;
    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();
        int r = sc.nextInt();

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



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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k>0){
        if(a>=b) b*=2,k--;
        else break;
    }
    while(k>0){
        if(b>=c) c*=2,k--;
        else break;
    }
    if(c>b&&b>a) printf("Yes");
    else puts("No");
}


Measured memory_bytes: 3760
#include <stdio.h>

int main(void) {
    int A[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}, K;
    scanf("%d", &K);
    printf("%d", A[K-1]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define E endl
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
     
int main()
{
	ll n,b;
	cin>>n>>b;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	
	ll sum=0;
	ll ans=1;
	for(ll i=0;i<n;i++)
	{
		sum=sum+a[i];
		if(sum<=b)
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

bool isprime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x%i == 0)return false;
	}

	return true;
}

int main() {

	int n; cin >> n;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;

		if (isprime(x)) {
			ans++;
		}
	}

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


Measured memory_bytes: 3104
import java.io.*;import java.util.*;class Main{public static void main(String[]z)throws Exception{BufferedReader s=new BufferedReader(new InputStreamReader(System.in));for(int t,m;(t=new Integer(s.readLine()))>0;System.out.println()){Map<String,String>c=new HashMap<String,String>();for(;t-->0;){z=s.readLine().split(" ");c.put(z[0],z[1]);}for(m=new Integer(s.readLine());m-->0;)System.out.print(c.containsKey(z[0]=s.readLine())?c.get(z[0]):z[0]);}}}

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

const int inf{int(1e9)};

void solve(int N, int T, vector<int> c, vector<int> t){
    int ans{inf};
    for(int i = 0; i < N; ++i){
        if(t[i] <= T && c[i] < ans) ans = c[i];
    }
    if(ans == inf) cout << "TLE" << endl;
    else cout << ans << endl;
}

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> c(N+1);
    vector<int> t(N+1);
    for(int i = 0; i < N; ++i){
        cin >> c[i] >> t[i];
    }
    solve(N, T, c, t);
    return 0;
}


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

void solve(int N, int K, string S)
{
    int n_seg = 1;
    char prev = S.at(0);
    for (int i = 1; i < N; i++)
    {
        if (prev != S.at(i))
        {
            n_seg++;
            prev = S.at(i);
        }
    }
    int res = min(N - 1, N - (n_seg - 2 * K));
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    int K;
    cin >> K;
    string S;
    cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 3856
S = input()
n = len(S)
ma = 0
c = 0
for i in range(n):
    for j in range(i,n):
        c = 0
        for k in range(i,j+1):
            if not S[k] in 'ACGT':
                break
            c += 1
        ma = max(ma,c)

print(ma)

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

int main() {
	int h, w, a[25][25], ans = 1e9, pans = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> a[i][j];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int k = 0; k < h; k++)
				for (int l = 0; l < w; l++)
					pans += min(abs(k - i), abs(l - j)) * a[k][l];
			ans = min(ans, pans);
			pans = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3136
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

s=input()+"T"
N=len(s)
x,y=MI()

F=[[],[]]

temp=0
bit=0
for i in range(N):
    if s[i]=="F":
        temp+=1
    else:
        if temp!=0:
            F[bit].append(temp)
        bit=(bit+1)%2
        temp=0
        
XY=[set([0]), set([0])]
    
for bit in range(2):
    for i in range(len(F[bit])):
        temp=set([])
        a=F[bit][i]
        b=-a
        if bit==0 and i==0 and s[0]=="F":
            b=a
        for j in range(len(XY[bit])):
            aaa=XY[bit].pop()
            temp.add(aaa+a)
            temp.add(aaa+b)
        XY[bit]=temp
        
if (x in XY[0] ) and (y in XY[1] ):
    print("Yes")
else:
    print("No")
        




Measured memory_bytes: 47964
k = gets.to_i
k0 = k % 10

ans = 0
d = 0
while !(ans == 0 && d > 0)
    a0 = ans % 10
    x = (0..9).find{|i| (k0 * i + a0) % 10 == 7}
    if !x
        p -1
        exit
    end
    ans += k * x
    ans /= 10
    d += 1
end

p d

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


int main()
{
	int n,count=0;
	scanf("%d",&n);
	if(n<10)
	{
	    for(int i=1;i<=n;i++)
		count++;	
	}
	if(n>9&&n<100)
	{
		count=9;
	}
	if(n>99&&n<1000)
	{
		count=9;
		for(int i=100;i<=n;i++)
	    count++;
	}
	if(n>999&&n<10000)
	count=909;
	if(n>9999&&n<100000)
	{
		count=909;
		for(int i=10000;i<=n;i++)
		count++;
	}
	if(n==100000) count=90909;
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$isi = trim(fgets(STDIN));
$isi = str_split($isi);


$r_cnt = array_count_values($isi)['R'];
$isi = array_chunk($isi, $r_cnt);

if(in_array('W', $isi[0]) && array_count_values($isi[0])['W']){
    $cng_cnt = array_count_values($isi[0])['W'];
}else{
    echo 0;
    exit;
}

echo $cng_cnt;

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

int main(){
  int x;
  cin>>x;
  vector<int64_t>A(87);
  A.at(0)=2;
  A.at(1)=1;
  for(int i=2;i<=x;i++){
    A.at(i)=A.at(i-2)+A.at(i-1);
    }
  cout<< A.at(x) <<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> a(4), b(4);

	while (cin >> a[0] >> a[1] >> a[2] >> a[3],
		cin >> b[0] >> b[1] >> b[2] >> b[3])
	{
		int hit = 0, blow = 0;

		for (int i = 0; i < a.size(); ++i)
			for (int j = 0; j < b.size(); ++j)
				if (a[i] == b[j])
					if (i == j) hit++;
					else blow++;

		cout << hit << " " << blow << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool color = true;
  cin >> N;
 
  for (int i=0; i<N; i++) {
    string S;
    cin >> S;
 	if (S == "Y") {
    	color = false;
    } 
  }
  if (color == true) cout << "Three" << endl;
  else cout << "Four" << endl;
}

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

int main(void){
  long i,j;

  long n;
  scanf("%ld",&n);

  long current;
  int current_state;
  scanf("%ld",&current);

  long next;
  for(i=1;i<n;i++){
    scanf("%ld",&next);
    if(current<next){
      current=next;
      current_state=0;
    }else if(current==next){
    }else if(current==next+1&&current_state==0){
      current=next;
      current_state=1;
    }else{
      printf("No\n");
      exit(0);
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
s=gets.chomp.delete('/').split("").map &:to_i
y=[s[0],s[1],s[2],s[3]].join.to_i
m=[s[4],s[5]].join.to_i
d=[s[6],s[7]].join.to_i
if y<=2019 && (m<4 || (m==4 && d<=30))
  puts :Heisei
else
  puts :TBD
end


Measured memory_bytes: 14312
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll a, b;
    cin >>a >>b;
    
    ll r = 0;
    r = max(max(a+b, a-b), a*b);
    mes(r);
}


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

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scn = new Scanner(System.in);
        Map<String, Integer> ans = new HashMap<>();
        create_anser(ans);
        while (scn.hasNext()) {
            String[] map = scn.nextLine().split(" ");
            System.out.println(ans.get("" + new Node(0, 0, map).getStrId()));
        }
    }

    public static void create_anser(Map<String, Integer> ans) {
        String[] map = {"0", "1", "2", "3", "4", "5", "6", "7"};
        Set<Integer> set = new HashSet<>();
        Queue<Node> queue = new PriorityQueue<>();
        int num = 0;
        for (int i = 0; i < 8; i++) {
            if (map[i].equals("0")) {
                num = i;
                break;
            }
        }
        queue.offer(new Node(num, 0, map));
        while (!queue.isEmpty()) {
            Node node = queue.poll();
            int id = node.getId();
            set.add(id);
            ans.put(node.getStrId(),node.num);

            int[] deadline = {-4,4,-1,1};

            for(int i = 0; i < 4; i++){
                int zero = node.zero + deadline[i];

                if(zero < 0 || zero > 7) continue;
                if(node.zero == 3 && i == 3) continue;
                if(node.zero == 4 && i == 2) continue;

                Node newNode = new Node(zero, node.num + 1, node.map);
                swap(newNode.map, node.zero, zero);
                if(set.contains(newNode.getId())) continue;
                newNode.addSteps(node.getSteps());
                newNode.addStep(newNode);

                queue.offer(newNode);
                set.add(newNode.getId());
            }

        }
    }

    public static void swap(String[] map, int p1, int p2){
        String buf = map[p1];
        map[p1] = map[p2];
        map[p2] = buf;
    }
}

class Node implements Comparable<Node>{
        int zero=0;
        int num;
        String[]map;
        List<Node> steps=new ArrayList<>();
        Node(int zero, int num, String[] map){
            this.zero = zero;
            this.num = num;
            this.map = map.clone();
        }

        public void addStep(Node node){
            this.steps.add(node);
        }

        public void addSteps(List<Node> steps){
            this.steps=new ArrayList<Node>(steps);
        }

        public List<Node> getSteps(){
            return this.steps;
        }

        public int getId(){
            int id=0;
            for(int i=0;i<map.length;i++){
                id = id * 10 + Integer.parseInt(map[i]);
            }
            return id;
        }

        public String getStrId(){
            String id="";
            for(int i = 0; i < map.length ; i++){
                id=id+map[i];
            }
            return id;
        }

        @Override
        public int compareTo(Node o){
            return this.num-o.num;
        }
}



Measured memory_bytes: 58208