akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;

int N, M, T[MAXN+5], A[MAXN+5], FAIL;
string S;
deque<int> ok, ans, D;

bool can(int x) { return S[x] == '0';}

int main () {
  cin >> N >> M >> S;
  FAIL = 2 * N;
  for (int i=0;i<=N;++i) T[i+1] = A[i] = FAIL;
  for (int i=N;i>=0;--i)
    if (can(i)) {
      if (i > 0) ok.push_front(i);
      if (i == N) A[i] = can(i) ? 0 : FAIL;
      else {
        while (!D.empty() && D.back() - i > M) D.pop_back();
        if (!D.empty()) A[i] = 1 + A[D.back()];
      }
      //printf("A[%d] = %d\n", i, A[i]);
      if (A[i] < FAIL) {
        while (!D.empty() && A[D.front()] >= A[i]) D.pop_front();
        D.push_front(i);
      }
    }
  if (A[0] == FAIL) {
    printf("-1\n");
    exit(0);
  }
  //for (int i=0;i<=N;++i) printf("%d ", A[i]); printf("\n");
  int K = A[0], cur = 0;
  for (auto p : ok) {
    if (A[p] == K-1) {
      ans.push_back(p - cur);
      K--;
      cur = p;
    }
  }
  for (auto v : ans) printf("%d ", v); printf("\n");
}


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

