akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline long long read(){
    long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
char s[maxn];
int fac1[maxn],fac2[maxn],mod1 = 0,mod2 = 0;
int get_step(int x){
    int cnt = 0;
    while(x){
        x %= __builtin_popcount(x);
        cnt++;
    }
    return cnt;
}
int main(){
    int n = read();
    scanf("%s",s + 1);
    int cnt = 0;
    for(int i=1; i<=n; i++){
        if (s[i] == '1'){
            cnt++;
        }
    }
    mod1 = cnt + 1;
    mod2 = cnt - 1;
    fac1[n] = 1;
    for(int i=n-1; i>=1; i--){
        fac1[i] = fac1[i+1] * 2;
        fac1[i] %= mod1; 
    }
    fac2[n] = 1;
    for(int i=n-1; i>=1; i--){
        fac2[i] = fac2[i+1] * 2;
        if (mod2) fac2[i] %= mod2; 
    }
    LL ans1 = 0,ans2 = 0;
    for(int i=1; i<=n; i++){
        ans1 = ans1 * 2 + s[i] - '0';
        ans1 %= mod1;
        ans2 = ans2 * 2 + s[i] - '0';
        if (mod2) ans2 %= mod2;
    }
    for(int i=1; i<=n; i++){
        if (s[i] == '0'){
            LL ans = ans1 + fac1[i];
            ans %= mod1;
            cout << 1 + get_step(ans) << endl;
        }else{
            LL ans = ans2 - fac2[i];
            if (mod2) {
                ans = (ans % mod2 + mod2) % mod2;
                cout << 1 + get_step(ans) << endl;
            }else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

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

int main(){
  int a;
  int b;
  int c;
  int d;
  int p;
  int X,Y;

  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>p;

  X=a*p;

  if(p<=c)
    Y=b;
  else
    Y=b+(p-c)*d;

  if(X<Y)
    cout<<X<<endl;
  else
    cout<<Y<<endl;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    vector<int> vec_height(10);
     
    for (auto& h : vec_height)
        cin >> h;
 
    sort(vec_height.begin(), vec_height.end(), greater<int>());
     
    cout
        << vec_height[0] << endl
        << vec_height[1] << endl
        << vec_height[2] << endl;
     
    return 0;
}

Measured memory_bytes: 3172
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A= keyboard.nextInt();
		int B= keyboard.nextInt();
		
		String ans = ":(";
		
		if(A <=8 && B<=8) {
			ans = "Yay!";
		}
		
		System.out.print(ans);
		keyboard.close();	
		
	}
}

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

using namespace std;

int n,W;
int w[110],v[110];
long long f[100010];
int main(){
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++){
		scanf("%d%d",w+i,v+i);
	}
	for(int i=1;i<=n;i++){
		for(int j=W;j>=w[i];j--)
			f[j]=max(f[j],f[j-w[i]]+v[i]);
	}
	printf("%lld\n",f[W]);
	return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = list(map(int,input().split()))
sum = 0
cnt = 0
for i in a:
    sum += i
for i in a:
    if(sum <= 4*m*i):
        cnt += 1
if(cnt >= m):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  struct cond { int l, r, x; };
  VV<cond> cs(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, x; cin >> l >> r >> x, l--;
    cs[r].push_back({l, r, x});
  }
  auto f = [&](cond c, int j, int k) {
    if (c.x == 1) return j <= c.l;
    if (c.x == 2) return k <= c.l and c.l < j;
    if (c.x == 3) return c.l < k;
  };
  VV<V<>> dp; assign(dp, n + 1, n, n);
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) for (int j = 0; j <= i; j++) for (int k = 0; k <= j; k++) {
    bool ok = true;
    for (auto&& c : cs[i + 1]) if (!f(c, j, k)) ok = false;
    if (ok) (dp[i + 1][j][k] += dp[i][j][k]) %= mod;
    ok = true;
    for (auto&& c : cs[i + 1]) if(!f(c, i, k)) ok = false;
    if (ok) (dp[i + 1][i][k] += dp[i][j][k]) %= mod;
    ok = true;
    for (auto&& c : cs[i + 1]) if(!f(c, i, j)) ok = false;
    if (ok) (dp[i + 1][i][j] += dp[i][j][k]) %= mod;
  }
  lint res = 0;
  for (int j = 0; j < n; j++) for (int k = 0; k <= j; k++) (res += dp[n][j][k]) %= mod;
  cout << emod(res) << '\n';
}

