akhauriyash/Code-Regression huggingface dataset:
/* 
  ╔╗         ╔╗              ╔═══╗                                  
  ║║        ╔╝╚╗             ║╔═╗║                                  
  ║║╔╗╔╗╔══╗╚╗╔╝    ╔══╗     ║╚═╝║╔═╗╔══╗╔══╗╔═╗╔══╗ ╔╗╔╗╔╗╔╗╔══╗╔═╗
╔╗║║║║║║║══╣ ║║     ╚ ╗║     ║╔══╝║╔╝║╔╗║║╔╗║║╔╝╚ ╗║ ║╚╝║║╚╝║║╔╗║║╔╝
║╚╝║║╚╝║╠══║ ║╚╗    ║╚╝╚╗    ║║   ║║ ║╚╝║║╚╝║║║ ║╚╝╚╗║║║║║║║║║║═╣║║ 
╚══╝╚══╝╚══╝ ╚═╝    ╚═══╝    ╚╝   ╚╝ ╚══╝╚═╗║╚╝ ╚═══╝╚╩╩╝╚╩╩╝╚══╝╚╝ 
                                         ╔═╝║                       
                                         ╚══╝                       */


//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#include<Personal/debug.h>
#else
#define debug(x...)
#endif

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)
#define repr(i,start,end) for(int i=(int)start;i>(int)end;i--)
#define all(x) (x).begin(), (x).end()

//Constants
const int mod = 1e9+7;

//Some useful functions
ll binpow(ll num,ll pow);
inline int mul(int a,int b) {return (a*1ll*b)%mod;}
inline int add(int a,int b) {return (a+0ll+b)%mod;}
inline int sub(int a,int b) {return ((a+0ll-b)%mod+mod)%mod; }
/*------------------------------------------------------Code Starts------------------------------------------------------*/
inline void solve()
{
	int n;
	string s;
	cin>>n>>s;
	vi prfw(n+1),prfr(n+1);
	rep(i,0,n)
	{
		prfw[i+1]=prfw[i]+((s[i]=='W')?1:0);
		prfr[i+1]=prfr[i]+((s[i]=='R')?1:0);
	}
	debug(prfr,prfw);
	int ans=1e9;
	rep(i,0,n+1)
	{
		int c=prfw[i];
		int r=prfr[n]-prfr[i];
		ans=min(ans,c+r-min(c,r));
		debug(ans,i,c,r);
	}
	cout<<ans<<'\n';
}

int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}
/*------------------------------------------------------Code ends------------------------------------------------------*/
ll binpow(ll num,ll pow)
{
	if(pow==0)
		return 1;
	ll val=binpow(num,pow/2);
	val*=val;
	if(pow&1) val*=num;
	return val;
}



Measured memory_bytes: 5252
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut buf_iter = buf.split_whitespace();
    let mut number = buf_iter.next().unwrap().to_string();
    number.push_str(buf_iter.next().unwrap());
    let number: f64 = number.parse().unwrap();

    match number.sqrt().floor().powi(2) == number{
        true => println!("Yes"),
        false => println!("No"),
    }
}

Measured memory_bytes: 4352
import itertools
import math

N = int(input())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

def des(i, j):
    return math.sqrt( (X[i] - X[j])**2.0 + (Y[i] - Y[j])**2.0 )

s = 0
for c in itertools.combinations(range(N), 2):
    s += des(c[0], c[1])

print(s*2 / N)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
 

public class Main{
          
    static int nowLoca=1;
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
               String[] spl=line.split(" ");
               Stack<Double> stk = new Stack<Double>();
               for(int i=0; i<spl.length;i++){
                   String str1=spl[i];
                   if(isNum(str1)){
                       stk.push(Double.valueOf(str1));
                   }else{
                       double n2=stk.pop(); double n1 = stk.pop(); double nRes=-1;
                       
                           if(str1.equals("+")){nRes=n1+n2;}
                           if(str1.equals("-"))nRes=n1-n2;
                           if(str1.equals("*"))nRes=n1*n2;
                           if(str1.equals("/"))nRes=n1/n2;
                       
                       stk.push(nRes);
                       
                   }
                   
               }System.out.println(stk.pop());
               
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
     
    static boolean isNum(String n){
        try{ Double.parseDouble(n);return true;}
        catch(NumberFormatException e){return false;}
    }
     
}

Measured memory_bytes: 15176
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    string s;
    cin>>s;
    int cnt = 0;
    vector<int> v;
    for(int i=0;i<s.length();i++){
      if(s[i]=='R'){
          cnt++;
       if(i==s.length()-1){
          v.push_back(cnt);
          break;
      }
      }
      else{
          v.push_back(cnt);
          cnt = 0;
      }


    }

    cout<<*max_element(v.begin(),v.end())<<endl;
}


Measured memory_bytes: 3628
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second

