akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

constexpr static int MAXN = 1e6 + 10;
constexpr static int MOD = 1e9 + 7;

int64_t f[MAXN], inv[MAXN], finv[MAXN];
int64_t cnt[MAXN]; // cnt[k] is score at most k

int64_t choose(int n, int k) {
    return f[n] * finv[k] % MOD * finv[n - k] % MOD;
}

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

    f[0] = 1;
    for (int i = 1; i <= n; i++)
        f[i] = i * f[i - 1] % MOD;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i <= n; i++) {
        // i*q + r = MOD
        // i*q = -r
        // q = -r * i^{-1}
        // i^{-1} = -q * r^{-1}
        inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
        finv[i] = inv[i] * finv[i - 1] % MOD;
    }

    // score <= k, 1 = a1 < a2 < ... < ak = n, consecutive diff 1 or 2
    // k choices, place n - k + 1 ones in any of the k - 1 slots
    for (int k = 0; k <= n; k++) {
        if (k - 1 < n - k)
            continue;
        cnt[k] = choose(k - 1, n - k) * f[k] % MOD * f[n - k] % MOD;
        // cout << k << " " << cnt[k] << endl;
    }
    int64_t total = 0;
    for (int k = 1; k <= n; k++) {
        total += (cnt[k] - cnt[k - 1] + MOD) * k;
        total %= MOD;
    }
    cout << total << endl;
}


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

//educational DP contest S
template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};
const int pri=1000000007;
ModInt<pri> dp[10000+1000][2][200];


signed main(){
	string S; int D; cin>>S>>D;
	dp[0][0][0]=1;
	int N=S.size();
	for(int i=0;i<N;i++){
		for(int smaller=0;smaller<2;smaller++){
			for(int j=0;j<=D;j++){
				for(int x=0;x<=(smaller ? 9 : S[i]-'0');x++){
					dp[i+1][smaller or x<(S[i]-'0')][(j+x)%D]+=dp[i][smaller][j];
				}
			}
		}
	}
	cout<<dp[N][0][0]+dp[N][1][0]-1<<endl;
}

Measured memory_bytes: 34688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int ao=0;
		int bh=0;
		int ab=0;
		int no=0;
		String[] s=new String[N];
		for(int i=0; i<N; i++) {
			s[i]=sc.next();
			if(s[i].charAt(0)=='B' && s[i].charAt(s[i].length()-1)=='A') {
				ab++;
			}
			else if(s[i].charAt(0)=='B' && s[i].charAt(s[i].length()-1)!='A') {
				bh++;
			}
			else if(s[i].charAt(s[i].length()-1)=='A' && s[i].charAt(0)!='B') {
				ao++;
			}
			else {
				no++;
			}
		}
		int add=0;
		if(ab==0) {
			add=Math.min(ao, bh);
		}
		else {
			if(ao+bh>0) {
				add=ab+Math.min(ao, bh);
			}
			else {
				add=Math.max(ab-1,0);
			}
		}
		int base=0;
		for(int i=0; i<N; i++) {
			int nagasa=s[i].length();
			for(int j=0; j<nagasa-1; j++) {
				if(s[i].charAt(j)=='A' && s[i].charAt(j+1)=='B') {
					base++;
				}
			}
		}
		pl(base+add);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
}


Measured memory_bytes: 24148
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		int sum = 0;
		for(int i = 1; i < n; i++){
			if(n % i == 0){
				if(i > n/i) break;
				if(i != n/i) sum += i + (n/i);
				else sum += i;
			}
		}
		sum -= n;
		cout << (sum == n ? "perfect number" : sum > n ? "abundant number" : "deficient number") << endl;
	}
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

class BinaryIndexTree {
public:
    BinaryIndexTree(int n)
            : mN(n) {
        mPow = 1;
        while (mPow < n)
            mPow <<= 1;
        node.resize(n + 1);
        REP(i, n + 1) {
            node[i] = 0;
        }
    }

    ~BinaryIndexTree() {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index) {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value) {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

    int lowerBound(ll value) {
        if (value <= 0)
            return 0;
        int x = 0;
        for (int k = mPow; k > 0; k >>= 1) {
            if (x + k <= mN && node[x + k] < value) {
                value -= node[x + k];
                x += k;
            }
        }
        return x + 1;
    }

private:
    vector<ll> node;
    ll mN;
    ll mPow;
};

int main() {
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }

    vector<ll> v;
    v.push_back(0);
    {
        ll s = 0;
        REP(i, N) {
            s += A[i] - K;
            v.push_back(s);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    ll ans = 0;
    BinaryIndexTree bit(v.size());
    bit.add(lower_bound(v.begin(), v.end(), 0) - v.begin() + 1, 1);
    {
        ll s = 0;
        REP(i, N) {
            s += A[i] - K;
            ll index = lower_bound(v.begin(), v.end(), s) - v.begin() + 1;
            ans += bit.sum(index);
            bit.add(index, 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, K;
string S;

int main() {
  cin >> N;
  vi h(N);
  rep(i, N){
    cin >> K;
    h[K-1] = i+1;
  }
  rep(i, N){
    print(h[i]);
  }
}

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

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h , vector<char>(w));
    vector<bool> h_det(h),w_det(w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a.at(i).at(j);
        }
    }
    int h_a = h;
    int w_a = w;

    for(int i = 0; i < h; i++){
        bool det = false;
        for(int j = 0; j < w; j++){
            if(a.at(i).at(j) == '#')det = true;
        }
        h_det.at(i) = det;
    }
    for(int i = 0; i < w; i++){
        bool det = false;
        for(int j = 0; j < h; j++){
            if(a.at(j).at(i) == '#')det = true;
        }
        w_det.at(i) = det;
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(h_det.at(i) && w_det.at(j))cout << a.at(i).at(j);
        }
        if(h_det.at(i))cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll solve(ll N);

int main(){
  ll N; cin>>N;
  ll ans = 0;

  map <ll,ll> z = prime_factor(N);

  for(auto itr = z.begin();itr != z.end();itr++){
    auto nz = (*itr);
    ll a = nz.second;

    ll mn = (sqrt(2 * a));

    for(ll i = mn;;mn++){
      if(mn * (mn + 1) > 2*a){
        mn--;
        break;
      }
    }
    ans += mn;

  }
  cout<<ans<<endl;

 


 

  return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>
int a,b,c,k,i,r;
int main(){
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<=a)printf("%d",k);
    else if(k<=a+b)printf("%d",a);
    else printf("%d",a-(k-a-b));
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    int n,m;

    cin >> n >> m;

    vector<int> a(n+1);

    for(int i = 0;i < m;i++)
    {
        int x,y;
        cin >> x >> y;
        a[x]++;
        a[y]++;
    }

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


Measured memory_bytes: 256
#include <iostream>
	#include <string>
	using namespace std;
	int main()
	{
		string s;
		cin >> s;
	
		if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] || s[1] == s[2] && s[0] == s[3] && s[1] != s[0] || s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes";
		else cout << "No";
		return 0;
	}

Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
  int n,m;cin>>n>>m;int co=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a>=m){
        co++;
    }
  }
  cout<<co<<endl;
over
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint A(N);rep(i,N)cin>>A[i];
    rep(i,N)A[i]-=i;
    sort(all(A));
    int ans=0;
    rep(i,N)ans+=abs(A[i]-A[N/2]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	int n;
	re(n);
	int arr[n];
	for(int i=0; i <n; i++)
	{
		re(arr[i]);
	}
	sort(arr,arr+n);
	if(arr[n/2 - 1] == arr[n/2])
	{
		cout<<0;
	}
	else
	{
		cout<<arr[n/2] - arr[n/2 - 1]<<"\n";
	}
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	ll H[N];
	
	for(int i=0; i<N; i++)
		cin >> H[i];
	
	bool fr = true;
	for(int i=1; i<N; i++){
		if(H[i-1] < H[i])
			fr = false;
		else if(!fr && H[i-1] == H[i])
			fr = false;
		if(H[i-1] >  H[i]){
			H[i-1]--;
			if(!fr && H[i-1] == H[i]){
				fr = true;
				continue;
			}
			if(H[i-1] >  H[i]){
				cout << "No";
				return 0;
			}else if(i >= 2 && H[i-2] > H[i-1]){
				cout << "No";
				return 0;
			}
		}
	}
	
	cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

vector<bool> used(200000,false);
vvec G(200000);
vector<string> s;
int h,w;
int cnt=0,cnt2=0;
void dfs(int now){
    used[now]=true;
    int x=now/w;
    int y=now%w;
    if(s[x][y]=='#') cnt2++;
    else cnt++;
    for(auto next:G[now]){
        if(used[next]) continue;
        dfs(next);
    }
    return;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    cin>>h>>w;
    s.resize(h);
    rep(i,h){
        cin>>s[i];
    }

    rep(i,h){
        rep(j,w){
            rep(k,4){
                if(range(i+dx[k],0,h)&&range(j+dy[k],0,w)){
                if(s[i][j]!=s[i+dx[k]][j+dy[k]]){
                    G[i*w+j].pb((i+dx[k])*w+j+dy[k]);
                }
                }
            }
        }
    }

    ll ans=0;
    rep(i,h){
        rep(j,w){
            int nu=i*w+j;
            if(used[nu]) continue;
            cnt=0;cnt2=0;
            dfs(nu);
            ans+=cnt*cnt2;
        }
    }
    cout<<ans<<endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int f[] = new int[n];
        for (int i = 0; i < n; i++) {
            f[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(f);

        long max = a[n - 1] * (long) f[n - 1];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i] * f[n - 1 - i];
        }
        ans = nibutan(a, f, 0, max, k);
        if (ans != 0) {
            // ans++;
        }
        System.out.println(ans);

        sc.close();
    }

    // l , r , m => answer
    static long nibutan(int arr[], int frr[], long l, long r, long rem) {
        long m = (l + r) / 2;
        // System.out.println(m);
        int len = arr.length;
        long wa = 0;
        if (m == l) {
            if (m == 0) {
                return 0;
            }
            return r;
        }
        for (int i = 0; i < len; i++) {
            long tmp = m / frr[len - 1 - i];
            if (arr[i] - tmp > 0) {
                wa += arr[i] - tmp;
            }
        }
        if (wa > rem) {
            return nibutan(arr, frr, m, r, rem);
        } else {
            return nibutan(arr, frr, l, m, rem);
        }
    }
}


Measured memory_bytes: 94804
/**
 *    author:  zjsdut
 *    created: 2020/03/23 10:46:01
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL && !defined DUIPAI
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n, m;
  scan(n, m);
  println(n * (n - 1) / 2 + m * (m - 1) / 2);
  return 0;
}

Measured memory_bytes: 256
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

vector<ll>g[maxx];
ll vis[maxx];
ll cnt=0; 
 

void dfs(ll u)
{
	vis[u]=1;
	cnt++;
	
	for(auto j:g[u])
	{
		if(!vis[j])
		{
			dfs(j);
		}
	}
}
 
 
int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	ll i;
	ll u,v;
	for(i=0;i<m;i++)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	ll ans=0;
	
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			cnt=0;
			dfs(i);
		}
		ans=max(ans,cnt);
	}
	
	cout<<ans<<endl;
	
	return 0;
}
     
 
     

Measured memory_bytes: 22384
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
const ll inf = 1e15;
using namespace std;

int main()
{
	FastIO;
	ll a,b,c,d, co, t, i, j, k, n;
	cin >> n>>k;
	f(i, n)
	{
		cin >> b;
	}
	if (n <= k)
		cout << 1 << endl;
	else
	{
		n = n - k;
		k--;
		cout << ceil((float)n / (float)k)+1<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var x = 0;
        for (int i = 0; i < N; i++)
        {
            var a = sc.ReadInt();
            if (i == 0) x = a;
            else x ^= a;
        }
        var ans = x == 0 ? "Yes" : "No";
        Console.WriteLine(ans);
    }
    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 23392
#include <iostream>
#include <stdlib.h>

using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((abs(b-a) <= d and abs(c-b) <= d) or abs(a-c)<=d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i

divs = lambda {|n|
  fs = []

  k = 1
  while k*k <= n
    if k*k == n
      fs << k
    elsif n % k == 0
      fs << k
      fs << n / k
    end
    k += 1
  end
  return fs
}

cnt = divs.call(n-1).size - 1

divs.call(n).each do |k|
  next if k == 1
  x = n
  while x % k == 0
    x /= k
  end

  if x % k == 1
    cnt += 1
  end
end

p cnt


Measured memory_bytes: 14376
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		char c[] = fs.next().toCharArray();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = c[i] - '0';
		}
		boolean zerostart = false;
		if(a[0] == 0)zerostart = true;
		
		List<Integer> ls = new ArrayList<>();
		int cnt = 0;
		int before = -1;
		for(int i = 0;i<n;i++) {
			if(a[i] == before)cnt++;
			else {
				if(i!=0)ls.add(cnt);
				cnt = 1;
				before = a[i];
			}
		}
		ls.add(cnt);
		int len = ls.size();
		int zeronum = 0;
		if(zerostart) {
			zeronum = (len+1)/2;
		}
		else {
			zeronum = len/2;
		}
		
		if(zeronum <= k) {
			System.out.println(n);
			return;
		}
		
		int sum[] = new int[len+1];
		for(int i=0;i<len;i++) sum[i+1] = sum[i] + ls.get(i);
		
		int ans = 0;
		if(!zerostart) {
			for(int i=0;i<len;i+=2) {
				if(i + 2 * k < len) {
					ans = Math.max(ans, sum[2 * k + i + 1] - sum[i]);
				}
			}
		}
		else {			
			//先頭の0を含む場合
			ans = Math.max(ans, sum[2 * k]);
			//先頭の0を含まない場合
			for(int i=1;i<len;i+=2) {
				if(i + 2 * k < len) {
					ans = Math.max(ans, sum[2 * k + i + 1] - sum[i]);
				}
			}
			
		}
		
		//末尾が0で終わる場合
		if(a[n-1]==0) {
			ans = Math.max(ans, sum[len] - sum[len-2*k]);
		}
		
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    sort(begin(a), end(a));
    sort(begin(b), end(b));
    sort(begin(c), end(c));

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (upper_bound(begin(a), end(a), b[i] - 1) - begin(a)) * (end(c) - upper_bound(begin(c), end(c), b[i]));
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s[3];
  for(int i=0;i<3;i++){
    cin >> s[i];
  }
    int t=0;
    while(true){
      if(s[t].empty()){
        cout << char('A'+ t) << endl;
        return 0;
      }
      char c =s[t][0];
      s[t].erase(s[t].begin());
      t = c -'a';
    }

  }


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,m,sz,cnt;
vector<int>g[100005]; 
int col[100005],id[100005];
void dfs(int x,int ind){
	sz++;
	for(auto to:g[x]){
		if(!col[to]){
			col[to]=3-col[x];
			id[to]=ind;
			dfs(to,ind);
		}
	}
}
bool bin[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int tot=0;
	for(int i=1;i<=n;i++){
		if(!col[i]){
			col[i]=1;
			id[i]=++tot;
			sz=0;
			dfs(i,tot);
			if(sz==1)cnt++;
		}
	}
	for(int i=1;i<=tot;i++)bin[i]=1;
	for(int i=1;i<=n;i++){
		for(auto to:g[i]){
			if(col[i]==col[to]){
				bin[id[i]]=0;
			}
		}
	}
	int cnt1=-cnt,cnt2=0;
	for(int i=1;i<=tot;i++){
		if(bin[i])cnt1++;
		else cnt2++;
	}
	cout<<(ll)n*n-(ll)(n-cnt)*(n-cnt)+(ll)(tot-cnt)*(tot-cnt)+(ll)cnt1*cnt1<<endl;
	return 0;
}

Measured memory_bytes: 10368
/*
 * ITP1_7_D.cpp
 *
 *  Created on: 2016/05/21
 *      Author: suna
 */

#include <iostream>
#include <vector>

using namespace std;

//row * colの行列を生成
void generateVector(int row, int col, vector< vector<unsigned long> > *v)
{
	v->resize(row);
	for(int i = 0; i < row; i++)
	{
		(*v)[i].resize(col);
	}
}

//row * colの行列への値入力
void inputVector(int row, int col, vector< vector<unsigned long> > *v)
{
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < col; j++)
		{
			cin >> (*v)[i][j];
		}
	}
}

