akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char c[MAXN];

void solve(){
	int n;
	scanf("%s", &c[0]);
	n = strlen(c);
	int cnt = 0;
	int fl = 0;
	REP(i, 1, n - 1){
		if (c[i - 1] != c[i + 1]){
			fl = 1;
			break;
		}
	}
	if (!fl){
		printf("Second\n");
		return;
	}
	if ((n + (c[0] == c[n - 1])) % 2 == 1){
		printf("First\n");
	} else {
		printf("Second\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
double x[110];
double y[110];
double r[110];
double xz[210];
double yz[210];
int s[210][210];
int main(){
	int a;
	int T=0;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf%lf",x+i,y+i,r+i);
		for(int i=0;i<a;i++){
			xz[i*2]=x[i]-r[i];xz[i*2+1]=x[i]+r[i];
			yz[i*2]=y[i]-r[i];yz[i*2+1]=y[i]+r[i];
		}
		std::sort(xz,xz+a*2);
		std::sort(yz,yz+a*2);
		for(int i=0;i<210;i++)for(int j=0;j<210;j++)
			s[i][j]=0;
		for(int i=0;i<a;i++){
			int X1=lower_bound(xz,xz+a*2,x[i]-r[i])-xz;
			int X2=lower_bound(xz,xz+a*2,x[i]+r[i])-xz;
			int Y1=lower_bound(yz,yz+a*2,y[i]-r[i])-yz;
			int Y2=lower_bound(yz,yz+a*2,y[i]+r[i])-yz;
			s[X1][Y1]++;s[X1][Y2]--;s[X2][Y1]--;s[X2][Y2]++;
		}
		for(int i=0;i<210;i++){
			for(int j=1;j<210;j++)s[i][j]+=s[i][j-1];
		}
		for(int i=0;i<210;i++){
			for(int j=1;j<210;j++)s[j][i]+=s[j-1][i];
		}
		
		double ret=0;
		for(int i=0;i<210;i++)for(int j=0;j<210;j++)if(s[i][j])
			ret+=(xz[i+1]-xz[i])*(yz[j+1]-yz[j]);
		printf("%d %.2f\n",++T,ret);
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A,B;
    cin >> A >> B;
    if(A ==1 && B == 2){
        cout << 3 << endl;
    } else if(A == 2 && B == 3){
        cout << 1 << endl;
    } else if(A ==1 && B == 3){
        cout << 2 << endl;
    } else if(A == 2 && B == 1){
        cout << 3 << endl;
    } else if(A == 3 && B == 1){
        cout << 2 << endl;
    } else if(A == 3 && B == 2){
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N;
	cin >> N;
	vector<int> a(N), res(N);
	priority_queue<pair<int,int>> Q;
	Q.push(make_pair(0,0));
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
		Q.push(make_pair(a[i], N - i));
	}
	int idx = Q.top().second, t = Q.top().first, cnt = 1;
	Q.pop();
	while(!Q.empty()) {
		if(idx >= Q.top().second) {
			res[N - idx] += (t - Q.top().first) * cnt;
			t = Q.top().first;
			++cnt;
			Q.pop();
		} else {
			res[N - idx] += (t - Q.top().first) * cnt;
			t = Q.top().first;
			++cnt;
			idx = Q.top().second;
			Q.pop();
		}
	}
	for(int i = 0; i < N; ++i) {
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4464
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> m;
  if(n==m){
    cout << "Yes"<<endl;
  }
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;

int main(){
	scanf("%ld", &n);
	printf("%ld\n", (n-2)*180);
	return 0;
}


Measured memory_bytes: 888
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  A=bisect.bisect_left(a,b[i])
  B=bisect.bisect_right(c,b[i])
  ans=ans+A*(n-B)
print(ans)
          

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

int main(){
  int n;
  cin>>n;
  int arr[100];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  sort(arr,arr+n);
  int sum=0,ans=0;
  for(int i=n-1;i>=0;i=i-2)
  {
    sum+=arr[i];
  }
  for(int j=n-2;j>=0;j=j-2)
  {
    ans+=arr[j];
  }
  cout<<abs(sum-ans)<<endl;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    dsu D(N);
    for (int i = 0; i < Q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t) cout << D.same(u, v) << "\n";
        else D.merge(u, v);
    }
}

Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e5 + 5;
const long oo = 1e15;

string s;

void Solve() {
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> s;
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 3652
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define nl              "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)           (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)        cout << #x << " = " << x << endl
#define trace(x)        cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //for storing unique elements
typedef tree<int , null_type , less_equal<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set; //for repeating elements
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void babuBhaiya()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int n; cin>>n;
	vi v(n); fo(i,n) cin>>v[i];
	vi pref(n+1,0);
	pref[0] = v[0];
	for(int i = 1;i<n;i++){
		pref[i] = pref[i-1] + v[i];
		pref[i] %= mod;
	}
	int ans = 0;
	for(int i = n-1;i>=1;i--){
		ans = (ans%mod + v[i]%mod*pref[i-1]%mod)%mod;
	}
	cout<<ans;
}

 
int32_t main()
{
    babuBhaiya();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {
    ll N, K, ans = 0;
    cin >> N >> K;

    vector<ll>p(N);

    rep(i, N) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    rep(i, K) {
        ans += p[i];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3176
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;
LL n,m,x,y,z,a[9][1010],ans,cnt;
LL abb(LL nnn){
	if(nnn>=0){
		return nnn;
	}else{
		return 0-nnn;
	}
}
int main(){
	cin>>n>>m;
	for(LL i=0;i<n;i++){
		cin>>x>>y>>z;
		a[1][i]=(x)+(y)+(z);
		a[2][i]=(x)+(y)+(0-z);
		a[3][i]=(x)+(0-y)+(z);
		a[4][i]=(0-x)+(y)+(z);
		a[5][i]=(x)+(0-y)+(0-z);
		a[6][i]=(0-x)+(y)+(0-z);
		a[7][i]=(0-x)+(0-y)+(z);
		a[8][i]=(0-x)+(0-y)+(0-z);
	}
	sort(a[1],a[1]+n);
	sort(a[2],a[2]+n);
	sort(a[3],a[3]+n);
	sort(a[4],a[4]+n);
	sort(a[5],a[5]+n);
	sort(a[6],a[6]+n);
	sort(a[7],a[7]+n);
	sort(a[8],a[8]+n);
	for(LL i=1;i<=8;i++){
		cnt=0;
		for(LL j=n-1;n-j<=m;j--){
			cnt+=a[i][j];
		}
		if(cnt>ans){
			ans=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int main(){
  
  int i,j,n1,n2,ans=0,flag=0;
  int arr1[MAX],arr2[MAX];

  
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&arr1[i]);
  }

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&arr2[i]);
  }

  for(i=0;i<n2;i++){
    for(j=0;j<n1;j++){
      if(arr2[i]==arr1[j]){
	flag = 1;
	ans++;
	if(flag = 1){
	  break;
	}
      }
    }
  }
 


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

  return 0;
}

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

int main() {
  int k;
  scanf("%d", &k);
  if (k == 1)
    return 0 * puts("1\n1");
  int n = (k + 3) / 4 * 2;
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int color = (i + j) % n;
      if (i % 2 == 1 && color + n < k)
        color += n;
      printf("%d\t", color + 1);
    }
    puts("");
  }
}


Measured memory_bytes: 1152
N,M = map(int,input().split())

Lli = []
Rli =[]
for i in range(M):
    tmp = list(map(int,input().split()))
    Lli.append(tmp[0])
    Rli.append(tmp[1])

print(max(min(Rli)-max(Lli)+1,0))

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll a,b,c;
	bool res = 0;
	cin >> a>>b>>c;
	if (a == b || b == c || c == a) {
		res = 1;
	}
	if (a == b&&b == c) {
		res = 0;
	}
	if (res) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return(0);
}

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

const int maxn = 100005;
int par[maxn];

void init() {
	for (int i = 0; i < maxn; i++) {
		par[i] = i;
	}
}

int find(int x) {
	while (par[x] != x) x = par[x];
	return par[x];
}

int main() {
	//freopen("aoj2170.txt", "r", stdin);
	while (1) {
		int n, q;
		scanf("%d%d", &n, &q);
		if (n == 0) break;

		//init();
		par[1] = 1;
		for (int i = 1; i < n; i++) {
			int t;
			scanf("%d", &t);
			par[i+1] = t;
		}

		long long res = 0;
		for (int i = 0; i < q; i++) {
			char c;
			int t;
			getchar();
			scanf("%c%d", &c, &t);
			if ('Q' == c) {
				res += find(t);
			} else {
				par[t] = t;
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 1420
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <limits.h>
using namespace std;

int N, A, B, C;
vector<int> bamboo;
map<int, int> m;

int rec(int a, int b, int c, int index, int mp, int use)
{
    if (index == bamboo.size())
    {
        if (use == 0b111)
        {
            return abs(A - a) + abs(B - b) + abs(C - c) - 30 + mp;
        }
        else
        {
            return INT_MAX;
        }
    }

    int first = bamboo[index];

    int ans1 = rec(a, b, c, index + 1, mp, use);
    int ans2 = rec(a + first, b, c, index + 1, mp + 10, use | 0b100);
    int ans3 = rec(a, b + first, c, index + 1, mp + 10, use | 0b010);
    int ans4 = rec(a, b, c + first, index + 1, mp + 10, use | 0b001);

    return min({ans1, ans2, ans3, ans4});
}

int main()
{
    cin >> N >> A >> B >> C;

    for (int i = 0; i < N; i++)
    {
        int bi;
        cin >> bi;
        bamboo.push_back(bi);
    }

    cout << rec(0, 0, 0, 0, 0, 0) << endl;
}

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

int main()
{
	int currStreak = 0, maxStreak = 0;
	
	string s;
	cin >> s;
	
	for(int i = 0; i < (int)(s.length()); i++)
	{
		if(s[i] == 'R')
		{
			currStreak++;
		}
		
		else
			currStreak = 0;
			
		maxStreak = max(maxStreak, currStreak);
	}
	
	printf("%d", maxStreak);
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	double a, b, x; cin >> a >> b >> x;
	x /= a;
	if ((a * b)/2 > x) {
		a = x * 2 / b;
		double ans = atan(b/a) * 180 / M_PI;
		cout << fixed << setprecision(10) << ans << "\n";
	}
	else {
		x = a * b - x;
		b = 2 * x / a;
		double ans = 90 - atan(a / b) * 180 / M_PI;
		cout << fixed << setprecision(10) << ans << "\n";
	}



	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int H,W;
char grid[1010][1010];
int dp[1010][1010];


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W;
    REP(i,H) REP(j,W) cin>>grid[i][j];

    dp[0][0] = 1;
    REP(i,H) REP(j,W){
        if(i+1<H && grid[i+1][j]=='.') add(dp[i+1][j],dp[i][j]);
        if(j+1<W && grid[i][j+1] == '.') add(dp[i][j+1],dp[i][j]);
    }
    cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::vector<int> v(3);
std::cin >> v[0]>>v[1]>>v[2];
sort(rall(v));
std::cout << v[0]*10+v[1]+v[2] << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        if (inp[0] % inp[1] == 0) {
            WriteLine(0);
        } else {
            WriteLine(1);
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int a[200010],b[200010];
int main(){
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	scanf("%d",&m);
	for(int i=0;i<m;i++)scanf("%d",b+i);
	a[n]=b[m]=2e9;
	for(int i=0,j=0;i!=n||j!=m;){
		if(a[i]<b[j])i++;
		else if(a[i]>b[j])j++;
		else printf("%d\n",a[i]),i++,j++;
	}
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int arr[105][100006];
    int N,W;
    cin>>N>>W;
    int v[N];
    int w[N];
    for(int i=0;i<N;i++)
    {
        cin>>w[i]>>v[i];
    }
    
    for(int i=0;i<=N;i++)
    {
        for(int j=0;j<=W;j++)
        {
            if(i==0 || j==0)
            {
                arr[i][j]=0;
                continue;
            }
            
            if(w[i-1]>j)
            { 
                arr[i][j]=arr[i-1][j];
            }
            else
            {
                arr[i][j]=max(arr[i-1][j],arr[i-1][j-w[i-1]]+v[i-1]);
                
            }
        }
    }
    cout<<arr[N][W];
}


Measured memory_bytes: 81024
n,m = list(map(int, input().split()))
i = list(map(int, input().split()))
k=[0]*n
ans=0
for j in range(m):
   
    a,b = list(map(int, input().split()))
    a-=1
    b-=1
    if i[a]==i[b]:
        k[a]+=1
        k[b]+=1
        
    else:
        if i[b]>i[a]:
            k[a]+=1
        else:
            k[b]+=1
            
for w in range(n):
    if k[w]==0:
        ans+=1
print(ans)

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long K) {

    int m = 0;
    for(int i = 1 ; i <= K ; i++){
        m = (m * 10 + 7) % K;
        if( m == 0 ){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  solve(K);
  return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
	double x1,x2,y1,y2,p;
	cin>>x1>>y1>>x2>>y2;
	
	x1=x2-x1;
	y1=y2-y1;
	
	x1=sqrt(x1*x1+y1*y1);
	
	cout<<setprecision(10)<<x1<<endl;
		
	return 0;
}         

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

    long long sum = 0;

    rep(i,n + 1){
        if((i % 3 == 0) || (i % 5 == 0)) continue;
        else sum += i;
    }
    
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

bool _less(string &s, string &t) {
	if(s.size()<t.size())
		return true;
	return s<=t;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string N; cin>>N;
	int K; cin>>K;
	int n=N.size();
	if(K==1) {
		int ret=0;
		for (int l=1; l<=n; l++) {
			for (char ch='1'; ch<='9'; ch++) {
				string cur=string(l,'0');
				cur[0]=ch;
				if(_less(cur,N))
					ret++;
			}
		}
		cout<<ret<<"\n";
	} else if(K==2) {
		int ret=0;
		for (int l=1; l<=n; l++) {
			string cur=string(l,'0');
			for (char ch='1'; ch<='9'; ch++) {
				string cur=string(l,'0');
				for (int i=1; i<l; i++) for (char ch2='1'; ch2<='9'; ch2++) {
					cur[0]=ch; cur[i]=ch2;
					if(_less(cur,N))
						ret++;
					cur[0]='0'; cur[i]='0';
				}
			}
		}
		cout<<ret<<"\n";
	} else {
		int ret=0;
		for (int l=1; l<=n; l++) {
			string cur=string(l,'0');
			for (char ch='1'; ch<='9'; ch++) {
				for (int i=1; i<l; i++) for (char ch2='1'; ch2<='9'; ch2++) {
					for (int j=i+1; j<l; j++) for (char ch3='1'; ch3<='9'; ch3++) {
						cur[0]=ch; cur[i]=ch2; cur[j]=ch3;
						if(_less(cur,N))
							ret++;
						cur[0]='0'; cur[i]='0'; cur[j]='0';
					}
				}
			}
		}
		cout<<ret<<"\n";
	}
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  
  int near = 999;
  rep(i, 0, s.size()-2) {
    int p = (s.at(i) -'0')*100 +(s.at(i+1) - '0')*10 + (s.at(i+2) - '0');
    near = min(abs(753 -p), near);
  }
  
  cout << near << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, M; cin >> N >> M;
  vector<int> cnt(N);
  for (int i = 0; i < M; i++) {
    int p, q; cin >> p >> q; p--; q--;
    cnt.at(p)++;
    cnt.at(q)++;
  }
  for (int i = 0; i < N; i++) {
    if (cnt.at(i) % 2 == 1) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}



Measured memory_bytes: 640
S = input()
mod = 10**9+7

dp = [[0 for j in range(13)] for i in range(len(S)+1)]
dp[0][0] = 1
for i in range(1, len(S)+1):
    s = S[i-1]

    if s == "?":
        for s in range(10):
            for j in range(13):
                dp[i][(10 * j + s) % 13] += dp[i - 1][j]
                dp[i][(10 * j + s) % 13] %= mod
    else:
        s = int(s)
        for j in range(13):
            dp[i][(10*j+s)%13] += dp[i-1][j]
            dp[i][(10*j+s)%13] %= mod
print(dp[len(S)][5])

Measured memory_bytes: 66140
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
ll a[100500], b[100500];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (i == 0 && x != 0) {
            cout << 0 << endl;
            return 0;
        }
        a[x]++;
    }
    if (a[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] > 0) {
            for (int j = 0; j < a[i]; j++) {
                ans = ans * a[i-1] % MOD;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll n,m,k; cin>>n>>m>>k;
	vector<ll> a(n+1),b(m+1);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1; i<=m; i++) {
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll anss=0;
	for(int i=0; i<=n; i++) {
		ll now=a[i];
		//	cout<<i<<" "<<now<<endl;
		if(now>k) {
			continue;
		}
		else{
			int l=0;
			int r=m;
			ll ans=0;
			while(l<=r) {
				int mid=(l+r)/2;
				if(now+b[mid]<=k) {
					ans=mid;
					l=mid+1;
				}
				else{
					r=mid-1;
				}
			}
			//cout<<i<<" "<<ans<<endl;
			anss=max(anss,ans+i);
		}
	}
	cout<<anss<<endl;

	return 0;
}


Measured memory_bytes: 6356
#include <iostream>
using namespace std;
int a[10];

bool func(int b,int c,int i){
	if (a[i]>b&&a[i]>c){
		if (b>c) {
			b=a[i];
		}
		else {
			c=a[i];
		}
	}
	else if(!(a[i]>b||a[i]>c)) {
		return false;
	}
	else {
		b>c?c=a[i]:b=a[i];
	}
	if (i==9) {
		return true;
	}
	if (func(b,c,i+1)) {
		return true;
	}
	return false;
}


		

int main () {
	int N;
	cin>>N;
	for (int i=0; i<N; i++) {
		for (int j=0; j<10; j++) {
			cin>>a[j];
		}
		if (func(0,0,0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		
	}
	
	
}

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

double sqre(double x,double y,double h)
{
	double r = 0;
	r = ((x + y)*h) / 2;
	return r;
}
int main()
{
	double a, b, c;
	cin >> a >> b >> c;
	cout << sqre(a, b, c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=3005;
const int MOD=1000000007;

int n,k,tot,a[N],f[N];

int ksm(int x,int y)
{
	int ans=1;
	while (y)
	{
		if (y&1) ans=(LL)ans*x%MOD;
		x=(LL)x*x%MOD;y>>=1;
	}
	return ans;
}

int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i*i<=n;i++)
		if (n%i==0)
		{
			a[++tot]=i;
			if (i*i<n) a[++tot]=n/i;
		}
	sort(a+1,a+tot+1);
	int ny2=ksm(2,MOD-2),ans=0;
	for (int i=1;i<=tot;i++)
	{
		f[i]=ksm(k,(a[i]+1)/2);
		for (int j=1;j<i;j++)
			if (a[i]%a[j]==0) (f[i]+=MOD-f[j])%=MOD;
		if (a[i]&1) (ans+=(LL)f[i]*a[i]%MOD)%=MOD;
		else (ans+=(LL)f[i]*a[i]%MOD*ny2%MOD)%=MOD;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n[34] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d\n", n[k-1]);
  return 0;
}


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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

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

	cout << 180*(a-2) << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

score = 0
bullet = K
if A >= bullet:
    print(bullet)
    exit()
else:
    score += A
    bullet -= A



if B >= bullet:
    print(score)
    exit()
else:
    bullet -= B
    pass
  
if C >= bullet:
    print(score - bullet)
    exit()
else:
    exit()

Measured memory_bytes: 9192
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <unordered_map>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

void no(){
	cout<<"NO"<<endl;
	exit(0);
}


void yes(){
	cout<<"YES"<<endl;
	exit(0);
}


string solve(){
	long long A,B,C,D;
	cin>>A>>B>>C>>D;

	if (A < B) return "No";
	if (D < B) return "No";
	if (C >= B) return "Yes";

	long long up = D % B;
	if (up == 0) up = B;
	long long ops = __gcd(B, up);
	//cout<<ops<<endl;

	long long sis = A % B;
	long long kur = C - sis;
	long long boy = kur / ops;
	long long naek = sis + (boy + 1) * ops;
	//cout<<sis<<" "<<naek<<endl;
	if (sis > C) return "No";
	if (naek > C && naek < B) return "No";
	return "Yes";

	int bzz = B;
	while(bzz--){
		long long sisa = A % B;
		//cout<<sisa<<endl;
		if (sisa > C) return "No";
		A = sisa + D;
	}
	return "Yes";
	//if (D >= B) return "Yes";


}
int main(){
	int T;
	ios_base::sync_with_stdio(false);
	cin>>T;
	while(T--) {
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

//#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

//const int inf=1e18,M=1e9+7;
const int N=2e5+10;

vector<int> v[N],clr[2],numbers[3];
vector<int> ans(N);

void dfs(int x,int p,int d)
{
    clr[d].pb(x);
    for(auto c:v[x])
    {
        if(c!=p)
            dfs(c,x,1-d);
    }
}

void solve()
{
    int n;
    cin>>n;

    int a,b;
    for(int i=0;i<n-1;++i)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    dfs(1,-1,0);

    for(int i=1;i<=n;++i)
        numbers[i%3].pb(i);

    if(clr[0].size()>clr[1].size())
        swap(clr[0],clr[1]);

//    show(clr[0]);
//    show(clr[1]);

    if(clr[0].size()>=numbers[1].size() && clr[1].size()>=numbers[2].size())
    {
        for(int i=0;i<2;++i)
        {
            for(auto c:clr[i])
            {
                if(numbers[i+1].size())
                {
                    ans[c]=numbers[i+1].back();
                    numbers[i+1].pop_back();
                }
                else
                {
                    ans[c]=numbers[0].back();
                    numbers[0].pop_back();
                }
            }
        }
    }
    else
    {
        for(int i=0;i<2;++i)
        {
            for(auto c:clr[i])
            {
                for(int j=0;j<3;++j)
                {
                    if(numbers[j].size())
                    {
                        ans[c]=numbers[j].back();
                        numbers[j].pop_back();
                        break;
                    }
                }
            }
        }
    }

    for(int i=1;i<=n;++i)
        cout<<ans[i]<<" ";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 22516
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int n, m;

struct unionfind {
  int parent;
  int node;
  int edge;
};
unionfind g[300001];

void init() {
  for (int i = 0; i <= n; i++) {
    g[i].parent = i;
    g[i].node = 1;
    g[i].edge = 0;
  }
}

int find(int x) {
  if (x == g[x].parent) {
    return x;
  }
  int res = find(g[x].parent);
  g[x].node = g[res].node;
  g[x].edge = g[res].edge;
  g[x].parent = res;
  return res;
}

void merge(int x, int y) {
  if (x > y) {
    x ^= y;
    y ^= x;
    x ^= y;
  }
  g[x].node += g[y].node;
  g[x].edge += g[y].edge + 1;
  g[y].parent = x;
}
int main() {
  int a, b, ans = 0;
  cin >> n >> m;
  init();
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a = find(a);
    b = find(b);
    if (a != b) {
      merge(a, b);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (g[i].parent == i) {
      ans = max(ans, g[i].node);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5980
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
//  cout<<fixed<<setprecision(1)<<1<<endl;
	int n;
	cin>>n;
	cout<<(n+1000-1)/1000*1000-n<<endl;
	return 0;
}

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

int main() {
    int n, temp, minj, swapNum = 0;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        v.push_back(temp);
    }
    for (int i = 0; i < n; i++) {
        minj = i;
        for (int j = i; j < n; j++) {
            if (v[j] < v[minj]) minj = j;
        }
        if (v[i] != v[minj]) {
            swap(v[i], v[minj]);
            swapNum++;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << v[i];
        if (i != n-1) cout << " ";
    }
    cout << endl << swapNum << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<char, int> cur;
    string str;
    cin >> str;
    for(int i=0; i<str.size(); i++) {
        cur[str[i]]++;
    }
    for(int n=1; n<N; n++) {
        cin >> str;
        map<char, int> tmp;
        for(int i=0; i<str.size(); i++) {
            if(cur[str[i]]>tmp[str[i]]) {
                tmp[str[i]]++;
            }
        }
        cur = tmp;
    }
    for(auto itr=cur.begin(); itr!=cur.end(); itr++) {
        for(int i=0; i<itr->second; i++) {
            cout << itr->first;
        }
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#define Max(a)max(a.first,a.second)
#define Min(a)min(a.first,a.second)
using namespace std;
long a[2<<17],ans=1e18,b,e,s[2<<17];
int n;
pair<long,long>f(int i,int j)
{
	long sum=(s[j]-s[i])/2+s[i];
	int k=upper_bound(s+i+1,s+j-1,sum)-s;
	long c=s[k]-s[i],d=s[j]-s[k];
	long ans=max(c,d)-min(c,d);
	pair<long,long>ret=make_pair(c,d);
	k--;
	if(k>=i+1)
	{
		c=s[k]-s[i];
		d=s[j]-s[k];
		if(ans>max(c,d)-min(c,d))
		{
			return make_pair(c,d);
		}
	}
	return ret;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i-1];
	for(int i=2;i<n-1;i++)
	{
		pair<long,long>a=f(0,i);
		pair<long,long>b=f(i,n);
		ans=min(ans,max(Max(a),Max(b))-min(Min(a),Min(b)));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  int l=0;
  vector<int>a(m);
  vector<int>b(m);
  vector<int>h(n);
  vector<int>s(n,1);
  for(int i=0;i<n;i++){
    cin >> h.at(i);  
  }
  for(int i=0;i<m;i++){
    cin >> a.at(i);   
    cin >> b.at(i);
  }
  for(int i=0;i<m;i++){
    if(h.at(a.at(i)-1)>h.at(b.at(i)-1)){
      s.at(b.at(i)-1)=0;
    }
    else if(h.at(a.at(i)-1)<h.at(b.at(i)-1)){
      s.at(a.at(i)-1)=0;
    }
    else{
      s.at(a.at(i)-1)=0;
      s.at(b.at(i)-1)=0;
    }
  }
  for(int i=0;i<n;i++){
  l+=s.at(i);
  }
  cout << l << endl;
}

Measured memory_bytes: 4844
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a>k)cout<< ":("<<endl;
    else cout<<"Yay!"<<endl;


    

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,k,a[200010],r[200010],ans;
map<int,vector<int>>v;
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	v[0].pb(-1);
	r[0]=a[0]-1;
	r[0]%=k;
	v[r[0]].pb(0);
	for(int i=1;i<n;i++){
		r[i]=r[i-1]+a[i]-1;
		r[i]%=k;
		v[r[i]].pb(i);
	}
	for(pair<int,vector<int>> pp:v){
		int i=pp.fi;
		for(int j=0;j<v[i].size();j++){
			int x=v[i][j];
			int p;
			if(v[i][v[i].size()-1]<=x+k-1)p=v[i].size();
			else p=upper_bound(all(v[i]),x+k-1)-v[i].begin();
			ans+=p-j-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int L, R;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin >> L >> R;
  int ans = 2019;
  for(int i = L; i <= min(R, L + 2018); i++) {
    for(int j = i + 1; j <= min(R, L + 2018); j++) {
      ans = min(ans, (i % 2019) * (j % 2019) % 2019);
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

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

    int ans = 0;
    for(int i=0; i<N; i++){
        ans++;
        int n = i;
        while(n + 1 < N && S[n+1] == S[i]){
            n++;
        }
        i = n;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
using namespace std;
const int inf = 1<<30;

int main() {
  int N; cin >> N;
  vector<int> X(N);
  for(int i = 0; i < N; i++) cin >> X[i];
  int ans = inf;
  for(int i = 0; i <= 100; i++) {
    int res = 0;
    for(int j = 0; j < N; j++) {
      res += (X[j] - i) * (X[j] - i);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// Created by CAD on 2020/4/18.
#include <bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define tst1(a) cout<<#a<<":"<<a<<endl
#define tst2(a, b) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl
#define tst3(a, b, c) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl
#define tst4(a, b, c, d) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl
#define lson (p<<1)
#define rson (p<<1|1)
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define ll long long
#define lowbit(i) (i&-i)
using namespace std;

bool judge(int x){
    while(x>0){
        if(x%10==7) return 1;
        x/=10;
    }
    return 0;
}
int main()
{
    int n;cin>>n;
    if(judge(n)) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3612
#include <vector>
#include <iostream>

int solve_impl(const std::vector<int> & a, int i, int c) {
  if(a.size() == c) {
    return -1;
  }

  const auto n { a[i - 1] };
  return (n == 2) ? c : solve_impl(a, n, c + 1);
}

int solve(const std::vector<int> & a) {
  return solve_impl(a, 1, 1);
}

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

  std::vector<int> a;
  for(int i = 0; i < n; ++i) {
    int ai;
    std::cin >> ai;
    a.push_back(ai);
  }

  std::cout << solve(a) << std::endl;
  return 0;
}



Measured memory_bytes: 892
function readInt(str) {
  return parseInt(str, 10);
}
function Main(raw: string) {
  const input = raw.split("\n");
  const [N]=input[0].split(" ").map(readInt);
  const H=input[1].split(" ").map(readInt);
  let count=0;
  let cur=0;
  for(let i=0;i<N;i++){
    if(cur<=H[i]){
      count++;
      cur=H[i];
    }
  }
  //出力
  console.log("%d", count);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}


int main() {
	int N; cin >> N;
	int a[110000];
	int s1 = 0, s4 = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			s4++;
		}
		if (a[i] % 2 == 1) {
			s1++;
		}
	}
	if (s1 + s4 == N) {
		if (s1 <= s4 + 1) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else if (s1 <= s4)cout << "Yes";
	else cout << "No";

}

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

int main()
{
    int x;
    cin >> x;
    if (400 <= x && x <= 599)
    {
        cout << 8 << endl;
    }
    else if (600 <= x && x <= 799)
    {
        cout << 7 << endl;
    }
    else if (800 <= x && x <= 999)
    {
        cout << 6 << endl;
    }
    else if (1000 <= x && x <= 1199)
    {
        cout << 5 << endl;
    }
    else if (1200 <= x && x <= 1399)
    {
        cout << 4 << endl;
    }
    else if (1400 <= x && x <= 1599)
    {
        cout << 3 << endl;
    }
    else if (1600 <= x && x <= 1799)
    {
        cout << 2 << endl;
    }
    else if (1800 <= x && x <= 1999)
    {
        cout << 1 << endl;
    }
    
    return 0;
}

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

using namespace std;

#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}
#define Pi acos(-1)
#define ll long long

int main()
{
    //INPUT_OUTPUT;
    int a, b;
    cin >> a >> b;
    if(a >= 0 && a <= 9 && b >= 0 && b <= 9) {
        cout << a*b << endl;
    }
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256