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

int main(){
  int N, M;
  int count = 0;
  cin >> N >> M;
  
  vector<int> height(N);
  vector<int> out(N);
  vector<vector<int>> path(M, vector<int>(2));
  
  for(int i=0; i<N; i++){
    cin >> height.at(i);
    out.at(i) = 1;
  }
  
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> path.at(i).at(j);
    }
  }
  
  for(int i=0; i<M; i++){
    if(height.at(path.at(i).at(0) -1) > height.at(path.at(i).at(1) -1)){
      out.at(path.at(i).at(1) -1) = 0;
    }
    else if(height.at(path.at(i).at(0) -1) < height.at(path.at(i).at(1) -1)){
      out.at(path.at(i).at(0) -1) = 0;
    }
    else if(height.at(path.at(i).at(0) -1) == height.at(path.at(i).at(1) -1)){
      out.at(path.at(i).at(0) -1) = 0;
      out.at(path.at(i).at(1) -1) = 0;
    }
  }
    
    //outの非ゼロの要素数を出力
  for(int i=0; i<N; i++){
    if(out.at(i) != 0){
      count++;
    }
  }
    
  cout << count << endl;
}


  


Measured memory_bytes: 9488
// using no_way as a way
// using no_limitation as a limitation

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());


int main(int argc, char const *argv[])
{
    // file();
    fast();
    
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;

}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
int main() {
	int n;
	ll dp[30];
	dp[0]=1; dp[1]=2; dp[2]=4;
	for (int i=3; i<30; i++) dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
	while (scanf("%d",&n)) {
		if (n==0) break;
		ll day,year;
		if (dp[n-1]%10!=0) day=dp[n-1]/10+1;
		else day=dp[n-1]/10;
		if (day%365!=0) year=day/365+1;
		else year=day/365;
		printf("%lld\n",year);
	}
}

Measured memory_bytes: 0
def resolve():
    (N, K) = list(map(int, input().split(" ")))
    hs = list(map(int, input().split(" ")))
    dps = [0] * N

    dps[0] = 0
    for i in range(1, N):
        m = float('inf')
        for k in range(i - K, i):
            if k < 0:
                continue
            m = min(m, dps[k]+abs(hs[i]-hs[k]))
        dps[i] = m

    print(dps[-1])

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 53840
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;
vector<long long> a;

int main() {
    while (cin >> n) {
        a.resize(n);
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        vector<long long> b = a;
        
        long long first = a.back();
        long long second = 0;
        long long maxsecond = 0;
        
        for (int i = 0; i < n-1; ++i) {
            if (a[i] > first - a[i]) b[i] = first - a[i];
            else b[i] = a[i];
            if (chmax(maxsecond, b[i])) {
                second = a[i];
            }
        }
        
        cout << first << " " << second << endl;
    }
}






























Measured memory_bytes: 1792
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

use std::{i32, i64, u32, u64, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        p: i64,
        arr: [i64; n],
    }
    if arr.iter().filter(|&a| a % 2 == 1).count() == 0 { println!("{}", (1 - p) << n); }
    else { println!("{}", 1u64 << (n - 1)); }
}


