akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    map<ll,ll> mp;
    int i;
    for(i=1;i<10000;i++){
        ll num = i*(i+1)/2;
        if(num<N) continue;
        mp[num-N]=1;
        break;
    }
    rep(ix,i){
        if(mp[ix+1]==0){
            cout << ix+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3844
n = gets.strip.to_i

rtmap = {}

n.times.each do
  eis = gets.strip.split(' ').map{|s| s.to_i}
  r = eis.shift
  k = eis.shift

  rtmap[r] = { :id => r, :nbrs => eis }
end

pn = gets.strip.to_i

pn.times.each do
  src, dst, ttl = gets.strip.split(' ').map{|s| s.to_i}

  rtmap.values.each{|nd| nd[:dist] = nil}

  rtmap[src][:dist] = 1
  queue = [src]

  while ! queue.empty?
    id = queue.shift
    dist0 = rtmap[id][:dist]

    for nid in rtmap[id][:nbrs]
      node = rtmap[nid]
      if node[:dist].nil?
        node[:dist] = dist0 + 1
        queue.push nid
      end
    end
  end

  ddist = rtmap[dst][:dist]
  puts (! ddist.nil? && ddist <= ttl) ? ddist : "NA"
end

Measured memory_bytes: 6548
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve() {
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);

    ll D, G; cin >> D >> G;
    vi p(D), c(D);
    F0R(i,D) cin >> p[i] >> c[i];
    ll best_np = 1e6;
    F0R(fs,1<<D) {
        ll np = 0, ng = 0;
        F0R(i,D) {
            if(fs & (1<<i)) {
                np += p[i];
                ng += p[i]*100*(i+1) + c[i];
            }
        }
        int npcur = 0;
        F0Rd(i,D) {
            //cout << i << ": " << (!(fs & (1<<i))) << endl;
            if(!(fs & (1<<i))) {
                //if(G-ng > 100*p[i]*(i+1)) {
                //    np += p[i];
                //    ng += 100*p[i]*(i+1);
                //} else {
                    while(G-ng > 0 && npcur < p[i]) {
                        npcur++;
                        ng += 100*(i+1);
                    }
                //cout << "asdf: " << i << " " << np << " " << ng << endl;
                    break;
                //}
            }
        }
        np += npcur;
        //cout << fs << " " << np << " " << ng << endl;
        if(G>ng) continue;
        best_np = min(best_np, np);
    }
    cout << best_np << endl;

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i<int(n); i++)
#define forr(i, t, n) for(int i = t; i<(int)n; i++)

const int maxn = 1000;
const int mod = 1e9 +7;
int dp[maxn+1][maxn+1];
bool mat[maxn+1][maxn+1];
int solve(int curn, int curm){
	if (not mat[curn][curm]) return 0;
	if (curn == 0 and curm == 0) return 1;
	if (dp[curn][curm] != -1) return dp[curn][curm];
	if (curn == 0) dp[curn][curm] = solve(curn, curm-1)%mod;
	else if (curm == 0) dp[curn][curm] = solve(curn-1, curm)%mod;
	else dp[curn][curm] = (solve(curn-1, curm) + solve(curn, curm-1))%mod;
	return dp[curn][curm];
}

int main(){
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	string s;
	forn(i, n){
		cin >> s;
		forn(j, m){
			if (s[j] == '.') mat[i][j] = 1;
			else mat[i][j] = 0;
		}
	}
	cout << solve(n-1, m-1) << "\n";
	return 0;
}

Measured memory_bytes: 5248
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
s=0
p=[]
for i in range(n):
    a,b=A[i],B[i]
    if(b<=a):
        p.append(a-b)
    else:
        s+=b-a
        ans+=1
p.sort()
while(s>0 and len(p)>0):
    s-=p.pop()
    ans+=1
if(s>0):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 19052
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1e9+9;
ll n,ans;
ll s[100009];
ll mn[100009];
ll psum[100009];
vector < int > v[100009];
void dfsMin(int node,int p){
	mn[node] = (s[node] == -1 ? inf : s[node]);
	for(int i=0;i<v[node].size();i++){
		int u = v[node][i];
		if(u == p) continue;
		dfsMin(u,node);
		mn[node] = min(mn[node],mn[u]);
	}
	if(mn[node] < s[node]) puts("-1"),exit(0);
}
ll dfs(int node,int p){
	psum[node] = psum[p];
	if(mn[node] < psum[node]) puts("-1"),exit(0);
	if(mn[node] != inf){
		ans += mn[node] - psum[node];
		psum[node] = mn[node];
	}
	for(int i=0;i<v[node].size();i++){
		int u = v[node][i];
		if(u != p) dfs(u,node);
	}
}
int main(){
	fast,cin>>n;
	cout<<n*n*n<<endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int N;
  cin >> N;
  // if(N == 1){
  //   cout << "No" << endl;
  //   return 0;
  // }
  FOR(i,2,1e3){
    if(N == i*(i-1)/2){
      //集合の数 i 集合の要素数 (i - 1)
      cout << "Yes" << endl;
      cout << i << endl;
      vector<vector<int> > S(i);

      int num = 1;
      rep(rank,i-1){//0,1,.....,i-1
        FOR(k,rank,i-1){
          S[rank].push_back(num);
          num++;
        }
      }

      num = 1;
      FOR(k,1,i){//0,1,.....,i-1
        FOR(rank,k,i){
          S[rank].push_back(num);
          num++;
        }
      }

      //print
      rep(j,i){
        cout << i-1 << ' ';
        rep(k,i-1){
          if(k != i-2) cout << S[j][k] << ' ';
          else        cout << S[j][k] << endl;
        }
      }
      return 0;
    }
  }

  cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 2304
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define pb push_back
#define pf push_front
#define INF 0x3f3f3f3f
#define MAXN (int) 1e6 + 7
#define all(a) a.begin(), a.end()

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K, T;

ll dp[100004][105];

int a[100004];

ll k;

ll dfs(int pos, int sum, bool limit) {
	if (pos == -1)
		return !sum;
	if (!limit && ~dp[pos][sum])
		return dp[pos][sum];
	int up = limit ? a[pos] : 9;

	ll ans = 0;
	for (int i = 0; i <= up; i++) {
		ans += dfs(pos - 1, (sum + i) % k, limit && i == up);
		ans %= mod;
	}

	if (!limit)
		dp[pos][sum] = ans;
	return ans;
}

signed main(void) {

#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	memset(dp, -1, sizeof(dp));

	string s;
	cin >> s >> k;
	
	for (int i = 0; i < s.size(); i++) {
		a[i] = s[s.size() - i - 1] - '0';
	}

	
	cout << (mod + dfs(s.size() - 1, 0, true) - 1) % mod;













#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 83200
#include <iostream>
#include <vector>
#include <set>
#include <utility>
using namespace std;
using ll = long long;
const ll INF = 1e18;

const int N = 2 * (int)1e5;
int hs[N];
int as[N];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> hs[i];
	for (int i = 0; i < n; ++i) cin >> as[i];

	set<pair<int, ll>> st;
	st.insert({0, 0});
	for (int i = 0; i < n; ++i) {
		auto it = st.lower_bound({hs[i], INF});
		--it;

		ll off = as[i] + (*it).second;
		pair<int, ll> ad = {hs[i], off};

		while(true) {
			it = st.lower_bound(ad);
			if (it == st.end()) break;
			if ((*it).second <= ad.second) st.erase(it);
			else break;
		}
		st.insert({hs[i], off});
	}
	auto it = st.end();
	--it;
	cout << (*it).second << '\n';
}


Measured memory_bytes: 14336
using System;

namespace  ITP1_5_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int i = 1;

            while(true)
            {
                int x = i;

                bool flag = false;

                if(x % 3 == 0)
                {
                    Console.Write(" {0}", i);
                    flag = true;
                }

                if(flag == false)
                {
                    while(true)
                    {
                        if(x % 10 == 3)
                        {
                            Console.Write(" {0}", i);
                            break;
                        }
                        
                        if((x /= 10) == 0) break;
                    }
                }

                if((++i) > n) break;
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9240
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        ll a,b;
                        cin>>a>>b;
                        cout<<(6-a-b);
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 256
/*
  AtCoder Grand Contest 027
  B - Garbage Collector

  方針
    ゴミはN個あるため、これをすべて拾うにはNXだけのエネルギーが必要です。
    これはゴミを拾う順番には関係ない。

    ロボットはゴミ箱にゴミを捨てに戻った場合、原点に戻っており、拾ったゴミ
    がないこと以外は初期状態と同じことがわかる。
    したがって、合計m台のロボットが同時にゴミを拾い、ゴミを捨てにもどって
    くるエネルギーを最小化することに等しくなる。

    またゴミは帰り際に遠い方から拾った方が最適である。

    ここで、ある１つのロボットに着目したとき、拾うゴミの数をi個とする。
    ゴミは遠い方から順にx_1, x_2, ...の位置にあるとする。
    (1) i = 1のとき
      E = x_1 + 4 * x_1
        = 5 * x_1
    (2) i = 2のとき
      E = x_1 + 4 * (x_1 - x_2) + 9 * x_2
        = 5 * x_1 + 5 * x_2
    (3) 9 = 3のとき
      E = x_1 + 4 * (x_1 - x_2) + 9 * (x_2 - x_3) + 16 * x_3
        = 5 * x_1 + 5 * x_2 + 7 * x_3
    以上の例からもわかるように手前にあるゴミを追加で拾う場合は、i-1個のゴ
    ミを拾うエネルギーに加えて、
      ((i+1)^2 - i^2) * x_i = (2 * i + 1) * x_i
    だけの追加のエネルギーが必要であることがわかる。以下、位置xにあるゴミ
    をi番目に拾うときに追加で必要なエネルギーをE(i,x)とする。

    以上の考察を踏まえると、i<jならばE(i,x)<=E(j,x)であることがわか
    る。つまり、同じ位置にあるゴミに対して、できるだけ少ない数のゴミを持っ
    ているロボットが拾うと効率が良いということになる。
    
    このことは同時に、各ロボットはどこまで遠いゴミを拾いにいくべきかもわか
    る。はじめはすべてのロボットが拾ったゴミは0個であるため、遠いところから
    順番に各ロボットが拾うのが効率が良いことになる。
    
    すべてのロボットの拾ったゴミの数が同じ場合は、次に近くにあるゴミをどの
    ロボットが拾っても必要なエネルギーは変わりません。しかし、こういった場
    合は、なんらかのルールを設けた方が計算が容易になることが多くあります。
    そこで遠い位置から順番にゴミがx_1, x_2, ..., x_Nの位置にあった場合、
    i番目のロボットはn * i番目（n: 整数）の位置のゴミを拾うこととします。
    するとi番目のロボットの必要なエネルギは
      E_i = E(1,x_i) + E(2,x_{2*i}) + ... + E(n,x_{n*i})
    となります。

    以上の方法で計算した場合、O(N^2)の計算量となり、部分点を得ることができ
    る。

    満点回答を得るためには、累積和を用いると、同じ個数を取る際の計算をまとめ
    て行うことができるため、O(N * log(N))で計算できる。
  
  実装
    上記の方針通り。
*/

#include<iostream>
#include<vector>
#include<limits>
using namespace std;

long long N, X;
vector<long long> x;
vector<long long> sum;

int main() {
  scanf("%lld%lld", &N, &X);
  x = vector<long long>(N+1);
  sum = vector<long long>(N+1, 0);
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &x[i]);
    sum[i] = sum[i-1] + x[i];
  }

  long long min_cost = numeric_limits<long long>::max();
  for (int m = 1; m <= N; ++m) {
    long long cost = m * X;
    for (int offset = N, group = 1; offset >= 0 && cost < min_cost; offset -= m, ++group) {
      int start = max(0, offset - m);
      int end = offset;
      if (group == 1) cost += 5 * (sum[end] - sum[start]);
      else cost += (2 * group + 1) * (sum[end] - sum[start]);
    }
    min_cost = min(min_cost, cost);
  }

  printf("%lld\n", min_cost + N * X);
  return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();
	pakuri_sort(N, A);

	int kotae = 0;
	ll kazu = A[0] << 1;
	rep1(i, N - 1) {
		if (kazu < A[i]) kotae = i;
		kazu += A[i] << 1;
	}

	printf("%d\n", N - kotae);

	Would you please return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[303030];
int ma[303030];
int mi[303030];
int did[303030];

int proc(vector<int> cand) {
	if(cand.empty()) return 1;
	FORR(c,cand) if(A[c]!=c) return 0;
	
	int i;
	int L=-1,R=-1;
	for(i=cand[0]-1;i<=cand.back()+1;i+=2) {
		if(A[i]==i) return 0;
		if(A[i]<i) {
			if(R>A[i]) return 0;
			R=A[i];
		}
		else {
			if(L>A[i]) return 0;
			L=A[i];
		}
	}
	
	return 1;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<=N;i++) {
		cin>>A[i];
		
		if(abs(i-A[i])%2==1) return _P("No\n");
		if(i<A[i]) {
			did[i+1]++;
			did[A[i]+1]--;
		}
		else {
			did[A[i]+1]++;
			did[i+1]--;
		}
	}
	
	vector<int> cand;
	for(i=1;i<=N;i++) {
		if(i>=2) did[i]+=did[i-2];
		if(did[i]) {
			if(did[i-1]) return _P("No\n");
			if(cand.size() && cand.back()+2!=i) {
				if(!proc(cand)) return _P("No\n");
				cand.clear();
			}
			cand.push_back(i);
		}
	}
	if(!proc(cand)) return _P("No\n");
	cout<<"Yes"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5364
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

signed main()
{
    fast;
    int n,m;
    cin>>n>>m;

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

    int x = (sum % (4*m) == 0)?sum/(4*m):sum/(4*m) + 1;
    int cnt = 0;
    for ( int i = 0 ; i < a.size() ; i++ )
    {
        if ( a[i] >= x )
        {
            cnt++;
        }
    }

    if ( cnt >= m )
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;  
    }
    


    return 0;
}

Measured memory_bytes: 256
#
n = int(input())
b = list(map(int,input().split()))
#
a = [b[0]]
for i in range(0,n-1):
    if a[i] > b[i]:
        a[i] = b[i]
    a.append(b[i])

s = 0
for i in range(0,n):
    s = s + a[i]

print(s)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int num = 0;
        String str = br.readLine();

        for (int i=0;i<6;i++){
            if (str.charAt(i) == '1'){
                num = num + 1;
            }
        }
        System.out.println(num);
    }
}

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

