akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int a[200006],b[200006];
int n1[200006],n2[200006];
int min(int a,int b)
{
	return a>b?b:a;
}
int main()
{
	ios;
	int len;
	int l=0,r=0;
	cin>>len;
	for(int i=1;i<=len;++i)
	{
		cin>>a[i];
		n1[a[i]]++;
	}
	for(int i=len;i>0;--i)
	{
		cin>>b[i];
		n2[b[i]]++;
	}
	int flag=0;
	for(int i=1;i<=len;++i)
	{
		if(a[i]==b[i]&&!flag){l=i;r=i;flag=1;}
		else if(a[i]==b[i])
		{
			r=i;
		}
	}
	if(l==0){
		cout<<"Yes\n"<<b[1];
		for(int i=2;i<=len;++i){cout<<' '<<b[i];}
		cout<<'\n';
		return 0;
	}
	if(len-n2[a[l]]<r-l+1)cout<<"No"<<'\n';
	else 
	{
		int l1=l;
		int goal=a[l];
		for(int i=1;i<l;++i)
		{
			if(l1>r)break;
			if(b[i]!=goal&&a[i]!=goal){b[l1]+=b[i];b[i]=b[l1]-b[i];b[l1]-=b[i];l1++;}
		}
		for(int i=r+1;i<=len;++i)
		{
			if(l1>r)break;
			if(b[i]!=goal&&a[i]!=goal){b[l1]+=b[i];b[i]=b[l1]-b[i];b[l1]-=b[i];l1++;};
		}
		if(l1>r)
		{
			cout<<"Yes\n"<<b[1];
			for(int i=2;i<=len;++i){cout<<' '<<b[i];}
			cout<<'\n';
		}
		else cout<<"No"<<'\n';
	}
} 

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

#define int long long
const int inf = 1145141919;
using pi = pair<int, int>;
using data = pair<pi, pi>;
int D[100][25];
vector<data> G[100];
int A[500], B[500], Cost[500], Hour[500], R[500];

int calc(int u, int time, int S)
{
    if(D[u][time] >= 0)
    {
        return D[u][time];
    }
    if (time == 0)
    {
        return D[u][time] = inf; 
    }
    

    int ret = calc(u, time - 1, S);
    for(auto v : G[u])
    {
        int to = v.first.first;
        int cost = v.first.second;
        int hour = v.second.first;
        int route = v.second.second;
        if (S >> route & 1)
        {
            cost = 0;
        }
        if(time - hour >= 0)
        {
            ret = min(ret, calc(to, time-hour, S) + cost);
        }
    }

    return D[u][time] = ret;
}

signed main()
{
    while (true)
    {
        int N, M, H, K;
        cin >> N >> M >> H >> K;
        if (N == 0)
            return 0;

        rep(i, N)G[i].clear();

        rep(i, M)
        {
            cin >> A[i] >> B[i] >> Cost[i] >> Hour[i] >> R[i];
            A[i]--;
            B[i]--;
            R[i]--;

            G[A[i]].emplace_back(data(pi(B[i], Cost[i]), pi(Hour[i], R[i])));
            G[B[i]].emplace_back(data(pi(A[i], Cost[i]), pi(Hour[i], R[i])));
        }
        int start, goal, P;
        cin >> start >> goal >> P;
        start--;
        goal--;

        vector<int> pass(1 << K, inf);
        pass[0] = 0;

        rep(i, P)
        {
            int L, D;
            cin >> L >> D;
            int stop = 0;
            rep(j, L)
            {
                int t;
                cin >> t;
                t--;
                stop |= 1 << t;
            }
            rep(j, pass.size())
            {
                if (pass[j] == inf)
                {
                    continue;
                }
                pass[j | stop] = min(pass[j | stop], pass[j] + D);
            }
        }

        int ans = inf;
        
        rep(S, pass.size())
        {
            if (pass[S] == inf)
            {
                continue;
            }

            //頂点iにj時に着く時の最小コスト
            memset(D, -1, sizeof(D));
            rep(i, H + 1)
            {
                D[start][i] = 0;
            }

            ans = min(ans, calc(goal, H, S) + pass[S]);
        }

        if (ans < inf)
        {
            cout << ans << endl;
        }
        else
        {
            cout << "-1" << endl;
        }
    }
}


Measured memory_bytes: 3232
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                a=__gcd(i,j);
                sum+=__gcd(a,k);

            }
        }
     }
     cout<<sum<<endl;

     return EXIT_SUCCESS;
}



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