Measured memory_bytes: 109696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int n, m;
    cin >> n >> m;
    int num ;
    num = n*(n-1)/2 + m*(m-1)/2;
    cout << num << endl;
}

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

const int MAXN = 1e5 + 10;

int u, v;
long long n, r = -1;
vector<int> adj[MAXN];
long long dp[MAXN][2];

void dfs(int root, int par = -1){
    long long s = 0, mx = 0;
    for(auto y: adj[root])
        if(y != par){
            dfs(y, root);
            s += dp[y][1];
            mx = max(mx, dp[y][1] - dp[y][0]);
        }
    dp[root][1] = s - mx;
    dp[root][0] = s - mx;
    if(s - mx == 0)
        dp[root][1] = 1;
    return;
}

int main(){
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    for(int i = 0; i < n; i++)
        if(adj[i].size() >= 3)
            r = i;
    
    if(r < 0)
        return cout << 1 << '\n', 0;
    
    dfs(r);
    cout << dp[r][1] << '\n';
    return 0;
}


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

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

ll mod = (ll)(1e9+7);

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

  vector<ll> ans(10005,0);
  for(ll x = 1; x < 100; x++){
    for(ll y = 1; y < 100; y++){
      for(ll z = 1; z < 100; z++){
        ll id = x*x + y*y + z*z + x*y + y*z + z*x;
        if(id > n){
          continue;
        }
        ans[id] ++;
      }
    }
  }
  rep(i,n){
    cout << ans[i+1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
typedef pair<int, int > point;
const int N=100+10;
char A[N][N];
bool V[N][N];
int h,w;
char s[N];
int mov[][4] ={
	-1,1,0,0,
	0,0,-1,1
};
void solve(){
	char tmp;
	int cnt=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(!V[i][j]){
				V[i][j]=1;
				tmp=A[i][j];
				cnt++;
				queue<point>q;
				q.push(make_pair(i,j));
				while(q.size()){
					point p=q.front();
					q.pop();
					for(int k=0;k<4;k++){
						int x=p.first+mov[0][k];
						int y=p.second+mov[1][k];
						if(!V[x][y]&&A[x][y]==tmp){q.push(make_pair(x,y));
							V[x][y]=1;
						}
					}
				}

			}
			else continue;
		}
	}
	printf("%d\n",cnt);
}
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	while(scanf("%d%d",&h,&w)!=EOF&&w&&h){
		memset(A,-1,sizeof(A));
		memset(V,0,sizeof(V));
		for(int i=1;i<=h;i++){
			scanf("%s", s);
			for(int j=1;j<=w;j++){
				A[i][j]=s[j-1];
				V[i][j]=0;
			}
		}
		solve();
	}
	//insert code above
	return 0;
}
//aoj0118.cc
//generated automatically at Thu Sep  8 16:14:59 2016
//by xsthunder

Measured memory_bytes: 1236
#include<stdio.h>

int yakusu(int x){
  int num = 0;
  for(int i=1; i<=x; i++){
    if(x%i==0)num++;
  }

  return num;
}

