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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair

typedef pair<int,int> pii;
	
const int inf=1145141919;
const int maxV=110;
const int maxE=1200;

struct MinCostFlow{
	struct Edge{
		int to,cost,cap,rev;
	};
	vector<Edge> graph[maxV];
	int h[maxV],pV[maxV],pE[maxV],d[maxV];
	MinCostFlow(){
		REP(i,maxV)
			graph[i].reserve(maxV);
	}
	int n;
	void Set(int s){
		n=s;
		REP(i,n)
			graph[i].clear();
	}
	void AddEdge(int from,int to,int cost,int cap){
		graph[from].push_back(Edge{to,cost,cap,(int)graph[to].size()});
		graph[to].push_back(Edge{from,-cost,0,(int)graph[from].size()-1});
	}
	int Calc(int s,int t,int f){
		int res=0;
		fill(h,h+n,0);
		while(f>0){
			priority_queue<pii,vector<pii>,greater<pii>> pq;
			pq.push(MP(0,s));
			fill(d,d+n,inf);
			d[s]=0;
			while(!pq.empty()){
				pii x=pq.top();
				pq.pop();
				if(d[x.second]<x.first) continue;
				int i=0;
				for(auto& e:graph[x.second]){
					int z=x.first+e.cost+h[x.second]-h[e.to];
					if(e.cap&&d[e.to]>z){
						pV[e.to]=x.second;
						pE[e.to]=i;
						d[e.to]=z;
						pq.push(MP(z,e.to));
					}
					i++;
				}
			}
			if(d[t]==inf) return inf;
			REP(i,n)
				h[i]+=d[i];
			int k=f;
			for(int u=t;u!=s;u=pV[u])
				k=min(k,graph[pV[u]][pE[u]].cap);
			f-=k;
			res+=k*h[t];
			for(int u=t;u!=s;u=pV[u]){
				graph[pV[u]][pE[u]].cap-=k;
				graph[u][graph[pV[u]][pE[u]].rev].cap+=k;
			}
		}
		return res;
	}
} mcf;

int n,m,b;
int ax[100],ay[100],bx[5],by[5],c[5],f[5];

bool Input(){
	scanf("%d%d%d",&n,&m,&b);
	if(!n&&!m&&!b)
		return false;
	REP(i,n)
		scanf("%d%d",&ax[i],&ay[i]);
	REP(i,m)
		scanf("%d%d%d%d",&bx[i],&by[i],&c[i],&f[i]);
	return true;
}

int SolveSub(int ven,int d){
	mcf.Set(n+m+2);
	REP(i,n)
		mcf.AddEdge(n+m,i,0,1);
	int p=0;
	REP(i,m)
		if((ven>>i)&1){
			p+=f[i]+d*b;
			REP(j,n)
				mcf.AddEdge(j,n+i,max(0,abs(ax[j]-bx[i])+abs(ay[j]-by[i])-d),1);
			mcf.AddEdge(n+i,n+m+1,0,c[i]);
		}
	return p+mcf.Calc(n+m,n+m+1,n);
}

void Solve(){
	int ans=inf;
	FOR(k,1,1<<m){
		int l=-1,r=4001;
		while(r-l>1){
			int mid=(l+r)/2;
			int s1=SolveSub(k,mid);
			int s2=SolveSub(k,mid+1);
			ans=min({ans,s1,s2});
			if(s1>s2)
				l=mid;
			else
				r=mid;
		}
	}
	printf("%d\n",ans);
}

int main(){
	while(Input()) Solve();
}

Measured memory_bytes: 3336
#include <cstdio>

int n,m,l,f[2005][2005],z;
const int p=1000000007;

int main()
{
    scanf("%d%d%d",&n,&m,&l);
    for(int i=1;i<l;++i)f[i][l-i]=1;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
            if(f[i][j])
                for(int k=0;k<l;++k)
                    if(i+k<=n&&j+l-1-k<=m)
                        (f[i+k][j+l-1-k]+=f[i][j])%=p;
            if(i%(l-1)==n%(l-1)&&j%(l-1)==m%(l-1))z=(z+f[i][j])%p;
        }
    return printf("%d\n",z),0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int n, q;
vector<vector<string>> seg;
vector<string> w;
string pre, suf;

