akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



int main(){
  int l;
  cin >> l;
  int k=0;
  while(l/((int) pow(2,k))!=0){
    k++;
  }
  vector<tuple<int, int, int> > g;
 // cout << k << endl;
  rep(i,k-1){
    g.pb(make_tuple(i+1,i+2,pow(2,k-2-i)));
    g.pb(make_tuple(i+1,i+2,0));
  }
  
  int kt=k;
  int lt=l;
  while(lt-pow(2,kt-1)>0){
    lt-=pow(2,kt-1);
    kt=0;
    while(lt/((int) pow(2,kt))!=0){
      kt++;
    }
    g.pb(make_tuple(1,k-kt+1,l-lt));
  }
  cout << k << " " << g.size() << endl;
  rep(i,g.size()){
    int& u=get<0>(g[i]);
    int& v=get<1>(g[i]);
    int& w=get<2>(g[i]);
    cout << u << " " << v << " " <<  w <<endl;
  }
  
  return 0;

}


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

int main(){
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

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

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

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

		Arrays.sort(cs);
		Arrays.sort(ct);

		StringBuilder sbt = new StringBuilder();
		StringBuilder sbs = new StringBuilder();

		for (int i = 0; i < t.length(); i++) {
			sbt = sbt.append(ct[t.length() - 1 - i]);
		}
		for (int i = 0; i < s.length(); i++) {
			sbs = sbs.append(cs[i]);
		}

		String[] str = new String[2];
		str[0] = sbs.toString();
		str[1] = sbt.toString();

		Arrays.sort(str);

		String ans = "";
		if (sbs.toString().equals(sbt.toString())) {
			ans = "No";
		} else if (str[0].equals(sbs.toString())) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    vector< long long > a(n);
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    map< long long, long long > s;
    for (long long i = 0; i < n; i++) {
        s[a[i]] = 0;
    }
    for (long long i = 0; i < n; i++) {
        s[a[i]]++;
    }

    map< long long, bool > done;
    for (long long i = 0; i < n; i++) {
        done[a[i]] = false;
    }
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
        if (!done[a[i]]) {
            sum += s[a[i]] * (s[a[i]] - 1) / 2;
            done[a[i]] = true;
        }
    }
    for (long long i = 0; i < n; i++) {
        cout << sum - s[a[i]] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 18944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 50;
const int mod = 996873654;
int a[MAX]={0};
int main(){
	int n;
	sfi(n);
	int len=0,ans=0;
	for(int i=1;i<=n;i++){
		sfi(a[i]);
	}
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1]){
			len++;
		}
		else{
			ans=max(ans,len);
			len=0;
		}
	}
	ans=max(ans,len);
	cout<<ans;
	return 0;
}

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

#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int n; cin >> n;
  vector<int> d(n); rep(i, 0,n-1) cin >> d[i];
  sort(d.begin(), d.end());
  int ans =0 ;
  int c = 0;
  rep(k, 0, 100*1000) {
      while(c < n and k>d[c]) c++;
      if (c>=n) break;

      if (c== n-c) ans++;
  }

  END(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    mat dp(M + 1, vec(bit(N), INF));
    dp[0][0] = 0;

    REP(i, M){
        int a, b; cin >> a >> b;
        vec c(b); cin >> c;
        int m = 0;
        REP(j, b) m ^= bit(c[j] - 1);
        REP(j, bit(N)){
            Min(dp[i + 1][j], dp[i][j]);
            Min(dp[i + 1][j | m], dp[i][j] + a);
        }
    }
    Ans(dp[M][bit(N) - 1] < INF, dp[M][bit(N) - 1], -1);

    return 0;
}


Measured memory_bytes: 32384
fact=[1]
MOD=10**9+7
temp=1
for i in range(1,10**6):
    temp*=i
    temp%=MOD
    fact+=[temp]

def bi(a,b):
    if b>a:
        return 0
    up=fact[a]
    down=fact[a-b]*fact[b]
    down=pow(down,MOD-2,MOD)
    return (up*down)%MOD
    