Measured memory_bytes: 4352
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int add(int a, int b)
{
	int c=a+b;
	if(c>=mod)c-=mod;
	return c;
}
int dif(int a, int b)
{
	int c=a-b;
	if(c<0)c+=mod;
	return c;
}
int mlt(int a, int b)
{
	long long c=a*1LL*b;
	return c%mod;
}
int bp(int a, int b)
{
	if(b==0)return 1;
	if(b%2==0)
	{
		int val=bp(a, b/2);
		return mlt(val, val);
	}
	if(b%2==1)
	{
		int val=bp(a, b-1);
		return mlt(val, a);
	}
}
int inv(int a)
{
	return bp(a, mod-2);
}
void outp(vector<vector<int>>&v)
{
	for(int i=0; i<v.size(); i++)
	{
		for(int j=0; j<v[i].size(); j++)cout<<v[i][j]<<' ';
		cout<<endl;
	}
	cout<<endl;
}
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b)
	{
		int c = a;
		a = b;
		b = c;
	}
	vector<vector<int>> dpa(n + 1, vector<int>(n + 1)),
			dpb(n + 1, vector<int>(n + 1));
	dpb[0][0]=1;
	for(int i=1; i<=n; i++)
	{
		for(int j=max(0, i-b+1); j<i; j++)
		{
			if(i>=j+a)
			{
				if (i >= a)
				{
					dpa[i][j] = add(dpa[i - 1][j], dpb[i - a][j]);
				}
				else dpa[i][j] = dpa[i - 1][j];
			}
			dpb[i][j] = add(dpa[i - 1][j], dpb[i - 1][j]);
		}
		dpa[i][i]=dpa[i-1][i-1];
		for(int j=i-1; j>=0; j--)dpa[i][i]=add(dpa[i][i], dpb[i-1][j]);
		if(i>=a)
		{
			for (int j = i - a; j >= 0; j--)
			{
				dpa[i][i] = dif(dpa[i][i], dpb[i - a][j]);
			}
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=n; j++)
		{
	//		cout<<i<<' '<<j<<' '<<dpa[i][j]<<' '<<dpb[i][j]<<endl;
		}
	}
	int ans=bp(2, n);
	for(int i=0; i<=n; i++)
	{
		ans=dif(ans, dpa[n][i]);
		ans=dif(ans, dpb[n][i]);
	}
	if(a>1)
	{
		cout << ans << endl;
	}
	else cout<<bp(2,n)<<endl;
}

