akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	board := make([][]int, 2)
	for i := range board {
		board[i] = make([]int, N)
	}

	for i := range board {
		for j := range board[i] {
			var A int
			fmt.Scan(&A)
			board[i][j] = A
		}
	}

	max := 0
	for i := 0; i < N; i++ {
		count := 0
		count += board[0][i]
		for j := 0; j < N; j++ {
			if j >= i {
				count += board[1][j]
			} else {
				count += board[0][j]
			}
		}

		if count > max {
			max = count
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;scanf("%d%d",&n,&m);
    map<int,int> a;
    for(int i=0;i<n;i++){
        int x;scanf("%d",&x);
        a[x]++;
    }
    vector<int> modm(m),modmp(m);
    for(auto p:a){
        modm[p.first%m]+=p.second%2;
        modmp[p.first%m]+=p.second/2*2;
    }
    int ans=modm[0]/2;
    for(int i=0;i<(m-1)/2;i++){
        int p=min(modm[i+1],modm[m-1-i]);
        ans+=p;
        modm[i+1]-=p,modm[m-1-i]-=p;
    }
    if((m-1)%2)ans+=modm[m/2]/2,modm[m/2]%=2;
    for(int i=0;i<m-1;i++){
        if(modm[i+1]<=1)continue;
        int p=min(modm[i+1],modmp[m-1-i]);
        ans+=p;
        modm[i+1]-=p,modmp[m-1-i]-=p;
    }
    for(int i=0;i<m;i++)ans+=modmp[i]/2;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0)
        cout << 1 << endl;
    if(b==0)
        cout << 2 << endl;
    if(c==0)
        cout << 3 << endl;
    if(d==0)
        cout << 4 << endl;
    if(e==0)
        cout << 5 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define hell 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
bool prime[200005];
void sieve(){
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<200005; p++) 
    {
        if (prime[p] == true) 
        {
            for (int i=p*p; i<200005; i += p) 
                prime[i] = false; 
        } 
    }
}
int powmod(int x,int y,int mod){
    int res = 1;
    x = x%mod;
    while(y>0){
        if(y&1){
            res = (res*x)%mod;
        }
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    priority_queue <long double, vector< long double>, greater<long double> > pq; 
    rep(i,0,n){
        cin>>a[i];
        pq.push((long double)a[i]);
    }
    while(pq.size()>1){
        long double x = pq.top();
        pq.pop();
        long double y = pq.top();
        pq.pop();
        pq.push((x+y)/2.0);
    }
    cout<<setprecision(10);
    cout<<pq.top()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vv vector<ll>
#define pp pair<ll,ll>
#define ff first
#define ss second
#define vp vector<pp>
#define ld long double
#define pb push_back
#define mp make_pair
const ll mod=7+1e9;
ll power(ll a,ll n)
{
	ll ans=1;
	a=a%mod;
	while(n>0)
	{
		if(n&1)
		{
			ans=(ans*a)%mod;
		}
		n=n>>1;
		a=(a*a)%mod;
	}
	return ans;
}
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={0};
    for(ll i=0;i<m;i++)
    {
    	ll l,r;
    	cin>>l>>r;
    	a[l]++;
    	a[r+1]--;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		a[i]=a[i-1]+a[i];
		if(a[i]==m)
		{
			ans++;
		}
	}
	cout<<ans;
return 0;
}

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

#define f1 for(int x1=0;x1<3;x1++)
#define f2 for(int x2=0;x2<3;x2++)
#define f3 for(int x3=0;x3<3;x3++)

int main()
{
	int n, k, a, b, p[100];
	int c1[3][3][3], c2[3][3][3];

	cin >> n >> k;
	for (int i = 0; i < n; i++){
		p[i] = 0;
	}
	for (int i = 0; i < k; i++){
		cin >> a >> b;
		p[a - 1] = b;
	}

	for (int i = 0; i < n - 2; i++){
		if (!i){
			f1{ f2{ f3{
				c1[x1][x2][x3] = 1;
			} } }
		}
		else{
			int sum = 0;
			f1{ f2{
				f3{ sum +=c2[x3][x1][x2]; }
				f3{ c1[x1][x2][x3] = sum; }
				sum = 0;
			} }
		}

		f1{ c1[x1][x1][x1] = 0; }

		if (p[i]){
			f1{ f2{ f3{
				if (p[i] != x1+1){ c1[x1][x2][x3] = 0; }
			} } }
		}
		if (p[i + 1]){
			f1{ f2{ f3{
				if (p[i + 1] != x2+1){ c1[x1][x2][x3] = 0; }
			} } }
		}
		if (p[i + 2]){
			f1{ f2{ f3{
				if (p[i + 2] != x3+1){ c1[x1][x2][x3] = 0; }
			} } }
		}

		f1{ f2{ f3{
			c2[x1][x2][x3] = c1[x1][x2][x3];
			c2[x1][x2][x3] %= 10000;
		} } }
	}

	int total=0;

	f1{ f2{ f3{
		total += c2[x1][x2][x3];
	} } }

	cout << total%10000<< endl;
	return 0;
}

Measured memory_bytes: 1160
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop acc =
        let step2 q =
            if q = 0 then acc else (
                let rec loop2 i acc =
                    if i = n then loop acc else
                        let c = a.(i) / n in
                        let () = a.(i) <- a.(i) - c * n + q - c in
                        loop2 (i + 1) (acc + c)
                in
                loop2 0 acc
            )
        in
        let rec loop2 i q =
            if i = n then step2 q else loop2 (i + 1) (q + a.(i) / n)
        in
        loop2 0 0
    in
    loop 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 4064
#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 emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mxn=200005;
int dx[mxn],dy[mxn];
struct UnionFind{
    int n;
    vector<int> data;
    UnionFind(int _n):n(_n),data(_n,-1){}
    int find(int x){return data[x]<0?x:data[x]=find(data[x]);}
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x!=y){
            if(data[y]<data[x]) swap(x,y);
            data[x]+=data[y];data[y]=x;dx[x]+=dx[y],dy[x]+=dy[y];
        }
        return;
    } 
    bool same(int x, int y){return (find(x) == find(y));}
    int size(int x){return -data[find(x)];}
};
int n;
int main(){
    cin>>n;
    UnionFind uf(mxn);
    int xi,yi;
    rep(i,100000) dx[i]=1,dy[i+100000]=1;
    rep(i,n){
        cin>>xi>>yi;
        --xi,--yi;
        uf.unite(xi,yi+100000);
    }
    ll ans=0;
    rep(i,mxn)if(uf.find(i)==i){
        ans+=(ll)dx[i]*dy[i];
    }
    cout<<ans-n<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int t, x;
    cin >> t >> x;

    cout << fixed << setprecision(5) << (double)t / (double)x << endl;

    return 0;
}