int main() {
  ll N; cin >> N;
  set<ll> s;
  map<ll,ll> count;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    s.insert(a);
    count[a]++;
  }
  ll res = 0;
  for (auto it = s.begin(); it != s.end(); it++) {
    ll a = *it;
    if (count[a] >= a) {res += (count[a]-a);}
    else {res += count[a];}
  }
  cout << res << endl;
}

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define MAX_NUM 50001
#include <iomanip>
#include <string>
using namespace std;


int main()
{
    int ans=0,N,temp;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>temp;
        ans+=temp-1;
    }
    cout<<ans;


}


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

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a < b) {
    if (b < c) System.out.printf("%d %d %d\n", a, b, c);
    else if (a < c) System.out.printf("%d %d %d\n", a, c, b);
    else System.out.printf("%d %d %d\n", c, a, b);
}
else{
    if(a<c)System.out.printf("%d %d %d\n", b, a, c);
    else if(b<c)System.out.printf("%d %d %d\n", b, c, a);
    else System.out.printf("%d %d %d\n", c, b, a);
} 
}
}


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

int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) { // n が 0 になるまで
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    int test = 10;
    int flag = 0;
    while(test <= n) {
        if (test == n) {
            cout << "10" << endl;
            flag = 1;
        }
        test = test * 10;
    }
    if (flag != 1) cout << findSumOfDigits(n) << endl;
    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
int h[20];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) cin>>h[i];
    int hight=h[0];
    int ans=1;
    for(int i=1;i<n;i++){
        if(hight<=h[i]){
            ans++;
            hight=h[i];
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

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

    int n, x, i;
    cin >> n >> x;
    if(n == 1)
        cout << x;
    else
    {


    for(i= x+1-n; i <x+n;i++)
    {
        cout << i << " ";
    }
    }
    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())

edge = []
for _ in range(N-1):
    edge.append(list(map(int, input().split())))
edge = sorted(edge)
n2w = [0]*(N+1)
for _ in range(Q):
  tmp = list(map(int,input().split()))
  n2w[tmp[0]] += tmp[1]

for a,b in edge:
  n2w[b] += n2w[a]

print(*n2w[1:])

Measured memory_bytes: 68252
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,b; cin>>a>>b;
    if((a+b)%2) cout<<"IMPOSSIBLE";
    else cout<<(a+b)/2;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;


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

	char b;
	cin >> b;

	if (b == 'A')
	{
		cout << "T" << endl;
	}
	else if (b == 'C')
	{
		cout << "G" << endl;
	}
	else if (b == 'G')
	{
		cout << "C" << endl;
	}
	else if (b == 'T')
	{
		cout << "A" << endl;
	}

	//system("pause");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    Int N,K;
    cin>>K>>N;
    vector<Int> A;

    Int offset = 0;
    for(int i = 0;i < N;i++) {
        Int a;
        cin>>a;
        if(i==0)
            offset = a;
        A.push_back(a-offset);
    }

    Int last = 0;
    vector<Int> D;
    Int sum = 0;
    Int md = 0;
    for(int i = 0;i < N;i++) {
        D.push_back(A[i]-last);
        sum += A[i]-last;
        md = max(md,A[i]-last);
        last = A[i];
    }
    D.push_back(K-last);
    md = max(K-last,md);
    sum += K-A[N-1];

    cout<<sum-md<<endl;


    return 0;
}



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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool solve(vl a)
{
	ll n=a.size();
	ll sum=accumulate(all(a),0ll);
	if(sum%(n*(n+1)/2))
		return false;
	ll m=sum/(n*(n+1)/2);
	rep(i,n){
		ll d=a[i]-a[(i-1+n)%n];
		if(m-d<0||(m-d)%n)
			return false;
	}
	return true;
}

