akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,X,T;
    cin >> N >> X >> T;
    cout << ((N+X-1)/X*T) << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
const int INF =1e7;
typedef pair<int, int> P;
int c[50];
int dp[50001];
int n, m;
int coin(int n)
{
    rep(i,n+1){
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, n + 1)
    {
        rep(j, m)
        {
            if ((i - c[j])>=0)
            {
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }
    }
    return dp[n];
}
int main()
{
    cin >> n >> m;
    rep(i, m)
    {
        cin >> c[i];
    }
    int ans = coin(n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int n;
		cin >> n;
		vector<int> a( n );
		for( auto& v: a ) { cin >> v; }

		int m;
		cin >> m;
		vector<int> b( m );
		for( auto& v: b ) { cin >> v; }

		vector<int> c;
		set_intersection( a.begin(), a.end(), b.begin(), b.end(), back_inserter( c ) );
		for( auto v: c ) { cout << v << '\n'; }
	}
};

int main() {
	Solver().solve();
	return 0;
}



Measured memory_bytes: 4668
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int A,B,C,K,ans=0;
	cin>>A>>B>>C>>K;
	if(K==A+B+C)ans=A-C;
	else if(K>=A+B)ans=A-(K-A-B);
	else if(K>=A)ans=A;
	else ans=K;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    set<int> box;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if (box.count(a)){
            box.erase(a);
        } else{
            box.insert(a);
        }
    }
    cout << box.size() << endl;
}

Measured memory_bytes: 8228
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;

int n;
vector<int> a;
vector<int> b;

int main(){

  cin >> n;
  a = vector<int>(n-1);
  b = vector<int>(n,0);
  rep(i,n-1) cin >> a[i];

  rep(i,n-1){
    b[a[i]-1]++;
  }

  rep(i,n){
    cout << b[i];
    if(i != n-1) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4768
#include<iostream>

using namespace std;

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

    int gcd = 1;
    for(int i=1; i<=min(a, b); i++){
        if(a%i == 0 && b %i==0){
            gcd = i;
        }
    }
    cout << a * b / gcd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

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

Measured memory_bytes: 256
import sys

n = int(input())

for i in range (1, n+1):
    if i % 3 == 0:
        print(" ", i, sep="", end="")
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                print(" ", i, sep="", end="")
                break
            x //= 10

print()


Measured memory_bytes: 6168
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

string s;

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

    int N, K;
    cin >> N >> K >> s;

    priority_queue<int> pq;

    int r = 1;
    queue<int> nextl;
    nextl.push(0);
    int ans = 0;
    while (r < N)
    {
        if (s[r - 1] == '0' && s[r] == '1')
        {
            nextl.push(r);
        }

        if (nextl.size() == K + 1 && s[r - 1] == '1' && s[r] == '0')
        {
            ans = max(ans, r - nextl.front());
            nextl.pop();;
        }
        ++r;
    }

    cout << max(ans, r - nextl.front()) << "\n";
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define bc __builtin_popcount
#define MAXN 200005
#define debug cout<<"we are debuuging"<<endl;
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
  ll n,m,k;
  cin>>n>>m>>k;
  //ll a[n];
  //ll b[m];
  vector<ll> a(n),b(m);
  for(int i=0;i<n;i++)
     cin>>a[i];
  for(int i=0;i<m;i++)
     cin>>b[i];
    for(int i=1;i<n;i++)
    {
         a[i]+=a[i-1];
    }
    for(int i=1;i<m;i++)
    {
         b[i]+=b[i-1];
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=k)
        {
             ll k1=k-a[i];
             ll it=upper_bound(b.begin(),b.end(),k1)-b.begin();
             ans=max(ans,i+1+it);
        }
    }
      for(int i=0;i<m;i++)
    {
        if(b[i]<=k)
        {
             ll k1=k-b[i];
             ll it=upper_bound(a.begin(),a.end(),k1)-a.begin();
             ans=max(ans,i+1+it);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6424
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	string S;
	cin >> S;

	if (S == "SSS")
	{
		cout << 0 << endl;
	}
	else if (S == "RRR")
	{
		cout << 3 << endl;
	}
	else if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR")
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s, t;
	cin >> s >> t;

	int op = 0;
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] != t[i]) {
			++op;
		}
	}

	cout << op << "\n";

	return 0;

}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];

    vector<vector<int>> U(h + 2, vector<int>(w + 2, 0));
    vector<vector<int>> D(h + 2, vector<int>(w + 2, 0));
    vector<vector<int>> L(h + 2, vector<int>(w + 2, 0));
    vector<vector<int>> R(h + 2, vector<int>(w + 2, 0));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (s[i][j] == '.'){
                U[i + 1][j + 1] = U[i][j + 1] + 1;
                L[i + 1][j + 1] = L[i + 1][j] + 1;
            }
            if (s[h - i - 1][w - j - 1] == '.'){
                D[h - i][w - j] = D[h - i + 1][w - j] + 1;
                R[h - i][w - j] = R[h - i][w - j + 1] + 1;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i < h + 1; i++){
        for (int j = 1; j < w + 1; j++){
            ans = fmax(ans, U[i][j] + D[i][j] + L[i][j] + R[i][j]);
        }
    }
    cout << ans - 3 << endl;
}


