akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define ll long long
#define P pair<int,int>
#define MP(a,b) make_pair(a,b)
using namespace std;
int n,m,dis[200005],head,tail,t,h[200005];
priority_queue<P> q;
set<int> in[200005];
struct E{int v,c,next;}g[400005];
void ins(int u,int v,int c){g[++t].v=v,g[t].c=c,g[t].next=h[u],h[u]=t;}
inline int read(){
    int 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<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	memset(dis,0x3f,sizeof dis);
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int u,v,c;
		u=read(),v=read(),c=read();
		ins(u,v,c); ins(v,u,c);
	}
	q.push(MP(0,1)); dis[1]=0;
	while(!q.empty())
    {
        int now=q.top().second,ca=-q.top().first;
        q.pop();
        if(dis[now]<ca)continue;
        for(int i=h[now];i;i=g[i].next)
        {
            int to=g[i].v,to_com=g[i].c;
            int to_ca=ca+(!in[now].count(to_com));
            if(dis[to]>to_ca)
            {
                dis[to]=to_ca;
                q.push({-to_ca,to});
                in[to].clear();
                in[to].insert(to_com);
            }
            else if(dis[to]==to_ca)
            {
                in[to].insert(to_com);
            }
        }
    }
	printf("%d",dis[n]==1061109567?-1:dis[n]);
}

Measured memory_bytes: 25208
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int main() {
	ll X1, Y1, W1, H1, X2, Y2, W2, H2;
	cin >> X1 >> Y1 >> W1 >> H1 >> X2 >> Y2 >> W2 >> H2;

	ll a = X1, b = X1 + W1, c = X2, d = X2 + W2;
	if (a > c) {
		ll t1 = a, t2 = b;
		a = c; b = d;
		c = t1; d = t2;
	}
	ll px1 = 0, px2 = 0;
	if (c <= b) {
		px1 = c; px2 = std::min(b, d);
	}

	a = Y1;
	b = Y1 + H1;
	c = Y2;
	d = Y2 + H2;
	if (a > c) {
		ll t1 = a, t2 = b;
		a = c; b = d;
		c = t1; d = t2;
	}
	ll py1 = 0, py2 = 0;
	if (c <= b) {
		py1 = c; py2 = std::min(b, d);
	}

	cout << W1 * H1 + W2 * H2 - 2 * (px2 - px1) * (py2 - py1) << endl;
}


Measured memory_bytes: 3128
# include <iostream>
# include <vector>
# include <queue>
# include <functional>

constexpr int MAX_N = 100;
constexpr int INF = 100000000;

typedef std::pair<int, int> P;

struct edge {
	int to, cost;
	edge(int t, int c) : to(t), cost(c) {}
};