int main()
{
	for(int n;cin>>n&&n;){
		vl a(n);
		rep(i,n) cin>>a[i];
		cout<<(solve(a)?"YES":"NO")<<endl;
	}
}


Measured memory_bytes: 1792
N = int(input())
dict = {}
s = [input() for i in range(N)]
for x in range(N):
    dict[s[x]] = 0
for y in range(N):
    dict[s[y]] += 1
# print(dict)

M = int(input())
t = [input() for i in range(M)]
for z in range(M):
    if t[z] in dict:
        dict[t[z]] -= 1
if max(dict.values()) > 0:
    print(max(dict.values()))
else:
    print(0)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  vector<int> ans(n);
  iota(ans.begin(), ans.end(), 0);

  sort(ans.begin(), ans.end(), 
    [&](int x, int y) { return a[x] < a[y]; });
    //[](int x,int y){return (a[x]>a[y]);}

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

Measured memory_bytes: 1664
sx,sy,tx,ty = map(int, input().split())

S = "U"*(ty-sy) + "R"*(tx-sx) + "D"*(ty-sy) + "L"*(tx-sx)
S += "L" + "U"*(ty+1-sy) + "R"*(tx+1-sx) + "D"
S += "R" + "D"*(ty+1-sy) + "L"*(tx+1-sx) + "U"
print(S)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
struct A{
	int a;
	int b;
	int c;
}arr[100];
bool fff(A a,A b)
{
	return a.c>b.c;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i].a>>arr[i].b>>arr[i].c;
	}
	sort(arr,arr+n,fff);
	if(arr[0].c==0)
		cout<<"0 0 0"<<endl;
	else
	{
		int q=1;
		int x,y,h;
		for(int i=0;i<=100;i++)
		{
			for(int j=0;j<=100;j++)
			{
				q=1;
				h=abs(arr[0].a-i)+abs(arr[0].b-j)+arr[0].c;
				for(int z=1;z<n;z++)
				{
					if(arr[z].c!=0)
					{
						if(abs(arr[z].a-i)+abs(arr[z].b-j)+arr[z].c==h)
						{
							q++;	
						}
						else
							break;
					}
					else
					{
						if((abs(arr[z].a-i)+abs(arr[z].b-j))>=h)
						{
							q++;
						}
						else
							break;
					}
					
						
				}
				if(q==n)
				{
					x=i;
					y=j;
					break;
				}
				
			}
			if(q==n)
				break;
		}
	
		if(q==n)
		{
			cout<<x<<" "<<y<<' '<<h<<endl;
		}	
	}
 } 

