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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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

int A, B, C;

void solve()
{
    cin >> A >> B >> C;
    if(A == B) cout << C << endl;
    else if(A == C) cout << B << endl;
    else cout << A << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();

    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
static const int MAX_N = 1000000;
bool isPrime[MAX_N];
 
int main(){
    int n;
 
    while(~scanf("%d",&n)){
        if(n==0) break;
        vector<int> nums;
        for(int i=0;i<n;i++){
            int sum=0;
            for(int j=0;j<5;j++){
                int p;
                scanf("%d",&p);
                sum += p;
            }
            nums.push_back(sum);        
        }
        sort(nums.begin(),nums.end());
        printf("%d %d\n",*(nums.end()-1),*nums.begin());
    }
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int k;
int a[100000];

int main() {
    cin >> k;
    rep(i,k) cin >> a[i];
    ll m = 2, M = 3;
    if (a[k-1] != 2) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = k-2; i >= 0; i--) {
        ll nm = m + (m%a[i]?(a[i]-m%a[i]):0);
        ll nM = M - M%a[i];
        if (nm > nM) {
            cout << -1 << endl;
            return 0;
        }
        m = nm;
        M = nM + a[i]-1;
    }
    cout << m << " " <<  M << endl;
}
































Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X);
  vector<long long> B(Y);
  vector<long long> C(Z);
  for (int i = 0; i < X; ++i) cin >> A[i];
  for (int i = 0; i < Y; ++i) cin >> B[i];
  for (int i = 0; i < Z; ++i) cin >> C[i];
  sort(A.begin(), A.end(), greater<long long>());
  sort(B.begin(), B.end(), greater<long long>());
  sort(C.begin(), C.end(), greater<long long>());
  priority_queue<vector<long long> > pq;
  set<long long> visited;
  pq.push({A[0] + B[0] + C[0], 0, 0, 0});
  while (K > 0) {
    vector<long long> v;
    v = pq.top();
    pq.pop();
    long long code = v[1] * 1000000 + v[2] * 1000 + v[3];
    if (visited.count(code) > 0) continue;
    visited.insert(code);
    cout << v[0] << endl;
    if (v[1] + 1 < X)
      pq.push({A[v[1] + 1] + B[v[2]] + C[v[3]], v[1] + 1, v[2], v[3]});
    if (v[2] + 1 < Y)
      pq.push({A[v[1]] + B[v[2] + 1] + C[v[3]], v[1], v[2] + 1, v[3]});
    if (v[3] + 1 < Z)
      pq.push({A[v[1]] + B[v[2]] + C[v[3] + 1], v[1], v[2], v[3] + 1});
    --K;
  }
  return 0;
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000;

	return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define pb push_back
