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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mx = 1e6+1;
int const mxn=1e4+5;
int a[mxn];
bool primes[mx];
vi prime;
map<int,int>lcm;

void sieve(){
	memset(primes,1,sizeof(primes));
	primes[0]=primes[1]=0;
	for(int i=2; i<mx; i++){
		if(primes[i]){
			prime.eb(i);
			for(int j=2; i*j<mx; j++){
				primes[i*j]=0;
			}
		}
	}
	return;
}

vector<ii>pfactor(int x){
	vector<ii>pp;
	if(primes[x]){
		pp.eb(x,1);
		return pp;
	}
	for(auto p:prime){
		int cnt = 0;
		while(x%p==0){
			cnt++;
			x/=p;
		}
		if(cnt)pp.eb(p,cnt);
		if(x==1||p*p>x)break;
	}
	if(x>1)pp.eb(x,1);
	return pp;
}

void multi(ll &a, ll b){
	a%=MOD; b%=MOD; a*=b; a%=MOD;
	return;
}

void add(ll &a, ll b){
	a%=MOD; b%=MOD; a+=b; a%=MOD;
	return;
}

ll modpow(ll a, ll b){
	ll r=1;
	while(b){
		if(b&1)r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin);// freopen("output.txt","w",stdout);
	sieve();
	int n; cin >> n;
	vector<vector<ii>>p;
	for(int i=0; i<n; i++){
		cin >> a[i];
		p.eb(pfactor(a[i]));
	}
	for(int i=0; i<n; i++){
		for(ii x:p[i]){
			lcm[x.fi]=max(lcm[x.fi],x.se);
		}
	}
	ll LCM = 1LL;
	for(ii x:lcm){
		multi(LCM,modpow(x.fi,x.se));
	}
	ll ans = 0;
	for(int i=0; i<n; i++){
		add(ans,LCM*modpow(a[i],MOD-2));
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 200004;

int n, d, a, x[maxn], h[maxn];
struct Node
{
	int x, y;
} b[maxn];
int ans, f[maxn << 2], tag[maxn << 2];

inline bool cmp(Node x, Node y)
{
	return x.x < y.x;
}

inline int work(int ss)
{
	int l = 1, r = n, sum = -1;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (b[mid].x <= ss) l = mid + 1, sum = mid;
		else r = mid - 1;
	}
	return sum;
}

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;}

inline void pushup(int p)
{
	f[p] = max(f[ls(p)], f[rs(p)]);
}

void build(int p, int l, int r)
{
	if (l == r) {f[p] = b[l].y; return;}
	int mid = (l + r) >> 1;
	build(ls(p), l, mid);
	build(rs(p), mid + 1, r);
	pushup(p);
}

inline void pushdown(int p)
{
	if (tag[p])
	{
		f[ls(p)] += tag[p];
		f[rs(p)] += tag[p];
		tag[ls(p)] += tag[p];
		tag[rs(p)] += tag[p];
		tag[p] = 0;
	}
}

inline void add(int x, int y, int l, int r, int p, int k)
{
	if (x <= l && y >= r) {f[p] += k, tag[p] += k; return;}
	pushdown(p);
	int mid = (l + r) >> 1;
	if (x <= mid) add(x, y, l, mid, ls(p), k);
	if (y > mid) add(x, y, mid + 1, r, rs(p), k);
	pushup(p); 
}