//row * colの行列の値出力
void outputVector(int row, int col, vector< vector<unsigned long> > *v)
{
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < col; j++)
		{
			cout << (*v)[i][j];

			if(j != col-1)
			{
				cout << " ";
			}
		}
		cout << endl;
	}
}

int main(void)
{
	//行，列, 掛ける行列の列数
	int n, m, l;

	vector< vector<unsigned long> >vec_A;	//行列A
	vector< vector<unsigned long> >vec_B;	//行列B
	vector< vector<unsigned long> >vec_AB; //A×Bの行列

	//行，列数の入力
	cin >> n >> m >> l;

	//行列の生成
	generateVector(n, m, &vec_A);
	generateVector(m, l, &vec_B);
	generateVector(n, l, &vec_AB);

	//行列への値入力
	inputVector(n, m, &vec_A);
	inputVector(m, l, &vec_B);

	//行列の積を計算
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < l; j++)
		{
			unsigned long sum_tmp = 0;
			for(int k = 0; k < m; k++)
			{
				sum_tmp += vec_A[i][k] * vec_B[k][j];
			}
			vec_AB[i][j] = sum_tmp;
		}
	}

	//行列の積を出力
	outputVector(n,l, &vec_AB);
	return 0;
}



Measured memory_bytes: 3216
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			h[i] = saori.saori_hayami();
		}
		int ans = 0;
		int num = 0;
		for(int i = 0;i < n-1;i++){
			if(h[i] >= h[i+1]){
				num++;
			} else {
				ans = Math.max(ans, num);
				num = 0;
			}
		}
		ans = Math.max(ans, num);
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long



signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

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

 
        int n;
        cin>>n;
        cout<<(1000-n%1000)%1000<<endl;
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

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

        int N = Integer.parseInt(s.next());
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(s.next());
        }

        int ans = 0;
        int active = 0;

        for (int i = 0; i < N; i++) {
            if (active >= h[i]) {
                active = h[i];
            } else {
                ans += h[i] - active;
                active = h[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
A = list(map(int, input().split()))

B = [[] for _ in range(m)]
for i in range(m):
    B[i] = list(map(int, input().split()))
B.sort(key=lambda x: -x[1])

_A = []
cnt = 0
for i in range(m):
    _A.extend([B[i][1]]*B[i][0])
    cnt += B[i][0]
    if cnt > n:
        break
A += _A
A.sort(reverse=True)
print(sum(A[:n]))

Measured memory_bytes: 36044
N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())
mi = float('inf')
for i, x in enumerate(H):
  d = abs(A - (T - 0.006 * x))
  if d < mi:
    ans = i + 1
    mi = d
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue>
#include<cmath>
#include<utility>
#include<set>
#include<cmath>
#define MOD 998244353
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, nb=0, x;
    cin >> n;
    int k = 1;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        if(x==k)
            k++;
        else
            nb++;
    }
    if(nb < n)
        cout << nb << '\n';
    else
        cout << "-1\n";
}

