akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class MPCO2020A
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var N = RI();
            int result;
            if (N < 600)
            {
                result = 8;
            }
            else if (N < 800)
            {
                result = 7;
            }
            else if (N < 1000)
            {
                result = 6;
            }
            else if (N < 1200)
            {
                result = 5;
            }
            else if (N < 1400)
            {
                result = 4;
            }
            else if (N < 1600)
            {
                result = 3;
            }
            else if (N < 1800)
            {
                result = 2;
            }
            else
            {
                result = 1;
            }
            Console.WriteLine(result);


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 27428
#include<bits/stdc++.h>
using namespace std;
#define ll long long         
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    for (int i = 0; i < 3; ++i)
    {
    if(s[i]=='7'){
        cout<<"Yes";
        return 0;
        }
    }
    cout<<"No";
    return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

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

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int A, B;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> A >> B;
	cout << max(A - 2 * B, 0);
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
# coding: utf-8
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
A.sort()
L1, L2 = [0] * N, [0] * N
L1[0] = A[N//2]
L2[0] = A[N//2]
for i in range(1, N):
    if i % 2 == 0:
        L1[i] = A[i//2-1]
        L2[i] = A[-i//2]
    else:
        L1[i] = A[-i//2]
        L2[i] = A[i//2]
a1, a2 = 0, 0
for i in range(N-1):
    a1 += abs(L1[i] - L1[i+1])
    a2 += abs(L2[i] - L2[i+1])
print(max(a1, a2))

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

struct UnionFind{
  vector<int> d;
  UnionFind(int n=0): d(n,-1){};
  int find(int a){
    if(d[a]<0) return a;
    return d[a]=find(d[a]);
  }
  bool unite(int a,int b){
    a=find(a); b=find(b);
    if(a==b) return false;
    if(d[a]>d[b]) swap(a,b);
    d[a]+=d[b];
    d[b]=a;
    return true;
  }
  bool same(int a,int b){return find(a)==find(b);}
  int size(int a) {return -d[find(a)];}
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;a--;b--;
        uf.unite(a,b);
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(!uf.same(0,i)){
            ans++;
            uf.unite(0,i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,ma,mb;cin>>n>>ma>>mb;
    vl a(n),b(n),c(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];

    vvl dp(500,vl(500,INF));
    dp[0][0]=0;
    rep(i,n){
        rrep(j,500)rrep(k,500){
            if(j-a[i]<0||k-b[i]<0)continue;
            chmin(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
        }
    }
    ll ans=INF;
    rep(i,1,min(500/ma,500/mb)){
        chmin(ans,dp[i*ma][i*mb]);
    }
    cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	int y, m, d;
	int zzz;
	map<string, int> mapper;
	for (int count = 0; count < n; count++) {
		cin >> y >> m >> d;
		y--;
		m--;
		d;
		zzz = 0;
		zzz+= 195 * y + (y / 3) * 5;
		if ((y+1) % 3 == 0) {
			zzz += 20 * m;
		} else {
			zzz += 20 * m - (m / 2);
		}
		zzz += d;
		cout << 196471 - zzz << endl;
	}
}


Measured memory_bytes: 3024
#include<cstdio>

using namespace std;

int ball[10];

bool dfs(int i,int b,int c){
	if(i==10)return true;
	if(ball[i]>b && dfs(i+1,ball[i],c))return true;
	if(ball[i]>c && dfs(i+1,b,ball[i]))return true;
	return false;
}

int main(){
	int lines;
	scanf("%d",&lines);
	for(int i = 0;i<lines;i++){
		for(int j=0;j<10;j++)scanf("%d",&ball[j]);
		if(dfs(0,0,0)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	int d4 = 0, d2 = 0;
	for (int i = 0; i < n; ++i) {
		int a; scanf("%d", &a);
		if (a%4==0) ++d4;
		else if (a%2==0) ++d2;
	}
	n -= d4+d2;
	if ((d2 && d4 >= n) || (!d2 && d4 >= n-1)) puts("Yes");
	else puts("No");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    double a,b; cin >> a >> b;
    if(a>b) {
        cout << "GREATER" << endl;
    }else if(a<b) {
        cout << "LESS" << endl;
    }else if(a==b){
        cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>
#include<algorithm>

void insert(const std::string& str,std::set<std::string>& dctnry){
     dctnry.insert(str);
}

void find(const std::string& str,const std::set<std::string>& dctnry){
    std::cout<<(dctnry.find(str)!=dctnry.end()?"yes":"no")<<std::endl;
}

int main(void){
    int n;
    std::set<std::string> dctnry;
    std::string str,inst;
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>inst>>str;
        if(inst=="insert"){
                insert(str,dctnry);
        }else{
                find(str,dctnry);
        }
    }
}


Measured memory_bytes: 32536
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,k;cin>>n>>k;

  ll ans=k;
  for(int i=1;i<n;i++){
    ans*=(k-1);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    int n, k; cin >> n >> k;
    double ans = 0;
    repf(i,1,n+1) {
        double tmp = 1.0/n;
        int cost = i;
        while (cost < k) {
            cost *= 2;
            tmp /= 2.0;
        }
        ans += tmp;
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
As = list(map(int, input().split()))

As.sort()

ans = 0
for A in As:
    if x > A:
        x -= A
        ans += 1
    elif x == A:
        ans += 1
        break
    else:
        break
else:
    ans -= 1

print(ans)


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

string triangle(int x,int y,int z){ //直角三角形なら"YES"を出力する関数
  if(x*x==y*y+z*z) return "YES";
  else if(y*y==z*z+x*x) return "YES";
  else if(z*z==x*x+y*y) return "YES";
  else return "NO";
}

int main()
{
  int n,a,b,c;
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> a >> b >> c;
    string str=triangle(a,b,c); //strにstring triangle(int x,int y,int z)を代入
    cout << str << endl;
  }
  return 0;
}

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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 1.8e5);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}


Measured memory_bytes: 89368
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    i64 N;
    read(N);

    i64 ans = LINF;
    for (i64 i = 1; i*i <= N; ++i) {
        if (N % i == 0) {
            chmin(ans, (i - 1) + (N / i - 1));
        }
    }

    print(ans);

    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {

    int n; cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll ans = 1;

    int c[3] = {}; //使った帽子の個数を管理

    for (int i = 0; i < n; ++i) {
        ll cnt = 0; //使える帽子の個数（=パターン数）
        ll id = -1;

        if (a[i] == c[0]) { //使える帽子か確認
            ++cnt;
            id = 0;
        }

        if (a[i] == c[1]) { //使える帽子か確認
            ++cnt;
            id = 1;
        }

        if (a[i] == c[2]) { //使える帽子か確認
            ++cnt;
            id = 2;
        }

        if (id == -1) { //使える帽子がない場合
            cout << 0 << endl;
            return 0;
        }

        ans *= cnt;
        ans %= MOD;
        ++c[id];
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

template<class D>
vector<int> calcmins(vector<D> a,int L){
	int N = a.size();
	if(N==0) return {};

	vector<int> ret;
	deque<int> deq;
	auto rsucc = [&](int i){
		while(!deq.empty() && a[deq.back()]>a[i]) deq.pop_back();
		deq.push_back(i);
	};
	auto lsucc = [&](int i){
		if(!deq.empty() && deq.front()==i) deq.pop_front();
	};
	rep(i,N+L-1){
		if(i<N) rsucc(i);
		ret.pb(deq.front());
		if(i>=L-1) lsucc(i-L+1);
	}
	return ret;
}

using ll = long long;
struct Donut{
	int v;
	ll c;
	ll M;
	Donut(int v,ll c,ll M):v(v),c(c),M(M){};
};

int N;
ll X,D;
ll solve(vector<Donut> d){
	rep(i,N-1) rep(j,N-1) if(d[j].c*d[j+1].v > d[j+1].c*d[j].v) swap(d[j],d[j+1]);

	vector<ll> use(N);
	ll x = X;
	rep(i,N){
		ll n = min(d[i].M,x/d[i].c);
		use[i] = n;
		x -= n*d[i].c;
	}

	ll ans = 0;
	x = X;

	rep(i,N){
		use[i] = max<ll>(0,use[i]-N);
		ans += use[i]*d[i].v;
		x -= use[i]*d[i].c;
	}
	ll inf = 2e18;
	vector<ll> dp = {0};
	rep(i,N){
		int num = min<ll>(d[i].M-use[i],2*N);
		int v = d[i].v;
		ll c = d[i].c;
		int S = dp.size();
		int nS = S + v*num;
		vector<ll> ndp(nS,inf);
//		printf("------ i = %d ---------\n",i);
//		show(S);
//		show(v);
//		show(c);
//		show(nS);

		rep(r,v){
			vector<ll> dpr;
			for(int q=0,s=r;s<S;q++,s+=v){
				dpr.pb(dp[s]-q*c);
			}
			vector<int> ag = calcmins(dpr,num+1);
			rep(q,ag.size()){
				int s = q*v + r;
				ndp[s] = dpr[ag[q]] + q*c;
			}
		}
		dp = ndp;
	}
	ll ad = 0;
	rep(s,dp.size()){
		if(dp[s]<=x) ad = s;
	}
	return ans + ad;
}

int main(){
	cin>>N>>X>>D;
	vector<ll> m(N);
	vector<int> n(N);
	vector<int> p(N);
	rep(i,N){
		cin>>m[i];
		if(i!=0) cin>>p[i],p[i]--;
	}
	for(int v=N-1;v>=0;v--){
		n[v]++;
		if(v==0) break;
		n[p[v]] += n[v];
		m[p[v]] += m[v];
	}
	vector<Donut> d;
	rep(i,N){
		d.pb(Donut(n[i],m[i],(i==0?1e9:D)));
	}
	cout<<solve(d)<<endl;
}


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

int main(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double rad;
    long double ans;
    if(abs(h*30+0.5*m-m*6)>180)rad=(long double)((abs(abs(h*30.0+0.5*m-m*6.0)-360.0)))*(acos(-1)/180.0);
    else rad=(long double)(abs(h*30.0+0.5*m-m*6.0)*(acos(-1)/180.0));
    ans=(long double)(a*a+b*b)-(long double)(2.0*a*b)*cosl(rad);
    ans=sqrt(ans);
    printf("%.20Lf\n",ans);
    return 0;
}

Measured memory_bytes: 4132
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s;
    cin >> s;

    if (s.size() % 2 || s.size() == 0) {
        cout << "No" << endl;
        return 0;
    }

    bool can = true;
    bool flip = false;
    for (auto &&i : s) {
        if(!flip && i=='h'){
            flip = !flip;
        }
        else if(flip && i=='i'){
            flip = !flip;
        }
        else{
            can = false;
        }
    }

    cout << (can ? "Yes" : "No") << endl;

}


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

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
typedef struct Card {
    int n;
    char c;
} Card;

// retard desu LMAO
void merge(Card *first, Card *mid, Card *last) {
    const int N1 = (int)(mid - first);
    const int N2 = (int)(last - mid);
    Card left[N1 + 1];
    Card right[N2 + 1];
    memcpy(left, first, sizeof(Card) * (N1 + 1));
    memcpy(right, mid, sizeof(Card) * (N2 + 1));
    left[N1].n = right[N2].n = 1000000000;
    int i = 0, j = 0;
    for(Card *it = first; it != last; ++it) {
        *it = left[i].n <= right[j].n ? left[i++] : right[j++];
    }
}
void merge_sort(Card *first, Card *last) {
    const int N = (int)(last - first);
    if(N < 2) return;
    Card *mid = first + N / 2;
    merge_sort(first, mid);
    merge_sort(mid, last);
    merge(first, mid, last);
}
void *partition(Card *first, Card *last) {
    Card pivot = *(last - 1);
    Card *p = first - 1;
    for(Card *it = first; it != last - 1; ++it) {
        if(it->n <= pivot.n) {
            p++;
            Card tmp = *p;
            *p = *it;
            *it = tmp;
        }
    }
    Card tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
void quicksort(void *first, void *last, size_t N) {
    if(last - first <= N) return;
    void *mid = partition(first, last);
    quicksort(first, mid, N);
    quicksort(mid, last, N);
}

int main(int argc, char **argv) {
    int n = get_uint();
    Card a[n], b[n];
    for(int i = 0; i < n; ++i) {
        a[i].c = getchar_unlocked();
        getchar_unlocked();
        a[i].n = get_uint();
    }
    memcpy(b, a, n * sizeof(Card));
    quicksort(a, a + n, sizeof(Card));
    merge_sort(b, b + n);

    int flag = 0;
    for(int i = 0; i < n; ++i) {
        if(a[i].c != b[i].c) flag |= 1;
    }
    puts(flag ? "Not stable" : "Stable");
    for(int i = 0; i < n; ++i) {
        putchar_unlocked(a[i].c), putchar_unlocked(' ');
        put_uint(a[i].n), putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 4024
package main

import (
	"fmt"
)

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)
	ar := make([]int, n)
	for i := 1; i < n; i++ {
		ar[i] = ar[i-1]
		if s[i-1] == 'A' && s[i] == 'C' {
			ar[i]++
		}
	}
	for i := 0; i < q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(ar[r-1] - ar[l-1])
	}
}


Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m){
		if (n == 0 && m == 0)return 0;
		int q[100];
		int p[100] = { 0 };
		for (int i = 0; i < m; i++) {
			cin >> q[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int a; cin >> a;
				p[j] += a;
			}
		}
		bool b = true;
		for (int i = 0; i < m; i++) {
			if (q[i] < p[i]) {
				b = false;
			}
		}
		if (b)cout << "Yes";
		else cout << "No";
		cout << endl;
	}
}

Measured memory_bytes: 2992
#include <cstdlib>
#include <iostream>

using namespace std;
int main()
{
  int h1, m1, h2, m2, k;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int hd = h2 - h1;
  cout << hd * 60 + (m2 - m1) - k << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int next = 1;
		for(int i = 0; i < n; i++) {
			if(a[i] == next) {
				next++;
			}
			else {
				count++;
			}
			
		}
		if(count==a.length) {
			System.out.println(-1);
		}
		else {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 82336
// AOJ 0270: Modular Query
// 2017.8.24 bal4u@uu
// 2017.11.5 retry

#include <stdio.h>

char tbl[300005];

char buf[2100010], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

void pr(char *p, int n)
{
	char *q;
	static char tmp[13] = {0};
	q = tmp; while (n >= 10) {
		*++q = '0' + (n % 10);
		n /= 10;
	}
	*p++ = n + '0';
	while (*q) *p++ = *q--;
	*p = 0;
}

int main()
{
	int N, Q, i, k, q, max;
	char maxz[13], tmp[13];

	fgets(p=buf, 20, stdin), N = getint(), p++, Q = getint();
	tbl[0] = 1, max = 0;
	fgets(p=buf, sizeof(buf), stdin);
	while (N--) {
		tbl[k=getint()] = 1, p++;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	pr(maxz, max);
	while (Q--) {
		fgets(p=buf, 10, stdin), q = getint();
		if (q > max) puts(maxz);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { pr(tmp, k), puts(tmp); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        for (int i = N; i <= 999; i++)
        {
            if (i % 111 == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin >> N;
    char S;
    rep(i, N) {
        cin >> S;
        if (S == 'Y') {
            cout << "Four\n";
            return 0;
        }
    }
    cout << "Three\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k,i,m,s;
  
  scanf("%d %d",&n,&k);
  
  int a[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  for(i=0;i<n;i++){
    if(a[i]==1)
      m=i+1;
  }
    
    s=(m-1)/(k-1) + (n-m)/(k-1);
  
    if( (n-m)%(k-1)!=0 )
     
      s=s+1;
         
      
      if( (m-1)%(k-1)!=0 )
        
      s=s+1;
  if( (m-1)%(k-1)!=0 && (n-m)%(k-1)!=0)
  if( (m-1)%(k-1) + (n-m)%(k-1)!=0 && (m-1)%(k-1) + (n-m)%(k-1)<=k-1)
    s=s-1;
  
   
      

    printf("%d",s);
}
  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 3001;

int n, a[N];
vector <int> v[N];

int dfs(int node, int pnode){
    for(auto &i : v[node]){
        if(a[i] < a[node]){
            if(dfs(i, node) == 0){
                return 1;
            }
        }
    }
    return 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }
    for(int i = 0 ; i < n - 1 ; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i = 1 ; i <= n ; i++){
        if(dfs(i, 0)) cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
using namespace std;
 
int n, a, b, c;
int l[10];
 
int dfs(int k, int t[]) {
	if (k == n)
		if (t[0] > 0 && t[1] > 0 && t[2] > 0) {
			return(abs(a - t[0]) + abs(b - t[1]) + abs(c - t[2])) - 30;
		}
		else {
			return(100000000);
		}
	else {
		int add0, adda, addb, addc;
        int t0[3] = {t[0] + l[k], t[1], t[2]};
        int t1[3] = {t[0], t[1] + l[k], t[2]};
        int t2[3] = {t[0], t[1], t[2] + l[k]};
		add0 = dfs(k + 1, t);
		adda = dfs(k + 1, t0) + 10;
		addb = dfs(k + 1, t1) + 10;
		addc = dfs(k + 1, t2) + 10;
		return(min(min(add0, adda), min(addb, addc)));
	}
}
 
int main()
{
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
    int t[3] {0};
	cout << dfs(0, t) << endl;
}

Measured memory_bytes: 256
import numpy as np
N = input()
number_list = np.array(list(map(int,input().split())))
count = 0
flag = True
while flag:
    for number in number_list:
        if(number%2==1):
            flag = False
            break
        else:
            continue
    if flag:
        number_list = number_list / 2
        count += 1
print(count)


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

void solve(long long N, long long P){
	long long res = 1, pp = P;
	for (long long i = 2; i*i<=P; i++) {
		long long count = 0, ppp = pp;
		while (ppp%i == 0) {
			ppp /= i;
			count++;
		}
		for (long long j = 0; j<count-(count%N); j++) pp /= i;
		for (long long j = 0; j<(count-(count%N))/N; j++) res *= i;
	}
	if (N == 1) res = P;
	printf("%lld\n", res);
}

int main(){
	long long P;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&P);
	solve(N, P);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    int N;
    int[] P, Q;

    int cmp(int[] a, int[] b){
        for(int i=0; i<N; i++){
            if(a[i] < b[i]) return -1;
            else if(a[i] > b[i]) return 1;
        }
        return 0;
    }

    void next_permutation(int[] as){
        int i = N - 1;
        while(i-1>=0 && as[i-1] > as[i])i--;
        int j = i;
        Arrays.sort(as, i, N);
        while(j < N && as[j] < as[i-1])j++;
        int t = as[j]; as[j] = as[i-1]; as[i-1] = t;
        Arrays.sort(as, i, N);
    }

    int solve(){
        int f = cmp(P, Q);
        if(f == 0) return 0;
        if(f > 0){
            int[] t = P; P = Q; Q = t;
        }
        int a = 0;
        while(cmp(P, Q) < 0){
            next_permutation(P);
            a++;
        }

        return a;
    }

    public void _main() throws Exception {
        //System.setIn(new FileInputStream("/home/zxt/workspace/contest/inputs/c.in"));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        N = Integer.parseInt(in.readLine());
        P = new int[N]; Q = new int[N];
        String[] ss;
        ss = in.readLine().split(" ");
        for(int i=0; i<N; i++){
            P[i] = Integer.parseInt(ss[i]);
        }

        ss = in.readLine().split(" ");
        for(int i=0; i<N; i++){
            Q[i] = Integer.parseInt(ss[i]);
        }

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

    public static void main(String[] args) throws Exception {
        Main s = new Main();
        s._main();
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 10000 + 10;
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    ll n,x,t;
    cin>>n>>x>>t; 
    ll ans=ceil((ld)n/(ld)x);
    cout<<ans*t;
    //printclock;
    return 0;
}
    

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 10;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int h, w;
int graph[10][10];

void WarshallFloyd() {
    for( int k = 0; k < SIZE; ++k ) {
        for( int i = 0; i < SIZE; ++i ) {
            for( int j = 0; j < SIZE; ++j ) {
                if( graph[i][k] == INF || graph[k][j] == INF ) {
                    continue;

                }
                graph[i][j] = min( graph[i][j], 
                                    graph[i][k] + graph[k][j] );

            }
        }
    }
    return;

}

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

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

        }
    }

    WarshallFloyd();
    int res = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            int a;
            cin >> a;
            if(a != -1) res += graph[a][1];

        }
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
As = list(map(int, input().split()))
ks = []
for a in As:
    ks.append(len(bin(a))-2)
K=100
d = [0]*K
for k in ks:
    d[k] += 1
s = 0
ss = 0
ri = 0
for i in range(K):
    i = K-i-1
    s += d[i]
    ss += s
    if ss >= M:
        ri = i
        break
Bs = []
qs = 0
for a in As[::-1]:
    q=max(0, len(bin(a))-2-ri)
    qs += q
    Bs.append(a//(2**q))
Bs.sort()
r = 0
c = 0
for b in Bs[::-1]:
    if c < M-qs:
        b = b//2
    c += 1
    r += b
print(r)


Measured memory_bytes: 69732
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	
	int *ap, *ip;
	ap = (int *) calloc(n, sizeof(int));
	int i,sum,devide,y;
	sum = 0;
	y = 0;
	ip = ap;
	for(i=0;i<n;i++){
		scanf("%d",ip);
		sum += *ip;
		ip += sizeof(int);
	}
	devide = sum / (m*4);
	if(sum > devide * m * 4) devide++;
	ip = ap;
	
	for(i=0;i<n;i++){
		if(*ip >= devide) y++;
		ip += sizeof(int);
	}
	
	if(y >= m){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii;
// d = distance(lower_bound(all(x)), upper_bound(all(x)));
int INF = 1e9;
int M = 1e9+7;
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

#define N 30
#define K 3

int main(){
  string s, t; cin >> s >> t; int a=0;
  if (s[0] == t[0]) a++;
  if (s[1] == t[1]) a++;
  if (s[2] == t[2]) a++; cout << a << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long A = long.Parse(input[1]);
            long B = long.Parse(input[2]);

            Console.WriteLine(Math.Min(N * A, B).ToString());
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main()
{
    int a=0,c;
    cin>>c;
    int p[c];
    for (int i=0;i<c;i++) cin>>p[i];
    for (int i=0;i<c;i++)
        if (p[i]+1-1==i+1)
            a++;
    for (int b=0;b<c;b++)
    {
        if (p[b]+1-1==b+1 and p[b+1]+1-1==b+2) 
        {
            a=a-1;
            b=b+1;
        }
    }
    cout<<a<<endl;
    system ("pause");
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<4;++i)
	{
		if(s[i]=='+')a+=1;
		if(s[i]=='-')a-=1;
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) cin >> a[i];

  int l = 0, r = 0, sum = 0;
  ll ans = 0;
  while(r < n || l < n) {
    if((a[r] + sum) == (a[r] ^ sum) && r < n) {
      sum = sum ^ a[r];
      r++;
    } else {
      ans += r - l;
      sum = sum ^ a[l];
      l++;
    }
  }

  cout << ans << endl;
}


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

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

    string S;
    cin >> S;
    if (S == "Sunny")
        cout << "Cloudy\n";
    else if (S == "Cloudy")
        cout << "Rainy\n";
    else
        cout << "Sunny\n";

    return 0;
}

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

int n;
int M[101010][3]={};
ll dp[101010][3]={};
ll cnt=0;


int main(){
   cin>>n;
   rep(i,n){
      cin>>M[i][0]>>M[i][1]>>M[i][2];
   }
   // dp[0][0]=max(M[0][1],M[0][2]);
   // dp[0][1]=max(M[0][0],M[0][2]);
   // dp[0][2]=max(M[0][0],M[0][1]);
   dp[0][0]=M[0][0];
   dp[0][1]=M[0][1];
   dp[0][2]=M[0][2];
   rep(i,n-1){
      rep(j,3){
         rep(k,3){
            if(j!=k){
               switch(j){
               case 0:
                  dp[i+1][0]=max(dp[i+1][0],M[i+1][0]+max(dp[i][1],dp[i][2]));
                  break;
               case 1:
                  dp[i+1][1]=max(dp[i+1][1],M[i+1][1]+max(dp[i][0],dp[i][2]));
                  break;
               case 2:
                  dp[i+1][2]=max(dp[i+1][2],M[i+1][2]+max(dp[i][0],dp[i][1]));
                  break;
               }
            }
         }
      }
   }
   cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
   return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    string s; cin >> s;
    ll ans = 0;

    vint red,green,blue;

    rep(i,n){
        if(s[i] == 'R') red.pb(i);
        else if(s[i] == 'G') green.pb(i);
        else blue.pb(i);
    }
    ans = red.size() * blue.size() * green.size();

    for(int i = 0; i < n; ++i){
        for(int j = 1; i+j+j < n; ++j){
            if(s[i] != s[i+j] and s[i+j] != s[i+j+j] and s[i+j+j] != s[i]) --ans;
        }
    }


    cout << ans << endl;
    

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3656
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A = [-i for i in A]
A.sort()
import heapq
while M:
    a = -heapq.heappop(A)
    a = a//2
    M -= 1
    heapq.heappush(A, -a)
print(-sum(A))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans = 0;
	//float ans = 0;
	cin >> n;

	V a(n);
	V x(100005, 0);
	rep(i, n) {
		cin >> a[i];
		x[a[i]]++;
		x[a[i] + 1]++;
		x[a[i] + 2]++;
	}

	sort(ALL(x));
	ans = x[100004];

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_c();

	return 0;
}


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

int main(){
  int q,r,a;
  cin>>q;

  for(int i=0;i<q;i++){
    cin>>r;
    int j=10,count=1;
    a=r;

    while(1){
      a/=j;
      if(a==0)break;
      count++;
    }
    int count1=0;
    while(1){
      int max=0;
      j=10; 
      if(r/j==0)break;
      
      for(int k=1;k<count;k++){
	a=(r/j)*(r%j);
	if(max<a)max=a;
	j*=10;
      }

      r=max;
      count1++;
    }

    cout<<count1<<endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

int main()
{
	int n, a, b;
	std::cin >> n >> a >> b;
	std::string s;
	std::cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'a' && a+b > 0) {
			std::cout << "Yes" << std::endl;
			if (a > 0) { a--; }
			else { b--; }
		}
		else if (s.at(i) == 'b' && b > 0) {
			std::cout << "Yes" << std::endl;
			b--;
		}
		else {
			std::cout << "No" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAX(x,y) x=max(x,y)
using namespace std;
const int N=105;
int n,m,a[N][N],sx,sy,f[2][N][N][N];
char str[N];
int get(int x1,int x2,int y1,int y2)
{
    return a[x2][y2]-a[x2][y1-1]-a[x1-1][y2]+a[x1-1][y1-1];
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
    {
        scanf("%s",str+1);
        for (int j=1;j<=m;j++)
            if (str[j]=='E') sx=i,sy=j;
            else if (str[j]=='o') a[i][j]++;
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
    int ans=0,now=0;
    for (int i=0;i<sx;i++)
    {
        now^=1;
        for (int j=0;j<sy;j++)
            for (int k=0;k<n-sx+1;k++)
                for (int l=0;l<m-sy+1;l++)
                {
                    f[now][j][k][l]=0;
                    if (i&&sx-i>k) MAX(f[now][j][k][l],f[now^1][j][k][l]+get(sx-i,sx-i,max(sy-j,l+1),min(sy+l,m-j)));
                    if (j&&sy-j>l) MAX(f[now][j][k][l],f[now][j-1][k][l]+get(max(sx-i,k+1),min(sx+k,n-i),sy-j,sy-j));
                    if (k&&n-sx-k+1>i) MAX(f[now][j][k][l],f[now][j][k-1][l]+get(sx+k,sx+k,max(sy-j,l+1),min(sy+l,m-j)));
                    if (l&&m-sy-l+1>j) MAX(f[now][j][k][l],f[now][j][k][l-1]+get(max(sx-i,k+1),min(sx+k,n-i),sy+l,sy+l));
                    MAX(ans,f[now][j][k][l]);
                }
    }
    printf("%d",ans);
    return 0;
}

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

int main()
{
    long long n, m, i;
    cin >> n >> m;
    long long ans = 0;
    if (m > 2 * n)
    {
        ans += n;
        m -= 2 * n;
    }
    else
    {
        ans += m / 2;
        m = 0;
    }
    ans += m / 4;
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  double ans;
  vector<double> a;

  while ( scanf("%lf",&ans) != EOF){
    a.push_back( ans );
  }


  double c = a[0];
  double d = a[0];
  for(int i=0; i<a.size(); i++){
    c=max(c, a[i]);
    d=min(c, a[i]);
  }

  printf("%f\n",c-d);
}

Measured memory_bytes: 1244
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        char[] S = scanner.next().toCharArray();
        char[] T = scanner.next().toCharArray();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i<N; i++) {
            sb.append(S[i]).append(T[i]);
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int L = A + B;
	int R = C + D;

	if (L > R)
		cout << "Left" << endl;
	else if (L < R)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x,n,a[200001],res=0;
map <int,int> cnt;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=n;i>0;i--)
    {
        x=i-a[i];
        if (x>0) cnt[x]++;
    }

    for (int i=1;i<n;i++)
    {
        x=i-a[i];
        if (x>0)
        if (cnt[x]>0) cnt[x]--;
        res+=cnt[i+a[i]];
        
    }
    
    cout<<res;
    
}

Measured memory_bytes: 15412