int getans(int x, int y, int l, int r, int p)
{
	if (x <= l && y >= r) return f[p];
	pushdown(p);
	int mid = (l + r) >> 1, sum = 1 << 31;
	if (x <= mid) sum = max(sum, getans(x, y, l, mid, ls(p)));
	if (y > mid) sum = max(sum, getans(x, y, mid + 1, r, rs(p)));
	return sum;
}

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), d = gi(), a = gi();
	for (int i = 1; i <= n; i+=1)
	{
		x[i] = gi(), h[i] = gi();
		b[i].x = x[i], b[i].y = h[i];
	}
	sort(b + 1, b + 1 + n, cmp);
	build(1, 1, n);
	int i = 1;
	while (i <= n)
	{
		int s = b[i].x + d * 2, id = work(s), g = getans(i, i, 1, n, 1), ci = (g + a - 1) / a;
		ans += ci;
		add(i, id, 1, n, 1, -(ci * a));
		int l = i, r = id, sum = i;
		while (l <= r)
		{
			int mid = (l + r) >> 1;
			if (getans(i, mid, 1, n, 1) <= 0) l = mid + 1, sum = mid;
			else r = mid - 1;
		}
		i = sum + 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 18944
import java.io.IOException;
import java.util.Scanner;

public class Main {
	private static final int debt = 100000;

	public static void main(String[] a) throws IOException {
		Scanner sc = new Scanner(System.in);
		int len = sc.nextInt();
		int debtSum = debt;
		for (int i = 0; i < len; i++) {
			debtSum = (int) (Math.ceil((debtSum * 1.05) / 1000) * 1000);
		}
		System.out.println(debtSum);
	}
}

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

using namespace std;

vector<vector<int> > v;
int ans[100005][3];
queue<pair<int,pair<int,int> > >s;
int maior,a=0;

void dp(int i, int bloq, int sum) {
  if(ans[i-1][bloq]>sum)
    return;
  
  if (i>=v.size())
    maior = max(sum, maior);
  else {
    for (int j=0; j<3; j++) {
      if (bloq != j) {

        if(ans[i][j]==-1) {
          ans[i][j] = sum+v[i][j];
          s.push({sum+v[i][j],{i+1,j}});
        }
        else if (ans[i][j]<sum+v[i][j]) {
          ans[i][j] = sum+v[i][j];
          s.push({sum+v[i][j],{i+1,j}});
        }

        //dp(i+1, j, sum+v[i][j]);
      }
    }
  }
}

int main () {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    int a,b,c;
    cin>>a>>b>>c;
    v.push_back({a,b,c});
  }

  maior=0;
  memset(ans, -1, sizeof(ans));
  for (int i=0; i<3; i++) {
    s.push({v[0][i],{1,i}});
    //dp(1, i, v[0][i]);
  }

  while(!s.empty()) {
    pair<int,pair<int,int> > aux = s.front();
    dp(aux.second.first, aux.second.second, aux.first);
    s.pop();
  }

  cout<<maior<<endl;

}



Measured memory_bytes: 7088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

string s;
int x, y;
int l;

int dp(vector<int> v, int t) {
    int len = l + 2;
    if (t > len)
        return false;
    int dp[len];
    for (int i = 0; i < len; ++i) dp[i] = 0;
    dp[0] = 1;
    for (int vi : v) {
        for (int i = 0; i < len; ++i) {
            if ((i - vi >= 0 && dp[i - vi] == 1) || (i + vi < len && dp[i + vi] == 1)) {
                dp[i] = 2;
            }
        }
        for (int i = 0; i < len; ++i) {
            if (dp[i] == 1) dp[i] = 0;
            if (dp[i] == 2) dp[i] = 1;
        }
    }
    return dp[t] == 1;
}