def find(A):
    n=len(A)-1
    dic={}
    for i in range(len(A)):
        if A[i] in dic:
            dic[A[i]]+=[i]
        else:
            dic[A[i]]=[i]
    bad=[]
    for x in dic:
        if len(dic[x])==2:
            bad=dic[x][:]
            break
    p1=bad[0]
    p2=n-bad[1]
    ans=[]
    ans+=[n]
    for k in range(2,n+1):
        ans+=[(bi(n+1,k)-bi(p1+p2,k-1))%MOD]
    ans+=[1]
    return ans

input()
A=list(map(int,input().strip().split(' ')))
for x in find(A):
    print(x)

Measured memory_bytes: 115888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1e9+7;
const ll N=1e6+6;
const ll inf=1e18+1e17;
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
 	while ( t--)
 		solve();
}

Measured memory_bytes: 256
/*There's a possibility*/
/*but stop sucking first*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
using namespace std;

int main()
{
    fast;
    int n,k,i,j;
    cin>>n>>k;
    int h[n],dp[n+1];
    f(i,0,n)
        cin>>h[i];
    dp[0]=0;
    f(i,1,n)
    {
        dp[i]=abs(h[i]-h[i-1])+dp[i-1];
        f(j,2,k+1)
            if(i-j>=0)
                dp[i]=min(abs(h[i]-h[i-j])+dp[i-j], dp[i]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  int k =  n%10;
  if(k == 2 || k== 4 || k== 5 || k== 7 || k== 9){
    cout<<"hon\n";
  }
  else if(k == 0 || k== 1|| k== 6 || k==8){
    cout<<"pon";
  }
  else if(k == 3){
    cout<<"bon";
  }
  return 0;}


Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>0) cout<<"Positive";
    else if(b>=0) cout<<"Zero";
    else if((a&1)^(b&1)) cout<<"Positive";
	else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
// #include <boost/multiprecision/cpp_int.hpp>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;

void Main(int argc, char** argv) {
    ll n, k;
    cin>>n>>k;
    ll a[n];
    rep(i,n) cin>>a[i];
    ll m = 0;
    rep(i,n) {
        for(int j = i+1; j < n; j++) {
            if (a[i] > a[j]) m++;
        }
    }
    // debug(m);
    // map<ll, ll> mp;
    // rep(i,n) {
    //     mp[a[i]]++;
    // }
    ll ans = 0;
    ans += (m * k) % MOD;
    // sort(a, a+n);
    // set<ll> s;
    // rep(i,n) {
    //     s.insert(a[i]);
    // }
    rep(i,n) {
        // ll x = a[i];
        rep(j,n) {
            if (a[i] > a[j]) {
                // debug(a[i]);debug(a[j]);debug(((k-1LL) * k / 2LL) % MOD);
                ans = (ans + ((k-1LL) * k / 2LL) % MOD) % MOD;
            }
        }
        // for(auto y : s) {
        //     // debug(y);debug(x);
        //     if (y >= a[i]) continue;
        //     ans += (mp[y] * (((k-1) * k / 2) % MOD) % MOD);
        // }
    }
    cout << ans << endl;
}

signed main(int argc, char** argv) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main(argc, argv);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(S: str):
    if S == "ABC":
        print("ARC")
    else:
        print("ABC")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		for (int i = 1; i <= N; i++) {
			sum += i;
		}
		System.out.println(sum);
		sc.close();
	}

}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define MAXN 100005
typedef long long int64;
using namespace std;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,A[MAXN],fac[MAXN],invfac[MAXN],inv[MAXN],sum[MAXN],sum_of_sum[MAXN];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
void update(int &x,int y) {
	x = inc(x,y);
}
int C(int n,int m) {
	if(n < m) return 0;
	return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
void Solve() {
    read(N);
	for(int i = 1 ; i <= N ; ++i) {
		read(A[i]);
		sum[i] = inc(sum[i - 1],A[i]);
		sum_of_sum[i] = inc(sum_of_sum[i - 1],sum[i]);
	}
	inv[1] = 1;
	for(int i = 2 ; i <= N ; ++i) {
		inv[i] = mul(inv[MOD % i],MOD - MOD / i);
	}
	fac[0] = invfac[0] = 1;
	for(int i = 1 ; i <= N ; ++i) {
		fac[i] = mul(fac[i - 1],i);
		invfac[i] = mul(invfac[i - 1],inv[i]);
	}
	int ans = 0;
	for(int i = 1 ; i <= N ; ++i) {
		if(i == N) update(ans,mul(sum[N],fac[N]));
		else {
			update(ans,mul(inc(sum[i],inc(sum[N],MOD - sum[N - i])),mul(mul(fac[i],C(N,i + 1)),fac[N - i - 1])));
			if(i < N - 1) {
				int t = inc(sum_of_sum[N - 1],MOD - sum_of_sum[i]);
				update(t,MOD - sum_of_sum[N - i - 1]);
				update(ans,mul(t,mul(mul(mul(2,fac[i]),C(N,i + 2)),fac[N - i - 2])));
			}
		}
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m,k,a[200010],b[200010],ans=0;
    cin>>n>>m>>k;
    rep(i,n)cin>>a[i+1];
    rep(i,m)cin>>b[i+1];
    a[0]=0;
    b[0]=0;
    rep(i,n)a[i+1]+=a[i];
    rep(i,m)b[i+1]+=b[i];
    rep(i,n+1){
        if(a[i]>k)break;
        chmax(ans,i+(upper_bound(b,b+m+1,k-a[i])-b)-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6788
package main

import "fmt"

func main() {
	d := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var k int
	fmt.Scan(&k)
	fmt.Println(d[k-1])
}


Measured memory_bytes: 512
k, n = map(int,input().split())
a = list(map(int,input().split()))
d = []
x = 0

for i in range(n):
  x = abs(a[i] - a[i-1])
  if x > k/2:
    x = abs(x - k) 
  d.append(x)

print(sum(d)-max(d))

Measured memory_bytes: 26100
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdlib>

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

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

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

	int max = *max_element(a.begin(), a.end());
	int min = *min_element(a.begin(), a.end());
	cout << max - min << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#define ll long long
using namespace std;

ll mod=1000000007;
const int arm=110000;
int a[arm], cnt[arm], c[2];
ll fac[arm], finv[arm], inv[arm];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<arm; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}
ll COM(int n, int k, ll m){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return (fac[n]*((finv[k]*finv[n-k])%m))%m;
}


int main() {
	int N;
	cin >> N;
	int dub;
	for(int i=0; i<=N; ++i){
		cin >> a[i];
		++cnt[a[i]];
		if(cnt[a[i]]==2) dub=a[i];
	}
	int now=0;
	for(int i=0; i<=N; ++i){
		if(a[i]==dub){
			c[now]=i;
			++now;
		}
	}
	COMinit(mod);
	cout << N << endl;
	for(int k=2; k<=N+1; ++k){
		ll ans=COM(N+1, k, mod), sbs=COM(c[0]+N-c[1], k-1, mod);
		ans=(ans+mod-sbs)%mod;
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  using lint= long long int;
  const int Ntrans= 5;
  lint N,buf;
  cin >> N;

  lint bottleneck= LLONG_MAX;
  for(int i=0; i<Ntrans; i++){
    cin >> buf;
    bottleneck= min(bottleneck, buf);
  }

  auto ceiling_div= [](lint a, lint b){ // ceiling(a/b)= floor((a+b-1)/b)
    return (a+b-1)/b;
  };

  lint ans= ceiling_div(N, bottleneck)+ Ntrans- 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#define _USE_MATH_DEFINES


int main()
{
    int n=0,k=0,sum=0,havenum[100]={0},havepeo[100][100]={0},cake[100]={0};
    scanf("%d %d",&n,&k);
    for(int i=0;i<k;i++){
	scanf("%d",&havenum[i]);
	for(int j=0;j<havenum[i];j++){
	    scanf("%d",&havepeo[i][j]);
	}
    }

    for(int i=0;i<k;i++){
	for(int j=0;j<n;j++){
	    for(int m=0;m<n;m++){
    		if(m+1==havepeo[i][j])
    		    cake[m]=1;
	    }
	}
    }

    for(int i=0;i<n;i++){
	if(cake[i]==0)
	    sum++;
    }

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

		



	



Measured memory_bytes: 1776
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 3000;
double p[N];
double dp[N][N];
int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; cin >> n ;
	for(int i = 1 ; i <= n ; ++i)
		cin >> p[i];
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ; ++i)
	{
		for(int j = 0 ; j <= i ; ++j)
		{
			dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1]*p[i];
		}
	}
	double ans;
	for(int i = (n/2)+1 ; i <= n ; ++i)
		ans += dp[n][i];
	cout << setprecision(10) << fixed <<ans;

	return 0;
}

Measured memory_bytes: 68992
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.math.BigInteger
import java.util.*

/**
 * @author: pashka
 */