Measured memory_bytes: 256
n,m = map(int,input().split())
A = []
for i in range(n):
    A.append(list(map(int,input().split())))

B = []
for j in range(n):
    for k in range(A[j][0]):
        B.append(A[j][k+1])

score = 0
for l in range(m+1):
    if B.count(l) == n:
        score += 1

print(score)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class394
    {
        static void Main()
        {
            string S = Console.ReadLine();
            int I = S.Count(_ => _ == '1');
            int O = S.Length - I;

            Console.WriteLine(Math.Min(I,O)*2);
        }
    }
}


Measured memory_bytes: 26520
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    int n, k;
    cin>>n>>k;
    int a[n];
    rep(i, 0, n) {
        cin>>a[i];
    }
    sort(a, a + n);
    int ans = hell;
    rep(i, k-1, n) {
        ans = min(ans, a[i] - a[i-k+1]);
    }
    cout<<ans<<endl;

}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4052
A,B,C,K=map(int,input().split())

flag_A=False
flag_B=False
flag_C=False

if K<=A:
  flag_A=True
elif A<K and K<=A+B:
  flag_B=True
elif A+B<K and K<=A+B+C:
  flag_C=True
  
if flag_A==True:
  print(K)
elif flag_B==True:
  print(A)
elif flag_C==True:
  print(A-(K-A-B))

