akhauriyash/Code-Regression huggingface dataset:
import math
N=int(input())
p=[list(map(int,input().split())) for _ in range(N)]
s=0
for i in range(N):
    for j in range(i+1,N):
        s+=((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5
print(s*2*math.factorial(N-1)/math.factorial(N))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin>>D;
  if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  else if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  else if(D==25){
    cout<<"Christmas"<<endl;
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=2e5+5;
ll n,k;
ll a[nxm];

bool can(ll hig,ll k)
{
    REP(i,0,n)
    {
        ll need=a[i]/hig;
        if(a[i]<=hig)
            need=1;
        else
        {
            need=a[i]/hig;

           if(a[i]%hig)
                need++;
        }
        k-=(need-1);

        if(k<0)
            return false;
    }
    return true;
}

void solve(){
cin>>n>>k;


ll maxi=0;

REP(i,0,n) cin>>a[i] , maxi=max(maxi,a[i]);


ll l= 1, r= maxi;

while(l<=r)
{
    ll mid=(l+r)/2;
    if(can(mid,k))
    {

        r=mid-1;
    }
    else
        l=mid+1;

}

cout<<l<<endl;








}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)
*/


Measured memory_bytes: 5192
N,K = map(int,input().split())
x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = map(int,input().split())

ans = float('inf')
sx = sorted(x)
sy = sorted(y)
for xi in range(N):
    for xj in range(xi+1,N):
        for yi in range(N):
            for yj in range(yi+1,N):
                lx = sx[xi]
                rx = sx[xj]
                by = sy[yi]
                uy = sy[yj]
                cnt = 0
                for i in range(N):
                    if lx <= x[i] <= rx and by <= y[i] <= uy:
                        cnt += 1
                if cnt >= K:
                    area = (rx-lx)*(uy-by)
                    ans = min(ans,area)
print(ans)

Measured memory_bytes: 50396
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int N = in.read<int>();

    for (int i : boost::irange(9, 0, -1)) {
        if (N % i) continue;
        if (N / i < 10) {
            out << "Yes";
            return 0;
        }
    }
    out << "No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int n,x,i,c=0;
    cin>>n>>x;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int b[n+1];
    b[0]=0;
    b[1]=a[0];
    for(i=2;i<n+1;i++)
    {
    	b[i]=b[i-1]+a[i-1];
	}
	for(i=0;i<n+1;i++)
    {
    	if(b[i]<=x)
    	c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MIDNIGHT 24*3600+1

using namespace std;

int read_time() {
    int h, m, s;
    cin >> h;
    cin.ignore(1);
    cin >> m;
    cin.ignore(1);
    cin >> s;
    cin.ignore(1);
    return 3600*h+60*m+s;
}

int main() {
    int n, time;
    int table[MIDNIGHT];
    while (true) {
        int count = 0;
        int max_count = 0;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<MIDNIGHT; i++) {
            table[i] = 0;
        }
        for (int i=0; i<n; i++) {
            time = read_time();
            table[time] += 1;
            time = read_time();
            table[time] -= 1;
        }
        for (int i=0; i<MIDNIGHT; i++) {
            count += table[i];
            max_count = max(count, max_count);
        }
        cout << max_count << endl;
    }
}

Measured memory_bytes: 1492
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n;
	cin >> n;

	if (n == 1)
	{
		print(0);
		return 0;
	}

	i64 ans = (n - 1) * n / 2;
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main(){
  int N;
  int a=1,b=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  while(true){
    a = vec.at(a-1);
    b += 1;
    if(a == 2){
      cout << b << endl;
      break;
    }
    if(b >= N){
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
import math
A, B, H, M = map(int, input().split())
h = H / 12 * 360 + 0.5 * M
m = M / 60 * 360
Ax = A * math.sin(math.radians(h))
Ay = A * math.cos(math.radians(h))
Bx = B * math.sin(math.radians(m))
By = B * math.cos(math.radians(m))
print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** 0.5)

Measured memory_bytes: 9580
N = int(input())
graph = [[float("inf") for _ in range(N)] for _ in range(N)]
for i in range(N):
    a_list = list(map(int, input().split()))
    for j in range(N):
        if i == j:
            continue
        graph[i][j] = a_list[j]
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
w_graph = floyd_warshall(graph, directed=False)
for i in range(N):
    w_graph[i][i] = float("inf")
result = 0
for i in range(N):
     w_graph[i][i] = float("inf")
for i in range(N):
    for j in range(i):
        if w_graph[i][j] != graph[i][j]:
            print(-1)
            exit()
        if w_graph[i][j] < np.min(w_graph[i] + w_graph[j]):
            result += w_graph[i][j]
print(int(result))


Measured memory_bytes: 31500
puts 9394,p=?+,0,1,m=9,?<,3,9,3,
[p,a=0,3,9]+(0..59).map{[p,a=4,a,a,p,a,3,6,[p,6,6,6]*(59-_1),?<,6,9,m+=1,p,a,m,a]},
[p,a=1,3,9]+(0..59).map{[p,a=5,a,a,p,a,3,6,[p,6,6,6]*(59-_1),?<,6,9,m+=1,p,a,m,a]},
(0..59).map{|m|[p,2,2,2]+(1..m).map{[p,40+m-_1,99+_1,6,?<,3,6,6,p,6,2,2]}}

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

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

    int a,b;

    for(int i=-1000; i <=1000; i++){
        for(int j=-1000; j <=1000; j++){
            if(std::pow(i,5) - std::pow(j,5) == X){
                a = i;
                b = j;
                break;
            }
        }
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 4044
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld pi=acos(-1.0);

bool kai(int n) {
	string st(to_string(n));
	for (int i = 0; i < st.size(); ++i) {
		if (st[i] != st[st.size() - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int N;cin>>N;
	pair<int,int>ans(1000000,-1);
	for (int i = 1; i < 100000; ++i) {
		if (kai(i)) {
			pair<int,int>nans((abs(N-i)),i);
			ans=min(ans,nans);
		}
	}
	cout<<ans.second<<endl;
	return 0;
}


Measured memory_bytes: 3292
N = int(input())
H = list(map(int, input().split()))
 
ans = 0
count = 0
for i in range(N-1):
    if H[i+1] <= H[i]:
        count += 1
    else:
        ans = max(count, ans)
        count = 0
 
print(max(count, ans))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m;

    cin >> n >> m;

    priority_queue<int> que;
    int tmp;

    for(int i = 0; i < n; i++) {
        cin >> tmp;
        que.push(tmp);
    }

    for(int i = 0; i < m; i++) {
        tmp = que.top();
        que.pop();
        que.push(tmp/2);
    }
    ll sum = 0;
    while(!que.empty()) {
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;
  
    return 0;
}



Measured memory_bytes: 892
#n,qの二重ループでO(10^10)でアウトでしょう
n = gets.to_i
num = gets.strip.split.map(&:to_i)
q = gets.to_i
ary = Array.new(10**5,0)
d = 0
while d < n do
  ary[num[d]-1] += 1
  d += 1
end
sum = num.sum
q.times do
  a,b = gets.strip.split.map(&:to_i)
  sum += ary[a-1]*(b-a)
  ary[b-1] += ary[a-1]
  ary[a-1] = 0
  puts sum
end

Measured memory_bytes: 22860
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define BTC 380000.0

using namespace std;

int main(){

	lli n;
	cin>>n;
	double sum=0;
	for(lli i=0;i<n;i++){
		double tmpX;
		string tmpY;
		cin>>tmpX>>tmpY;
		if(tmpY == "JPY"){
			sum += tmpX;
		}
		else{
			sum += tmpX * BTC;
		}
	}

	cout<<sum<<endl;



	return 0;
}

Measured memory_bytes: 256
#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 P[201010];
int D[202020];
int VD[202020];
vector<int> E[202020];
ll p2[202020];
ll mo=1000000007;

deque<vector<ll>> dp[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	VD[0]++;
	FOR(i,N) {
		cin>>P[i+1];
		E[P[i+1]].push_back(i+1);
		D[i+1]=D[P[i+1]]+1;
		VD[D[i+1]]++;
	}
	N++;
	
	p2[0]=1;
	FOR(i,N) p2[i+1]=p2[i]*2%mo;
	
	for(i=N-1;i>=0;i--) {
		FORR(e,E[i]) {
			if(dp[e].size()>dp[i].size()) swap(dp[e],dp[i]);
		}
		int ma=0;
		FORR(e,E[i]) {
			ma=max(ma,(int)dp[e].size());
			FOR(j,dp[e].size()) {
				ll a[3]={};
				a[0]=dp[i][j][0]*dp[e][j][0]%mo;
				a[1]=(dp[i][j][0]*dp[e][j][1]+dp[i][j][1]*dp[e][j][0])%mo;
				a[2]=(dp[i][j][2]*(dp[e][j][0]+dp[e][j][1])+dp[i][j][1]*dp[e][j][1])%mo;
				dp[i][j][0]=a[0];
				dp[i][j][1]=a[1];
				dp[i][j][2]=a[2];
			}
		}
		FOR(j,ma) {
			(dp[i][j][0]+=dp[i][j][2])%=mo;
			dp[i][j][2]=0;
		}
		
		dp[i].push_front({1,1,0});
	}
	
	ll ret=0;
	FOR(i,dp[0].size()) ret+=dp[0][i][1]*p2[N-VD[i]]%mo;
	cout<<ret%mo<<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: 248176
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

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 mod = 1e9 + 7;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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

	int N;
	cin >> N;


	ll kotae = modpow(10, N) + modpow(8, N) - modpow(9, N) - modpow(9, N);

	kotae %= mod;
	kotae += mod;

	co(kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
typedef long long ll;
typedef long double ld;
using namespace std;

 
int main() {
    string s;
    cin >> s;
    for (int i = 0; i<3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> v;
	rep(i,n){
		if(s[i] == 'R'){
			v.pb(i);
		}
	}
	int m = v.size();
	if(m == n || m == 0){
		cout << "0" << endl;
		return 0;
	}
	int j = m-1, cnt = 0;
	rep(i,n){
		if(s[i] == 'W' && v[j] > i){
			cnt++;
			j--;
		}
		if(j < 0){
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4504
n = int(input())
a = list(map(int, input().split()))
b = [[i] for i in a]

for j in range(n):
    for i in range(1<<n):
        if i & (1<<j):
            b[i] = sorted(b[i]+b[i^1<<j], reverse=True)[:2]
ans = []
tmp = 0
for i in range(1, 1<<n):
    tmp = max(tmp, sum(b[i]))
    ans.append(tmp)
print(*ans, sep="\n")

Measured memory_bytes: 157708
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n,m;
	cin>>n>>m;
	int k;
	cin>>k;
	int cnt=0;
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			cnt++;
		}
	}	
	cout<<cnt<<endl;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MN 100005
int T,num,dep[MN],n,id[MN],head[MN];
ll a[MN];
map<ll,int>rea,cnt;
struct node{int x,y;};
vector<node>sc;
struct edge{int to,next;}g[MN<<1];
bool cmp(int x,int y){return a[x]>a[y];}
void ins(int u,int v){g[++num].next=head[u];head[u]=num;g[num].to=v;}
void dfs(int u,int ff){
	for(int i=head[u];i;i=g[i].next)if(g[i].to!=ff){
		dep[g[i].to]=dep[u]+1,dfs(g[i].to,u);
	}
}
int main(){
//	freopen("test.in","r",stdin);
//	freopen("mysol.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),rea[a[i]]=i,cnt[a[i]]=1,id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<n;i++){
		int t=id[i];ll tmp=a[t]-n+2*cnt[a[t]];
		if(rea[tmp]&&tmp<a[t]){
			cnt[tmp]+=cnt[a[t]];
			sc.push_back((node){t,rea[tmp]});
		}
		else return 0*puts("-1");
	}
	for(int i=0;i<sc.size();i++)ins(sc[i].x,sc[i].y),ins(sc[i].y,sc[i].x);
	dfs(id[n],id[n]);ll tans=0;
	for(int i=1;i<=n;i++)tans+=dep[i];
	if(tans!=a[id[n]])return 0*puts("-1");
	for(int i=0;i<sc.size();i++)printf("%d %d\n",sc[i].x,sc[i].y);
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,u,v,m;
int uc[555],ur[555],nc[555],nr[555],ucros[2],ncros[2];
map<int,P> usa,neko;
int card[100010];

int main(){
	scanf("%d%d%d%d",&n,&u,&v,&m);
	rep(i,n)rep(j,n){
		int a;
		scanf("%d",&a);
		usa[a]=P(i,j);
	}
	rep(i,n)rep(j,n){
		int a;
		scanf("%d",&a);
		neko[a]=P(i,j);
	}
	rep(i,m)scanf("%d",card+i);
	int ucnt=0,ncnt=0;
	rep(i,m){
		int a=card[i];
		if(usa.count(a)){
			uc[usa[a].fi]++;
			if(uc[usa[a].fi]==n)ucnt++;
			ur[usa[a].se]++;
			if(ur[usa[a].se]==n)ucnt++;
			if(usa[a].fi==usa[a].se){
				ucros[0]++;
				if(ucros[0]==n)ucnt++;
			}
			if(usa[a].fi+usa[a].se==n-1){
				ucros[1]++;
				if(ucros[1]==n)ucnt++;
			}
		}
		if(neko.count(a)){
			nc[neko[a].fi]++;
			if(nc[neko[a].fi]==n)ncnt++;
			nr[neko[a].se]++;
			if(nr[neko[a].se]==n)ncnt++;
			if(neko[a].fi==neko[a].se){
				ncros[0]++;
				if(ncros[0]==n)ncnt++;
			}
			if(neko[a].fi+neko[a].se==n-1){
				ncros[1]++;
				if(ncros[1]==n)ncnt++;
			}
		}
		//dbg(ucnt); dbg(ncnt);
		if(n==1){
			minch(ucnt,1);
			minch(ncnt,1);
		}
		if(ucnt>=u&&ncnt>=v){
			printf("DRAW\n"); return 0;
		}else if(ucnt>=u){
			printf("USAGI\n"); return 0;
		}else if(ncnt>=v){
			printf("NEKO\n"); return 0;
		}
	}
	printf("DRAW\n");
	return 0;
}

Measured memory_bytes: 21136
#include<iostream>
using namespace std;
int main(){
    int m[4][3][10]={};
    int n,b,f,r,v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        m[b-1][f-1][r-1]+=v;
    }
    for(int x=0;x<4;x++){
        for(int y=0;y<3;y++){
            for(int z=0;z<10;z++){
                cout<<" "<<m[x][y][z];
            }
            cout<<endl;
        }
        if(x!=3) cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;
const int MAX = 510000;

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

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve(int N, int M) {
  ll res = 0;
  rep(d, 1, N) {
    res += (ll)d * (N - d) * M * M;
    res %= MOD;
  }
  return res;
}

int main() {
  COMinit();
  int N, M, K;
  cin >> N >> M >> K;
  ll ans = solve(N, M) + solve(M, N);
  ans *= COM(N * M - 2, K - 2);
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <set>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int c[3];
    int d[3];
    int e[3];

    cin >> c[0] >> c[1] >> c[2];
    cin >> d[0] >> d[1] >> d[2];
    cin >> e[0] >> e[1] >> e[2];

    if(!(c[0]-d[0] == c[1]-d[1] && c[0]-d[0] == c[2]-d[2]))
    {
        cout << "No" << "\n";
    }
    else if(!(c[0]-e[0] == c[1]-e[1] && c[0]-e[0] == c[2]-e[2]))
    {
        cout << "No" << "\n";
    }
    else
    {
        cout << "Yes" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n: usize = get();
    let m: usize = get();
    let q: usize = get();
    let mut s = vec![Vec::new(); n];
    for i in 0 .. n {
        s[i] = get_word().chars().map(|x| (x as u8 - 0x30) as i32).collect();
    }
    let mut acc = vec![vec![0; m + 1]; n + 1];
    let mut link1 = vec![vec![0; m + 1]; n + 1];
    let mut link2 = vec![vec![0; m + 1]; n + 1];
    for i in 0 .. n {
        for j in 0 .. m {
            acc[i + 1][j + 1] = acc[i + 1][j] + acc[i][j + 1] - acc[i][j]
                + s[i][j];
            link1[i + 1][j + 1] = link1[i + 1][j] + link1[i][j + 1]
                - link1[i][j];
            link2[i + 1][j + 1] = link2[i + 1][j] + link2[i][j + 1]
                - link2[i][j];
            if j < m - 1 && s[i][j] == 1 && s[i][j + 1] == 1 {
                link1[i + 1][j + 1] += 1;
            }
            if i < n - 1 && s[i][j] == 1 && s[i + 1][j] == 1 {
                link2[i + 1][j + 1] += 1;
            }
        }
    }
    for _ in 0 .. q {
        let x1: usize = get::<usize>() - 1;
        let y1: usize = get::<usize>() - 1;
        let x2: usize = get();
        let y2: usize = get();
        let cell = acc[x2][y2] - acc[x1][y2] - acc[x2][y1] + acc[x1][y1];
        let l1 = link1[x2][y2 - 1] - link1[x1][y2 - 1] - link1[x2][y1]
            + link1[x1][y1];
        let l2 = link2[x2 - 1][y2] - link2[x1][y2] - link2[x2 - 1][y1]
            + link2[x1][y1];
        println!("{}", cell - l1 - l2);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 75644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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






int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int l,r,d;
    cin >> l >> r >> d;
    int ans = r/d-l/d;
    if(l%d == 0){
        ans ++;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3568
#include<stdio.h>
#define MAX 200000

int partition(int A[], int n, int p, int r){
    int i,j;
    int x,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){  //xより小さいとき
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

void quickSort(int A[], int n, int p, int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}

int main(void){
    int n,c,k,i,cnt=1,ans=1,temp;
    scanf("%d%d%d",&n,&c,&k);
    int T[n];
    
    for(i=0;i<n;i++){
        scanf("%d",&T[i]);
    }
    
    quickSort(T,n,0,n-1);
    temp = T[0];
    
    for(i=1;i<n;i++){
        if(cnt<c && T[i]<= temp +k){ //乗れるとき
            cnt++;
        }else{
            ans++;
            temp = T[i];
            cnt = 1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        long a = Integer.parseInt(st.nextToken()),
                b = Integer.parseInt(st.nextToken()),
                c = Integer.parseInt(st.nextToken()),
                d = Integer.parseInt(st.nextToken()),
                max = Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d));

        if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) {
            max = Math.max(max, 0);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 25364
/**
*    author:  yuya1234
*    created: 08.07.2020 14:13:33
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n,m;
  cin>>n>>m;

  ll a[50][2],c[50][2];
  REP(i,n)cin>>a[i][0]>>a[i][1];
  REP(i,m)cin>>c[i][0]>>c[i][1];

  ll amin,ans;
  REP(i,n)
  {
    amin=INT_MAX;
    ans=0;
    REP(j,m)
    {
      if(amin>abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]))
      {
        amin=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
        ans=j+1;
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<ll> MARCH(5, 0);

    for(int i=0; i<N; i++) {
        string s;
        cin >> s;
        if(s[0] == 'M') MARCH[0]++;
        else if(s[0] == 'A') MARCH[1]++;
        else if(s[0] == 'R') MARCH[2]++;
        else if(s[0] == 'C') MARCH[3]++;
        else if(s[0] == 'H') MARCH[4]++;
    }

    ll ans = 0;
    for(int i=0; i<5; i++) {
        for(int j=i+1; j<5; j++) {
            for(int k=j+1; k<5; k++) {
                ans += MARCH[i] * MARCH[j] * MARCH[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
//  LINK ZADATKA: http://abc069.contest.atcoder.jp/tasks/arc080_a

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;


#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9
ll n, a, br4, br2, br0;
int main(){


	
	scanf("%lld", &n);
	REP(i, n){
		scanf("%lld", &a);
		if(a%4 == 0) br4++;
		else if(a%2 == 0) br2++;
		else br0++;
	}
	//printf("%lld %lld %lld\n", br4, br2, br0);
	br2 %= 2;
 	br0 -= (br4+1);
	if(br0 < 0){
		br0 = 0;
		br2--;
		if(br2 < 0) br2 = 0;
	}
	if(br0 == 0 && br2 != 1) printf("Yes\n"); 
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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 (B / A >= C) {
      System.out.println(C);
    } else {
      System.out.println(B/A);
    }
  }
}

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

typedef long long ll;
ll N, ans = 0;

void dfs(ll x, bool a, bool b, bool c){
  if (x > N) {
    return;
  }
  if(a && b && c) {
    ans++;
  }

  dfs(10 * x + 3, true, b, c);
  dfs(10 * x + 5, a, true, c);
  dfs(10 * x + 7, a, b, true);
}

int main() {
  cin >> N;
  
  dfs(0, false, false, false);
  cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;
	setIO();
	cin >> n;
	map<int,int> cnt;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		cnt[x]++;
	}
	for(auto it : cnt) {
		if(it.second >= it.first) ans += it.second - it.first;
		else ans += it.second;
	}
	cout << ans;

	return Accepted;
}

// B...a

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


string bar(int len) {
    if (len <= 0) {
        return "-";
    }
    string ret = "";
    for (int i=0; i<len; ++i) {
        ret += "*";
    }
    return ret;
}

int main() {
    int n, a;
    while (cin >> n, n) {
        vector<int> num(10, 0);
        for (int i=0; i<n; ++i) {
            cin >> a;
            num[a] ++;
        }
        for (int i=0; i<10; ++i) {
            cout << bar(num[i]) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1216
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    s = []
    for i in range(N):
        s.append(int(input().rstrip()))
    dp = []
    for i in range(N):
        dp.append([-1]*(100*100))
    dp[0][s[0]] = 1
    for i in range(1,N):
        for j in range(100*100):
            if(j == s[i] or (j-s[i]>=0 and dp[i-1][j-s[i]]==1)):
                dp[i][j] = 1
            else:
                dp[i][j] = dp[i-1][j]
    ans = 0
    # print('\n'.join(str(_) for _ in(dp[N-1])))
    for i in range(100*100-1,0,-1):
        if(i%10 != 0 and dp[N-1][i]==1):
            ans = i
            break
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 11488
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    Q=I()
    for _ in range(Q):
        S=ST()
        T=ST()[::-1]
        lis = []
        find, append = T.find, lis.append

        for c in S:
            i = find(c)+1
            while i:
                j = bisect_left(lis, -i)
                if j >= len(lis):
                    append(-i)
                else:
                    lis[j] = -i
                i = find(c, i)+1
        print(len(lis))
if __name__ == '__main__':
    main()


Measured memory_bytes: 6416
while True:
    N=input()
    if N==0:break
    L=[[0]*21 for i in range(21)]
    init=[[0]*21 for i in range(21)]
    for i in range(N):
        x,y=map(int,raw_input().split())
        L[y][x]=1
    M=input()
    nowX,nowY=10,10
    for i in range(M):
        d,l=raw_input().split()
        if d=="N":
            for j in range(int(l)):
                nowY+=1
                L[nowY][nowX]=0
        elif d=="S":
            for j in range(int(l)):
                nowY-=1
                L[nowY][nowX]=0
        elif d=="W":
            for j in range(int(l)):
                nowX-=1
                L[nowY][nowX]=0
        elif d=="E":
            for j in range(int(l)):
                nowX+=1
                L[nowY][nowX]=0
    print "Yes" if L==init else "No"

Measured memory_bytes: 4276
N,M=map(int,input().split())
par=[0 for i in range(N)]
rnk=[0 for i in range(N)]
def init(n):
    for i in range(N):
        par[i]=i
        rnk[i]=0
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if (rnk[x]<rnk[y]):
        par[x]=y
    else:
        par[y]=x
        if(rnk[x]==rnk[y]):
            rnk[x]+=1
def same(x,y):
    return find(x)==find(y)

p=[int(i)-1 for i in input().split()]
init(N)
for i in range(M):
    x,y=map(int,input().split())
    unite(x-1,y-1)
ans=0
for i in range(N):
    if same(i,p[i]):
        ans+=1
print(ans)


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

using namespace std;

const int MAX_HW = 1234;
int h, w;
long long dp[MAX_HW][MAX_HW];
char a[MAX_HW][MAX_HW];

int main() {
    
    cin >> h >> w;

    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> a[i][j];

    dp[0][0] = 1;

    for (int i = 1; i < h; ++i) {
        if (a[i][0] != '#')
            dp[i][0] = dp[i - 1][0];

        else
            dp[i][0] = 0;
    }

    for (int i = 1; i < w; ++i) {
        if (a[0][i] != '#')
            dp[0][i] = dp[0][i - 1];

        else
            dp[0][i] = 0;
    }

    for (int i = 1; i < h; ++i)
        for (int j = 1; j < w; ++j)
            if (a[i][j] == '#')
                dp[i][j] = 0;

            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;

    cout << dp[h - 1][w - 1] << endl;
    return 0;
}


Measured memory_bytes: 14444
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int K,N;
    cin>>K>>N;
    int ans=0;

    vector<int>A(N);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    B[0]=K-A[N-1]+A[0];
    for(int i=1;i<N;i++){
        B[i]=A[i]-A[i-1];
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    for(int i=0;i<N;i++){
        ans+=B[i];
    }
    cout<<ans-B[0]<<endl;
}

Measured memory_bytes: 6404
def main():
    n,m = map(int,input().split())
    maze=[]
    for _ in range(n):
        maze.append(list(input()))
    cnt=0
    for i in range(n):
        for j in range(m):
            if maze[i][j]=="#":
                cnt+=1
    if cnt==n+m-1:print("Possible")
    else:print("Impossible")
    
main()

Measured memory_bytes: 38384
from collections import deque


def main():
    input()  # n
    array = [int(x) for x in input().split()]
    array.sort()
    coming = deque(array)

    edges = deque()
    new = coming.pop()
    edges.append(new)
    ans = 0
    while coming:
        ans += edges.popleft()
        new = coming.pop()
        edges.append(new)
        edges.append(new)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int x[n],y[n];
  rep(i,n)cin >> x[i] >> y[i];
  double ans = 0;
  rep(j,n)rep(i,j){
    double difx = x[i]-x[j];
    double dify = y[i]-y[j];
    double d = sqrt(difx*difx+dify*dify);
    ans += d*2.0/double(n);
  }
  printf("%.12f\n",ans);
}


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

 int main(){

   int x;
   cin>>x;

   // 整数どうしの割り算は少数点が切り捨てられます
   // X%60 で Xを60で割ったあまりを計算できます
   int h = x / 3600;
   int m = (x / 60) % 60;
   int s = x % 60;
   cout<<h<<":"<<m<<":"<<s<<endl;
   
   return 0;
 }
  



Measured memory_bytes: 3116