Measured memory_bytes: 67200
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        
        var a = scaner.nextInt(); // 時針
        var b = scaner.nextInt(); // 分針
        var h = scaner.nextInt();
        var m = scaner.nextInt();

        var x = 30 * h + 0.5 * m;
        var y = 6 * m;
        var r = Math.max(x, y) - Math.min(x, y);

        var ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - (2*a*b) * Math.cos(Math.toRadians(r)));

        System.out.println(ans);

        scaner.close();
    }

}


Measured memory_bytes: 35964
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

LL sm,N;
stack<int> st;
vii cnt;
vector<string> s;
int f(int idx,array<LL,3> a){
    cerr<<idx<<" "<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    if(idx==N){
        return 1;
    }
    FOR(jj,0,2){
        int i=s[idx][jj]-'A';
        int j=s[idx][1-jj]-'A';
        if(a[j]!=0){
            if(cnt[idx][i]<=a[i]&&cnt[idx][j]<=a[j]&&jj==1)continue;
            array<LL,3> b(a);
            b[i]++;b[j]--;
            int fl=f(idx+1,b);
            if(fl){
                st.push(i);
                return 1;
            }
        }
    }
    return 0;
}

int main(){
	LL n,a,b,c;
    cin>>n>>a>>b>>c;
    sm=a+b+c;
    N=n;
    s=vector<string>(n);
    cnt=vii(n+1,vi(3,0));
    FOR(i,0,n){
        cin>>s[i];
    }
    FORD(i,n,0){
        FOR(j,0,3){
            cnt[i][j]=cnt[i+1][j];
        }
        FOR(j,0,2){
            cnt[i][s[i][j]-'A']++;
        }
    }

    if(f(0,{a,b,c})==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        cerr<<st.size()<<endl;
        FOR(i,0,n){
            int t=st.top();
            st.pop();
            cout<<(char)('A'+t)<<endl;
        }
    }

    

}