int main(){
  int n;
  scanf("%d", &n);

  int sum = 0;
  for(int i=1; i<=n; i++){
    if(i%2==1){
      if(yakusu(i)==8){
	//	printf("%d\n", i);
	sum++;
      }
    }
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
from queue import PriorityQueue
import sys

sys.setrecursionlimit(10**9)

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

ans=0
MOD = 1000000007

def dfs(u,fa,k):
    temp=k
    if(fa==0): temp-=1
    else: temp-=2
    global ans
    global MOD
    vis[u]=1
    i=0
    for  v in a[u]:
        if(vis[v]==1):continue
        ans=(ans%MOD*(temp-i)%MOD)%MOD
        dfs(v,u,k)
        i+=1


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

n,k = IA()
ans=k
a=[ [] for i in range(0,n+1)]
vis=[int(0) for i in range(0,n+1)]

for i in range(0,n-1):
     u,v=IA()
     a[u].append(v)
     a[v].append(u)

dfs(1,0,k)
print(ans)






Measured memory_bytes: 89004
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s;
    cin>>s;
    int n = s.length();
    string ans(n,'x');
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	ll A, B, M, tmp, x, y, c, ans, min_tmp;

	std::cin >> A >> B >> M;

	vll a(A+1), b(B+1);
	vector<pair<ll, pair<ll, ll>>> m(M);

	min_tmp = 9999999;
	repeq(i, 1, A) {
		std::cin >> tmp;
		a[i] = tmp;
		min_tmp = min(min_tmp, tmp);
	}
	ans = min_tmp;

	min_tmp = 9999999;
	repeq(i, 1, B) {
		std::cin >> tmp;
		b[i] = tmp;
		min_tmp = min(min_tmp, tmp);
	}
	ans += min_tmp;

	rep(i, 0, M) {
		std::cin >> x >> y >> c;
		ans = min(ans, a[x] + b[y] - c);
	}

	std::cout << ans << endl;
	
	return 0;

}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();

		char[] cs = s.toCharArray();
		char[] ct = t.toCharArray();

		sort(cs , true);

//		System.out.println(new String(cs));

		sort(ct , false);

//		System.out.println(new String(ct));
		
		s = new String(cs);
		t = new String(ct);
		
		if( s.compareToIgnoreCase(t) < 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

	public static void sort(char[] a , boolean asc){
		int n = a.length;
		for(int i = 1 ; i < n ; ++i){
			char v = a[i];
			int j = i -1;
			if(asc){
				while(j >= 0 && Character.compare(v , a[j]) <= 0){
					a[j+1] = a[j];
					--j;
				}
			}else{
				while(j >= 0 && Character.compare(v , a[j]) >= 0){
					a[j+1] = a[j];
					--j;
				}
			}

			a[j+1] = v;
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const ll INF=1e18 + 5;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;cin>>n>>k;
    int dp[k+1]={0};
    int a[n];
    rep(i,n){
        cin>>a[i];
        dp[a[i]]=1;
    }
    dp[0]=0;
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(a[j]<=i){
                if(dp[i-a[j]]==0)
                    dp[i]=1;
            }
        }
    }

    if(dp[k]==1){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>

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

    int cnt = 0;

    int min = 2e5 + 1;
    for (int i = 0; i < N; ++i) {
        int p;
        std::cin >> p;
        if (p < min) {
            cnt++;
            min = p;
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
import sys
s = list(input())
t = list(input())
for i in range(len(s) - len(t) + 1):
    cut_char = s[len(s)-len(t)-i:len(s)-i]
    for j in range(len(t)):
        if cut_char[j] == t[j] or cut_char[j] == '?':
            if j == len(t)-1:
                for k in range(len(t)):
                    s[len(s)-len(t)-i+k] = t[k]
                ans = [tmp.replace('?', 'a') for tmp in s]
                print(''.join(ans))
                sys.exit()
        else:
            break
print('UNRESTORABLE')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

struct st {
    int v, c, d;
};

int main() {
    constexpr int INF = 1e9 + 6;
    int n, m; cin >> n >> m;
    map<pair<int,int>,map<pair<int,int>, int>> G;
    map<pair<int, int>, int> ans;
    for (int i = 0; i < m; i++) {
        int p, q, c; cin >> p >> q >> c;
        p--; q--;
        G[{p, -1}][{p, c}] = 1;
        G[{q, -1}][{q, c}] = 1;
        G[{p, c}][{p, -1}] = 0;
        G[{q, c}][{q, -1}] = 0;
        G[{p, c}][{q, c}] = 0;
        G[{q, c}][{p, c}] = 0;
        ans[{p, -1}] = ans[{q, -1}] = ans[{p, c}] = ans[{q, c}] = INF;
    }
    deque<st> deq;
    deq.push_back({0,-1,0});
    ans[{0, -1}] = 0;
    while (!deq.empty()) {
        auto p = deq.front(); deq.pop_front();
        for (auto &q : G[{p.v,p.c}]) {
            if (ans[q.first] <= q.second + p.d) continue;
            if (q.second == 0) {
                deq.push_front({q.first.first,q.first.second,p.d});
            }
            else {
                deq.push_back({q.first.first,q.first.second,p.d + q.second});
            }
            ans[q.first] = q.second + p.d;
        }
    }
    if (ans.find({n-1,-1}) == ans.end() || ans[{n - 1, -1}] == INF) {
        puts("-1");
    }
    else {
        cout << ans[{n - 1, -1}] << endl;
    }
    return 0;
}

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

using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int a, b, c, N;
    while(cin >> a >> b >> c, a) {
        cin >> N;
        vector<vector<int>> check(N, vector<int>(4));
        vector<int> res(a + b + c, 2);
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < 4; ++j) {
                cin >> check[i][j];
                if(j != 3) {
                    check[i][j]--;
                }
            }
        }
        bool update = true;
        while(update) {
            update = false;
            vector<vector<int>> nc;
            for(int i = 0; i < check.size(); ++i) {
                if(check[i].back() == 1) {
                    update = true;
                    for(int j = 0; j < 3; ++j) {
                        res[check[i][j]] = 1;
                    }
                } else {
                    vector<int> undef, ng;
                    for(int j = 0; j < 3; ++j) {
                        if(res[check[i][j]] == 0) {
                            ng.push_back(check[i][j]);
                        } else if(res[check[i][j]] == 2) {
                            undef.push_back(check[i][j]);
                        }
                    }
                    if(undef.size() == 1 && ng.size() == 0) {
                        res[undef[0]] = 0;
                        update = true;
                    } else {
                        nc.push_back(check[i]);
                    }
                }
            }
            check = move(nc);
        }
        for(auto x : res) {
            cout << x << endl;
        }
    }
}


Measured memory_bytes: 3236
import math


n = int(input())
o = n / 1.080

o_floor = math.floor(o)
o_ceil = math.ceil(o)

if math.floor(o_floor * 1.08) == n:
    print(o_floor)

elif math.floor(o_ceil * 1.08) == n:
    print(o_ceil)

else:
    print(':(')

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

bool check_2( const map<int64_t, int>& m, int n ) {
	for( auto&& kv: m ) {
		if( kv.first == 0 && kv.second != n/3 ) {
			return false;
		}
		else if( kv.first != 0 && kv.second != n/3*2 ) {
			return false;
		}
	}

	return true;
}

bool check_3( const map<int64_t, int>& m, int n ) {
	vector<int64_t> v;

	for( auto&& kv: m ) {
		if( kv.second != n/3 ) {
			return false;
		}

		v.push_back( kv.first );
	}

	int64_t x = v[0] ^ v[1] ^ v[2];
	return x == 0 && v[0] != v[1] && v[1] != v[2] && v[2] != v[0];
}

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

	map<int64_t, int> m;
	for( int i = 0; i < N; ++i ) {
		int64_t k;
		cin >> k;

		m[k] += 1;
	}

	bool result = false;

	if( m.size() == 1 && m[0] == N ) {
		result = true;
	}
	else if( N % 3 == 0 ) {
		if( m.size() == 2 ) {
			result = check_2( m, N );
		}
		else if( m.size() == 3 ) {
			result = check_3( m, N );
		}
	}

	cout << (result ? "Yes" : "No") << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x;
    cin >> x;
    if (400 <= x && x <= 599) {
        cout << 8 << endl;
    } else if (600 <= x && x <= 799) {
        cout << 7 << endl;
    } else if (800 <= x && x <= 999) {
        cout << 6 << endl;
    } else if (1000 <= x && x <= 1199) {
        cout << 5 << endl;
    } else if (1200 <= x && x <= 1399) {
        cout << 4 << endl;
    } else if (1400 <= x && x <= 1599) {
        cout << 3 << endl;
    } else if (1600 <= x && x <= 1799) {
        cout << 2 << endl;
    } else if (1800 <= x && x <= 1999) {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll i = 1; i <= k; ++i) {
        r *= n--;
        r /= i;
    }
    return r;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    pf(lcm(a, b));
    return 0;
}


Measured memory_bytes: 256
import itertools

N=int(input())
D=list(map(int, input().split()))

takocombi=list(itertools.combinations([i for i in range(N)],2))

ans=0
for h in range(len(takocombi)):
	ans+=D[takocombi[h][0]]*D[takocombi[h][1]]

print(ans)

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

using namespace std;

int const NMAX = 100;
char v[1 + NMAX][1 + NMAX];

int main() {

  int n = 0, m = 1000000000, k, inp;
  char p;
  cin >> p;
  if(p == 'A'){
    cout << 'T';
  }else if(p == 'T'){
    cout << 'A';
  }
  if(p == 'C'){
    cout << 'G';
  }else if(p == 'G'){
    cout << 'C';
  }
  return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

char inp[201][201];
int dis[201][201];

int main(){

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

    int n;
    cin>>n;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin>>inp[i][j];
        }
    }

    queue<int> qq;
    qq.push(0);

    vector<int> dist(n, -1);
    dist[0] = 0;
    int fl = 0;

    while(!qq.empty()) {
        int ele = qq.front();
        qq.pop();

        for(int i = 0; i < n; i++) {
            if(inp[ele][i] == '1') {
                if(dist[i] == -1) {
                    dist[i] = dist[ele] + 1;
                    qq.push(i);
                } else {
                    if(abs(dist[i] - dist[ele]) != 1) {
                        fl = 1;
                        break;
                    }
                }
            }
        }

        if(fl) break;
    }

    if(fl) {
        cout<<-1<<endl;
        return 0;
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) continue;
            if(inp[i][j] == '1') dis[i][j] = 1;
            else dis[i][j] = 1000000;
        }
    }

    int ans = 0;

    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(dis[i][k] + dis[k][j] < dis[i][j]) {
                    dis[i][j] = dis[i][k] + dis[k][j];
                }
            }
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans = max(ans, dis[i][j]);
        }
    }

    cout<<ans+1<<endl;




}


