akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	int a,b,c;
    cin>>a>>b>>c;
    cout<<a<<" "<<b<<" "<<3*c-a-b<<endl<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c<<endl<<a+b-c <<" "<<2*c-b<<" "<<2*c-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,w_max, v_sum=0, value=0;
	cin>>n>>w_max;
	ll w[n+1],v[n+1];
	
	for (ll i = 1; i <=n; ++i){
		cin>>w[i]>>v[i];
		v_sum+=v[i];
	}
	
	ll dp[n+1][v_sum+1];
	bool check[n+1][v_sum+1];

	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=v_sum;j++){
			//dp[i][j]=1e15;
			check[i][j]=false;
		}
	}

	

	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=v_sum;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}

			else if(v[i]<=j){
				if(check[i-1][j-v[i]] || (j==v[i])){
					dp[i][j] = w[i] + dp[i-1][j-v[i]];
					check[i][j]=true;
				}

				// if(check[i][j-1]){
				// 	if(!check[i][j] || dp[i][j]>dp[i][j-1]){
				// 		dp[i][j]=dp[i][j-1];
				// 		check[i][j]=true;
				// 	}
				// }

				if(check[i-1][j]){
					if(!check[i][j] || dp[i][j]>dp[i-1][j]){
						dp[i][j]=dp[i-1][j];
						check[i][j]=true;
					}
				}
			}

			else{
				//dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
				// if(check[i][j-1]){
				// 	dp[i][j]=dp[i][j-1];
				// 	check[i][j]=true;
				// }

				if(check[i-1][j]){
					if(!check[i][j] || dp[i][j]>dp[i-1][j]){
						dp[i][j]=dp[i-1][j];
						check[i][j]=true;
					}
				}

			}
		}
	}
	//int temp;

	for(ll i=1; i<=n;i++){
		for(ll j=1;j<=v_sum;j++){
			if(check[i][j] && dp[i][j]<=w_max)
				value = max(value, j);
				// if(j>value){
				// 	value = j;
				// 	temp=dp[i][j];
				// }
		}
	}

	cout<<value<<'\n';
	return 0;
}

Measured memory_bytes: 88704
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N,M; cin >>N >>M;
  vector<int> nodes(N, 0);
  rep(i, M){
    int a,b; cin >>a >>b; a--; b--;
    nodes[a]++; nodes[b]++;
  }
  bool ok = true;
  rep(i, N) if (nodes[i]%2==1) ok = false;
  cout <<(ok ? "YES" : "NO") <<endl;
}


Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int -> Int
solve !n !m !an = sum $ map snd $ M.toList $ M.map
  (\i -> if i == 1 then 0 else comb2 i)
  modBnMaps
 where
  comb2 !n = n * (n - 1) `div` 2

  bn = VU.scanl' (+) 0 an

  modBnMaps =
    VU.foldl' (\(!mp) (!bi) -> M.insertWith (+) (bi `mod` m) 1 mp) M.empty bn

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, m) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n m an


Measured memory_bytes: 19964
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

#define MAX_V 2010

struct edge{int to; ll cap, cost; int rev; };

int V;
vector<edge> G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, ll cap, ll cost){
	G[from].push_back((edge){to, cap, cost, G[to].size()});
	G[to].push_back((edge){from, 0LL, -cost, G[from].size()-1});
}

