akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

int *q;
int head, tail;

void initialize(int n) {
	q = malloc(sizeof(int) * n);
	head = tail = 0;
}

int isEmpty() {
	return head == tail;
}

int isFull() {
	return head == (tail + 1) % MAX;
}

void enqueue(int x) {
	if (!isFull()) {
		q[tail] = x;
		tail = (tail + 1) % MAX;
	}
}

int dequeue() {
	int x;
	if (!isEmpty()) {
		x = q[head];
		head = (head + 1) % MAX;
		return x;
	}
}

int main(int argc, char const *argv[]) {
	char name[100000][11];
	int ptime[100000];
	int time = 0;
	int i, t, n, q, rest;
	scanf("%d%d", &n, &q);
	initialize(MAX);
	for (i = 0; i < n; i++) {
		scanf("%s %d", name[i], &ptime[i]);
		enqueue(i);
	}
	while (!isEmpty()) {
		t = dequeue();
		if (ptime[t] <= q) {
			time += ptime[t];
			ptime[t] = 0;
			printf("%s %d\n", name[t], time);
		} else {
			time += q;
			ptime[t] -= q;
			enqueue(t);
		}
	}
	return 0;
}

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

int main(){
    int N,M,K,swNum,cnt,sum;
    bool flg;
    cnt = 0;
    sum = 0;
    flg = true;
    
    cin >> N >> M;
    
    vector<vector<int>> sw(M);
    vector<int> p(M,0);
    
    //電球iの繋がっているスイッチの個数を入力
    for(int i = 0; i < M; i++){
        cin >> K;
        for(int j = 0; j < K; j++){
            cin >> swNum;
            --swNum;
            sw.at(i).push_back(swNum);
        }
    }
    //点灯パターンを入力
     for(int i = 0; i < M; i++){
        cin >> p.at(i);
    }
    
    //全ての電球が点灯する組み合わせの数を計算
    for(int bit = 0; bit < (1<<N); bit++){
        //電球の点灯/無点灯を決める
        for(int i = 0; i < sw.size(); i++){
            sum = 0;
            //スイッチがONの数を算出
            for(int j = 0; j < sw.at(i).size(); j++){
                if(bit>>sw.at(i).at(j) & 1) sum++;
            }
            //電球の点灯/無点灯判定
            if(sum % 2 != p.at(i)){
               flg = false;
               break;
            }
        }
        //全ての電球が点灯していればカウント変数+1する
        if(flg){
            cnt++;
        }
        
        flg = true;
    }
    
    cout << cnt << endl;
    
    return 0;
}

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