var res = 0
var pow2 = IntArray(0)

fun dfs(g: List<MutableList<Int>>, x: Int, p: Int) : Int {
    val n = g.size
    res += pow2[n - 1]
    res %= MOD
    var size = 1
    var num = 0
    for (y in g[x]) {
        if (y == p) continue
        var s = dfs(g, y, x)
        res -= pow2[s]
        res %= MOD
        size += s
        num++
    }
    if (p != -1) {
        var s = n - size
        res -= pow2[s]
        res %= MOD
        num++
    }
    res += num - 1
    res %= MOD
    return size
}

private val MOD = 1000000007

private fun solve() {
    var n = nextInt()
    var g = ArrayList<MutableList<Int>>(n)
    for (i in 0 until n) {
        g.add(ArrayList())
    }
    for (i in 0 until n - 1) {
        var a = nextInt() - 1
        var b = nextInt() - 1
        g[a].add(b)
        g[b].add(a)
    }

    pow2 = IntArray(n + 1)
    pow2[0] = 1
    for (i in 1..n) {
        pow2[i] = (pow2[i - 1] * 2) % MOD
    }

    dfs(g, 0, -1)
    var d = BigInteger.valueOf(pow2[n].toLong()).modInverse(
            BigInteger.valueOf(MOD.toLong())
    ).toLong()

    res = ((res * d) % MOD).toInt()
    if (res < 0) res += MOD

    println(res)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 93344
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200000];
int main(){
  int i;
  int k = 1;
  int res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    if(A[i]==k){
      k++;
    }
  }
  res = N - k + 1;
  if(k==1){
    res = -1;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191214-1

// --- original code ---
// int N, A[2d5];
// {
//   int k = 1, res;
//   rd(N,A(N));
//   rep(i,N) if(A[i]==k) k++;
//   res = N - k + 1;
//   if(k==1) res = -1;
//   wt(res);
// }


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

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    a--, b--, c--, d--;
    bool ok = true;
    string route_a = s.substr(a, c-a+1);
    string route_b = s.substr(b, d-b+1);
    if (route_a.find("##") != string::npos) ok = false;
    if (route_b.find("##") != string::npos) ok = false;    
    if (d < c && (s.substr(b-1, d-b+3).find("...") == string::npos)) ok = false;

    string ans = "No";
    if (ok) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 772
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    string str;
    cin>>str;
    vector<char> odd={'R','U','D'};
    vector<char> even={'L','U','D'};
    bool flag=false;
    rep(i,str.size())
    {
        if((i+1)%2==0)
        {
            rep(j,even.size())
            {
                if(str[i]==even[j])
                {
                    flag=true;
                    break;
                }
                else flag=false;
            }
        }
        else
        {
            rep(j,odd.size())
            {
                if(str[i]==odd[j])
                {
                    flag=true;
                    break;
                }
                else flag=false;
            }
        }
        if(!flag)break;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 10) {
    x = r*x-d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  unordered_map<char,int> m;
  for(int i=0;i<s.size();i++)
    m[s[i]]=1;
  
  if(m.size()==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = input()
if n[len(n) - 1] == "2" or n[len(n) - 1] == "4" or n[len(n) - 1] == "5" or n[len(n) - 1] == "7" or n[len(n) - 1] == "9":
    print("hon")
elif n[len(n) - 1] == "0" or n[len(n) - 1] == "1" or n[len(n) - 1] == "6" or n[len(n) - 1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61684
using System;
class Program
{
    static void Main(string[] args)
    {
        char a, b, c, d;
        string str = Console.ReadLine();//2つ以上のスペース区切り入力の取得
        a = str[0];  //数値で受け取りたい場合は変換する
        b = str[1];
        c = str[2];
        d = str[3];
        if ((a == b && a != c && c == d) || (a == c && a != b && b == d) || (a == d && a != b && b == c))
        {

            Console.Write("Yes");
        }
        else
        {
            Console.Write("No");
        }
        string str2 = Console.ReadLine();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  // unsigned long ans = n * (n + 1) / 2;
  unsigned long ans = 0;
  for(ll i = 1; i <= n; i++) {
    for(ll j = 1; j <= n / i; j++) {
      ans += i * j;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int n,k,x,y;
    cin >> n >> k >> x >> y;

    int ans;
    if(n <= k){
        ans = n*x;
    }
    else{
        ans = k*x+(n-k)*y;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s,t; READ s>> t;
  
  REP(i,s.size()){
    if(s[i]!=t[i]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

const long long mod = 1000000007;

int N, M;
char S[3030];
int l[3030], r[3030];
long long comb[3030][3030];
long long p[3030],n[3030];

int main()
{
	scanf("%d %d %s", &N, &M, S);
	for (int i = 0; i < M; i++){
		scanf("%d %d", &l[i], &r[i]);
		l[i]--; r[i]--;
		if (i > 0 && l[i - 1] == l[i])
		{
			if (r[i - 1] < r[i])
				r[i - 1] = r[i];
			i--;
			M--;
		}
		else if (i > 0 && r[i] <= r[i-1])
		{
			i--;
			M--;
		}
	}

	for (int i = 0; i <= N; i++){
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; j++) comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
	}

	int have = 0;
	p[0] = 1;
	for (int i = 0; i < M; i++){
		int nxt = ((i == M - 1) ? 0 : (r[i] < l[i + 1] ? 0 : r[i] - l[i + 1] + 1));

		int L = (i == 0 || r[i - 1] < l[i]) ? l[i] : r[i - 1] + 1;
		int R = r[i];

		int cnt = 0;
		for (int j = L; j <= R; j++) if (S[j] == '1') cnt++;
		int all = r[i] - l[i] + 1;

		for (int k = 0; k <= nxt; k++) n[k] = 0;

		for (int j = 0; j <= have; j++){
			int v = cnt + j;
			for (int k = 0; k <= nxt; k++){
				int p1 = v - k;
				int p0 = (all - nxt) - p1;
				if (p1 < 0 || p0 < 0) continue;

				n[k] = (n[k] + p[j] * comb[all - nxt][p1]) % mod;
			}
		}

		for (int k = 0; k <= nxt; k++) p[k] = n[k];
		have = nxt;
	}

	printf("%lld\n", p[0]);

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  bool a = false;
  
  for(int i = 0; i<N; i++){
    cin >> S;
    
    if(S == "Y"){
     a = true;
     break;
    }
  }
  if (a){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> divisor;
    for (ll i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            divisor.push_back(i);
            if (i * i != m) {
                divisor.push_back(m / i);
            }
        }
    }
    sort(divisor.begin(), divisor.end(), greater<ll>());
    for (int i = 0; i < divisor.size(); ++i) {
        if (divisor[i] * n * 1ll <= m) {
            cout << divisor[i] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n-k;i++){
        if(a.at(i)<a.at(i+k)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
}

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

int main(){
	double a,b,c,d,e,f,x,y,A,B,C,s,r;
	int n;
	cin >> n ;
	for(int i=0;i<n;i++){
		cin >> a >> b >> c >> d >> e >> f;
		C = (a-c)*(a-c)+(b-d)*(b-d);
		A = (c-e)*(c-e)+(d-f)*(d-f);
		B = (e-a)*(e-a)+(f-b)*(f-b);
		s = 2*(A*B+B*C+C*A)-(A*A+B*B+C*C);
		x = (A*(B+C-A)*a+B*(C+A-B)*c+C*(A+B-C)*e)/s;
		y = (A*(B+C-A)*b+B*(C+A-B)*d+C*(A+B-C)*f)/s;
		A = sqrt(A);
		B = sqrt(B);
		C = sqrt(C);
		r = A*B*C/sqrt((A+B+C)*(B+C-A)*(A-B+C)*(A+B-C));
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
	return 0;
}

Measured memory_bytes: 3284
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;

int W, H;
ll pw[100005], ph[100005];
ll ans;
int main() {
    cin >> W >> H;
    vector<P> vec;
    vec.reserve(W + H);
    rep(i, W) cin >> pw[i];
    rep(i, H) cin >> ph[i];
    rep(i, W) vec.push_back(P(pw[i], 0));
    rep(i, H) vec.push_back(P(ph[i], 1));
    sort(pw, pw + W);
    sort(ph, ph + H);
    sort(all(vec));
    rep(i, vec.size()) {
        auto p = vec[i];
        if (p.second == 0) {
            int k = upper_bound(ph, ph + H, p.first) - ph;
            k = H - k + 1;
            // cout << k << ", " << p.first << endl;
            ans += k * p.first;
        } else {
            int k = lower_bound(pw, pw + W, p.first) - pw;
            k = W - k + 1;
            // cout << k << ", " << p.first << endl;
            ans += k * p.first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

const int mod = 998244353;

pii a[200010];
int nxt[200010];
int dp[200010];

struct Segment_tree {
	int maxj[800010];
	Segment_tree() {memset(maxj, 0, sizeof(maxj));}
	void Update(int now, int l, int r, int pos, int x) {
		if (l == r) {
			maxj[now] = max(maxj[now], x);
			return ;
		}
		int mid = l + r >> 1;
		if (pos <= mid) Update(now << 1, l, mid, pos, x);
		else Update(now << 1 | 1, mid + 1, r, pos, x);
		maxj[now] = max(maxj[now << 1], maxj[now << 1 | 1]);
	}
	int Query(int now, int l, int r, int L, int R) {
		if (l == L && r == R) return maxj[now];
		int mid = l + r >> 1;
		if (R <= mid) return Query(now << 1, l, mid, L, R);
		if (L > mid) return Query(now << 1 | 1, mid + 1, r, L, R);
		return max(Query(now << 1, l, mid, L, mid), Query(now << 1 | 1, mid + 1, r, mid + 1, R));
	}
}seg;

int main () {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i].fi, &a[i].se);
	}
	sort(a, a + n);
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		int pos = lower_bound(a, a + n, mp(a[i].fi + a[i].se - 1, 0x3f3f3f3f)) - a;
		nxt[i] = max(i, seg.Query(1, 0, n - 1, i, pos - 1));
		seg.Update(1, 0, n - 1, i, nxt[i]);
		dp[i] = dp[nxt[i] + 1] + dp[i + 1];
		if (dp[i] >= mod) dp[i] -= mod;
	}
	printf("%d\n", dp[0]);
	return 0;
}


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

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;

    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long sum = accumulate(a.begin(), a.end(), 0);

    long res = 1;
    for(long qq=1; qq*qq<sum; qq++) {
        if(sum % qq != 0) continue;

        for(long q : {qq, sum/qq}) {
            vector<long> b(n);
            copy(a.begin(), a.end(), b.begin());

            for(auto &x: b) x %= q;
            sort(b.begin(), b.end());

            long s = 0;
            for(auto &x: b) s += q - x;

            long t = 0, r = 1e9;
            for(int i=0; i<n; i++) {
                r = min(max(t, s), r);
                t += b[i];
                s -= q - b[i];
            }
            r = min(max(t, s), r);

            if(r <= k)
                res = max(res, q);

        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n;
	ll h;
	cin >> n >> h;
	vector<ll>a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];
	int cnt = 0;

	sort(all(b), greater<ll>());

	ll ma = *max_element(all(a));
	rep(i, n) {
		if (b[i] > ma) {
			h -= b[i];
			cnt++;
			if (h <= 0) {
				break;
			}
		}
	}
	if (h > 0) {
		int a = (h + ma - 1) / ma;
		cnt += a;
	}
	cout << cnt << endl;
	return 0;
}





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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


constexpr int64 mod = 1e9+7;

int main(void) {
    int64 N;
    cin >> N;
    int64 res = 0;
    FOR(i, 1, N+1) {
        int64 cnt = 0;
        int64 now = i;
        while (now) {
            cnt++;
            now /= 10;
        }
        if (cnt%2) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
class Integer
  @mod = nil
  def self.set_mod(mod = 10**9 + 7)
    @mod = mod
  end

  def combination(k = self) # 4C2 = 6
    return 1 if k.zero?
    if @mod.nil?
      (self - k + 1..self).inject(:*) / k.factorial
    else
      (self - k + 1..self).inject{|i,m|i * m % @mod} * k.factorial.modinv % @mod
    end
  end

  def permutation(k = self) # 4P2 = 12
    return 1 if k.zero?
    if @mod.nil?
      (self - k + 1..self).inject(:*)
    else
      (self - k + 1..self).inject{|i,m|i * m % @mod}
    end
  end

  def factorial(step = 1) # 4! = 24
    return 1 if self.zero?
    if @mod.nil?
      (1..self).inject(:*)
    else
      (1..self).inject{|i,m|i * m % @mod}
    end
  end

  def modinv # https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    a = self; b = @mod; u = 1; v = 0
    while b > 0
      t = a / b
      a -= t * b
      a, b = b, a
      u -= t * v
      u, v = v, u
    end
    u %= m
    u += m if u < 0
    u
  end

  # 繰り返し二乗法
  def repeat_squaring(p, mod = (10**9 + 7))
    return 1 if p == 0
    if p % 2 == 0
      t = repeat_squaring(p/2, mod)
      return t*t % mod
    end
    self * repeat_squaring(p - 1, mod) % mod
  end

  alias :C :combination
  alias :P :permutation
  alias :! :factorial
end
require 'pp'
# 4 13 26484
n = gets.to_i
cnt = 0

sum = 0
M = 10
rs = []
cnts = (1..M).map do |m|
  [3,5,7].repeated_permutation(m) do |arr|
    cnt3 = arr.count(3)
    cnt5 = arr.count(5)
    cnt7 = arr.count(7)
    next if cnt3 == 0 || cnt5 == 0 || cnt7 == 0
    r =  arr.size.! / (cnt3.! * cnt5.! * cnt7.!)
    rs << arr.join.to_i
  end
end
# pp rs

# p n
p rs.bsearch_index{|x|x > n}



Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 4/26/2020
 
 17:35-
 
 */

int N;

vector<LL> primeFactors(LL n) {
  assert(n>=1);
  vector<LL> res;
  for(LL p=2; p*p<=n; ++p) while(n%p==0) {
    res.push_back(p);
    n/=p;
  }
  if(n>1) res.push_back(n);
  return res;
}

void solve() {
  map<int,int> cnt;
  FORE(i,1,N) {
    auto ps=primeFactors(i);
    REP(i,SZ(ps)) cnt[(int)ps[i]]++;
  }
  VI A;
  FORR(kvp,cnt) A.push_back(kvp.second);
  VV<LL> dp(SZ(A)+1,vector<LL>(100,0LL));
  dp[0][1]=1;
  int M=SZ(A);
  REP(i,M)REPE(j,75) {
    REPE(k,A[i]) if(j*(k+1)<=75) {
      dp[i+1][j*(k+1)]+=dp[i][j];
    }
  }
  cout<<dp[M][75]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


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

using namespace std;
typedef long long ll;
ll n;
const ll nax = 1e5;
vector<ll> v[nax];
const ll mod = 1e9 + 7;


// (black, white)
pair<ll, ll> dfs(ll s, ll p){
	ll white = 1;
	ll black = 0;
	for(ll &c : v[s]){
		if(c == p) continue;
		pair<ll, ll> pf = dfs(c, s);
		black = ((1LL*(white+black)*pf.first)%mod + (1LL*black*pf.second)%mod)%mod;
		white = (white*pf.second)%mod;
	}
	return make_pair(white, (white + black)%mod);
}


int main(){
	ll n; cin >> n;
	for (ll i = 1; i < n; ++i)
	{
		ll a, b; cin >> a >> b;
		v[--a].push_back(--b);
		v[b].push_back(a);
	}
	auto p = dfs(0, -1);
	ll ans = (p.first+p.second)%mod;
	cout << ans;
}	

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

int main(){
//srandom((unsigned long)time(NULL));
long long n,k;
cin>>n>>k;
long long h[n];
for(int i=0;i<n;i++){
    cin>>h[i];
}
sort(h,h+n);
long long ans=0;
if(n-k<=0){
    cout<<0<<endl;
    return 0;
}
for(int i=0;i<n-k;i++){
    ans+=h[i];
}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int a, b, c;
  int s[3];

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

  if(a<b && a<c){
    s[0]=a;
    if(b<c){s[1]=b; s[2]=c;}
    else{s[1]=c; s[2]=b;}  
  }
  else if(b<c){
    s[0]=b;
    if(a<c){s[1]=a; s[2]=c;}
    else{s[1]=c; s[2]=a;}
  }
  else{
    s[0]=c;
    if(a<b){s[1]=a; s[2]=b;}
    else{s[1]=b; s[2]=a;}
  }

  printf("%d %d %d\n", s[0], s[1], s[2]);  
  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll X[100005], V[100005], A1[100005], A2[100005];

int main() {
    init();
    ll N, C;
    cin >> N >> C;
    rep(i, N) cin >> X[i] >> V[i];
    X[N] = C;


    ll M = 0, pre = 0, d = C;
    repr(i, N){
        pre += V[i] - d + X[i];
        chmax(M, pre);
        A1[i] = M, d = X[i];
    }
    M = 0, pre = 0, d = 0;
    rep(i,N){
        pre += V[i] - X[i] + d;
        chmax(M, pre);
        A2[i] = M, d = X[i];
    }

    ll ans = max(A1[0], A2[N - 1]);
    rep(i,N - 1){
        chmax(ans, max(A2[i] - X[i] + A1[i + 1], A2[i]));
    }
    repe(i,1,N){
        chmax(ans, max(A1[i] - C + X[i] + A2[i - 1], A1[i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		while (!isPrime(X)) {
			X++;
		}
		System.out.println(X);
		sc.close();
	}

	//素数判定
	//計算量O(√N)
	public static boolean isPrime(long n) {
		if (n == 1) {
			return false;
		}
		for (long i = 2; i * i <= n; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 23892
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;

	c = malloc(sizeof(int)*(m+10000));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(n+1));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[2014], y[2014];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 4620
import bisect
n,K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
ans = [0]
if K>2*n:
    K = 2*n
if K == 1:
    print(max(a[0],a[n-1],0))
    exit()
for k in range((K+1)//2,min(K+1,n+1)):
    r = K-k
    for i in range(k+1):
        ls = a[:i]+a[n-k+i:]
        ls.sort()
        if r == 0:
            ans.append(sum(ls))
        elif ls[r-1]<0:
            ans.append(sum(ls[r:]))
        else:
            x = bisect.bisect_left(ls,0)
            ans.append(sum(ls[x:]))
print(max(ans))

Measured memory_bytes: 3316