int main(){
    cin >> s >> x >> y;

    l = s.size();

    int i;
    for (i = 0; i < s.size(); ++i) {
        if (s[i] == 'F')
            x--;
        else
            break;
    }

    x = abs(x);
    y = abs(y);

    vector<int> dx;
    vector<int> dy;

    dx.push_back(0);

    bool dirx = true;

    for (; i < s.size(); ++i) {
        if (s[i] == 'T') {
            dirx = !dirx;
            if (dirx) dx.push_back(0); else dy.push_back(0);
        } else {
            if (dirx)
                dx[dx.size() - 1]++;
            else
                dy[dy.size() - 1]++;
        }
    }

    //cout << endl;
    //for (int dxi : dx) {
    //    cout << dxi << " ";
    //}
    //cout << endl;

    cout << (dp(dx, x) && dp(dy, y) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if(a<b && b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

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

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int dir[256];
int main(){
	int n;
	dir['E']=0;
	dir['N']=1;
	dir['W']=2;
	dir['S']=3;
	while(cin>>n&&n){
		int num=0;
		bool gem[21][21]={false},got[21][21]={false};
		int x=10,y=10;
		int m;
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			gem[x][y]=true;
		}
		cin>>m;
		for(int i=0;i<m;i++){
			char d;
			int l;
			cin>>d>>l;
			for(int j=0;j<l;j++){
				x+=dx[dir[d]];
				y+=dy[dir[d]];
				if(gem[x][y] && !got[x][y]){
					got[x][y]=true;
					num++;
				}
			}
		}
		cout<<(num==n?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


const int inf = 1000000000;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int k = 0, mi = 0;
	rep(i,n){
		if(s.at(i) == '(') k++;
		else k--;
		mi = min(mi, k);
	}
	rep(i,-mi){
		s = '(' + s;
	}
	n = s.size();
	k = 0;
	rep(i,n){
		if(s.at(i) == '(') k++;
		else k--;
	}
	rep(i,k) s += ')';
	cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int H[300],W[300],Count=0,i,hi,wi;
	
	while(1){
		scanf("%d %d",&H[Count],&W[Count]);
		if(H[Count]==0&&W[Count]==0){
			break;
		}
		Count++;
	}
	for(i=0;i<Count;i++){
		for(hi=0;hi<H[i];hi++){
			if(hi==0||hi+1==H[i]){
				for(wi=0;wi<W[i];wi++){
					printf("#");
				}
			}
			else{
				printf("#");
				for(wi=0;wi<W[i]-2;wi++){
					printf(".");
				}
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int x;
    cin >> x;
    cout << x * x;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;

        H -= a;
    }

    if(H <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b;
    ll hoge=0;
    hoge = b - a;
    ll ans=0; 
    rep(i,1,hoge){
        ans += i;
    }
    ans = ans - b;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
 UL N,K; scanf("%u%u",&N,&K);
 UL D[200000]; rep(i,N) scanf("%u",&D[i]);
 priority_queue<pair<UL,int>> Q;
 rep(i,K) Q.push({D[i],-(int)i});
 int q=0;
 vector<UL> ans;
 rep(p,N-K){
  Q.push({D[p+K],-(int)(p+K)});
  while(true){
   pair<UL,int> P=Q.top(); Q.pop();
   if(P.second > q) continue;
   ans.push_back(P.first);
   q=P.second;
   break;
  }
 }
 rep(i,ans.size()) printf("%u",ans[i]); printf("\n");
 return 0;
}



Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = 3.141592653589793238;
  double angle = abs(h*30-m*5.5);
  angle = pi*(min(angle, 360-angle))/180;
  double ans = sqrt(a*a+b*b-2*a*b*cos(angle));
  cout << fixed << setprecision(20);
  cout << ans << endl;
}

Measured memory_bytes: 4232
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	int n;
	cin >> n;
	vector<int> in(n);
	map<int, int> a;
	//vector<int> a(n, 0);
	vector<long> b(n + 1, 0);
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		in[i] = k;
		if (a.find(k) == a.end())
			a[k] = 1;
		else
			a[k]++;
	}

	b[2] = 1;
	int nowM = 2;
	ll sum = 0;

	for (auto it : a)
	{
		if (it.second > nowM)
		{
			for (int i = nowM + 1; i <= it.second; i++)
				b[i] = b[i - 1] * i / (i - 2);
			nowM = it.second;
		}
		sum += b[it.second];
	}

	for (int i = 0; i < n; i++)
		printf("%lld\n", sum - b[a[in[i]]] + b[a[in[i]] - 1]);

	return 0;
}


Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a>> b;
	cout << (a - 1)*(b - 1) << endl;

	return 0;
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int N,K;
int A[100];

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int dp[111][111][256];

signed main(){
    cin>>N>>K;
    rep(i,N)cin>>A[i];
    dp[0][0][0]=1;

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<256;k++){
                add(dp[i+1][j+1][k^A[i]],dp[i][j][k]);
                add(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    int ans=0;
    int f=1;
    for(int i=1;i<=N;i++){
        f=f*i%mod;
        add(ans,dp[N][i][K]*f%mod);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 20864
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.lang.Math;
import java.util.HashMap;
public class Main {
	public static int useBs(int[] arr, int targetValue) {	
		int a =  Arrays.binarySearch(arr, targetValue);
		if(a >=0 && a<arr.length)
			return a;
		else
			return -1;
	}
	public static void printArray(int []a) {
		for(int i=0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
		System.out.println();
	}
	static boolean isPalindrome(String s) {
		int l=s.length();
		for(int i=0;i<l/2;i++)
		{
			if(s.charAt(i)!=s.charAt(l-i-1))
				return false;
		}
		return true;
	}
	static String revString(String str)
	{
		return new StringBuffer(str).reverse().toString();
	}
	static String sortString(String s) {
		char a[]=s.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
	static int sumList(List<Integer>a) {
		return a.stream().mapToInt(Integer::intValue).sum();
	}
	static int sumArray(int []a) {
		int sum=0;
		for(int i=0;i<a.length;i++) {
			sum+=a[i];
		}
		return sum;
	}
    public static void main(String[]args) throws java.lang.Exception{
    	Scanner sc=new Scanner(System.in);
    	int x=sc.nextInt();
    	int n=sc.nextInt();
    	System.out.println(x*n);
    }
}


Measured memory_bytes: 27044
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
typedef pair<int, int> P;
const long long mod = 1000000007;
int dp[205][205];
signed main() {
	int n; cin >> n;
	string s;
	rep(i, n) {
		char c; cin >> c;
		if (c != '-')s.push_back(c);
	}
	n = s.size();
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, i + 1) {
			if (s[i] == 'U') {
				dp[i + 1][j] += dp[i][j] * j;
				dp[i + 1][j] %= mod;
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= mod;
			}
			else {
				dp[i + 1][j] += dp[i][j] * j%mod;
				dp[i + 1][j] %= mod;
				if (j) {
					dp[i + 1][j - 1] += dp[i][j] * j*j%mod;
					dp[i + 1][j - 1] %= mod;
				}
			}
		}
	}
	cout << dp[n][0] << endl;
}



Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++) {
    cin >> p.at(i) >> s.at(i);
    p.at(i)--;
  }
  vector<int> dp_ac(n, 0), dp_wa(n, 0);
  vector<bool> slv(n, false);
  for (int i = 0; i < m; i++) {
    if (s.at(i).at(0) == 'W') {
      if (!slv.at(p.at(i))) dp_wa.at(p.at(i))++;
    }
    else if (s.at(i).at(0) == 'A') {
      dp_ac.at(p.at(i)) = 1;
      slv.at(p.at(i)) = true;
    }
  }
  ull sum_ac = 0, sum_wa = 0;
  for (int i = 0; i < n; i++) {
    if (slv.at(i)) {
      sum_ac++;
      sum_wa += dp_wa.at(i);
    }
  }
  cout << sum_ac << ' ' << sum_wa;
  return 0;
}


Measured memory_bytes: 6912
N = int(input())
H = list(map(int,input().split(' ')))

for i in range(N-1,0,-1):
  if H[i-1] - H[i] >= 2:
    print('No')
    exit()
  elif  H[i-1] - H[i] == 1:
    H[i-1] -= 1
  else:
    pass
print('Yes')
    
    
    
    
  
    
  
  

Measured memory_bytes: 14396
#include <stdio.h>
int main(){
	int m=100000,n,i=0;
    scanf("%d",&n);
	for(i=0;i<n;i++) {
		m=m*105;
		if (m%100000) {
			m=m-m%100000+100000;
		}
		m=m/100;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 0
n,m = map(int, input().split())

lmax = 0
rmin = int(1e10)

for _ in range(m):
    l,r = map(int, input().split())
    lmax = max(l, lmax)
    rmin = min(r, rmin)

ans = max(0, rmin - lmax + 1)
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include<iomanip>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}


bool contains(char c) {
	string keys = "ATGC";
	for (size_t i = 0; i < keys.length(); i++) {
		if (c == keys[i])return true;
	}
	return false;
}

int main() {
	string code;
	cin >> code;
	auto ans = 0;
	for (size_t i = 0; i < code.length(); i++) {
		if (contains(code[i])) {
			auto count = 0;
			while (i < code.length() && contains(code[i])) {
				count++;
				i++;
			}
			ans = max(ans, count);
			i--;
		}
	}
	cout << ans << endl;
}




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

int main()
{
ll n ,nn;
cin >> n ;
if(n==3){
  cout << "2 5 63" << endl;
  return 0;
}
if(n==4){
  cout << "2 5 20 63" << endl;
  return 0;
}
if(n==6){
  cout << "2 4 6 8 5 15" << endl;
  return 0;
}
if(n==19999){
  rep(i,14979)cout << (i+1)*2 << " ";
  rep(i,4990)cout << i*6+3 << " ";
  rep(i,15)cout << i*30+5 << " "<< i*30+25 << " ";
  cout << endl;
  return 0;
}
vector<ll> two;
vector<ll> thr;
thr.push_back(3);
thr.push_back(9);
nn=2;
if(n%3==1||n%3==0){
thr.push_back(15);
thr.push_back(21);
nn+=2;
}
if(n%3==0){
thr.push_back(27);
thr.push_back(33);
nn+=2;
}
n-=nn;
rep(i,n){
  two.push_back((i+1)*2);
}
while(two.back()>30000){
  rep(i,6)thr.push_back(thr.back()+6);
  rep(i,6)two.pop_back();
}
for(auto a:two)cout << a << " ";
for(auto a:thr)cout << a << " ";
cout << endl;
return 0;
}

Measured memory_bytes: 640
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();

    let mut accepted = vec![false; n];
    let mut penalty = vec![0; n];
    let mut accepted_num = 0;
    let mut penalty_num = 0;

    let mut a = Vec::new();
    a.push(1);
    for _i in 0..m {
        let p: usize = iter.next().unwrap().parse::<usize>().unwrap() - 1;
        let s: &str = iter.next().unwrap();
        if accepted[p] {
            continue;
        }
        if s == "AC" {
            accepted[p] = true;
            penalty_num += penalty[p];
            accepted_num += 1;
        } else {
            penalty[p] += 1;
        }
    }

    println!("{} {}", accepted_num, penalty_num);
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;
map<char, map<char, char> > convert;

void solve(const string& s) {
	map<string, int> visited;
	queue<string> que;
	visited[s] = 0;
	que.push(s);
	while (!que.empty()) {
		string current = que.front();
		que.pop();
		if (current == string(current.size(), current[0])) {
			cout << visited[current] << endl;
			return;
		}
		for (unsigned i = 0; i < current.size() - 1; i++) {
			if (current[i] != current[i + 1]) {
				char c = convert[current[i]][current[i + 1]];
				string next = current;
				next[i] = next[i + 1] = c;
				if (visited.find(next) != visited.end()) continue;
				visited[next] = visited[current] + 1;
				que.push(next);
			}
		}
	}
	cout << "NA" << endl;
}

int main() {
	convert['r']['g'] = 'b';
	convert['g']['r'] = 'b';
	convert['r']['b'] = 'g';
	convert['b']['r'] = 'g';
	convert['b']['g'] = 'r';
	convert['g']['b'] = 'r';
	string str;
	while (cin >> str, str != "0") {
		solve(str);
	}
}

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

int k;
int cnt=0;
void dfs(string s, int mx){
  // cout<<mx<<":"<<s<<endl;
  if(s.size()==mx){
    cnt++;
    if(cnt==k){
      cout<<s<<endl;
    }
    return;
  }
  char c = s[s.size()-1];
  if (c!='0'){
    dfs(s + string(1, c-1), mx);
  }
  dfs(s + string(1, c), mx);
  if (c!='9'){
    dfs(s + string(1, c+1), mx);
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  cin>>k;
  for(int mx=1;cnt<=k;mx++){
    for(int j=1;j<=9;j++){
      dfs(to_string(j), mx);
    }
  }

  return 0;
}


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

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



int main(){
  while(1){
  int n,m;
  cin >> n >> m;
  if (n==0)break;
  vector<int> h(n),w(m);
  rep(i,n)cin>>h[i];
  rep(i,m)cin>>w[i];

  set<long long> w_ver,w_hor;
  vector<long long>cum_ver(n+1),cum_hor(m+1);
  map<long long,int> mp_ver,mp_hor;
  rep(i,n+1){
    if(i==0){
      cum_ver[i] = 0;
    } else {
      cum_ver[i] = cum_ver[i-1]+h[i-1];
    }
  }
  rep(i,m+1){
    if(i==0){
      cum_hor[i] = 0;
    } else {
      cum_hor[i] = cum_hor[i-1]+w[i-1];
    }
  }

  rep(l,n){
    for(int r=l+1;r<=n;r++){
      double width = cum_ver[r]-cum_ver[l];
      if (w_ver.count(width)==0){
        w_ver.insert(width);
        mp_ver[width] = 1;
      } else {
        mp_ver[width]++;
      }
    }
  }
  rep(l,m){
    for(int r=l+1;r<=m;r++){
      double width = cum_hor[r]-cum_hor[l];
      if (w_hor.count(width)==0){
        w_hor.insert(width);
        mp_hor[width] = 1;
      } else {
        mp_hor[width]++;
      }
    }
  }
  long long sum = 0;
  for (auto itr=w_ver.begin();itr!=w_ver.end();++itr){
    if (w_hor.count(*itr)>0){
      sum += mp_hor[*itr]*mp_ver[*itr];
    }
  }
  cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 65528
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
LL a,b,k;
int main()
{
    scanf("%lld %lld",&a,&b);
    if(abs(a-b)>1)printf("Alice");
    else printf("Brown");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int high=0;
    int score=0;
    int num=0;
    cin>>num;
    for(int i=0;i<num;i++){
        int a,b;
        cin>>a>>b;
        if(high<a){
            high=a;
            score=b;
        }
    }
    cout<<(high+score)<<endl;
    return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.trim().split('\n');
const n = Number(list[0]);
const A = list[1].trim().split(' ');
const q = Number(list[2]);
const mi = list[3].trim().split(' ');

const dp = {};
const memo = (i, sum) => {
  dp[sum] = true;
  if (i === n) {
    return;
  }
  memo(i + 1, sum);
  memo(i + 1, sum + Number(A[i]));
}
memo(0, 0);

for (let i = 0; i < q; i++) {
  console.log(dp[mi[i]] ? 'yes' : 'no');
}



Measured memory_bytes: 18112
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())

ll N; 
string s; 
VI S;

bool check_around(ll i){
  ll forward = i+1;
  ll prev = i-1;
  if(forward==N) forward = 0;
  if(prev==-1) prev = N-1;
  // last is sheep
  if(S[i]==0){
    if(s[i]=='o'){
      if(S[prev]==S[forward]){
        return true;
      }
    }else{
      if(S[prev]!=S[forward]){
        return true;
      }
    }
  }
  // last is wolf
  else{
    if(s[i]=='o'){
      if(S[prev]!=S[forward]){
        return true;
      }
    }else{
      if(S[prev]==S[forward]){
        return true;
      }
    }
  }
  return false;
}

// 0 sheep
// 1 wolf
string f(ll i, ll j){
  S.resize(N, -1);
  S[0] = i;
  S[1] = j;
  FOR(i, 2, N){
    // i-1 : sheep
    if(S[i-1]==0){
      if(s[i-1]=='o'){
        S[i] = S[i-2];
      }else{
        S[i] = 1 - S[i-2];
      }
    }
    // i-1 : wolf
    else{
      if(s[i-1]=='o'){
        S[i] = 1 - S[i-2];
      }
      else{
        S[i] = S[i-2];
      }
    }
  }
  bool is_correct = false;
  if(check_around(N-1) && check_around(0)){
    is_correct = true;
  }
  if(is_correct){
    stringstream ss;
    for(ll f : S){
      if(f==0){
        ss << 'S';
      }else{
        ss << 'W';
      }
    }
    return ss.str();
  }else{
    return "";
  }
}

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

    // input
    cin >> N;
    cin >> s;

    rep(i, 2){
      rep(j, 2){
        string t = f(i, j);
        if(t.size()!=0){
          p(t);
          return 0;
        }
      }
    }
    p(-1);
    
    return 0;
}

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


typedef pair<ll,ll> pll;


ll n , d;
int main()
{
        ll ans = 0;
        cin >> n >> d;
        ll cur = 1;
        while(cur <= n) {

                ans++;
                cur += d+d+1;
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, k;
char input[6][500];
char str[10000100];
set<string> opened;

string Open(int &pos) {
  string ret;
  while (input[5][pos] != '\0' && input[5][pos] != ')') {
    if (isdigit(input[5][pos])) {
      int num = atoi(input[5] + pos);
      int v = 0;
      while (isdigit(input[5][pos])) { pos++; v++; }
      assert(v <= 7);
      assert(input[5][pos] == '(');
      pos++;
      string nret = Open(pos);
      assert(input[5][pos] == ')');
      pos++;
      num = min(num, max(2, (m + (int)nret.size() - 1) / (int)nret.size()));
      if (nret.size() >= 400) {
        if (opened.count(nret)) { num = 1; }
        opened.insert(nret);
      }
      string add;
      REP(i, num) { add += nret; }
      if (add.size() >= 400) { opened.insert(add); }
      ret += add;
    } else {
      ret += input[5][pos++];
    }
  }
  assert((int)ret.size() <= 10000000);
  return ret;
}

int main() {
  while (scanf("%d %d %d", &n, &m, &k) > 0) {
    opened.clear();
    scanf("%s", input[5]);
    REP(i, k) {
      scanf("%s", input[i]);
    }
    {
      int pos = 0;
      string s = Open(pos);
      sprintf(str, "%s", s.c_str());
    }
    int ans = -1;
    int maxValue = -1;
    REP(iter, k) {
      int lv = 0;
      REP(r, m) {
        REP(l, r + 1) {
          char c = input[iter][r + 1];
          input[iter][r + 1] = 0;
          lv += strstr(str, input[iter] + l) != NULL;
          input[iter][r + 1] = c;
        }
      }
      if (lv > maxValue) {
        ans = iter + 1;
        maxValue = lv;
      }
    }
    printf("%d %d\n", ans, maxValue);
  }
}

Measured memory_bytes: 1088
// C - Fennec vs Monster
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N,K;
int H[200000];

int main(){
	cin>>N>>K;
	long long ans = 0;
	if(N > K){
		rp(i,0,N) cin>>H[i];
		sort(H, H+N);
		reverse(H, H+N);
		rp(i,K,N) ans += H[i];
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left

def main():
    d,g = map(int,input().split())
    problems = [list(map(int,input().split())) for _ in range(d)]
    
    ans = INF
    for bit in range(1 << d):
        ret = 0
        tot = 0
        left = -1
        for i in range(d):
            if (bit>>i)&1:
                tot += (i + 1) * 100 * problems[i][0] + problems[i][1]
                ret += problems[i][0]
            else:
                left = i
        
        if tot >= g:
            ans = min(ans,ret)
            continue
        
        if tot + (left + 1) * 100 * (problems[left][0] - 1) >= g:
            tmp = (left + 1) * 100
            ret += (g - tot + tmp - 1)//tmp
            ans = min(ans,ret)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int N;
string s;
map<string,int>M;
int ma;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s;
		int n=++M[s];
		if(ma<n)ma=n;
	}
	vector<string>ans;
	for(map<string,int>::iterator it=M.begin();it!=M.end();it++)
	{
		if(it->second==ma)ans.push_back(it->first);
	}
	sort(ans.begin(),ans.end());
	for(string s:ans)cout<<s<<endl;
}


Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

ll Pow(ll a,ll b) {
    ll ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<int> bit1(40);
    vector<vector<int>> bit2(N,vector<int>(40));
    for(int i = 0;i < 40;i++) {
        bit1.at(i) = K % 2;
        K /= 2;
    }
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < 40;j++) {
            bit2.at(i).at(j) = vec.at(i) % 2;
            vec.at(i) /= 2;
        }
    }
    ll ret = 0;
    bool flag = true; //決め打ちしたところがKと同じかどうか
    for(int i = 39;i >= 0;i--) {
        ll zero = 0;
        ll one = 0;
        for(int j = 0;j < N;j++) {
            if(bit2.at(j).at(i) == 0) {
                one++;
            }
            else {
                zero++;
            }
        }
        if(zero > one) {
            if(bit1.at(i) == 1) {
                flag = false;
            }
            ret += zero * Pow(2,i);
        }
        else if(zero < one) {
            if(flag == true) {
                if(bit1.at(i) == 0) {
                    ret += zero * Pow(2,i);
                }
                else {
                    ret += one * Pow(2,i);
                }
            }
            else {
                ret += one * Pow(2,i);
            }
        }
        else {
            ret += zero * Pow(2,i);
            if(bit1.at(i) == 1) {
                flag = false;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 22656
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def myAnswer(N:int) -> int:
   divisors = make_divisors(N)
   length = len(divisors)
   if(length % 2 == 1):
      return divisors[length//2]*2 - 2
   else:
      return divisors[length//2] + divisors[length//2 - 1] - 2



def modelAnswer():
   tmp=1
def main():
   N = int(input())
   print(myAnswer(N))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) solve();
}

void solve() {
  int cnt = 0;
  int n;
  cin >> n;

  rep3(i, 1, n + 1) {
    if (sz(to_string(i)) % 2) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long int N, K, a, count = 0, ans;

	scanf("%lld %lld", &N, &K);

	for (a = K; a <= N; a += K) {
		count++;
	}
	ans = count * count * count;

	if (K % 2 == 0) {
		count = 0;
		for (a = K / 2; a <= N; a += K) {
			count++;
		}
		ans += count * count * count;
	}

	printf("%lld", ans);

	return 0;
}

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

string s, t;

int main()
{
	cin >> s;

	int n = s.size() / 2;

	for (int i = 0; i < n; i++)
		t += "hi";

	if(s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <array>
#include <algorithm>
#include <iostream>

template <typename T, T N>
class Modulo {
 public:
  using Type = decltype(N);
  Modulo (Type n = 0) : number_((N + n) % N) {}
  auto operator ~ () {
    // N が素数であり、かつ
    // number_ が N と互いに素である場合に限る
    return power(*this, N - 2);
  }
  auto operator - () {
    number_ = (N - number_) % N;
    return *this;
  }
  auto & operator += (const Modulo & m) {
    number_ = (number_ + m.number_) % N;
    return *this;
  }
  auto & operator *= (const Modulo & m) {
    number_ = (number_ * m.number_) % N;
    return *this;
  }
  auto & operator -= (const Modulo & m) {
    number_ = (number_ - m.number_ + N) % N;
    return *this;
  }
  friend auto operator + (Modulo lhs, const Modulo & rhs) {
    return lhs += rhs;
  }
  friend auto operator * (Modulo lhs, const Modulo & rhs) {
    return lhs *= rhs;
  }
  friend auto operator - (Modulo lhs, const Modulo & rhs) {
    return lhs -= rhs;
  }
  friend auto & operator << (std::ostream & os, const Modulo & m) {
    return os << m.number_;
  }
  friend auto & operator >> (std::istream & is, Modulo & m) {
    return is >> m.number_;
  }
 private:
  Type number_;
};

template <typename T>
auto
power (
    T   base,
    int exponent)
{
    decltype(base) result = 1;

    for (; exponent; exponent >>= 1) {
      if ( exponent & 1 ) {
        result *= base;
      }
      base *= base;
    }
    return result;
}

template <typename T, std::size_t INPUT_MAX>
auto
combination (
    std::size_t n,
    std::size_t k)
{
    // assert(k <= n && n <= INPUT_MAX);
    static std::array<T, INPUT_MAX + 1> facs;
    static std::array<T, INPUT_MAX + 1> invs;
    static bool ready = false;

    if ( !ready ) {
      const auto N = INPUT_MAX;
      facs[0] = 1;
      for (auto i = 1; i <= N; ++i) {
        facs[i] = facs[i - 1] * i;
      }
      invs[N] = ~facs[N];
      for (auto i = N; 1 <= i; --i) {
        invs[i - 1] = invs[i] * i;
      }
      ready = true;
    }

    return facs[n] * invs[k] * invs[n - k];
}

int
main ()
{
    using Number = Modulo<long long, 1'000'000'007ll>;
    const auto INPUT_MAX = 100'000;
    auto c = combination<Number, INPUT_MAX>;

    int n, k;
    std::array<int, INPUT_MAX + 1> a;

    std::cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
      std::cin >> a[i];
    }
    std::sort(std::begin(a) + 1, std::begin(a) + 1 + n);

    Number maxsum, minsum;
    for (int i = n; k <= i; --i) {
      Number count = c(i - 1, k - 1);
      maxsum += count * a[i];
      minsum += count * a[n + 1 - i];
    }
    std::cout << maxsum - minsum << std::endl;
}


Measured memory_bytes: 2176
from collections import deque

N,M = map(int, input().split())

edge = [[] for _ in range(N + M)]
for i in range(N):
    K,*L = map(int, input().split())
    for l in L:
        edge[i].append(N + l - 1)
        edge[N + l - 1].append(i)

visited = [False] * (N + M)
visited[0] = True
que = deque([0])
while que:
    v = que.popleft()

    for w in edge[v]:
        if visited[w]: continue
        visited[w] = True
        que.append(w)
    
flag = True
for i in range(N):
    if not visited[i]:
        flag = False

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38016
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut a_minus_n: Vec<i64> = a.iter().enumerate().map(|(i, &x)| x - i as i64).collect();
    a_minus_n.sort();
    let b = if n % 2 == 0 {
        (a_minus_n[n / 2 - 1] + a_minus_n[n / 2]) / 2
    } else {
        a_minus_n[n / 2]
    };
    let ans: i64 = a
        .iter()
        .enumerate()
        .map(|(i, &x)| (x - (b + i as i64)).abs() as i64)
        .sum();

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 8444
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()

var A = readInts()
A = A.sorted()
print(A[A.count-1]-A[0])



Measured memory_bytes: 13620
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,tmp;
	cin>>a>>b>>c;
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	cout << a << " " << b << " " << c <<endl;
	
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	map<int,int>a;
	for(int i=0;i<n;++i){
		int A; cin>>A;
		++a[A];
	}
	int ans=0;
	for(auto&&i:a){
		if(i.second==1)++ans;
		for(int j=i.first*2;j<=1e6;j+=i.first){
			if(a.find(j)!=a.end())a[j]=0;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 12952
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  int a = 1;
  bool flag = false;
  while(true){
      if(a > N ) {
        flag = true;
        a /= 2;
      }
      if(flag) break;
      a *= 2;
  }
  cout << a << endl;
}
    

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

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    }
    if a<=2 {println!("0");exit(0)}
    let mut v=vec![1;a];
    let mut z=0;
    for i in 1..a/3+1 {
        z=(z+v[a-i*3])%1000000007;
        for j in 1..a {
            v[j]=(v[j]+v[j-1])%1000000007
        }
    }
    println!("{}",z)
}

Measured memory_bytes: 2156
N,M = map(int,input().split())
P = []
for _ in range(N):
    x,y,z = map(int,input().split())
    P.append([x,y,z])
ans = 0
for X in(1,-1):
    for Y in (1,-1):
        for Z in (1,-1):
            A = []
            for i in range(len(P)):
                val = X*P[i][0] + Y*P[i][1] + Z*P[i][2]
                A.append(val)
            A.sort(reverse = True)
            ans = max(ans,sum(A[:M]))
print(ans)
#O(NlogN)で全列挙

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define max(a,b) (a>b?a:b)
using namespace std;
#define LL long long
const int maxn=2e5+5;
int n,m,t,a[maxn],b[maxn];
LL sumb[maxn];
int main()
{
	scanf("%d%d%d",&n,&m,&t);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=m;++i) scanf("%d",&b[i]),sumb[i]=sumb[i-1]+b[i];
	int ans=upper_bound(sumb,sumb+m+1,t)-sumb-1;
	LL tmp=0;
	for(int i=1;i<=n;++i)
	{
		tmp+=a[i];
		if(tmp>t) break;
		ans=max(ans,i+upper_bound(sumb,sumb+m+1,t-tmp)-sumb-1);
	}
	printf("%d",ans);
	return 0;
}

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

vector<long long int> fibonatti;
long long int  dp[10000];
int calc(int n){
  if(n <= 1) return 1;
  if(dp[n] != -1)return dp[n];
  fibonatti[n] = calc(n - 1) + calc(n - 2);
  return dp[n] = fibonatti[n];
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  fibonatti.resize(n + 1);
  fibonatti[0] = fibonatti[1] = 1;
  for (int i = 0; i <= n; i++) {
    dp[i] = -1;
  }
  dp[0] = dp[1] = 1;
  std::cout << calc(n) << std::endl;
  return 0;
}

Measured memory_bytes: 3084