Measured memory_bytes: 888
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    string ans;
    cin >> n;
    while(n>0)
    {
        n--;
        ll k=n%26;
        ans+='a'+k;
        n=n/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>E[101000];
int n, m, Col[101000], cnt;
bool DFS(int a, int c){
    Col[a] = c;
    cnt++;
    int i;
    bool res = true;
    for(i=0;i<E[a].size();i++){
        if(Col[E[a][i]]){
            if(Col[E[a][i]] + c != 3)res = false;
        }
        else{
            if(!DFS(E[a][i], 3 - c))res = false;
        }
    }
    return res;
}
int main(){
    int i, a, b, c1 = 0, c2 = 0, c3 = 0;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }
    for(i=1;i<=n;i++){
        if(!Col[i]){
            cnt = 0;
            bool tp = DFS(i,1);
            if(cnt == 1)c1++;
            else if(tp)c2++;
            else c3++;
        }
    }
    printf("%lld\n",1ll*c1*c1 + 2ll*c1*(n-c1) + 1ll*(c2+c3)*(c2+c3) + 1ll*c2*c2);
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a;
    cin>>a;
    int ans=0;
    rep(i,20){
        if(a<pow(2,i)){
            ans=i-1;
            break;
        }

    }
    cout<<pow(2,ans)<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class Modint {
public:
	ll val;
	Modint(ll a) {
		val = (a+mod) % mod;
	}
	Modint operator+(const Modint& r) {
		return Modint((this->val + r.val) % mod);
	}
	Modint operator-(const Modint& r) {
		return Modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	Modint operator*(const Modint& r) {
		return Modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	Modint operator/(const Modint& r) {
		return Modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	Modint& operator+=(const Modint& r) {
		*this = *this + r;
		return *this;
	}
	Modint& operator-=(const Modint& r) {
		*this = *this - r;
		return *this;
	}
	Modint& operator*=(const Modint& r) {
		*this = *this * r;
		return *this;
	}
	Modint& operator/=(const Modint& r) {
		*this = *this / r;
		return *this;
	}

};

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(A.begin(), A.end());
	Modint<MOD> ans = 0;
	vector<Modint<MOD>> frac(300000, Modint<MOD>(1));
	for (int i = 1; i < 300000; i++) {
		frac[i] = frac[i-1] * Modint<MOD>(i);
	}

	for (int i = 0; i <= N - K; i++) {
		//A_i * (N-i-1)_C_K
		ans -= Modint<MOD>(A[i]) * frac[N - i - 1] / (frac[K - 1] * frac[N - i - K]);
	}
	for (int i = N - 1; i >= K - 1; i--) {
		ans += Modint<MOD>(A[i]) * frac[i] / (frac[K - 1] * frac[i - K + 1]);
	}
	cout << ans.val << endl;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k<0 || n<k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

mint f(int r,int c){
	mint res=0;
	rep(i,r+1) res+=choose(i+c+1,c);
	return res;
}

int main(){
	int r1,c1,r2,c2; scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
	cout<<f(r2,c2)-f(r1-1,c2)-f(r2,c1-1)+f(r1-1,c1-1)<<'\n';
	return 0;
}


Measured memory_bytes: 21752
#include <bits/stdc++.h>
using i64 = long long;

std::vector<int> c;
std::vector<std::vector<int>> g;

void dfs(int v, int p, int t) {
    c[v] += t;
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v, c[v]);
    }
}

int main() {
    int n, q;
    std::cin >> n >> q;
    c.resize(n);
    g.resize(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 0; i < q; i++) {
        int p, x;
        std::cin >> p >> x;
        c[p - 1] += x;
    }

    dfs(0, -1, 0);
    for (auto e : c) std::cout << e << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

V<V<int>> G;

int main() {
    int n, m; cin >> n >> m;
    G = V<V<int>>(n * 3, V<int>(0));
    loop (m, i) {
        int u, v; cin >> u >> v;
        u--, v--;
        G[u].push_back(n + v);
        G[n + u].push_back(2 * n + v);
        G[2 * n + u].push_back(v);
    }

    int s, t; cin >> s >> t;
    s--, t--;

    queue<int> Q;
    Q.push(s);

    V<int> dis(n * 3 + 1, -1);
    dis[s] = 0;

    while (1) {
        int u = Q.front();
        Q.pop();
        for (int v : G[u]) {
            if (dis[v] != -1) continue;
            dis[v] = dis[u] + 1;
            Q.push(v);
        }
        if (Q.empty()) break;
    }
    if (dis[t] == -1) cout << -1 << endl;
    else cout << dis[t] / 3 << endl;
    return 0;
}



Measured memory_bytes: 17792
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int a,a1,b,b1,ten=1,len=0;
    scanf("%d%d\n",&a,&b);
    b1=b;
    while(b1)
    {
        len++;
        b1/=10;
    }
    while(len)
    {
        ten*=10;
        len--;
    }
    a=a*ten+b;
    a1=sqrt(a);
    if(a1*a1==a)printf("Yes\n");
        else printf("No\n");
    return 0;
}

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

int main(){
int a,b;
string c;
cin >> a;
cin >> b;
if(a<b)
	c = "a < b";
if(a>b)
	c = "a > b";
if(a == b)
	c = "a == b";
cout << c << endl;
return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  int A[N]; rep(i, N) cin >> A[i];

  static int dp[111][222];
  rep(i, 111) rep(j, 222) dp[i][j] = inf;
  rep(i, 222) dp[0][i] = 0;

  rep(i, N) {
    rep(tar, 220) {
      dp[i + 1][tar] = min(dp[i + 1][tar], dp[i][tar] + (int)pow(abs(A[i] - (tar - 110)), 2));
    }
  }

  int ans = inf;

  rep(tar, 220) {
    minimize(ans, dp[N][tar]);
  }

  cout << ans << endl;
  
  return 0;
}

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

typedef long long ll;

const ll MOD = 1000000007;

int mpow(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c*a%MOD;
        b/=2;
        a = a*a%MOD;
    }
    return c;
}

int C (ll a, ll b) {
    ll nume = 1;
    for (int i = a; i > a-b; i--) {
        nume = nume*i%MOD;
    }
    ll deno = 1;
    for (int i = 2; i <= b; i++) {
        deno = deno*i%MOD;
    }
    return nume*mpow(deno, MOD-2) % MOD;
}

int main() {
    int x, y;
    cin >> x >> y;
    int a = (x+y)/3;
    int b = x-a;
    int c = y-a;
    if ((x+y)%3 != 0 || b < 0 || c < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << C(b+c, b) << endl;
    return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);

	cout << a << " " << b << " "  << c << endl;



	return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define N 2005
#define ll long long
const ll mod=1e9+7;
 
 
int main()
{
    ll l,r;
    cin>>l>>r;
 
    if(r-l>2018)printf("0");
    else
    {
        l%=2019,r%=2019;
        int ans=2019;
        for(int i=l;i<r;i++)
            for(int j=i+1;j<=r;j++)
            {
                ans=min(ans,(i*j)%2019);
            }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
Num,Count = zip(*sorted(collections.Counter(int(T) for T in input().split()).most_common()))
DisN = ((min(Num)-1),)+Num+((max(Num)+1),)
DisC = (0,)+Count+(0,)
MAX = 0
for T in range(1,len(Num)+1):
    Dis = DisC[T]
    if DisN[T-1]==DisN[T]-1:
        Dis += DisC[T-1]
    if DisN[T+1]==DisN[T]+1:
        Dis += DisC[T+1]
    if MAX<Dis:
        MAX = Dis
print(MAX)

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

int main() {
  int n, a, b;
  char s[200000];

  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%s", s);

  int a_qualified = 0;
  int b_qualified = 0;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (a_qualified + b_qualified < a + b) {
        a_qualified++;
        printf("Yes\n");
      } else {
        printf("No\n");
      }
    } else if (s[i] == 'b') {
      if (a_qualified + b_qualified < a + b && b_qualified < b) {
        b_qualified++;
        printf("Yes\n");
      } else {
        printf("No\n");
      }
    } else {
      printf("No\n");
    }
  }
}

Measured memory_bytes: 768
// Created by akashbhalotia
import java.io.*;
import java.util.*;
public class Main
{
    private static int N,a[];
    private static int solve(int i,int A, int B, int C, int f1,int f2, int f3)
    {
        if(i==N)
        {
            if(f1==0||f2==0||f3==0)
                return Integer.MAX_VALUE-100;

            int cost=Math.abs(A)+(f1-1)*10;
            cost+=Math.abs(B)+(f2-1)*10;
            cost+=Math.abs(C)+(f3-1)*10;

            return cost;
        }



        int w=solve(i+1,A,B,C,f1,f2,f3);
        int x=solve(i+1,A-a[i],B,C,f1+1,f2,f3);
        int y=solve(i+1,A,B-a[i],C,f1,f2+1,f3);
        int z=solve(i+1,A,B,C-a[i],f1,f2,f3+1);

        w=Math.min(w,x);
        x=Math.min(y,z);
        w=Math.min(w,x);

        return w;
    }

    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i;

        String s[]=br.readLine().trim().split(" ");
        N=Integer.parseInt(s[0]);
        int A=Integer.parseInt(s[1]);
        int B=Integer.parseInt(s[2]);
        int C=Integer.parseInt(s[3]);

        a=new int[N];

        for(i=0;i<N;i++)
            a[i]=Integer.parseInt(br.readLine().trim());

        System.out.println(solve(0,A,B,C,0,0,0));
    }
}

Measured memory_bytes: 22740
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	const long MOD = 1000000007;
	int N;
	long ans, D;
	long[] ds, cs, ct;
	bool[] done;
	List<E>[] g;
	public K()
	{
		var I = G;
		N = I[0];
		var M = I[1];
		I = G;
		var s = I[0] - 1;
		var t = I[1] - 1;
		g = new List<E>[N];
		for (var i = 0; i < N; i++) g[i] = new List<E>();
		for (var i = 0; i < M; i++)
		{
			I = G;
			int a = I[0] - 1, b = I[1] - 1, c = I[2];
			g[a].Add(new E(b, c));
			g[b].Add(new E(a, c));
		}
		ds = DijkstraFrom(s);
		cs = Count(s, ds);
		ct = Count(t, DijkstraFrom(t));
		done = new bool[N];
		ans = cs[t] * cs[t] % MOD;
		D = ds[t];
		DFS(t);
		WriteLine((ans %= MOD) < 0 ? ans + MOD : ans);
	}
	long Sq(long x) => x * x % MOD;
	void DFS(int u)
	{
		if (done[u]) return;
		done[u] = true;
		if (2 * ds[u] == D) ans -= Sq(cs[u] * ct[u] % MOD);
		foreach (var e in g[u]) if (ds[e.To] + e.D == ds[u])
			{
				if (2 * ds[u] > D && 2 * ds[e.To] < D) ans -= Sq(ct[u] * cs[e.To] % MOD);
				DFS(e.To);
			}
	}
	long[] Count(int u, long[] d)
	{
		var t = new List<E>();
		for (var i = 0; i < N; i++) t.Add(new E(i, d[i]));
		t.Sort();
		var c = new long[N];
		c[u] = 1;
		foreach (var v in t.Select(hoge => hoge.To)) foreach (var e in g[v]) if (d[e.To] + e.D == d[v]) c[v] = (c[v] + c[e.To]) % MOD;
		return c;
	}
	long[] DijkstraFrom(int u)
	{
		var d = new long[N];
		for (var v = 0; v < N; v++) d[v] = 4011686018427387913L;
		var queue = new PriorityQueue();
		d[u] = 0;
		queue.Enqueue(new E(u, 0));
		while (queue.Count > 0)
		{
			var p = queue.Dequeue();
			var v = p.To;
			if (d[v] < p.D) continue;
			foreach (var e in g[v])
			{
				var t = d[v] + e.D;
				if (d[e.To] > t) queue.Enqueue(new E(e.To, d[e.To] = t));
			}
		}
		return d;
	}
}
struct E : IComparable<E>
{
	public readonly int To;
	public readonly long D;
	public E(int t, long d) { To = t; D = d; }
	public int CompareTo(E e) => D.CompareTo(e.D);
}
class PriorityQueue
{
	readonly List<E> a = new List<E>();
	public int Count { get; private set; } = 0;
	public void Enqueue(E x)
	{
		var i = Count++;
		a.Add(x);
		while (i > 0)
		{
			var p = (i - 1) / 2;
			if (a[p].CompareTo(x) <= 0) break;
			a[i] = a[p];
			i = p;
		}
		a[i] = x;
	}
	public E Dequeue()
	{
		var v = a[0];
		var x = a[--Count];
		a.RemoveAt(Count);
		if (Count == 0) return v;
		var i = 0;
		while (i * 2 + 1 < Count)
		{
			var l = 2 * i + 1;
			var r = 2 * i + 2;
			if (r < Count && a[r].CompareTo(a[l]) < 0) l = r;
			if (a[l].CompareTo(x) >= 0) break;
			a[i] = a[l];
			i = l;
		}
		a[i] = x;
		return v;
	}
	public E Peek() => a[0];
}


