akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, M;
int L[200100];
int R[200100];
int D[200100];
int points[200100];
vector<tpl> G[200100];
const int INF = (1 << 30);


bool rec(int pos){
    for(tpl p : G[pos]){
        int to =   get<0>(p);
        int dist = get<1>(p);
        int ang =  get<2>(p);
        int next = points[pos] +  dist * ang;
        if(points[to] != -INF){
            if(next != points[to]){
                return false;
            }
        }
        else{
            points[to] = next;
            if(!rec(to)) return false;
        }
    }
    return true;
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> L[i] >> R[i] >> D[i];
        L[i]--; R[i]--;
        G[L[i]].push_back(tpl(R[i], D[i], +1));
        G[R[i]].push_back(tpl(L[i], D[i], -1));
    }
    for(int i = 0; i < N; i++)
        points[i] = -INF;

    for(int i = 0; i < N; i++){
        if(points[i] == -INF){
            points[i] = 0;
            if(!rec(i)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 17920
#include <iostream>

using namespace std;
const int maxn=2e5+10;
int a[maxn],b[maxn],c[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)cin>>b[i];
    int r=n,l;
    for(int i=1; i<=n; i++)c[i]=b[r--];
    l=1;r=n;
    for(int i=1; i<=n; i++){
        if(a[i]!=c[i])continue;
        if(l<i&&c[l]!=a[i]&&a[l]!=c[i]){
            swap(c[l],c[i]);
            l++;
        }else if(i<r&&c[r]!=a[i]&&a[r]!=c[i]){
            swap(c[r],c[i]);
            r--;
        }else return cout<<"No"<<endl,0;
    }
    cout<<"Yes"<<endl;
    for(int i=1; i<=n; i++)cout<<c[i]<<' ';
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i)
  {
    if(i == 10 || i == 1000 || i == 100000) i *= 10;
    if(i <= n) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main()
{
    double r;
    cin >> r;

    cout.setf(ios::fixed);
    cout.precision(10);
    cout << M_PI * r * r << ' ' << 2 * M_PI * r << endl;

    return 0;
}

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

int i;
int n, q;
vector<int> s;

int binarySearch(int key) {
    int start = 0, end = n;
    int mid;
    while (start < end) {
        mid = (end+start) / 2;
        if (s[mid] == key) return mid;
        if (s[mid] < key) {
            start = mid + 1;
        } else {
            end = mid;
         }
    }
    return -1;
}

int main() {
    int input;
    vector<int> ans;

    cin >> n;
    rep(i, n) {
        cin >> input;
        s.push_back(input);
    }

    cin >> q;
    rep(i, q) {
        cin >> input;
        int t = binarySearch(input);
        if (t >= 0) ans.push_back(t);
    }
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans.size() << endl;

    return 0;
}



Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);

ll solve(){
	ll n,k,ans=0;
	cin>>n>>k;
	while(k<=n+1){
		ans+=(k*(n-k+1)+1);
		ans%=mod;
		k++;
	}
	return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


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

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

#define vi vector<int>
#define pb push_back
#define mp make_pair

typedef long long ll;

struct P {
    int l,r,t,b,d;
    P(int l, int r, int t, int b, int d) : l(l),r(r),t(t),b(b),d(d){
    }
    P() {
    }
    P(int l, int r, int t, int b) : l(l),r(r),t(t),b(b),d((r - l) * (b - t)){
    }
    // 演算子オーバーロードで比較関数を定義
    bool operator<(const P &another) const {
        return d <= another.d;
    }
};


int main() {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());

    int n, w, h;
    int p, ss, sp;
    while (cin >> n >> w >> h, (n != 0 || w != 0 || h != 0)) {
        vector <P> cake;
        cake.pb(P(0, w, 0, h, w * h));
        rep(i, n) {
            cin >> p >> ss;
            int cl = cake[p - 1].l;
            int cr = cake[p - 1].r;
            int ct = cake[p - 1].t;
            int cb = cake[p - 1].b;
            int cw = cr - cl;
            int ch = cb - ct;
            int mod = (cw + ch) * 2;
            int s = ss % mod;
            // cout << s << endl;
            P c1; P c2;
            if ((s < cw) || (cw + ch < s && s < cw + ch + cw)) {
                if (s < cw) sp = cl + s;
                else sp = cl + (cw - (s - ch - cw));
                // cout << sp << endl;
                c1 = P(cl, sp, ct, cb);
                c2 = P(sp, cr, ct, cb);
            } else {
                if (cw + ch + cw < s) sp = ct + (s - cw - ch - cw);
                else sp = ct + (ch - (s - cw));

                c1 = P(cl, cr, ct, sp);
                c2 = P(cl, cr, sp, cb);
            }
            // cout << c1.d << endl;
            if (c1.d < c2.d) {
                cake.pb(c1);
                cake.pb(c2);
            } else {
                cake.pb(c2);
                cake.pb(c1);
            }

            // rep(i, cake.size() ) cout << cake[i].d << " ";
            // cout << endl;
            cake.erase(cake.begin() + p - 1);

        }

        sort(cake.begin(), cake.end());
        rep(i, cake.size() - 1) cout << cake[i].d << " ";
        cout << cake[cake.size() - 1].d << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] card = new int[4][13];
		String mark;
		int num;
		int i;

		//入力されたカード
		for (i = 0; i < n; i++) {
			mark = sc.next();
			num = sc.nextInt();
			switch (mark) {
			case "S":
				card[0][num - 1] = 1;
				break;
			case "H":
				card[1][num - 1] = 1;
				break;
			case "C":
				card[2][num - 1] = 1;
				break;
			case "D":
				card[3][num - 1] = 1;
				break;
			}
		}

		//ないカード
		for (num = 0; num <= 3; num++) {
			for (i = 0; i <= 12; i++) {
				if (card[num][i] == 0) {
					switch (num) {
					case 0:
						System.out.println("S " + (i+1));
						break;
					case 1:
						System.out.println("H " + (i+1));
						break;
					case 2:
						System.out.println("C " + (i+1));
						break;
					case 3:
						System.out.println("D " + (i+1));
						break;
					}
				}
			}
		}
	}

}


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

int main(){
    double x1,y1,x2,y2;

    double dis;
  
  cin >> x1 >> y1 >> x2 >> y2;

  dis = ((double)x1 - x2) * ((double)x1 - x2) + ((double)y1 - y2) * ((double)y1 - y2);
  dis = sqrt(dis);

  cout << fixed << setprecision(12) << dis << endl;
  
  return 0;
}



Measured memory_bytes: 3272
<?php

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);
fscanf(STDIN, "%d", $Q);