ll min_cost_flow(int s, int t, ll f){
	ll res = 0;
	fill(h, h+V, 0);
	while(f > 0){	
		priority_queue<pl, vector<pl>, greater<pl> > que;
		fill(dist, dist+V, linf);
		dist[s] = 0;
		que.push(pl(0,s));
		while(!que.empty()){
			pl p = que.top(); que.pop();
			int v = p.second;
			if(dist[v] < p.first) continue;
			for(int i = 0; i < G[v].size(); i++){
				edge &e = G[v][i];
				if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push(pl(dist[e.to],e.to));
				}
			}
		}
		if(dist[t] == linf){
			return -1;
		}
		for(int v = 0; v < V; v++) h[v] += dist[v];
		
		ll d = f;
		for(int v = t; v != s; v = prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d*h[t];
		for(int v = t; v != s; v = prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

int n;

int main() {
    ll total = 0;
    cin >> n;
    V = 2*n+6;
    rep(i,n) {
        int x, y, c;
        cin >> x >> y >> c;
        add_edge(2*n, i, c, 0);
        add_edge(i, 2*n+2, inf, 100*(ll)inf - x - y);
        add_edge(i, 2*n+3, inf, 100*(ll)inf - x + y);
        add_edge(i, 2*n+4, inf, 100*(ll)inf + x - y);
        add_edge(i, 2*n+5, inf, 100*(ll)inf + x + y);
        total += c;
    }
    rep(i,n) {
        int x, y, c;
        cin >> x >> y >> c;
        add_edge(n+i, 2*n+1, c, 0);
        add_edge(2*n+2, n+i, inf, 100*(ll)inf + x + y);
        add_edge(2*n+3, n+i, inf, 100*(ll)inf + x - y);
        add_edge(2*n+4, n+i, inf, 100*(ll)inf - x + y);
        add_edge(2*n+5, n+i, inf, 100*(ll)inf - x - y);
    }
    cout << -1 * (min_cost_flow(2*n, 2*n+1, total) - 200*total*inf) << endl;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  int ans=0;
  for(int i=0;i<=K;++i){
    for(int j=0;j<=K;++j){
      if(i+j<=S && S-i-j<=K) ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
string alice, bob, charlie;
void alic();
void bo();
void cha();
int main() {

    cin >> alice >> bob >> charlie;
    alic();
    return 0;
}
void alic() {
    if(alice.empty()) cout << "A" << endl;
    else if (alice[0] == 'a') {
        alice.erase(0, 1);
        alic();
    } else if (alice[0] == 'b') {
        alice.erase(0, 1);
        bo();
    } else if (alice[0] == 'c') {
        alice.erase(0, 1);
        cha();
    }
}
void bo() {
    if(bob.empty()) cout << "B" << endl;
    else if (bob[0] == 'a') {
        bob.erase(0, 1);
        alic();
    } else if (bob[0] == 'b') {
        bob.erase(0, 1);
        bo();
    } else if (bob[0] == 'c') {
        bob.erase(0, 1);
        cha();
    }
}
void cha() {
    if(charlie.empty()) cout << "C" << endl;
    else if (charlie[0] == 'a') {
        charlie.erase(0, 1);
        alic();
    } else if (charlie[0] == 'b') {
        charlie.erase(0, 1);
        bo();
    } else if (charlie[0] == 'c') {
        charlie.erase(0, 1);
        cha();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 2000000

int main() 
{ 


    string s;
    cin>>s;

    string last = "";
    lli ans=0;

    string curr;
    loopl(i,0,s.size())
    {
        curr.pb(s[i]);

        if(curr != last)
        {
            ans++;
            last = curr;
            curr.clear();
        }
    }

    if(curr!="" && curr!=last) ans++;

    cout<<ans;

} 

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double N = sc.nextInt();
		double K = sc.nextInt();
		double devide = N/2;
//		System.out.println(devide);
		if(devide%2==0) {
			if (devide >= K) {
				System.out.println("YES");
			}else {
//				System.out.println("1");
				System.out.println("NO");
			}
		}else {
			if(devide+0.5 >= K) {
				System.out.println("YES");
			}else {
//				System.out.println("2");
				System.out.println("NO");
			}
		}


	}
}


Measured memory_bytes: 21716
import bisect
s = input()
t = input()
d = { c: [] for c in t }
for i, c in enumerate(s):
  if c in d:
    d[c].append(i)

n = -1
ans = 0


for j, c in enumerate(t):
  l = d[c]
  if l:
    i = bisect.bisect_right(l, n)
    if i == len(l):
      ans += len(s)
      n = l[0]
    else:
      n = l[i]
    if j == len(t) - 1:
      if i == len(l):
        ans += l[0] + 1
      else:
        ans += l[i]+1
  else:
    ans = -1
    break

print(ans)


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

int main() {
  int n;
  cin >>n;
  
  int n_1000, n_100, n_10, n_1, d_100, d_10;
  n_1000 = n/1000;
  d_100 = n%1000;
  n_100 = d_100/100;
  d_10 = d_100%100;
  n_10 = d_10/10;
  n_1 = d_10%10;
  

  if ((n_1000==n_100 && n_100==n_10) || (n_100==n_10 && n_10==n_1)) {
    cout << "Yes ";
  }
  
  else {
    cout << "No";
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;
ul euclidean_gcd(ul a, ul b) {
  if(a < b) return euclidean_gcd(b, a);
  ul r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;cin >> n;
	ul a[n];
	rep(i, n){
		cin >> a[i];
	}
	ul f[n], b[n];
	int tem = a[0];

	rep(i, n){
		tem = euclidean_gcd(tem, a[i]);
		f[i] = tem;
	}
	tem = a[n-1];
	for(int i = n-1;i >= 0; i--){
		tem = euclidean_gcd(tem, a[i]);
		b[i] = tem;
	}
	ul maxg = max(f[n-2],b[1]);
	for(int i = 1;i <= n-2;i++){
		chmax(maxg, euclidean_gcd(f[i-1],b[i+1]));
	}/*
	rep(i, n){
		cout << f[i] << endl;
	}
	rep(i, n){
		cout << b[i] << endl;
	}*/
	cout << maxg << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int X, t;
  cin >> X >> t;

  cout << std::max(0, X - t) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a);
    if(a[0]==a[1] && a[1]==a[2] && a[2]==a[0]) cout<<"No\n";
    else if(a[0]==a[1] || a[1]==a[2])cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;
vector <int> v1,v2;
int f1[100005],f2[100005];
int mx11,mx12,mx21,mx22,m11,m12,m21,m22;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i=0;i<n;i++) {
        int t;
        cin >> t;
        if (i%2==0) {
            v1.push_back(t),f1[t]++;
            if (f1[t]>mx11) mx11=f1[t],m11=t;
            else if (f1[t]>mx12) mx12=f1[t],m12=t;
        }
        else {
            v2.push_back(t),f2[t]++;
            if (f2[t]>mx21) mx21=f2[t],m21=t;
            else if (f2[t]>mx22) mx22=f2[t],m22=t;
        }
    }
    if (m11==m21) {
        int tmp = 0,tmp2 = 0;
        for (int i=0;i<v1.size();i++) {
            if (v1[i]!=m12) tmp++;
            if (v1[i]!=m11) tmp2++;
        }
        for (int i=0;i<v2.size();i++) {
            if (v2[i]!=m21) tmp++;
            if (v2[i]!=m22) tmp2++;
        }
        return cout << min(tmp,tmp2) << endl,0;
    }
    int ans = 0;
    for (int i=0;i<v1.size();i++) {
        if (v1[i]!=m11) ans++;
        if (v2[i]!=m21) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main () {
    int x1, x2, x3=0, x4=0, y1, y2, y3=0, y4=0;
    cin >> x1 >> y1 >> x2 >> y2;
    x3=x2-(y2-y1);
    y3=y2+(x2-x1);
    x4=x3-(x2-x1);
    y4=y3-(y2-y1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

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

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}


ll dot(pll v1, pll v2){
    return v1.first * v2.first + v1.second * v2.second;
}

int main() {
    int n;
    cin >> n;
    vector<pll> dat(n);
    REP(i, n){
        cin >> dat[i].first >> dat[i].second;
    }
    
    ll maxx = 0;
    // ベクトルiに沿って境界線を決める
    REP(i, n){
        pll vec = dat[i];
        if(vec.first == 0 && vec.second == 0)
            continue;
        pll vec1 = make_pair(vec.second, -vec.first);
        pll vec2 = make_pair(-vec.second, vec.first);
        ll num1 = 0, num2 = 0;
        pll p1 = {0, 0}, p2 = {0, 0};
        REP(j, n){
            ll dot1 = dot(vec1, dat[j]);
            ll dot2 = dot(vec2, dat[j]);
            if(dot1 > 0 || (dot1 == 0 && dot(dat[i], dat[j]) < 0)){
                p1.first += dat[j].first;
                p1.second += dat[j].second;
            }
            if(dot2 > 0 || (dot2 == 0 && dot(dat[i], dat[j]) > 0)){
                p2.first += dat[j].first;
                p2.second += dat[j].second;
            }
        }
        num1 = dot(p1, p1);
        num2 = dot(p2, p2);
        maxx = max({maxx, num1, num2});
    }

    printf("%.14f\n", sqrt(maxx));

    return 0;
}

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

int main(){
    int N;
    cin >>N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        vec.at(i)=1+i;
    }
    int A,B;
    cin >>A>>B;
    int count =0;
    for(int j=0;j<N;j++){
        int a=0;
        if(vec.at(j)<=9){
           if(A<=vec.at(j)&&vec.at(j)<=B){
               count += vec.at(j);
           }
        }
        else if(10<=vec.at(j)&&vec.at(j)<=99){
            for(int i=1;i<=10;i*=10){
                a+=vec.at(j)/i%10;
            }
            if(A<=a&&a<=B){
                count += vec.at(j);
            }
        }
        else if(100<=vec.at(j)&&vec.at(j)<=999){
            for(int i=1;i<=100;i*=10){
                a+=vec.at(j)/i%10;
            }
            if(A<=a&&a<=B){
                count += vec.at(j);
            }
        }
        else if (1000<=vec.at(j)&&vec.at(j)<=9999){
            for(int i=1;i<=1000;i*=10){
                a+=vec.at(j)/i%10;
            }
            if(A<=a&&a<=B){
                count += vec.at(j);
            }
        }
        else if(vec.at(j)==10000){
                count += vec.at(j);
        }
    }
    cout << count <<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;

int main(void){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n+1);
    FOR(i,1,n) cin >> h.at(i);
    sort(h.begin(),h.end());
    rep(i,k-1) h.pop_back();
    if( n-k > 0) {
        ll attack = 0;
        rep(i,n-k+1){
            attack += h.at(i);
        }
        cout << attack << endl;
    }
    else cout << 0 << endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using namespace std;
using lint = int64_t;
using P = pair<lint, lint>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(int i = (a); i < (b); ++i)
#define Rep(i, n) for (lint i = (n); i >= 0; --i)
#define All(vec) vec.begin(), vec.end()
#define cend printf("\n")

//constexpr lint mod = 998'244'353LL;
constexpr lint mod = 1000'000'007LL;
constexpr lint inf = 3LL * mod * mod;
constexpr double Pi = 3.141592653589793;

template<class T> using prique = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second << "\n"; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

constexpr bool pri(lint x) { for (lint i = 2; i * i <= x; ++i) if (x % i == 0) return false; return 1 < x; }

lint fact[3000000];
void fact_init(lint n, lint m = mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1] % m;
	}
}

lint modpow(lint x, lint n, lint m = mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

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

int main() {
	int c[3], k;
	rep(i, 3) cin >> c[i];
	cin >> k;
	while (c[0] >= c[1]) {
		c[1] <<= 1;
		k--;
	}
	while (c[1] >= c[2]) {
		c[2] <<= 1;
		k--;
	}
	if (0 <= k) cout << "Yes\n";
	else cout << "No\n";
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int n; rd(n);
	ll ans = 0;

	for (int i = 1; i <= n; i++) {
		ans += 1ll * (n - i + 1) * (n - i + 2) / 2;
	}

	for (int i = 1; i < n; i++) {
		int u, v; rd(u, v);
		if (u > v) swap(u, v);
		ans -= 1ll * u * (n - v + 1);
	}

	printf("%lld\n", ans);
}

Measured memory_bytes: 3776
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, n) for(int i=0;i<(int)(n);i++)

int main(void){
	char s[200];
	int len;
	int i;
	int cnt;
	scanf("%s",s);
	len = strlen(s);
	for(i=0;i<len/2;i++){
		if(s[i] != s[len-1-i])	cnt++;

	}
	printf("%d\n",cnt);
    return 0; 
}


Measured memory_bytes: 128
#include <stdio.h>
#define MAX 53

char f[MAX][MAX];

int main() {
	int x, y, i, j, h, w;
	scanf("%d %d", &h, &w);
	for(y=1; y<=h; y++) scanf("%s", f[y]+1);
	for(y=1; y<=h; y++) for(int x=1; x<=w; x++) if(f[y][x]=='.')
	{
		f[y][x] = '0';
		for(i=-1; i<=1; i++) for(j=-1; j<=1; j++) if(f[y+i][x+j]=='#')
			f[y][x]++;
	}
	for(y=1; y<=h; y++) printf("%s\n", f[y]+1);
	
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] nums = str.Select(s => int.Parse(s)).ToArray();

        Array.Sort(nums);
        Console.WriteLine(nums[0] + nums[1]);
    }
}



Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

struct Key
{
    int price;
    int count;
    bitset<12> openable;
};

constexpr int64_t impossible = -1;

vector<vector<int64_t>> memo(1000, vector<int64_t>(4096));

int64_t f(const vector<Key>& keys, size_t nbox, size_t i, const bitset<12>& openable)
{
    //const string indent(i, ' ');
    //cout << indent << openable << endl;
    if(openable.count() == nbox)
    {
        //cout << indent << "completed\n";
        return 0; // no more keys needed
    }
    else if(i >= keys.size())
    {
        //cout << indent << "try key[" << i << "]" << endl;
        //cout << indent << "impossible\n";
        return impossible; // there is no key
    }
    if(memo[i][openable.to_ullong()])
    {
        return memo[i][openable.to_ullong()];
    }
    //cout << indent << "try key[" << i << "] (" << keys[i].price << ")" << endl;
    //cout << indent << "if take\n";
    int64_t x = f(keys, nbox, i + 1, openable | keys[i].openable); // take keys[i]
    //cout << indent << x << endl;
    //cout << indent << "if not take\n";
    
    int64_t y = f(keys, nbox, i + 1, openable); // not take keys[i]
    if(x == impossible)
    {
        return memo[i][openable.to_ullong()] = y;
    }
    x += keys[i].price;
    if(y == impossible)
    {
        return memo[i][openable.to_ullong()] = x;
    }
    //cout << indent << y << endl;
    return memo[i][openable.to_ullong()] = min(x, y);
}

int main()
{
    const auto n = read<int>();
    const auto m = read<int>();
    vector<Key> keys(m);
    for(int i = 0; i < m; ++i)
    {
        cin >> keys[i].price;
        cin >> keys[i].count;
        for(int j = 0; j < keys[i].count; ++j)
        {
            const auto bit = read<int>();
            keys[i].openable[bit-1] = true;
        }
    }
    
    int64_t cost = f(keys, n, 0, bitset<12>{});
    cout << cost << '\n';
    
    return 0;
}


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

int N;
int x;
vector<int> a;
multiset<int> st;

int main()
{
    cin>>N;
    for(int i=1;i<=(1<<N);i++)
    {
        cin>>x;
        st.insert(x);
    }
    multiset<int>::iterator iter=st.end();
    iter--;
    a.push_back(*iter);
    st.erase(iter);
    while(a.size()<(1<<N))
    {
        int t=a.size();
        for(int i=0;i<t;i++)
        {
            iter=st.lower_bound(a[i]);
            if(iter==st.begin())
            {
                cout<<"No";
                return 0;
            }
            iter--;
            a.push_back(*iter);
            st.erase(iter);
        }
    }
    cout<<"Yes";
}
/*
3
8 7 7 6 7 6 6 5
*/


Measured memory_bytes: 13692
n =int(input())

S = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

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

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(S[i][j][k]), end = "")
        print("")
    if i == 3:
        break
    print("####################")

Measured memory_bytes: 7756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long w = in.nextLong();
        long h = in.nextLong();
        long x = in.nextLong();
        long y = in.nextLong();
        out.println(w * h / 2.0 + " " + (((2 * x == w) && (2 * y == h)) ? 1 : 0));
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 21460
#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

/*
        time complexty
auto start = chrono::steady_clock::now();
    ............

auto endd = chrono::steady_clock::now();
auto dif =   endd- start;
cout << chrono::duration<double, milli>(dif).count() <<"ms"<<endl;

*/

bool prime(LL num)
{
    if ( num < 4 ) return true;

    if (num%2==0 || num %3==0)return false;

    LL c=5;
    while( c*c <= num)
    {
        if (num%c==0 || num%(c+2)==0 )return false ;
        c+=6;
    }
    return true ;
}


int t, n ;

int main(){

scanf("%d",&n);
while(1)
{

  if ( prime(n) ) { cout <<n<<endl ; break ;}
  n++;
}

return 0;
}




Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,w;
    cin>>n>>w;
    long long wt[n+2];
    long long val[n+2];
    for(int i=1;i<=n;i++){
       cin>>wt[i]>>val[i];
    }
    long long dp[n+1][n*1002];
    for(int i=0;i<=n*1001;i++)
    dp[1][i]=INT_MAX;
   
    dp[1][0]=0;
    dp[1][val[1]]=wt[1];

    for(int i=2;i<=n;i++){
        for(int value=0;value<=n*1001;value++){
               dp[i][value]=dp[i-1][value];
               if(val[i]<=value){
                   dp[i][value]=min(dp[i][value],wt[i]+dp[i-1][value-val[i]]);
               }
        }
    }
      long long ans=0;
        for(int value=0;value<=n*1001;value++){
            if(dp[n][value]<=w){
                ans=value;
            }
        }    
    
    cout<<ans;

    
}


Measured memory_bytes: 78592
fun main(args: Array<String>) {
    val (animalCount, legCount) = readLine()?.split(" ")?.map(String::toInt)?: return
    var ans = "No"
    for (a in 0..animalCount) {
        val b = animalCount - a
        if (4 * a + 2 * b == legCount) {
            ans = "Yes"
            break
        }
    }
    println(ans)
}

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

struct city{
	int x;
	int y;
	int num;
	int ans;
};

bool comp_city_x(city &c1,city &c2){
	return c1.x<c2.x;
}

bool comp_city_n(city &c1,city &c2){
	return c1.num<c2.num;
}

int main(){
	int N;
	cin >> N;
	vector<city> C(N);
	for(int i=0;i<N;i++){
		int X,Y;
		cin >> X >> Y;
		C[i].x=X;
		C[i].y=Y;
		C[i].num=i;
	}
	
	sort(C.begin(),C.end(),comp_city_x);
	
	if(C[N-1].y==N){
		for(int i=0;i<N;i++)cout << N << endl;
		return 0;
	}
	
	dsu d(N);
	
	vector<bool> flag(N,false);
	vector<int> m(N,0);
	m[N-1]=C[N-1].y;
	for(int i=N-2;i>=0;i--)m[i]=max(m[i+1],C[i].y);
	for(int i=0;i<N;i++){
		if(flag[i])continue;
		for(int j=i+1;j<N;j++){
			if(C[i].y>m[j])break;
			if(C[i].y<C[j].y){
				d.merge(i,j);
				flag[j]=true;
			}
		}
	}
	
	for(int i=0;i<N;i++)C[i].ans=d.size(i);
	
	sort(C.begin(),C.end(),comp_city_n);
	
	for(int i=0;i<N;i++)cout << C[i].ans << endl;
	
	return 0;
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
ll dp[105][2][5];
int main(){
  ll x,y; cin >> x >> y;
  ll k = y-2*x, t=4*x-y;
  if(k>=0&&k%2==0&&t>=0&&t%2==0) cout << yes;
  else cout << no;
  return 0;
}

Measured memory_bytes: 3640
N,M = map(int,input().split())
ls = [-1]*N

for i in range(M):
    s,c = map(int,input().split())
    s = s-1
    if ls[s] == -1:
        ls[s] = c
    elif ls[s] != c:
        print(-1)
        exit()

if ls[0] == 0 and N > 1:
    print(-1)
    exit()
if ls[0] == -1 and N > 1:
    ls[0] = 1

ans = 0
for i in range(N):
    if ls[i] == -1:
        ls[i] = 0
    ans = ans*10 + ls[i]

print(ans)


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

int main(){
  int n; cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i=0; i<n; ++i)cin>>a[i];
  for(int i=0; i<n; ++i)cin>>b[i];
  for(int i=0; i<n; ++i)cin>>c[i];

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

  vector<int> bsum(n,0); vector<long long> csum(n,0);
  int now=0;
  for(int i=0; i<n; ++i){
    while(a[now]<b[i] && now<=n-1)++now;
    bsum[i]=now;
  }

  now=0; long long sum=0LL;
  for(int i=0; i<n; ++i){
    while(b[now]<c[i] && now<=n-1){
      sum+=bsum[now];
      ++now;
    }
    csum[i]=sum;
  }

  long long ans=0LL;
  for(int i=0; i<n; ++i)ans+=csum[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
//#define sz 2

using namespace std;

char s[ 400010 ];
int l[ 400010 ], r[ 400010 ];

int main() {
	int n, m, c;
	scanf( "%d%d%d", &n, &m, &c );
	scanf( "%s", s + 1 );
	for( int i = 1; i <= n; ++i ) {
		l[ i ] = l[ i - 1 ];
		if( s[ i ] == 'o' ) {
			if( i - c - 1 > 0 )
				l[ i ] = max( l[ i ], l[ i - c - 1 ] + 1 );
			else
				l[ i ] = max( l[ i ], 1 );
		}
	}
	for( int i = n; i; --i ) {
		r[ i ] = r[ i + 1 ];
		if( s[ i ] == 'o' )
			r[ i ] = max( r[ i ], r[ i + c + 1 ] + 1 );
	}
	if( l[ n ] < m )
		return 0;
	for( int i = 1; i <= n; ++i )
		if( l[ i - 1 ] + r[ i + 1 ] < m )
			printf( "%d\n", i );
	return 0;
}

Measured memory_bytes: 3328
q = int(input())

def lcs(X, Y):
    dp = [0]*(len(Y)+1)
    
    for x in X:
        tmp = dp[:]
        for j, y in enumerate(Y):
            if x == y:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]
                               
    return dp[-1]
    
for _ in range(q):
    X = input()
    Y = input()
    print(lcs(X, Y))

Measured memory_bytes: 7748
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
    int n;
    int x;
    long a[100100];
    long d[100100];
    int gd;
  
    cin >> n >> x; 
  
    for (int i = 0; i < n; ++i) cin >> a[i]; 
    
    for (int i = 0; i < n; ++i)
     {
        d[i] = abs(x - a[i]);
     }
  
 
     sort(d,d+n);
  
     if(n == 1){
       cout << d[0] << endl;
       return 0;
     }  
  
      gd = __gcd(d[0],d[1]);
  
      for (int i = 0; i < n; ++i)
     {
          int nex;
          nex = d[i];
          gd = __gcd(gd, nex);
     }
     
     cout << gd << endl;
  
}

Measured memory_bytes: 1792
//  Copyright 2019 Nikita Golikov
//  2 * a_i = (b_i + b_{i + 1})
//  1 + 2, 2 + 3, 3 + 1

#include <iostream>
#include <vector>

int main() {
  std::size_t n;
  std::cin >> n;
  std::vector<int> a(n);
  std::int64_t total = 0;
  for (auto& x : a) {
    std::cin >> x;
    total += x;
    x *= 2;
  }
  std::vector<std::int64_t> pref(n);
  std::vector<std::int64_t> suff(n);
  pref[0] = a[0];
  pref[1] = a[1];
  for (size_t i = 2; i != n; ++i) {
    pref[i] = pref[i - 2] + a[i];
  }
  suff[n - 1] = a[n - 1];
  suff[n - 2] = a[n - 2];
  for (size_t i = n - 2; i--; ) {
    suff[i] = suff[i + 2] + a[i];
  }
  auto get_pref = [&pref, &n](std::size_t i) {
    return i < 0 || i >= n ? 0 : pref[i];
  };
  auto get_suff = [&suff, &n](std::size_t i) {
    return i < 0 || i >= n ? 0 : suff[i];
  };
  for (std::size_t i = 0; i != n; ++i) {
    auto ans = total - get_suff(i + 1) - get_pref(i - 2);
    std::cout << ans << ' ';
  }
  std::cout << '\n';
  return 0;
}


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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m, 0));
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    //クリアできる?
    // vector<int> allAb(m, 0);
    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j < m; j++){
    //         allAb[j] += a[i][j];
    //     }
    // }
    // for(auto ab : allAb){
    //     if(ab < x){
    //         cout << -1 << endl;
    //         return 0;
    //     }
    // }

    //総当り
    int ans = accumulate(c.begin(), c.end(), 0);
    bool isEnd = false;
    for(int i = 0; i < (1 << n); i++){
        bitset<12> s(i);
        vector<int> abilities(m, 0);
        int tmp = 0;
        for(int j = 0; j < n; j++){
            if(s.test(j)){
                tmp += c[j];
                for(int k = 0; k < m; k++){
                    abilities[k] += a[j][k];
                }
            }
        }
        bool ok = true;
        for(auto ab : abilities){
            if(ab < x){
                ok = false;
            }
        }
        if(ok){
            ans = min(ans, tmp);
            isEnd = true;
        }
    }

    if(!isEnd){
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char[] c = str.toCharArray();
		boolean tag = false;
		if(c[0]==c[c.length-1]){
			if(c.length%2==0) System.out.println("First");
			else System.out.println("Second");
		}
		else{
			if(c.length%2==0) System.out.println("Second");
			else System.out.println("First");
		}
	}
}