void build() {
    seg.resize(2 * n + 1);
    for (int i = 0; i < n; i++) {
        string s = w[i];
        reverse(s.begin(), s.end());
        seg[i + n].push_back(s);
    }

    for (int i = n - 1; i > 0; i--) {
        for (auto s:seg[i * 2]) {
            seg[i].push_back(s);
        }
        for (auto s:seg[i * 2 + 1]) {
            seg[i].push_back(s);
        }
        sort(seg[i].begin(), seg[i].end());
    }
}

int seg_query(int l, int r, string &q) {
    int ans = 0;
    reverse(q.begin(), q.end());
    string q2 = q;
    q2.back()++;
    l += n;
    r += n;
    while (l < r) {
        if (l & 1) {
            ans += lower_bound(seg[l].begin(), seg[l].end(), q2)
            - lower_bound(seg[l].begin(), seg[l].end(), q);
            l++;
        }
        if (r & 1) {
            r--;
            ans += lower_bound(seg[r].begin(), seg[r].end(), q2)
            - lower_bound(seg[r].begin(), seg[r].end(), q);
        }
        l >>= 1;
        r >>= 1;
    }

    return ans;
}

int query(string &p, string q) {
    string p2 = p;
    p2.back()++;
    int s = lower_bound(w.begin(), w.end(), p) - w.begin();
    int t = lower_bound(w.begin(), w.end(), p2) - w.begin();

    //cout << s << " " << t << endl;
    return seg_query(s, t, q);
}

int main() {
    cin >> n >> q;
    w.resize(n);
    for (auto &s:w) cin >> s;
    sort(w.begin(), w.end());

    build();
    while (q--) {
        cin >> pre >> suf;

        cout << query(pre, suf) << endl;
        //query(pre, suf);
        //cout << seg_query(0, n, suf) << endl;
    }
}



Measured memory_bytes: 40800
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