Measured memory_bytes: 512
#086
#a と b の積が偶数か奇数か判定してください。

#　1 <= a,b <= 10000
#a,bは整数

#1,入力を受け取ること
a, b = map(int, input().split())
#print(a, b)

#受け取った入力値を使って計算する
answer= a * b

#積が奇数なら 'Odd' と、偶数なら　'Even' と出力せよ
if answer % 2 == 0:
    print('Even')
else:
    print('Odd')

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int MaxN = 2e5 + 10;
int n, m;
int u, v;
vector<int> E[MaxN];
int vis[MaxN];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i = 0; i < E[1].size(); i++){
		vis[E[1][i]] = 1;
	}
	for(int i = 0; i < E[n].size(); i++) {
		if(vis[E[n][i]]){
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 12784
n, t = list(map(int, input().split()))
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
minCost = 1001
for i in range(n):
    if data[i][1] <= t and minCost > data[i][0]:
        minCost = data[i][0]

if minCost == 1001:
    print("TLE")
else:
    print(minCost)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    a.sort()
    def f(a):
        q = deque(a)
        p = q.popleft()
        ans = deque([p])
        for i in range(n-1):
            if i % 4 in [2, 3]:
                p = q.popleft()
            else:
                p = q.pop()
            if i & 1:
                ans.appendleft(p)
            else:
                ans.append(p)
        num = 0
        for i in range(n - 1):
            num += abs(ans[i + 1] - ans[i])
        return num
    print(max(f(a), f(a[::-1])))
    return


#main
if __name__ == '__main__':
    solve()


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

using namespace std;
long long x, a=100;
int main()
{
    cin>> x;
    for(int i=1; ;i++){
        a *= 1.01;
        if(a >= x){
            cout<< i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=(ll)1e9+7;

void multiply(ll first[][50],ll second [][50],ll n){
  ll i,j,k,tmp[n][50];
  memset(tmp,0,sizeof(tmp));
   for(i=0;i<n;i++)
    for(j=0;j<n;j++)
     for(k=0;k<n;k++)
     (tmp[i][j]+=first[i][k]*second[k][j])%=mod;
  
   for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      first[i][j]= tmp[i][j]%mod;
}

void power(ll arr[][50],ll m,ll n){
   ll tmp[n][50];
   memset(tmp,0,sizeof(tmp));
   for(ll i=0;i<n;i++)tmp[i][i]=1;
   while(m){
     if(m&1)multiply(tmp,arr,n);
     m>>=1;
     multiply(arr,arr,n);
   }
  ll ans=0;
  for(ll i=0;i<n;i++)
   for(ll j=0;j<n;j++)
     (ans+=tmp[i][j])%=mod;
    
  cout<<ans;
}

int main(){
  ll i,n,j,m;
  cin>>n>>m;
  ll arr[n][50];
  for(i=0;i<n;i++)
   for(j=0;j<n;j++)
    cin>>arr[i][j];
  power(arr,m,n);
}

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

int main(){

    int N;
    cin >> N;
    vector<long long> A(N);
    rep (i, N) cin >> A[i];

    long long ans = 0;
    for (int i = 1; i < N; i++){
        if (A[i-1] > A[i]){
            long long diff = A[i-1] - A[i];
            ans += diff;
            A[i] += diff;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4844
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A, DP[int(1e5 + 5)];

int main(){
  scanf("%d", &N);
  fill(DP, DP + N + 1, -1);
  for (int i = 0; i < N; i++){
    scanf("%d", &A);
    if (DP[0] < A){
      DP[0] = A; continue;
    }
    int L = 0, R = N;
    while (R - L > 1){
      int Mid = (L + R) / 2;
      if (A <= DP[Mid]) L = Mid;
      else R = Mid;
    }
    DP[R] = A;
  }

  for (int i = 0; i <= N; i++){
    if (DP[i] == -1){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 640
N, *XL = map(int, open(0).read().split())
XL = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))
curr = -float("inf")
ans = 0
for right, left in XL:
    if left >= curr:
        curr = right
        ans += 1
print(ans)



Measured memory_bytes: 25876
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
	
	int N,D;
	cin >> N >> D;
	
	int X[11][11];
	
	rep(i,0,N){
		rep(j,0,D){
			cin >> X[i][j];
		}
	}
	
	ll ans =0;
	rep(i,0,N){
		rep(j,i+1,N){
			ll tmp = 0;
			rep(k,0,D){
				ll t = abs(X[i][k]-X[j][k]);
				tmp += t * t;
			}
			double tmp_ans = sqrt(double(tmp));
			if(tmp_ans - int(tmp_ans) == 0) ans++; 
		}
	}
	
	print(ans);
	
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define MII map<int,int>
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
{
    FIO
    string day; cin>>day;
    if(day == "SUN") cout<<7;
    if(day == "MON") cout<<6;
    if(day == "TUE") cout<<5;
    if(day == "WED") cout<<4;
    if(day == "THU") cout<<3;
    if(day == "FRI") cout<<2;
    if(day == "SAT") cout<<1;


    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;cin>>n;
	if((n/1000)==0){cout<<1000-n<<endl;return 0;}
	ll near;
	if((n%1000)==0)near=(n/1000);
	else near=(n/1000)+1;
	cout<<(1000*near)-n<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 1000 + 10;
const ll INF = 1e17;
int a[MAXN];
ll dp[MAXN][MAXN];

ll f(int l, int r) {
  assert(l % 2 == r % 2);
  if (dp[l][r] != -INF)
    return dp[l][r];
  ll &res = dp[l][r];
  if (l == r)
    return res = a[l];
  if (a[r] > 0)
    return res = f(l, r - 2) + a[r];
  else
    return res = f(l, r - 2);
}

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%d", &a[i]);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      dp[i][j] = -INF;
  ll bst = -INF;
  PII bst_f;
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j += 2) {
      ll tmp = f(i, j);
      if (tmp > bst) {
        bst = tmp;
        bst_f = MP(i, j);
      }
    }
  //assert(a[bst_f.S] > 0);
  VI op;
  for (int i = N; i > bst_f.S; i--)
    op.PB(i);
  for (int i = bst_f.S - 2; i > bst_f.F; i -= 2) {
    if (a[i] > 0)
      op.PB(i + 1);
    else
      op.PB(i);
  }
  if (bst_f.S != bst_f.F)
    op.PB(bst_f.F + 1);
  for (int i = 1; i < bst_f.F; i++)
    op.PB(1);
  printf("%lld\n", bst);
  printf("%d\n", SZ(op));
  for (int u : op)
    printf("%d\n", u);
  return 0;
}


Measured memory_bytes: 8192
while True:
    n, l, r = map(int, input().split())
    if n == 0:
        break
    A = [int(input()) for _ in range(n)]

    ans = 0
    for x in range(l, r + 1):
        checked = False
        for i, a in enumerate(A):
            if x % a == 0:
                ans += (i % 2 == 0)
                checked = True
                break
        if not checked and n % 2 == 0:
            ans += 1
    print(ans)


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

int main() {
  long long N,ans=0;
  cin>>N;
  for(int a=1;a<=N;a++){
    for(int b=1;b<=N;b++){
      for(int c=1;c<=N;c++){
        ans+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<ans;
  
  
}

Measured memory_bytes: 3636
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define int long long
#define ld long double
#define ll long long

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k, c, cnt = 0, i = 0;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vector<int> ans, f(n), s1(n);
	for (i = 0; i < n; i++) {
		if (s[i] == 'o' && cnt < k) {
			f[cnt] = i;
			cnt++;
			i += c;
		}
	}
	cnt--;
	for (i = n - 1; i > -1; i--) {
		if (s[i] == 'o' && cnt >= 0) {
			s1[cnt] = i;
			i -= c;
			cnt--;
		}
	}
	for (int i = 0; i < k; i++) {
		if (s1[i] == f[i]) {
			ans.pb(s1[i] + 1);
		}
	}
	for (auto to : ans) {
		cout << to << endl;
	}
	return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1)
    {
        cin >> b[i];
    }
    vector<int> a(n);
    a[0] = b[0];
    for (int i = 1; i < n - 1; i++)
    {
        a[i] = min(b[i - 1], b[i]);
    }
    a[n - 1] = b[n - 2];
    ll sum = 0;
    rep(i, n)
    {

        sum += a[i];
    }
    c(sum);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MOD = 1e9+7;
ll dp[222][222][222];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
        int N;
    cin >> N;
    string s;
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;
        if (c != '-') s += c;
    }
    N = s.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) for (int k = 0; k <= i; k++) {
            if (s[i] == 'D') {
                dp[i+1][j][k] += dp[i][j][k] * j % MOD;
                if (j > 0 && k > 0) dp[i+1][j-1][k-1] += dp[i][j][k] * j * k % MOD;
            } else {
                dp[i+1][j+1][k+1] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k] * k % MOD;
            }
        }
        for (int j = 0; j <= i+1; j++) for (int k = 0; k <= i+1; k++) {
            dp[i+1][j][k] %= MOD;
        }
    }
    cout << dp[N][0][0] << endl;
    return 0;
}

Measured memory_bytes: 37204
n = int(input())
a = [int(i) for i in input().split()]
a.sort()

out = ""

minus = [a[0]]
plus = [a[-1]]

for v in a[1:-1]:
    if v < 0:
        minus.append(v)
    else:
        plus.append(v)

# (plus[0] - (minus[0] - plus[n])) - minus[n]
base_minus = minus.pop(0)
base_plus = plus.pop(0)
for i in range(len(plus)):
    x = base_minus
    y = plus[i]
    out += "{} {}\n".format(x, y)
    base_minus = x - y

out += "{} {}\n".format(base_plus, base_minus)
base_plus -= base_minus

for i in range(len(minus)):
    x = base_plus
    y = minus[i]
    out += "{} {}\n".format(x, y)
    base_plus = x - y
print(base_plus)
print(out)

Measured memory_bytes: 15144
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int main()
{string s,t;
cin>>s>>t;
int ans =0;
for(int i=0;i<s.length();i++)
if(s[i]!=t[i])++ans;
cout<<ans;
return 0;
}

Measured memory_bytes: 3912
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/

int main()
{
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int m=i;
		int temp=0;
		while(m)
		{
			temp++;
			m/=10;	
		}
		if(temp%2==1)
		cnt++;
	}
	cout<<cnt;
	return 0;
}











Measured memory_bytes: 256
# dp[i]:  minimum possible total cost to reach Stone i.
# dp[1] = 0
# dp[2] = |h[2]-h[1]|
# dp[i+2] = min{ dp[i] + |h[i]-h[i+2]|,  dp[i+1] + |h[i+1]-h[i+2]| }
# dp[0] = INF, h[0] = INF

INF = 10**9

N = int(input())
h = [INF] + list(map(int, input().split()))

dp = [INF]*(N+1)
dp[1] = 0

for i in range(2, N+1):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),  dp[i-2] + abs(h[i]-h[i-2]))

print(dp[N])


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

int main(void) {
	int n, m, r;
	cin >> n >> m;
	vector<int> tree(n);
	vector<vector<int> > parent(n, vector<int>(0)), child(n, vector<int>(0));
	
	for (int i = 0; i < n - 1 + m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		parent[b].push_back(a);
		child[a].push_back(b);
	}
	
	for (int i = 0; i < n; i++) {
		if (parent[i].size() == 0) r = i;
	}
	
	queue<int> q;
	vector<int> v(n, 0);
  
	q.push(r);	
	tree[r] = -1;
	
	while (!q.empty()) {
		int now = q.front(); q.pop();
		
		for (int i = 0; i < child[now].size(); i++) {
			int next = child[now][i];
			
			v[next]++;
			
			if (v[next] != parent[next].size()) continue;
			
			tree[next] = now;
			q.push(next);
		}
	}
	
	for (int i = 0; i < n; i++) cout << tree[i] + 1 << endl;
}

Measured memory_bytes: 12544
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    ll A, B, N;
    cin >> A >> B >> N;
    ll X = min(N, B-1);
    cout << ((A*X)/B) << endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 50; i++) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if (m == -1 && f == -1 && r == -1) {
                break;
            } else if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65) {
                System.out.println("B");
            } else if (m + f >= 50) {
                System.out.println("C");
            } else if (m + f >= 30) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
        }
    }
}