int main(){
    int p,q;
    while(cin>>p>>q){
        p*=10;
        map<int,int>M;
        vector<int>V;
        int start=-1;
        while(true){
            if(M[p]!=0){
                start=M[p];
                break;
            }
            V.PB(p/q);
            M[p]=V.size();
            if(p%q==0)break;
            p%=q;
            p*=10;
        }
        REP(i,V.size())cout<<V[i];cout<<endl;
        if(start==-1)continue;
        start--;
        REP(i,start)cout<<" ";
        FOR(i,start,V.size())cout<<"^";
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1224
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    String S = sc.next(); 
    String T = sc.next();
    String[] Sa = S.split("");
    String[] Ta = T.split("");
    String ans = "";
    for (int i=0;i<N;i++){
      ans = ans + Sa[i] + Ta[i];
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

int main(){
	ll X;
	cin>>X;
	ll ans;
	ans=X/11*2;
	X%=11;
	if (X>6){
		ans+=2;
	}else if (X>0){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
int main(){
int i,n,s,M,m,S;
for(;scanf("%d",&n),n;printf("%d\n",(S-M-m)/(n-2)))for(i=S=M=0,m=1000;i<n;i++)scanf("%d",&s),M=M>s?M:s,m=m<s?m:s,S+=s;return 0;}

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

int main() {
  int w, n, a, b;
  char c;
  std::cin >> w >> n;
  int d[w + 1];
  for (int i = 0; i <= w; i++) {
    d[i] = i;
  }
  for (int i = 0; i < n; i++) {
    std::cin >> a >> c >> b;
    std::swap(d[a], d[b]);
  }
  for (int i = 1; i <= w; i++) {
    std::cout << d[i] << std::endl;
  }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int A, B, C; cin >> A >> B >> C;
  string result = ((A-C)*(C-B)>0) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
    int a,b;
    cin >> a >> b;
    if(a > b){
        rep(i,a){
            cout << b;
        }
        cout << endl;
    }else{
        rep(i,b){
            cout << a;
        }
        cout << endl;
    }
	return 0;
}

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

int main() {
    int a, b;
    char op;
    while(1) {
        cin >> a >> op >> b;
        if(op == '?') return 0;
        if(op == '+') cout << a+b << '\n';
        else if(op == '-') cout << a-b << '\n';
        else if(op == '*') cout << a*b << '\n';
        else cout << a/b << '\n';
    }
}



Measured memory_bytes: 3100
fun main(args:Array<String>) {
    val n:Int = readLine()!!.toInt()
    val(s,t) = readLine()!!.split(" ")
    var st:String = ""
    for (x in 0..n-1) {
        st = "${st}${s[x]}${t[x]}"
    }
    println(st)
}


Measured memory_bytes: 36008
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
typedef unsigned long long ul;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ul h;
    cin >> h;

    ul cnt(0);
    while (h>1)    
        h /=2, ++cnt;

    ++cnt;

    ll ans = -1*(1-pow(2,cnt));

    cout << ans << endl;

    return 0;
}


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

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for(int v2 = 0; v2 < n; v2++) {
        if(graph[v][v2] == false) continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}

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

    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < m; i++){
        graph[a[i]][b[i]] = false;
        graph[b[i]][a[i]] = false;

        for(int j = 0; j < n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for(int j = 0; j < n; j++) if(visited[j] == false) bridge = true;
        if(bridge) ans++;

        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

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


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);

$tarou  = 0;
$hanako = 0;

for ($i = 0; $i < $n; $i++) {
    $line  = trim(fgets(STDIN));
    $cards = preg_split('/\s+/', $line);

    if (strcmp($cards[0], $cards[1]) > 0) {
        $tarou += 3;
    }
    else if (strcmp($cards[0], $cards[1]) == 0) {
        $tarou  += 1;
        $hanako += 1;
    }
    else {
        $hanako += 3;
    }
}

echo "$tarou $hanako\n";

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

#define endl '\n'
#define ll long long
#define int long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

#define db  long double;
#define pll pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	cin >> n;
	cout_p((44 * n) / 7.0, 6);
}


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

vector<Int> zalgorithm(string s){
  Int n=s.size();
  vector<Int> a(n,0);
  a[0]=n;
  Int i=1,j=0;
  while(i<n){
    while(i+j<n&&s[j]==s[i+j]) j++;
    a[i]=j;
    if(j==0){
      i++;
      continue;
    }
    Int k=1;
    while(i+k<n&&k+a[k]<j) a[i+k]=a[k],k++;
    i+=k;
    j-=k;
  }
  return a;
}

//INSERT ABOVE HERE
using vint = vector<Int>;
void print(const vint &v){
  for(Int i=0;i<(Int)v.size();i++){
    if(i) cout<<" ";
    cout<<v[i];
  }
  cout<<endl;
}

vint add(const vint &a,const vint &b){
  vint c(26,0);
  for(Int i=0;i<26;i++) c[i]=a[i]+b[i];
  return c;
}
vint sub(const vint &a,const vint &b){
  vint c(26,0);
  for(Int i=0;i<26;i++) c[i]=a[i]-b[i];
  return c;
}

signed main(){
  string s;
  cin>>s;
  Int l,r;
  cin>>l>>r;
  l--;
  {
    string t(s);
    t.erase(unique(t.begin(),t.end()),t.end());
    if(t.size()==1u){
      vint ans(26,0);
      ans[t[0]-'a']=r-l;
      print(ans);
      return 0;
    }
  }
  
  Int n=s.size(),k=n/2+1;
  vector<Int> z=zalgorithm(s);
  while(k<n&&k+z[k]<n) k++;
  
  vector<Int> x;
  x.emplace_back(n);
  x.emplace_back(k*2);
  for(Int i=0;x.back()<=r;i++)
    x.emplace_back(Int(x[i]+x[i+1]));

  vector<vint> a(n+1,vint(26,0));
  for(Int i=0;i<n;i++)
    for(Int j=0;j<26;j++)
      a[i+1][j]=a[i][j]+(s[i]=='a'+j);
  
  using P = pair<Int, Int>;
  map<P, vint> dp;
  function<vint(Int, Int)> dfs=
    [&](Int l,Int r){
      if(dp.count(P(l,r))) return dp[P(l,r)];
      vint &res=dp[P(l,r)];
      if(r<=n) return res=sub(a[r],a[l]);
      Int p=0;
      while(r>x[p]) p++;
      Int y=x[p]/2;
      if(y<=l) return res=dfs(l-y,r-y);
      return res=add(dfs(l,y),dfs(0,r-y));
    };
  
  print(dfs(l,r));
  return 0;
}


Measured memory_bytes: 50496
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  double r;
  int i,j;
  while(cin>>r,r){
    for(i=1;i<=10000000;i++){
      j=(int)( ((double)i)*M_PI );
      if( fabs( ((double)j/i)-M_PI ) <= r )break;
      j++;
      if( fabs( ((double)j/i)-M_PI ) <= r )break;
    }
    cout<<j<<"/"<<i<<endl;
  }
}

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

typedef long long ll;
// #define int ll
#define pb push_back
const int INF = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);





	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true){
		c-=b;
		if (c<=0){
			cout<<"Yes";
			break;
		}
		a -= d;
		if (a<=0){
			cout<<"No";
			break;
		}
	}
	

	return 0;
}