#define eb emplace_back
const  int MAX=1000000;
int main()
{
    ll a,b;

    cin>>a>>b;


    if( (a==1 || a==13 )&& (b==1 || b==13))
    {
             if(a>b)cout<<"Bob"<<endl;
     else if(a<b)cout<<"Alice"<<endl;
 else cout<<"Draw"<<endl;
    }else{
     if(a>b)cout<<"Alice"<<endl;
     else if(a<b)cout<<"Bob"<<endl;
     else cout<<"Draw"<<endl;

    }

}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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

	if (abs(c - a) <= d || abs(c - b) <= d && abs(b - a) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string o,e;cin>>o>>e;
  for(int i = 0; o.size() > i; i++){
    cout << o[i];
    if(!(o.size()!=e.size() && i+1==o.size()))cout << e[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int l,a,b,c,d,e,f,g,h,k,z;
	
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	
	e=a/c;
	if(a%c==0){g=e;}
	if(a%c!=0){g=e+1;}
	
	h=b/d;
	if(b%d==0){k=h;}
	if(b%d!=0){k=h+1;}
	if(g<k){z=l-k;}
	if(g>k){z=l-g;}
	if(g==k){z=l-g;}

	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define per(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll h,m;
    cin>>h>>m;
    if(h==1||m==1){cout<<1;return 0;}
    ll ans=h*m;
    if(h*m%2==0)ans/=2;
    else ans=ans/2+1;
    cout<<ans;
    return 0;
}


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

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

void solve()
{
    lli n; cin>>n;
    lli a[n], b[n], c[n];

    forz(i,n) cin>>a[i]>>b[i]>>c[i];

    lli dp[n+1][3];

    forz(i,n+1)
    {
        forz(j,3)
        {
            dp[i][j]=0;
        }
    }

    dp[1][0] = a[0];
    dp[1][1] = b[0];
    dp[1][2] = c[0];

    for(lli i=2; i<=n; i++)
    {
        dp[i][0] = fmax( dp[i-1][1]+a[i-1], dp[i-1][2]+a[i-1]);

        dp[i][1] = fmax( dp[i-1][0]+b[i-1], dp[i-1][2]+b[i-1]);

        dp[i][2] = fmax( dp[i-1][1]+c[i-1], dp[i-1][0]+c[i-1]);
    }

    // cout<<"### : ";
    // for(lli i=1; i<=n; i++)
    // {
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    // }

    lli key = fmax( fmax(dp[n][0], dp[n][1]), dp[n][2]);

    cout<<key<<endl;
}

int main()
{
    kira; 

    lli t=1; //cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}




















Measured memory_bytes: 4992
#include<stdio.h>

int isprime(x){
	if(x == 2){
	    return 1;
	}
else if(x < 2||x%2==0){
    return 0;
	}
  int i = 3;
while (i*i <= x){
	if (x %i==0){ 
	      return 0;
	}
    i = i + 2;
}
 return 1;
} 
int main(void){
	int n;
    scanf("%d",&n);
	int ans=0;
	int i,x,answer;
	for (i = 0; i < n; i++) {
    scanf("%d", &x);
    answer = answer + isprime(x);
  }
  printf("%d\n", answer);
  return 0;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  int a, b; 
  cin >> a >> b;
  cout << a + b / 2 << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char A[110000];
char B[110000];
char C[110000];
char ret[110000];
int main(){
	while(1){
		scanf("%s",A);
		if(A[0]=='-')break;
		scanf("%s%s",B,C);
		int l=0;
		int r=1;
		int at=0;
		int n=strlen(A)+strlen(B);
		for(int i=0;i<100;i++)ret[i]=0;
		char now=B[0];
		int sz=0;
		for(int i=0;i<n;i++){
			if(C[at]==now){
				now=A[l++];
				at++;
			}else{
				ret[sz++]=now;
				now=B[r++];
			}
		}
		printf("%s\n",ret);
	}
}

Measured memory_bytes: 960
n = int(input())
R = list()

for _ in range(n):
    R.append(int(input()))

ans = R[1] - R[0]
min_R = R[0]

for i in range(1, n):
    ans   = max(ans, R[i] - min_R)
    min_R = min(min_R, R[i])
print(ans)

Measured memory_bytes: 15512
// CPP program to find number of ways
// in which number expressed as
// product of two different factors
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main()
{


    int mx=1000000;

      for(int i=1;i<=mx;i++)
    {
        for(int j=i;j<=mx;j+=i)
        {
            a[j]++;
        }
    }


    int n;

   cin>>n;


   int sum=0;

    for(int i=1;i<n;i++)
    {
        sum+=a[i];
    }


    cout<<sum<<endl;




}


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

int n, x, y;
int pt[4][2];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    cin >> x >> y;
    for (int i = 0; i < 4; i++) {
        pt[i][0] = x;
        pt[i][1] = y;
    }
    while (n---1) {
        cin >> x >> y;
        if (x + y > pt[0][0] + pt[0][1]) {
            pt[0][0] = x;
            pt[0][1] = y;
        }
        if (x - y > pt[1][0] - pt[1][1]) {
            pt[1][0] = x;
            pt[1][1] = y;
        }
        if (-x + y > -pt[2][0] + pt[2][1]) {
            pt[2][0] = x;
            pt[2][1] = y;
        }
        if (-x - y > -pt[3][0] - pt[3][1]) {
            pt[3][0] = x;
            pt[3][1] = y;
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = i+1; j < 4; j++) {
            int dx = abs(pt[i][0] - pt[j][0]);
            int dy = abs(pt[i][1] - pt[j][1]);
            ans = max(ans, dx + dy);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
function Main(input){
    input = input.split(" ");
    //console.log(input[0]);
    tmp = parseInt(input[0])*parseInt(input[1]);

    if(tmp%2 == 0){
        console.log('Even');
    }else{
        console.log('Odd');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000];
int main()
{	int n,now=1,ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]);
	for(rint i=1;i<=n;i++)
	if(a[i]!=a[i+1]) ans+=now/2,now=1;
	else now++;
	cout<<ans;
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  const int inf = (int) 1e9 + 7;
  vector<int> dp(n, inf);
  dp[0] = 0;
  for (int i = 0; i < n; i++) { 
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        int cost = abs(h[i] - h[i - j]);
        dp[i] = min(dp[i], dp[i - j] + cost);
      }
    }
  }
  cout << dp[n - 1] << '\n';
	return 0;
}



Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)1e9;

#define maxn 100010
#define mod (ll) (1e9 + 9)

ll inv(ll a, ll b){
    return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

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

    vi a (n);

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

    vi dp (n, INF);

    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j >= n) continue;
            dp[i + j] = min (dp[i + j], dp[i] + abs (a[i + j] - a[i]));
        }
    }

    cout << dp[n - 1] << "\n";


}

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

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

  if (A < B){
    cout << "<" << endl;
  }
  else if (A > B)
  {
    cout << ">" << endl;
  }
  else
  {
    cout << "=" << endl;
  }
  
  
}

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