Measured memory_bytes: 59396
N, W = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(N)] for _ in range(W+1)]
# 重さwまで品物nまででで最大になる価値

for n in range(N): # 品物nまでの世界で決めていく
    for w in range(W+1):
        vn, wn = K[n]
        if wn > w: # カバンに入りきらないなら入れられない
            dp[w][n] = dp[w][n-1]
        else: #カバンに入れられる可能性があるなら
            dp[w][n] = max(dp[w][n-1], vn+dp[w-wn][n-1]) #　入れた場合と入れなかった場合で価値の高い方を選ぶ

print(dp[W][N-1])


Measured memory_bytes: 26656
let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let W = input[1]

var weights: [Int] = .init(repeating: 0, count: N)
var values: [Int] = .init(repeating: 0, count: N)

for i in 0..<N {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  weights[i] = inp[0]
  values[i] = inp[1]
}

let V = values.reduce(0, +)

var dp: [[Int]] = .init(repeating: .init(repeating: .max, count: V + 1), count: N + 1)
dp[0][0] = 0
for i in 1...N {
  for j in 0...V {
   	let prev = j - values[i - 1]
    if prev < 0 || dp[i-1][prev] == .max {
      dp[i][j] = dp[i-1][j]
      continue
    }
    dp[i][j] = min(dp[i-1][prev] + weights[i - 1], dp[i-1][j])
  }
}
for j in (0..<dp[N].count).reversed() {
  if dp[N][j] <= W {
    print(j)
    break
  }
}