Measured memory_bytes: 8972
from math import factorial
n, a, b = map(int, input().split())
if n == 2 and a == 1 and b == 2:
    print(0)
    exit()

mod = 10**9 + 7

limit = 0
m = n
while m > 0:
    m //= 2
    limit += 1
# print(limit)

def solve(n):
    ans = 1
    p = 2
    for i in range(limit):
        # print(i, (n >> i) & 1)
        if (n >> i) & 1 == 1:
            ans = (ans * p) % mod
        p = (p * p) % mod
    # print(p)
    return ans

ans = solve(n)
# print(ans)
# a1 = solve(a - 1)
# a2 = solve(a)
# a3 = (a1 - a2) % mod
# b1 = solve(b - 1)
# b2 = solve(b)
# b3 = (b1 - b2) % mod
# print((ans - a3 - b3) % mod)

def gcd1(a, b):
    def calc(a, b, first, second):
        if a < b:
            a, b = b, a
        r = a % b
        q = -(a - r)//b
        if r == 0:
            return b, second
        # first += q * second
        first = [x + q * y for (x, y) in zip(first, second)]
        return calc(r, b, second, first)
    first = [1, 0]
    second = [0, 1]
    return calc(a, b, first, second)

def mod_inv(n, mod):
    table = gcd1(n, mod)
    inv = table[1][1]
    if inv < 0:
        inv += mod
    return inv