int fld[101][101][101];
int N,K;

void unq(vector<int> &px,int vx[]){
    for(int i=0;i<px.size();){
        if(i+1<px.size() && px[i]==px[i+1]){
            px.erase(px.begin()+i);
        }
        else{
            vx[i]=px[i+1]-px[i];
            i++;
        }
    }
    return;
}

int compress(int x[][2],int vx[]){
    vector<int> px;
    for(int i=0;i<N;i++)for(int j=0;j<2;j++) px.push_back(x[i][j]);
    sort(px.begin(),px.end());
    unq(px,vx);
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            x[i][j] = find(px.begin(),px.end(),x[i][j])-px.begin();
        }
    }
    //for(int i=0;i<px.size()-1;i++) printf("%d ",vx[i]); puts("");
    return px.size()-1;
}

int main(){
    int X[50][2],Y[50][2],Z[50][2],vX[101]={},vY[101]={},vZ[101]={};
    cin>>N>>K;
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            cin>>X[i][j]>>Y[i][j]>>Z[i][j];
        }
        //X[i][1]--; Y[i][1]--; Z[i][1]--;
    }

    int maxX=0,maxY=0,maxZ=0;
    maxX=compress(X,vX); maxY=compress(Y,vY); maxZ=compress(Z,vZ);
    //printf("%d,%d,%d\n",maxX,maxY,maxZ);
    for(int i=0;i<N;i++){
        for(int j=X[i][0];j<X[i][1];j++){
            for(int k=Y[i][0];k<Y[i][1];k++){
                for(int l=Z[i][0];l<Z[i][1];l++){
                    fld[j][k][l]++;
                }
            }
        }
    }

    long long ans=0;
    for(int i=0;i<maxX;i++){
        for(int j=0;j<maxY;j++){
            for(int k=0;k<maxZ;k++){
                if(fld[i][j][k]>=K){
                    //printf("%d\n",ans);
                    //printf("%d: %d,%d,%d\n",fld[i][j][k],vX[i],vY[j],vZ[k]);
                    ans += ((long long)vX[i]*(long long)vY[j]*(long long)vZ[k]);
                }
            }
        }
    }
    printf("%lld\n",ans);

    /*int vx[10]={},in;
    vector<int> px;
    for(int i=0;i<10;i++) cin>>in,px.push_back(in);
    unq(px,vx);
    for(int i=0;i<px.size();i++) printf("%d ",px[i]); puts("");
    for(int i=0;i<10;i++) printf("%d ",vx[i]); puts("");*/
    return 0;
}