Measured memory_bytes: 27196
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();

		// 計算
		int cnt = 0;
		for(int i = 1; i < n + 1; i++){
		    String s = Integer.toString(i);
		    if(s.length()%2 == 1){
		        cnt++;
		    }
		}

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


Measured memory_bytes: 28244
#include <stdio.h>

#define OVER_SIX_DIGITS 1000000

int sosuu_num[OVER_SIX_DIGITS];

void make_sosuu_num_list(void) {
	int i,j;
	for(i=0;i<OVER_SIX_DIGITS;i++)sosuu_num[i]=1;
	sosuu_num[0]=sosuu_num[1]=0;
	for(i=2;i<OVER_SIX_DIGITS;i++) {
		if(sosuu_num[i]) {
			for(j=i+i;j<OVER_SIX_DIGITS;j+=i)sosuu_num[j]=0;
		}
	}
	for(i=1;i<OVER_SIX_DIGITS;i++)sosuu_num[i]+=sosuu_num[i-1];
}

int main(void) {
	int n;
	make_sosuu_num_list();
	while(scanf("%d",&n)==1) {
		printf("%d\n",sosuu_num[n]);
	}
	return 0;
}

Measured memory_bytes: 0
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashSet;
use std::collections::HashMap;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let s = read_as_string().chars().collect::<Vec<char>>();
    let mut hash: HashMap<char, usize> = HashMap::new();

    let mut ans = 1;
    for c in &s{
        *hash.entry(*c).or_insert(0) += 1;
    }

    for (c, v) in hash{
        ans *= v+1;
        ans %= 1_000_000_007;
    }
    println!("{}", ans-1);


}


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 1;
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  int add = a-1;
  while(a < b){
    a += add;
    //cout << a << endl;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

// https://atcoder.jp/contests/agc004/tasks/agc004_a
// 入力 A, B, C: 直方体の要素の個数(縦, 横, 高さ)
// 出力 赤色と青色の直方体の個数の差の最小値

// 両方の色のブロックの塊が直方体でなければならないので、
// ある1辺の途中で区切った場合、残りの2辺は途中で区切ることはできない
// 数の差ができるだけ小さくなる、ということは、3辺のうちのどれかを半分で切って、
// 差が最も小さくなる場合を求めればよいはず。

import (
	"fmt"
)

func calc_box_num(nums []int) (boxes int) {
	boxes = 1
	for _, num := range nums {
		boxes *= num
	}
	return
}

func solve(a, b, c int) {

	min := 0
	min = calc_box_num([]int{a/2 + (a % 2), b, c}) - calc_box_num([]int{a / 2, b, c})
	tmin := calc_box_num([]int{a, b/2 + (b % 2), c}) - calc_box_num([]int{a, b / 2, c})
	if tmin < min {
		min = tmin
	}
	tmin = calc_box_num([]int{a, b, c/2 + (c % 2)}) - calc_box_num([]int{a, b, c / 2})
	if tmin < min {
		min = tmin
	}
	fmt.Printf("%v\n", min)
}

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d\n", &a, &b, &c)

	solve(a, b, c)
}