def cmb(n, r, mod):
    ans = 1
    for i in range(r):
        ans = (ans * n) % mod
        n -= 1
    ans1 = 1
    for i in range(1, r + 1):
        ans1 = (ans1 * i) % mod
    return ans * mod_inv(ans1, mod)

# f_n = factorial(n) % mod
# f_a = factorial(a) % mod
# f_b = factorial(b) % mod
# f_na = factorial(n - a) % mod
# f_nb = factorial(n - b) % mod
# print(f_n, f_a, f_b, f_na, f_nb)
# ac = (f_n * mod_inv(f_a, mod)) % mod
# ac = (ac * mod_inv(f_n_a, mod)) % mod
# bc = (f_n * mod_inv(f_b, mod)) % mod
# bc = (bc * mod_inv(f_n_b, mod)) % mod

ac = cmb(n, a, mod)
bc = cmb(n, b, mod)

# print(ans, ac, bc)
print((mod + ans - ac - bc - 1) % mod)


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	int ans = n - 1;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans = min(ans, i + n / i - 2);
		}
	}
	cout << ans << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    set<ll> ar;
    ar.insert(1);
    ar.insert(2);
    ar.insert(3);
    ar.erase(a);
    ar.erase(b);
    for(auto it : ar)
        cout<<it;
}


Measured memory_bytes: 256
def examB():
    St = S()
    AZ = [chr(i) for i in range(97, 97 + 26)]
    ans = "None"
    for s in AZ:
        if s not in St:
            ans = s
            break
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3700
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
int a[MAX_N];