Measured memory_bytes: 4924
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,e;
    cin>>n;
    vector<ll> v(n,0);
    rep(i,n-1){
        cin>>e;
        v[e-1]++;
    }
    rep(i,n) cout<<v[i]<<endl;
    return 0;
}

Measured memory_bytes: 4840
s = input()
s1 = s[0:2]
s2 = s[2:4]

i1 = int(s1)
i2 = int(s2)
 
if 1 <= i1 <=12 and 1 <= i2 <= 12:
    res = "AMBIGUOUS"
elif 1 <= i1 <= 12:
    res = "MMYY"
elif 1 <= i2 <= 12:
    res = "YYMM"
else:
    res = "NA"

print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin>>n>>m;
	int l=0,r=n+1;
	REP(i,m){
		int a,b;
		cin>>a>>b;
		l=max(l,a);
		r=min(r,b);
	}
	cout<<max(0,r-l+1)<<'\n';
}



Measured memory_bytes: 3616
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<vector<P>>an(n);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a--){
            int x,y;cin>>x>>y;
            an[i].pb(mp(x,y));
        }
    }
    int maxm=-1;
    for(int bit=0;bit<(1<<n);bit++){
        bool abc=true;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                for(int j=0;j<siz(an[i]);j++)
                    if(((bit>>(an[i][j].fi-1))&1)!=an[i][j].se)/*==
                                                                if((bit&(1<<an[i][j].fi))&&an[i][j].se==0)*/
                            abc=false;                          /*       abc=false;
                                                                else if(!(bit&(1<<an[i][j].fi))&&an[i][j].se==1)
                                                                    abc=false;*/
                        
            }
        }
        if(abc==true)
            chmax(maxm,counter(bit));
    }
    cout<<maxm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <iterator>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <functional>

void pushset( std::map< std::string, std::vector< std::string > > *mp, std::set< std::string > *ans, std::string name, std::set< std::string > *group, std::map< std::string, int> *f ) {
	using namespace std;
	
	if( group->find(name) != group->end() ) {
		if( f->at(name) ) return;
		f->at(name) = 1;
		for( int i = 0; i < mp->at(name).size(); i++ ) {
			pushset( mp, ans, mp->at(name)[i], group, f );
		}
	} else {
		ans->insert( name );
	}
	
}

int solve( ) {
	using namespace std;

	int n;
	cin >> n;
	if( n == 0 ) return 1;

	vector< string > ss(n);
	map< string, vector< string > > mp;
	set<string> group;
	map< string, int > flg;
	string top;

	for( int i = 0; i < n; i++ ) {

		char tstr[1000];
		char *tok;
		cin >> ss[i];
	
		for( int j = 0; j < ss[i].length(); j++ )
			tstr[j] = ss[i][j];

		tstr[ss[i].length()] = '\0';
		tok = strtok( tstr, ":,.");

		string s;
		vector< string > st;
		for( int j = 0;;j++ ) {
			if( tok == NULL ) break;
			string str = string( tok );			
			if( j == 0 ) {
				s = str;
				if( i == 0 ) top = str;
				group.insert( str );
				flg[ str ] = 0;
			} else {
				st.push_back( str );
			}
			tok = strtok( NULL, ";,.");
		}

		mp[s] = st;

 	}
	set<string> ans;
	for( int i = 0; i < mp[top].size(); i++ ) {
		pushset( &mp, &ans, mp[top][i], &group,&flg );
	}
	cout << ans.size() << endl;
	return 0;
}

int main(void){

	while( true ) {
		if( solve() ) break;
	}
	return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int a,b,sum=0,ma=0;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		ma=max(ma,n-a);
		sum+=max(0,n-a);
	}

	cout<<sum-ma<<endl;
	return 0;
}

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


int main(void){
    string str;
    long long int t=0;
    long long int l;
    cin >> str;
    l=str.length();
    long long int ba=0;
    for(int i=0;i<l;i++){
        if(str[i]=='B'){
            ba++;
        }else if(str[i]=='W'){
                t+=ba;
        }
    }
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() 
{		
	int c=0;
	int n; cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x; cin>>x;
		if(x&1 )
		{
			if(i&1)c++;
		}
	}
	cout<<c;


}