Measured memory_bytes: 3652
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

struct edge{
    int a, b;
    ll cap, flow;
    edge(){}
    edge(int a, int b, ll cap, ll flow){
        this->a = a;
        this->b = b;
        this->cap = cap;
        this->flow = flow;
    }
};
 
 
int s, t;
ll dist[205], ptr[205];
vector<edge> edgeList;
vector<int> adj[205];
 
 
void add_edge(int a, int b, ll cap){
    adj[a].pb(edgeList.size());
    edgeList.pb(edge(a, b, cap, 0));
    adj[b].pb(edgeList.size());
    edgeList.pb(edge(b, a, 0, 0));
// cout<<"added edge "<<a<<" "<<b<<" "<<cap<<endl;
}
 
 
bool bfs(){
 
    memset(dist, -1, sizeof(dist));
    queue<int> qq;
    dist[s] = 0;
    qq.push(s);
    while(!qq.empty()){
 
        int v = qq.front();
        qq.pop();
        for(int i=0;i<(int)adj[v].size();i++){
           
            int id = adj[v][i];
            int to = v ^ edgeList[id].a ^ edgeList[id].b;
 
            if(dist[to] == -1 && edgeList[id].flow < edgeList[id].cap){
                dist[to] = dist[v]+1;
                qq.push(to);
            }
        }
    }
    return (dist[t] != -1);
}
 
 
 
ll dfs(int v, ll flow){
 
    if(!flow)   return 0;
    if(v == t)  return flow;
 
    for(;ptr[v]<(int)adj[v].size();ptr[v]++){
 
        int id = adj[v][ptr[v]];
        int to = v ^ edgeList[id].a ^ edgeList[id].b;
        if(dist[to] != dist[v]+1)   continue;
 
        ll pushed = dfs(to, min(flow, 1LL*edgeList[id].cap-edgeList[id].flow));
        if(pushed > 0){
            edgeList[id].flow += pushed;
            edgeList[1^id].flow -= pushed;
            return pushed;
        }
    }
    return 0;
}

ll dinitz(){
    ll ans = 0;
    while(1){
        if(!bfs())  break;
        memset(ptr, 0, sizeof(ptr));
        while(ll pushed = dfs(s, (ll)1e12))
            ans += pushed;
    }
    return ans;
}