int prime2(int n)
{
  int result = 0;
  while (n % 2 == 0) {
    n /= 2;
    result++;
  }
  return result;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> a[i];

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    mp[prime2(a[i])]++;
  }

  int total = 0;
  for (auto m : mp) {
    if (m.first != 0 && m.first != 1) {
      total += m.second;
    }
  }

  int num0 = mp.count(0) > 0 ? mp[0] : 0;
  int num1 = mp.count(1) > 0 ? mp[1] : 0;

  if (total < (num0 - 1)) {
    cout << "No" << endl;
    return 0;
  }
  if (total - num0 < (num1 % 2) - 1) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main(){
	int n,q;
	string s;
	cin>>n>>s>>q;
	s=" "+s;
	
	vector<set<int>>Si(26);
	// 各アルファベットごとに、出現位置をsetで記録していく。
	for(int pos=1; pos<=n; pos++){
		int alp=s[pos]-'a';
		Si[alp].insert(pos);
	}

	for(int qi=0;qi<q;qi++){
		int type;	cin>>type;

		if(type==1){
			int pos;	char c;
			cin>>pos>>c;

			int alp=s[pos]-'a';
			Si[alp].erase(pos);
			s[pos]=c;		alp=s[pos]-'a';
			Si[alp].insert(pos);
		}else{
			int L,R;	cin>>L>>R;

			int ans=0;	// L-R 範囲内の、アルファベットの種類数
			for(int alp=0; alp<26; alp++){
				auto it=Si[alp].lower_bound(L);
				// it: L 以降で、アルファベット（alp）が出る最小のポジション

				if(it != Si[alp].end() && *it<=R ){
					// it が Rより左にあるなら、範囲内にアルファベット（alp）が存在するよね！
					ans++;
				}
			}
			cout<<ans<<endl;
		}
	}


	return 0;
}


Measured memory_bytes: 26264
from collections import Counter
n, k = map(int, input().split())
c = Counter(list(map(int, input().split()))).most_common()
l = len(c)
if l >= k:
    m = 0
    for i in range(k):
        m += c[i][1]
    print(n-m)
else:
    print(0)


Measured memory_bytes: 37780
#include <stdio.h>
 
int main()
{
	char c;
	scanf("%c", &c);
    
	  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
          printf("vowel\n");
	}
      else{
	      printf("consonant\n");
	}
	return 0;
}

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

int main(void){
  int N,K;
  std::cin >> N >> K;
  
  int h[N];
  
  for(int idxh=0; idxh<N; idxh++) std::cin >> h[idxh];
  
  int n=0;//乗れる人数
  
  for(int idxh=0; idxh<N; idxh++) if(h[idxh] >= K) n++;
  
  std::cout << n << std::endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, d;
void solve(){
	cin >> n >> m >> d;
	
	if(d == 0){
		printf("%.10f\n", (double)(m-1)/n);
		return;
	}
	double ans = (double)max(n-d, 0)*2/n/n*(m-1);
	printf("%.10f\n", ans);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {
    int n;
    cin>>n;
    int mi=INF;
    int sum=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a%10!=0&&mi>a){
            mi=a;
        }
        sum+=a;
    }
    if(sum%10!=0){
        fin(sum);
    } else {
        if(mi==INF)fin(0);
        else {
            fin(sum-mi);
        }
    }
}








Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){
  if(a < b){
    return a;
  }
  else return b;
}

int main()
{
  int e = 0, c, i, q;
  P u;

  scanf("%d %d", &n, &q);
  for(i = 1;i <= n;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    e += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name, e);
    }
  }

  return 0;
}
    
  



Measured memory_bytes: 11952
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back


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


	vector<int> ans;
	while(n != 0)
	{
		int temp = 0;
		temp = n%26;
		ans.pb(temp);
		if(temp == 0){
			n--;
		}
		n = n/26;	
	}

	while(ans.size())
	{
		if(ans.back() == 0){
			ans[ans.size() - 1] = 26;
		}
		cout << (char)(ans.back() + 96);
		
		ans.pop_back();
	}
	
	// solve(n);
}
	