Measured memory_bytes: 27064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100005
struct up{int l,r;}a[N];
bool cmp(up A,up B){return A.l==B.l?A.r>B.r:A.l<B.l;}
int n,mx,mn,fl[N],fr[N],tt,glx[N],gln[N],grx[N],grn[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1,cmp);
	mx=1,mn=1e9;
	for(int i=1;i<n;++i){
		mx=max(mx,a[i].l);
		mn=min(mn,a[i].r);
		fl[i]=max(mn-mx+1,0);
	}
	mx=1,mn=1e9;
	for(int i=n;i>1;--i){
		mx=max(mx,a[i].l);
		mn=min(mn,a[i].r);
		fr[i]=max(mn-mx+1,0);
	}
	for(int i=1;i<n;++i) tt=max(tt,fl[i]+fr[i+1]);
	gln[0]=grn[n+1]=1e9;
	for(int i=1;i<=n;++i){
		gln[i]=min(gln[i-1],a[i].r);
		glx[i]=max(glx[i-1],a[i].l); 
	}
	for(int i=n;i>=1;--i){
		grn[i]=min(grn[i+1],a[i].r);
		grx[i]=max(grx[i+1],a[i].l);
	}
	for(int i=1;i<=n;++i){
		int p=max(min(gln[i-1],grn[i+1])-max(glx[i-1],grx[i+1])+1,0);
		tt=max(tt,a[i].r-a[i].l+1+p);
	}
	printf("%d",tt);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}


int main(void){
    ll result;
    ll N, M;
    cin >> N >> M;
    
    if(N >= M){
        cout << 0 << endl;
        return 0;
    }
    
    vector<ll> X;
    rep(i, M){
        ll x;
        cin >> x;
        X.push_back(x);
    }
    sort(ALL(X));
    
    vector<ll> Xdif;
    rep(i, M - 1){
        Xdif.push_back(X[i+1] - X[i]);
    }
    sort(ALL(Xdif));
    
    ll sum = 0;
    rep(i, Xdif.size() - (N-1)){
        sum += Xdif[i];
    }
    result = sum;
    cout << sum << endl;
}


Measured memory_bytes: 2548
#include <stdio.h>
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[100][100];