Measured memory_bytes: 87400
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


H,W = map(int, input().split())
An = [""] * H
for i in range(H):
  An[i] = str(input())

# dp[i][j] := (1,1)->(i,j)への経路数
dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[1][1] = 1
for i in range(1,H+1):
  for j in range(1,W+1):
    if An[i-1][j-1] == '.':
      dp[i][j] = (dp[i][j]+dp[i-1][j]+dp[i][j-1]) % (10**9+7)

print(dp[-1][-1])

Measured memory_bytes: 53852
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

// clang-format on
int main(){

    llint x;
    cin>>x;
    double tmp;
    FOR(b,-200,200){
        tmp=pow(x+b*b*b*b*b,0.2);
        if(abs(tmp-(llint)tmp)<0.000000001){
            cout<<(llint)tmp<<" "<<b<<endl;
            break;
        }
    }

    return 0;
}


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

int main() {
  int n , m ;
  cin >> n >> m;
  if(m==0){
    cout << n << endl;
  }
  else{
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    vec[i]=a;
  }
  int ans=0;
  int min=100;
  for(int i=-100;i<102;i++){
    bool hant=1;
	for(int j=0;j<m;j++){
      if(vec[j]==i)
        hant=0;
    }
    if(hant){
      if(abs(n-i)<min){
        min=abs(n-i);
        ans=i;
      }
    }
  }
  cout << ans << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

#define int long long
double const pi = 3.1415926535;

signed main(){
	int r;
	cin >> r;
	cout << 2*r*pi << endl;
	return 0;
}

Measured memory_bytes: 3772
l_vec = input().split()
def classifier1(l) :
    if ((l[0] == 'H') and (l[1] == 'H')) or ((l[0] == 'D') and (l[1] == 'D')) :
        return 'H'
    else :
        return 'D'
print(classifier1(l_vec))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i,j;
	cin>>N;
	vector<int> H(N);
	for (i=0;i<N;i++){
		cin>>H[i];
	}
	int ans=1;
	for (i=1;i<N;i++){
		bool OK=true;
		for (j=0;j<i;j++){
			if (H[j]>H[i]){
				OK=false;
				break;
			}
		}
		if (OK){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {

	string s; cin >> s;
	int ans = 0;
	int r_cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') r_cnt++;
	}
	if (r_cnt == 0) {
		ans = 0;
	}
	else if (r_cnt == 1) {
		ans = 1;
	}
	else if (r_cnt == 3) {
		ans = 3;
	}
	else {
		if (s[0] == 'R' && s[2] == 'R') {
			ans = 1;
		}
		else {
			ans = 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {
 
	long N; cin >> N;
	long res = 0;
	long A[100009], B[100009]; for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	long* mymax = max_element(A, A + N);

	for (int i = 0; i < N; i++) if (mymax == A + i) res = A[i] + B[i];

	cout << res << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n , sz[N] , ans;
vector<int> g[N];
int fp(int x , int y) {
    if(!y)
        return 1;
    int res = fp(x , y >> 1);
    res = (1ll * res * res) % mod;
    if(y & 1)
        res = (1ll * res * x) % mod;
    return res;
}
void dfs(int node , int par) {
    sz[node] = 1;
    for(auto &i : g[node])
        if(i != par) {
            dfs(i , node);
            sz[node] += sz[i];
        }
}
void solve(int node , int par) {
    // all n - 1 nodes are white
    int p = fp(fp(2, n - 1), mod - 2);
    for (auto &i : g[node])
        if (i != par) {
            solve(i, node);
            // subtree of i are all white
            int p1 = fp(fp(2, sz[i]), mod - 2);
            // subtree of i has at least one black node
            p1 = (1 - p1 + mod) % mod;
            // all n - 1 - sz[i] are white
            int p2 = fp(fp(2, n - 1 - sz[i]), mod - 2);
            p = (p + (1ll * p1 * p2) % mod) % mod;
        }
    // subtree of parent
    int p1 = fp(fp(2, n - sz[node]), mod - 2);
    p1 = (1 - p1 + mod) % mod;
    int p2 = fp(fp(2, sz[node] - 1), mod - 2);
    p = (p + (1ll * p1 * p2) % mod) % mod;
    p = (1 - p + mod) % mod;
    p = (1ll * p * fp(2, mod - 2)) % mod;
    ans = (ans + p) % mod;
}
int main() {
    abdelrahman010
    cin >> n;
    for(int i = 1;i < n;i++) {
        int u , v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1 , 1);
    solve(1 , 1);
    cout << ans;
    return 0;
}

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

int main() {
  ll X, A, B, ansA, ansB;
  cin >> X;
  bool isEnd = false;
  rep(i, 1000){
    rep(j, 1000){
      A = i*i*i*i*i;
      B = j*j*j*j*j;
      if(A-B == X) {
        isEnd = true;
        ansA = i;
        ansB = j;
        break;
      }
      if(A+B == X) {
        isEnd = true;
        ansA = i;
        ansB = -j;
        break;
      }
    }
    if(isEnd) break;
  }
  cout << ansA << " " << ansB << endl;
}


Measured memory_bytes: 3620
# coding: utf-8

# https://atcoder.jp/contests/abc105
# 12:25-


def main():
    N = int(input())

    n = 0
    while 4*n <= N:
        m = 0
        while 4*n + 7*m <= N:
            if 4*n + 7*m == N:
                return "Yes"
            m += 1
        
        n += 1
    
    return "No"


print(main())


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>


using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
int main() {

  string T;
  cin >> T;
  rep(i,T.length())
    if(T[i]=='?') T[i] = 'D';


  cout << T << endl;

}

Measured memory_bytes: 3724
#undef __STRICT_ANSI__
#include <bits/stdc++.h>
using namespace std;
int pd[100001], n, v[100001], k;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    pd[1]=0;
    for(int i=2; i<=n; i++)
    {
        pd[i]=INT_MAX;
        for(int j=1; j<=k; j++)
            if(i>j)
                pd[i]=min(pd[i], pd[i-j]+abs(v[i-j]-v[i]));
    }
    cout<<pd[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2;
}

Measured memory_bytes: 256
N = int(input())
# スペース区切りの整数をリストに入力
a = [int(x) for x in input().split()]

s = "APPROVED"

for i in a:
    if i % 2 == 1:
        continue
    if i % 3 == 0:
        continue
    if i % 5 == 0:
        continue
    s = "DENIED"
print(s)



Measured memory_bytes: 38256
import math

n = int(input())

ns = [int(i) for i in str(n)]
a = 0
b = 0
ans = 0
f = 0


y = math.sqrt(n)
for i in range(int(y),1,-1):
    if n % i == 0:
        a = i
        b = n // i
        break
else:
    ans = n - 1
    f = 1

# else:
#     z = math.sqrt(n)
#     for i in range(7,int(z)+1,2):
#         if n % i == 0:
#             a = i
#             b = n // i
#             break
#         else:
#             ans = n - 1
#             f = 1

# print('a',a)
# print('b',b)

if f:
    print(ans)
else:
    ans = a - 1 + b - 1
    print(ans)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	path := make([]int, 4)
	for i := 0; i < 3; i++ {
		p := nextInts(2)
		for _, v := range p {
			path[v-1] += 1
		}
	}
	for _, v := range path {
		if v > 2 {
			fmt.Printf("NO")
			return
		}
	}
	fmt.Printf("YES")
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,k;
ll a[1000010];
int main(){
	n=d,k=d;
	f(i,1,n)a[i]=d;
	f(i,k+1,n){
		if(a[i]>a[i-k])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 5184
#include <iostream>
#include <climits>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする



int main(){
	int prime[1005];
	long long int i,j;
	// 素数なら１、ちがうなら０
	for(i=1;i<=1000;i++){
		prime[i]=1;
	}
	prime[1]=0;
	prime[2]=1;
	for(i=2;i<=1000;i++){
		if(prime[i]==1){
			for(j=2;j*i<=1000;j++){
				prime[j*i]=0;
			}
		}
	}
	long long int n;
	cin>>n;
	int num[1005];
	long long int namae;
	memset(num,0,sizeof(num));
	for(i=2;i<=n;i++){
		if(prime[i]==1){
			num[i]+=1;
		}else{
			for(j=2;j<=i;j++){
				namae = i;
				while(prime[j]==1 && namae%j==0){
					num[j]+=1;
					namae=namae/j;
				}
			}
		}
	}
	long long int ans=1;
	for(i=1;i<=n;i++){
		ans *= (num[i]+1);
		ans = ans%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  vector<long long int> t(5);
  long long min_t = 1e15;
  long long ans = 0;
  
  long long n; cin >> n;
  for(int i = 0; i < 5; i++){
    cin >> t.at(i);
    min_t = min(min_t, t.at(i));
  }
  
  ans = 5 + (n-1) / min_t;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int INF = 1e9 + 239;

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

	vector<int> cnt(26);
	string s;
	cin >> s;
	int cm = 0;
	map<int, int> dpmin;
	dpmin[cm] = 0;
	int n = (int)s.size();
	vector<int> dp(n);
	for (int i = 0; i < n; i++) {
		char t = s[i];
		cm ^= (1 << (t - 'a'));
		int cdp = INF;
		if (dpmin.count(cm)) cdp = dpmin[cm];
		for (int j = 0; j < 26; j++) {
			if (dpmin.count(cm ^ (1 << j))) cdp = min(cdp, dpmin[cm ^ (1 << j)]);
		}
		cdp++;
		if (!dpmin.count(cm)) dpmin[cm] = INF;
		dpmin[cm] = min(dpmin[cm], cdp);
		dp[i] = cdp;
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 10644
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
string S = "";

int main() {
	scanf("%lld %lld", &N, &K);
	cin >> S;

	ll j = 0;
	ll i = 0;
	ll ans = 0;

	while(j < N && K > 0) {
		while(S[j] == '1' && j < N) {
			j++;
		}
		while(S[j] == '0' && j < N) {
			j++;
		}
		while(S[j] == '1' && j < N) {
			j++;
		}
		K--;
		if(K <= 0) {
			ans = max(ans, j - i);
			while(S[i] == '1' && i < N) {
				i++;
			}
			while(S[i] == '0' && i < N) {
				i++;
			}
			K++;
		}
		ans = max(ans, j - i);
	}
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef char* String;

String string_input(void){
    int i,len;
    char buf[100001];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    String S=string_input();

    int N=strlen(S);
    int ans=0;
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1]) ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 384
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を2と3以上の奇数で順次割っていくする（下から計算したら、素数判定は不要）
# 3. 2.の結果に含まれる数の種類の数＋１が答え

def main():
  a, b = sorted(list(map(int, input().split())), reverse = True) #aのほうを大きくする
  while b != 0: a, b = b, a % b #最大公約数を求める
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int(n ** 0.5) + 1
  
  if n == 1: return ans  
  for cursor in two_and_odds(max_n):
    if n % cursor == 0: ans += 1
    while n % cursor == 0: n = n // cursor
      
  if n != 1: ans += 1
  return ans

def two_and_odds(max_n):
  if max_n >= 2: yield 2
  for i in range(3, max_n, 2): yield i
    
if __name__ == "__main__":
  main()


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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod=1e9+7;
ll dp[N][110];

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,i,j,k;
	cin>>n>>k;
	int a[n],dp[k+1];
	for(i=0;i<n;i++)cin>>a[i];
	dp[0]=0;
	for( i=1;i<=k;i++ ){
		dp[i]=0;
		for(j=0;j<n;j++){
			if(a[j]<=i){
				dp[i]|=(1^dp[i-a[j]]);
			}
		}
	}
	cout<<(dp[k]?"First":"Second");
}
// check for any potential overflow before submitting


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef struct _info{
    int x;
    int y;
    int s;
    _info(int xx, int yy, int ss){
        x=xx; y=yy; s=ss;
    }
} info;

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

bool cango(int x1, int y1, int x2, int y2,
           vector<vector<bool> >& hwall, vector<vector<bool> >&wwall){
    if(x2<x1) swap(x1,x2);
    if(y2<y1) swap(y1,y2);
    if(x1<0 || y1<0) return false;
    if(x1==x2){
        return hwall[y1][x1];
    }else{
        return wwall[y1][x1];
    }
}

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w==0) break;

        vector<vector<bool> > map(h, vector<bool>(w, true));
        vector<vector<bool> > hwall(h, vector<bool>(w, false));
        vector<vector<bool> > wwall(h, vector<bool>(w, false));
        for(int i=0; i<h; i++){
            int tmp;
            for(int j=0; j<w-1; j++){
                cin >> tmp;
                if(tmp==0) wwall[i][j]=true;
            }
            if(i==h-1) break;
            for(int j=0; j<w; j++){
                cin >> tmp;
                if(tmp==0) hwall[i][j]=true;
            }
        }

        int gx=w-1;
        int gy=h-1;
        queue<info> search;
        info start(0,0,1);
        search.push(start);
        map[0][0]=false;
        bool find=false;
        while(!search.empty()){
            info cur = search.front();
            search.pop();
            if(cur.x==gx && cur.y==gy){
                cout << cur.s << endl;
                find = true;
                break;
            }

            for(int i=0; i<4; i++){
                int nx=cur.x+dx[i];
                int ny=cur.y+dy[i];
                if(cango(cur.x, cur.y, nx, ny, hwall, wwall) && map[ny][nx]){
                    info next(nx,ny,cur.s+1);
                    search.push(next);
                    map[ny][nx] = false;
                }
            }
        }
        if(!find){
            cout << 0 << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int h,w; cin >> h >> w;
  int a[90][90], b[90][90];
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; ++j){
      cin >> a[i][j];
    }
  }
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; ++j){
      cin >> b[i][j];
    }
  }
  bool dp[90][90][10000]={};
  for(int i = 0; i < 90; ++i)dp[i][0][0]=dp[0][i][0]=1;
  
  for(int i = 1; i <= h; ++i){
    for(int j = 1; j <= w; ++j){
      int d = abs(a[i][j] - b[i][j]);
      for(int k = 0; k < 10000; ++k){
	if((j==1||i>1)&&dp[i-1][j][k]){
	  int d2 = abs(k-d);	  
	  dp[i][j][d2]=true;
	  d2 = d+k;	  
	  dp[i][j][d2]=true;
	}
	if((i==0||j>1)&&dp[i][j-1][k]){
	  int d2 = abs(k-d);
	  dp[i][j][d2]=true;
	  d2 = k+d;
	  dp[i][j][d2]=true;
	}
      }
    }
  }
  int ans = 100000;
  for(int i = 0; i < 10000; ++i){
    if(dp[h][w][i]){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79360
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  string str;
  scanf("%d", &n);
  cin >> str;
  REP(i, str.size()){
    if (str.at(i) + n < 91){
      cout << (char)(str.at(i) + n);
    }else if (str.at(i) + n > 90){
      cout << (char)(str.at(i) + n -26);
    }
  }
  printf("\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;

typedef long long ll;

ll ans;
ll n, k;
ll a[5005];
bool d[10005];
vector<ll> ve;

bool f(ll p)
{
    bitset<5005> bs;
    bs = 1;
    for(ll i = 0; i < n; i++)
    {
        if(i == p) continue;
        bs |= (bs << ve[i]);
    }
    for(ll i = k - ve[p]; i < k; i++)
    {
        if(bs[i]) return true;
    }
    return false;
}

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if(a[i] > k) continue;
        ve.push_back(a[i]);
    }
    n = ve.size();
    sort(ve.begin(), ve.end());
    ll lt = 0, rt = n - 1, mid, ans = n;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid)) rt = mid - 1, ans = mid;
        else lt = mid + 1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
integer :: n,p(20)
integer :: i,ans

read*,n
read*,p(1:n)

ans = 0

do i = 2,n-1
  if( (p(i-1)<p(i) .and. p(i)<p(i+1)) .or.&
      (p(i-1)>p(i) .and. p(i)>p(i+1))) ans = ans + 1
end do
print*,ans
end program


Measured memory_bytes: 2792
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i, 3)
        if( s[i] == t[i] ) ans++;
    cout << ans;
    return 0;    
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int sum = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '0'){
            continue;
        }
        sum += (int)s[i] - 48;
    }

    if(sum%9 == 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 3684
N, A, B = list(map(int, input().split()))

if N == 1:
  if A != B:
    print(0)
  else:
    print(1)
  exit()
if A > B:
  print(0)
  exit()

N -= 2
Ans = (B - A) * N + 1
print(Ans)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val x = readLine()!!.toLong()
    var best = x - 1L
    (1L..1000003L).forEach { a ->
        if (x % a == 0L) {
            val b = x /a
            val c = a - (if (a == 1L) 0L else 1L) +
                    b - (if (b == 1L) 0L else 1L)
            best = Math.min(best, c)
        }
    }

    println(best)
}


Measured memory_bytes: 33728