Measured memory_bytes: 3632
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int

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

        if(K%2 == 0 || K%5 == 0) cout << "-1" << endl;
        else{
            ll i=0;
            ll K_sub=K;
            while(true){
                if(K_sub/10 > 0){
                    K_sub/=10;
                    i++;
                }else break;
            }
            ll d=7;
            for(int j=0; j<i; j++) d=d*10+7;
            if(K > d){
                i+=2;
                d=d*10+7;
            }else i++;
            d=d%K;
            if(d == 0){
                cout << i << endl;
                return 0;
            }
            while(true){
                i++;
                if( (d*10+7)%K==0 ){
                    cout<<i<<endl;
                    return 0;
                }
                else{
                    d=(d*10+7)%K;
                }
            }
        }
    }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
constexpr int INF = 1LL<<60;

signed main() {
  string s; cin>>s;
  vector<int> cnt(26,0);
  for(int i=0;i<s.size();++i){
    // 出現する文字数をカウント
    ++cnt[s[i]-'a'];
  }
 
  int ans = INF;
  for(int i=0;i<26;++i){
    // 出現しなかった文字はスルー
    if(!cnt[i]) continue;

    string cpy_s = s;
    int cnt = 0;

    // breakを含んでいるので, 兵庫県警には捕まりません
    while(true){
      // 全ての文字が同じ文字の時はbreak
      if(string(cpy_s.size(), cpy_s[0])==cpy_s) break;

      // i文字目かi+1文字目に'a'+iがあれば, それに変更(操作)
      for(int j=0;j<cpy_s.size();++j){
        if(cpy_s[j+1]=='a'+i || cpy_s[j]=='a'+i) cpy_s[j]='a'+i;
      }
      // 末尾を削除
      cpy_s.pop_back();
      ++cnt;
    }
    ans = min(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m, x = map(int, input().split())
    toll = [False] * (n + 1)
    for a in map(int, input().split()):
        toll[a] = True

    back = 0
    for i in range(x - 1, -1, -1):
        back += toll[i]
    forth = 0
    for i in range(x + 1, n + 1):
        forth += toll[i]
    print(min(back, forth))
resolve()

Measured memory_bytes: 62000
N = int(input())

A = list(map(int,input().split(" ")))
flag = 0
ans = 1

if 0 in A:
    flag = 2
    print(0)

if flag != 2:
    for x in A:
        ans *= x
        #print(ans)
        if ans > 10**18:
            flag = 1
            break

if flag == 0:
    print(ans)
elif flag == 1:
    print("-1")

Measured memory_bytes: 21656
#include<bits/stdc++.h>
using namespace std;
int main() {
  int cnt1 = 0, cnt2 = 0;
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5) cnt1++;
  if(b == 5) cnt1++;
  if(c == 5) cnt1++;
  if(a == 7) cnt2++;
  if(b == 7) cnt2++;
  if(c == 7) cnt2++;
  if(cnt1 == 2 && cnt2 == 1) 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<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  int x;
  cin >> x;
  if (x >= 2100) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i <= 20; i++) {
    if (100 * i <= x && x <= 105 * i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
a = list(map(str, input().split()))

t = []

for n in a:
    if n == '+':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b + c)
    elif n == '-':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b - c)
    elif n == '*':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b * c)
    elif n == '/':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b / c)
    else:
        t.append(n)
print(t[0])


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

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

    vector<double> x(N);
    vector<string> u(N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> u[i];
    }

    double ans;
    double rate = 380000.0;
    for(int i = 0; i < N; i++){
        if(u[i] == "JPY"){
            ans += x[i];
        }else if(u[i] == "BTC"){
            ans += x[i] * rate;
        }
    }

    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#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 pushbottun(int i, int cnt, vector<int> &a) {
    if (i == 2) return cnt;
    if (cnt > a.size()) return -1;
    pushbottun(a[i-1], cnt+1, a);
    
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int ans = pushbottun(a[0], 1, a);
    cout << ans << endl;
}

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

int main(){
    int N;  cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    
    ll ans = 0;
    for(int i=N-1; i>=0; i--){
        if(i == N-1){ 
            ans += A[i];
            continue;
        }
        
        if(A[i] >= A[i+1]) ans += A[i];
        if(A[i] < A[i+1] - 1){
            cout << -1 << endl;
            return 0;
        }
    }
    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792