Measured memory_bytes: 199152
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, W;
  cin >> N >> W;

  vector<i64> w(N + 1), v(N + 1);
  for(int i = 1;i <= N;i++) cin >> w[i] >> v[i];
  vector<vector<i64>> dp(N + 1, vector<i64>(1000 * 100 + 1, 1e10));
  dp[0][0] = 0;

  for(int i = 1;i <= N;i++) {
    for(int j = 0;j <= 1000 * 100;j++) {
      if(j - v[i] >= 0) {
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
      }
      else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  i64 ans = 0;
  for(int j = 0;j <= 1000 * 100;j++) {
    if(dp[N][j] <= W) ans = j;
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

ll n,m,a,b,c,x,y,aa[100010],ba[100010];
bool r,br,ar;
string s;
char ca,cb;


int main(){
    cin>>a>>b>>c;
    
    if(b>=c)cout<<"delicious"<<endl;
    else if(a>=c-b)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[2][5];
int main()
{
    int ans = 0;
    scanf(" %s %s",str[0],str[1]);
    for(int i=0;i<3;i++)    ans+=(str[0][i]==str[1][i]);
    printf("%d\n",ans);
    return 0;
}


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

const int MAX = 2000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    long long ans=0;
    ans+=COM(r1+c1,r1);
    ans%=MOD;
    for(int i=r2+c2;i>r1+c2;--i){
        ans+=COM(i,c2)%MOD;
        ans%=MOD;
    }
    for(int i=r2+c2;i>c1+r2;--i){
        ans+=COM(i,r2)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 50452
#include<stdio.h>
int main()
{
    int a,b,c=0,d=0,f,i,j,m,n,r;
    scanf("%d%d",&n,&m);
    int x[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
        c=c+x[i];
    }
    a=(4*m);
    b=c/a;
    if(c%a!=0){b++;}
    for(i=0;i<n;i++)
    {
        if(x[i]>=b) {d++;}
    }
    if(d>=m) {printf("Yes\n");}
    else {printf("No\n");}
return 0;
}


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

int a[100005];

int main()
{
    int n, x;
    long long ans = 0;
    scanf("%d%d", &n,&x);
    for (int i = 0; i < n; i++) 
    {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < (n-1); i++)
    {
        if (a[i] + a[i+1] > x)
        {
            ans += (a[i] + a[i+1]) - x; 
            if(a[i] < x)
            {
                a[i+1] = x - a[i];
//                cout << "a[" << i << "]=" << a[i] << endl;
//                cout << "a[" << i + 1 << "]=" << a[i+1] << endl;
//                cout << "ans[i]=" << ans << endl;
            }
            else
            {
                a[i+1] = 0;
                a[i] = x;
//                cout << "a[" << i << "]=" << a[i] << endl;
//                cout << "a[" << i + 1 << "]=" << a[i+1] << endl;
//                cout << "ans[i]=" << ans << endl;
             }
        }
    }

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

}

Measured memory_bytes: 640
#include<iostream>
#include<complex>
#include<cmath>
#include<map>
#define fs first
#define sc second
#define EPS 0
using namespace std;


typedef complex<double> P;
typedef pair<P,double> C;

int cpr(C a,C b){
  double d = abs(a.fs-b.fs);
  if(a.sc+b.sc + EPS < d)return -1;      //no intersection (outside)
  if(b.sc<a.sc && d + EPS < a.sc-b.sc)return 1;       //no intersection (inside,B in A)
  if(a.sc<b.sc && d + EPS < b.sc-a.sc)return 2;       //no intersection (inside,A in B)
  if(abs(a.sc+b.sc - d) < EPS)return -3; //one cross point (outside)
  if(abs(b.sc+d - a.sc) < EPS)return 3;  //one cross point (inside,B in A)
  if(abs(a.sc+d - b.sc) < EPS)return 4;  //one cross point (inside,A in B)
  return 0;                              //two cross point
}


int main(){
  double ax,ay,ar,bx,by,br;

  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin>> ax >> ay >> ar >> bx >> by >> br;
    C a = C(P(ax,ay),ar), b = C(P(bx,by),br);
    int v = cpr(a,b);
    if(v==-1)cout <<  0 << endl;
    else if(v==1)cout << 2 << endl;
    else if(v==2)cout << -2 << endl;
    else cout << 1 << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
  unsigned int x1, x2, x3;
  unsigned int y1, y2, y3;
  unsigned long s;

  x1 = 0;
  y1 = 0;
  x2 = 1000000000;
  y2 = 1;

  cin >> s;
  if( s < 1.e18 ) {
    x3 = x2 - ( s % x2 );
    y3 = s/x2 + 1;
  } else {
    y2 = 0;
    y3 = x2;
  }
  
  
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " \
<< y3 << endl;

  return 0;

}

Measured memory_bytes: 256
import sys

A,B,C,K = map(int, input().split())

total = 0

if A>=K:
    total = total + 1*K
    print(total)
else:
    total = total + 1*A
    if K-A==0:
        print(total)
        sys.exit()
    else:
        if (K-A)<=B:
            total = total + 0*(K-A)
            print(total)
            sys.exit()
        else:
            if (K-A-B)<=C:
                total = total + (K-A-B)*(-1)
                print(total)
                sys.exit()
            else:
                total = total + C*(-1)
                print(total)
                sys.exit()

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a - 1].push_back(b - 1);
  }

  vector<int> d(n), in(n), s, r;
  function<void(int)> dfs = [&](int i) {
    d[i] = s.size();
    s.push_back(i);
    for (auto j : v[i]) in[j]++;

    priority_queue<pair<int, int>> q;
    for (auto j : v[i]) {
      if (d[j] != -1) q.push(make_pair(d[j], j));
    }
    if (!q.empty()) {
      r = vector<int>(s.begin() + q.top().first, s.end());
      return;
    }
    for (auto j : v[i]) {
      if (d[j] != -1 || in[j] > 1) continue;
      dfs(j);
      if (!r.empty()) return;
    }

    for (auto j : v[i]) in[j]--;
    s.pop_back();
    d[i] = -1;
  };
  for (int i = 0; i < n; i++) {
    fill(d.begin(), d.end(), -1);
    fill(in.begin(), in.end(), 0);
    dfs(i);
    if (!r.empty()) break;
  }

  cout << (r.empty() ? -1 : (int)r.size()) << endl;
  for (auto e : r) cout << e + 1 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	char x, y; cin >> x >> y;
	if (x < y)cout << "<" << endl;
	else if (x > y)cout << ">" << endl;
	else cout << "=" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

bool exhaustiveSearch(int pivot, int n, int A[], int m) {
  if (A[pivot] == m) {
    return true;
  }
  if (pivot+1 == n) {
    return false;
  }
  return exhaustiveSearch(pivot+1, n, A, m-A[pivot]) || exhaustiveSearch(pivot+1, n, A, m);  
}

int main() {
	int n;
  scanf("%d", &n);
  int A[n];
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  int q;
  scanf("%d", &q);
  int m[q];
  for ( int i = 0; i < q; i++ ) scanf("%d", &m[i]);

  for ( int i = 0; i < q; i++ ) {
    if (exhaustiveSearch(0, n, A, m[i])) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



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

#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define P(a,b) make_pair(a,b)
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1<<50);



void solve(long long N, long long X){
    ll ans=N;
    ll x=max(X,N-X),y=min(X,N-X);
    while(x!=0&&y!=0){
        ans+=x/y*2*y-((x%y==0)?y:0);
        DEBUG(ans);
        ll tmp=y;
        y=x%y;
        x=tmp;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    solve(N, X);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         std::iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         std::rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         std::rotate(k,itr2,last);
         return true;
      }
   }
   std::rotate(first,k,last);
   return false;
}

#define INF INT_MAX/3
#define MAX_N 1000
ll n;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<string> v(n);
  rep(i,n) cin>>v[i];
  ll p[5] = {0};
  char d[5] ={'M','A','R','C','H'};
  rep(i,n) rep(j,5) if(v[i][0] == d[j]) p[j]++;
  // rep(j,5)cout<<p[j]<<endl;
  std::vector<ll> data;
  ll ans = 0;
  rep(i,5) if(p[i]>0) data.pb(i);
  // rep(i,data.size()) cout<<data[i]<<endl;
  if(data.size() <3) cout<<0<<endl;
  else {
    do {
       // cout<<p[data[0]]<<" "<<p[data[1]]<<" "<<p[data[2]];
        ans+=p[data[0]]*p[data[1]]*p[data[2]];
    } while ( next_combination(data.begin(), data.begin()+3, data.end()) );
    cout<<ans<<endl;
  }
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

ll fact_mod(ll N, ll MOD){
  ll retval = 1;
  rep(i,N) (retval *= (i+1))%= MOD;
  return retval;
}

int main(){
  ll N, M; cin >> N >> M;
  ll MOD = 1000000007;
  ll retval;
  if (abs(N-M)>1) {
    retval = 0;
  }
  else if (abs(N-M)==1){
    retval = fact_mod(N,MOD)*fact_mod(M,MOD)%MOD;
  }
  else retval = 2*fact_mod(N,MOD)*fact_mod(M,MOD)%MOD;

  cout << retval << endl;

  

  
  // cout << fixed << setprecision(10);
  
  return 0;
}


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

struct UnionFind {
    // 根は大きさの負
    // それ以外は親を持つ
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    int root (int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    bool unite (int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool same_root (int x, int y) {
        return root(x) == root(y);
    }
    int size (int x) {
        return -data[root(x)];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    vector<ll> ans(M);
    ans[M-1] = (ll)N*(N-1)/2;

    UnionFind Uni(N);

    for(int i = M - 1; i >= 1; i--)
    {
        ans[i-1] = ans[i];
        if(Uni.root(A[i]) != Uni.root(B[i])){
            ans[i-1] -= (ll)Uni.size(A[i])*Uni.size(B[i]);
            Uni.unite(A[i], B[i]);
        }
    }
    
    for(int i = 0; i < M; i++)
    {
        cout << ans[i] << endl;
    }    
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n;string s;
  cin >> n >> s;
  ll ans = 1, now = 0;
  for(int i = 0; i < 2*n; ++i){
    bool f = false;
    if(s[i]=='B'&& now%2==0)f = true;
    if(s[i]=='W'&& now%2!=0)f = true;
    if(f)++now;
    else{
      ans = (ans*now)%MOD;
      --now;
    }
  }
  if(now != 0)ans= 0;
  for(int i = 1; i <= n; ++i){
    ans= (ans*i)% MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        String tmp = sc.next();
        char[] s = tmp.toCharArray();
        for(int i = 1; i < n; i++){
            if(s[i-1] == 'L' && s[i] == 'L'){
                ans++;
            }
        }
        for(int i = 0; i < n-1; i++){
            if(s[i] == 'R' && s[i+1] == 'R'){
                ans++;
            }
        }
        int cnt = 0;
        for(int i = 0; i < n-1; i++){
            if(s[i] == 'R' && s[i+1] == 'L'){
                cnt++;
            }
        }
        System.out.println(Math.min(n-1,ans + k*2));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 28572
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,x; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
vector<ll> vi(200010);
ll a, b, c, d; bool flg = true; bool af = false; bool bf = false;
bool dfs(ll x,ll y) {
	if (x == c) { af = true; }
	if (y == d) { bf = true; }
	if (a>c||b>d) return false;
	else if (af&&bf) return true;
	for (int i = 1; i <= 2; i++) {
		if (flg) {
			if (vi[x + i] == 0) {
				x += i;
				vi[x] = 2;
				dfs(x, y);
			}
			else if (vi[x + i] == 2) {
				vi[x] = 2;
				flg = false;
				dfs(x, y);
			}
		}
		else if (!flg) {
			if (vi[y + i] == 0) {
				y += i;
				vi[y] = 2;
				dfs(x, y);
			}
			else if (vi[y + i] == 2) {
				vi[y] = 2;
				flg = true;
				dfs(x, y);
			}
		}
		else return false;
	}
}

int main() {
	cin >> a >> b >> c;
	ll res = a + b;
	chmin(res, a + c);
	chmin(res, b + c);
	cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;
 
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
 
int gcds(vector<int> A, int skip, int ans){
  int result = A[0];
  if(skip==0)result=A[1];
  for(int i=1;i<A.size();i++){
    if(i==skip)continue;
    result = gcd(A[i],result);
    if(result<=ans)break;
  }
  return result;
}
 
int gcds2(vector<int> A){
  int result = A[0];
  for(int i=1;i<A.size();i++){
    result = gcd(A[i],result);
  }
  return result;
}
 
int main()
{
  int N,ans1=0,ans2=0, ans=0;
  cin>>N;
  vector<int> A(N), B,C;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(i<N/2){
      B.push_back(A[i]);
    }else{
      C.push_back(A[i]);
    }
  }

  if(N>=8000){
    int gcd1=gcds2(B);
    int gcd2=gcds2(C);
    cout<<max(gcd1,gcd2)<<endl;
  }else{
    for(int i=0;i<N;i++){
      ans=max(ans,gcds(A,i,ans));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1404
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        int cnt = 1;
        char c = s.charAt(0);
        List<Integer> list = new ArrayList<>();
        if (c == '0') {
            list.add(0);
        }
        for (int i = 1; i < n; i++) {
            char tmp = s.charAt(i);
            if (c == tmp) {
                cnt++;
                continue;
            }
            list.add(cnt);
            cnt = 1;
            c = tmp;
        }
        list.add(cnt);
        if (s.charAt(n - 1) == '0') {
            list.add(0);
        }
        int size = list.size();
        long ar[] = new long[size];
        for (int i = 0; i < size; i++) {
            ar[i] = list.get(i);
        }
        for (int i = 1; i < size; i++) {
            ar[i] += ar[i - 1];
        }
        long ans = ar[Math.min(size - 1, k * 2)];
        for (int r = k * 2 + 2; r < size; r += 2) {
            long tmp = ar[r] - ar[r - (k * 2 + 1)];
            ans = Math.max(ans, tmp);
        }
        System.out.println(ans);
        sc.close();

    }
}


Measured memory_bytes: 25660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n % 1000 == 0){
			System.out.println("0");
		} else {
			System.out.println(1000 - n % 1000);
		}
	}

}

Measured memory_bytes: 35600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc173/abc173_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<char>> c(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) { cin >> c[i][j]; }
  }

  ll ans = 0;
  rep(i, pow(2, H)) {
    vector<vector<char>> tmp(c);
    // 行の塗りつぶし
    rep(j, H) {
      if (i & (1 << j)) {
        rep(l, W) { tmp[j][l] = ' '; }
      }
    }

    // 列の塗りつぶし
    rep(j, pow(2, W)) {
      vector<vector<char>> tmptmp(tmp);
      rep(l, W) {
        if (j & (1 << l)) {
          rep(k, H) { tmptmp[k][l] = ' '; }
        }
      }

      // 数え上げ
      int cnt = 0;
      rep(j, H) rep(k, W) {
        if (tmptmp[j][k] == '#') {
          cnt++;
        }
      }
      if (cnt == K) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

bool time2x[200010][32];

int main(void) {


	int N, C;
	cin >> N >> C;
	
	REP(i, N) {
		int start, endd, chan;
		cin >> start >> endd >> chan;
		
		for(int t = start*2-1; t < endd*2; t++) {
			time2x[t][chan-1] = true;
		}
	}
	
	int ret = 0;
	REP(tt, 200010) {
		int sum = 0;
		REP(c, C) {
			if ( time2x[tt][c] ) { sum++; }
		}
		
		if ( ret < sum ) { ret = sum; }
	}
	
	cout << ret << endl;
}


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

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

    if (S[1] == 'B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    string A = "", B = "";
    char ca = a + '0';
    char cb = b + '0';
    REP(i, b) { A.push_back(ca); }
    REP(i, a) { B.push_back(cb); }

    cout << min(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    string s;
    cin >> s;
    int N = s.size();
    vector<int> origin(N);
    int md13[6] = {1, 10, 9, 12, 3, 4};
    rep(i, N) { origin[i] = md13[i % 6]; }
    reverse(all(origin));
    ll MOD = 1000000007;

    vector<vector<ll>> dp(N + 10, vector<ll>(13, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        rep(j, 13) {
            if (s[i] == '?') {
                rep(k, 10) {
                    ll num = k * origin[i] % 13;
                    dp[i + 1][(j + num) % 13] += dp[i][j];
                    dp[i + 1][(j + num) % 13] %= MOD;
                }
            } else {
                ll num = (s[i] - '0') * origin[i] % 13;
                dp[i + 1][(j + num) % 13] += dp[i][j];
                dp[i + 1][(j + num) % 13] %= MOD;
            }
        }
    }

    cout << dp[N][5] << endl;
}

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

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> tList(N + 1);
    vector<int> xList(N + 1);
    vector<int> yList(N + 1);

    tList[0] = 0;
    xList[0] = 0;
    yList[0] = 0;

    for (int i = 1; i <= N; ++i) {
        cin >> tList[i];
        cin >> xList[i];
        cin >> yList[i];
    }

    bool flg = true;
    for (int i = 1; i <= N; ++i) {
        int time = tList[i] - tList[i - 1];
        int x = xList[i] - xList[i - 1];
        int y = yList[i] - yList[i - 1];

        // 移動が無理な場合
        if (x + y > time) {
            flg = false;
            break;
        }

        // 偶奇が合わない場合
        if (abs(x + y) % 2 != time % 2) {
            flg = false;
            break;
        }
    }


    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 1408
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


signed main() 
{
    speed;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    
    int k,a,b;
    cin>>k>>a>>b;
    if(a%k==0 || b%k==0) cout<<"OK";
    else if((a/k)==(b/k)) cout<<"NG";
    else cout<<"OK";
}

Measured memory_bytes: 3624
'use strict';
const main = input => {
  const nums = input[0].split(' ').map(val => parseInt(val));
  const a = nums[0], b = nums[1];
  let aa = '', bb = '';
  for(let i=0; i<b; i++) {
    aa += a;
  }
  for(let i=0; i<a; i++) {
    bb += b;
  }
  console.log(a>b?bb:aa);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
N, Ma, Mb = map(int, input().split())

a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    

INF = float("inf")
sA = sum(a)
sB = sum(b)
# 薬A,Bの合計がi,jになるのに必要な最小金額
dp = [[[INF for _ in range(401)] for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for j in range(401):
        for k in range(401):
            if a[i] <= j and  b[i] <= k:
                dp[i+1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i])
            else:
                dp[i+1][j][k] = dp[i][j][k]


ans = INF

x = Ma
y = Mb
while x <= sA and y <= sB :

    ans = min(ans, dp[N][x][y])
    x += Ma
    y += Mb


if ans == INF:
    ans = -1
print(ans)




Measured memory_bytes: 137820
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long count = 0;

//	3でも5でも割り切れないときに、countにその数を足す
		for(int i=1 ; i<=n ; i++) {
			if(i%3==0 || i%5==0) {
				continue;
			}
			else {
				count += i;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 27180
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; cin >> n;
    cout << n * n * n;

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import collections

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n, m = map(int, input().split(" "))
ufb = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split(" "))
    ufb.union(a- 1 , b - 1)

c = collections.Counter([ufb.find(i) for i in range(n)])
print(max(c.values()))

Measured memory_bytes: 33836
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N = int(input())
    c = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 == 1:
            c += 1
    print(c)
    # a, b, c = [int(a) for a in input().split()]
    # # A = [
    # #     int(input())
    # #     for _ in range(N)
    # # ]
    # A = [int(a) for a in input().split()]



if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import sys

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


# main
n, q = map(int, sys.stdin.readline().strip().split())

uf = UnionFind(n)
for _ in range(q):
    query_type, x, y = map(int, sys.stdin.readline().strip().split())
    if query_type == 0:
        uf.union(x, y)
    elif query_type == 1:
        is_same = uf.same(x, y)
        print(1 if is_same else 0)


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i,2) rep(j, n) cin >> a[i][j];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j <= i; j++){
            sum += a[0][j];
        }
        for(int k = i; k < n; k++){
            sum += a[1][k];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int x; cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3624
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<vector<int>>up(N, vector<int>(M, -1));
	vector<vector<int>>down(N, vector<int>(M, MOD));
	bool flag = true;
	for (int i = 0; i < N; i++) {
		cin >> K;
		while (K--) {
			string s;
			int a, b;
			cin >> a >> s >> b;
			a--;
			if (s[0] == '<')down[i][a] = min(down[i][a], b);
			else up[i][a] = max(up[i][a], b);
		}
		for (int j = 0; j < M; j++) {
			if (up[i][j] > down[i][j])flag = false;
		}
	}
	vector<vector<int>>edge(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j)continue;
			for (int k = 0; k < M; k++) {
				if (down[i][k] < up[j][k])edge[i][j] = 1;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		vector<int>visit(N);
		queue<int>Q;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (int j = 0; j < N; j++) {
				if (edge[cn][j] && !visit[j]) {
					visit[j] = 1;
					Q.push(j);
				}
			}
		}
		if (visit[i])flag = false;
	}
	if (flag)cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3356