#define limit (int)(2e5 + 5)
// #define mod (int)(1e9 + 7)
#define pb push_back
#define fi first
#define se second

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int main() {

	char c;
	cin >> c;

	int t = c - 'a';

	if (t >= 0 && t <= 26)
	{
		cout << 'a';
	} else {
		cout << 'A';
	}
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long x = sc.nextLong();
        long[] a = new long[N];
        for(int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        long answer = 0;
        for(int i = 0; i < N; i++) {
            long surplus = a[i] - x;
            if (surplus > 0) {
                a[i] -= surplus;
                answer += surplus;
            }
            if (i > 0) {
                long pairSurplus = a[i] + a[i-1] - x;
                if (pairSurplus > 0) {
                    a[i] -= pairSurplus;
                    answer += pairSurplus;
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 61072
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	const int mod = 1e9 + 7;
	ll ans = 1;
	for(int i = 2; i <= n; i++){
		bool p = 1;
		for(int j = 2; j * j <= i; j++) if(i % j == 0){ p = 0; break; }
		if(!p) continue;
		int k = 1;
		for(int j = n; j; j /= i) k += j / i;
		ans = ans * k % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

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

class ARatedForMe {
public:
    void solve(std::istream& in, std::ostream& out) {
        int R;
        in >> R;

        string result;
        if (R < 1200) {
            result = "ABC";
        } else if (R < 2800) {
            result = "ARC";
        } else {
            result = "AGC";
        }

        out << result;
    }
};


int main() {
	ARatedForMe solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define int long long
using namespace std;

signed main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	vector<int> S(N+1,0);
	vector<int> Sp(N+1,0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];

		S[i + 1] = S[i] + a[i];
		if (a[i] > 0) {
			Sp[i + 1] = Sp[i] + a[i];
		}else{
			Sp[i + 1] = Sp[i];
		}
	}
	
	int res = -1;
	for (int i = 0; i < N - K+1; i++) {
		res = max(res, Sp[N] - (Sp[i + K] - Sp[i]) + max((int)0, (S[i + K] - S[i])));
	}
	cout << res << endl;

	return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 10450555;
const int M = 1155;

void solve() {
    int x,n;
    cin >> x >> n;

    set <int> s;
    for (int i = 1; i <= n; i++){
        int y;
        cin >> y;
        s.insert(y);
    }

    int ans = INF, id = 0;
    for (int i = 0; i <= 1000; i++){
        if (s.count(i)) continue;
        if (ans > abs(i-x)){
            ans = abs(i-x);
            id = i;
        }
    }

    cout << id;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
  int A, B;
  scanf("%d %d", &A, &B);
  int ans = max(A+B, max(2*A-1, 2*B-1));
  printf("%d\n", ans);

  return 0;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int ht[n];
    for(int i=0;i<n;i++)scanf("%d",&ht[i]);
    int dp[n];
    dp[0]=0;
    dp[1]=abs(ht[1]-ht[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-2]+abs(ht[i-2]-ht[i]), dp[i-1]+abs(ht[i-1]-ht[i]));
    }
    printf("%d",dp[n-1]);
    return 0;
}

Measured memory_bytes: 4496
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int A = 0;
    int B = 0;
    for(int i=0;i<N;i++){
        int max = 0;
        int num = 0;
        for(int j=0;j<N;j++){
            if(a[j] > max){
                max = a[j];
                num = j;
            }
        }
        a[num] = 0;
        if(i%2 == 0) A += max;
        else B += max;
    }
    cout << A-B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, x, y, z;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 998244353;
ld epi = 0.00000001;
ll cas=0;

void init(){}

void solve(){
    cin>>n;
    ll cn=0;
    ll flg=0;
    F(i,n){
        cin>>t1>>t2;
        if((t2-t1)==0)cn++;
        else cn=0;
        if(cn>=3)flg=1;
    }
    if(flg)prs("Yes");
    else prs("No");
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
    init();
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100001
int n;
int prime[MAX];
int cnt[MAX]={};
void eratos() {
	for (int i=0;i<MAX;i++) {
	//全部primeと設定する
	prime[i] = 1;
	}
	prime[0] = prime[1] = 0;

	for (int i=2;i<MAX;i++) {
	for (int j=i+i;j<MAX;j+=i) {
	if (prime[j]) prime[j] = 0;
	}
	}
}

void like() {
	for (int i=3;i<MAX;i+=2) 
	{	
	if (prime[i] && prime[(i+1)/2]) {
	++cnt[i];
	}
	}
	for (int i=4;i<MAX;i++) {
	cnt[i] += cnt[i-1];
	}
	
}



int main() {
	int q;
	int l,r;
	cin >> q;
	eratos();
	like();
	for (int i=0;i<q;i++) {
	scanf("%d %d", &l, &r);
	printf("%d\n", cnt[r]-cnt[l-1]);
	}

/*	for (int i=0;i<=11;i++) {
	cout << "p "<<prime[i] << endl;
	cout << "c "<<cnt[i] << endl;
	}
*/
	return 0;
}


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

int main()
{  
    int n,q;
    cin>>n>>q;
    vector<vector<int>>a(n);
    REP(i,q)
    {
        int x,y;
        cin>>x>>y;
        if(x==0)
        {
            int z;
            cin>>z;
            a.at(y).push_back(z);
        }else if(x==1)
        {
            if(a.at(y).empty()==0)cout<<a.at(y).back()<<endl;
        }else if(x==2)
        {
            if(a.at(y).empty()==0)a.at(y).pop_back();
        }
    }
}



Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const int MAX_N=100005;
int N;
vec G[MAX_N];
int dist[MAX_N];
int main()
{
	memset(dist,-1,sizeof(dist));
	cin>>N;
	rep(i,0,N-1)
	{
		int a,b;
		cin>>a>>b;
		G[a].pb(b);
		G[b].pb(a);
	}
	priority_queue <Pair,vector<Pair>,greater<Pair> > q;
	int K;
	cin>>K;
	rep(i,0,K)
	{
		int v,p;
		cin>>v>>p;
		dist[v]=p;
		q.push(mp(p,v));
	}
	while(!q.empty())
	{
		Pair t=q.top();
		q.pop();
		rep(i,0,G[t.se].size())
		{
			int to=G[t.se][i];
			if(dist[to]==-1)
			{
				dist[to]=dist[t.se]+1;
				q.push(mp(t.fi+1,to));
			}
		}
	}
	bool res=true;
	For(i,1,N)
	{
		rep(j,0,G[i].size())
		{
			if(abs(dist[i]-dist[G[i][j]])!=1)res=false;
		}
	}
	if(res)
	{
		puts("Yes");
		For(i,1,N)cout<<dist[i]<<endl;
	}
	else puts("No");
	return 0;
}


Measured memory_bytes: 8448
N,gate,start=list(map(int,input().split()))
W=list(map(int,input().split()))
le=0
ri=0
for i in range(start,N+1):
  if i in W:
    ri+=1
for k in range(start+1):
  if k in W:
    le+=1
print(min(ri,le))

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
 int main(){
  int N,M;
   cin >> N >> M; 
   int sum = 0;
   vector<int>vec(N,0);
   for (int i = 0;i < N;i++){
   cin >> vec.at(i); 
     sum += vec.at(i);
   }
   sort(vec.begin(),vec.end());
   if (vec.at(N-M)*4*M >= sum){
   cout << "Yes";
   }
   else{
   cout << "No";
   }
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) {
    cout << s << endl;
  }
  else {
    cout << s.substr(0,k);
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int A, B;
    string S;
    cin >> A >> B;

    cin >> S;
    bool isValid = true;
    repeat (i, A + B + 1) {
        if (i == A) {
            if ('-' != S[i]) {
                isValid = false;
                break;
            }
        } else {
            if (!('0' <= S[i] && S[i] <= '9')) {
                isValid = false;
                break;
            }
        }
    }
    if (isValid) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int h;
        cin >> h;
        if (h >= K)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> data(H + 2,vector<char>(W + 2,'.'));
    for(int i = 1;i < H + 1;i++){
        for(int j = 1;j < W + 1;j++){
            cin >> data[i][j];
        }
    }

    bool flag = true;

    for(int i = 1;i < H + 1;i++){
        for(int j = 1;j < W + 1;j++){
            if(data[i][j] == '#'
            && data[i - 1][j] == '.' 
            && data[i + 1][j] == '.'
            && data[i][j + 1] == '.'
            && data[i][j - 1] == '.'){
                flag = false;
                break;
            }
        }
    }

    if(flag == true)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys

S=input()
L=list('abcdefghijklmnopqrstuvwxyz')

for i in L:
    if S.count(i+i):
        n=S.index(i+i)
        print(n+1,n+2)
        sys.exit()

for i in L:
    for j in L:
        if S.count(i+j+i):
            n=S.index(i+j+i)
            print(n+1,n+3)
            sys.exit()

print(-1,-1)

Measured memory_bytes: 3188
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m = map(int,input().split())
ansset = set(range(1,m+1))

times = n
table = []
for _ in range(times):
    table.append(list(map(int,input().split()))) # 行列の場合

for lis in table:
    ansset = ansset & set(lis[1:])

print(len(ansset))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3060
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
//#pragma GCC optimize(3)
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define mod (int)(1e9+7)
#define inf (1<<30)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline void writeln(ll a){
    if(a==0){puts("0");return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    FORD(i,h,1)putchar(c1[i]);putchar('\n');
    return;
}
inline ll Max(ll a,ll b){return (a>b)?a:b;}
inline ll Min(ll a,ll b){return (a<b)?a:b;}
inline ll Abs(ll x){return (x<0)?-x:x;}
inline void Swap(ll &x,ll &y){ll t=x;x=y;y=t;}
char s[mn];
int n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int la=0;
	if(s[1]!='1'||s[n]!='0'){writeln(-1);return 0;}
	FOR(i,1,n-1)if(s[i]=='1'&&s[n-i]!='1'){writeln(-1);return 0;}
	la=1;
	FOR(i,2,n-1){
//		if(s[i]=='0')printf("%d %d\n",la,i),f[i]=la;else
//		printf("%d %d\n",f[la],i),f[i]=f[f[la]],la=f[i];
		printf("%d %d\n",la,i);
		if(s[i]=='1')la=i;
	}
	printf("%d %d\n",1,n);
	return 0;
}


Measured memory_bytes: 1536
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define endl '\n'
using ll = long long;
using namespace std;

const int maxn = 1e3 + 69;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
#ifdef BOI
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ll n, d; cin >> n >> d;
    int cnt = 0;
    for(ll i = 0, x, y; i < n; ++i) {
        cin >> x >> y;
        if(x * x + y * y <= d * d) ++cnt;
    }
    cout << cnt;
    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string S;
  cin >> S;
  vector<int> num(S.size());
  for(int i = 0; i < S.size(); i++){
    num[i] = S[i] - '0';
  }
  unsigned long long sum = 0;
  for(int i = 0; i < S.size(); i++){//num[i]
    int cnt = 0, size = pow(2, S.size() - 1);
    for(int j = pow(2, S.size() - 1); j > 0; j--){
      sum += num[i] * pow(10, cnt);
      if(j - 1 <= size / 2 && cnt + 1 < S.size() - i){
        size /= 2;
        cnt++;
      }
    }
  }
  cout << sum << endl;
}


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

int main(){
    
    long int a,b,x,k;
    
    std::cin >> a >> b;
    x = a - b;
    
    if(x % 2 == 1){std::cout << "IMPOSSIBLE"; return 0;}
    
    x /= 2;
    
    if(a > b){
        k = b + abs(x);
    }
    if(a < b){
        k = a + abs(x);
    }
    
    if( abs(a - k) == abs(b - k) ){
        std::cout << k << "\n";
    } else { std::cout << "IMPOSSIBLE" << "\n"; }
    
    return 0;
}

Measured memory_bytes: 256
using System;
namespace tst
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for(int i=0; i<n; i++)
            {
                A[i] = int.Parse(In[i]);
            }
            int index = 1;
            int cnt = 0;
            for(int i=0; i<n; i++)
            {
                if (A[i] == index)
                {//満足する数字
                    index++;
                }
                else
                {//砕く
                    cnt++;
                }
            }
            if (index == 1)
            {
                Console.WriteLine(-1);
            }else if (index > 1)
            {
                Console.WriteLine(cnt);
            }
        }

    }
}

Measured memory_bytes: 31452
using System;
using System.IO;

namespace AOJ.intro
{
    namespace AOJ_1_1_D
    {
        public static class Watch
        {
            public static void Main()
            {
                int time = int.Parse(Console.ReadLine());
                int hour = 0, minutes = 0, seconds = 0;
                convertSecondsToTime(time, hour, minutes, seconds);
            }
            public static void convertSecondsToTime(int time, int hour, int minutes, int seconds)
            {
                int remainder = time;

                if(time / 3600 >= 1){
                    hour = time / 3600;
                    remainder = time % 3600;
                }
                if(remainder / 60 >= 1){
                    minutes = remainder / 60;
                    remainder = remainder % 60;
                }
                if(remainder != 0){
                    seconds = remainder;
                }
                Console.WriteLine(hour + ":" + minutes + ":" + seconds);
            }
        }
    }
}


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if ((A + B) > (C + D)) {
        cout << "Left" << endl;
    } else if ((A + B) < (C + D)) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

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

using namespace std;

typedef long long LL;
typedef long double LD;



int main()
{
  LL N, K, Q;
  cin >> N >> K >> Q;
  vector<LL> A(Q+1);
  for (LL i = 1; i <= Q; i++) {
    cin >> A[i];
  }
  
  vector<LL> P(N + 1);
  for (LL i = 1; i <= Q; i++) {
    P[A[i]]++;
  }

  for (LL i = 1; i <= N; i++) {
   // cerr << i << " : " << (P[i]) << endl;;

  }

  for (LL i = 1; i <= N; i++) {
    //cerr << i << " : " << (K + P[i] - Q) << endl;;
  }

  for (LL i = 1; i <= N; i++) {
    LL v = (K + P[i] - Q);
    if (v > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }



  return 0;
}






Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;
const int INF = (1 << 29);

int deside(vector<int> &cost,int bit){
  int min_cost = cost[0];
  for(int i = 0;i < cost.size()-1;i++){
    if((bit & (1 << i)) != 0 ){
      min_cost = min(min_cost,cost[i+1]);      
    }
  }
  return min_cost;
}
int main(){
  int n;
  while(cin >> n,n){
    vector<int> dp(1<<(n),INF);
    dp[0] = 0;
    vector<vector<int> > cost(n,vector<int>(n+1,0));
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n+1;j++){
	cin >> cost[i][j];
      }
    }
    queue<int> que;
    que.push(0);
    while(!que.empty()){
      int current = que.front();que.pop();
      for(int i = 0;i < n;i++){
	if(dp[current] + deside(cost[i],current) < dp[current | (1 << i)]){
	  dp[current | (1 << i)] = dp[current] + deside(cost[i],current);
	  que.push(current | (1 << i));
	}	
      }
      //      cout << bitset<12>(current) <<"   ddd" <<dp[current] << endl;

    }
    cout << dp[(1<<n)-1] << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1596
#include <stdio.h>

int main(void) {
	int i;
	int data[5];
	int answer = 0;
	int asumikana = 0;
	for (i = 0; i < 5; i++) {
		if (scanf("%d", &data[i]) != 1) return 1;
	}
	for (i = 0; i < 5; i++) {
		answer += (data[i] + 10 - 1) / 10 * 10;
		if (data[i] % 10 != 0) {
			int horieyui = 10 - data[i] % 10;
			if (horieyui > asumikana) asumikana = horieyui;
		}
	}
	printf("%d\n", answer - asumikana);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int h,w,H,W,a,b,x;
	cin>>H>>W;
	cin>>h>>w;
	a=H-h;
	b=W-w;
	x=a*b;
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N, M, X;
  cin >> N >> M >> X;
  int left = 0;
  int right = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    if (A < X) left++;
    else right++;
  }
  cout << min(left, right) << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
  
int main(int argc, char *argv[])
{
  int n, i, j, k;
  int A[1000000];
  int count, m, G[12], v;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  
  count = 0;
  m = 1;
  G[0] = 1;
  while (3 * G[m-1] + 1 < n) {
    G[m] = 3 * G[m-1] + 1;
    m++;
  }
  
  for (i = 0; i < m / 2; i++) {
    v = G[i];
    G[i] = G[m-1-i];
    G[m-1-i] = v;
  }
  
  printf("%d\n", m);
  for (i = 0; i < m; i++) {
    if (i != m - 1) printf("%d ", G[i]);
    else printf("%d\n", G[i]);
  }
  
  for (i = 0; i < m; i++) {
    for (j = G[i]; j < n; j++) {
      v = A[j];
      k = j - G[i];
      while (k >= 0 && A[k] > v) {
    A[k+G[i]] = A[k];
    k -= G[i];
    count++;
      }
      A[k+G[i]] = v;
    }
  }
  
  printf("%d\n", count);
  for (i = 0; i < n; i++) printf("%d\n", A[i]);
  
  return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
map <char,int> mp;

string s;

bool XOR(int a,int b){
    return !a != !b;
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> s;
   
    for(int i=0;i<s.size();i++) mp[s[i]]++;
    
    if(XOR(mp['N'],mp['S']) || XOR(mp['W'],mp['E'])) cout << "No" <<"\n";
    else cout << "Yes" <<"\n";
    return 0;
}

Measured memory_bytes: 256
def find_gcd(x, y):
    while (y):
        x, y = y, x % y

    return x
s=int(input())
k=0
for i in range(1,s+1):
    for j in range(1, s + 1):
        for l in range(1, s + 1):
            k+=find_gcd(i,find_gcd(j,l))
print(k)


Measured memory_bytes: 73808
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse
#p a
ans = 0
top = 0
len = 1
k = 1
while k < n do
  for i in 0...len do
    ans += a[top + i / 2]
#    puts "top=#{top} len=#{len} ans=#{ans} k=#{k}"
    k += 1
    break if k >= n
  end
  top += (len + 1) / 2
  len *= 2
end
puts ans


Measured memory_bytes: 31008
S = input()
A = int(S[0]+S[1])
B = int(S[2]+S[3])
if (A > 0 and A < 13) and (B > 0 and B < 13):
    print('AMBIGUOUS ')
elif (A > 0 and A < 13) and (B > 12 or B == 0):
    print('MMYY')
elif (A > 12 or A == 0) and (B > 0 and B < 13):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    priority_queue<ll> pq;
    map<ll,vector<ll>> mp;
    ll ans = 0;
    rep(i,n) {
        ll a,b; cin>>a>>b;
        mp[a].push_back(b);
    }

    for (int i = m-1; i >= 0; --i) {
        int day = m-i;
        for (auto &&e: mp[day]) {
            pq.push(e);
        }
        if (pq.empty()) continue;
        ans += pq.top();
        pq.pop();
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int d;
  cin>>d;
  string ans="Christmas",eve=" Eve";
  rep(i,25-d) ans+=eve;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

char mas[20][20]={0};

char check(x,y){
  if(mas[y][x+3]=='1'){
    //printf("C\n");
    return 'C';
  }
  if(mas[y+2][x+1]=='1'){
    //printf("F\n");
    return 'F';
  }
  
  if(x>0){
    if(mas[y+2][x-1]=='1'){
      //printf("D\n");
      return 'D';
    }
  }
  

  if(mas[y+3][x]=='1'){
    //printf("B\n");
    return 'B';
  }

  if(mas[y][x+1]=='1'){
    if(mas[y+1][x+2]=='1'){
      //printf("E\n");
      return 'E';
    }
    if(x>0){
      if(mas[y+1][x-1]=='1'){
	//printf("G\n");
	return 'G';
      }
    }
    if(mas[y+1][x]=='1'){
      //printf("A\n");
      return 'A';
    }
  }
  // printf("NA");
}

main(){
  int i,j;
  int f,x,y;
  char ans;
  while(scanf("%s",mas[0])!=EOF){

    f=0;

    for(j=0;j<8;j++){
      if(mas[0][j]=='1' && f==0){
	x=j;
	y=0;
	f=1;
      }
    }

    for(i=1;i<8;i++){
      scanf("%s",mas[i]);
      for(j=0;j<8;j++){
	if(mas[i][j]=='1' && f==0){
	  x=j;
	  y=i;
	  f=1;
	}
      }
    }
    printf("%c\n",check(x,y));
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll ft(ll a, ll b) {
    return (a + ((a % b) ? (b - a % b) : 0)) / (b);
}

int main() {
    int K; cin >> K;
    ll A[K]; rep(i, K) cin >> A[i];
    ll L = 2, R = 3;
    bool ok = true;
    for(int i = K - 2; i >= 0; --i) {
        ll mult = ft(L, A[i]) * A[i];
        if(L <= mult && mult <= R) {
            L = mult;
            R = ll(R / A[i]) * A[i] + A[i] - 1;
        } else {
            ok = false;
            break;
        }
    }
    if(A[K - 1] != 2) ok = false;
    if(ok) cout << L << ' ' << R << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i] = (p[i]+1)/2
kset = 0
for j in range(k):
    kset += p[j]
max = -10000
if n != k:
    for l in range(n-k):
        if kset >= max:
            max = kset
        kset = kset - p[l] + p[l+k]
else:
    max = kset
    
if kset >= max:
    max = kset
print(max)


Measured memory_bytes: 24804
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a != c) puts("1");
    else puts("0");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
n,m = gets.split(' ').map(&:to_i)
cond = []
m.times {|i| cond << gets.split(' ').map(&:to_i)}
r1 = []
r2 = []
r3 = []
cond.each do |c|
  if c[0] == 1
    r1 << c[1].to_s
    r1 << "-1" if r1.uniq.size > 1
  elsif c[0] == 2
    r2 << c[1].to_s
    r2 << "-1" if r2.uniq.size > 1
  elsif c[0] == 3
    r3 << c[1].to_s
    r3 << "-1" if r3.uniq.size > 1
  end
end
if n == 1
  if r1.include?("-1")
    puts "-1"
  else
    r1 = ["0"] if r1.empty?
    puts r1[0]
  end
elsif n == 2
  if r1.include?("-1") || r2.include?("-1")
    puts "-1"
  elsif r1[0] == "0"
    puts "-1"
  else
    r1 = ["1"] if r1.empty?
    r2 = ["0"] if r2.empty?
    puts r1[0] + r2[0]
  end
elsif n == 3
  if r1.include?("-1") || r2.include?("-1") || r3.include?("-1")
    puts "-1"
  elsif r1[0] == "0"
    puts "-1"
  else
    r1 = ["1"] if r1.empty?
    r2 = ["0"] if r2.empty?
    r3 = ["0"] if r3.empty?
    puts r1[0] + r2[0] + r3[0]
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
const int N = 1e5 + 54;
int f[N], a[N], ans[N], tot[N], n, m, k, x, y;
inline int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
int main() {
	std::cin >> n >> m >> k;
	int i;
	for (i = 1; i <= n; ++i) f[i] = i;
	for (i = 1; i <= m; ++i) {
		std::cin >> x >> y;
		++a[x], ++a[y];
		x = find(x), y = find(y);
		if (x != y) f[x] = y;
		
	}
	for (i = 1; i <= n; ++i) f[i] = find(i), ++tot[f[i]];
	for (i = 1; i <= k; ++i) {
		std::cin >> x >> y;
		if (f[x] == f[y]) ++a[x], ++a[y];
	}
	for (i = 1; i <= n; ++i) std::cout << tot[f[i]] - 1 - a[i] << ' ';
	puts("");
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(18);
	string str[300];
	char ch;
	long long int n,c,x[200000],v[200000],left[200000]={},left2[200000]={},right[200000]={},right2[200000]={},res=0;
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
	}
	long long int now=v[1]-x[1];
	right[1]=max(0LL,now);
	for(int i=2;i<=n;i++)
	{
		now+=v[i]-x[i]+x[i-1];
		right[i]=max(right[i-1],now);
	}
	
	now=v[1]-2*x[1];
	right2[1]=max(0LL,now);
	for(int i=2;i<=n;i++)
	{
		now+=v[i]-2*(x[i]-x[i-1]);
		right2[i]=max(right2[i-1],now);
	}
	
	
	now=v[n]+x[n]-c;
	left[n]=max(0LL,now);
	for(int i=n-1;i>=1;i--)
	{
		now+=v[i]-(x[i+1]-x[i]);
		left[i]=max(left[i+1],now);
	}
	
	now=v[n]+2*(x[n]-c);
	left2[n]=max(0LL,now);
	for(int i=n-1;i>=1;i--)
	{
		now+=v[i]-2*(x[i+1]-x[i]);
		left2[i]=max(left2[i+1],now);
	}
	
	
	for(int i=0;i<=n;i++)
	{
		res=max(res,right[i]+left2[i+1]);
		res=max(res,right2[i]+left[i+1]);
		
	}
	cout<<res<<endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)

using ll = long long;
using ull = unsigned long long;
constexpr ll mod = 1e9 + 7;
using namespace std;

int main() {

	bool isgood = true;
	string S; cin >> S;

	rep(i, S.size()) {
		if (i % 2 == 0) {//奇数
			if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')isgood = false;
		}
		else {
			if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')isgood = false;
		}
	}

	if (isgood)cout << "Yes";
	else cout << "No";

	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        
        int min = Math.min(P+Q, Math.min(Q+R, R+P));
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, N;
  cin >> N >> A;
  if(A > N){cout << "Yes" << endl;}
  else if(N%500 <= A){cout << "Yes" << endl;}
  else if(N%500 == 0){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}


Measured memory_bytes: 3612
a,b,c,d=map(int,input().split())
if a<=c<=b:
  if b<d:
    print(b-c)
  else:
    print(d-c)
elif c<=a<=d:
  if b<d:
    print(b-a)
  else:
    print(d-a)
else:
  print(0)

Measured memory_bytes: 3188
unittest
{
	assert( [ "6" ].parse.expand.solve == 2 );
	assert( [ "27" ].parse.expand.solve == 5 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	return tuple( k );
}

auto solve( long k )
{
	const AS = [ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 ];
	return AS[ k - 1 ];
}


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

int main(void)
{
	char ara[1000];
	int num[100], sum, max;
	int i, j, len;
	
	while (scanf("%s", ara) != EOF){
		len = strlen(ara);
		sum = 0;
		max = 0;
		for (i = 0; i < len; i++){
			if (ara[i] == 'I')num[i] = 1;
			else if (ara[i] == 'V') num[i] = 5;
			else if (ara[i] == 'X') num[i] = 10;
			else if (ara[i] == 'L') num[i] = 50;
			else if (ara[i] == 'C') num[i] = 100;
			else if (ara[i] == 'D') num[i] = 500;
			else if (ara[i] == 'M') num[i] = 1000;
		}
		for (i = len - 1; i >= 0; i--){
			if (max > num[i])sum -= num[i];
			if (max < num[i])max = num[i];
			if (max <= num[i])sum += num[i];
		}
		
		printf("%d\n", sum);
		
	}
	
	return (0);
}

Measured memory_bytes: 540
#include <cstdio>
#include <cstdlib>
int n, MIN=9999999;

int solve(int x)
{
	int ans = 0;
	while (x >= 10)
	{
		ans += (x - x / 10 * 10);
		x /= 10;
	}
	return ans + x;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n / 2; i++)
	{
		int j = n - i, t = solve(i) + solve(j);
		if (t < MIN) MIN = t;
	}
	printf("%d", MIN);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int tmp;
  vector<int> left;
  vector<int> right;
  for (int i = 0; i < m; ++i) {
    cin >> tmp;
    if (tmp < x) left.push_back(tmp);
    else right.push_back(tmp);
  }
  cout << min(left.size(), right.size()) << endl;
  return 0;
}


Measured memory_bytes: 256
def lscan; gets.split.map(&:to_i); end

x,y = lscan

g = 0
g += [0, 30, 20, 10][x] || 0
g += [0, 30, 20, 10][y] || 0
g += 40 if x == 1 && y == 1
g *= 10000
p g

Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	long long x;
	cin >> x;
	long long y = 100;

	int i = 0;

	while (y<x) {
		y = y * 1.01;
		i++;
	}
	cout << i << endl;
	
	
}

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

#define MAX 10000
using namespace std;
#define inf    0x3f3f3f3f
#define ll long long
#define all(a) (a).begin(),(a).end()
#define INF (int)1e15
#define MOD 1000000007
#define access(i) a[i/3][i%3]

using namespace std;

const int maxi = 1e5+7;

vector< vector<int> >adj(maxi);

 int cnt=0;
 int ani[maxi] ;

 void dfs(int node){

  ani[node] = 1;

   for(int j=0;j<adj[node].size();j++)
    {
     if(! ani[adj[node][j]]){
        dfs(adj[node][j]);
     }
   }

 }

int main()
{
    int n,m; cin>>n>>m;

    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for(int i=1;i<=n;i++)
    {
       if(!ani[i]){
            dfs(i);
            cnt++;
        }
    }

  cout<<cnt-1<<endl;

 return 0;
}

Measured memory_bytes: 9940
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define dec DEC

const int N=1e5+5;
bool f[N][3][3][3];
int inc[N][3][3][3],dec[N][3][3][3],ans[N],n,val[3];

void print(int n,int x,int y,int z){
	if(!n) return ;
	int i=x,j=y,k=z;
	if(inc[n][i][j][k]==0) x--;
	if(inc[n][i][j][k]==1) y--;
	if(inc[n][i][j][k]==2) z--;	
	if(dec[n][i][j][k]==0) x++;
	if(dec[n][i][j][k]==1) y++;
	if(dec[n][i][j][k]==2) z++;
	print(n-1,x,y,z);
	printf("%c\n",'A'+inc[n][i][j][k]);
}

int getop(){
	char c=getchar();
	while(c<'A'||c>'C') c=getchar();
	return c-'A';
}

void dp(){
	f[0][val[0]][val[1]][val[2]]=1;
	for(int ni=1;ni<=n;ni++){
		int x=getop(),y=getop();
		if(x==0&&y==1){
			for(int i=1;i<=2;i++)
				for(int j=0;j<2;j++)
					for(int k=0;k<=2;k++) if(f[ni-1][i-1][j+1][k]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=0;
						dec[ni][i][j][k]=1;
					}
			for(int i=0;i<2;i++)
				for(int j=1;j<=2;j++)
					for(int k=0;k<=2;k++) if(f[ni-1][i+1][j-1][k]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=1;
						dec[ni][i][j][k]=0;
					}
		}
		if(x==0&&y==2){
			for(int i=1;i<=2;i++)
				for(int j=0;j<=2;j++)
					for(int k=0;k<2;k++) if(f[ni-1][i-1][j][k+1]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=0;
						dec[ni][i][j][k]=2;
					}
			for(int i=0;i<2;i++)
				for(int j=0;j<=2;j++)
					for(int k=1;k<=2;k++) if(f[ni-1][i+1][j][k-1]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=2;
						dec[ni][i][j][k]=0;
					}
		}
		if(x==1&&y==2){
			for(int i=0;i<=2;i++)
				for(int j=1;j<=2;j++)
					for(int k=0;k<2;k++) if(f[ni-1][i][j-1][k+1]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=1;
						dec[ni][i][j][k]=2;
					}
			for(int i=0;i<=2;i++)
				for(int j=0;j<2;j++)
					for(int k=1;k<=2;k++) if(f[ni-1][i][j+1][k-1]){
						f[ni][i][j][k]=1;
						inc[ni][i][j][k]=2;
						dec[ni][i][j][k]=1;
					}
		}	
	}
	for(int i=0;i<=2;i++)
		for(int j=0;j<=2;j++)
			for(int k=0;k<=2;k++) if(f[n][i][j][k]){
				puts("Yes");
				print(n,i,j,k);
				return ;
			}
	puts("No");
}

signed main(){
	read(n);read(val[0]);read(val[1]);read(val[2]);
	if(val[0]+val[1]+val[2]==2){
		dp();
		return 0;
	}
	for(int i=1;i<=n;i++){
		int x=getop(),y=getop();
		if(val[x]+val[y]==0){
			puts("No");
			return 0;
		}
		if(val[x]>=val[y]) swap(x,y);
		val[x]++;val[y]--;
		ans[i]=x;
	}
	puts("Yes");
	for(int i=1;i<=n;i++) printf("%c\n",'A'+ans[i]);
}

Measured memory_bytes: 32160