const int N = 202;
int n, arr[N];


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

    cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
    	cin>>arr[i];
    	if(arr[i] <= 0){
    	}
    	else{
    		ans += arr[i];
    	}
    }

    s = 0, t = n+1;
    for(int i=1;i<=n;i++){
    	if(arr[i] <= 0){
    		add_edge(s, i, -arr[i]);
	    	for(int j=2*i;j<=n;j+=i)
	    		add_edge(i, j, (ll)1e12);
	    }	
    	else	add_edge(i, t, arr[i]);
    }

// cout<<ans<<endl;

    ans -= dinitz();
    cout<<ans;
    return 0;
}











Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D; ll C;
//***********//
int main() {
	cin >> N >> C;
	ll z = 0;
	vpll F(N);
	for (i = 0; i < N; i++) {
		cin >> F[i].first >> F[i].second;
	}
	//右回りonly
	vl R(N);
	R[0]= F[0].second - F[0].first;
	for (i = 1; i < N; i++) {
		R[i] = R[i-1] + F[i].second - (F[i].first-F[i-1].first);
	}
	vl L(N);
	L[N-1] = F[N-1].second - (C-F[N-1].first);
	for (i = N-2; i >=0; i--) {
		L[i] = L[i + 1] + F[i].second - (F[i+1].first - F[i].first);
	}
	//往復左回りmax
	vl Ld(N);
	Ld[N-1]=max(z,L[N - 1] - (C - F[N - 1].first));
	for (i = N-2; i >=0; i--) {
		Ld[i] = max(Ld[i + 1], L[i] - (C - F[i].first));
	}
	vl Rd(N);
	Rd[0] = max(z,R[0] - F[0].first);
	for (i = 1; i < N; i++) {
		Rd[i] = max(Rd[i - 1], R[i] - F[i].first);
		//cout << Rd[i] << endl;
	}
	for (i = 0; i < N; i++) {
		if(i==N-1) ans= max(ans, R[i]);
		else {
			ans = max(ans, R[i] + Ld[i + 1]);
			//cout << R[i] << " " << Ld[i + 1] << endl;
		}
	}
	for (i = 0; i < N; i++) {
		if (i == 0) ans = max(ans, L[i]);
		else ans = max(ans, L[i] + Rd[i-1]);
	}
	if (ans < 0) cout << 0;
	else cout << ans;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int N,M;
    cin >> N >> M;
    priority_queue<ll,vector<ll>,greater<ll> > que;
    REP(i,N){
        ll tmp;
        cin >> tmp;
        que.push(tmp);
    }
    

    // map<ll,ll> ms;

    // for(int i=0;i<M;i++){
    //     ll c,b;
    //     cin >> b >> c;
    //     ms[c]+= b;
    // }
    // vector<pll> CB; //C,Bの順番

    // for(auto tmpm:ms){
    //     CB.push_back(pll(tmpm.first,tmpm.second));
    // }
    priority_queue<pll,vector<pll>> cb;
    for(int i=0;i<M;i++){
        ll c,b;
        cin >> b >> c;
        cb.push(pll(c,b));
    }

    // sort(all(CB));
    // reverse(all(CB));

    // int prev_b = 0;
    // for(int i=0;i<CB.size();i++){

    //     // if(prev_b>CB[i].second)continue;
    //     // for(int j=prev_b;j<prev_b+CB[i].second;j++){
    //     //     if(j>=N||A[j]>=CB[i].first)break;
    //     //     A[j]=CB[i].first;
    //     // }
    //     int j;
    //     for(j=0;j<CB[i].second;j++){
    //         if(A[j]>=CB[i].first)break;
    //     }

    //     for(int k=j-1;k>=0;k--){
    //         A[j]=CB[i].first;
    //     }

    //     A[j]=CB[i].first;


    //     prev_b = CB[i].second;

    // }

    for(int i=0;i<M;i++){
        pll tmp_cb = cb.top();
        cb.pop();
        for(int j=0;j<tmp_cb.second;j++){
            ll tmp = que.top();
            que.pop();
            if(tmp>=tmp_cb.first){
                que.push(tmp);
                break;
            }
            tmp = tmp_cb.first;
            que.push(tmp);
        }
    }

    ll sum=0;
    while(!que.empty()){
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;

}

//貪欲法？



Measured memory_bytes: 3188
#include<stdio.h>
 
int main(void)
{
   int h, m, s;
   scanf("%d", &s);
   h = s / 3600;
   m = (s % 3600) / 60;
   s = s % 60;
   printf("%d:%d:%d\n", h, m, s);
   return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A, B, C;
	cin >> A >> B >> C;
	cout << min(A+B+1, C) + B << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];
  whole(sort, a, greater<ll>());
  vector<ll> d(n,a[n-1]); FOR(i,1,n) d[n-1-i] = d[n-i]+a[n-i-1];
  FOR(i,1,n) {
    if (a[i-1] > 2*d[i]) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi l(n+1), r(n);
    l[0] = 0;
    r[n-1] = 0;

    rep(i, n) {
        l[i+1] = max(l[i], a[i]);
        if (n-2-i < 0) continue;
        r[n-2-i] = max(r[n-1-i], a[n-1-i]);
    }

    rep(i, n) cout << max(l[i], r[i]) << endl;
    return 0;
}


Measured memory_bytes: 3968
/*https://atcoder.jp/contests/abc123/tasks/abc123_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int a[5];
	for (int i = 0; i < 5; i++)
		cin >> a[i];
	int count = 5, dish, total_t = 0;
	while (count--)
	{
		// count++;
		int min_time = 11, pos;
		for (int i = 0; i < 5; i++)
		{

			int time ;
			// if (a[i] != 0)

			if (a[i] % 10 == 0)
				time = a[i] % 10;
			else
				time = 10 - a[i] % 10;
			// cout << a[i] << " " << time << endl;

			if (min_time > time && a[i] > 0)
			{
				min_time = time;
				dish = a[i];
				pos = i;
			}
			// cout << min_time << " " << dish << endl;
			// cout << endl;
		}
		a[pos] = 0;
		// cout << min_time << " " << dish << endl;
		// cout << endl;
		total_t += dish;
		// cout << dish << " " << total_t << " ";

		if (total_t % 10 != 0 && count != 0)
			total_t += (10 - total_t % 10);
		// cout << total_t << endl;
	}
	cout << total_t;
}

Measured memory_bytes: 3616
H, W, h, w = map(int, input().split())

grid = [[0] * W for _ in range(H)]
inf = 10**9
for i in range(H):
    for j in range(W):
        if i%h == h-1 and j%w == w-1:
            grid[i][j] = -inf
        elif i%h == 0 and j%w == 0:
            grid[i][j] = inf-1

if sum([sum(line) for line in grid]) > 0:
    print('Yes')
    for i in range(H):
        print(*grid[i])
else:
    print('No')


Measured memory_bytes: 50268
import sys
S = input().strip()
keyence = "keyence"
n = len(keyence)

if keyence in S:
    k = S.find(keyence)
    if k == 0:
        print("YES")
        sys.exit()
    elif k + n == len(S):
        print("YES")
        sys.exit()

for i in range(n):
    if S[:i] == keyence[:i] and S[-(n-i):] == keyence[-(n-i):]:
        print("YES")
        sys.exit()

print("NO")

Measured memory_bytes: 3064
import heapq

INFTY = 100000000000000000000000000
heap = []
n = int(raw_input())
graph = {}
for i in range(n):
    entry = map(int, raw_input().split(' '))
    u = entry[0]
    k = entry[1]
    graph[u] = {}
    for j in range(k):
        v = entry[2+j*2]
        c = entry[2+j*2+1]
        graph[u][v] = c

d = {}
visited = {}
heap = []
for i in range(n):
    d[i] = INFTY
    visited[i] = False

s = 0
d[s] = 0
visited[s] = True
heapq.heappush(heap,(0,s))

while len(heap) > 0:
    mincost,minnode = heapq.heappop(heap)
    if mincost > d[minnode]: continue
    visited[minnode] = True
    for i in graph[minnode]:
        if not visited[i] and d[i] > d[minnode] + graph[minnode][i]:
            d[i] = d[minnode] + graph[minnode][i]
            heapq.heappush(heap, (d[i],i))

for i in range(n):
    print i,d[i]

Measured memory_bytes: 75188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const ll MAX_H=1000,MAX_W=1000;
ll H,W;
char a[MAX_H][MAX_W];
ll dp[MAX_H][MAX_W];

void solve(){
    dp[0][0]=1;dp[H-1][W-1]=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i!=0||j!=0){
                if(a[i][j]=='.'){
                    if(i==0){
                        if(a[i][j-1]=='.') dp[i][j]=dp[i][j-1];
                    }else if(j==0){
                        if(a[i-1][j]=='.') dp[i][j]=dp[i-1][j];
                    }else{
                        if(a[i-1][j]=='.'&&a[i][j-1]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                        else if(a[i-1][j]=='#') dp[i][j]=dp[i][j-1];
                        else if(a[i][j-1]=='#') dp[i][j]=dp[i-1][j];
                    }
                }
            }
        }
    }
    cout<<dp[H-1][W-1];
}

int main(){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cin>>a[i][j];
    }
    solve();
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
bool prime[1005];
void sieve()
{
	prime[0]=prime[1]=0;
	for(int i=2;i*i <=1005;i++)
	{
		if(!prime[i])continue;
		for(int j=i*i;j<=1005;j+=i)
		{
			prime[j]=0;
		}
	}
	
}
int freq[1008];
int main()
{	
	memset(prime, 1, sizeof prime);

	vector<int> p;
	for(int i=0;i<=1000;i++)
	{
		if(prime[i])
		p.push_back(i);
	}
    
	int n;ll ans=1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{ 
		int temp=i;
		
			for(int j=2;j*j<=(temp);j++)
			{
				
				while(temp%j == 0)
				{
					freq[j]++;temp=temp/j;
				};
                
			}
        if(temp>1)freq[temp]++;
        
		
	}
    for(int i=0;i<1000;i++)
    {
        ans=((ans%mod)*((freq[i]+1) %mod))% mod;
    }
	cout<<ans;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n, k; cin >> n >> k;
	VI h(n+2); h[0]=0; h[n+1]=0;
	REP(i,n) cin >> h[i+1];
	VVI dp(n+10,VI(n+10,INF));
	dp[0][0]=0;
	for(int i=1;i<=n+1;i++){
		for(int j=1;j<=i;j++){
			REP(l,k+1){
				if(l+j-1<=k){
					ll cost=dp[i-j][l];
					if(h[i]>h[i-j])
						cost+=h[i]-h[i-j];
					dp[i][l+j-1]=min(cost,dp[i][l+j-1]);
				}
			}
		}
	}
	ll ans=INF;
	REP(i,k+1)
		ans=min(ans,dp[n+1][i]);
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
int main()
{
    ll N,W;
    scanf("%lld%lld",&N,&W);
    vector<ll> dp(W+1);
    //dp[i] is the total value with exactly weight i
    REP(i,N){
        ll w,v;
        scanf("%lld%lld",&w,&v);
        for(int j=W-w;j>=0;j--){//it doesn't take same weights,> 0 will give wrong result 
            dp[j+w]=max(dp[j+w],dp[j]+v);
        }
    }
    ll res=0;
    for(int i=0;i<=W;i++){
        res = max(res,dp[i]);
    }
    printf("%lld\n",res);       
    return 0;
}

Measured memory_bytes: 1024
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  a=[int(i) for i in input().split()]
  c.append(a)
import numpy as np
c=np.array(c)
ans=float('inf')
for i in range(1,2**n):
  p=[0]*m
  cost=0
  for j in range(n):
    if(i>>j)&1==1:
      cost+=c[j][0]
      p+=c[j][1:]
    if min(p)>=x:
      ans=min(ans,cost)
       
if ans==float('inf'):
  ans=-1
print(ans)

Measured memory_bytes: 27216
S = input()
answer = [0]*len(S)
pre = S[0]
R_stack = 0
L_stack = 0
for i in range(len(S)-1):
    j = i+1
    tmp = S[j]
    
    if tmp == pre:
        if i %2 == 0:
            R_stack += 1
        else:
            L_stack += 1
    elif tmp == "L":
        R_point = i
        L_point = j
        if i %2 == 0:
            R_stack += 1
        else:
            L_stack += 1
        if i%2 == 0:
            answer[R_point] += R_stack
            answer[L_point] += L_stack
        else:
            answer[R_point] += L_stack
            answer[L_point] += R_stack
        R_stack = 0
        L_stack = 0
    elif tmp == "R":
        if i %2 == 0:
            R_stack += 1
        else:
            L_stack += 1
        if R_point%2 == 0:
            answer[R_point] += R_stack
            answer[L_point] += L_stack
        else:
            answer[R_point] += L_stack
            answer[L_point] += R_stack
        R_stack = 0
        L_stack = 0
    pre = tmp
if R_point%2 == 0:
    answer[R_point] += R_stack
    answer[L_point] += L_stack
else:
    answer[R_point] += L_stack
    answer[L_point] += R_stack
if j %2 == L_point%2:
    answer[L_point] += 1
else:
    answer[R_point] += 1
    
print(*answer)

Measured memory_bytes: 49084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    int h, w, k;
    int g = 1;
    char sq[300][300] = {};
    int ans[300][300] = {};


    cin >> h >> w >> k;

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

    for (int i = 0; i < h; i++) {
        int m = -1;
        for (int j = 0; j < w; j++) {
            if (sq[i][j] == '#') {
                m = j;
                break;
            }
        }

        if (m == -1) {
            for (int j = 0; j < w; j++) {
                sq[i][j] = '0';
            }
        } else {
            int ct = 0; 
            for (int j = 0; j < w; j++) {   
                if (sq[i][j] == '#') {
                    ct++;
                    if (ct > 1) g++;
                }
                ans[i][j] = g;
            }
            g++;      
        }
    }

    for (int i = 1; i < h; i++) {
        if (ans[i][0] == 0 && ans[i-1][0] != 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = ans [i-1][j];
            }
        }
    }

    for (int i = h - 2; i >= 0; i--) {
        if (ans[i][0] == 0 && ans[i+1][0] != 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = ans [i+1][j];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N, M, K;
int dp[4001][2001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M >> K;

  int s = 0;
  dp[0][0] = 1;
  int all = (N+M-1)/(K-1);
  // O((N+M)/K*K*M) = O((N+M)*M)
  rep(i, all+1) rep(j, M+1) rep(k, K) if (j+k <= M) add(dp[i+1][j+k], dp[i][j]);
  for (int m=M; m>=1; m-=K-1) {
    int all = (N+m-1)/(K-1);
    add(s, dp[all][m]);
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 31488
A,B,C,D,E,F = map(int,input().split())
possible_x = set()
possible_y = set()
for i in range(32):
    for j in range(32):
        value = i*100*A+j*100*B
        if value <= F:
            possible_x.add(value)
for i in range(3001//C+10):
    for j in range(3001//D+10):
        value = C*i+D*j
        if value <= F:
            possible_y.add(value)
max_density = 0
max_water = 0
max_sugar = 0
for x in possible_x:
    for y in possible_y:
        if x+y > F:
            pass
        elif E*x/100 < y:
            pass
        else:
            if x+y == 0:
                pass
            elif (100*y)/(x+y) >= max_density:
                max_density = (100*y)/(x+y)
                max_water = x
                max_sugar = y
print(max_water+max_sugar,max_sugar)


Measured memory_bytes: 41052
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

struct Node
{
    int key;
    Node *prev, *next;
};

Node *nil;

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node *listSearch(int key)
{
    Node *cur = nil->next;
    while (cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t)
{
    if (t == nil)
        return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst()
{
    deleteNode(nil->next);
}
void deleteLast()
{
    deleteNode(nil->prev);
}
void deleteKey(int key)
{
    deleteNode(listSearch(key));
}
void printList()
{
    Node *cur = nil->next;
    int isf = 0;
    while (1)
    {
        if (cur == nil)
            break;
        if (isf++ > 0)
            cout << " ";
        cout << cur->key;
        cur = cur->next;
    }
    cout << endl;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N;
    cin >> N;

    init();
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        if (s == "insert")
        {
            int x;
            cin >> x;
            insert(x);
        }
        else if (s == "delete")
        {
            int x;
            cin >> x;
            deleteKey(x);
        }
        else if (s == "deleteFirst")
        {
            deleteFirst();
        }
        else
        {
            deleteLast();
        }
    }

    printList();
    return 0;
}


Measured memory_bytes: 34440
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  for (int x=0;x<=k;x++){
    for (int y=0;y<=k;y++){
      int z=s-x-y;
      if (z>=0 && z<=k) ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b + c >= 22) 
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  scanf(" %d%d%d",&a,&b,&c);
  if ((a < b) && (b < c))
  {
      printf("Yes\n");
  }
  else
  {
      printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int ans;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x) make_pair(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {

    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;

    ll ans=4;
    ll mini=min(a,min(b,min(c,min(d,e))));
    ans+=(n+mini-1)/mini;
    if(n<=mini) ans=5; 
    
    cout<<ans<<endl;

 return 0;
}

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

int main(){
  ll n,k,q;
  cin>>n>>k>>q;
  ll s[n];
  rep(i,n){
    s[i] = k-q;
  }
  rep(i,q){
    int a;
    cin >> a;
    s[a-1]++;
  }
  rep(i,n){
    if(s[i]<=0){
      cout<<"No"<<endl;
    }
    
    else {
      cout<<"Yes"<<endl;
    }
  }
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  REP(i, ty - sy)
  cout << "U";
  REP(i, tx - sx)
  cout << "R";
  REP(i, ty - sy)
  cout << "D";
  REP(i, tx - sx)
  cout << "L";
  cout << "L";
  REP(i, ty - sy + 1)
  cout << "U";
  REP(i, tx - sx + 1)
  cout << "R";
  cout << "D";
  cout << "R";
  REP(i, ty - sy + 1)
  cout << "D";
  REP(i, tx - sx + 1)
  cout << "L";
  cout << "U";
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

int UF[114514];
void UFinit(int n){
    for(int i=0;i<=n;i++){
        UF[i]=i;
    }
}
int UFroot(int k){
    if(UF[k]==k){
        return k;
    }else{
        UF[k]=UFroot(UF[k]);
        return UF[k];
    }
}
int UFsame(int P,int Q){
    if(UFroot(P)==UFroot(Q)){
        return true;
    }else{
        return false;
    }
}
void UFunite(int P,int Q){
    int p=UFroot(P);
    int q=UFroot(Q);
    if(p==q)return;
    if(p>q)swap(p,q);
    UF[q]=p;
}


signed main(void){
    int N,M;
    int a[114514];
    int x[114514],y[114514];
    cin >> N >> M;
    REP(i,N){
        cin >> a[i];
    }
    REP(i,M){
        cin >> x[i] >> y[i];
    }
    int C=2*(N-M-1);
    if(C>N){
        cout << "Impossible" << endl;
        return 0;
    }
    if(C==0){
        cout << 0 << endl;
        return 0;
    }
    
    UFinit(N);
    REP(i,M){
        UFunite(x[i],y[i]);
    }
    
    pair<int,int> mn[114514];
    REP(i,114514){mn[i]={INF,0};}
    REP(i,N){
        if(a[i]<mn[UFroot(i)].first){
            mn[UFroot(i)]={a[i],i};
        }
    }
    bool al[114514]={};
    int Ans=0;
    REP(i,N){
        if(mn[i].first!=INF){
            Ans+=mn[i].first;
            al[mn[i].second]=1;
            C--;
        }
    }
    
    vector<int> V;
    REP(i,N){
        if(al[i]==0){
            V.push_back(a[i]);
        }
    }
    sort(V.begin(),V.end());
    REP(i,C){
        Ans+=V[i];
    }
    
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 6776
#include<stdio.h>
int main()
{
    int a,b,sum=0,sub=0,mul=0,large=0;
    scanf("%d %d",&a,&b);

    sum = a+b;
    sub = a-b;
    mul = a*b;

    if(sum>=sub && sum>=mul)
        large = sum;
    else if(sub>=sum && sub>=mul)
        large = sub;
    else
        large = mul;
    printf("%d\n",large);

    return 0;
}


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



int main(){
	int N,K;
	cin>>N>>K;
	int a = N/K;
	long long ans = (long long)a*a*a;
	if(K%2==0){
		N+=K/2;
		a=N/K;
		ans+=(long long)a*a*a;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>

using namespace std;


class ACantWaitForHoliday {
public:
    void solve(std::istream &in, std::ostream &out) {
        string s;
        in >> s;

        if (s == "SUN") out << 7 << endl;
        if (s == "MON") out << 6 << endl;
        if (s == "TUE") out << 5 << endl;
        if (s == "WED") out << 4 << endl;
        if (s == "THU") out << 3 << endl;
        if (s == "FRI") out << 2 << endl;
        if (s == "SAT") out << 1 << endl;
    }
};


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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc106/editorial.pdf
　　　https://atcoder.jp/contests/abc106/submissions/3024983
　　　https://imoz.jp/algorithms/imos_method.html
・二次元累積和
・最後にどこを足し引きするかは上記参考の二次元いもすと同じ話だと思う。
"""

N, M, Q = map(int, input().split())
LR = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
    l, r = map(int, input().split())
    LR[l][r] += 1

# 縦横両方について累積和を出す
# 先頭1行1列は0のままにしておく
for i in range(1, N+1):
    for j in range(2, N+1):
        LR[i][j] += LR[i][j-1]
for i in range(1, N+1):
    for j in range(2, N+1):
        LR[j][i] += LR[j-1][i]

for i in range(Q):
    p, q = map(int, input().split())
    # +左上 -右上 -左下 +右下
    ans = LR[p-1][p-1] - LR[p-1][q] - LR[q][p-1] + LR[q][q]
    print(ans)


Measured memory_bytes: 58092
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,k,memo[N],c[N];

int dp(int curr) {
    if (curr == n) return 0;
    if (curr > n) return 1e9;
    int &sol = memo[curr];
    if (sol != -1) return sol;
    int keep = INT_MAX;
    for (int i = 1 ; i <= k ; i++) {
        keep = min(
            dp(curr + i) + abs(c[curr] - c[curr + i]) ,
            keep
        );
    }
    return sol = keep;
}

int main() {
    scanf("%d%d" , &n , &k);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d" , &c[i]);
    memset (memo , -1 , sizeof memo);
    printf("%d\n" , dp(1));
}


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

int P[36];
int main() {
	int N, M; cin >> N >> M;
	for(int i=0; i<N; ++i){
	    int K; cin >> K;
	    for(int j=0; j<K; ++j){
	        int A; cin >> A;
	        ++P[A];
	    }
	}
	int ans=0;
	for(int i=1; i<=M; ++i) if(P[i]==N) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int bubbleSort(int A[],int N){
	bool flag = true;
	int i = 0; 
	for(int s=0;flag;s++){
		flag = false;
		for(int j = N-1;j>=s+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag = true;
				i++;
			}
		}
	}
	return i;
}
int main(){
	int A[100],N,i;
	cin >> N;
	for(int j = 0;j<N;j++) cin >> A[j];

	i = bubbleSort(A,N);
	for(int j = 0;j<N;j++){
		if(j)cout << " ";
		cout << A[j];
	}
	cout<<endl;
	cout<<i<<endl;

	return 0;
}


Measured memory_bytes: 3100
/*
AizuOnline A0039
Roman Figure
*/
#include <stdio.h>
#include <string.h>

char roman_table[] = "IVXLCDM";
int  roman_value_table[]={1,5,10,50,100,500,1000};

int roman2arabic(char roman[])
{
        int i;
        int s =0;
  
        for(i=0;i<strlen(roman);i++)
          s += roman_value_table[strchr(roman_table,roman[i])-roman_table]

            * (((i<strlen(roman)-1)&&(strchr(roman_table,roman[i])<strchr(roman_table,roman[i+1])))?(-1):1);

        return(s);
}


main()
{
  char roman_str[1024];
  
                  while(EOF != scanf("%s",roman_str))
                    {
                      printf("%d\n",roman2arabic(roman_str));
                    }

return(0);
}

Measured memory_bytes: 0