Measured memory_bytes: 26404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,x;
  cin>>k>>x;
  if(k*500>=x)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 2e3+10;

const int mod = 1e9+7;

//R , L , D , U
string dr = "RLDU";
int dx[]{1 , -1 , 0 , 0};
int dy[]{0 , 0 , -1 , 1};

int sx , sy;
int tx , ty;
string ans = "";
bool vis[N][N];
bool act[N][N];
pair < int , int > from[N][N];
char is[N][N];


void bfs(int a , int b , int c , int d){
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++){
            from[i][j] = {0 , 0};
        }
    bool reach;
    memset(vis , 0 , sizeof vis);
    queue < pair < int , int > > q;
    q.push({a , b});
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        if(x == c && y == d){
            break;
        }
        vis[x][y] = 1;
        for(int d = 0; d < 4; d++){
            int X = dx[d] + x;
            int Y = dy[d] + y;
            if(X >= 0 && Y >= 0 && X < N && Y < N && !vis[X][Y] && !act[X][Y]){
                    from[X][Y].first = x;
                    from[X][Y].second = y;
                    is[X][Y] = dr[d];
                    vis[X][Y] = 1;
                    q.push({X , Y});
            }
        }
    }
    string cur;
    int X = c , Y = d;
    while(abs(X - a) + abs(Y - b) != 0){
        cur = is[X][Y] + cur;
        act[X][Y] = 1;
        pair < int , int > p = from[X][Y];
        X = p.first;
        Y = p.second;
    }
    act[a][b] = 0;
    act[c][d] = 0;
    ans += cur;
    //system("PAUSE");
}