$new_text = [];
foreach(str_split($S) as $value){
    $new_text[] = 1 << (ord($value )- 97);
}

$ST = new SegmentTree($new_text);

while($Q--){

    fscanf(STDIN, "%d%d%s",$type, $from, $to);
    if($type === 1){

        $ST->update($from-1, (1 << (ord($to)-97)));

    }else{
        echo bitnum($ST->query($from-1, $to-1, 0, 0, $ST->size-1)).PHP_EOL;

    }

}



class SegmentTree{

    /**
     * @var array
     */
    private $tree = [];
    public $size = 0;
    private $default = 0;

    function __construct($array, $default=0){
        $count = count($array);
        $pow = floor(log($count, 2));
        $pow = (int)pow(2,$pow);
        while($count>$pow){
            $pow*=2;
        }
        $this->size = $pow;
        $this->tree = array_merge(array_fill(0,$pow-1,$default), $array, array_fill(0, $pow-$count, $default));
        $this->default = $default;
//        for($i=$this->size - intdiv($this->size,2)-1; $i < $this->size-1;$i++){
//            $this->updateUP($i);
//        }
        $this->updateAll();
    }

    function update($target, $value){
        $target = $target + $this->size -1;
        $this->tree[$target] = $value;
        $this->updateUP(intdiv($target-1, 2));

    }

    function updateUP($target){

        while($target >=0){
            $this->tree[$target] = $this->ev($this->tree[($target << 1) + 1], $this->tree[($target <<1) + 2]);
            $target-=1;
            $target>>=1;
        }
//
//        if($target != 0){
//            $this->updateUP(($target-1)>>1);
//        }
    }

    function updateAll(){
        for($i = $this->size-2;$i>=0;$i--){
            $this->tree[$i] = $this->ev($this->tree[$i * 2 + 1], $this->tree[$i * 2 + 2]);
        }
    }