int main()
{
    char s[201], p[101], s2[101], *ret;
    int i = 0;

    scanf("%s", s);
    scanf("%s", p);
    while(s[i]){
        if(s[i+1]){
            s2[i] = s[i];
            i++;
        }else{
            s2[i] = 0;
            break;
        }
    }

    strcat(s,s2);

    ret = strstr(s, p);
    if(ret != NULL){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll p = 1, ans = 0, d=1;
  while(ans<=n) {
    p*=26LL;
    ans += p;
    if(ans+1>n){
      ans-=p;
      p/=26;
      break;
    }
    d++;
  }
  string res = "";
  while(d--) {
    int zz = n%26;
    if(!zz)
      zz = 26;
    n -= zz;
    n/=26;
    res += (char)('a'+zz-1);
  }
  reverse(begin(res), end(res));
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
main()
{
    int n,l,i;
    string s,p;
    vector<string>v;
    cin>>n>>l;
    for(i=0;i<n;i++)
    {
        cin>>s;
        v.pb(s);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
        p+=v[i];
    cout<<p;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <math.h>

int main(){
  long int A,B,C,D;
  scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
  long int S,X;

  long int C1 = (B/C-(A-1)/C);
  long int D1 = (B/D-(A-1)/D);

  X = C * D;

  long int tmp;
  if(C<D){
    tmp = C;
    C = D;
    D = tmp;
  }

  long int R = C%D;
  while(R!=0){
    C = D;
    D = R;
    R = C%D;
  }
  R = X/D;

  S = (B-A+1) - C1 - D1 + (B/R-(A-1)/R);

  printf("%ld\n",S);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;cin>>N;
    vector<int> A(N);
    REP(i,N){cin >>A[i];}
    int bit = 0;
    REP(i,N){
        bit = (bit ^ A[i]);
    }
    vector<int> ans(N);
    REP(i,N){
        ans[i] = bit ^ A[i];
    }
    REP(i,N-1){
        cout <<ans[i] << " ";
    }
    cout <<ans[N-1] << endl;
}

Measured memory_bytes: 4776
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 100000;

ll N, A, B;
ll X[MAX_N];

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

    cin >> N >> A >> B;

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

    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ll wcost = A * (X[i + 1] - X[i]);
        if (wcost >= B) {
            ans += B;
        } else {
            ans += wcost;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 4428
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = b = c = d = e = f = 0
    c = 10 ** 9
    d = 1
    f = (n + c - 1) // c
    e = c * f - n
    print(a, b, c, d, e, f)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	int h,w,k;
	string s;
	cin >> h >> w >>k;
	vector<string>v;
	for(int i=0;i<h;i++){
		cin >> s;
		v.push_back(s);
	}
	queue<pair<int,int> > q,q2;
	int flag[802][802]={};
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(v[i][j]=='S'){
				flag[i][j]=1;
				q.push(make_pair(i,j));
			}else if(v[i][j]=='#'){
				flag[i][j]=-1;
			}
		}
	}
	int count =0;
	pair<int,int> p;
	int x,y;
	while(count<k){
		while(!q.empty()){
		p = q.front();
		q.pop();
		x = p.first;
		y = p.second;
		if(x+1<h){
			if(flag[x+1][y]==0){
				flag[x+1][y]=1;
				q2.push(make_pair(x+1,y));
			}
		}
		if(y+1<w){
			if(flag[x][y+1]==0){
				flag[x][y+1]=1;
				q2.push(make_pair(x,y+1));
			}
		}
		if(x>0){
			if(flag[x-1][y]==0){
				flag[x-1][y]=1;
				q2.push(make_pair(x-1,y));
			}
		}
		if(y>0){
			if(flag[x][y-1]==0){
				flag[x][y-1]=1;
				q2.push(make_pair(x,y-1));
			}
		}
		}
		q = q2;
		while(!q2.empty()){
			q2.pop();
		}
		count +=1;
	}
	int min=100000000;
	int tmp;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(flag[i][j]==1){
				tmp = std::min(i,j);
				tmp = std::min(tmp,h-i-1);
				tmp = std::min(tmp,w-j-1);
				if(min>tmp){
					min = tmp;
				}
			}
		}
	}
	if(min==0){
		cout << 1 << endl;
	}else{
		if(min%k==0){
			cout << 1+min/k <<endl;
		}else{
			cout << 1+min/k+1 <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
  long long n, ans;

  scanf("%lld", &n);

  if (n % 2 == 0)
  {
    ans = n;
  }
  else
  {
    ans = 2 * n;
  }

  printf("%lld\n", ans);

  return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr int MAX = 1e5 + 10;

std::vector<int> g[MAX];
bool used[MAX];

void dfs(int v)
{
    used[v] = 1;
    for (auto x : g[v])
    {
        if (!used[x])
        {
            dfs(x);
        }
    }
}

int main()
{
    int n, m;

    std::cin >> n >> m;

    rep(i, m)
    {
        int a, b;
        std::cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;

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

    std::cout << ans - 1 << std::endl;

    return 0;
}

Measured memory_bytes: 9648
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
using namespace std;


int main()
{
    string s,t;
    getline(cin,s);
    getline(cin,t);
    if(s.length()!=t.length()) cout<<"No\n";
    else
    {
        bool same;
        for(int i=0; i<s.length(); i++)
        {
            same = true;
            for(int j=0; j<s.length(); j++)
            {
                if(s[(i+j)%s.length()]!=t[j])
                {
                    same = false;
                    break;
                }
            }
            if(same)
            {
                cout<<"Yes\n";
                break;
            }
        }
        if(!same) cout<<"No\n";
    }
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

map<string,int>m;

int main()
{
    weewoo;
    string x,y;
    cin >> x >> y;
    ll a,b;
    cin >> a >> b;
    m[x]=a;
    m[y]=b;
    string c;
    cin >> c;
    m[c]--;
    cout << m[x] << ' ' << m[y] << endl;
    return 0;
}


Measured memory_bytes: 256
import math
a,b,c=map(float,input().split())
c *= math.pi/180
print("{:.10f}\n{:.10f}\n{:.10f}".format(a*b*math.sin(c)/2, a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(c)), b*math.sin(c)))


Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;



int main(){

    int n; cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);
    rep(i,n) cin >> c.at(i);
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;

    rep(i,n){
        auto x = lower_bound(all(a),b.at(i));
        auto y = upper_bound(all(c),b.at(i));
        ans +=  (x - a.begin())*(c.end() - y);

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


Measured memory_bytes: 2560
a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())
 
if a<b:
  if b+w*t<=a+v*t:
    print('YES')
  else:
    print('NO')
if a>b:
  if a-v*t<=b-w*t:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 9144
#include<stdio.h>
int main(){
  int n,m,x,y,w,h,s,t,c;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d %d",&x,&y,&w,&h);
    scanf("%d",&m);
    c=0;
    while(m--){
      scanf("%d %d",&s,&t);
      if(x<=s&&s<=x+w&&y<=t&&t<=y+h)c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
	int n,i,l;
	long a[5000],ans,s;
	
	for(i=0;i<5000;i++)a[i]=NULL;
	
	while(scanf("%d",&n)){
		if(n==0)break;
		ans=-100000;
		for(i=0;i<n;i++){
			scanf("%ld",&a[i]);
		}
		
		for(i=0;i<n;i++){
			s=0;
			for(l=i;l<n;l++){
				s+=a[l];
				if(ans<s)ans=s;
			}
		}
		
		printf("%ld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int abs(int x){
    return max(x, -x);
}

int main() {
    vector<int> x(5);
    rep(i, 5){
        cin >> x.at(i);
        if(x.at(i)==0){
            cout << i+1 << endl;
            return 0;
        }
    }
}

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

typedef long long ll;

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

#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

typedef double D;
typedef complex<D> P;
namespace std{
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}

struct L : public vector<P> {
  L(const P&a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; D r;
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1; //ccw
  if(cross(b, c) < 0) return -1; //cw
  if(dot(b, c) < 0)   return +2; //c-a-b on line
  if(norm(b) < norm(c)) return -2; //a-b-c on line
  return 0;
}

P projection(const L& l, const P& p) {
  D t = dot(p - l[0], l[0] - l[1]) / norm(l[0]- l[1]);
  return l[0] + t * (l[0] - l[1]);
}
P refrection(const L& l, const P& p) {
  return p + 2.0 * (projection(l, p) - p);
}

bool intersectSP(const L& l, const P& p) {
  return abs(l[0]-p) + abs(l[1]-p) - abs(l[1] - l[0]) < EPS;
}

bool intersectSS(const L& a, const L& b) {
  return ccw(a[0], a[1], b[0]) * ccw(a[0], a[1], b[1]) <= 0
    && ccw(b[0], b[1], a[0]) * ccw(b[0], b[1], a[1]) <= 0;
}
P crossP(const L& a, const L& b) {
  D x = cross(a[1]-a[0], b[1]-b[0]);
  D y = cross(a[1]-a[0], a[1]-b[0]);
  if(abs(x) < EPS && abs(y) < EPS) return a[0];
  return b[0] + y / x * (b[1]-b[0]);
}
D distSP(const L& l, const P& p) {
  const P r = projection(l, p);
  if(intersectSP(l, r)) return abs(r - p);
  return min(abs(l[0]-p), abs(l[1]-p));
}
D distSS(const L& a, const L& b) {
  if(intersectSS(a, b)) return 0;
  return min({distSP(a, b[0]), distSP(a, b[1]), distSP(b, a[0]), distSP(b, a[1])});
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    vector<P> ps(4);
    rep(i, 4) {
      D x, y;
      cin >> x >> y;
      ps[i] = {x, y};
    }
    vector<L> ls;
    rep(i, 2) ls.push_back({ps[2*i], ps[2*i+1]});
    cout << fixed << setprecision(20);
    cout << distSS(ls[0], ls[1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#include <random>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;



int main(){
  int n;
  cin>>n;
  vector<int> x(n),y(n);
  vector<P> plus(n),minus(n);
  rep(i,n){
    cin>>x[i]>>y[i];
    plus[i].first=x[i]+y[i];
    minus[i].first=x[i]-y[i];
    plus[i].second=i;
    minus[i].second=i;
  }
  sort(plus.begin(),plus.end());
  sort(minus.begin(),minus.end());
  int ans=0;
  int temp=0;
  rep(i,n){//
    if(plus[0].second!=i){
      temp=max(x[i]+y[i]-plus[0].first,temp);
      temp=max(-(x[i]+y[i])+plus[0].first,temp);

    }
    if(plus[n-1].second!=i){
      temp=max(-(x[i]+y[i])+plus[n-1].first,temp);
      temp=max(x[i]+y[i]-plus[n-1].first,temp);

    }
    if(minus[0].second!=i){
      temp=max(-(x[i]-y[i])+minus[0].first,temp);
      temp=max((x[i]-y[i])-minus[0].first,temp);

    }
    if(minus[n-1].second!=i){
      temp=max(-(x[i]-y[i])+minus[n-1].first,temp);
      temp=max(x[i]-y[i]-minus[n-1].first,temp);
    }
  }
  cout<<temp<<endl;


}


Measured memory_bytes: 7936
/*
 * SAD
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back
const int inf = 1e9;
using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, M = 1000 * 1000 * 10 + 5, K = 55, Base = 27, MOD = 1e9
		+ 7, MOD2 = 998244353;
const ll MX = 1e15;
const int blkSz = 200;
const db EPS = 1e-7;
const int PI = 3;

int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	string s;
	cin >> s >> s;
	int r = count(s.begin(),s.end(),'R');
	int b = count(s.begin(),s.end(),'B');
	if(r > b)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int main(){
    ll n,k;
    cin>>n>>k;
    ll res=k;
    rep(i,1,n-1)
        res*=(k-1);
    cout<<res<<endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "2";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    while (a >= b) {
        ans++;
        b *= 2;
    }

    while (b >= c) {
        ans++;
        c *= 2;
    }

    cout << yn(ans <= k) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}


Measured memory_bytes: 3524
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,num=0;
    cin >> N;
    for(int i=1;2*i-1<=N;i++){
        int count=0;
        for(int j=1; j<=2*i-1;j++){
        if((2*i-1)%j==0) count++;
        }
        if(count==8) num++;
    }
    cout << num << endl;
}

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

int main() {
  string s; cin >> s;

  int n = s.size() - 1;
  int left = 0, right = n;
  int ans = 0;
  bool flag = true;
  while (left <= right) {
    if (s[left] == s[right]) {
      left ++, right --;
    } else if (s[left] == 'x') {
      left ++, ans ++;
    } else if (s[right] == 'x') {
      right --, ans ++;
    } else {
      flag = false;
      break;
    }
  }

  if (flag) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  string[] st = readln.chomp.split;
  int[] ab = readln.chomp.split.to!(int[]);
  string u = readln.chomp;
  if(u==st[0]) ab[0]--;
  else if(u==st[1]) ab[1]--;
  writef("%d %d\n", ab[0], ab[1]);
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int X, Y;
  cin >> X >> Y;
  rep(a, 0, X + 1) {
    int b = X - a;
    if (a * 2 + b * 4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return (0 ^ _ ^ 0);
}



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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n, k;
ll dp[MAXN], h[MAXN];

bool read() {
    if (!(cin >> n >> k))
        return false;

    forn (i, n)
        cin >> h[i];

    return true;
}

void solve() {
    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        dp[i] = INF * INF;

        for (int j = 1; j <= k && i - j >= 0; ++j)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
    }

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

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,m,n;
	string Dice;
	int sum;
	int num[6],s[6];
	while(1){
		sum=1;
		for(i=0;i<6;i++){
			s[i]=i+1;
			num[i]=i+1;
		}
		cin>>n;
		if(n==0){
			break;
		}
		for(m=0;m<n;m++){
			cin>>Dice;
			if(Dice=="North"){
				num[0]=s[1];
				num[1]=s[5];
				num[4]=s[0];
				num[5]=s[4];
				s[0]=num[0];
				s[1]=num[1];
				s[4]=num[4];
				s[5]=num[5];
			}
			else if(Dice=="East"){
				num[0]=s[3];
				num[2]=s[0];
				num[3]=s[5];
				num[5]=s[2];
				s[0]=num[0];
				s[2]=num[2];
				s[3]=num[3];
				s[5]=num[5];
			}
			else if(Dice=="West"){
				num[0]=s[2];
				num[2]=s[5];
				num[3]=s[0];
				num[5]=s[3];
				s[0]=num[0];
				s[2]=num[2];
				s[3]=num[3];
				s[5]=num[5];
			}
			else if(Dice=="South"){
				num[0]=s[4];
				num[1]=s[0];
				num[4]=s[5];
				num[5]=s[1];
				s[0]=num[0];
				s[1]=num[1];
				s[4]=num[4];
				s[5]=num[5];
			}
			else if(Dice=="Right"){
				num[1]=s[2];
				num[2]=s[4];
				num[3]=s[1];
				num[4]=s[3];
				s[1]=num[1];
				s[2]=num[2];
				s[3]=num[3];
				s[4]=num[4];
			}
			else{
				num[1]=s[3];
				num[2]=s[1];
				num[3]=s[4];
				num[4]=s[2];
				s[1]=num[1];
				s[2]=num[2];
				s[3]=num[3];
				s[4]=num[4];
			}
			sum=sum+num[0];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int H, W;

  std::cin >> H >> W;

  std::vector<std::string> board(H + 2, std::string(W + 2, '#'));

  for (int i = 1; i <= H; i ++) {
    std::cin >> board[i];

    board[i] = '#' + board[i] + '#';
  }

  for (const auto& s : board)
    std::cout << s << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        int n;
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(n);
        
        for(int i = 0; i < n; i++){
            map.put(sc.nextInt(), i + 1);
        }
        
        for(int j = 1; j <= n; j++){
            if(j > 1){
                System.out.print(" ");
            }
            System.out.print(map.get(j));
        }
        
    }
}


Measured memory_bytes: 71372
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    ll a[100004];
    map<ll,int>m;
    m.clear();
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    sort(a,a+n,greater<int>());
    /*for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }*/
    ll h=0,w=0;
    for(int i=0;i<n;i++){
        //cout<<a[i]<<" "<<m[a[i]]<<endl;
        if(h==0){
            if(m[a[i]]>=4){
                h=a[i];
                w=a[i];
                break;
            }else if(m[a[i]]>=2){
                h=a[i];
                m[a[i]]-=2;
            }
        
        }else{
            if(m[a[i]]>=2){
                w=a[i];
                break;
            }
        }
    }
    ll ans=h*w;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,p;
	int i,j;
	int  a[100000];
	int b[100000];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>p;
	for(i=0;i<p;i++){
		cin>>b[i];
	}
	int c=0;
	for(i=0;i<p;i++){
		j=lower_bound(a,a+n,b[i])-a;
		if(a[j]==b[i])c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int Maxn = 100010;

int cnt[Maxn];


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

    int ans = 0;
    for (int i = 1; i < Maxn - 1; i++){
        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
    }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

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

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

ll cntTwo(ll x) {
    ll ret = 0;
    while (x % 2 == 0) {
        x /= 2;
        ret++;
    }
    return ret;
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll a[n];
    for (int i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        tmp /= 2;
        a[i] = tmp;
    }
    ll two = cntTwo(a[0]);
    for (int i = 1; i < n; i++) {
        if (two != cntTwo(a[i])) {
            OUT(0);
            return 0;
        }
    }
    ll t = a[0];
    for (int i = 1; i < n; i++) {
        t = lcm(t, a[i]);
    }
    ll ans = (m / t + 1) / 2;
    OUT(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    OKawaiiKoto
    ll n,k,a[1005];
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,k) ans+=a[i];
    cout<<ans;
}


Measured memory_bytes: 3560
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int n = S.length();
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<n-8;i++) {
			sb.append(S.charAt(i));
		}
		System.out.println(sb.toString());
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

ll addmod(ll a,ll b)
{
    if(a+b<mod)return a+b;
    else return a+b-mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll modinv(ll a)
{
    return modexp(a,mod-2,mod);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x; cin>>x;
	ll ans = 1000*(x/500);
	x-=(x/500)*500;
	ans+=(5*(x/5));
	cout<<ans<<endl;
	return 0;
}
/*
6
1 2 3 4 5 -6
*/


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  string S;
  cin >> S;

  ll length = S.size();

  vector<vector<ll>> dp(length, vector<ll>(13,0));

  if(S[0] == '?'){
    rep(i, 10) dp[0][i] = 1;
  }
  else{
    int x = S[0] - '0';
    dp[0][x] = 1;
  }

  for(int i = 0; i < length-1; i++){
    for(int j = 0; j < 13; j++){
      if(S[i+1] == '?'){
        rep(k, 10){
          int next_j = (j * 10 + k) % 13;
          dp[i+1][next_j] += dp[i][j];
          dp[i+1][next_j] %= MOD;
        }
      }
      else{
        int x = S[i+1] - '0';
        int next_j = (j * 10 + x) % 13;
        dp[i+1][next_j] += dp[i][j];
        dp[i+1][next_j] %= MOD;
      }
      //cout << dp[i+1][j] <<" ";
    }
    //cout << endl;
  }

  cout << dp[length-1][5] << endl;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N,int a,int b)
{
    vector<ll> F1(3);
    F1[1] = a;
    F1[2] = b;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = -1, T[2][2] = 1;
    if (N == 1)
        return a;
    if(N==2) return b;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]+ MOD)%MOD ;
    return res;
}

//1 2 3 4 5
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 int t =1;
 while(t--)
  {
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      cout<<max(0,min(b,d)-max(a,c));

     // 3 0 3 0 3

  }
}


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

const int INF = 2e9;

int main(){
    int k,s;
    cin >> k >> s;
    ll ans = 0;
    rep(x,k+1){
        rep(y,k+1){
            int z = s - x - y;
            if(0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
}

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

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d=a-b;
    int ans=c-d;
    if(ans>=0){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,y{0};
    cin>>a>>b>>c>>k;
    if(k<a)
    {
        y=k;
    }
    else
    {
        y=a;
    }
 
    if(k-a-b>0)
    {
        y+=(k-a-b)*(-1);
    }
    cout<<y<<endl;
}

Measured memory_bytes: 3640
# coding: utf-8

N = input()

list=[]
flag = True

for i in range(int(N)):
    temp=input()
    #print(temp)
    if str(temp) in list:
        flag=False
    list.append(temp)
    if flag==False:
        break

    str1=list[i-1]
    str2=list[i]
    if i!=0:
        if str1[-1]==str2[0]:
            flag=True
        else:
            flag=False
    if flag==False:
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++i) {
            fac[i]  = fac[i - 1] * i % mod;
            inv[i]  = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint operator()(lint n, lint k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    Combination nCk(4 * 1000000);
    auto f = [&](int r, int c) {
        mint ret = 0;
        for (int i = 1; i <= r + 1; ++i) {
            ret += nCk(i + c, c);
        }
        return ret;
    };
    mint ret = f(r2, c2);
    if (r1 != 0)
        ret -= f(r1 - 1, c2);
    if (c1 != 0)
        ret -= f(r2, c1 - 1);
    if (r1 != 0 && c1 != 0)
        ret += f(r1 - 1, c1 - 1);

    cout << ret << "\n";
    return 0;
}

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


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

int main() {

	long long m, a[5];
	cin >> m;
	rep(i, 5) cin >> a[i];

	long long ans = 0;
	rep(i, 5) {
		ans = max(ans, (m - 1) / a[i] + 1);
	}
	ans += 4;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq

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

a = [0] * n
b = [0] * n
info = [[] for _ in range(m+1)]

for i in range(n):
    a[i], b[i] = map(int,input().split())
    if a[i] <= m:
        info[a[i]].append(b[i])

l = []
count = 0

for j in range(1,m+1):
    for x in info[j]:
        heapq.heappush(l,-x)
    if l != []:
        count += -heapq.heappop(l)

print(count)


Measured memory_bytes: 23128
n = int(input())
A = input().split()

print(' '.join(A))
for i in range(1,n):
    for j in range(i,0,-1):
        if int(A[j]) < int(A[j-1]):
            A[j], A[j-1] = A[j-1], A[j]
    print(' '.join(A))



Measured memory_bytes: 5600
#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=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mmax=1000009;

int main(void){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    long long ans=0;
    int right=0;
    long long sum=0,xsum=0;
    rep(left,n){
        while(right<n){
            sum+=A[right];
            xsum^=A[right];
            if(sum!=xsum){
                sum-=A[right];
                xsum^=A[right];
                break;
            }
            right++;
        }
        ans+=right-left;
        //printf("l=%d r=%d ans=%ld sum=%ld xsum=%ld\n",left,right,ans,sum,xsum);
        if(left==right) right++;
        else{
            sum-=A[left];
            xsum^=A[left];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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


			

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<pair<int,pair<int,int>>> V(N);
	for(int i=0;i<N;i++)scanf("%d %d %d",&V[i].second.first,&V[i].second.second,&V[i].first);
	sort(V.begin(),V.end());
	
	for(int i=0;i<N;i++){
		V[i].second.first-=V[i].first;
		V[i].second.second-=V[i].first;
	}
	
	vector<int> ans(Q,-1);
	
	set<int> S;
	vector<int> D(Q);
	for(int i=0;i<Q;i++){
		scanf("%d",&D[i]);
		S.insert(D[i]);
	}
	
	for(int i=0;i<N;i++){
		auto a = S.lower_bound(V[i].second.first);
		for(;a!=S.end();){
			if(*a<V[i].second.second){
				ans[lower_bound(D.begin(),D.end(),*a)-D.begin()]=V[i].first;
				a=S.erase(a);
			}
			else{
				break;
			}
		}
	}
	
	for(int i=0;i<Q;i++){
		printf("%d\n",ans[i]);
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 15104
#!/usr/bin/env python3
import sys
def read(): return sys.stdin.readline() # 標準入力
def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示
def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f


def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N): # スイッチの状態を全て列挙(bit全探査)
        # ビットの数をカウント
        # count = popcount(bits)
        flag = True
        for i in range(M): # 点灯条件 M[i]でpopcount%2=p[i]
            # マスクビット用のmaskを作成
            mask = 0
            # 各電球の利用可能スイッチをマスクで取得 => 1,2 なら　0b11とか
            for j in s[i]:
                mask = mask|1<<(j-1)
            # print(fbit(mask))
            # ビットカウント => 条件分岐
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans)

def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p)


if __name__ == '__main__':
    main()



2&3


Measured memory_bytes: 73784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll d, t, s;cin >> d >> t >> s;
    if(s*t < d){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

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

int n, x[101];

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

    cin >> n;
    for(int i = 0; i < n; i++) cin >> x[i];

    int ans = 1e9;
    for(int p = 1; p <= 100; p++) {
        int stamina = 0;
        for(int i = 0; i < n; i++) {
            stamina += (p - x[i]) * (p - x[i]);
        }
        ans = min(ans, stamina);
    }

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


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])

Measured memory_bytes: 20704