int main() {
    scanf("%d%d%d%d" , &sx , &sy , &tx , &ty);
    sx += 1e3+5;
    sy += 1e3+5;
    tx += 1e3+5;
    ty += 1e3+5;
    bfs(sx , sy , tx , ty);
    bfs(tx , ty , sx , sy);
    bfs(sx , sy , tx , ty);
    bfs(tx , ty , sx , sy);
    printf("%s\n" , ans.c_str());
    return 0;
}


Measured memory_bytes: 47204
#include<iostream>
using namespace std;
int main() {
    int n, m, l;
    int a[100][100] = {}, b[100][100] = {};
    
    cin >> n >> m >> l;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            if (j != 0) cout << " ";
            long c = 0;
            for (int k = 0; k < m; k++) {
                c += a[i][k] * b[k][j];
            }
            cout << c;
        }
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(){
    long long n;
    cin>>n;
    vector<long long> hoge(5);
    for(int i=0;i<5;i++) cin>>hoge.at(i);
    sort(hoge.begin(),hoge.end());
    
    long long waittime;
    if(n%hoge.at(0)==0) waittime=n/hoge.at(0);
    else waittime=n/hoge.at(0)+1;
    
    cout<<4+waittime<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

// 方針
// 累積和を取る
// ex) 18171
// s[4] 1
// s[3] 71
// s[2] 171
// s[1] 8171
// s[0] 18171
// mod 2019 = 0の区間(i, j), i < j は, (s[i] - s[j]) mod 2019 = 0
// つまり, s[i] mod 2019 == s[j] mod 2019

ll calc(ll t) {
  return t * (t-1) / 2;
}

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

  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  vector<ll> val(2019, 0);
  val[0] += 1;
  ll fac = 1;
  ll cur = 0;
  for (auto itr : s) {
    ll num = itr - '0';
    cur = (cur + num * fac) % 2019;
    val[cur] += 1;
    fac = (fac * 10) % 2019;
  }

  ll ans = 0;
  for (int i = 0; i < 2019; ++i) {
    ans += calc(val[i]);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3728