Measured memory_bytes: 3636
import copy
N, M = map(int, input().split())
A = sorted(map(int, input().split()))

digit2match_num = {i:j for i, j in zip(range(1, 10), [2,5,5,4,5,6,3,7,6])}

match_nums = sorted({digit2match_num[d]: d for d in A}.items())

rest = N


pattern_num = len(match_nums)
i = 0

ans = []

match_num, digit = match_nums[i]
n, rest = divmod(rest, match_num)
ans += [digit] * n

def make_tail(rest_match_num, ans):
  queue = [
    [[], rest_match_num]
  ]
  _ans = copy.copy(ans)
  flag = False
  tail = []
  for i in range(min(len(ans), 5)):
    new_queue = list()
    last_digit = ans.pop()
    last_match_num = digit2match_num[last_digit]
    for nums, rest_match_num in queue:
      rest_match_num += last_match_num
      new_queue.append([nums, rest_match_num])
      for match_num, digit in match_nums:
        if match_num <= rest_match_num:
          if rest_match_num == match_num:
            tail.append(
              sorted((ans + nums + [digit]), reverse=True)
            )
          elif match_num != last_match_num:
            new_queue.append([nums + [digit], rest_match_num - match_num])
        else:
          break
    queue = new_queue
  best = sorted(tail, key=lambda x: (len(x), x), reverse=True)[0]

  return best

# print(ans, rest)
if rest != 0:
  ans = make_tail(rest, ans)
print("".join(map(str, sorted(ans, reverse=True))))


Measured memory_bytes: 4212
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using Q = priority_queue<long long>; //erase  (でキーごと削除)
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define inf 1000000000000000000+10

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}


//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君

vector<long long> divisor_enumetarion(long long n){
    vector<long long> divisors;
    for(long long i=1 ; i*i<=n ; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i != n/i){
                divisors.push_back(n/i);
            }
        }
    }
    return divisors;
}

bool is_prime(long long n){
    if (n==1) return false;
    long long i=2;
    while (i*i<=n){
        if (n%i==0) return false;
        i++;
    }
    return true;
}