int dp[1400][1400],g[1400][1400];
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h)rep(j,w) cin>>g[i][j];
    rep(i,h) dp[i][0]=g[i][0]==1?0:1;
    rep(i,w) dp[0][i]=g[0][i]==1?0:1;
    int ans=0;
    if(h==1||w==1){
        rep(i,h) ans=max(dp[i][0],ans);
        rep(i,w) ans=max(dp[0][i],ans);
    }
    FOR(i,1,h)FOR(j,1,w){
        if(g[i][j]==1) dp[i][j]=0;
        else{
            dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
            ans=max(dp[i][j],ans);
        }
    }
    cout<<ans*ans<<endl;
    return 0;
}

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

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

  string s;
  cin >> s;
  ll n = s.size();

  rep(i, n-1) {
    if (s[i] == s[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  rep(i, n-2) {
    if (s[i] == s[i+2]) {
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(3*n);
    rep(i,3*n) cin>>a[i];
    sort(begin(a),end(a),greater<ll>());
    ll ans=0;
    ll cnt=0;
    rep(i,3*n){
      if(i%2==1){
        ans+=a[i];
        cnt++;
        //cout<<a[i]<<endl;
      }
      if(cnt==n) break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 2e5+5;
const ll M = 998244353;

ll C[N];

inline ll qpow(ll a,ll b){
	ll res = 1;
	a %= M;
	while(b){
		if(b & 1) (res *= a) %= M;
		(a *= a) %= M;
		b >>= 1;
	}
	return res%M;
}
inline ll inv(ll a){
	return qpow(a,M-2);
}

inline void C_table(ll n){
	C[0] = 1ll;
	C[1] = n;

	for(int i = 2;i <= n;++i){
		C[i] = C[i-1]%M * (ll)(n-i+1)%M * inv(i)%M;
		C[i] += M;
		C[i] %= M; 
	}
	return ;
}

int main() {
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	C_table(n-1);
	
	ll ans = 0;
	for(int i = 0;i <= k;++i){
		int t = n-1-i;
		
		ll l = C[t];
		ll r = t+1;
		
		l = l*(ll)m%M;
		r--;
		l = l*qpow(m-1,r)%M;
		(ans += l) %= M;
		(ans += M) %= M;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
    int H, W, D;
    cin >> H >> W >> D;
    int A[H * W + 1][2] = {};
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int a;
            cin >> a;
            A[a][0] = i;
            A[a][1] = j;
        }
    }

    int cumulative_sum[H * W + 1] = {};
    for (int i = 1; i <= H * W; i++)
    {
        if (i <= D)
        {
            cumulative_sum[i] = 0;
        }
        else
        {
            cumulative_sum[i] = cumulative_sum[i - D] + abs(A[i][0] - A[i - D][0]) + abs(A[i][1] - A[i - D][1]);
        }
    }

    int Q;
    cin >> Q;
    int L, R;
    for (int i = 0; i < Q; i++)
    {
        cin >> L >> R;
        cout << cumulative_sum[R] - cumulative_sum[L] << endl;
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
string s;
ll ans;
ll d[300005];

int main()
{
    cin>>s;
    d[0] = 1;
    for(ll i = 1; i <= s.size(); i++)
    {
        d[i] = d[i - 1] * 3 % M;
    }
    ll now = 1;
    for(ll i = 0; i < s.size(); i++)
    {
        if(s[i] == '1') ans += d[(ll)s.size() - i - 1] * now % M, ans %= M, now *= 2;
        now %= M;
    }
    ans += now;
    ans %= M;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <iomanip>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        u32 x;
        scanf("%x", &x);
        cout << setprecision(100) << (x&(1u << 31) ? "-" : "") << ldexp(x&((1u << 31)-1), -7) << (!(x&((1u << 7)-1)) ? ".0" : "") << "\n";
    }
    return 0;
}


Measured memory_bytes: 3364
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N;
#define MAXN 200001
string S[MAXN];
int main(){
    cin >> N;
    rep(i,N)cin >> S[i];
    map<string,int>M;
    int maxn = 0;
    rep(i,N){
        auto itr = M.find(S[i]);
        if(itr == M.end()){
            M[S[i]] = 1;
            if(maxn < M[S[i]])maxn = M[S[i]];
        }else{
            M[S[i]]++;
            if(maxn < M[S[i]])maxn = M[S[i]];
        }
    }
    string A[MAXN];
    int count =0;
    rep(i,N){
        if(M[S[i]]==maxn){
            A[count] = S[i];
            count++;
        }
    }

    sort(A,A+count);
    for(int i=0;i<count;i+=maxn){
        cout << A[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 28288
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp()
{
	ll i,j,k,n,m;
	string s;
	cin>>n;
	ll ans=(n/500)*1000;
	n%=500;
	ans+=(n/5)*5;
	cout<<ans<<endl;
}

int main()
{
    speedup;
    ll i=0,t;
    ll n;
    //cin>>t;
    t=1;
	while(t--)
    {
        comp();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	vector<double> mp;
	vector<ll> lll;
	for(ll i=0;i<a;i++)
	{
		ll c;
		cin>>c;
		double k = c*(c+1)/2;
		double jk = k/c;
		mp.push_back(jk);
		lll.push_back(c);
	}
	vector<double> vd;
	double step=0.0;
	vector<double> mpq;
	for(ll i=0;i<mp.size();i++)
	{
		step+=mp[i];
		mpq.push_back(step);
	}
	if( a == b )
		vd.push_back(mpq[mpq.size()-1]);
	else
	for(ll i=0;i<mpq.size();i++)
	{
		if(i-b>=0)
		{
			vd.push_back(mpq[i]-mpq[i-b]);
		}
	}
	double sum = 0.0;
	for(ll i=0;i<vd.size();i++)
	{
		if(sum<vd[i])
		{
			sum = vd[i];
		}
	}
	printf("%.12f",sum); 
	return 0;
}


Measured memory_bytes: 8036
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  string s3 = s1;
    reverse(s1.begin(),s1.end());
  string s4 = s2;
    reverse(s2.begin(),s2.end());
  if(s1 == s4 && s2 == s3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

int main() {
    int n = 0;
    scanf("%d", &n);
    int ans = 0;
    for (int i=105; i<=n; i += 2) {
        int count = 0;
        for (int j=1; j<=i; j++) {
            if (i%j == 0) count++;
        }
        if (count == 8) ans++;
    }
    printf("%d\n", ans);    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
}

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

int main()
{
  string s; cin >> s;
  ll k; cin >> k;
  ll n = s.size();

  char ans = '1';
  for (int i=0; i<min(n,k); i++) {
    if (s[i] > '1') {
      ans = s[i];
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=100005;

int n,x;
ll ans;
int a[N];

int main(){
	int i;
	scanf("%d%d",&n,&x);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]>x){
		ans+=1ll*(a[1]-x);
		a[1]=x;
	}
	for (i=2;i<=n;i++){
		if (a[i]+a[i-1]>x){
			ans+=1ll*(a[i]-(x-a[i-1]));
			a[i]=x-a[i-1];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>
#define go_precise cout << fixed << setprecision(18);
const ll mod = 1e9 + 7;

const int maxn = 1e5 + 10;
vector<int> e[maxn];
vector<int> g[maxn];
int n;
bool used[maxn];
// 0 - white, 1 - black
ll dp[maxn][2];

void dfsbuild(int v) {
    used[v] = true;
    for (auto to : e[v]) {
        if (used[to]) continue;
        g[v].pb(to);
        dfsbuild(to);
    }
    return;
}

void dfs(int v) {
    dp[v][0] = 1;
    dp[v][1] = 1;
    for (auto to : g[v]) {
        dfs(to);
        dp[v][0] = (dp[v][0] * (dp[to][0] + dp[to][1])) % mod;
        dp[v][1] = (dp[v][1] * dp[to][0]) % mod;
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    for (int i=1; i<n; i++) {
        int u,v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
    }
    dfsbuild(1);
    dfs(1);
    cout << ((dp[1][0] + dp[1][1]) % mod + mod) % mod << '\n';

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int,int> P;
typedef vector<P> VP;
 
int dx[] = {+0,-1,-1,+0,+1,+1};
int dy[] = {-1,-1,+0,+1,+1,+0};
int N,C;
 
void dfs(VVI &G,VVB &used,int x,int y,int c)
{
  if(used[y][x])return;
  used[y][x] = true;
 
  rep(i,8)
    {
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(!(0 <= ny && ny < N && 0 <= nx && nx < G[ny].size()))continue;
      if(used[ny][nx])continue;
      if(G[ny][nx] != c)continue;
      dfs(G,used,nx,ny,c);            
    }
 
}
 
int Count(VVI &G,VVB &used)
{
  int ret = 0;
  rep(i,N)
    {
      rep(j,i+1)
    {
      if(used[i][j])continue;
      if(G[i][j] == 0)continue;
      //cout << "yes " << j << " " << i << endl; 
      if(G[i][j] == C)ret--;
      else            ret++;
    }
    }
  return ret;
}
 
 
int main()
{
  while(cin >> N >> C,N|C)
    {
      VP zero;
      VVI G(N);
      rep(i,N)
    {
      G[i].resize(i+1);
      rep(j,i+1)
        {
          cin >> G[i][j];
          if(G[i][j] == 0)
        zero.push_back(P(j,i));
        }
    }
 
      int ans = -(1<<29);
      rep(i,N)
    {
      rep(j,i+1)
        {
          if(G[i][j] != 0)continue;  
          G[i][j] = C;
          VVB used(N);
          rep(k,N)
        {//init
          used[k].resize(k+1);
          rep(l,k+1)
            used[k][l] = false;
        }//init
 
          int zeroSize = zero.size();
          rep(k,zeroSize)
        {
          P p = zero[k];
          if(p.F == j && p.S == i)continue;
          rep(l,6)
            {
              int nx = p.F+dx[l];
              int ny = p.S+dy[l];
              if(!(0 <= ny && ny < N && 0 <= nx && nx < G[ny].size()))continue;
              dfs(G,used,nx,ny,G[ny][nx]);
            }
        }
 
          int cnt = Count(G,used);
          //cout << "cnt = " << cnt << endl;
          ans = max(ans,cnt);
 
          G[i][j] = 0;
        }
    }
 
      cout << ans << endl;
 
    }
  return 0;
}

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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void vin(std::vector<T> &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void vout(std::vector<T> &a){
  for(auto x: a)
    cout << x << " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n, k; cin >> n >> k;
  string s; cin >> s;
  std::vector<int> a(n);
  for(int i=0; i<n; i++)
    a[i]=s[i]==s[0];
  int i=0;
  for(int j=0; j<k; j++){
    while (i<n && a[i])
      i++;
    while (i<n && !a[i])
      i++;
  }
  while (i<n && a[i])
    i++;
  int res=i-1;
  // cerr << res<<"\n";
  for(; i<n-1; i++)
    res+=a[i]==a[i+1];
  cout << res << "\n";
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

ll n;
ll imos[2521830];
ll dp[2521830];

int main(){
  scanf("%lld",&n);
  ll ans = 0;
  ll n1 = n-1;
  dp[0] = 1;
  REP(i,2*n+10){
    if(i < n-1){
      // one
      dp[i+1] += dp[i];
      dp[i+1] %= MOD;
      // double use
      ans += dp[i] * n1 % MOD * n1 % MOD;
      ans %= MOD;
      // k, 1*k
      imos[i+3] += dp[i];
      imos[i+3] %= MOD;
      imos[i+n+2] += MOD - dp[i];
      imos[i+n+2] %= MOD;
    }else if(i==n-1){
      // finisher
      ans += dp[i] * n % MOD;
      ans %= MOD;
    }else{
      // k, 1*k
      ans += dp[i] % MOD;
      ans %= MOD;
    }
    imos[i+1] += imos[i];
    imos[i+1] %= MOD;
    dp[i+1] += imos[i+1];
    dp[i+1] %= MOD;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 35072
#include<iostream>

using namespace std;

int main() {
    int x = 1;
    int temp;
    cin >> temp;
    if(temp < 10){
        x = temp;
        cin >> temp;
        if(temp < 10){
            cout << x * temp;
        }
        else{
            cout << -1 << endl;
        }
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
lis = list(map(int,input().split()))

lis.sort()


if (lis[2] % 2 == lis[1] % 2 and lis[2] % 2 != lis[0] % 2 ) or (lis[2] % 2 == lis[0] % 2 and lis[2] % 2 != lis[1] % 2 ):
    tall = lis[2] + 1

else:
    tall = lis[2]

print ((3*tall - lis[0] - lis[1] - lis[2]) // 2)


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

int N;
int A[210];
  
  int main() {
  	cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    int res = 0;
    
    while (true) {
      bool exist_odd = false;
      
      for (int i = 0; i < N; i++) {
        if (A[i] % 2 != 0) exist_odd = true;
      }
      
      if(exist_odd) break;
      
      for (int i = 0; i < N; i++) {
      	A[i] /= 2;
      }
      ++res;
    }
    
    cout << res << endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,s;
  string f;
  cin >> a >>s;
  for(int i=0;i<s+2;i++){
    cout << "#" ;
  }
  cout << endl;
  
  for (int i=0;i<a;i++){
    cin >> f;
 cout << "#" << f << "#" << endl;
  }
    for(int i=0;i<s+2;i++){
    cout << "#" ;
  }
  cout << endl;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll N, K;
ll A[200010], nA[200010];

bool C( ll x )
{
  ll cnt = 0;

  rep( j, N )
  {
    if( !A[j] )
      cnt += x>=0?j:0;
    else if( A[j] > 0 )
    {
      ll val = x >= 0 ? -x/A[j] : (-x+(A[j]-1))/A[j];
      ll idx = nA+N-std::lower_bound( nA, nA+N, val );
      cnt += std::min((ll)(j), idx);

      //printf( "val: %lld\n", val );
      //printf( "x: %lld, A[j]: %lld, idx: %lld\n", x, A[j], std::min((ll)(j+1), idx) );
    }
    else
    {
      ll val = x >= 0 ? -x/(-A[j]) : (-x+(-A[j]-1))/(-A[j]);
      ll nidx = A+N-std::lower_bound( A, A+N, val );
      ll start = N-1-(nidx-1);
      cnt += std::max(0ll, j-start);
      
      //printf( "val: %lld\n", val );
      //printf( "x: %lld, A[j]: %lld, nidx: %lld\n", x, A[j], std::max(0ll, j+1-start) );
    }
  }

  //printf( "cnt: %lld\n", cnt );

  return cnt >= K;
}

int main()
{
  scanf( "%lld%lld", &N, &K );
  rep( i, N )
  {
    scanf( "%lld", A+i );
    nA[i] = -A[i];
  }

  std::sort( A, A+N );
  std::sort( nA, nA+N );

  ll lb = -INF, ub = INF;

  while( ub-lb > 1 )
  {
    ll mid = (lb+ub)/2;

    //printf( "[%lld, %lld)\n", lb, ub );

    (C(mid) ? ub : lb) = mid;
  }

  printf( "%lld\n", ub );

  return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
int const N_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  if (!po[n]) {
    po[0] = 1;
    FOR(i, 1, n + 1) po[i] = po[i - 1] * i % MOD;
  }
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

// least common multiple
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll L, R;

int main() {
  scanf("%lld %lld", &L, &R);

  int l = L % 2019;
  int r = R % 2019;
  if (R - L > 2019 || l > r) r += 2019;

  int min_v = 3000;
  FOR(i, l, r) {
    FOR(j, i + 1, r + 1) {
      int x = i * j % 2019;
      min_v = min(x, min_v);
    }
  }
  if (min_v == 3000) min_v = l * r % 2019;

  printf("%d\n", min_v);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    int hotel = 0, highest = -1;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= highest) {
            hotel++;
            highest = h;
        }
    }

    cout << hotel << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vll A(N), B(M);
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, M) {
        cin >> B[i];
    }
    vll ruiseki_A(N + 1), ruiseki_B(M + 1);
    ll tmp = 0;
    rep(i, N + 1){
        if (i > 0){
            tmp += A[i - 1];
        }
        ruiseki_A[i] = tmp;
    }
    tmp = 0;
    rep(i, M + 1){
        if (i > 0){
            tmp += B[i - 1];
        }
        ruiseki_B[i] = tmp;
    }

    ll ans = 0, total = 0;
    auto solver = [&] (int l){
        if (K - ruiseki_A[l] < 0) return 0;
        auto iter = upper_bound(all(ruiseki_B), K - ruiseki_A[l]);
        if (iter == ruiseki_B.begin()) return l;
        else return l + (int)distance(ruiseki_B.begin(), iter) - 1;
    };
    rep(i, N + 1){
        ans = max(ans, (ll)solver(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  int n; cin >> n;
  cout << 1110-n;
  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  int max = 0;
  ll ans = 0;
  RREP(i, n) {
    if (a[i] > i) {
      cout << -1 << endl;
      return;
    }
    if (a[i] > max) {
      ans += a[i];
      max = a[i];
    } else if (a[i] < max) {
      cout << -1 << endl;
      return;
    }
    max--;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
 //ボールは
 //y=1,2,3,4,5,...の順に配置されていく
 //そのあとx1=?? x2=?? x3=??となっていく
 //タイプAは(0.1)(0,2)...となっていく
 //タイプBは入力【K】により(K,1)(K,2)...となる
 //つまり一つのボールを取りに行くのはどちらか2つ
 //それをN回繰り返す
 //
 //サンプル
 //
 //A5         *
 //A4   *    B4
 //A3        B3    *
 //A2        B2           *
 //A1    *    B1
 //O         K

//つまり　ボールのx座標 を元に
//B[x]-boal[x]<x
//なら　Bのほうが近いのでその値を総距離に代入

int main() {
    //ball x=ボールのx座標　N＝ボールが何個あるか　K=ロボBのx座標　a,b=計算用変数　s=総距離
    int ballx,N,K,a,b,s=0;
    cin >> N >> K;
    
    for (int i=0; i<N; i++){
        cin >> ballx;
        a=ballx;
        b=K-ballx;
        if (a<b){
            s+=a;
        }
        else {
            s+=b;
        }


    }
    s*=2;
    
    cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007


int main(){
    int n,k;
    cin >>n>>k;
    vector<int> l(n);
    rep(i,n){
        cin>>l[i];
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    //大きい順にソート
    int sum=0;
    rep(i,k){
        sum+=l[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    //降順にソートした順番で挿入するのが最適解の一つ
    sort(ALL(A), greater<ll>());

    //1番大きい数を1回、それ以外を大きい順に2回ずつ足していくのが最大
    ll ans = A[0];
    FOR(i, 2, N - 1)
    {
        ans += A[i / 2];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4696
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    vector<Ld> aa(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        aa[i] = log10l(a[i]);
    }

    Ld old = 0;
    for (Int i = 0; i < k; i++) {
        old += aa[i];
    }

    for (Int i = k; i < n; i++) {
        Ld ne = old - aa[i - k] + aa[i];

        if (old < ne) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

        old = ne;
    }

    return 0;
}

Measured memory_bytes: 7956
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
 
ll K;
 
int main(void) {
  cin >> K;
 
  vector< vector<pll> > E(K);
  REP(i, 1, K + 1) {
    E[i % K].push_back(pll((i + 1) % K, 1));
    E[i % K].push_back(pll((i * 10) % K, 0));
  }
 
  vector<ll> dp(K, INF);
  priority_queue< pll, vector<pll>, greater<pll> > q;
  q.push(pll(1, 1));
  while(!q.empty()) {
    ll d = q.top().first, v = q.top().second;
    q.pop();
 
    if(dp[v] <= d) continue;
    dp[v] = d;
 
    if(v == 0) break;
 
    for(pll p : E[v]) {
      ll nd = d + p.second, nv = p.first;
      if(dp[nv] > nd) q.push(pll(nd, nv));
    }
  }
 
  cout << dp[0] << endl;
}

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

signed main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for( int i = 0; i <= K; i++ ){ //X
    for( int j = 0; j <= K; j++ ){ //Y
      int Z = S - i - j;
      if( 0 <= Z && Z <= K ) count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

const int mod=1e9+7;
#define ll long long
#define pb push_back
#define Dracarys ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()

void solve(){
	ll n,s;
	cin>>n>>s;
	
	ll base=1e18;
	bool flag=false;
	for (ll b=2;b<=sqrt(n);b++){
		ll sum=0,temp=n;
		while(temp){
			sum+=(temp%b);
			temp/=b;
		}
		if (sum==s){
			flag=true;
			base=b;
			break;
		}
	}
	//cout<<flag<<" "<<base<<"\n";
	if (!flag){
		
		ll res=n-s;
		if (res>0){
			for (ll i=1;i<=sqrt(res);++i){
				if (res%i==0){
					ll f1=i,f2=res/i;
					if (f1<=f2){
						ll x=f1,bb=f2+1,y=s-x;
						if (y>=0 and y<bb and (bb*x+y==n))
						base=min(base,bb),flag=true;
					}
				}
			}
		}
		else{
			if (n==s){
				base=n+1;flag=true;
			}
		}
	}
	
	if (flag){
		cout<<base<<"\n";
	}
	else{
		cout<<"-1\n";
	}
}

int main(){
	
	Dracarys
	
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
 
int main() {
    ll a, c;
  	long double b;
    cin >> a >> b;
	c = a * b;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3728
def resolve():
    import numpy as np
    N, M, C = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    A = np.array([list(map(int, input().split())) for _ in range(N)])
    ans = 0
    for i in range(N):
        ans += 1 if sum(A[i] * B) + C > 0 else 0
    print(ans)


resolve()


Measured memory_bytes: 12404
fun main(args : Array<String>) {
    val (N, K, L) = readLine()!!.split(" ").map { it.toInt() }
    val connetctedByBridge = UnionFind(N)
    val connetctedByRails = UnionFind(N)
    (1..K).forEach {
        val (p, q) = readLine()!!.split(" ").map { it.toInt() }
        connetctedByBridge.merge(p - 1, q - 1)
    }
    (1..L).forEach {
        val (r, s) = readLine()!!.split(" ").map { it.toInt() }
        connetctedByRails.merge(r - 1, s - 1)
    }

    val map = mutableMapOf<Pair<Int, Int>, Int>()
    (0..(N-1)).forEach {
        val p = Pair(connetctedByBridge.root(it), connetctedByRails.root(it))
        if (!map.contains(p)) {
            map[p] = 0
        }
        map[p] = map[p]!! + 1
    }

    (0..(N-1)).forEach {
        val p = Pair(connetctedByBridge.root(it), connetctedByRails.root(it))
        print(map[p])
        print(" ")
    }
}

class UnionFind(size: Int) {
    var parent: IntArray
    var height: IntArray
    var size: IntArray

    init {
        this.parent = IntArray(size)
        this.height = IntArray(size)
        this.size = IntArray(size)

        for (i in 0 until size) {
            makeSet(i)
        }
    }

    fun merge(x: Int, y: Int) {

        val rootX = root(x)
        val rootY = root(y)

        if (rootX == rootY) {
            return
        }

        if (height[rootX] > height[rootY]) {
            parent[rootY] = rootX
            size[rootX] += size[rootY]

        } else if (height[rootX] < height[rootY]) {
            parent[rootX] = rootY
            size[rootY] += size[rootX]

        } else {
            parent[rootY] = rootX
            size[rootX] += size[rootY]
            height[rootX]++
        }
    }

    fun isSame(x: Int, y: Int) : Boolean {
        return root(x) == root(y)
    }

    fun size(x: Int): Int {
        val rootX = root(x)
        return size[rootX]
    }

    fun root(x: Int): Int {
        if (x != parent[x]) {
            parent[x] = root(parent[x])
        }
        return parent[x]
    }


    private fun makeSet(i: Int) {
        parent[i] = i
        height[i] = 0
        size[i] = 1
    }
}

Measured memory_bytes: 106456
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;
vi a;

bool ok(int mid) {
    ll sum = 0; F0R(i,mid+1) sum += a[i];
    FOR(i,mid+1,n) if (2*sum >= a[i]) {
        sum += a[i];
    } else return 0;
    return 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; a.resize(n);
    F0R(i,n) cin >> a[i];
    sort(all(a));
    int lo = 0, hi = n;
    while (lo < hi) {
        int mid = (lo+hi)/2;
        if (ok(mid)) hi = mid;
        else lo = mid+1;
    }
    cout << n-hi;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>

constexpr intmax_t MOD = 1e9+7;

std::map<intmax_t, intmax_t> factor(intmax_t n) {
  std::map<intmax_t, intmax_t> res;
  for (intmax_t i = 2; i*i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n > 1) ++res[n];
  return res;
}

template <class Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <class Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

class modchoose {
  std::vector<intmax_t> fact, fact_inv;
  intmax_t mod;

public:
  modchoose(intmax_t N, intmax_t mod): mod(mod) {
    fact.resize(N+1);
    fact_inv.resize(N+1);
    fact[0] = 1;
    for (intmax_t i = 1; i <= N; ++i)
      fact[i] = fact[i-1] * i % MOD;

    fact_inv[N] = modinv(fact[N], mod);
    for (intmax_t i = N; i--;)
      fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
  }

  intmax_t operator ()(intmax_t n, intmax_t r) const {
    intmax_t res = fact[n] * fact_inv[r] % mod;
    (res *= fact_inv[n-r]) %= mod;
    return res;
  }
};

int main() {
  intmax_t N, M;
  scanf("%jd %jd", &N, &M);

  modchoose ncr(200000, MOD);

  intmax_t res = 1;
  for (const auto& p: factor(M))
    (res *= ncr(p.second+N-1, N-1)) %= MOD;

  printf("%jd\n", res);
}


Measured memory_bytes: 3328
using System;
using System.Linq;

namespace ABC126C
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();

            int N = int.Parse(line[0]);
            int K = int.Parse(line[1]);

            double sum = 0.0;

            for(var i = 1; i <= N; i++)
            {
                double tmp = 1.0 / N;
                int point = i;
                while(point < K)
                {
                    point *= 2;
                    tmp /= 2;
                }
                sum += tmp;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Tenki(void) {

	string S, T; cin >> S >> T;

	int counter = 0;
	rep(index, 3) if (S[index] == T[index]) counter++;
	
	cout << counter << flush;
	return;
}

void B_Power_Socket(void) {
	
	int A, B; cin >> A >> B;
	
	cout << ceil(double(B - 1) / double(A - 1)) << flush;
	return;
}

int main(void) {

	//A_Tenki();
	B_Power_Socket();
	return 0;
}


Measured memory_bytes: 256
#init
N = int(input())
S=[]
for _ in range(N):
  S.append(input())
score=[0]*4
for _ in S:
  if _=='AC':
    score[0]=score[0]+1
  if _=='WA':
    score[1]=score[1]+1
  if _=='TLE':
    score[2]=score[2]+1
  if _=='RE':
    score[3]=score[3]+1
    
print('AC x {0}'.format(score[0]))
print('WA x {0}'.format(score[1]))
print('TLE x {0}'.format(score[2]))
print('RE x {0}'.format(score[3]))

Measured memory_bytes: 16040
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
 int i;
 double a,b,c,d,e,f;
 vector<double> x,y;
 while(cin >> a >> b >> c >> d >> e >> f) {
	 if (a==0 && e==0) {y.push_back(c/b); x.push_back(f/d); continue; }
	 if (b==0 && d==0) {x.push_back(c/a); y.push_back(f/e); continue; }
	 if (d==0 || e==0) {swap(a,d); swap(b,e); swap(c,f); }
	 y.push_back((c-f*a/d)/(b-e*a/d));
	 x.push_back((c-f*b/e)/(a-d*b/e));
	 }
 for (i=0;i<x.size();i++) printf("%.3f %.3f\n",x[i],y[i]); 
 return 0;
}

Measured memory_bytes: 1260
#他の人の見てみた結果
#これでfindごとに全探索回避できるのだろうか？
n=int(input())
D=set()
for i in range(n):
    order,str=input().split( )
    if order == "insert":
        D.add(str)
    else:
        if str in D:
            print("yes")
        else:
            print("no")



Measured memory_bytes: 30988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const double PI = acos(-1);


int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double p = (60*h + m) % 720;
    double q = m;

    double diff = abs(p * PI / 360 - q * PI / 30);
    diff = min(2*PI - diff, diff);
    
    double ans = a*a + b*b - 2*a*b*cos(diff);

    cout << fixed << setprecision(20) << pow(ans, 0.5) << endl;

    return 0;
}


Measured memory_bytes: 4256