Measured memory_bytes: 256
find'::Eq a=>a->[] a->Int
find' x [] = 0
find' x (y:ys) =
  if y == x
    then 0
    else 1 + find' x ys
split::Char->String->[] String
split x [] = []
split x ys = take n ys : (split x (drop (n+1) ys))
  where
    n = find' x ys
toInt::String->Int
toInt = read
maxProf::Int->[] Int->Int
maxProf mini (x:[]) = x - mini
maxProf mini (x:xs) =
  max (x - mini) (maxProf (min x mini) xs)
main = do
  getLine
  getContents >>=
    print.(maxProf (2*10^9::Int)).(map toInt).(split '\n')


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=1,ans=0,a[10000000],b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n;
       rep(i,n)cin>>a[i];
       sort(a,a+n);
       rep(i,n){
           if(a[i]==a[i+1]&&fl){
               cnt=0;
               fl=false;
           }
           else if(a[i]==a[i+1]&&!fl){
               cnt=1;
               fl=true;
           }
           else{
               ans+=cnt;
               fl=true;
               cnt=1;
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) printf("a < b\n");
	else if (a > b) printf("a > b\n");
	else if (a == b) printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 火 11/ 8 16:49:06 2016

# Usage
#
"""
def read_input():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())

    return N, K, X, Y


def check_sum(N, K, X, Y):
    """
    >>> check_sum(5, 3, 10000, 9000)
    48000
    >>> check_sum(2, 3, 10000, 9000)
    20000
    """
    if N > K:
        return K * X + (N-K)*Y
    else:
        return N * X


if __name__ == "__main__":
    # import doctest
    #
    # doctest.testmod()
    N, K, X, Y = read_input()

    print(check_sum(N, K, X, Y))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l; cin >> n >> l;
  vector<string> S(n);
  rep(i, n) cin >> S[i];
  sort(all(S));
  rep(i, n) cout << S[i];
  cout << endk;
  return 0;
}


Measured memory_bytes: 3552
# coding:utf-8
N = int(input())
S = input()
Snum = [ord(i)-65 for i in S]
chgnum = [(j + N) % 26 + 65 for j in Snum]
chgstr = [chr(k) for k in chgnum]
ans = "".join(chgstr)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string a,b; cin>>a>>b;
    string s = a+b;
    int num = stoi(s);
    
    rep(i,1000) if(num == i*i) {cout<<"Yes"<<endl; return 0;}
    cout<<"No"<<endl;
    return 0;
}


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

int power(int n)
{
    int ret = 1;
    int x = 2;
    while (n > 0)
    {
        if (n & 1)
        {
            ret *= x;
        }
        x *= x;
        n >>= 1;
    }
    return ret;
}

int f(int init, int k)
{
    int count = 0;
    while (init < k)
    {
        init <<= 1;
        count++;
    }
    return power(count);
}

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

    double ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ans += 1. / (double)f(i, K) / (double)N;
    }

    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256