int main(){
    long long n,m;
    cin>>n>>m;
    L a=divisor_enumetarion(__gcd(n,m));
    long long ans=0;
    for(auto x:a){
        ans+=is_prime(x);
    }
    print(ans+1);
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[15];
    ll n;
    scanf("%s",s);
    n=strlen(s);
    if(n%2==1){
        printf("No\n");
        return 0;
    }
    rep(i,0,n-1){
        if(s[i]=='h'&& s[i+1]=='i' ){
            i++;
        }else{
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var k = int.Parse(spl[2]);

        var tbl = new char[h][];
        for (int i = 0; i < tbl.Length; i++) {
            tbl[i] = input.ReadLine().ToCharArray();
        }

        var list = new List<P>();
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(tbl[i][j] == Black) {
                    list.Add(new P { h=i, w=j});
                }
            }
        }

        var bsh = new BitSearch(h);
        var bsw = new BitSearch(w);

        long ret = 0;

        do {
            bsw.Reset();
            do {
                int c = 0;
                foreach(var p in list) {
                    if(!bsh[p.h] && !bsw[p.w]) {
                        c++;
                    }
                }
                if(c==k) ret++;
            }while(bsw.Next());
        }while(bsh.Next());

        return ret;
    }

    class P
    {
        public int h;
        public int w;
    }

    class BitSearch
    {
        private int max;
        private int x;
        public int Length { get; }

        //0~n-1
        public bool this[int i] {
            get {
                var si = Length - i - 1;
                return ((x >> si) & 0x01) == 1;
            }
        }

        public BitSearch(int n) {
            this.Length = n;
            this.max = (int)Math.Pow(2, n) - 1;
            this.x = 0;
        }
        public bool Next() {
            if (x >= max) {
                return false;
            }
            x += 1;
            return true;
        }
        public void Reset() {
            x = 0;
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27976
//    ? WHY YOU OPEN THIS ?    //
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
#define PAIR    pair<int,int>
#define Vector  vector<int>
#define MAP     map<int,int>
#define pb      push_back
#define mk      make_pair
#define MOD     1e9+7 
#define all(a)  begin(a),end(a)
#define F       first
#define S       second
 
#define FOR(i, a, b)     for(int i = a; i < b; i++)
#define ROF(i, a, b)     for(int i = a; i>= b; i--)
#define check(c)       cout<<#c<<" : "<<c<<endl;
#define check2(a, b)    cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<endl;
#define check3(a, b, c)  cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<" | "<<#c<<" : "<<c<<endl;
#define SWIFT          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void testCase(){
    // int n; cin >> n;
    // int a[n]; FOR(i, 0, n) cin >> a[i];

	string s; cin >> s;
	int mx = 0, len = 0;
	FOR(i, 0, s.size()){
		if(s[i] == 'R') len += 1;
		else len = 0;
		mx = max(mx, len);
	}	    
	cout << mx << endl;
}
 
signed main(){
    SWIFT;
    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t = 1;
    // int t; cin >> t;
    while(t--){
        testCase();
    }
    return 0;
}

Measured memory_bytes: 3612
def resolve():
    N, K = map(int, input().split())
    S = input()

    # even:1
    # odd:0
    # 1-0-1-0-1 の配列にする. 両端は1にする
    L = []
    pre = "1"
    cnt = 0
    for i in range(N):
        if pre == S[i]:
            cnt += 1
        else:
            L.append(cnt)
            cnt = 1
        pre = S[i]
    L.append(cnt)
    # 最後が0で終わっていたら、仮の1を付け足す。(値が0なので影響ない)
    if pre == "0":
        L.append(0)

    # 1-0-1-0-1の配列を作成し、K＝2だとする。
    # 0を2個含めた個数は, 1＝3、0＝2の長さが作成できる
    length = 2 * K + 1

    # 0をすべて変換できる
    if len(L) <= length:
        return print(N)

    # 1-0-1-0-1の配列なので間に0を含んだ数え上げ
    # なので偶数とびに1を起点に数え上げ
    left = 0
    right = 0
    tmp = 0
    # しゃくとり
    ans = 0
    for i in range(0, len(L), 2):
        nextL = i
        nextR = min(i + length, len(L))

        while nextL > left:
            tmp -= L[left]
            left += 1
        while nextR > right:
            tmp += L[right]
            right += 1

        ans = max(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 10088
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;


lli INF=1e18;

lli memo[101][100001];
lli N,W;
lli w[101];
lli v[101];
lli P;


lli min_weight(lli index,lli tot_price){
	if(tot_price<0)
		return  INF;
	if(tot_price==0)
		return 0;

	if(index==N){
		return INF;
	}
	if(memo[index][tot_price]!=-1)return memo[index][tot_price];
	return memo[index][tot_price] = min({ min_weight(index+1,tot_price) , min_weight(index+1,tot_price-v[index])+w[index] });
}

void solve()
{
	lli i,ans=0;

	for(i=100001;i>=0;i--)
	{
		P=i;
 		if(min_weight(0,0)<=W && min_weight(0,0)!=0)
 		{
			ans=i;
			break;
		}
	}
	cout<<ans;
}



int main()
{
	lli i,j;
	for(i=0;i<100;i++)
	{
		for(j=0;j<100001;j++)
			memo[i][j]=-1;
	}



	cin>>N>>W;

	for(i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
	}

	lli a;

	for(i=0;i<100001;i++)
		a=min_weight(0,i);


	for(i=100000;i>=0;i--)
	{
		if(memo[0][i]<=W)
		{
			cout<<i;
			break;
		}
	}


	return 0;

}



Measured memory_bytes: 78336
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] a, b; readM(n, a, b);
  int[] c, d; readM(n, c, d);

  auto g = GraphW!()(n*2+2);
  foreach (i; 0..n)
    foreach (j; 0..n)
      if (a[i] < c[j] && b[i] < d[j])
        g.addEdge(i, n+j, 1);

  foreach (i; 0..n) {
    g.addEdge(n*2, i, 1);
    g.addEdge(n+i, n*2+1, 1);
  }

  auto r = FordFulkerson!(typeof(g)).fordFulkerson(g, n*2, n*2+1);
  writeln(r);
}