int n, m, K;
std::vector<edge> G[2][MAX_N];
int d[MAX_N];

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

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (p.first > d[v])
			continue;
		for (int i = 0; i < G[r][v].size(); ++i) {
			edge e = G[r][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() {
	int a, b, c, t;
	while (1) {
		std::cin >> m >> n;
		if (m + n == 0)
			break;

		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < n; ++j)
				G[i][j].clear();
		}

		for (int i = 0; i < m; ++i) {
			std::cin >> a >> b >> c >> t;
			G[0][a - 1].push_back(edge(b - 1, c));
			G[0][b - 1].push_back(edge(a - 1, c));
			G[1][a - 1].push_back(edge(b - 1, t));
			G[1][b - 1].push_back(edge(a - 1, t));
		}
		std::cin >> K;
		int p, q, r;
		for (int i = 0; i < K; ++i) {
			std::cin >> p >> q >> r;
			dijkstra(p - 1, r);
			std::cout << d[q - 1] << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, k, res;

signed main() {
	cin >> n >> k;
	reps(a,1,n+1) if ((a*2)%k==0) {
		int x = (n+a)/k - a/k;
		res += x*x;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
from itertools import groupby
n = int(input())
a = sorted(list(map(int,input().split())))
g = groupby(a)
# 1-indexed
r = [0]*100010
for k,v in g:
    r[k] = len(list(v))
s = []
for i in range(len(r)-2):
    t = r[i] + r[i+1] + r[i+2]
    s.append(t)
print(max(s))


Measured memory_bytes: 14256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
namespace G{
	const int E=200010;
	int to[E],bro[E],head[N],e=0;
	int col[N];
	inline void init(){
		memset(head,-1,sizeof(head));
		memset(col,-1,sizeof(col));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	int pcnt[3],ecnt;
	bool dfs(int x,int c){
		if(~col[x])return col[x]!=c;
		col[x]=c,pcnt[c]++;
		int nxt=(c+1)%3,pre=(c+2)%3;
		bool flag=false;
		for(int i=head[x],v;~i;i=bro[i]){
			ecnt++;
			flag|=dfs(v=to[i],i&1?pre:nxt);
		}
		return flag;
	}
}
int main(){
	G::init();
	int n=ni;
	for(int tot=ni;tot--;G::add(ni,ni));
	lint ans=0;
	for(int i=1;i<=n;i++){
		using namespace G;
		if(col[i]==-1){
			memset(pcnt,0,sizeof(pcnt));
			ecnt=0;
			if(dfs(i,0)){
				int sum=pcnt[0]+pcnt[1]+pcnt[2];
				ans+=(lint)sum*sum;
			}else if(pcnt[0]&&pcnt[1]&&pcnt[2]){
				ans+=(lint)pcnt[0]*pcnt[1]+(lint)pcnt[1]*pcnt[2]+(lint)pcnt[2]*pcnt[0];
			}else{
				ans+=ecnt>>1;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7296
import static java.lang.Math.min;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {

			//
			int n = Integer.parseInt(line);
			int[][] grid = new int[n + 2][n + 2];

			for (int i = 0; i < n; i++) {
				line = br.readLine();
				for (int j = 0; j < n; j++) {
					grid[i + 1][j + 1] = line.charAt(j) == '.' ? 1 : 0;
				}
			}

			//
			int max = 0;
			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < n + 1; j++) {
					if (grid[i][j] != 0) {
						int min;
						min = (int) min(grid[i - 1][j - 1], grid[i - 1][j]);
						min = (int) min(min, grid[i][j - 1]);
						grid[i][j] = min + 1;
						if (grid[i][j] > max) {
							max = grid[i][j];
						}
					}
				}
			}
			System.out.println(max);

		}

	}

}

Measured memory_bytes: 50252
# coding:utf-8

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;

int main() {
    int h,w,a,b; cin >>  h >> w >> a >> b;
    vector<vector<char>> grid(h,vector<char>(w,'0'));

    for (int i = 0; i < b; i ++) {
        for (int j = 0; j < a; j ++) {
            grid[i][j] = '1';
        }
    }

    for (int i = b; i < h; i ++) {
        for (int j = a; j < w ; j ++) {
            grid[i][j] = '1';
        }
    }

    for (int i = 0; i < h; i ++ ) {
        for (int j = 0; j < w; j ++) {
            cout << grid[i][j];
        }
        cout << '\n';
    }
  
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int a, b, k;

int main(void)
{
	cin >> a >> b >> k;
	for(int i = 0; i < k; i++){
		if(i%2 == 0){
			a -= a%2;
			b += a/2;
			a /= 2;
		}
		else{
			b -= b%2;
			a += b/2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
nlista=[]
nlistb=[]
for i in range(n):
    a,b=map(int,input().split())
    nlista.append(a)
    nlistb.append(b)
#print(nlista,nlistb)
nlista.sort()
nlistb.sort()
#print(nlista,nlistb)

ansl=0
ansh=0
n2=n//2
#print(n2)
if n%2:
    ansl=nlista[n2]
    ansh=nlistb[n2]
else:
    ansl=nlista[n2-1]+nlista[n2]
    ansh = nlistb[n2-1] + nlistb[n2]
print(ansh-ansl+1)

Measured memory_bytes: 99088
import sys
T1, T2, A1, A2, B1, B2 = map(int, sys.stdin.read().split())
a1, b1 = T1*A1, T1*B1
a2, b2 = T2*A2, T2*B2
sa, sb = a1+a2, b1+b2
if sa==sb:
    print("infinity")
    exit()
if sa < sb:
    a1, a2, b1, b2, sa, sb = b1, b2, a1, a2, sb, sa
# 2*n-1 回以上出会うか
ok = 0
ng = 10**1800
a = 0
while ok+1 < ng:
    c = (ok+ng)//2
    if (c-1)*sa+a1 <= (c-1)*sb+b1:
        if (c - 1) * sa + a1 == (c - 1) * sb + b1:
            a = -1
        ok = c
    else:
        ng = c
if ok > 10**1799:
    print("a")
    print("infinity")
else:
    print(max(ok*2-1+a, 0))


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	if(h%3 == 0 || w %3 == 0){
		printf("0\n");
	}else{
		int mi = min(((w + 2) / 3) * h - (w / 3)*h, ((h + 2) / 3) * w - (h / 3)*w);
		//int mi = min(w, h);
		for(int i = h/3; i <= (h+2)/3; ++i){
			int x = i*w, y = (h-i)*(w/2), z = (h-i)*((w+1)/2);
			//cout<<i<<"&&"<<x<<"**"<<y<<"**"<<z<<endl;
			mi = min(mi, max(x,max(y, z))-min(min(x, y), z));
		}
		for(int i = w/3; i <= (w+2)/3; ++i){
			int x = i*h, y = (w-i)*(h/2), z = (w-i)*((h+1)/2);
			//cout<<i<<"&&%%%"<<x<<"**"<<y<<"**"<<z<<endl;
			mi = min(mi, max(x,max(y, z))-min(min(x, y), z));
		}
		printf("%d\n", mi);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
ordered_set<ll> ors;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;
 
ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}
 
ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}
 
ll lp[100001];
vector<ll> pr;
 
void prime()
{
    repf(i,1,100001) lp[i]=i;
    repf(i,2,100001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<100001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    repf(i,2,100001) if(lp[i]==i) pr.pb(i);
}

const ll MX=200001;

vector<ll> v[MX];
ll depth[MX];
ll D[MX][22];
 
void dfs(ll x, ll p, ll h=0) {
    D[x][0]=p;
    depth[x]=h;
    repf(i,1,22)
    {
        if(D[x][i-1]!=-1 && D[D[x][i-1]][i-1]!=-1)
        {
            D[x][i]=D[D[x][i-1]][i-1];
        }
    }
    for(auto i:v[x]) {
        if(i==p) continue;
        dfs(i,x,h+1);
    }
}

ll walk(ll x, ll k)
{
    repf(i,0,22)
    {
        if((1<<i)&k)
        {
            x=D[x][i];
        }
    }
    return x;
}

ll lca(ll x, ll y)
{
    if(depth[x]>depth[y]) x=walk(x,depth[x]-depth[y]);
    if(depth[y]>depth[x]) y=walk(y,depth[y]-depth[x]);
    if(x==y) return x;
    repb(i,21,0)
    {
        if(D[x][i]!=D[y][i])
        {
            x=D[x][i];
            y=D[y][i];   
        }
    }
    return D[x][0];
}

void init() {

}

void solve(ll tt) {
    string s;
    cin>>s;
    ll n=s.length();
    if(s[n-1]=='s') cout<<s<<"es\n";
    else cout<<s<<"s\n";
} 
 
 
int main()
{
    // IOS;
    // init();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 8328
import math

N = int(input())

def is_prime(n):
    return all(n%i != 0 for i in range(2, int(math.sqrt(n)+1)))

n = 0
k = 1

while True:
    if is_prime(5*k+1):
        print(5*k+1, end="")
        n += 1
        if n == N:
            print("")
            break
        else:
            print(" ", end="")
    k += 1


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }

    ll ret = 0;
    vector<ll> bik(N, 1e9 + 1);
    for(int k=0; k<N; ++k) {
        ll sum = 0;
        for(int i=0; i<N; ++i) {
            int idx = (i - k + N) % N;
            bik[i] = min(bik[i], a[idx]);
            sum += bik[i];
        }
        if(ret == 0) {
            ret = sum + k*x;
        } else {
            ret = min(ret, sum + k*x);
        }
    }
    cout << ret << endl;
}


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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

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

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

void solve()
{
  ll n, k; cin >> n >> k;
  // ll x, y, z; cin >> x >> y >> z;
  // string s; cin >> s;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  // bool ok = false;
  ll r = n - k;
  ans = (r + (k - 1) - 1) / (k - 1) + 1;
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;}
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 1024
n = int(input())
l = list(map(int,input().split()))
a1 = 0
a2 = 0

c1 = int(sum(l)/n)
c2 = c1 + 1

for i in range(len(l)):
    a1 = a1 + (c1-l[i])**2
    a2 = a2 + (c2-l[i])**2
ans = min(a1,a2)
print(ans)

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

using namespace std;

typedef long long ll;

const int MAX = 2e5+10;
const ll INF = (1ll<<60);

int N;
ll A[MAX];

int main() {

  cin >> N;

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
    A[i] = sum;
  }

  ll ans = INF;
  int l = 0;
  int c = 1;
  int r = 2;
  for (; c < N-2; c++) {
    while (true) {
      if (abs(A[c]-2*A[l]) < abs(A[c]-2*A[l+1])) break;
      l++;
      if (c-l == 1) break;
    }
    while (true) {
      if (abs(sum-2*A[r]+A[c]) < abs(sum-2*A[r+1]+A[c])) break;
      r++;
      if (N-r == 1) break;
    }
    vector<ll> v;
    v.push_back(A[l]);
    v.push_back(A[c]-A[l]);
    v.push_back(A[r]-A[c]);
    v.push_back(sum-A[r]);
    sort(v.begin(), v.end());
    ans = min(ans, v[3]-v[0]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>

using namespace std;

typedef pair<int,int> ii;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int le[3];
	int c[3];
	int en;
	cin>>le[0]>>le[1];
	priority_queue <ii> mq;
	for(int i=0;i<3;i++)cin>>c[i];
	for(int i=0;i<3;i++){
		for(int j=0;j<c[i];j++){
			cin>>en;
			mq.push(ii(en,i));
		}
	}
	int ne = le[0]+le[1];
	le[2] = ne;
	long long res = 0;
	while(ne){
		if(le[mq.top().second]){
			le[mq.top().second]--;
			res+=mq.top().first;
			ne--;
		}
		mq.pop();
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair< complex<double> , complex<double> > pp;

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

int n;
int x[200],y[200],r[200];

P ver[1000][2];

pp get_2cross_point_of_2circle(double x1,double y1,double r1,double x2,double y2,double r2){
    P c1(x1,y1),c2(x2,y2);
    double a =abs(c2 - c1);
    double b = r1;
    double c = r2;

    double rc = (a * a + b * b - c * c) / (2.0 * a);
    double rs = sqrt(b * b - rc * rc);
    P diff = (c2 - c1) / a;

    pp p;
    p.first = c1 + diff * rc + (diff * P(0,1) * rs);
    p.second = c1 + diff * rc + (diff * P(0,-1) * rs);

    return p;
}

bool judge(P a1,P a2,P b1,P b2){
    P a = a2 - a1;
    P c1 = b1 - a1;
    P c2 = b2 - a1;
    return (a.real() * c1.imag() - a.imag() * c1.real()) * (a.real() * c2.imag() - a.imag() * c2.real()) <= 0.0;
}

bool judgecross(P a,P b,int a1,int b1){
    FOR(i,a1+1,b1)
        if(!judge(a,b,ver[i][0],ver[i][1]))
            return false;
    return true;
}

bool input(){
    scanf("%d",&n);
    if(n == 0)
        return false;
    REP(i,n){
        scanf("%d%d%d",&x[i],&y[i],&r[i]);
    }
    return true;
}

double G[1000][1000];
void solve(){

    REP(i,1000)
        REP(j,1000)
            G[i][j] = 1000000000.0;
    REP(i,1000)
        G[i][i] = 0.0;

    REP(i,n-1){
        pp p = get_2cross_point_of_2circle(x[i],y[i],r[i],x[i + 1],y[i + 1],r[i + 1]);
        ver[i][0] = p.first;
        ver[i][1] = p.second;
    }
    REP(i,(n - 1) * 2){
        FOR(j,i + 1,(n - 1) * 2){
            int i1 = i / 2;int i2 = i % 2;
            int j1 = j / 2;int j2 = j % 2;
            if(!judgecross(ver[i1][i2],ver[j1][j2],i1,j1))
                continue;
            G[i][j] = G[j][i] = abs(ver[i1][i2] - ver[j1][j2]);
        }
    }
    P start(x[0],y[0]);
    REP(i,(n - 1) * 2){
        int i1 = i / 2;int i2 = i % 2;
        if(!judgecross(start,ver[i1][i2],-1,i1))
            continue;
        G[i][n * 2 - 2]  = G[n * 2 - 2][i] = abs(start - ver[i1][i2]);
    }
    P end(x[n-1],y[n-1]);
    REP(i,(n - 1) * 2){
        int i1 = i / 2;int i2 = i % 2;
        if(!judgecross(ver[i1][i2],end,i1,n-1))
            continue;
        G[i][n * 2 - 1] = G[n * 2 - 1][i] = abs(end - ver[i1][i2]);
    }
    if(judgecross(start,end,-1,n-1))
        G[n * 2 - 1][n * 2 - 2] = G[n * 2 - 2][n * 2 - 1] = abs(start - end);

    REP(k,n*2){
        REP(i,n*2){
            REP(j,n*2){
                G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
            }
        }
    }
    printf("%lf\n",G[n*2-2][n*2-1]);
}



int main(){
    while(input()){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11108
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int cnt[111111];
int ans;
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)
	{
		int x=io::F();
		if(x>100000)++ans;
			else cnt[x]++;
	}
	for(register int i=1;i<=100000;++i)
		if(cnt[i]>=i)ans+=cnt[i]-i;
			else ans+=cnt[i];
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
a = int(input())
l=list(map(int ,input().split()))
list.sort(l, reverse=True)
alice=0
bob=0
for i in range(a):
    if i==0 or i%2==0:
        alice=alice+l[i]
    else:
        bob=bob+l[i]    
print(alice-bob)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define line cout<<"\n"
#define ci std ::cin
#define co std ::cout
#define sf scanf
#define sff(n,m) scanf("%d%d",&n,&m)
#define pf printf
#define p_line printf("\n")
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
#define mx 10000000
/*ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}*/
ll n,a[100000+5][5];
ll dp[100000+5][5];
ll dpcall(int pos,int g)
{
	if(pos>n)
		return 0;
	if(dp[pos][g]!=-1)
		return dp[pos][g];
	if(g==0)
	{
		ll r1=0,r2=0,r3=0;
		r1=dpcall(pos+1,1);
		r2=dpcall(pos+1,2);
		r3=dpcall(pos+1,3);
		return dp[pos][g]=max(r1,max(r2,r3));
	}
	ll ans1=0,ans2=0,ans3=0;
	if(g==1)
	{
		ll r1=0,r2=0;
		r1=a[pos][g]+dpcall(pos+1,2);
		r2=a[pos][g]+dpcall(pos+1,3);
		ans1=max(r1,r2);
	}
	if(g==2)
	{
		ll r1=0,r2=0;
		r1=a[pos][g]+dpcall(pos+1,1);
		r2=a[pos][g]+dpcall(pos+1,3);
		ans2=max(r1,r2);
	}
	if(g==3)
	{
		ll r1=0,r2=0;
		r1=a[pos][g]+dpcall(pos+1,2);
		r2=a[pos][g]+dpcall(pos+1,1);
		ans3=max(r1,r2);
	}
	return dp[pos][g]=max(ans1,max(ans2,ans3));
}
void solve()
{
    //Code here
 	ci>>n;
 	for(int i=1 ; i<=n ; i++)
 	{
 		for(int j=1 ; j<=3 ; j++)
 		{
 			ci>>a[i][j];
 		}
 	}
 	memset(dp,-1,sizeof(dp));
 	co<<dpcall(0,0);
 	line;
}
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	/*ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	solve();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) cin >> V[i];
  vector<int> C(N);
  for (int i=0; i<N; i++) cin >> C[i];

  int cnt = 0;
  for (int i=0; i<N; i++) {
    if (V[i] >= C[i]) cnt += V[i] - C[i];
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for ( int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000; // 十分小さい値を初期値に設定
    int minv = R[0];

    for ( int i = 1; i < n; i++){       //　ここで毎回 R[i] を読み込めば，配列は不要
        maxv = max(maxv, R[i] -minv);   //　最大値の更新
        minv = min(minv, R[i]);         //　ここまでの最小値を保持しておく
    }

    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3884
n = int(input())

l = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i):
        for k in range(j):
            if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
                if l[i]+l[j]>l[k] and l[k]+l[j]>l[i] and l[i]+l[k]>l[j]:
                    ans+=1
print(ans)

Measured memory_bytes: 9120
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <math.h>
#define llint long long int
using namespace std;

llint ceil1(llint x,llint y){
  if(x%y==0) return x/y;
  else return (x/y)+1;
}

int main(void){
  int i,j,k,t,tmp;
  llint a,b,c;
  llint T,A;
  int N;
  llint x,y;
  scanf("%d",&N);
  scanf("%lld %lld",&T,&A);
  a=T;
  b=A;
  for(i=2;i<=N;i++){
    scanf("%lld %lld",&T,&A);
    if(T==A){
      a=b=(llint)max(a,b);
    }
    else if(T>A){
      x=ceil1(b,A);
      if(a>T*x) x=ceil1(a,T);
      a=T*x;
      b=A*x;
    }
    else{
      x=ceil1(a,T);
      if(b>A*x) x=ceil1(b,A);
      a=T*x;
      b=A*x;
    }
  }
  c=a+b;
  printf("%lld\n",c);
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	vl A(3);
	ll K;
	cin >> A[0] >> A[1] >> A[2] >> K;
	sort(ALL(A));
	cout << A[0] + A[1] + A[2] * pow(2, K) << endl;	
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.length()/2){
        ans+=s[i]!=s[s.length()-1-i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#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 n;
    cin >> n;
    int A = 1000000007;
    ll sum10 = 1;
    ll sum9 = 1;
    ll sum8 = 1;
   	rep(i,n){
        sum10 = (sum10 % A) * 10;  
        sum9 = (sum9 % A) * 9; 
        sum8 = (sum8 % A) * 8;
    }
    ll ans = (sum10 - sum8) - 2 * (sum9 - sum8);
    ans = ans % A;
    if(ans < 0) ans += A;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            var listA = new List<int>();
            var listB = new List<int>();
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    listA.Add(int.Parse(strs[i]));
                }
                else
                {
                    listB.Add(int.Parse(strs[i]));
                }
            }
            listA.Sort();
            listB.Sort();

            var dictA = new Dictionary<int, int>();
            var dictB = new Dictionary<int, int>();
            int before = 0;
            int count = 0;
            for(int i = 0; i < listA.Count; i++)
            {
                if (before == listA[i])
                {
                    count++;
                }
                else
                {
                    if (count > 0) dictA.Add(before, count);
                    before = listA[i];
                    count = 1;
                }
            }
            if (count > 0) dictA.Add(before, count);

            before = 0;
            count = 0;
            for (int i = 0; i < listB.Count; i++)
            {
                if (before == listB[i])
                {
                    count++;
                }
                else
                {
                    if (count > 0) dictB.Add(before, count);
                    before = listB[i];
                    count = 1;
                }
            }
            if (count > 0) dictB.Add(before, count);

            

            var maxA = 0;
            var maxA_num = 0;
            var nextA = 0;
            var nextA_num = 0;
            var maxB = 0;
            var maxB_num = 0;
            var nextB = 0;
            var nextB_num = 0;

            foreach (var kvp in dictA.OrderBy(x => x.Value))
            {
                if (maxA <= kvp.Value)
                {
                    nextA = maxA;
                    nextA_num = maxA_num;
                    maxA = kvp.Value;
                    maxA_num = kvp.Key;
                }
            }
            foreach (var kvp in dictB.OrderBy(x => x.Value))
            {
                if (maxB <= kvp.Value)
                {
                    nextB = maxB;
                    nextB_num = maxB_num;
                    maxB = kvp.Value;
                    maxB_num = kvp.Key;
                }
            }

           if (maxA_num == maxB_num)
           {
                if (maxA + nextB < maxB + nextA)
                {
                    maxA = nextA;
                }
                else maxB = nextB;
           }
           Console.WriteLine(N - (maxA + maxB));
        }
    }
}


Measured memory_bytes: 26464
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int point = 0;
		for (int i = 0; i < arr.length; i++) {
		    if (i % 2 == 0) {
		        if (arr[i] == 'p') {
		            point--;
		        }
		    } else {
		        if (arr[i] == 'g') {
		            point++;
		        }
		    }
		}
		System.out.println(point);
   }
}




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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  string s;
  cin>>s;
  ll k;cin>>k;
  bool fl=true;
  if(k>100){
    ll cnt=0;
    while(cnt<s.size()&&s[cnt]=='1')cnt++;
    cout<<s[cnt]<<endl;
  }else{
    bool fl=true;
    for(int i=0;i<min((ll)s.size(),k);i++){
      if(s[i]!='1')fl=false;
    }
    if(fl){
      cout<<1<<endl;
    }else{
      ll cnt=0;
      while(s[cnt]=='1')cnt++;
      cout<<s[cnt]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int a[3000];
long int dp[3000][3001];
bool checked[3000][3001];

long int get(int l, int r, int turn){

    if(l == r){
        return 0;
    }

    if(checked[l][r]){
        return dp[l][r];
    }
    else{
        long int temp = 0;

        if(turn == 0){
            temp = max(get(l + 1, r, 1) + a[l], get(l, r - 1, 1) + a[r - 1]);
        }
        else{
            temp = min(get(l + 1, r, 0) - a[l], get(l, r - 1, 0) - a[r - 1]);
        }
        dp[l][r] = temp;
        checked[l][r] = true;
        return temp;
    }
}

int main(){

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= N; j++){
            checked[i][j] = false;
        }
    }

    long int ans = get(0, N, 0);
    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 78336
import java.util.*;

public class Main {
	public static void main(String args[]) {
    	Scanner scan = new Scanner(System.in);
      	int boxes = scan.nextInt();
      	int[] squareBoxes = new int[boxes];
      	int[] dp = new int[boxes];
      	int max = 0;
      	dp[boxes-1]=0;
      	for(int i=0; i<boxes; i++){
        	squareBoxes[i]=scan.nextInt();
        }
      	
      	for(int i=boxes-2; i>=0; i--) {
        	if(squareBoxes[i]>=squareBoxes[i+1]) {
            	dp[i]=dp[i+1]+1;
            }else{
              	dp[i]=0;
            }
          	max=Math.max(dp[i],max);
        }
      	System.out.println(max);
    }
}

Measured memory_bytes: 50332
#include <iostream>

int nCeil(int a, int b)
{
	if (a%b==0) return a/b;
	else return a/b + 1;
}

int main()
{
	int n, k;
	std::cin >> n >> k;
	
	int *w = new int[n];
	for (int i=0; i<n; i++) std::cin >> w[i];
	
	int max_w = 0;
	for (int i=0; i<n; i++) {
		if (max_w < w[i]) max_w = w[i];
	}
	
	int lb = max_w - 1;
	int ub = max_w * nCeil(n, k);
	int P;
	
	while (lb < ub) {
		if (lb + 1 == ub) {
			std::cout << ub << std::endl;
			break;
		}
		P = (lb + ub) / 2;
		int num_of_loads = 0;
		int weight = 0;
		for (int trucks=0; trucks<k; ) {
			if (weight + w[num_of_loads] > P) {
				weight = 0; trucks++;
			}
			else {
				weight += w[num_of_loads];
				num_of_loads++;
				if (num_of_loads == n) break;
			}
		}
		if (num_of_loads < n) { // P is small
			lb = P;
		} else { // P is large
			ub = P;
		}
	}
	
	delete[] w;
	
	
	return 0;
}




Measured memory_bytes: 3124
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#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(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
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;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    ll cnt[n+1]={0};
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
        cnt[c]++;
    }
    sort(all(v));
    if((v[n-1]-v[0])>1)
    {
        cout<<"No\n";
        return;
    }
    if(v[n-1]!=v[0])
    {
        ll k=v[n-1];
        ll proper=cnt[k-1];
        ll rem=cnt[k];
        ll fun=k-proper;
        if(fun<=0)
        {
            cout<<"No\n";
            return;
        }
        if((rem/2)>=fun)
        {
            cout<<"Yes\n";
            return;
        }
        else
        {
            cout<<"No\n";
            return;
        }
    }
    else
    {
        if(v[0]==n-1)
        {
            cout<<"Yes\n";
            return;
        }
        int limit=(n/2);
        if(v[0]<=limit)
        {
            cout<<"Yes\n";
            return;
        }
        else
        {
            cout<<"No\n";
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int m, d;
	cin >> m >> d;
	int ans=0;
	for(int i=2; i<=d; i++){
		int j=i/10, k=i%10, l=j*k;
		if(j>=2 && k>=2 && 2<=l && l<= m) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 50;

int n, sz[N], x[N][N], y[N][N];
int32_t main(){_

   cin>>n;  

   for (int i = 0; i < n; ++i)
   {
      cin >> sz[i];

      for (int j = 0; j < sz[i]; ++j)
      {
         cin >> x[i][j] >> y[i][j];
         --x[i][j];
      }

   }

   int ans = 0;

   for (int i = 0; i < (1LL << n); ++i)
   {
      vector<int> honest;
      vector<bool> good(n, false);
      for (int j = 0; j < n; ++j)
      {
         if(i & (1LL << j)){
            honest.push_back(j);
            good[j] = true;
         }
      }

      bool is_good = true;
      for(auto it: honest){
         for (int i = 0; i < sz[it]; ++i)
         {
            int xx = x[it][i], yy = y[it][i];
            if(good[xx] != yy){
               is_good = false;
               break;
            }
         }
      }

      if (!is_good){
         continue;
      }

      int vals = accumulate(good.begin(), good.end(), 0);
      tr(i, good);
      ans = max(ans,  vals);
   }

   cout<<ans;
   
   

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

class Main {

    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int times = stdin.nextInt();
	for(int i = 0; i < times; i++){
	    BigInteger a = new BigInteger(stdin.next());
	    BigInteger b = new BigInteger(stdin.next()).add(a);
	    if(b.compareTo(BigInteger.TEN.pow(80)) >= 0){
		System.out.println("overflow");
	    } else {
		System.out.println(b);
	    }
	}
    }
}

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

int main() {
  int n;
  cin >> n;
  set<int> set1;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    set1.insert(a);
  }
  cout << set1.size() << endl;
}


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

int main(){
  int i,j,N,T;
  cin >> N >> T;
  vector<pair<int,int>> A(N);
  int a,b;
  for(i=0; i<N; i++){
    cin >> a >> b;
    A[i] = make_pair(a,b);
  }
  sort(A.begin(),A.end());
  vector<vector<int>> dp(N,vector<int>(T));
  vector<vector<int>> dp2(N,vector<int>(T));
  for(i=0; i<T; i++){
    dp[0][i] = A.at(0).second;
    if(i<A.at(0).first) dp2[0][i] = 0;
    else dp2[0][i] = A.at(0).second;
  }
  int tmp;
  for(i=0; i<T; i++){
    for(j=1; j<N; j++){
      dp[j][i] = max(dp[j-1][i],dp2[j-1][i]+A.at(j).second);
      if(i>=A.at(j).first) tmp = dp2[j-1][i-A.at(j).first] +A.at(j).second;
      else tmp = 0;
      dp2[j][i] = max(dp2[j-1][i], tmp);
    }
  }
  cout << dp[N-1][T-1];
  return 0;
}

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


int main() {
  int H, W;
  int INF = pow(10, 9);
  cin >> H >> W;
  vector<vector<char>> G(H, vector<char>(W));
  int sum = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> G.at(i).at(j);
      if (G.at(i).at(j) == '.') {
        ++sum;
      }
    }
  }
  vector<vector<int>> M(H, vector<int>(W, -1));
  M.at(0).at(0) = 1;
  queue<pair<int, int>> q;
  q.push(pair<int, int>(0, 0));
  vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
  while (!q.empty()) {
    pair<int, int> coord = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int xi = coord.first + dx.at(i), yi = coord.second + dy.at(i);
      if (xi < 0 || yi < 0 || W - 1 < xi || H - 1 < yi || G.at(yi).at(xi) == '#' || M.at(yi).at(xi) != -1) {
        continue;
      }
      M.at(yi).at(xi) = M.at(coord.second).at(coord.first) + 1;
      q.push(pair<int, int>(xi, yi));
    }
  }
  if (M.at(H - 1).at(W - 1) == -1) {
    cout << -1 << endl;
  } else {
    cout << sum - M.at(H - 1).at(W - 1) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int X;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.X = sc.nextInt();
    }
    
    //解答処理
    private boolean solve() {
        boolean judge = false;
        
        if (X >= 30) {
        	judge = true;
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean answer) {
        if (answer) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }

}


Measured memory_bytes: 35656
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func abs(n int) int {
	if n > 0 {
		return n
	} else {
		return -n
	}
}

func main() {
	n, m := readInt(), readInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = readInt(), readInt()
	}
	c := make([]int, m)
	d := make([]int, m)
	for i := 0; i < m; i++ {
		c[i], d[i] = readInt(), readInt()
	}

	for i := 0; i < n; i++ {
		min := -1
		chk := -1
		for j := 0; j < m; j++ {
			d := abs(a[i]-c[j]) + abs(b[i]-d[j])
			if min == -1 || d < min {
				min = d
				chk = j + 1
			}
		}
		fmt.Println(chk)
	}
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll h, w, a, b; cin >> h >> w >> a >> b;
    rep(i, b) {
        rep(j, w) {
            if(j < a) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }
    rep(i, h-b) {
        rep(j, w) {
            if(j < a) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    sort(a, a + N, greater<int>());
    int cnt1 = 0, cnt2 = 0;
    rep(i, N) {
        if (a[0] == a[i]) cnt2++;
        else cnt1++;
    }
    if (abs(a[N - 1] - a[0]) > 1) {cout << "No" << endl; return 0;}
    if (a[N - 1] == N - 1) {cout << "Yes" << endl; return 0;}

    int k = N - a[0];
    //cout << k + 1 << " " << k * 2 << endl;
    if (k + 1 <= cnt2 && cnt2 <= k * 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //cout << cnt2 << " " << cnt1 << endl;



    return 0;
}
// a b c d e
// 4 4 4 4 4

// a a b c d
// 4 4 3 3 3

// a a a b c
// 3 3 3 2 2

// a a b b c
// 3 3 3 3 2

// a a a b b
// 2 2 2 2 2

// a a a a b
// 2 2 2 2 1

// a a a a a
// 1 1 1 1 1

// a a a b c d

// a a b b c d
// 4 4 4 4 3 3

// a a b b c c
// 3 3 3 3 3 3

// a a a b b b
// 2 2 2 2 2 2

// a a a a a b
// 2 2 2 2 2 1

Measured memory_bytes: 640