int a, b;
int main () {
	cin >> a >> b;
		if ( a, b >=1 && a,b <=13){
		} if (a > b && b != 1){
			cout << "Alice" << endl;
		} else if ( a < b && a != 1){
			cout << "Bob" << endl;
		} else if ( a == b){
			cout << "Draw" << endl;
		} else if ( a == 1) {
			cout << "Alice" << endl;
		} else if ( b == 1 ){
			cout << "Bob" << endl;
	
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  int ans1,ans2;
  cin>>a>>b>>c>>d;
  if(c%b==0)
  {
      ans1=c/b;
  }
  else
    ans1=c/b+1;
  if(a%d==0)
  {
      ans2=a/d;
  }
  else
    ans2=a/d+1;
  if(ans1>ans2)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

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

int main() {
	vector<int> c(4);

	rep(i,3) {
		int a,b;
		cin >> a >> b;
		++c.at(--a), ++c.at(--b);
	}

	rep(i,4)
		if(c.at(i) > 2) {
			cout << "NO" << endl;
			return 0;
		}
	cout << "YES" << endl;
}

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


int main() {
  //int long long total=0,H,W,i,j;
  int N,a,b,c;
  cin>>N;
  for(int i=N;true;i++){
      a=i/100;
      b=(i-a*100)/10;
      c=i-(100*a)-(10*b);
      if(a==b && b==c){
          cout<<i<<endl;
          break;
      }
  }
}


Measured memory_bytes: 256
N = int(input())

def divisors(n):
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            ret.add(m)
            ret.add(n//m)
        m += 1
    return ret

a = divisors(N)
b = divisors(N-1)

ans = len(b)-1
for k in a:
    if k==1: continue
    n = N
    while n%k==0:
        n //= k
    if n%k == 1:
        ans += 1

print(ans)

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

void solve(int ind, ll x, vector<ll> &ans) {
    if (fin) return;
    int ni = ind+1;
    if (ni == n) ni = 0;
    if (ni == start) fin = true;

    ll tmp = a[ind]-x/2;
    ans[ni] = tmp*2;
    solve(ni, ans[ni], ans);
}

int main(int argc, char const *argv[]) {
    cin >> n;
    a.resize(n);
    ll sum = 0;
    REP(i,n) {
        cin >> a[i];
        sum += a[i];
    }

    ll bsum = 0;
    vector<ll> b(n);
    for (int i = 0; i < n; ++i) {
        b[i] = a[i]*2;
    }

    ll tmp = 0;

    for (int i = 0; i < n-1; i += 2) {
        tmp += (b[i]);
    }

    start = n-1;
    ll X = sum-tmp;
    // printf("start = %d, sum = %lld, tmp = %lld, X = %lld\n", start,sum,tmp,X);
    vector<ll> ans(n);
    solve(n-1,X,ans);

    REP(i,n) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
ll dp[30][200001]={};
map<ll,int>mp;

void add(int h,int k){
	dp[0][h]+=k;
	int s=1;
	h/=2;
	while(s<=29){
		dp[s][h]=dp[s-1][h*2]+dp[s-1][h*2+1];
		h/=2;
		s++;
	}
}
ll sum(int h){
	ll r=dp[0][h];
	int s=0;
	while(h>0){
		if(h%2>0)r+=dp[s][h-1];
		else r+=dp[s+1][(h-1)/2];
		h=(h-1)/2;
		++s;
	}
	return r;
}
ll b[200001]={};
ll c[200001]={};
int main() {
	ll n,k,a;
	cin>>n>>k>>a;
	b[0]=a-k;
	c[0]=b[0];
	rep(i,1,n){
		cin>>a;
		b[i]=b[i-1]+a-k;
		c[i]=b[i];
	}
	sort(c,c+n);
	rep(i,0,n)mp[c[i]]=i;

	ll ans=0;
	rep(i,0,n){
		if(b[i]>=0)++ans;
		int d1=mp[b[i]];
		ans+=sum(d1);
		add(d1,1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 61824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) break;
			for (int i = 0; i < H; i++) {
				for(int k = 0; k < W; k++) {
					if(i%2 == 0 && k%2 == 0) {
						System.out.print("#");
					}
					else if (i%2 != 0 && k%2 != 0){
						System.out.print("#");
					}
					else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 34784
/*
	Name:
	Author: xiaruize
	Date:
*/
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		cout<<s[i];
	}
	return 0;
}


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

#define NO_DATA -1
#define MAX_COUNT 20

int main(int argc, const char * argv[]) {
    unsigned int input;
    int resultArray[MAX_COUNT];
    int scanResult;
    int index = 0;
    
    for(int cnt=0;cnt<MAX_COUNT;cnt++){
        resultArray[cnt]=NO_DATA;
    }

    
    scanResult = scanf("%ud", &input);
    while (scanResult!=EOF) {
        int result = 0;
        for (int i=input; i<=600-input; i+=input) {
            result = result + i*i*input;
        }
        resultArray[index]=result;
        index++;
        
        scanResult = scanf("%ud", &input);
    }
    
    for (int i=0; i<index; i++) {
        printf("%d\n",resultArray[i]);
    }
    
    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;
    string S; cin >> S;

    vector<int> R_cnt(N+1,0);
    vector<int> G_cnt(N+1,0);
    vector<int> B_cnt(N+1,0);

    for(int i=N-1; i>=0; i--){
        if(S.at(i) == 'R'){
            R_cnt.at(i) = R_cnt.at(i+1)+1;
            G_cnt.at(i) = G_cnt.at(i+1);
            B_cnt.at(i) = B_cnt.at(i+1);
        }else if(S.at(i) == 'G'){
            R_cnt.at(i) = R_cnt.at(i+1);
            G_cnt.at(i) = G_cnt.at(i+1)+1;
            B_cnt.at(i) = B_cnt.at(i+1);
        }else if(S.at(i) == 'B'){
            R_cnt.at(i) = R_cnt.at(i+1);
            G_cnt.at(i) = G_cnt.at(i+1);
            B_cnt.at(i) = B_cnt.at(i+1)+1;
        }

    }

    long long ans = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){

            if( (S.at(i) == 'R' && S.at(j) == 'G') || (S.at(i) == 'G' && S.at(j) == 'R') ){
                //Bを数える
                ans += B_cnt.at(j);

                if(2*j-i < N && S.at(2*j-i) == 'B'){
                    ans--;
                }

            }

            if( (S.at(i) == 'G' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'G') ){
                //Bを数える
                ans += R_cnt.at(j);

                if(2*j-i < N && S.at(2*j-i) == 'R'){
                    ans--;
                }

            }

            if( (S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R') ){
                //Bを数える
                ans += G_cnt.at(j);

                if(2*j-i < N && S.at(2*j-i) == 'G'){
                    ans--;
                }

            }





        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3672
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0;
  cin >> n;

  if(n%2==0){
    pri(n/2);
  }
  else{
    pri(n/2+1);
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int t = Integer.parseInt(sa[0]);
		for (int i = 0; i < t; i++) {
			sa = br.readLine().split(" ");
			long a = Long.parseLong(sa[0]);
			long b = Long.parseLong(sa[1]);
			long c = Long.parseLong(sa[2]);
			long d = Long.parseLong(sa[3]);

			if (a < b || b > d) {
				System.out.println("No");
			} else {
				long e = BigInteger.valueOf(b).gcd(BigInteger.valueOf(d)).longValue();
				long g = a % b;
				long h = (c + 1 - g + e - 1) / e;
				long min = g + e * h;
				if (min < b) {
					System.out.println("No");
				} else {
					System.out.println("Yes");
				}
			}
		}
		br.close();
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll x,y;
    cin>>x>>y;
    if(x==y){
        cout<<0<<endl;return 0;
    }
    if(x==0){
        if(y<0) cout<<abs(y)+1<<endl;
        else cout<<y<<endl;
        return 0;
    }
    if(y==0){
        if(x<0) cout<<abs(x)<<endl;
        else cout<<x+1<<endl;
        return 0;
    }




    //符号揃ってて単純にyの方が大きければ++する操作だけ
    if(x*y>0&&y>x){
        cout<<y-x<<endl;return 0;
    }
    




    //符号が揃っているがxの方が大きい
    if(x*y>0){
        //両者正
        //符号反転->絶対値揃え->符号反転が最適
        if(x>0){
            cout<<2+abs(x)-abs(y)<<endl;return 0;
        }   
        //両者負
        //このときxを符号反転加えて絶対値をyにそろえるxをまた符号反転が最適
        else{
            cout<<2+abs(y)-abs(x)<<endl;return 0;
        }
    }

    //以下xとyの符号が違う
    //これって負をxに固定して問題ない気がする操作回数変わらない
    if(y<0){
        y=-y;
        x=-x;
    }
    if(abs(x)>abs(y)){
        cout<<abs(x)-abs(y)+1<<endl;
    }
    else{
        cout<<1+y-abs(x)<<endl;
    }
    return 0;
}

Measured memory_bytes: 764
def ternary_search(*, l, r, func, loop_count=100, find_local_minimum: bool = True):
    """
    三分探索とは「たかだか一つしか極値のない関数fにおける極値を探索するアルゴリズム」
    https://qiita.com/ganariya/items/1553ff2bf8d6d7789127
    loop_count: 70-80で十分.厳密には2/3の冪乗で収束するか計算.epsで条件判定は無限ループが怖い.
    """

    if find_local_minimum:  # 極小値
        for i in range(loop_count):
            c1 = (l * 2 + r) / 3  # lr間を3等分した内分点
            c2 = (l + r * 2) / 3  # lr間を3等分した内分点
            if func(c1) > func(c2):
                l = c1  # 大きい方を(中央に)近づける
            else:
                r = c2
        return func(l)

    else:  # 極大値
        for i in range(loop_count):
            c1 = (l * 2 + r) / 3  # lr間を3等分した内分点
            c2 = (l + r * 2) / 3  # lr間を3等分した内分点
            if func(c1) < func(c2):
                l = c1  # 小さい方を(中央に)近づける
            else:
                r = c2
        return func(l)


def main():
    from collections import namedtuple
    from math import hypot
    import sys
    input = sys.stdin.readline

    MX = 1000

    Pt = namedtuple('Pt', 'x y')

    N = int(input())
    ps = [Pt(*map(int, input().split())) for _ in range(N)]

    def max_dist(x, y):
        return max(hypot(x - p.x, y - p.y) for p in ps)

    def f(x):
        return ternary_search(
            l=0,
            r=MX + 1,
            func=lambda y: max_dist(x, y)
        )  # y[l,r),func=x,yを固定

    res = ternary_search(
        l=0,
        r=MX + 1,
        func=f
    )  # x[l,r),func=xを固定

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m;
int p[MAXN];
int fa[MAXN];
int getFa(int x) {
    return fa[x] == x ? x : fa[x] = getFa(fa[x]);
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &p[i]);
    }
    for(int i = 1; i <= n; i++)
    {
        fa[i] = i;
    }
    for(int i = 1; i <= m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        fa[getFa(x)] = getFa(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(getFa(p[i]) == getFa(i)) ans++;
    }
    printf("%d\n", ans);
}


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

typedef long long ll;

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

int n,q;

int main(){
  scanf("%d%d",&n,&q);
  int head = 0;
  while(q--){
    int typ, k;
    scanf("%d%d",&typ,&k);
    k--;
    if(typ==0){
      printf("%d\n",(head+k)%n + 1);
    }else{
      head = (head+k+1)%n;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

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

    if(c <= a + b)  return 0 * puts("No");

    puts(4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
}


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

bool ishamming[1000001];
bool isHamming(int i) {
  int x = i;
  if(x % 5 == 0) x /= 5;
  if(x % 3 == 0) x /= 3;
  if(x % 2 == 0) x /= 2;
  if(ishamming[x]) {
    ishamming[i] = true;
    return true;
  } else {
    ishamming[i] = false;
    return false;
  }
}

main() {
  int hammingNum[1000001];
  hammingNum[1] = 1;
  ishamming[1] = true;
  for(int i = 2; i <= 1000000; i++) {
    hammingNum[i] = hammingNum[i-1];
    if(isHamming(i)) hammingNum[i]++;
    if(i <= 20) {
    }
  }
  while(1) {
    int m, n;
    cin >> m;
    if(m == 0) break;
    cin >> n;
    cout << hammingNum[n] - hammingNum[m-1] << endl;
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.TreeMap;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int k = getInt();
		int q = getInt();
		int p[] = new int[n];

		for ( int i = 0 ; i < q ; i++ ) {
			p[getInt()-1]++;
		}
		for ( int i = 0 ; i < n ; i++ ) {
			System.out.println( p[i]>q-k ? "Yes" : "No" );
		}
	}
}


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

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

    int a, b, c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]){
        if(s[2]==s[3] && s[0]!=s[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if(s[0]==s[2] && s[1]==s[3]) cout << "Yes" << endl;
        else if(s[0]==s[3] && s[1]==s[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    vector<lint> v(3);
    REP(i, 3) { cin >> v[i];}
    lint ans=0;
    sort(ALL(v));
    ans = v[0] * v[1];

    REP(i,3)
    if(v[i]%2==0)
        ans = 0;
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	N := readInt()
	X := readInt()
	Y := readInt()

	t := make([]int, N)

	for i := 1; i < N; i++ {
		for j := i + 1; j < N+1; j++ {
			t[min(j-i, abs(X-i)+1+abs(Y-j))]++
		}
	}

	for i := 1; i < N; i++ {
		fmt.Println(t[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function main(){
    let n = parseInt(readline());
    let a  = new Array(n);
    let b = new Array(n);
    let c = new Array(n);

    for(let i = 0; i < n; i++){
        let [x,y,z] = ti(readline().split(' '));
        a[i] = x;
        b[i] = y;
        c[i] = z;
    }

    let dpA = new Array(n);
    let dpB = new Array(n);
    let dpC = new Array(n);

    for(let i = 0; i < n; i++){
        if(i === 0){
            dpA[i] = a[i];
            dpB[i] = b[i];
            dpC[i] = c[i];
        }else{
            dpA[i] = Math.max(dpB[i-1] + a[i], dpC[i-1] + a[i]);
            dpB[i] = Math.max(dpA[i-1] + b[i], dpC[i-1] + b[i]);
            dpC[i] = Math.max(dpB[i-1] + c[i], dpA[i-1] + c[i]);
        }
    }

    console.log(Math.max(dpA[n-1], dpB[n-1], dpC[n-1]));
}

Measured memory_bytes: 60064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define min_ll(a, b) a<b? a :b

int main() {

  ll N;
  ll t = 0;
  vector<ll> a(5);
  cin >> N;
  REP(i, 5) cin >> a[i];
  vector<ll> a_tmp = {N, 0LL, 0LL, 0LL, 0LL, 0LL};
  //vector<ll> a_tmp1 = a_tmp;
  vector<ll> trans(5);
/*
  while (a_tmp[5] != N){
    t++;
    REP(i, 5) {
      if (a_tmp[i] - a[i] > 0) trans[i] = a[i];
      else trans[i] = a_tmp[i];
    }
    REP(i, 6) {
      if (i == 0) a_tmp[i] -= trans[i];
      else if (i == 5) a_tmp[i] += trans[i-1];
      else a_tmp[i] += trans[i-1] - trans[i];
    }
    //cout << t << ":";
    //REP(i, 6) cout << a_tmp[i];
    //cout << endl;
  }
*/
  ll min_t = *min_element(a.begin(), a.end());
  ll ans;
  if (N % min_t == 0){
    ans = N / min_t + 4;
  } else {
    ans = N / min_t + 4 + 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll b[n];
  ll c[n-1];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  for(ll i=0;i<n;i++)
    cin>>b[i];
  for(ll i=0;i<n-1;i++)
    cin>>c[i];
  ll satisfaction=0;
  ll last=-1;
  for(ll i=0;i<n;i++)
  {
    ll dish=a[i];
    satisfaction+=b[dish-1];
    if(last!=-1&&last==dish-2)
      satisfaction+=c[last];
    last=dish-1;
  }
  cout<<satisfaction<<endl;
}

Measured memory_bytes: 256
#include <iostream>
int main()
{
	int64_t N, M, r;
	std::cin >> N >> M;
	bool n = N == 1;
	bool m = M == 1;

	if (n && m) r = 1;
	else if (n) r = M - 2;
	else if (m) r = N - 2;
	else        r = (M - 2) * (N - 2);

	std::cout << r << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main() {
	int n;
	int p[11];
	int pmax;
	int total = 0;

	cin >> n;

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

	pmax = p[0];
	for (int i = 0; i < n; i++) {
		if (p[i]>pmax) {
			pmax = p[i];
		}

		total += p[i];
	}

	total -= pmax / 2;

	cout << total;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split())) + [0]
money = 1000
stock = 0
prev = 201

for i,price in enumerate(A):
    if price > prev and money >= prev:
        stock += money // prev
        money -= stock * prev

    elif price < prev and stock:
        money += prev * stock
        stock = 0
    prev = price

print(money)



Measured memory_bytes: 9180
#include <iostream>
#include <vector>
using namespace std;
 
long mod=1000000007;
long a[100001];
long sumlist[100001];
int ncalc(int N){
    long tmp = 1;
    while(1){
        tmp *= (long)N;
        N--;
        tmp %= mod;
        if (N == 0) break;
    }
    return tmp;
}

//aのp乗を求めるアルゴリズム
//p=62>31>30>15>14>7>6>3>2>1>0
//計算量はO(logp)になる。
long long modpow(long a, int p){
    if (p == 0) return 1;
    if (p%2 == 0){
        //p even
        int halfP = p/2;
        long long half = modpow(a, halfP);
        //a^(p/2)をhalfとしてhalf*halfを計算
        return half * half % mod;
    }
    else {
        return a * modpow(a, p-1) % mod; 
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int tmp = 0;
        cin >> tmp;
        a[i] = tmp;
    }
    
    int nex = ncalc(N);
    //printf("%d\n",nex);
    int sum = 0;
    for(int i = 2; i <= N; i++)
    {
        //nexが1000000007を超えたとき、nex / iの計算が想定通りにならない。
        int tmp = nex * modpow((long)i, mod - 2) % mod;
        sum += tmp;
        sum %= mod;
        sumlist[i-2] = sum;
    }
    //sumlist[0] = 24/2  24/3 24/4
    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long anum = 0;
 
        //ai - ai
        anum += nex;
                //printf("aunm %d %d\n",anum, a[i]);
        //ai - ai+1 - an
        if(i != N - 1){  
            anum += sumlist[N - i - 2];
            anum %= mod;
        }
              //printf("aunm %d %d %d\n",anum, a[i], sumlist[N-i-1]);
        //ai - ai-1 a0
        if(i != 0){
            anum += sumlist[i - 1];
            anum %= mod;
        }
        //printf("aunm %d %d\n",anum, a[i]);
        ans += a[i] * anum;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const double pi = 3.1415926;
int main() {
    ll a;
    while(cin >> a) {
        ll ans = a + 1 ;
        for(ll i=1; i*i<=a; i++) {
            if(a%i==0) {
                ans=min(ans,i+a/i);
            }
        }
        cout <<ans-2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
Q={"A":1,"B":0,"C":0}
while True:
    try:
        N=list(input().split(","))
        Q[N[0]],Q[N[1]]=Q[N[1]],Q[N[0]]
    except:
        for v,m in Q.items():
            if m==1:
                print(v)
        break


Measured memory_bytes: 5560
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <string>

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); ++i)

int main()
{
    cin.tie(nullptr);

    int K;
    std::string S;
    std::cin >> K;
    std::cin >> S;
    if (S.length() > K)
    {
        std::cout << S.substr(0, K) << "..." << std::endl;
    }
    else
    {
        std::cout << S << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int find(int i,vector<int>& uf){
  if(uf[i]<0) return i;
  return uf[i]=find(uf[i],uf);
}

void union_(int a,int b,vector<int>& uf){
  a=find(a,uf); b=find(b,uf);
  if(a==b) return;
  if(uf[a]>uf[b]) swap(a,b);
  uf[a]+=uf[b];
  uf[b]=a;
}

int main(){
  int n,m; cin >>n >>m;
  vector<int> v(n);
  for(auto& x: v) {cin >>x; x--;}
  vector<vector<int>> adj(n);
  vector<int> uf(n,-1);
  rep(i,m){
    int a,b; cin >>a >>b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    union_(a,b,uf);
  }
  int cnt=0;
  rep(i,n) cnt+=(find(i,uf)==find(v[i],uf));
  print(cnt);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x,y;
	cin>>x>>y;
	for(ll i=0;i<=x;i++){
		ll cnt=i*2+(x-i)*4;
		if(cnt==y){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	// your code goes here
	return 0;
}

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

    int main() {
        long long  a  , b;
        long long n;
       cin >> n >> a >> b;
       if(a % 2 == 0 && b % 2 == 0)
       {
           cout << (b-a)/2;
       }
       else if(a % 2 != 0 && b % 2 != 0)
       {
           cout << (b-a)/2;
       }
        else
        {
            cout << min(a-1 , n - b) + 1 + (b-a-1)/2;
        }

        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;



// xの桁数を返す関数
int digit_max(ll x){
    int dig = 0;
    while(x > 0){
        dig++;
        x /= 10;
    }
    return dig;
}


template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

int main(){
    ll n; cin >> n;
    auto f = [&](ll x, ll y) -> ll{
        return max(digit_max(x), digit_max(y));
    };
    ll ans = INF;
    rep(i,sqrt(n)+1){
        if(i <= 0)continue;
        if(n % i == 0)chmin(ans, f(i,n/i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

S = input()

evenNumber = ["D", "R", "U"]
oddNumber = ["L", "U", "D"]

for i, x in enumerate(S):
    if i%2 == 0:
        if x in evenNumber:
            continue

        else:
            print("No")
            sys.exit()

    else:
        if i%2 == 1:
            if x in oddNumber:
                continue

            else:
                print("No")
                sys.exit()

print("Yes")


Measured memory_bytes: 38384
import java.util.*;
public class Main{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		int min[]=new int[n];
		min[0]=0;
		min[1]=(int)Math.abs(h[1]-h[0]);
		for(int i=2;i<n;i++)
		{
			int h1=(int)Math.abs(h[i]-h[i-1])+min[i-1];
			int h2=(int)Math.abs(h[i]-h[i-2])+min[i-2];
			min[i]=h1<h2?h1:h2;
		}
		System.out.println(min[n-1]);
	}

}

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

int main() {
  int N; cin >> N;
  int ac = 0, wa = 0, tle = 0, re = 0;
  REP(i, N) {
    string S; cin >> S;
    if (S == "AC") ++ac;
    if (S == "WA") ++wa;
    if (S == "TLE") ++tle;
    if (S == "RE") ++re;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))
A.sort()

s = 0
point = -1

for i in range(N-1):
    s += A[i]
    if s*2 >= A[i+1]:
        pass
    else:
        point = i

ans = N - point - 1
print(ans)

Measured memory_bytes: 14224
import Data.IORef
import Control.Monad

main :: IO()
main = do
  [n, k] <- map read . words <$> getLine :: IO([Int])
  hs <- map read . words <$> getLine :: IO([Int])
  putStrLn $ show $ solve k hs

solve :: Int -> [Int] -> Int
solve k hs = foldr f 0 hs
  where
    f x acc = if x >= k then acc + 1 else acc


Measured memory_bytes: 18812
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false
#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N,M,X,Y ;
char str[26];
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N >> M >> X >> Y ;
  int x[N];
  int y[M];
  bool o1 = true;
  bool o2 = true;
  REP(i,N){
    cin >> x[i];
  }
  int j,k;
  REP(i,M){
    cin >> y[i];
  }
  for(int z = X+1; z <= Y ;z++){
    REP( j,N){
      if(x[j] >= z){
        o1 =false;
      }
    }
    REP(k,M){
      if(y[k] < z){
        o2 = false;
      }
    }
    if(o1 && o2){
      cout << "No War" << endl;
      return 0 ;
    }else
    {
      o1 = true ;
      o2 = true ;
    }
  }
  printf("War\n");
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


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

int main()
{
	int b,r,g,c,s,t;
	while(cin >> b >> r >> g >> c >> s >> t, b||r||g||c||s||t)
	{
		int ret=100;
		ret += 15*(b+r) + 15*(5*b+3*r) - 2*(5*b+3*r);
		ret += 7*g + 2*c;
		ret -= 3*(t-s-5*b-3*r);

		cout << ret << endl;

	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b;
    cin >> a >> b;

    if(a >= b) {
        rep(i, a) {
            cout << b;
        }
    }
    else {
        rep(i, b) {
            cout << a;
        }
    }
    
    cout << endl;
    re0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

int main()
{
    ll N;
    while (cin >> N, N) {
        vector<pii> v;
        ll m, a, b;
        for (int i = 0; i < N; i++) {
            cin >> m >> a >> b;
            v.push_back(pii(a, +m));
            v.push_back(pii(b, -m));
        }
        sort(v.begin(), v.end());
        ll sum = 0;
        bool ok = 1;
        for (int i = 0; i < (int)v.size(); i++) {
            sum += v[i].second;
            if (sum > 150) {
                ok = 0;
                break;
            }
        }
        cout << (ok ? "OK" : "NG") << endl;
    }
    return 0;
}

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

Measured memory_bytes: 2940
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>

#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define vector std::vector
#define max(a, b) std::max(a, b)
#define min(a, b) std::min(a, b)
#define swap(a, b) std::swap(a, b)
#define sort(...) std::sort(__VA_ARGS__)
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)

#if __cplusplus >= 201103L
using ll = long long;
using ull = unsigned long long;
#else
typedef long long ll;
typedef unsigned long long ull;
#endif

#define _GIO 1

#if _GIO
struct _gio {
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

  char rcha;
  bool rneg;
#if _GG
#else
  char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

  _gio() {
    rcha = ' ';
#if _GG
#else
    r1 = r2 = ruf, w1 = wuf;
#endif
  }

  ~_gio() {
#if _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout);
#endif
  }

  inline void flush() {
#ifdef _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
  }

  inline int readc() {
#if _GG
    return getchar();
#else
    return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
                ? -1
                : *r1++);
#endif
  }

  template <typename T, typename... Args>
  void read(T &x, Args &... args) {
    read(x), read(args...);
  }

  inline void read() {}

  inline void read(char *s) {
    while (blank(rcha)) rcha = readc();
    while (!blank(rcha) && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  inline void readl(char *s) {
    while (blank(rcha)) rcha = readc();
    while (rcha != '\n' && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  template <typename T>
  inline void read(T &x) {
    x = rcha = rneg = 0;
    while (!isdigit(rcha) && rcha != '-') rcha = readc();
    rcha == '-' && (rneg = true, rcha = readc());
    while (isdigit(rcha)) x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
    rneg && (x = -x);
  }

  inline void writec(char c) {
#if _GG
    putchar(c);
#else
    (w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
    *w1++ = c;
#endif
  }

  template <typename T, typename... Args>
  void write(const T &x, const Args &... args) {
    write(x), write(args...);
  }

  template <typename T, typename... Args>
  void writel(const T &x, const Args &... args) {
    write(x), write(args...);
    writec('\n');
  }

  inline void write() {}

  inline void write(const char &c) { writec(c); }

  template <typename T>
  void write(T x) {
    if (x < 0) {
      writec('-');
      write(-ll(x));
      return;
    }
    if (x > 9) write(x / 10);
    writec(x % 10 ^ 48);
  }

  inline void write(const char *s) {
    while (*s) writec(*s++);
  }
#undef BFSZ
} io;
#endif

const int INF = 0x3f3f3f3f;
const int MAXN =
#ifdef GONGKUNPENG
    15
#else
    1000005
#endif
    ;

char in[5];

int main() {
  io.read(in);
  tfor(i, 3) if (in[i] == '7') {
    io.write("Yes\n");
    return 0;
  }
  io.write("No\n");
  return 0;
}

Measured memory_bytes: 3060
#include<stdio.h>
int n, a[110],b,max,m;
int main(){
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&b);
        if(max<b) max=b;
        a[b]++;
    }
    for(i=max;i>(max+1)/2;i--){
        if(a[i]<2){
            printf("Impossible");
            return 0;
        }
        n=n-a[i];
    }
    //printf("%d %d",n, (max+1)/2);
    if(max%2==1&&a[(max+1)/2]==2&&n==2){
        printf("Possible");
        return 0;
    }else if(max%2==0&&a[(max+1)/2]==1&&n==1){
        printf("Possible");
        return 0;
    }
    printf("Impossible");
    return 0;
}

Measured memory_bytes: 128
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    n = I()
    s = S()

    cnt = 0
    right = 0
    
    for char in s:
        if char == "(":
            cnt += 1
        else:
            if cnt == 0:
                right += 1
            else:
                cnt -= 1

    ans = "("*right + s + ")"*cnt

    print(ans) 
    

        


main()


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

double r;

int main(){
    cin >> r;
    double ans = 2.0*r*M_PI;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using i64 = long long;

i64 dp[13][10][2][2];
int digits[13];

i64 rec(int i, int j, bool f, bool s) {
    if (i == 0) return s ? 1 : 0;
    if (dp[i][j][f][s] >= 0) return dp[i][j][f][s];
    i64 ret = 0;
    if (!s || j <= 1) ret += rec(i - 1, 0, f || 0 < digits[i - 1], s);
    for (int nd = 1; nd < 10; nd++) {
        if (s && abs(nd - j) > 1) continue;
        if (!f && nd > digits[i - 1]) continue;
        ret += rec(i - 1, nd, f || nd < digits[i - 1], true);
    }
    return dp[i][j][f][s] = ret;
}

int main() {
    int k;
    std::cin >> k;

    i64 l = 0, r = 100000000000;
    while (r - l > 1) {
        for (auto &v : dp) for (auto &w : v) w[0][0] = w[0][1] = w[1][0] = w[1][1] = -1;
        const i64 mid = (l + r) / 2;
        {
            i64 j = mid;
            for (int i = 0; i < 13; i++) {
                digits[i] = j % 10;
                j /= 10;
            }
        }

        if (rec(12, 0, false, false) < k) l = mid;
        else r = mid;
    }

    std::cout << r << std::endl;

    return 0;
}


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

using namespace std;

const long long MAX = 1e10 + 7;

int main(){
  int n;
  cin >> n;
  vector<pair<long long, long long>> lr(n);
  for(int i = 0; i < n; i++){
    long long a, b;
    cin >> a >> b;
    lr[i] = make_pair(a, b);
  }
  sort(lr.begin(), lr.end());
  
  vector<long long> r_min1(n, MAX);
  vector<long long> r_min2(n, MAX);
  
  r_min1[0] = lr[0].second;
  for(int i = 1; i < n; i++){
    r_min1[i] = min(lr[i].second, r_min1[i - 1]);
  }
  
  r_min2[n - 1] = lr[n - 1].second;
  for(int i = n - 2; i >= 0; i--){
    r_min2[i] = min(lr[i].second, r_min2[i + 1]);
  }
  
  long long fun = 0ll;
  for(int i = 0; i < n - 1; i++){
    long long score1 = max(r_min2[i + 1] - lr[n - 1].first + 1, 0ll)
      + max(r_min1[i] - lr[i].first + 1, 0ll);
    long long score2 = max(r_min1[n - 1] - lr[n - 1].first + 1, 0ll)
      + max(lr[i].second - lr[i].first + 1, 0ll);
    fun = max(fun, max(score1, score2));
  }
  
  cout << fun << endl;
}

Measured memory_bytes: 3328
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

std::string a,b;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a >> b; a += b;
	int32_t N = std::stoi(a);

	for (int32_t i = 0; i < N; i++)
	{
		if (i*i == N) {
			out << "Yes\n"; return 0;
		}
	}
	out << "No" << endl;

	return 0;
}
#endif


Measured memory_bytes: 256