struct GraphW(N = int, W = int, W i = 10^^9)
{
  alias Node = N, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}

template FordFulkerson(Graph)
{
  import std.algorithm, std.container, std.traits;
  alias Node = TemplateArgsOf!Graph[0], Wt = TemplateArgsOf!Graph[1];

  struct EdgeR { Node src, dst; Wt cap, flow; Node rev; }

  Wt fordFulkerson(ref Graph g, Node s, Node t)
  {
    auto n = g.n, adj = withRev(g, n), visited = new bool[](n);

    Wt augment(Node u, Wt cur)
    {
      if (u == t) return cur;
      visited[u] = true;
      foreach (ref e; adj[u]) {
        if (!visited[e.dst] && e.cap > e.flow) {
          auto f = augment(e.dst, min(e.cap - e.flow, cur));
          if (f > 0) {
            e.flow += f;
            adj[e.dst][e.rev].flow -= f;
            return f;
          }
        }
      }
      return 0;
    }

    Wt flow;

    for (;;) {
      visited[] = false;
      auto f = augment(s, g.inf);
      if (f == 0) break;
      flow += f;
    }

    return flow;
  }

  EdgeR[][] withRev(ref Graph g, Node n)
  {
    auto r = new EdgeR[][](n);

    foreach (gi; g)
      foreach (e; gi) {
        r[e.src] ~= EdgeR(e.src, e.dst, e.cap, 0, cast(Node)(r[e.dst].length));
        r[e.dst] ~= EdgeR(e.dst, e.src, 0, 0, cast(Node)(r[e.src].length) - 1);
      }

    return r;
  }
}


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

using VI = vector <int>;
using ll = long long;

ll solve(int n, VI pos, VI L, VI R) {
	vector <vector <int> > V(n+1);
	for (int i = 0; i < n; i ++) {
		int val = R[i] - L[i];
		V[pos[i]].push_back(val);
	}
	ll ans = accumulate(L.begin(), L.end(), 0ll);
	priority_queue <int> pq;
	for (int i = 0; i <= n; i ++) {
		for (auto x : V[i]) pq.push(x);
		while (pq.size() > i) {
			ans += pq.top();
			pq.pop();
		}
	}
	return ans;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
	int T, n;
	cin >> T;
	while (T --) {
		cin >> n;
		VI K(n+1), L(n+1), R(n+1);
		VI vl, vr;
		for (int i = 1; i <= n; i ++) {
			cin >> K[i] >> L[i] >> R[i];
			if (L[i] >= R[i]) vl.push_back(i);
			else vr.push_back(i);
		}
		ll ans = 0;
		vector <int> pos, l, r;
		int sz = vl.size();
		for (auto x : vl) {
			pos.push_back(min(sz, K[x]));
			l.push_back(L[x]);
			r.push_back(R[x]);
		}
		ans += solve(sz, pos, l, r);
		pos.clear(), l.clear(), r.clear();
		sz = vr.size();
		for (auto x : vr) {
			pos.push_back(min(sz, n - K[x]));
			l.push_back(R[x]);
			r.push_back(L[x]);
		}
		ans += solve(sz, pos, l, r);
		cout << ans << endl;
	}
	return 0;
}


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

typedef long long ll;
const ll INF = 9e18;
const int N = 55;

ll a[N];

int main()
{
	ll k; cin >> k;
	int n = 50;
	ll s = k / n;
	k %= n;
	for (int i = 0; i < n; i++) a[i] = i + s;
	for (int i = 0; i < k; i++)
	{
		a[i] += n + 1;
		for (int i = 0; i < n; i++) a[i]--;
	}
	cout << n << endl;
	for (int i = 0; i < n; i++) cout << a[i] << " ";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
	int n,m;
	string S;
	vector<string> s,s2;
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> S;
		s.push_back(S);
	}
	for(int i=0;i<m;i++){
		cin >> S;
		s2.push_back(S);
	}
	
	bool ok;
	for(int i=0;i+m<=n;i++){
		for(int j=0;j+m<=n;j++){
		ok=true;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(s[i+k][j+l]!=s2[k][l]){
						ok=false;
					}
				}
			}
			if(ok) goto bb;
		}
	}
	bb:;
	cout << (ok?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int N;
	cin >> N;
	int greater = 1;
	for (int i = 1; i * i <= N; i++)if (N % i == 0)greater = N / i;
	int ans= log10(greater) + 1;
	cout << ans;
}