    function query($from, $to, $node, $node_from, $node_to){

        if($node_from > $to || $node_to < $from){
            return $this->default;
        }
        if($node_to <= $to && $node_from >= $from){
            return $this->tree[$node];
        }else{
            $left = $this->query($from, $to, 2*$node + 1, $node_from, intdiv($node_from + $node_to, 2));
            $right = $this->query($from, $to, 2*$node + 2, intdiv($node_from + $node_to, 2)+1, $node_to);
            return $this->ev($left,$right);
        }


    }

    function ev($new, $comp){
        return $new | $comp;
    }

}
function bitnum($bits){
    $bits = ($bits & 0x55555555) + ($bits >> 1 & 0x55555555);
    $bits = ($bits & 0x33333333) + ($bits >> 2 & 0x33333333);
    $bits = ($bits & 0x0f0f0f0f) + ($bits >> 4 & 0x0f0f0f0f);
    $bits = ($bits & 0x00ff00ff) + ($bits >> 8 & 0x00ff00ff);
    return ($bits & 0x0000ffff) + ($bits >>16 & 0x0000ffff);
}


Measured memory_bytes: 88560
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<vector<int>> C(10, vector<int>(10));
    for (int i = 1; i <= N; i++) {
        int left = i, right = i % 10;
        while (left > 9) {
            left /= 10;
        }
        C[left][right]++;
    }
    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += 1ll * C[i][j] * C[j][i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ans+=(n*(n-1))/2;
	ans+=(m*(m-1))/2;
	cout<<ans;

	return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, a, b, c, d;
string s;

char get(int i) {
	if (i >= 0 && i < n) return s[i];
	return '.';
}

signed main() {
	int i;
	
	cin >> n >> a >> b >> c >> d; a--; b--; c--; d--;
	cin >> s;
	
	for (i = b; i < d; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			break;
		}
	}
	if (i < d) { cout << "No" << endl; return 0; }
	for (i = a; i < c; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			break;
		}
	}
	if (i < c) { cout << "No" << endl; return 0; }
	if (c < d) { cout << "Yes" << endl; return 0; }
	
	//c > d
	for (i = b; i <= d; i++) {
		if (get(i-1) == '.' && get(i) == '.' && get(i+1) == '.') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

    set<string> S;
    for (int i = 0; i < N; i++)
    {
        string l;
        cin >> l;
        S.insert(l);
    }
    cout << S.size() << endl;

    return 0;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 500010
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	while(cin >> n)
	{
		vector<int> v(n);
		FOR(i, 0, n)
		{
			cin >> v[i];
		}
		int sum = 0;
		FOR(i, 0, n)
			FOR(j, i+1, n)
				sum += v[i]*v[j];
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 384
import itertools

n = int(input())

p = input().replace(' ', '')
q = input().replace(' ', '')

array = []
for v in itertools.permutations(list(map(str,range(1, n+1)))):
  tmp = list(v)
  array.append(''.join(tmp))
  
array.sort()

ans = abs(array.index(q) - array.index(p))
print(ans)

Measured memory_bytes: 6040
program count_abc
  implicit none
  integer :: n, i, m = 0
  character(50) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n-2
    if (s(i:i+2) == "ABC") m = m+1
  end do
  write(*,'(i0)') m
end program count_abc

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

typedef long long int ll;

using namespace std;

ll beki(ll A,ll B){
  ll C=1;
  for (ll i = 0; i < B; i++)
  {
    C *= A;
  }
  return C;
}

int main()
{
  ll N,M,count=0,waru=0,sum=0;

  cin >> N;

  if(N%2==1){
    cout << 0 << endl;
  }
  else{
    M = N;

    while (M >= 5)
    {
      M = M / 5;
      count++;
    }
    vector<ll> vec(count);
    for (ll i = 0; i < count; i++)
    {
      vec.at(i) = 0;
    }

    for (ll i = 0; i < count; i++)
    {
      waru = beki(5, i + 1);
      //cout << waru << endl;
      vec.at(i) = N / (waru * 2);
      //cout << vec.at(i) << endl;
      waru = 0;
    }

    for (ll i = 0; i < count; i++)
    {
      sum += vec.at(i);
    }
    cout << sum << endl;
  }

}

Measured memory_bytes: 256
x, n = map(int, input().split(" "))
if n != 0:
  p=list(map(int, input().split(" ")))
else:
  p=[]
lst = list(range(-1, x * 2 + 1))
for i in p:
  if i in lst:
    lst.remove(i)
for i in range(x + 2):
  if x - i in lst or x - i < 0:
    print(x - i)
    break
  elif x + i in lst:
    print(x + i)
    break

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;
const long long INF=1e9;
int ci;

int main(){
    ll x, k, d, x_d;
    ll ans;
    cin >> x >> k >> d;
    x = abs(x);
    x_d = x/d;
    if(k <= x_d) ans = abs(x)-k*d;
    else{
        k-=x_d;
        x-=x_d*d;
        if(k%2==0) ans = x;
        else ans = min(abs(x-d), x+d);
        }
    cout << ans << endl;
    cin >> ci;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int B=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		B|=x%2;
	}
	cout<<(B?"first":"second")<<endl;
}

Measured memory_bytes: 384
function Main(input){
    input = input.split("\n")
    var N = parseInt(input[0],10)
    input.shift()
    var W = input

    for(var i = 0;i < N;i++){
        for(var j = i + 1;j < N;j++){
            if(W[i] === W[j]){
                console.log("No")
                return
            }
        }
    }

    for(var i = 0;i < N - 1;i++){
        if(W[i].slice(-1) !== W[i+1].slice(0,1)){
            console.log("No")
            return
        }
    }

    console.log("Yes")
}

Main(require("fs").readFileSync("/dev/stdin","utf8"))

Measured memory_bytes: 7372
#!/usr/bin/perl

use strict;
use warnings;

my ($n, $a, $b);
{
    my $in = <STDIN>;
    ($n, $a, $b) = split(" ", $in);
}

my $ans;
if($a % 2 == $b % 2) {
    $ans = ($b - $a) / 2;
} elsif ($a - 1 < $n - $b) {
    $ans = $a - 1 + 1 + ($b - $a - 1) / 2;
} else {
    $ans = $n - $b + 1 + ($b - $a - 1) / 2;
}
print $ans;

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


struct Dice {
  int omote,ura,up,down,left,right;
  Dice(vector<int> &a){
    omote = a[0]; ura = a[5];
    up = a[4]; down = a[1];
    left = a[3]; right = a[2];
  }

  void operate(int &a,int &b,int &c,int &d){
    int buf = a;
    a = b; b = c; c = d; d = buf;
  }

  void rotate(char c){
    if (c == 'E') operate(omote, left, ura, right);
    if (c == 'N') operate(omote, down, ura, up);
    if (c == 'S') operate(omote, up, ura, down);
    if (c == 'W') operate(omote, right, ura, left);
  }
};

int main() {
  vector<int> a(6); rep(i, 6) cin >>a[i];
  Dice dice = Dice(a);
  string s; cin >>s;
  for (char c : s){
    dice.rotate(c);
  }
  cout <<dice.omote <<endl;
}


Measured memory_bytes: 3140
n=int(input())
a=[[int(i) for i in input().split()] for i in range(n)]

import itertools
import math
pe=itertools.permutations(range(n))
pe=list(pe)
ans=0

for i in pe:
    tmp=0
    for j in range(n-1):
        tmp+=((a[i[j]][0]-a[i[j+1]][0])**2+(a[i[j]][1]-a[i[j+1]][1])**2)**0.5
    ans+=tmp
print(ans/math.factorial(n))

Measured memory_bytes: 8100
#include <iostream>

using namespace std;

int main()
{
	int count;
    cin>>count;
    
    int* list  = new int[count];
    for(int x = 0; x<count; x++){
        cin>>list[x];
    }
    
    //  start sorting;
    int sum = 0;
    
    for(int i = 0; i< count; i++){
        for(int j = count-1;j>i;j--){
            if(list[j-1]>list[j]){
                int temp = list[j];
                list[j] = list[j-1];
                list[j-1] = temp;
                sum++;
            }
        }
    }
    
    for(int x = 0;x < count;x++){
        cout<<list[x];
        if(x!= count-1){
            cout<<' ';
        }
    }
    cout<<endl;
    
    cout<<sum<<endl;
    
	return 0;
}

Measured memory_bytes: 3092
package main

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

// ToIntSlice はstring型のスライスをint型のスライスに変換する関数
func ToIntSlice(targetSlice []string) []int {
	var num int
	var returnSlice []int

	for i := 0; i < len(targetSlice); i++ {
		num, _ = strconv.Atoi(targetSlice[i])
		returnSlice = append(returnSlice, num)
	}

	return returnSlice
}

// returnBigger 小さいほうを返す関数
func returnSmaller(num1 int, num2 int) int {
	var smaller int

	if num1 < num2 {
		smaller = num1
	} else if num1 > num2 {
		smaller = num2
	} else {
		smaller = num1
	}

	return smaller
}

func main() {
	reader := bufio.NewScanner(os.Stdin)

	var inputSlice []string
	for i := 0; i < 4; i++ {
		reader.Scan()
		inputSlice = append(inputSlice, reader.Text())
	}

	inputSlice2 := ToIntSlice(inputSlice)

	fmt.Print(returnSmaller(inputSlice2[0], inputSlice2[1]) + returnSmaller(inputSlice2[2], inputSlice2[3]))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	FastInput;

	long long int a, b;
	cin >> a >> b;
	char c;
	cin >> c;
	int d;
	cin >> d;
	b *= 100;
	b += d;

	lli result = a * b;

	result /= 100;

	cout << result << endl;

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
min = 100
a_sum = 0
b_sum = 0

for a in range(1, n):
  b = n-a
  while a >= 1:
    a_sum += a%10
    a = a//10
  
  while b >= 1:
    b_sum += b%10
    b = b//10
  
  if a_sum + b_sum < min:
    min = a_sum + b_sum
  
  a_sum = 0
  b_sum = 0

print(min)

Measured memory_bytes: 3064
// FSX nb!
//
// OP 1:
// * * * * x
// x * * * *
// ⇒ +1
//
// OP 2:
// * * * x *
// * * * * x
// ⇒ ×2

#include <cstdio>

#include <deque>

using namespace std;

typedef long long i64;

static deque<int> L, R;
static i64 M;

int main() {
    scanf("%lld", &M);
    i64 N = 0;
    for (int j = 60, i = 0; j >= 0; j--) {
        if ((M >> j) & 1) {
            i++;
            N++;
            L.push_back(i);
            R.push_front(i);
        }
        if (N && j) {
            i++;
            N <<= 1;
            int u = L.back();
            L.pop_back();
            L.push_back(i);
            L.push_back(u);
            R.push_back(i);
        }
    }

    printf("%zu\n", L.size() + R.size());
    for (int i = 0; i < L.size(); i++)
        printf("%d ", L[i]);
    for (int i = 0; i < R.size(); i++)
        printf("%d ", R[i]);
    puts("");
    return 0;
}


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


void solve(long long A, long long B){
   long long a = A + (A-1);
   long long b = B + (B-1);
   long long c = A + B;
   cout << std::max({a,b,c}) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main() {
	int n, h, m, v; char dm;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> h >> dm >> m;
		v = abs(60*h-11*m); if(v>360) v=720-v;
		cout << (v<60?"alert":180<=v&&v<=360?"safe":"warning") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 2e4 + 15;
const ll MOD = 1e9  ;
const double EPS = 1e-9;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back
#define pb push_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    string a, b;
    int c1, c2;
    cin >> a >> b >> c1 >> c2;
    string s;
    cin >> s;
    if (s == a) {c1--;}
    else {
        c2--;
    }
    cout << c1 << ' ' << c2;
}

signed main() {
    IO();
    int t = 1;
   // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

bool check(long n){
    if(n >= 1 && n <= 12) return true;
    else return false;
}

int main(){
// long N;
// cin >> N;
// vector<long> A(N+1);
string S, S1, S2;
cin >> S;
S1 = S.substr(0, 2);
S2 = S.substr(2, 2);
long N1, N2;
N1 = stoll(S1);
N2 = stoll(S2);
if(!check(N1) && !check(N2)) show("NA")
else if(!check(N1) && check(N2)) show("YYMM")
else if(check(N1) && !check(N2)) show("MMYY")
else if(check(N1) && check(N2)) show("AMBIGUOUS")



// show(ans);

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;


int main(void){
  //入力
  long long int N, M;
  cin >> N >> M;
  long long int ans = 1;
  //Mの約数を求める
  vector<long long int> d;
  for(long long int i = 1; i < sqrt(M); i++){
    if(M % i == 0){
      d.push_back(M / i);
      d.push_back(i);
    }
  }
  sort(d.begin(), d.end(), greater<long long int>());
  //gNup = MだからN以上で割った時の最大の整数がans
  for(long long int i = 0; i < d.size(); i++){
    if(M / d[i] >= N){
      ans = d[i];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, M; cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i=0; i<M; i++){
    cin >> L[i] >> R[i];
  }
  int l=1, r=N;
  for (int i=0; i<M; i++){
    l = max(l, L[i]);
    r = min(r, R[i]);
  }
  
  cout << max(0,r-l+1) << endl;
  return 0;
}

Measured memory_bytes: 1024
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 1 == 0:
      cnt += 1
print(cnt)

Measured memory_bytes: 9084
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int e[12];
    for(int i=0;i<12;i++){
        cin >> e[i];
    }
    sort(e,e+12);
    int cnt=0;
    if(e[0]==e[1]&&e[0]==e[2]&&e[0]==e[3]){
        cnt++;
    }
    if(e[4]==e[5]&&e[4]==e[6]&&e[4]==e[7]){
        cnt++;
    }
    if(e[8]==e[9]&&e[8]==e[10]&&e[8]==e[11]){
        cnt++;
    }
    if(cnt==3){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3152
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
print("A" if now==0 else "B" if now==1 else "C")

Measured memory_bytes: 9160
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    map<int, int> m1, m2;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            m1[v[i]]++;
        } else {
            m2[v[i]]++;
        }
    }
    int maxi1 = 0, maxc1 = 0, cnt1 = 0;
    int maxi2 = 0, maxc2 = 0, cnt2 = 0;
    for (auto x : m1) {
        cnt1 += x.second;
        if (x.second > maxc1) {
            maxi1 = x.first;
            maxc1 = x.second;
        }
    }
    for (auto x : m2) {
        cnt2 += x.second;
        if (x.second > maxc2) {
            maxi2 = x.first;
            maxc2 = x.second;
        }
    }
    int ans;
    if (maxi1 != maxi2) {
        ans = (cnt1 - maxc1) + (cnt2 - maxc2);
    } else {
        if (maxc1 > maxc2) {
            int i2 = 0, c2 = 0;
            for (auto x : m2) {
                if (x.first == maxi2) {
                    continue;
                }
                if (x.second > c2) {
                    i2 = x.first;
                    c2 = x.second;
                }
            }
            ans = (cnt1 - maxc1) + (cnt2 - c2);
        } else if (maxc1 < maxc2) {
            int i1 = 0, c1 = 0;
            for (auto x : m1) {
                if (x.first == maxi1) {
                    continue;
                }
                if (x.second > c1) {
                    i1 = x.first;
                    c1 = x.second;
                }
            }
            ans = (cnt2 - maxc2) + (cnt1 - c1);
        } else {
            int i1 = 0, c1 = 0;
            int i2 = 0, c2 = 0;
            for (auto x : m1) {
                if (x.first == maxi1) {
                    continue;
                }
                if (x.second > c1) {
                    i1 = x.first;
                    c1 = x.second;
                }
            }
            for (auto x : m2) {
                if (x.first == maxi2) {
                    continue;
                }
                if (x.second > c2) {
                    i2 = x.first;
                    c2 = x.second;
                }
            }
            if (c1 > c2) {
                ans = (cnt1 - c1) + (cnt2 - maxc2);
            } else {
                ans = (cnt1 - maxc1) + (cnt2 - c2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  string G;
  N=S.size();
  rep(i,0,N){
    if(i&1){
      T+='0';
      G+='1';
    }
    else{
      T+='1';
      G+='0';
    }
  }
  rep(i,0,N){
    if(T[i]!=S[i])sum++;
    if(G[i]!=S[i])num++;
  }
  Out(min(sum,num));
}

Measured memory_bytes: 720
n,k=[int(i) for i in input().split()] 
a = [[int(j) for j in input().split()] for _ in range(n)]
a.sort()
x=0
i=0
while 1:
  if k <=0:
    break
  else:
  	k-=a[i][1]
  	i+=1
print(a[i-1][0])

Measured memory_bytes: 21600
# WIP
from itertools import combinations

N = int(input())
SSS = [input() for _ in range(N)]

# Filter1
filter_1 = {'M', 'A', 'R', 'C', 'H'}
canditates = [S for S in SSS if S[0] in filter_1]
cand_inits = [c[0] for c in canditates]
cand_inits_set = set(cand_inits)
init_counts = {init_c: cand_inits.count(init_c) for init_c in filter_1}

n_combi = 0
for init_combi in combinations(cand_inits_set, 3):
    tmp_combi = 1
    for init_c in init_combi:
        tmp_combi *= init_counts[init_c]

    n_combi += tmp_combi

print(n_combi)


Measured memory_bytes: 11436
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

vector<int> v[100001];
int cnt,used[100001];
bool nibu;

void dfs(int x,int flag){
  if(flag==1)cnt++;
  else cnt--;
  rep(i,v[x].size()){
    if(used[v[x][i]]==flag){
      nibu=false;
      return;
      }
    if(used[v[x][i]]==-1){
      used[v[x][i]]=1-flag;
      dfs(v[x][i],1-flag);
      }
    }
  }


int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--;y--;
    v[x].push_back(y);
    v[y].push_back(x);
    }
  rep(i,n)used[i]=-1;
  int num=0;
  vector<int> e;
  rep(i,n){
    if(used[i]==-1){
      used[i]=1;
      cnt=0;
      nibu=true;
      dfs(i,1);
      if(!nibu){cout<<-1<<endl;return 0;}
      if(abs(cnt)>1)e.push_back(abs(cnt));
      if(abs(cnt)==1)num++;
      }
    }
  bitset<2000001> b;
  b=1;
  b=b<<100000;
  rep(i,e.size())b=(b<<e[i])|(b>>e[i]);
  rep(i,100001){
    if(b[100000+i]){
      ll ma,mi,d;
      if(i>num)d=ll(i-num);
      else d=(ll)(num-i)%2;
      ma=(ll)(d+n)/2;
      mi=(ll)(n-d)/2;
      cout<<ma*mi-m<<endl;
      return 0;
      }
    }
  return 0;    
  }


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

int sum_l[2000][2000];
int sum_r[2000][2000];
int sum_u[2000][2000];
int sum_d[2000][2000];

void solve() {
  int h, w;
  cin >> h >> w;
  vstr s(h);
  cin >> s;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') {
      if (j == 0) {
        sum_l[i][j] = 1;
      } else {
        sum_l[i][j] = sum_l[i][j - 1] + 1;
      }
    }
  }
  rep(i, h) rrep(j, w) {
    if (s[i][j] == '.') {
      if (j == w - 1) {
        sum_r[i][j] = 1;
      } else {
        sum_r[i][j] = sum_r[i][j + 1] + 1;
      }
    }
  }
  rep(j, w) rep(i, h) {
    if (s[i][j] == '.') {
      if (i == 0) {
        sum_u[i][j] = 1;
      } else {
        sum_u[i][j] = sum_u[i - 1][j] + 1;
      }
    }
  }
  rep(j, w) rrep(i, h) {
    if (s[i][j] == '.') {
      if (i == h - 1) {
        sum_d[i][j] = 1;
      } else {
        sum_d[i][j] = sum_d[i + 1][j] + 1;
      }
    }
  }
  int ans = 0;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') {
      amax(ans, sum_l[i][j] + sum_r[i][j] + sum_u[i][j] + sum_d[i][j] - 3);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 67072
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

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

signed main() {
    int n;
    cin >> n;

    deque<int> qr, qw;
    rep(i, n) {
        char c;
        cin >> c;

        if (c == 'R') {
            qr.push_back(i);
        } else {
            qw.push_back(i);
        }
    }

    int ans = 0;
    if (!(qr.empty() || qw.empty())) {
        while (qr.back() > qw.front()) {
            if (qr.empty() || qw.empty()) break;
            qw.pop_front();
            qr.pop_back();
            ++ans;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n>>x>>k;

    a = (n+x-1)/x;

    cout<<a*k<<"\n";


    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,b,c,d; cin>>a>>b>>c>>d;
    int mini = max(a, c);
    int maxi = min(b, d);
    cout << (maxi - mini >= 0 ? maxi-mini : 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;
 
int main(){
  int A ,B,C;
  cin >> A >> B >> C;
  if(A*B*C%(25*7)==0){
    if(A==5 || A==7){
     if(B==5 || B==7){
      if(C==5 || C==7){
       cout << "YES" << endl; 
      }
     }
    }
  }
  else{
   cout << "NO" << endl; 
  }
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
  
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans = x - min(k, x / d) * d;
    if ((k - min(k, x / d)) & 1) {
        ans = min(ans + d, abs(ans - d));
    }
    cout << ans;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
string s1;
int main()
{
	cin>>s1;
	int len=s1.length();
	if(s1[len-1]!='s') {
		cout<<s1; cout<<'s';
	}
	else 
	{
		cout<<s1; cout<<'e'<<'s';
	}
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

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

	int ans = 0;
	if( a > b ){
		ans += a;
		a--;
	}
	else{
		ans += b;
		b--;
	}

	if( a > b ){
		ans += a;
		a--;
	}
	else{
		ans += b;
		b--;
	}

	cout << ans << endl;

	ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
int dp[100001];

int main()
{
    int n,k,i,j,x,y;
    cin>>n>>k;
    int a[n+1];
    fo(i,0,n) cin>>a[i];
    a[n]=100002;
    x=0;
    fo(i,a[0],k+1)
    {
        if(i==a[x+1]) x++;
        fo(j,0,x+1)
        {
            if(!dp[i-a[j]]){
                dp[i]=1;
                break;
            }
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


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

int n;

int main(void)
{
	cin >>n;

	int cnt=0;
	int ans=0;
	for(int i=3; i<=n; i+=2) {
		for(int j=1; j<=sqrt(i); j+=2) {
			if(i%j==0 && j/i!=i) cnt+=2; 
		}
		if(cnt==8) ans++;
		cnt=0;
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
int main()
{
#if 0
    cout<<"in test mode:"<<endl;
	freopen("input.txt","r",stdin);
#endif
    int n,k,c=0,d,e;
    cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++) 
	{
		cin>>a[i];
	    if (a[i]>1) c++;
    }
	d=k-1; 
	e=c+d-1;
	cout<<e/d<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a,b;cin >> a >> b;
    for(int c=1;c<=3;c++){
        if(a*b*c%2==1){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


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

int main(){
  int n;
  cin >> n;
  typedef pair<int,int> P;
  vector<P> coordinate = {};
  int x,y;
  int tmp;
  int maximum = 0;
  bool flag = false;
  for (int i = 0; i<n; i++){
    cin >> x >> y;
    maximum = max(maximum,abs(x)+abs(y));
    if (i==0) {
      tmp = (abs(x) + abs(y))%2;
      if (tmp%2==0) flag = true;
    }
    //if (x+y)%2 dose not match with tmp, we cannot meat the condition
    else if (tmp != (abs(x) + abs(y))%2){
      cout << -1 << endl;
      exit(0);
    }
    if (flag) x--;
    coordinate.push_back({x,y});
  }
  //出力
  //case:tmp%2==0 you should add 1 to some direction
  int ranges = 1;
  while (1){
    if (maximum < pow(2,ranges)) break;
    else ranges++;
  }
  //m:the number of arms
  if (flag) cout << ranges+1 << endl;
  else cout << ranges << endl;
  //d:the length of arms
  if (flag) cout << 1 << " ";
  for (int i = ranges-1; i>=0; i--){
    cout << (int)pow(2,i);
    if (i!=0) cout << " ";
    else cout << endl;
  }
  //w:the mode of each arms
  vector<int> dx={1,-1,0,0};
  vector<int> dy={0,0,1,-1};
  vector<char> dz={'R','L','U','D'};
  for (int i=0; i<n; i++){
    x=coordinate[i].first;
    y=coordinate[i].second;
    if (flag){
      cout << 'R';
    }
    for (int j=ranges-1; j>=0; j--){
    for (int k=0; k<4; k++){
      if (abs(x-dx[k]*pow(2,j))+abs(y-dy[k]*pow(2,j))<pow(2,j)){
        cout << dz[k];
        x-=pow(2,j)*dx[k];
        y-=pow(2,j)*dy[k];
        break;
      }
    }
    }
    cout << endl;
  }
}

Measured memory_bytes: 384