Measured memory_bytes: 512
#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>;

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n=0):n(n), d(n+1){}
  void add(int i, T x=1){
    for(i++; i<=n; i+=i&-i){
      d[i] += x;
    }
  }
  T sum(int i){
    T x = 0;
    for (i++; i; i-=i&-i){
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r){
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> pi(n+1, -1);
  vector<vector<int>> ps(n);
  rep(i, n){
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }
  vector<vector<P>> qs(n);
  rep(qi, q){
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r, qi);
  }
  vector<int> ans(q);
  BIT<int> d(n);
  for (int x=n-1; x>=0; --x){
    for (int y: ps[x]) d.add(y, 1);
    for (P query: qs[x]){
      int r = query.first, i = query.second;
      ans[i] = (r-x+1) - d.sum(r);
    }
  }
  rep(i, q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 59908
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char lx[N];

int main() {
	scanf("%s", lx + 1);
	int len = strlen(lx + 1);
	if(lx[1] == lx[len]) {
		if(len & 1) printf("Second\n");
		else printf("First\n");
	} else {
		if(len & 1) printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(void)
{
  string s; cin>>s;
  
  if(((s[0]!=s[1])&&(s[2]==s[3]))&&(s[4]==s[5])){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;cin>>n>>k;
    vector<int> x(n);
    rep(i,n){
        cin>>x[i];
    }
    int ans =0;
    rep(i, n){
        ans += min(abs(x[i]-k), x[i]) * 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int v[n],c[n];
  for(int i=0;i<n;i++)
  cin>>v[i];
    for(int i=0;i<n;i++)
  cin>>c[i];
    for(int i=0;i<n;i++)
     if(0<v[i]-c[i])
   ans+=v[i]-c[i];
  cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

#define N 50000

using namespace std;

int main(void){
  int p[N+1] = {0};
  int n, ans;
  
  for (int i=2; i<N; i++){
    if (p[i]==-1) continue;
    p[i]=1;
    for (int j=i*2; j<N; j+=i){
      p[j]=-1;
    }
  }
  while (scanf("%d",&n), n){
    ans = 0;
    for (int i=2; i<=n/2; i++){
      if (p[i]==1 && p[n-i]==1){
        ans++;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2860
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d, e, f = na()
m = f // (100 * a)
n = f // c
wli = []
sli = []
for i in range(m+1):
    for j in range(m+1):
        x = 100 * a * i + 100 * b * j
        if 0 < x <= f:
            wli.append(x)
for i in range(n):
    for j in range(n):
        y = c * i + d * j
        if y <= f:
            sli.append(y)
ans = [0, 0, 0]
for x in wli:
    for y in sli:
        if x + y <= f and 100 * y <= e * x:
            p = y * 100 / (x + y)
            if ans[2] <= p:
                ans = [x + y, y, p]
print(*ans[:2])




Measured memory_bytes: 52220
#include <bits/stdc++.h>
using namespace std;
int main() {
    string word;
    int n;
    cin >> n;
    cin >> word;
    int len = word.length();
    char str;
    for(int i = 0; i < len; i++) {
        for(int j = 0; j < n; j++) {
            if(word[i] == 'Z') {
                word[i] = 'A';
                continue;
            }
            word[i]++;
        }
    }

    cout << word << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

int main()
{
	LL N;
	std::string S;
	in >> N >> S;

	LL ans = 1;
	std::vector<LL>cnt(26);
	rep(i, N) ++cnt[S[i] - 'a'];
	rep(i, 26) (ans *= (cnt[i] + 1)) %= mod;
	--ans;
	(ans += mod) %= mod;

	out << ans << std::endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	uint ans = 0;
	uint k = 2 * pow(10, 5);
	
	for(uint i=0; i<N; i++) {
		uint P;
		cin >> P;
		
		if(P <= k) ans++;
		//cout << P << " " << k << " " << ans << endl;
		k = min(P, k);
	}
	
	 
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256