Measured memory_bytes: 256
<?php
$a=explode(' ',trim(fgets(STDIN)));
if($a[2]-$a[4]<0){echo 'No';}
elseif($a[3]-$a[4]<0){echo 'No';}
elseif($a[2]+$a[4]>$a[0]){echo 'No';}
elseif($a[3]+$a[4]>$a[1]){echo 'No';}
else{echo 'Yes';}
?>

Measured memory_bytes: 15436
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;

const long long mod = 1e9+7;

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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  for(int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++) {
      int S;
      cin >> S;
      s[i].push_back(S - 1);
    }
  }
  vector<int> p(M);
  for(int i = 0; i < M; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    bool ok = true;
    for (int j = 0; j < M; ++j) {
      int c = 0;
      for (int id : s[j]) {
        // cout << id << " ";
        if ((i >> id) & 1) {
          ++c;
        }
      }
      // cout << endl;
      c %= 2;
      if (c != p[j]) {
        ok = false;
      }
    }
    if (ok) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int w = ni();
        int a = ni();
        int b = ni();

        if (b > a + w) {
            out.println(b - (a + w));
        } else if (a > b + w) {
            out.println(a - (b + w));
        } else {
            out.println(0);
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 23124
n=int(input())
s,rem=input(),0
ans = s.count('R') * s.count('B') * s.count('G')

for i in range(1, (n-1) // 2 + 1):
  for j in range(i*2, n):
    if s[j]+s[j-i]+s[j-2*i] in ("RGB","RBG","GRB","GBR","BGR","BRG"):
      rem += 1
    
print(ans - rem)

Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.System;
import java.math.BigDecimal;

public class Main {

    private static int n;
    private static BigDecimal a, b, z;
    private final static int MAX_LEN = 80;

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

        int n = Integer.parseInt(r.readLine());
        for (int i = 0; i < n; i++) {
            a = new BigDecimal(r.readLine());
            b = new BigDecimal(r.readLine());
            z = a.add(b);

            if (String.valueOf(z).length() > MAX_LEN) {
                System.out.println("overflow");
            } else {
                System.out.println(z);
            }
        }
    }
}

Measured memory_bytes: 18468
#include <iostream>
#include <cmath>

using namespace std;

int cnt;

void InsertionSort(int A[], int n, int g) {
  for(int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void ShellSort(int A[], int n) {
  int m = log2(n) + 1;
  int G[20], j = 1;
  for(int i = m - 1; i >= 0; i--) {
    G[i] = j;
    j *= 2;
  }

  for(int i = 0; i < m; i++) {
    InsertionSort(A,n,G[i]);
  }

  cout << m << endl;
  for(int i = 0; i < m; i++) {
    if(i == m - 1) {
      cout << G[i] << endl;
    } else {
      cout << G[i] << " ";
    }
  }
  cout << cnt << endl;
  for(int i = 0; i < n; i++) {
    cout << A[i] << endl;
  }
}

int main() {
  int n;
  cin >> n;
  static int A[1000000];
  for(int i = 0; i < n; i++) {
    cin >> A[i];
  }

  ShellSort(A, n);

  return 0;
}


Measured memory_bytes: 7184
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, L;
string S;

int main() {
    cin >> N >> L;
    int m = INF;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        a[i] = i + L;
        if (abs(a[i]) < abs(m)) {
            m = a[i];
        }
    }

    cout << accumulate(ALL(a), 0) - m << endl;

    return 0;
}


Measured memory_bytes: 256
use num::rational::Ratio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        r#as: [u64; n],
    }

    let mut ratio = Ratio::new(1, 1);
    for i in k..n {
        let ans = r#as[i - k] < r#as[i];
        println!("{}", if ans { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 5596