akhauriyash/Code-Regression huggingface dataset:
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps || (abs(goa - now_min) <= eps && (abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	long long ans = 0;
	vector<pair<int, char>> A;
	int cnt = 1;
	char b = s[0];
	for (int i = 1; i < s.length(); ++i) {
		if (s[i] == b) {
			cnt++;
		}
		else {
			A.push_back(make_pair(cnt, b));
			cnt = 1;
			b = s[i];
		}
	}
	A.push_back(make_pair(cnt, b));
	REP(i, A.size()) {
		ans += A[i].first - 1;
	}
	for (int i = 1; i < A.size(); i += 2) {
		if (i != A.size() - 1) ans++;
		ans++;
		k--;
		if (k == 0) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	string a="",b="";
	char c[2][2]={".","#"};
	while(1){
		bool h=false;
		rep(i,2)rep(j,2){
			string ta=a+(string)c[i],tb=b+(string)c[j];
			cout<<ta<<endl<<tb<<endl;
			string out;
			cin>>out;
			if(out=="T"){
				a=ta;b=tb;
				goto end;
			}
		}
		break;
		end:;
		if(a.size()==n)break;
	}
	if(a.size()!=n)while(1){
		bool h=false;
		rep(i,2)rep(j,2){
			string ta=(string)c[i]+a,tb=(string)c[j]+b;
			cout<<ta<<endl<<tb<<endl;
			string out;
			cin>>out;
			if(out=="T"){
				a=ta;b=tb;
				goto end1;
			}
		}
		break;
		end1:;
		if(a.size()==n)break;
	}
	cout<<a<<endl<<b<<endl;
}








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

using namespace std;


#define mod        1000000007
#define ft         first
#define sd         second
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define ll         long long int
#define db         long double
#define vbi        vector<bool> 
#define vlli       vector<long long int >
#define mp         make_pair
#define ms(x,v)    memset(x, v, sizeof x)
#define cnl        printf("\n");
#define fr(i,b)    for(ll i=0; i<=b; i++)
#define frr(i,b)   for(ll i=0;i<b;i++)
#define fb(i,b)    for(ll i=b-1; i>=0; i--)
#define PI         3.14159265
const int maxn=    100000;
ll i,j,k;
int main(){
  ll a,b;
  cin>>a>>b;
  ll c=a*b;
  ll d=a+b;
  ll e=a-b;
  ll f=max(c,d);
  f=max(e,f);
  cout<<f<<endl;





    return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  int32 n = s.size();
  int32 m = t.size();
  int32 ans = inf;
  REP(i,n-m+1){
    int32 cnt = 0;
    REP(j,m){
      if(s[i+j] != t[j])++cnt;
    }
    chmin(ans,cnt);
  }
  ANS(ans);
  return 0;
}

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

using namespace std;
#define ll long long int

int main()
{
    ll t;
    t = 1;
    //cin t;
    while (t--)
    {
        ll n, m, k;
        cin >> n >> m >> k;
        ll x, y, x1, y1;
        cin >> x >> y >> x1 >> y1;
        int dx[4] = {0, 0, -1, 1};
        int dy[4] = {-1, 1, 0, 0};
        char a[n][m];
        ll dist[n][m];
        bool visited[n][m];
        x--;
        y--;
        x1--;
        y1--;
        if (a[x1][y1] == '@')
        {
            cout << "-1" << endl;
            return 0;
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                dist[i][j] = INT_MAX;
                visited[i][j] = false;
                cin >> a[i][j];
            }
        }
        queue<pair<int, int>> q;
        q.push({x, y});
        visited[x][y] = true;
        dist[x][y] = 0;
        while (!q.empty())
        {
            pair<int, int> temp = q.front();
            q.pop();
            if(temp.first == x1 && temp.second == y1)
            break;
            for (int i = 0; i < 4; i++)
            {
                int x2 = temp.first;
                int y2 = temp.second;
                for (int j = 0; j < k; j++)
                {
                    x2 += dx[i];
                    y2 += dy[i];
                    if (x2 >= 0 && x2 < n && y2 >= 0 && y2 < m && a[x2][y2] != '@')
                    {
                        if (!visited[x2][y2])
                        {
                            visited[x2][y2] = true;
                            q.push({x2, y2});
                            dist[x2][y2] = 1 + dist[temp.first][temp.second];
                        }
                        else
                        {
                            if(dist[x2][y2] < 1 + dist[temp.first][temp.second])
                            break;
                            dist[x2][y2] = min((ll)dist[x2][y2], (ll)1 + dist[temp.first][temp.second]);
                        }
                            
                    }
                    else
                        break;
                }
            }
        }
        if (dist[x1][y1] == INT_MAX)
            cout << "-1" << endl;
        else
            cout << dist[x1][y1] << endl;
    }
}



Measured memory_bytes: 14004
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for(int i=0; i<n-1; ++i){
        if(s[i] == s[i+1]){
            cout << (i + 1) << ' ' << (i + 2) << endl;
            return 0;
        }
    }

    for(int i=0; i<n-2; ++i){
        if(s[i] == s[i+2]){
            cout << (i + 1) << ' ' << (i + 3) << endl;
            return 0;
        }
    }

    cout << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int x, y;
    cin >> x >> y;

    int ans = 0;
    if (x == 1) ans += 300000;
    if (x == 2) ans += 200000;
    if (x == 3) ans += 100000;
    if (y == 1) ans += 300000;
    if (y == 2) ans += 200000;
    if (y == 3) ans += 100000;
    if (x == 1 && y == 1) ans += 400000;

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

Measured memory_bytes: 764
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	string s;
	while(cin>>s)
	{
		for (ll i = 0; i < s.size(); i++)
		{
			if (s[i] == 'L' && i % 2 == 0)
			{
				cout << "No" << endl;
				break;
			} else if (s[i] == 'R' && i % 2 == 1)
			{
				cout << "No" << endl;
				break;
			} else if (i == s.size() - 1)
				cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
data = gets.split(" ").map(&:to_i).sort
cnt = 0

if data.size <= 2
  puts cnt
  exit
end

data = data.combination(3).to_a

data.each do |i|
  if i[0] == i[1] || i[1] == i[2] || i[0] == i[2]
    next
  end
  if i[0] + i[1] > i[2]
    cnt += 1
  end
end

puts cnt


Measured memory_bytes: 22692
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, char const *argv[])
{
    COMinit();
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    ll ans = 0;
    rep(i, n)
    {
        ans -= v[i] * COM(n - 1 - i, k - 1);
        ans += v[i] * COM(i, k - 1);
        ans %= MOD;
        while (ans < 0)
            ans += MOD;
    }
    rep(i, n)
    {
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12928
n=gets.to_i
a=gets.chomp.split.map(&:to_i)
co={}
s=0
for i in 0..n-1
  if a[i]<3200
    c=a[i]/400
    co[c]=true
  else
    s+=1
  end
end
puts "#{[co.size,1].max} #{co.size+s}"


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int A, B, C; scanf("%d %d %d", &A, &B, &C);
  int M = max({A, B, C});
  int ans = -1;
  if ((3 * M) % 2 == (A + B + C) % 2) {
    ans = (3 * M - A - B - C) / 2;
  }
  else {
    ans = (3 * M + 3 - A - B - C) / 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << A * B * C / (2 * max({A, B, C})) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
int n,a,b,c;
char s[maxn][3],ans[maxn];
int main(){
	n=read(),a=read(),b=read(),c=read();
	for(int i=1;i<=n;i++) scanf("%s",s[i]);
	for(int i=1;i<=n;i++){
		if(s[i][0]=='A'&&s[i][1]=='B'){
			if(a<b){
				++a,--b;
				ans[i]='A';
			}
			else if(a>b){
				--a,++b;
				ans[i]='B';
			}
			else{
				if(s[i+1][0]=='A'){
					++a,--b;
					ans[i]='A';
				}
				else{
					--a,++b;
					ans[i]='B';
				}
			}
		}
		if(s[i][0]=='A'&&s[i][1]=='C'){
			if(a<c){
				++a,--c;
				ans[i]='A';
			}
			else if(a>c){
				--a,++c;
				ans[i]='C';
			}
			else{
				if(s[i+1][0]=='A'){
					++a,--c;
					ans[i]='A';
				}
				else{
					--a,++c;
					ans[i]='C';
				}
			}
		}
		if(s[i][0]=='B'&&s[i][1]=='C'){
			if(c<b){
				++c,--b;
				ans[i]='C';
			}
			else if(c>b){
				--c,++b;
				ans[i]='B';
			}
			else{
				if(s[i+1][1]=='C'){
					++c,--b;
					ans[i]='C';
				}
				else{
					--c,++b;
					ans[i]='B';
				}
			}
		}
		if(a<0||b<0||c<0){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++) printf("%c\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4236
#include <stdio.h>

int H, W;
char s[64][64];

int main(void) {
	int i, j;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 1; i <= H; i++) {
		if (scanf("%63s", s[i] + 1) != 1) return 1;
	}
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (s[i][j] == '#' && s[i - 1][j] != '#' && s[i + 1][j] != '#' && s[i][j - 1] != '#' && s[i][j + 1] != '#') {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
 
using namespace std;
 
#define INF   (1 << 30)
 
int main()
{
    int N, K, A, B;
 
    cin >> N >> K;
 
    vector<int> C(N + 1);
    vector<int> R(N + 1);
 
    vector<bool> S(N + 1, false);
    vector<int> D(N + 1, INF);
    vector<int> P(N + 1, INF);
 
    vector<vector<int> > M1(N + 1, vector<int>());
    vector<vector<int> > M2(N + 1, vector<int>(N + 1, INF));
 
    for (int i = 1; i <= N; i++)
        cin >> C[i] >> R[i];
 
    for (int i = 1; i <= K; i++)
    {
        cin >> A >> B;
 
        M1[A].push_back(B);
        M1[B].push_back(A);
    }
 
    for (int i = 1; i <= N; i++)
    {
        if (R[i] < N - 1)
        {
            queue<pair<int, int> > que;
 
            pair<int, int> start;
 
            start.first = i;
            start.second = (short)0;
 
            que.push(start);
 
            while (!que.empty() && que.front().second < R[i])
            {
                pair<int, int> p1 = que.front(); que.pop();
 
                for (int j = 0; j < M1[p1.first].size(); j++)
                {
                    if (M2[i][M1[p1.first][j]] == INF)
                    {
                        pair<int, int> p2;
 
                        p2.first = M1[p1.first][j];
                        p2.second = p1.second + 1;
 
                        que.push(p2); 
 
                        M2[i][M1[p1.first][j]] = C[i];
                    }
                }
            }
        }
        else
        {
            for (int j = 1; j <= N; j++)
            {
                if (i != j)
                {
                    M2[i][j] = C[i];
                }
            }
        }
    }
 
    D[1] = 0;
    P[1] = -1;
 
    while (true)
    {
        int mincost = INF;
 
        int u = -1;
 
        for (int i = 1; i <= N; i++)
        {
            if (S[i] == false && D[i] < mincost)
            {
                mincost = D[i];
 
                u = i;
            }
        }
 
        if (mincost == INF) { break; }
 
        S[u] = true;
 
        for (int v = 1; v <= N; v++)
        {
            if (S[v] == false && M2[u][v] != INF)
            {
                if (D[u] + M2[u][v] < D[v])
                {
                    D[v] = D[u] + M2[u][v];
                    P[v] = u;
                }
            }
        }
    }
 
    cout << D[N] << endl;
 
    return 0;
}
 
// Time : O ( N ^ 2 )

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0; i+2<n; i++){
    if(s.substr(i, 3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n, y;
    cin >> n >> y;

    for(int i = 0 ; i <= n ; i++){
        for(int j = 0 ; j <= n - i ; j++){
            if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
# AOJ 0552: Exposition
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

x, y = [], []
n = int(input())
for i in range(n):
	a, b = map(int, input().split())
	x.append(a+b)
	y.append(a-b)
xmin, xmax = min(x), max(x)
ymin, ymax = min(y), max(y)
ans1 = ans2 = 0
for i in range(n):
	d1 = max(x[i]-xmin, y[i]-ymin)
	d2 = max(xmax-x[i], ymax-y[i])
	ans1 = max(ans1, min(d1, d2))

	d1 = max(x[i]-xmin, ymax-y[i])
	d2 = max(xmax-x[i], y[i]-ymin)
	ans2 = max(ans2, min(d1, d2))
print(min(ans1, ans2))


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

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<ll,ll>;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int x; cin >> x;
  cout << 1 - x << "\n";
  return 0;
}

Measured memory_bytes: 3648
import sys
from collections import Counter

def prime_factorize(n):
    ans = []
    while not n%2:
        ans.append(2)
        n //= 2
    mod = 3
    while mod**2 <= n:
        if n%mod == 0:
            ans.append(mod)
            n //= mod
        else:
            mod += 2
    if n != 1:
        ans.append(n)
    counter = Counter(ans)
    return counter

def main():
    input = sys.stdin.readline
    mod = pow(10,9)+7
    n = int(input())
    a = [int(x) for x in input().split()]
    
    prime_list = dict()
    for i in range(n):
        primes = prime_factorize(a[i])
        for key, value in primes.items():
            if key in prime_list:
                if prime_list[key] < value:
                    prime_list[key] = value
            else:
                prime_list[key] = value
    
    L = 1
    for key, value in prime_list.items():
        L *= pow(key, value, mod)
        L %= mod
        
    ans = 0
    for i in range(n):
        ans += (L*pow(a[i], mod-2, mod))%mod
        ans %= mod
    
    print(ans)
            


if __name__ == "__main__":
    main()

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

//Cost,Pos
typedef std::pair<int, int> P;

struct edge{
	int to, cost;
	edge(int a, int b):to(a), cost(b){};
};

const int max = 25; 
const int inf = 1000000000;

int n, m;
std::vector<edge> g[max];
int d[max];

void dijkstra(int s){
	std::priority_queue<P, std::vector<P>, std::greater<P> > que;
	for(int i = 0; i <= n; i++)d[i] = inf;
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first)continue;
		for(int i = 0; i < g[v].size(); i++){
			edge e = g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	char ch;
	std::cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b, c, d;
		std::cin >> a >> ch >> b >> ch >> c >> ch >> d;
		edge f(b, c), s(a, d);
		g[a].push_back(f);
		g[b].push_back(s);
	}
	int x1, x2, y1, y2;
	std::cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
	y1 -= y2;
	dijkstra(x1);
	y1 -= d[x2];
	dijkstra(x2);
	y1 -= d[x1];
	std::cout << y1 << std::endl;

	return 0;
}

Measured memory_bytes: 1200
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static boolean found = false;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] board = new char[h][w];

        int[][] dt =  new int[][] {
                new int[] {1, 0},
                new int[] {1, 1},
                new int[] {0, 1},
                new int[] {-1, 1},
                new int[] {-1, 0},
                new int[] {-1, -1},
                new int[] {0, -1},
                new int[] {1, -1}
        };

        for (int i = 0; i < h; i++) {
            String line = sc.next();
            board[i] = line.toCharArray();
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {

                if (board[i][j] != '#') {
                    int count = 0;

                    for (int k = 0; k < dt.length; k++) {
                        int x = i + dt[k][0];
                        int y = j + dt[k][1];

                        if ((0 <= x && x < h) && (0 <= y && y < w) && board[x][y] == '#') {
                            count++;
                        }
                    }
                    board[i][j] = (char)(count + '0');
                }

                System.out.print(board[i][j]);
            }
            System.out.println("");
        }



    }

}

Measured memory_bytes: 21844
n,x,y = map(int,input().split())
a = [0 for i in range(1,n)]
l=y-x;m= max(x-1+l//2,x+n-y)
x-=1;y-=1
for i in range(n):
  for j in range(i+1,n):
    if i+1==j:
      a[0]+=1
    else:
      k = j-i
      if i<=x and j>=y:
      	k=k-l+1
      elif i>=x and j<=y:
        k=min(k,(l+1)-k)
      elif i<=x:
        k=x-i+min((j-x),(l+1)-(j-x))
      else:
        k = j-y+min(y-i,(l+1)-(y-i))  

      a[k-1]+=1
for i in a:
  print(i)

Measured memory_bytes: 47324
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    bool b[k+1];
    b[0]=0;
    for(int o=1;o<=k;o++)
    {
        bool c=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]>o) break;
            if(!b[o-a[i]]) c=1;
        }
        b[o]=c;
    }
    if(b[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
lli LARGE_NUM = 1000000007;

// easy hash table
int ehash(char x) {
    int ret = 0;
    if (x == 'A') ret = 0;
    else if (x == 'C') ret = 1;
    else if (x == 'G') ret = 2;
    else if (x == 'T') ret = 3;
    return ret;
}
int ehash(char x1, char x2) {
    return ehash(x1) * 4 + ehash(x2);
}
int ehash(char x1, char x2, char x3) {
    return ehash(x1) * 16 + ehash(x2) * 4 + ehash(x3);
}

char rhash(int x) {
    if (x == 0) return 'A';
    if (x == 1) return 'C';
    if (x == 2) return 'G';
    return 'T';
}

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

    // dp[i][e1][e2][e3]
    lli dp[101][4][4][4] = {};
    for (int h = 0; h < 64; h++) { // e1 e2 e3
        int e1 = h / 16;
        int e2 = (h % 16) / 4;
        int e3 = h % 4;
        if (h == ehash('A', 'G', 'C')
            ||
            h == ehash('A', 'C', 'G')
            ||
            h == ehash('G', 'A', 'C')) continue;
        dp[3][e1][e2][e3] = 1LL;
    }

    for (int i = 4; i <= N; i++) {
        for (int h = 0; h < 64; h++) { // e1 e2 e3
            for (int k = 0; k < 4; k++) { // new
                int e1 = h / 16;
                int e2 = (h % 16) / 4;
                int e3 = h % 4;

                // pattern = '*AC'
                if (e2 == ehash('A') && e3 == ehash('C') && k == ehash('G')) continue;
                // pattern = '*GA'
                if (e2 == ehash('G') && e3 == ehash('A') && k == ehash('C')) continue;
                // pattern = '*AG'
                if (e2 == ehash('A') && e3 == ehash('G') && k == ehash('C')) continue;
                // pattern = 'AG*'
                if (e1 == ehash('A') && e2 == ehash('G') && k == ehash('C')) continue;
                // pattern = 'A*G'
                if (e1 == ehash('A') && e3 == ehash('G') && k == ehash('C')) continue;

                dp[i][e2][e3][k] = (dp[i][e2][e3][k] + dp[i - 1][e1][e2][e3]) % LARGE_NUM;
            }
        }
    }

    lli ans = 0LL;
    for (int h = 0; h < 64; h++) { // e1 e2 e3
        int e1 = h / 16;
        int e2 = (h % 16) / 4;
        int e3 = h % 4;
        ans = (ans + dp[N][e1][e2][e3]) % LARGE_NUM;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int a[n][m], b[m], c[n];
	for (int i = 0; i < n; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int j = 0; j < m; j++) {
		scanf("%d", &b[j]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a,b;

// <------------- Implement Functions Here ----------> //

set<pll,greater<pll>> X,Y;
multiset<ll> By;
multiset<ll,greater<ll>> Ay;

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	a = vll(n);
	b = vll(n);

	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++) cin>>b[i];

	reverse(all(b));
	
	ll num = -1,l = 0, r = -1;
	for(ll i=0;i<n;i++) {
		if(a[i]==b[i]) {
			num = a[i];
			l = i;
			break;
		}
	}
	for(ll i=n-1;i>=0;i--) {
		if(a[i]==b[i]) {
			r=i;
			break;
		}
	}

	for(ll i=0;i<n;i++) {
		if(a[i]!=num && b[i]!=num && l<=r) {
			swap(b[i],b[l]);
			l++;
		}
	}

	if(l<=r) {
		cout<<"No\n";
		return;
	}

	cout<<"Yes\n";
	DISP(b);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 6392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	string s;
	int C = 0;
	cin >> s;

	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 1; i < s.length(); i++) {

		if (i == 1 || i == s.length() - 1) {
			if (isupper(s[i])) {
				cout << "WA" << endl;
				return 0;
			}
		}

		if (s[i] == 'C') {
			C++;
		}
		else if (isupper(s[i])) {
			cout << "WA" << endl;
			return 0;
		}
	}
	
	if (C != 1) cout << "WA" << endl;
	else cout << "AC" << endl;

	return 0;
}

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

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    vector<int> b;
    b.push_back(0);
    for(int i=0;i<N;i++){
        if(i%2==0){
            b.push_back(a[i]);
        }else{
            b.push_back(24-a[i]);
        }
    }
    sort(b.begin(),b.end());

    int ans=1e9;
    for(int i=0;i<N;i++){
        ans=min(ans,b[i+1]-b[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::cmp::max;

fn solve(n: usize, k: usize, vs: Vec<i64>) -> i64{
    let mut dp: Vec<Vec<Vec<i64>>> = vec![vec![vec![-1000000000; 101]; 51]
; 51];
    let mut result: i64 = 0;
    for i in 0..n {
        dp[i][i][k] = 0;
    }
    for i in 0..n {
        for j in (i..n+1).rev() {
            if k < i + (n - j) {
                continue;
            }
            let rest = k - (i + (n - j));
            let get_all = vs[0..i].iter().sum::<i64>()+vs[j..n].iter().sum
::<i64>();
            for l in 0..rest+1 {
                dp[i][j][l] = get_all;
                if i > 0 {
                    dp[i][j][l] =
                        max(dp[i][j][l],
                            dp[i-1][j][l+1]+vs[i-1]);
                    if l+2 <= k {
                        dp[i][j][l] =
                            max(dp[i][j][l],
                                dp[i-1][j][l+2]);
                    }
                }
                if j < n {
                    dp[i][j][l] =
                        max(dp[i][j][l],
                            dp[i][j+1][l+1]+vs[j]);
                    if l+2 <= k {
                        dp[i][j][l] =
                            max(dp[i][j][l],
                                dp[i][j+1][l+2]);
                    }
                }
                result = max(result, dp[i][j][l]);
                //println!("  k:{}, local:{}", l, dp[i][j][l]);
            }
            //println!("i:{}, j:{}, result:{}", i, j, result);
        }
    }
    result
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let vs: Vec<i64> = (0..n)
        .map(|_| {
            iter.next().unwrap().parse().unwrap()
        }).collect();
    println!("{}", solve(n, k, vs));
}


Measured memory_bytes: 6396
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    vector<pair<int, int>> p(n), q(n);
    rep(i, n) {
        int a = x[i] + y[i], b = x[i] - y[i];
        p[i] = {a, i};
        q[i] = {b, i};
    }

    sort(all(p));
    sort(all(q));
    cout << max(abs(x[p[0].second] - x[p[n - 1].second]) + abs(y[p[0].second] - y[p[n - 1].second]),
                abs(x[q[0].second] - x[q[n - 1].second]) + abs(y[q[0].second] - y[q[n - 1].second]))
         << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 12696
#define ll long long int
#define pb push_back
#define mp make_pair
#define ln cout<<"\n";
#include <bits/stdc++.h>
using namespace std;

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

	 ll t=1,r,n,a,b,c,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,g,ts;
	
	 char ch;
	 double dans;
	 string str,ttr;
	 
//	 cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	     flag=0;sum=0;cnt=0;ans=0;k=0;maxx=0;minn=0;a=0;b=0;temp=0;
	    
	     cin >> n;
	     ll arr[n+1];
	     
	     for(i=0;i<n+1;i++)
	     arr[i]=0;
	     
	     for(i=0;i<n-1;i++)
	     {
	         cin >> x;
	         arr[x]++;
	     }
	     
	     for(i=1;i<=n;i++)
	     {
	         cout<<arr[i]<<"\n";
	     }
	     
	     //ln
	 }
	return 0;
}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        ll l[n], r[n];
        pll p[n];
        fo(i,n){
            cin>>l[i]>>r[i];
            p[i]=mp(l[i],-r[i]);
        }
        sort(p,p+n);
        fo(i,n)p[i].se=-p[i].se;
        pll pre[n], suff[n];
        pre[0]=p[0];
        suff[n-1]=p[n-1];
        fo1(i,n-1){
            pre[i].fi=max(pre[i-1].fi, p[i].fi);
            pre[i].se=min(pre[i-1].se , p[i].se);
        }
        for(int i=n-2;i>=0;i--){
            suff[i].fi=max(suff[i+1].fi, p[i].fi);
            suff[i].se=min(suff[i+1].se , p[i].se);
        }
        ll ans=0;
        fo(i,n-1){
            ans= max(ans, max(0,pre[i].se - pre[i].fi +1 )+ max(0,suff[i+1].se - suff[i+1].fi +1 ) );
            //cout<<ans;
        }
        fo1(i,n-2){
            ans= max(ans, p[i].se- p[i].fi+1+ max(0, min(pre[i-1].se , suff[i+1].se ) - max(pre[i-1].fi , suff[i+1].fi  ) +1  ) );
        }
        cout<<ans;

        





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int a,b;
    cin >> a >> b;
    if(a == b or a == b-1 or a == b+1) cout << a+b << endl;
    else{
        a = max(a,b);
        cout << a+a-1 << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
string s,t;

int main(){
	cin>>s;
	t="CODEFESTIVAL2016";
	for(i=0;i<16;i++){
		if(s[i]!=t[i])ans++;
	}
	p(ans);
	return 0;
    

}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s << endl;
}

Measured memory_bytes: 3620
// ABC054 B - Template Matching
#include <stdio.h>
#include <string.h>

int main(void) {
    int N, M;
    scanf("%d %d", &N, &M);
    char A[50][51];
    char B[50][51];
    char joinA[2501] = {'\0'};
    char joinB[2501] = {'\0'};
    int i;
    for (i = 0; i < N; i++) {
        scanf("%s", A[i]);
    }
    for (i = 0; i < M; i++) {
        scanf("%s", B[i]);
    }

    for (i = 0; i < M; i++) {
        strcat(joinB, B[i]);
    }
    int x, y;
    for (y = 0; y < (N - M + 1); y++) {
        for (x = 0; x < (N - M + 1); x++) {
            if (A[y][x] == joinB[0]) {
                // joinAを作る
                for (i = 0; i < M; i++) {
                    strncat(joinA, &A[y + i][x], M);
                }
                // printf("joinA:%s\n",joinA);
                // joinA=joinBならYes
                if (strcmp(joinA, joinB) == 0) {
                    printf("Yes\n");
                    return 0;
                }
                joinA[0] = '\0';
            }
        }
    }

    printf("No\n");
    return 0;

}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}
ll b[100100];
//ここから書き始める
int main()
{
	cout << setprecision(10);
	int q;
	cin >> q;
	vector<int> l(q),r(q);
	rep(i,q) cin >> l[i] >>r[i];

	vector<ll> number(100100);
	rep(i,100100){
		number[i] = i;
	}
	vector<bool> is_prime(100100);
	rep(i,100100){
		if(IsPrime(i)){
			is_prime[i] = true;
		}
	}
	ll count = 0;
	b[0] = 0;
		
	For(i,1,100100){
		if(is_prime[i]&&is_prime[(i+1)/2]&&(i+1)%2==0){
			count ++;
			b[i] = count;
		}else b[i] = count ;
	}
		
	rep(i,q){
		if(l[i]>1){
		cout << b[r[i]] - b[l[i]-1] <<endl;
		}else{
			cout << b[r[i]] - b[l[i]] <<endl;
		}
	}
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,n,i,j,k,a,b,c,sum=0;
    cin>>a>>b;
    j=a*b;
    if(j%2!=0)
        cout<<"Yes";
    else
        cout<<"No";
}


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

const int MAXN = 100005;

int X, Y, a, b, c, p[MAXN], q[MAXN], r[MAXN];

int main(){
	scanf("%d %d %d %d %d", &X, &Y, &a, &b, &c);
	for(int i = 0; i < a; i++)
		scanf("%d", &p[i]);
	for(int i = 0; i < b; i++)
		scanf("%d", &q[i]);
	for(int i = 0; i < c; i++)
		scanf("%d", &r[i]);
	
	sort(p, p + a);
	sort(q, q + b);
	sort(r, r + c);
	
	reverse(p, p + a);
	reverse(q, q + b);
	reverse(r, r + c);
	
	long long sum = 0;
	for(int i = 0; i < X; i++)
		sum += p[i];
	for(int i = 0; i < Y; i++)
		sum += q[i];
	
	int j = X - 1, k = Y - 1;
	
	for(int i = 0; i < min(c, X + Y); i++){
		int rj = 1 << 30, rk = 1 << 30;
		if(j >= 0)rj = p[j];
		if(k >= 0)rk = q[k];
		
		if(r[i] <= rj && r[i] <= rk)break;
		
		if(r[i] > rj && rj <= rk){
			sum += r[i] - rj;
			j--;
		}else{
			sum += r[i] - rk;
			k--;
		}
	}
	
	printf("%lld\n", sum);
	
	return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<vector>
#include<cassert>

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

using namespace std;

const int INF=1<<29;

class edge{
public:
	int v,cost;
	edge(int v,int cost):v(v),cost(cost){}
};

int main(){
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n;){
		vector<edge> G[100];
		int d[100][100];
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(_,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
			assert(cost>0 && (d[u][v]==0 || d[u][v]==INF) && u!=v);
			d[u][v]=d[v][u]=cost;
			G[u].push_back(edge(v,cost));
			G[v].push_back(edge(u,cost));
		}

		rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		double dp[100][100]={}; // dp[u][v] := ( u->v 間の最短経路の個数 )
		rep(u,n) rep(i,G[u].size()) {
			int v=G[u][i].v,cost=G[u][i].cost;
			if(d[0][u]+cost+d[v][n-1]==d[0][n-1]) dp[u][v]=1;
		}
		rep(w,n) rep(u,n) rep(v,n) dp[u][v]+=dp[u][w]*dp[w][v];

		rep(_,k){
			int c; scanf("%d",&c);
			printf("%.9f\n",dp[0][c]*dp[c][n-1]/dp[0][n-1]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1308