akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}
int dp[100001];
void solve()
{
  //code begins from here//
  int n;
  cin>>n;
  int a[n+1];
  lop1(i,n) cin>>a[i];
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
      dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      if(i>2) minn(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n]<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


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

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 
#define rep(i, n) for(int i = 0;i < n;i++)
using namespace std;

using ll = long long;



int main()
{
	string x;
	int n;

	cin >> n;
	cin >> x;

	int cnt = 0;
	int l = 0;
	rep(i,n) {
		if (x[i] == '(') {
			cnt++;
		}
		else {
			cnt--;
		}
		l = min(l, cnt);
	}

	
	if (l >= 0) {
		cout << x;
		rep(i,cnt) {
			cout << ")";
		}
	}
	else {
		rep(i, -l) {
			cout << "(";
		}
		cout << x;
		rep(i, -l + cnt) {
			cout << ")";
		}

	}
	cout << endl;

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight capacity, cost;
  int rev;
};
bool operator < (const Edge &e, const Edge &f) {
  return e.cost != f.cost ? e.cost > f.cost : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int s, int d, Weight cap, Weight cost) {
  g[s].push_back((Edge){s,d,cap,cost,g[d].size()});
  g[d].push_back((Edge){d,s,0,-cost,g[s].size()-1});
}

// Bellman-Ford
pair<Weight, Weight> minimumCostFlow3(Graph g, int s, int t) {
  const int n = g.size();
  pair<Weight, Weight> total; // (cost, flow)

  for (int F = INF; F > 0;) { // residual flow
    vector<Weight> d(n, INF); d[s] = 0;
    vector<int> pv(n), pe(n);
    REP(k, n) REP(i, n) if (d[i] < INF) REP(j, g[i].size()) {
      Edge &e = g[i][j];
      if (e.capacity == 0) continue;
      if (d[e.dst] > d[i] + e.cost) {
        d[e.dst] = d[i] + e.cost;
        pv[e.dst] = i; pe[e.dst] = j;
      }
    }
    if (d[t] == INF) break;
    Weight f = F;
    for (int u = t; u != s; u = pv[u]) {
      f = min(f, g[pv[u]][pe[u]].capacity);
    }
    if (!f) break;
    for (int u = t; u != s; u = pv[u]) {
      total.first += f * g[pv[u]][pe[u]].cost;
      // cout << f * cost[p[u]][u] << endl;
      g[pv[u]][pe[u]].capacity -= f;
      g[u][g[pv[u]][pe[u]].rev].capacity += f;
    }
    F -= f;
    total.second += f;
  }
  return total;
}

int main() {
  int n;
  while(cin >> n, n) {
    Graph g(367);
    
    REP(i, n) {
      int a, b, w;
      cin >> a >> b >> w;
      add_edge(g, a-1, b, 1, -w);
    }
    REP(i, 366) {
      add_edge(g, i, i+1, 2, 0);
    }
    cout << -minimumCostFlow3(g, 0, 366).first << endl;
  }
}

Measured memory_bytes: 1052
#include<iostream>
#include<string>
#include<vector>
#include <iosfwd>
#include <sstream>
#include<stdio.h>
using namespace std;
#define _dg cout << "debug" << endl;

int main(){
    string a;
    int k=0;
    cin >> a;
    const char* x= a.c_str();
    vector<int> v;
    for(int i=0; i<strlen(x); i++){
        v.emplace_back(x[i]-'0');
    }
    int len = v.size();
    int cnt=0;
    int c= len;
    while(k<len-1){
        if((v[k])+(v[k+1])==1){
            v.erase(v.begin()+k);
            v.erase(v.begin()+k); 
            // cout << k << endl;
            cnt+=2;
            k-= 2;
        }
        if(k<-1) k=-1;
        // for(int h: v){
        //     cout << h;
        // }cout << endl;
        
        len= v.size();
        k++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 1020
/*      Welcome to my Code      */

#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a
#define co(a)                   cout<<a
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define sr(a,n)                 sort(a,a+n)
#define rv(a,n)                 reverse(a,a+n)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;

using namespace std;

int main()
{
    fast;
    double d,s,t;
    cin>>d>>t>>s;
    if((d/s)<=t) cout<<"Yes";
    else cout<<"No";
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/


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

int main()
{
   int n; cin>>n;
   
   map<string,int>s;
  
  
   for(int i=0;i<n;i++)
   {
        string a;
     
        cin>>a;
   
        s[a]++;
      
   }
  int mx =0;
  for(auto p:s) mx = max(mx,p.second);
   
   int cnt=0;
  
   for(auto x:s)
   {
        if(x.second==mx)
        {
            cout<<x.first<<endl;
        }
       else
       {
           continue;
       }   
     
   }
     

return 0;

}


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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)6e5 + 7;
const int lmaxn = (int)6e6 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

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

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

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

string s;
ll a[maxn], sz;

int main(){
    cin >> s;
    for(auto i : s){
        if(i == '0') a[++sz] = 0;
        else if(i == '1') a[++sz] = 1;
        else --sz;
        sz = max(0ll, sz);
    }
    for(ll i = 1; i <= sz; ++i)
        cout << a[i];
    return 0;
}



Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,1,N+1){
        double nn = i;
        nn *= 1.08;
        nn = floor(nn);
        if((ll)nn == N){
            print(i);
            return 0;
        }
    }
    print(":(");

}

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

int main(){
        int h,w,i,j,y,x,cnt;
        char tmp;
        cin >> h >> w;
        vector<vector<int>> a(h, vector<int>(w));
        queue<vector<int>> q;
        for(i=0;i<h;++i){
                for(j=0;j<w;++j){
                        cin >> tmp;
                        if(tmp=='#'){
                                a.at(i).at(j) = 1;
                                q.push({i, j, 0});
                        }
                        else a.at(i).at(j) = 0;
                }
        }
        while(!q.empty()){
                vector<int> v = q.front(); q.pop();
                y = v.at(0);
                x = v.at(1);
                cnt = v.at(2);
                if(x+1<w && a.at(y).at(x+1)==0){
                        a.at(y).at(x+1) = 1;
                        q.push({y, x+1, cnt+1});
                }
                if(x-1>=0 && a.at(y).at(x-1)==0){
                        a.at(y).at(x-1) = 1;
                        q.push({y, x-1, cnt+1});
                }
                if(y+1<h && a.at(y+1).at(x)==0){
                        a.at(y+1).at(x) = 1;
                        q.push({y+1, x, cnt+1});
                }
                if(y-1>=0 && a.at(y-1).at(x)==0){
                        a.at(y-1).at(x) = 1;
                        q.push({y-1, x, cnt+1});
                }
        }
        cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 59572
import itertools

n, m = map(int, input().split())

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

for i in itertools.permutations(range(n), n):
    #print(i)
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break

print(ans)


Measured memory_bytes: 3064
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct DisjointSet {
	vector<int> rank, p;

	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++) makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

struct Edge {
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0) :
		source(source), target(target), cost(cost) {}
	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges) {
	int totalCost = 0;
	sort(edges.begin(), edges.end());

	DisjointSet dset = DisjointSet(N + 1);

	for (int i = 0; i < N; i++) dset.makeSet(i);

	for (unsigned int i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if (!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}

int main() {
	int N, M, cost;
	int source, target;

	cin >> N >> M;

	vector<Edge> edges;
	for (int i = 0; i < M; i++) {
		cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	}

	cout << kruskal(N, edges) << endl;

	return 0;
}


Measured memory_bytes: 5448
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int b,r,g,c,s,t;
  while(cin>>b>>r>>g>>c>>s>>t&&b+r+g+c+s+t)
    cout<<100+b*80+r*54+g*7+c*2+s*3-(t-b*5-r*3)*3<<endl;
  return 0;
}

Measured memory_bytes: 0
#include "stdio.h"
void call(int n){
int x,i=1;
while(++i<=n){
x=i;

if((x%3)==0){
printf(" %d",i);
}else{
while(x){
if((x%10)==3){
printf(" %d",i);
break;
}
x/=10;
}
}
}
puts("");                                                                                                                               
}
int main(void){
int n;
scanf("%d",&n);
call(n);
return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, hs[100100];
int dp[100100];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> hs[i];
    }

    std::fill(dp, dp+N, 1001001001);
    dp[0] = 0;

    for(int i=0;i+1<N;++i){
        dp[i+1] = std::min(dp[i+1], dp[i] + std::abs(hs[i+1] - hs[i]));

        if(i+2 < N){
            dp[i+2] = std::min(dp[i+2], dp[i] + std::abs(hs[i+2] - hs[i]));            
        }
    }

    std::cout << dp[N-1] << std::endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
vector<pair<int, int>> ps, L, R;

void _main() {
    cin >> N;
    ps.resize(N);
    REP (i, N) cin >> ps[i].second >> ps[i].first;
    sort(ps.begin(), ps.end());
    L.resize(N);
    R.resize(N);
    int l = -1, r = 1000000001;
    REP (i, N) {
        l = max(l, ps[i].second);
        r = min(r, ps[i].first);
        L[i] = {l, r};
    }
    l = -1, r = 1000000001;
    REP (i, N) {
        l = max(l, ps[N - i - 1].second);
        r = min(r, ps[N - i - 1].first);
        R[N - i - 1] = {l, r};
    }
    int ans = 0;
    REP (i, N - 1) {
        int numL = max(0LL, L[i].second - L[i].first + 1);
        int numR = max(0LL, R[i + 1].second - R[i + 1].first + 1);
        ans = max(ans, numL + numR);
    }
    FOR (i, 1, N - 1) {
        ans = max(ans, ps[i].first - ps[i].second + 1 + max(0LL, min(L[i - 1].second, R[i + 1].second) - max(L[i - 1].first, R[i + 1].first) + 1));
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}


int main(void){
	int n,c,a,b;
	cin>>n>>c;
	vector<ll> A,B;
	A.push_back(-1);B.push_back(-1);
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	rep(i,n){
		cin>>b;
		B.push_back(b);
	}
	vector<vector<ll>> dp;
	rep(i,n+1){
		dp.push_back(vector<ll>());
		rep(j,c+1){
			dp[i].push_back(0);
		}
	}
	dp[0][0] = 1;
	reps(i,n){
		a = A[i];
		b = B[i];
		for(int x = a; x <= b; x++){
			vector<ll> dp2;
			rep(j,c+1){
				dp2.push_back(dp[i-1][j]);
				//cout<<dp2[j]<<" ";
			}
			rep(j,c){
				dp2[j+1] += dp2[j] * x;
				dp2[j+1] %= MOD;
			}
			rep(j,c+1){
				dp[i][j] += dp2[j];
				dp[i][j] %= MOD;
			}
		}
	}
	/*rep(i,n+1){
		rep(j,c+1){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[n][c]<<endl;
	return 0;
}


Measured memory_bytes: 1920
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

res = []
x = n
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)

from collections import Counter
import bisect

c = Counter(res)

tt = [i for i in range(1,60)]
for j in range(1,len(tt)):
    tt[j] += tt[j-1]

ans = 0
for v in c.values():
    ans += bisect.bisect_right(tt,v)

print(ans)

Measured memory_bytes: 9492
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=a+b,cnt=c+d;
    if (ans==cnt)
        cout<<"Balanced"<<endl;
    else  if (ans>cnt)
            cout<<"Left"<<endl;
          else
            cout<<"Right"<<endl;
    system("pause");
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, k; cin >> n >> k;
    string s; cin >> s;

    vector<int> a;

    int cur = 1;
    for(int i = 1; i < n; ++i) {
        if(s[i] == s[i-1]) ++cur;
        else {
            a.push_back(cur);
            cur = 1;
        }
    }
    a.push_back(cur);

    if(s[0] == '0') a.insert(a.begin(), 0);
    if(s[n-1] == '0') a.push_back(0);

    int sz = a.size();
    
    int rk = min(2*k, sz-1);
    
    int sm = 0;
    for(int i = 0; i <= rk; ++i) {
        sm += a[i];
    }

    int ans = sm;
    for(int i = rk+1; i < sz; i += 2) {
        sm -= a[i-rk-1] + a[i-rk];
        sm += a[i] + a[i+1];
        ans = max(ans, sm);
    }

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


Measured memory_bytes: 1528
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    priority_queue<ll> que;
    ll n,m,ans=0;
    cin >> n >> m;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        que.push(a);
    }
    for (ll i=0;i<m;i++){
        ll a=que.top();
        que.pop();
        a/=2;
        que.push(a);
    }
    for (ll i=0;i<n;i++){
        ans+=que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int lower = Math.max(a, Math.max(b, c));
            int ans = Integer.MAX_VALUE;

            for (int n = lower; n <= 100; n++) {
                for (int ia = a; ia <= n; ia += 2) {
                    for (int ib = b; ib <= n; ib += 2) {
                        for (int ic = c; ic <= n; ic += 2) {
                            int x[] = {n - ia, n - ib, n - ic};
                            Arrays.sort(x);
                            if ( x[2] - x[0] == x[1] ) {
                                int cnt = (ia - a) / 2 + (ib - b) / 2 + (ic - c) / 2;
                                cnt += (x[0] + x[1] + x[2]) / 2;
                                ans = Math.min(ans, cnt);
                            }
                        }
                    }
                }
            }

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 59604
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

int main(){

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for (int h: irange(0, H)){
        if (h < B){
            for (int w: irange(0, W)){
                if (w < A) cout << '0';
                else cout << '1';
            }
        }
        else{
            for (int w: irange(0, W)){
                if (w < A) cout << '1';
                else cout << '0';
            }
        }
        cout << endl;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
H, W = MAP()
S = [input() for _ in range(H)]

w = [[-1]*W for _ in range(H)]
h = [[-1]*W for _ in range(H)]

for i in range(H):
	cnt = 0
	for j in range(W):
		if S[i][j] == ".":
			cnt += 1
			w[i][j] = cnt
		else:
			cnt = 0
	for j in range(W-2, -1, -1):
		if S[i][j] == ".":
			w[i][j] = max(w[i][j], w[i][j+1])


for i in range(W):
	cnt = 0
	for j in range(H):
		if S[j][i] == ".":
			cnt += 1
			h[j][i] = cnt
		else:
			cnt = 0

	for j in range(H-2, -1, -1):
		if S[j][i] == ".":
			h[j][i] = max(h[j][i], h[j+1][i])


ans = 0
for i in range(H):
	for j in range(W):
		if h[i][j] != -1 and w[i][j] != -1:
			ans = max(ans, h[i][j]+w[i][j]-1)
print(ans)








Measured memory_bytes: 141380
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef struct st{int s,t;double d;}st;
int N,U[100],i,j,k;
double P[100][4],R;
st D[10005];
int s(const void *a,const void *b){return ((st*)a)->d-((st*)b)->d>0;}
int pa(int n){return U[n]!=n?pa(U[n]):n;};
int eq(int a,int b){return pa(a)==pa(b);}
int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0;i<N;i++)
			scanf("%lf%lf%lf%lf",&P[i][0],&P[i][1],&P[i][2],&P[i][3]);
		for(i=k=0;i<N-1;i++)
			for(j=i+1;j<N;j++)
			{
				double *p=P[i],*q=P[j],d;
				d=sqrt((p[0]-q[0])*(p[0]-q[0])+(p[1]-q[1])*(p[1]-q[1])+(p[2]-q[2])*(p[2]-q[2]));
				d=d<p[3]+q[3]?0:d-p[3]-q[3];
				D[k].s=i;
				D[k].t=j;
				D[k].d=d;
				k++;
			}
		qsort(D,k,sizeof(st),s);
		for(i=0;i<N;i++)U[i]=i;
		for(i=R=0;i<k;i++)
		{
			if(!eq(D[i].s,D[i].t))
			{
				U[pa(D[i].s)]=pa(D[i].t);
				R+=D[i].d;
			}
		}
		printf("%.3f\n",R);
	}
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    string ans = (s=="AAA"|| s=="BBB") ? "No" :"Yes";
    cout<< ans <<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif


int main(void)
{
	ll n; cin >> n;

	cout << pow(n, 3);
	return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<ll> a(n+1),b(m);
    for1(i,n) cin>>a[i];
    for(auto& it:b) cin>>it;
    for(int i=1;i<=n;i++) a[i]+=a[i-1];
    for(int i=1;i<m;i++) b[i]+=b[i-1];
    ll ans=0;
    forn(i,n+1){
        ll left=k-a[i];
        if(left<0) break;
        ll pos=upper_bound(all(b),left)-b.begin();
        ans=max(ans,i+pos);
    }
    cout<<ans;
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		int cost1 = dp[i - 2] + abs(h[i] - h[i - 2]);
		int cost2 = dp[i - 1] + abs(h[i] - h[i - 1]);
		dp[i] = min(cost1, cost2);
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
def divide_two(c, z):
    min_b = z // 2 + 1
    max_b = min(c-1, z-1)
    return max(max_b-min_b+1, 0)
    

num_set = []
cnt = 0
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0):
        break
    else:
        num_set.append((n, x))
        cnt += 1

for i in range(cnt):
    num_count = 0
    (n, x) = num_set[i]
    for c in range(x//3, n+1):
        num_count += divide_two(c, x-c)
    print(num_count)


Measured memory_bytes: 5600
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cinai(a, n);

    vi aidx(n);
    for(int i=0; i<n; i++)
        aidx[i]=i;

    sort(aidx.begin(), aidx.end(), [&](int i1, int i2) {
        return a[i1]<a[i2];
    });

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

}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;//×Ô¶¯È¡Ä£2^64 
const double pi=acos(-1.0);
const int mod = 998244353; // 998244353;
const int inf = 0x7fffffff;//2^31-1	
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//double begin_time=clock();    double end_time=clock();printf("time= %f ms\n",end_time-begin_time);
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //¿ìËÙÃÝÈ¡Ä£ 
//lower_bound(begin,end,num); µÚÒ»¸ö>=numµÄÊý×Ö upper_bound(begin,end,num); µÚÒ»¸ö>numµÄÊý×Ö,·µ»ØµØÖ·
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //ÎÄ¼þ¶ÁÐ´Ìá½» 
//reverse(s.begin(),s.end());   //·­×ª×Ö·û´® ||        floor(); ÏòÏÂÈ¡Õû  ceil(); ÏòÉÏÈ¡Õû
//ÊýÖáÉÏµÄn¸öµãÒÆ¶¯µ½Í¬Ò»Î»ÖÃ£¬ÒÆ¶¯µ½¸Ã×éÊý×ÖµÄÖÐÎ»ÊýµÄ×Ü¾àÀë×î¶Ì
//bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
//int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//ÅÐ¶ÏËØÊý   


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b,c,d,e,f,T;
//	cin>>T;
//	while(T--)
	{
		cin>>a>>b>>c>>d>>e;
		a*=60;a+=b;
		c*=60;c+=d;
		c-=a;c-=e;
		cout<<c<<endl;
		
	}
 
 
 
}




Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<ii>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

ll n, arr[N], dp[N][3];

ll solve(int id, int taken, int skipped)
{
	if (id >= n) return (taken == n / 2) ? 0 : -1e18;
	if (dp[id][skipped] != -1) return dp[id][skipped];
	ll ans = -1e18;
	if (skipped < 2) ans = max(ans, solve(id + 1, taken, skipped + 1));
	ans = max(ans, solve(id + 2, taken + 1, skipped) + arr[id]);
	return dp[id][skipped] = ans;
}

int main()
{ 
	assem99;
	memset(dp, -1, sizeof(dp));
	cin >> n;
	rep(i, 0, n) cin >> arr[i];
	cout << solve(0, 0, 0);

	return 0;
}


Measured memory_bytes: 17696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		long[] a = GetLongs(N);

		long[] cnt = new long[N];
		for(long i = 0; i < N; i++)
		{
			long tmp = a[i] / 2;
			while(tmp > 0 && tmp % 2 == 0)
			{
				cnt[i]++;
				tmp /= 2;
			}
		}

		if(cnt.Any(x => x != cnt[0]))
		{
			WriteLine(0);
			return;
		}

		long l = a[0] / 2;
		for(long i = 1; i < N; i++)
		{
			l = lcm(l, a[i] / 2);
			if(l > M)
			{
				WriteLine(0);
				return;
			}
		}

		WriteLine((M - l) / (2 * l) + 1);
	}

	private long lcm(long x, long y) => (x / gcd(x,y)) * y;
	private long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 27996
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
char a[2][3];
int main(){
   int n;
   cin>>n;
   n=sqrt(n);
   cout<<n*n;
    return 0;
}


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

int main(){
	int n,k;
	cin >> n >> k;
	int h[n];
	int ans = 0;
	rep(i,n){
		cin >> h[i];
		if(h[i] >= k){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll al = 0;
  map<int, int> mp;
  bool flag = true;
  rep(i,n) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      flag = false;
    }
  }
  printf(!flag ? "first" : "second");
  END;
}


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

using ll = long long ; 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


mint fact(int N , int M ){
  mint sum_N = 1;
  mint sum_M = 1;
  
  for (int i = 1; i <= N; ++i){
    sum_N *= i;
  }
  for(int i = 1 ; i <= M ; i++){
    sum_M *= i ; 
  }
  return sum_M*sum_N ; 
}

int main(){
  int N , M ; 
  cin >> N >> M ; 
  mint A ; 
  if(N > M+1 || M > N+1) cout << 0 << endl ; 
  else if( N == M+1) cout << fact(N , M) << endl ; 
  else if( M == N+1) cout << fact(N , M) << endl ; 
  else {
    A = fact(M , M) ;
    A *= 2 ; 
    cout << A << endl ; 
  }
  
  return 0 ; 
}

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

int main()
{
    int n,c=0;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0 ; i < n-2 ; i ++)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
           c++;
        }
    }
    cout << c;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>

int main()
{
    int64_t N, M;

    std::cin >> N >> M;

    std::map<int64_t, std::set<int64_t>> G;

    for (int64_t m = 0; m < M; ++m)
    {
        int64_t a, b;
        std::cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
    }

    std::set<int64_t> r;
    for (int64_t i = 1; i <= N; ++i) {
        r.insert(i);
    }
    size_t m = 0;
    while (true)
    {
        if (r.empty()) break;

        std::set<int64_t> g1;
        std::set<int64_t> g2;
        g2.insert(*r.begin());
        int64_t s = *r.begin();
        r.erase(s);
        while (!g2.empty())
        {
            int64_t s = *g2.rbegin();
            g2.erase(s);
            g1.insert(s);
            auto x = G[s];

            for (auto xx : x) {
                if (g1.find(xx) == g1.end()) {
                    g2.insert(xx);
                }
            }
        }
        for (auto gg : g1)
        {
            r.erase(gg);
        }
        m = std::max(m, g1.size());
    }

    std::cout << m << std::endl;
    
    return 0;
}



Measured memory_bytes: 59836
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<string.h>
#include<queue>
#include <set>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
    int n;
    int a[105][105];
    int dp[105][105];
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        for(int i=1; i<=2; i++)
            for(int j=1; j<=n; j++)
                scanf("%d",&a[i][j]);
        dp[1][1]=a[1][1];
        for(int i=1; i<=2; i++)
            for(int j=1; j<=n; j++)
            {
                if(i==1)
                    dp[i][j]=dp[i][j-1]+a[i][j];
                else
                    dp[i][j]=max(dp[i-1][j]+a[i][j],dp[i][j-1]+a[i][j]);

            }

        printf("%d\n",dp[2][n]);
    }
    return 0;
}
/*
5
3 2 2 4 1
1 2 2 2 1
*/
//using namespace std;
//char s[1000005];
//int a[1000005];
//vector<int>v[1000005];
//int main()
//{
//    //vector<int>v[1000004];
//    set<int>q;
//    memset(a,0,sizeof(a));
//    scanf("%s",s);
//    int len=strlen(s);
//    if(s[0]=='1')
//        a[1]=1;
//    else
//        a[1]=-1;
//    v[0].push_back(0);
//    for(int i=1; i<len; i++)
//    {
//        if(s[i]=='1')
//            a[i+1]=a[i]+1;
//        else
//            a[i+1]=a[i]-1;
//        q.insert(a[i+1]);
//        v[a[i+1]].push_back(i+1);
//    }
//    int sum=0;
//    set<int>::iterator iter = q.begin();
//    for(iter; iter!=q.end(); iter++)
//    {
//        int qq=*iter;
//        int ze=v[qq].size();
//        if(ze==1)
//            continue;
//        sum=max(sum,v[qq][ze-1]-v[qq][0]);
//    }
//
//
//    printf("%d\n",sum);
//    return 0;
//
//}
//int main()
//{
//   int a[1005];
//   int t;
//   scanf("%d",&t);
//   while(t--)
//   {
//       int n;
//       scanf("%d",&n);
//       for(int i=1;i<=n;i++)
//        scanf("%d",&a[i]);
//        int i=1;
//        int sum=0,nn=n,kai=1;
//        if(a[1]==n)
//        {
//            while(a[i]==nn)
//            {
//                i++;
//                nn--;
//                sum++;
//            }
//            if(a[i]==1)
//            {
//                while(a[i]==kai)
//                {
//                    kai++;
//                    i++;
//                    sum++;
//                }
//            }
//        }
//        if(sum==n)
//            printf("No\n");
//        else
//            printf("Yes\n");
//    }
//    return 0;
//}
//


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+1+3);
	if(a[2]-a[1]==a[3]-a[2])
	{
		cout<<"YES";
		return 0;
	}
	else
	{
		cout<<"NO";
		return 0;
	}
	return 0;
} 

Measured memory_bytes: 256
n = input()
digit1 = int(n[-1])
ans = ''

if digit1 in {2, 4, 5, 7, 9}:
    ans = 'hon'
elif digit1 in {0, 1, 6, 8}:
    ans = 'pon'
elif digit1 in {3}:
    ans = 'bon'

print(ans)


Measured memory_bytes: 9164
S = input()
leng = len(S)
S = S[::-1]

count = [0] * 2019
count[0] = 1

num = 0
d = 1

for char in S:
    num += int(char) * d
    num %= 2019
    count[num] += 1
    d *= 10
    d %= 2019


res = 0
for cnt in count:
    res += cnt * (cnt - 1) // 2

print(res)


Measured memory_bytes: 9288
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n;
   cin >> n;
   int d[n];
   REP(i,n) cin >> d[i];
   
   int ans=0;
   REP(i,n){
      for(int j=i+1; j<n; j++){
         ans+=d[i]*d[j];
      }
   }
   
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()

{
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
    return 0;
}

Measured memory_bytes: 256
# include<iostream>
using namespace std;
int C[20];
int A[20][20];
int B[20];
int N,M,X;
int V[20];
const int INF = 1e9+7;
int MIN =INF;

void  dfs(int i,int sum)
{
	if(i>=N)
	{
		
	
		
		bool ok = true;
        for(int j=0;j<M;j++)
        {
        	 if(V[j]<X)
        	 {
        	 	ok = false;
        	 	break;
			 }
		}
       				 
	    if(ok)
		{
	  
		   MIN = min(MIN,sum);	
		}			 
				 
		return;
	}
	dfs(i+1,sum);
	for(int j=0;j<M;j++)
	{
		V[j] += A[i][j];
	}
	dfs(i+1,sum+C[i]);
	for(int j=0;j<M;j++)
	{
		V[j] -= A[i][j];
	}	

	
	
	
}

int main ()
{

	 cin>>N>>M>>X;

	 for(int i=0;i<N;i++)
	 {
	 	  cin>>C[i];
	 	  for(int j=0;j<M;j++)
	 	  {
	 	  	  cin>>A[i][j];
		   }
		   
		   
	 }
	
	
	 dfs(0,0);
	 if(MIN==INF)
	 {
	 	cout<<"-1"<<endl;
	 }
	 else
	 cout<<MIN<<endl;
	
	
	
	
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#define MAXN 2152145
using namespace std;
const double pi=acos(-1.0);
struct Complex
{
	double r,i;
	Complex(){}
	Complex(double _r,double _i)
	{r=_r;i=_i;}
}a[MAXN],b[MAXN],c[MAXN];
Complex operator+(Complex A,Complex B)
{return Complex(A.r+B.r,A.i+B.i);}
Complex operator-(Complex A,Complex B)
{return Complex(A.r-B.r,A.i-B.i);}
Complex operator*(Complex A,Complex B)
{return Complex(A.r*B.r-A.i*B.i,A.r*B.i+B.r*A.i);}
int n,m,k,len,bit;
int rev[MAXN];
void FFT(Complex*a,int len,int f)
{
	for (int i=0;i<len;i++)
	if (i<rev[i])swap(a[i],a[rev[i]]);
	for (int p=1;p<len;p<<=1)
	{
		Complex wn(cos(pi/p),sin(pi/p)*f);
		for (int i=0;i<len;i+=(p<<1))
		{
			Complex e(1,0);
			for (int j=0;j<p;j++,e=e*wn)
			{
				Complex x=a[i+j],y=a[i+j+p]*e;
				a[i+j]=x+y;a[i+j+p]=x-y;
			}
		}
	}
	if (f==1)return;
	for (int i=0;i<len;i++)
	a[i].r/=double(len);
}
long long cnt[200010],p=200003,mi[200010],x0,pos[200010],res[400010],ans,d[200010];
int main()
{
	int i,now=1,t;
	for(i=0;i<p-1;i++)
	{
         mi[i]=now;
         pos[now]=i;
         now=now*2%p;
     }
     cin>>x0;
     for(i=1;i<=x0;i++)
     {
         cin>>t;
         d[i]=t;
         if(t!=0)cnt[pos[t]]++;
     }
     n=m=p;
	n++;m++;k=n+m-1;len=1;
	while (len<k)len<<=1,bit++;
	for (i=0;i<n;i++)a[i].r=b[i].r=cnt[i];
	for (i=1;i<len;i++)
	rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));
	FFT(a,len,1);FFT(b,len,1);
	for (i=0;i<len;i++)c[i]=a[i]*b[i];
	FFT(c,len,-1);
	for(i=0;i<k;i++) res[i]=(long long)(c[i].r+0.5);
	for(i=0;i<p-1;i++) ans+=mi[i]*(res[i]+res[i+p-1]);
	for(i=1;i<=x0;i++) ans-=d[i]*d[i]%p;
	cout<<ans/2;
	system("pause");
}


Measured memory_bytes: 39876
// If I can't Make It then I Should Try Harder
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
#define F first
#define S second
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9+7,INF=8e18;
const ll N = 1e5+5;
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll comb(ll x,ll y){
    if(x==y || y==0)    return 1;
    return ((comb(x-1,y-1))+(comb(x-1,y)))%mod;
}



ll a,b;

int main() {
    isc;
    cin >> a >> b;
    ll ans=0;
    ww(a>0){
        a/=b;
        ans++;
    }
    cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 1;
        if (n > 2)
        {
            int x = 0, y = 0, z = 0;
            for (int i = 0; i < n; i++)
            {
                if (z != a[i])
                {
                    x = y;
                    y = z;
                    z = a[i];
                    if (x > 0 && (x < y && y > z || x > y && y < z))
                    {
                        ans++;
                        x = y = 0;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 20448
N, K = map(int, input().split())
S = input()

block_count = 0
ans = 0
last = 0
for i in range(N):
	if S[i] != last:
		last = S[i]
		block_count += 1
	if S[i] == "L" and  i > 0 and S[i-1] == "L": ans += 1
	if S[i] == "R" and  i < N-1 and S[i+1] == "R": ans += 1

half = (block_count - 1)//2

if K > half:
	ans = N - 1
else:
	ans += 2*K

print(ans)

Measured memory_bytes: 40432