int prim(int n) {
	int i, u, minv, d[100], p[100], color[100];

	for (i = 0; i < n; i++) {
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE;
	}
	d[0] = 0;
	while (1) {
		minv = INF;
		u = -1;
		for (i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (i = 0; i < n; i++) {
			if (color[i] != BLACK && M[u][i] != INF) {
				if (d[i] > M[u][i]) {
					d[i] = M[u][i];
					p[i] = u;
					color[i] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (i = 0; i < n; i++) {
		if (p[i] != -1) sum += M[i][p[i]];
	}
	return sum;
}

int main() {
	int n, i, j, e;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			scanf("%d", &e);
			if (e == -1) {
				M[i][j] = INF;
			}
			else { 
				M[i][j] = e; 
			}
		}
	}
	printf("%d\n", prim(n));
}


Measured memory_bytes: 2104
/**
*    created: 27.06.2020 19:10:17
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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() {

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

    int n;
    cin >> n;
    if (n < 1200) cout << "ABC" << endl;
    else if (n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 3588
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp[5], m, h, w, x, y, sum, k, q;

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

  rep(i, 3) cin >> tmp[i];
  sort(tmp, tmp + 3);
  rrep(i, 1, 3) { ans += tmp[i] - tmp[i - 1]; }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typpo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所,分けてた方がデバッグしやすい気がする---------------------
intl n,x,y;

void input_var(){
    cin >> n >> x >> y;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl ans[n];
    m0(ans);
    x--;
    y--;
    rep(i,n)repi(j,i + 1,n)ans[min({abs(i - j),abs(j - x) + abs(i - y) + 1,abs(j - y) + abs(i - x) + 1})]++;
    repi(i,1,n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <class T, class U>
void chmin(T& t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
void chmax(T& t, U f) {
  if (t < f) t = f;
}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  UnionFind(const UnionFind& u) { data = u.data; }
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int N;
vector<int> x, y;
map<pair<int, int>, vector<pair<int, int>>> m;

void hoge(int i, int j) {
  //-2x(x2-x1)-2y(y2-y1)+()+()
  ll a = -2 * (x[j] - x[i]);
  ll b = -2 * (y[j] - y[i]);
  ll c = (x[j] * x[j] - x[i] * x[i]) + (y[j] * y[j] - y[i] * y[i]);
  for (int k = 0; k < N; ++k) {
    for (int l = k + 1; l < N; ++l) {
      if (abs(a * x[l] + b * y[l] + c) == abs(a * x[k] + b * y[k] + c) &&
          (x[k] - x[l]) * (y[i] - y[j]) == (y[k] - y[l]) * (x[i] - x[j])) {
        m[{i, j}].push_back({k, l});
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  x.resize(N), y.resize(N);
  for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      hoge(i, j);
    }
  }

  UnionFind start(N);
  vector<pair<UnionFind, int>> dp;
  dp.push_back({start, 0});
  int mi = N;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      vector<pair<UnionFind, int>> v;
      for (auto& p : dp) {
        if (p.first.findSet(i, j)) continue;
        UnionFind next(p.first);
        for (auto& q : m[{i, j}]) {
          next.unionSet(q.first, q.second);
        }
        for (int k = 1; k < N; ++k) {
          if (!next.findSet(0, k)) {
            v.push_back({next, p.second + 1});
            break;
          }
          if (k == N - 1) chmin(mi, p.second + 1);
        }
      }
      for (auto& q : v) {
        dp.push_back(q);
      }
    }
  }
  cout << mi << endl;
}

Measured memory_bytes: 48448
# input n,m,l
n, m, l = map(int, input().split())

# matrixA
mtxA = []
for i in range(n):
    list_tmp = list(map(int, input().split()))
    mtxA.append(list_tmp)

# matrixB
mtxB = []
for i in range(m):
    list_tmp = list(map(int, input().split()))
    mtxB.append(list_tmp)

# initialize C
mtxC = [[0 for i in range(l)] for i in range(n)]

# compute mtxA x mtxB
for n_tmp in range(n):
    for l_tmp in range(l):
        for m_tmp in range(m):
            mtxC[n_tmp][l_tmp] += mtxA[n_tmp][m_tmp] * mtxB[m_tmp][l_tmp]

# output
for n_tmp in range(n):
    for l_tmp in range(l):
        print(mtxC[n_tmp][l_tmp], end='')
        if l_tmp < l-1:
            print(' ', end='')
    print('')



Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    
    for(int i=0;i<4;i++)
        cout << s[i];
    cout << ' ';
    for(int i=4;i<12;i++)
        cout << s[i];
    cout << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    ll n;
    int flag = 0;

    scanf("%lld", &n);

    ll sq = sqrt(n);
    ll max = 0;
    for (int i = 2; i < sq + 1; i++)
        if (n % i == 0)
        {
            flag = 1;
            max = i;
        }

    if (flag == 0)
        printf("%lld\n", n - 1);
    else
    {
        ll tmp = n / max;
        printf("%lld", tmp - 1 + max - 1);
    }

    return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()

Y=[]
for i in range(1,M):
    Y.append(X[i]-X[i-1])
Y.sort(reverse=True)

ans=sum(Y)
for i in range(min(N-1,M-1)):
    ans-=Y[i]
print(ans)

Measured memory_bytes: 13960
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (s[n - 1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
  return 0;
}

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

using ll = long long;

void f(vector<int> &keep, int n, int m) {
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      if (keep.at(i) < m) {
        keep.at(i)++;
        return;
      }
      else {
        continue;
      }
    }
    else {
      if (keep.at(i) < m && keep.at(i) < keep.at(i + 1)) {
        keep.at(i)++;
        for (int j = i + 1; j < n; j++) {
          keep.at(j) = keep.at(i);
        }
        return;
      }
      else {
        if (keep.at(i) < m) {
          keep.at(i)++;
          for (int j = i + 1; j < n; j++) {
            keep.at(j) = keep.at(i);
          }
        }
        else continue;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m, q;
  cin >> n >> m >> q;
  
  vector<int> a(q), b(q), c(q), d(q);
  for (int i = 0; i < q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  
  vector<int> keep(n, 1);
  ll ans = 0;
  while (true) {
    ll ans2 = 0;
    for (int i = 0; i < q; i++) {
      if (keep.at(b.at(i)) - keep.at(a.at(i)) == c.at(i)) ans2 += d.at(i);
    }
    ans = max(ans, ans2);
    //for (int j = 0; j < n; j++) cout << keep[j] << " ";
    //cout << endl;
    if (keep.at(0) == m) break;
    f(keep, n, m);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		bool ans=(m==n);

		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

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

	vector<int> as, bs;
	copy_n(istream_iterator<int>(cin), a, back_inserter(as));
	copy_n(istream_iterator<int>(cin), b, back_inserter(bs));
	int min = *min_element(as.begin(), as.end()) + *min_element(bs.begin(), bs.end());
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		int val = as[x - 1] + bs[y - 1] - c;
		if (val < min) {
			min = val;
		}
	}
	cout << min << endl;
	return 0;
}


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

using namespace std;
/*

Chào cô gái, có ph?i em tên t? t? không, mà sao lúc sub bài này anh toàn nghi d?n em th?

Miku is waving, start shaking >:(



*/


typedef long long ll ;
const ll mk = 100055;
const ll logn  = 29;
const ll mod = 1e9 + 7;

#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define mp make_pair
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define Miku_singing     god_shaking
#define a_Miku           cho_doi_bot_ngu

vector <ll> Pr;
ll d[mk + 5];

unordered_map <ll,ll> occurance;
 
unordered_map <ll,pii> cnt;


vector < pii > Rev; 


void Sieve()   // i dont know why my previous sieve goes tle TvT
{
    vector<bool> prime(mk + 5 , 1);
  
    for (ll i=3; i * i <=mk; i+=2) 
    { 
        if (prime[i] == true) 
        { 
            for (ll j = i * i ; j <=mk; j += 2*i)  prime[j] = false; 
        } 
    } 
  
    Pr.push_back(2);
    for (ll p=3; p<=mk; p+=2) if (prime[p]) Pr.push_back(p);
}
inline pair<ll,ll> root(ll x)     // find the root of x
{
    ll val=1,reverse_val=1;
    for (ll i: Pr)
    {
        if(i*i>x) break;
        if(x%i==0)
        {
            ll num=0;
            while(x%i==0)
            {
                num++;
                x/=i;
            }
            num%=3;
            for(ll j = 0 ; j < num ; j++) val *= i;
            if(num == 1 || num == 2)for(ll j = 0 ; j < 3 - num; j++) reverse_val *= i;
        }
    }
    if(x>1)
    {
        
        // x must be a prime 
    	ll num = 1; 
    	for(ll i = 0 ; i < num; i++) val *= x; 
    	for(ll i = 0 ; i < 3 - num ; i++) reverse_val *= x; 
    }
    return mp(val,reverse_val);
}
  

void solve()
{
    Sieve();
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        ll x; cin >> x; 
        if(cnt.count(x)==0)
        {
            pair<ll,ll> cur= root(x);
            Rev.push_back(cur);
            cnt[x]=cur;
        }
        else
            Rev.push_back(cnt[x]);
            occurance[Rev.back().first]++;
    }
    ll ans=0;
    if(occurance[1]>=1) ans++;
    for (ll i = 0; i < n; i++)
    {
    	
        ll value = Rev[i].first;
        ll cur_val = occurance[value];
        if(cur_val==0) continue;
        if(value==1) continue;
        ll rever = Rev[i].second;
        ans += max(cur_val, occurance[rever]);
        occurance[rever]=0;
        occurance[value]=0;
       /// cout <<  " Miku huhuhu"
    }
    cout << ans << endl;
}
 
signed main()
{
    solve();
}


Measured memory_bytes: 18752
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 5005;
int n, z[MAX_N];
char s[MAX_N];
void input() {
    RI(n);
	scanf("%s", s);
}

// void calz(int a) {
// 	int x=a, y=a;
// 	for(int i=a; i<n; i++) z[i]=0;
// 	for(int i=a+1; i<n; i++) {
// 		z[i]=max(0, min(z[i-x], y-i+1));
// 		while(i+z[i]<n && s[a+z[i]]==s[i+z[i]]) {
// 			x=i; y=i+z[i]; z[i]++;
// 		}
// 	}
// }

void calz() {
	int x=0, y=0;
	for(int i=0; i<n; i++) z[i]=0;
	for(int i=1; i<n; i++) {
		z[i]=max(0, min(z[i-x], y-i+1));
		while(i+z[i]<n && s[z[i]]==s[i+z[i]]) {
			x=i; y=i+z[i]; z[i]++;
		}
	}
}

void solve() {
	int ans = 0;
	// REP(i, n) {
	// 	calz(i);
	// 	for(int j=i+1; j<n; j++) {
	// 		ans = max(ans, min(j-i, z[j]));
	// 	}
	// }

	while(n > 0) {
		calz();
		for(int j=0; j<n; j++) {
			ans = max(ans, min(j, z[j]));
		}
		n--;
		for (int i = 0; i < n; i++)
			s[i] = s[i + 1];
	}

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

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


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

int main() {
//	cout<<"GfG!";
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=3;i++)
    {
        if(i!=a&&i!=b)
        {
            cout<<i;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi(i,a,b) for (int i=a; i<=b; ++i)
#define fid(i,a,b) for (int i=a; i>=b; --i)
#define pp pair<int,int>
#define f first
#define s second
#define DAVu "Frog2"
#define maxn 100005
using namespace std;
int n, a[maxn], l[maxn], k ;
int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(NULL); cout.tie(NULL) ;
    //freopen(DAVu".inp", "r", stdin) ;
    //freopen(DAVu".out", "w", stdout) ;
    cin >> n >> k ;
    fi(i,1,n) cin >> a[i];
    fi(i,1,n) l[i] = 1e9 ;
    l[1] = 0 ;
    fi(i,2,n)
    fi(j,max(1,i-k),i-1)
        l[i] = min(l[i], l[j]+abs(a[j] - a[i])) ;
    cout << l[n] ;
}


Measured memory_bytes: 4416
#include <stdio.h>
#include <algorithm>
#define  NUM 300000

using namespace std;

bool MS_prime_number[NUM];

void set_prime_number(bool* array) {

  fill(array, array + NUM, true);
  array[0] = array[1] = false;
  for (int i = 2; i < NUM; i++) {
    if (!array[i])
      continue;
    for (int j = i * 2; j < NUM; j += i) {
      array[j] = false;
    }
  }

}

void set_MonSat_prime_number(bool* array) {

  fill(array, array + NUM, true);
  array[0] = array[1] = false;
  for (int i = 2; i < NUM; i++) {
    if (i % 7 == 1 || i % 7 == 6) {
      if (!array[i])
        continue;
      for (int j = i * 2; j < NUM; j += i) {
        array[j] = false;
      }
    } else {
      array[i] = false;
    }
  }
}

int main() {

  int input;

  set_MonSat_prime_number(MS_prime_number);

  scanf("%d", &input);
  while (input != 1) { //
    printf("%d:", input);
    for (int i = 2; i <= input; i++) {
      //if (input % MS_prime_number[i] == 0) {
      if (MS_prime_number[i] && input % i == 0) {
        printf(" %d", i);
      }
    }
    printf("\n");

    scanf("%d", &input); //
  } //

  return 0; //
}

Measured memory_bytes: 1320
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int max_N = 2e5 + 10;
const ll inf = 1e17 + 42;
int A[max_N];
ll pref[max_N];

ll rsq(int i, int j);
ll spdiff(int L, int R, int sp);
ll s3diff(int sp1, int sp2, int sp3);

int N;
int main() {
    cin_desync();

    cin >> N;

    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        pref[i] = pref[i - 1] + A[i];
    }

    int fsplit = 1, tsplit = 3;
    ll best = inf;
    for (int msplit = 2; msplit <= N - 2; ++msplit) {
        while (fsplit < msplit &&
               spdiff(1, msplit, fsplit + 1) < spdiff(1, msplit, fsplit)) {
            ++fsplit;
        }

        tsplit = max(tsplit, msplit + 1);
        while (tsplit < N && spdiff(msplit + 1, N, tsplit + 1) <
                                 spdiff(msplit + 1, N, tsplit)) {
            ++tsplit;
        }

        best = min(best, s3diff(fsplit, msplit, tsplit));
    }

    cout << best << endl;
}

ll rsq(int i, int j) { return (pref[j] - pref[i - 1]); }

ll spdiff(int L, int R, int sp) {
    ll lsum = rsq(L, sp);
    ll rsum = rsq(sp + 1, R);

    return abs(lsum - rsum);
}

ll s3diff(int sp1, int sp2, int sp3) {
    vector<ll> temp = {rsq(1, sp1), rsq(sp1 + 1, sp2), rsq(sp2 + 1, sp3),
                       rsq(sp3 + 1, N)};
    sort(temp.begin(), temp.end());

    return (temp.back() - temp.front());
}


Measured memory_bytes: 2560
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
char s[100007];
int get[128];
int main()
{
    get['b'] = 0 , get['p'] = 1 , get['d'] = 2 , get['q'] = 3;
    scanf("%s",s+1); 
    for(int l = strlen(s+1), i = 1; i <= (l>>1) + 1; ++i)
    {
        if(get[s[i]]^((get[s[l-i+1]]+2)%4)) 
            return printf("No\n"),0;
    } 
    return printf("Yes\n"),0;
}

Measured memory_bytes: 256
import sys
x, y = map(int, input().split())
if x==1 and y==1:
    print(1000000)
    sys.exit()

def f(a):
    if a == 1:
        return 300000
    elif a == 2:
        return 200000
    elif a == 3:
        return 100000
    else:
        return 0

ans = f(x) + f(y)
print(ans)


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

void main_()
{
    ll N;
    cin >> N;
    array<ll, 3> hats = {};

    ll ans = 1;
    for (ll i = 0; i < N;i++){
        ll A;
        cin >> A;
        auto n = count(begin(hats), end(hats), A);
        ans = ans * n % ((ll)1e9 + 7);
        auto it = find(begin(hats), end(hats), A);
        (*it)++;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(void){
    string s;
    stack<int> st;
    while(cin>>s){
        if(s=="+"||s=="-"||s=="*"){
            int a,b;
            a=st.top();
            st.pop();
            b=st.top();
            st.pop();
            if(s=="+"){
                st.push(a+b);
            }else if(s=="-"){
                st.push(b-a);
            }else st.push(a*b);
        }
        else{
            int num=stoi(s);
            st.push(num);
        }
    }
    cout<<st.top()<<endl;
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  double l;
  cin >> l;
  double a=l/3;
  double ans=a*a*a;
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(void) {
  int a, b;
  std::cin >> a >> b;
  
  if(a <= 0 && b >= 0) {
    std::cout << "Zero" <<std::endl;
  } else if(a > 0 && b > 0) {
    std::cout << "Positive" <<std::endl;
  } else if(a < 0 && b < 0 && (b - a + 1) % 2 == 0) {
    std::cout << "Positive" <<std::endl;
  } else {
    std::cout << "Negative" <<std::endl;    
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys
import copy

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [INT() for _ in range(N)]

A.sort()
#print(A)

cur = 0
while cur < len(A) and not sum(A)%10:
	#print(cur)
	if not A[cur] % 10:
		cur += 1
		continue
	A.pop(cur)
	#print(A)

print(sum(A) if sum(A)%10 else 0)

Measured memory_bytes: 3436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

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

		while (true) {

			int n = Integer.parseInt(br.readLine());

			if (n == 0)
				break;

			ArrayList<ArrayList<Edge>> edges = new ArrayList<>();

			for (int i = 0; i < n; i++) {
				edges.add(new ArrayList<>());
			}

			double x[] = new double[n];
			double y[] = new double[n];
			double z[] = new double[n];
			double r[] = new double[n];

			for (int i = 0; i < n; i++) {
				String str[] = br.readLine().split(" ");
				x[i] = Double.parseDouble(str[0]);
				y[i] = Double.parseDouble(str[1]);
				z[i] = Double.parseDouble(str[2]);
				r[i] = Double.parseDouble(str[3]);
			}

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					double dist = Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])
							+ (z[i] - z[j]) * (z[i] - z[j]));

					dist = dist - (r[i] + r[j]);
					if (dist < 0)
						dist = 0;
					
					edges.get(i).add(new Edge(j, dist));
					edges.get(j).add(new Edge(i, dist));
				}
			}

			double sum = prime(edges, n);
			System.out.println(String.format("%.3f", sum));
		}
	}

	static double prime(ArrayList<ArrayList<Edge>> edges, int n) {
		boolean[] done = new boolean[n];

		Queue<Edge> q = new PriorityQueue<Edge>();
		q.add(new Edge(0, 0));

		double totalCost = 0;
		while (!q.isEmpty()) {
			Edge e = q.poll();
			if (done[e.to]) {
				continue;
			}

			done[e.to] = true;
			totalCost += e.cost;
			q.addAll(edges.get(e.to));
		}

		return totalCost;
	}
}

class Edge implements Comparable<Edge> {

	int to;
	double cost;

	public Edge(int to, double cost) {
		this.to = to;
		this.cost = cost;
	}

	@Override
	public int compareTo(Edge e) {
		if (this.cost > e.cost)
			return 1;
		else if (this.cost < e.cost)
			return -1;

		return 0;
	}
}


Measured memory_bytes: 40860
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
typedef long long ll;

int memo[9][9];
int n;
int cnt;


int dfs() {
	//cnt++;
	int w = 0, l = 0;
	for (int i = 0; i < n; i++) {
		w = 0, l = 0;
		for (int j = 0; j < n; j++) {
			if (memo[i][j] == -1) l++;
			if (memo[i][j] == 1) w++;

		}
		if (w > n / 2 || l > n / 2) return 0;
	}
	int x = -1, y = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (memo[i][j] == 0) {
				x = i, y = j;
				break;
			}
		}
		if (x != -1) break;
	}
	if (x == -1) return 1;
	//cerr << cnt << " " << x << " " << y << endl;

	
	int ret = 0;
	int win = 0, lose = 0;
	for (int i = 0; i < n; i++) {
		if (memo[x][i] == 1) win++;
		if (memo[x][i] == -1) lose++;
	}
	if (win > (n - 1) / 2 || lose > (n - 1) / 2) return 0;


	if (win < (n - 1) / 2) {
		memo[x][y] = 1;
		memo[y][x] = -1;
		ret += dfs();
		memo[x][y] = 0;
		memo[y][x] = 0;
	}
	if (lose < (n - 1) / 2) {
		memo[x][y] = -1;
		memo[y][x] = 1;
		ret += dfs();
		memo[x][y] = 0;
		memo[y][x] = 0;
	}
	return ret;



}


int main() {
	vector<int> v;
	while (cin >> n) {
		if (n == 0) break;
		int m;
		cin >> m;
		for (int i = 0; i < 9; i++)for (int j = 0; j < 9; j++) {
			memo[i][j] = 0;
		}
		for (int i = 0; i < n; i++) memo[i][i] = 4;


		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			x--, y--;
			memo[x][y] = 1;
			memo[y][x] = -1;
		}
		cnt = 0;
		int ans = dfs();
		cout << ans << endl;
		v.push_back(ans);
	}
	//cerr << endl;
	//for (auto i : v) cout << i << endl;
}


Measured memory_bytes: 3104
a = input().split(' ')
a[0] = int(a[0])
a[1] = int(a[1])

if (a[0] == 1): a[0] += 99
if (a[1] == 1): a[1] += 99

if (a[0] == a[1]): print("Draw")
elif (a[0]) > a[1]: print("Alice")
else: print("Bob")


Measured memory_bytes: 9176