akhauriyash/Code-Regression huggingface dataset:
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


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


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto p = next_vec<int>(in, n);
  vec<int> posOf(n);
  FOR(i, n) {
    --p[i];
    posOf[p[i]] = i;
  }
  vec<int> leftMost(n, -1), rightMost(n, -1);
  i64 res = 0;
  for (int i = n-1; i >= 0; --i) {
    int pos = posOf[i];
    int le = pos, ri = pos;
    if (le - 1 >= 0 && p[le - 1] > i) {
      le = leftMost[le - 1];
    }
    if (ri + 1 < n && p[ri + 1] > i) {
      ri = rightMost[ri + 1];
    }
    i64 leSize = pos - le;
    i64 riSize = ri - pos;
    res += ((leSize * riSize) + leSize + riSize + 1) * (i + 1);
    leftMost[ri] = le;
    rightMost[le] = ri;
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
ll gcd(ll f , ll s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
int p[N];
queue<int>q;
ll Farray[1032][1032] , Sarray[1032][1023] , arr[1002][1003];
int main() {
	
	int n;cin >> n;
	if(n==2){
		cout << 4 << " " << 7 << endl << 23 << " " << 10 ;
		return 0;
	}
	for(int i = 2 ; i <= 1000 ; i++){
		if(!p[i]){
			for(int x = i + i; x <= 100000 ; x+=i)p[x] = 1;
		}
	}	
	for(int i = 2 ; i <= 100000 ; i++)if(!p[i])q.push(i);
	pair<int,int>start = mp(0,0);
	for(pair<int,int> i = start ; i.first < n ; i.first += 2){
		int currP = q.front();
		q.pop();
		for(pair<int,int> x = i ; x.first < n && x.second < n ; x.first++ , x.second++){
			Farray[x.first][x.second] = currP;
		}
	}
	for(pair<int,int> i = mp(0,2) ; i.second < n ; i.second += 2){
		int currP = q.front();
		q.pop();
		for(pair<int,int> x = i ; x.first < n && x.second < n ; x.first++ , x.second++){
			Farray[x.first][x.second] = currP;
		}
	}
	
	for(pair<int,int> i = start ; i.second < n ; i.second += 2){
		int currP = q.front();
		q.pop();
		for(pair<int,int> x = i ; x.first < n && x.second >= 0 ; x.first++ , x.second--){
			Sarray[x.first][x.second] = currP;
		}
	}

	for(pair<int,int> i = mp(1+(n%2),n-1) ; i.first < n ; i.first += 2){
		int currP = q.front();
		q.pop();
		for(pair<int,int> x = i ; x.first < n && x.second >= 0 ; x.first++ , x.second--){
			Sarray[x.first][x.second] = currP;
		}
	}


	for(int i = 0 ; i < n ; i++)
		for(int x = 0 ; x < n ; x++)
			arr[i][x] = Farray[i][x] * Sarray[i][x];
	for(int i=0 ; i< n ; i++){
		for(int j=0 ; j< n ; j++){
			if((i + j)%2== 1){
				set<ll>s;
				if(i != 0){
					s.insert(Farray[i-1][j]);
					s.insert(Sarray[i-1][j]);
				}
				if(i != n-1){
					s.insert(Farray[i+1][j]);
					s.insert(Sarray[i+1][j]);
				}
				if(j != 0){
					s.insert(Farray[i][j-1]);
					s.insert(Sarray[i][j-1]);
				}
				if(j != n-1){
					s.insert(Farray[i][j+1]);
					s.insert(Sarray[i][j+1]);
				}
				arr[i][j] = 1;
				set<ll>::iterator it = s.begin();
				for(;it!=s.end() ; it++)arr[i][j]*= *(it);
				arr[i][j]++;
			}
		}
	}
	for(int i=0 ; i< n ; i++){
		for(int j=0 ; j< n ; j++){
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}
	return 0;	
}

Measured memory_bytes: 23552
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  ll n;
  ll x = 0;
  ll y = 0;
  cin>>n;
  vector<vector<ll>> v(2,vector<ll>(n));
  rep(i,2) rep(j,n) cin>>v[i][j];
  rep(i,n) {
    if(v[0][i] < v[1][i])
      x+=(v[1][i]-v[0][i])/2;
    else
      y+=v[0][i]-v[1][i];
  }
  if(x>=y)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  
  return 0;
}


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

using namespace std;

const int N = 101000;

int a[N], b[N];
int deg[N], fat[N];
int paint[N];

vector <int> adj[N];

void dfs(int u, int l = -1) {
	for (int x: adj[u]) {
		if(l == x)continue;
		fat[x] = u;
		dfs(x, u);
	}
}

int main() {
	int n;
	scanf("%d", &n);


	for (int i = 0; i < n-1; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		deg[a[i]]++; deg[b[i]]++;
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}

	dfs(1);
	fat[1] = 0;
	paint[0] = 1;
	queue <int> q;

	for (int i = 2; i <= n; ++i) {
		if(deg[i] <= 1) {
			q.push(i);
		}
	}
	if(n == 1) {
		q.push(1);
	}
	int ok = 1;
	while(!q.empty()) {
		int at = q.front();
		//printf("%d\n", at);
		q.pop();
		if(paint[at] == 0) {
			paint[at] = 1;
			if(paint[fat[at]] == 0) {
				paint[fat[at]] = 1;
				if(fat[fat[at]] != 0) {
					deg[fat[fat[at]]]--;
					if(deg[fat[fat[at]]] <= 1 && paint[fat[fat[at]]] != 1) {
						q.push(fat[fat[at]]);
					}
				}
			} else {
				//printf("enter\n");
				ok = 0;
				break;
			}
		} else {
			//printf("enter\n");
			ok = 0;
			break;
		}
	}

	/*

		o
	   / \
	  o   o
	  	   \
	  	    o


	*/
	if (ok) puts("Second");
	else puts("First");
	
}

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(){
    // Your code here!!

    vector<string> vec1(3);
    
    REP(i,3){
        cin >> vec1[i];
        }

        cout<<vec1[0][0]<<vec1[1][1]<<vec1[2][2]<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int n;
	scanf("%d", &n);
	int a[200000];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n,sizeof(int), ASCttenannoryaku);
	for (int i = 0; i < n-1; i++) {
		//printf("%d ", a[i]);
		if (a[i] == a[i+1]) {
			printf("NO");
			return 0;
		}
	}

	printf("YES");
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	string s; cin >> s;
	int k; cin >> k;
	int num = 1, index = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != '1'){
			num = s[i] - '0';
			index = i;
			break;
		}
	}
	if(k - 1 >= index) cout << num << endl;
	else cout << 1 << endl;
		
	return 0;	
}





  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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 add(int a, int b){
	a = (a+b) % MOD;
	return a;
}
int mul(int a, int b){
	a = (a*b) % MOD;
	return a;
}
int mod_pow(int x, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}
int mod_inv(int x)
{
	return mod_pow(x, MOD - 2);
}
//割り算はmod_inv!

int dp[404][404];

signed main(){
	int N,C;
	cin>>N>>C;
	vector<int> a(N); for(auto& e:a)cin >> e;
	vector<int> b(N); for(auto& e:b)cin >> e;
	vector<vector<int>>sum(N,vector<int>(C+1,0));
	REP(i,N){
		REP(j,C+1){
			int tmp = 0;
			FOR(k,a[i],b[i]+1){
				tmp += mod_pow(k,j);
				tmp %= MOD;
			}
			sum[i][j] = tmp;
		}
	}
	REP(i,C+1)dp[1][i] = sum[0][i];
	FOR(i,1,N){
		REP(j,C+1){
			REP(k,C+1){
				if(j+k>403)continue;
				dp[i+1][j+k] += dp[i][j] * sum[i][k];
				dp[i+1][j+k] %= MOD;
			}
		}
	}
	cout << dp[N][C] << endl;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/
int main(){
	int N;
	cin >> N;
	int W[102] = {};
	FORq(i,1,N){
		cin >> W[i];
	}
	int ans = 1e6;

	FORq(i,1,N-1){
		int S1 = 0;
		int S2 = 0;
		FORq(j,1,i){
			S1 += W[j];
		}

		FORq(j,i+1,N){
			S2 += W[j];
		}

		chmin(ans,abs(S1-S2));
	}

	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
#define lb(x) (x&-x)
#define mod 1000000007
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
int n,m,ans=1,tot=0,tmp,t1,t2,t[500001],a[100001],b[100001],h[100001];
pr p[100001];
bool cmp(pr a,pr b){
	return a.first==b.first?a.second>b.second:a.first<b.first;
}
void add(int u,int x){
	for(;u<=n;u+=lb(u)){
		t[u]=(t[u]+x)%mod;
	}
}
int query(int u){
	int ret=0;
	for(;u;u-=lb(u)){
		ret=(ret+t[u])%mod;
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++){
		if(a[i]>b[1]&&a[i]<b[m]){
			tmp=lower_bound(b+1,b+m+1,a[i])-b;
			//if(a[i]==b[tmp])continue;
			p[++tot]=pr(a[i]-b[tmp-1],b[tmp]-a[i]);
			h[tot]=b[tmp]-a[i];
		}
	}
	sort(h+1,h+tot+1);
	t1=unique(h+1,h+tot+1)-h-1;
	for(int i=1;i<=tot;i++){
		p[i].second=lower_bound(h+1,h+t1+1,p[i].second)-h;
	}
	sort(p+1,p+tot+1,cmp);
	t2=unique(p+1,p+tot+1)-p-1;
	for(int i=1;i<=t2;i++){
		tmp=query(p[i].second-1)+1;
		ans=(ans+tmp)%mod;
		add(p[i].second,tmp);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b+c==17){
        if(a==b&&c==7){
            printf("YES");
        }else if(a==c&&b==7){
            printf("YES");
        }else if(b==c&a==7){
            printf("YES");
        }else{
            printf("NO");
        }
    }else{
        printf("NO");
    }
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main(){
	char W[1025],ans[1024][7];
	int clen=0,cans=0;;
	while(scanf("%c",&W[clen]),W[clen]!='\n'){
		if(W[clen]==' ' || W[clen]==',' || W[clen]=='.'){
			W[clen] = '\0';
			if(3<=clen && clen<=6){
				strncpy(ans[cans],W,clen+1);
				cans++;
			}
			clen = 0;
		}
		else clen++;
	}
	if(cans!=0) printf("%s",ans[0]);
	for(int i=1;i<cans;i++){
		printf(" %s",ans[i]);
	}puts("");
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;cin>>N>>M;
    if(N>=M){
        cout<<0<<endl;
        return 0;
    }
    int a[M],b[M-1];
    for(int i=0;i<M;i++)cin>>a[i];
    sort(a,a+M);
    for(int i=0;i<M-1;i++)b[i]=a[i+1]-a[i];
    sort(b,b+M-1,greater<int>());
    int ans=0;
    for(int i=0;i<N-1;i++)ans+=b[i];
    cout<<a[M-1]-a[0]-ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

		int n = stdIn.nextInt();
		int min = stdIn.nextInt();
		int max = min;
		BigDecimal sum = new BigDecimal(min);
		for(int i=0;i<n-1;i++){
			int t = stdIn.nextInt();
			min = Math.min(min, t);
			max = Math.max(max, t);
			sum = sum.add(new BigDecimal(t));
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 31856
s=list(input())
D=[s[0]]
i=0
while i < len(s) - 1:
  if s[i+1] == D[-1]:
    D.append(s[i+1:i+3])
    i+=2
  else:
    D.append(s[i + 1])
    i+=1

print(len(D)-(1 if i == len(s) else 0))

Measured memory_bytes: 11812
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> next(1, 0);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        next.push_back(t);
    }
    vector<int> v(n + 1, 0);
    v[1] = 1;
    vector<int> v1, v2;
    v1.push_back(1);
    int res = 0;
    while (v1.size() > 0) {
        v2.clear();
        for (auto node : v1) {
            if (node == 2) {
                cout << res << endl;
                return 0;
            }
            if (v[next[node]] == 0) {
                v2.push_back(next[node]);
                v[next[node]] = 1;
            }
        }
        v1 = v2;
        res++;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x = 0, w = 0;
	char ch = 0;
	while (!isdigit(ch)) {w |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();}
	return w ? -x : x;
}
const int M=100010;
const int N=300010;
struct seg_tree
{
	int cnt,l,r;
}t[N<<5];
int cnt_sgt,p[M],n,m;
struct rg
{
	int l,r;
	friend bool operator < (rg a,rg b)
	{
		return a.l<b.l;
	}
}rg[N];
void pushup(int root)
{
	t[root].cnt=t[t[root].l].cnt+t[t[root].r].cnt;
}
void insert(int &root,int l,int r,int x)
{
	t[++cnt_sgt]=t[root],root=cnt_sgt;
	if(l==r) 
	{
		t[root].cnt++;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) insert(t[root].l,l,mid,x);
	else insert(t[root].r,mid+1,r,x);
	pushup(root);
}
int query(int root1,int root2,int l,int r,int ll,int rr)
{
	if(ll<=l&&r<=rr) return t[root2].cnt-t[root1].cnt;
	int mid=l+r>>1;
	int s=0;
	if(ll<=mid) s+=query(t[root1].l,t[root2].l,l,mid,ll,rr);
	if(rr>mid) s+=query(t[root1].r,t[root2].r,mid+1,r,ll,rr);
	return s;
}
int main(int argc, char const *argv[])
{
	n=read(),m=read();
	for(int i=1;i<=n;++i) rg[i].l=read(),rg[i].r=read();
	sort(rg+1,rg+1+n);
	int q=1;
	for(int i=1;i<=m;++i)
	{
		p[i]=p[i-1];
		while(rg[q].l==i) insert(p[i],1,m,rg[q++].r);
	}
	printf("%d\n",n);
	for(int i=2;i<=m;++i)
	{
		int answer=n,j;
		for(j=i;j<=m;j+=i) answer-=query(p[j-i],p[j-1],1,m,j-i+1,j-1);
		if(j-i+1<=m) answer-=query(p[j-i],p[m],1,m,j-i+1,m);
		printf("%d\n",answer);
	}
	return 0;
}

Measured memory_bytes: 66432
from collections import deque
h, w = map(int, input().split())
bord = [list(input()) for _ in range(h)]
visit = [[-1 for _ in range(w)] for _ in range(h)]
visit[0][0] = 1


q = deque([[0,0]])
visit[0][0] = 1
while q:
    px, py = q.popleft()
    for i, j in ([1,0],[-1,0],[0,1],[0,-1]):
        if px+i >= 0 and px+i < h and py+j >= 0 and py+j < w:
            if bord[px+i][py+j] == "." and visit[px+i][py+j] < 0:
                visit[px+i][py+j] = visit[px][py]+1
                q.append([px+i, py+j])
if visit[h-1][w-1] < 0:
    print(-1)
else:
    c = [i.count(".") for i in bord]
    print(sum(c)-visit[h-1][w-1])

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

int main()
{
    map<string, int> table;
    int n;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        ++table[s];
    }
    int m = 0;
    for (auto i : table)
        if (m < i.second)
            m = i.second;
    for (auto i : table)
        if (i.second == m)
            cout << i.first << endl;
}

Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(a,k);
    k-=a;
    k-=b;
    if(k>0) ans-=min(c,k);
    cout<<ans;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

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

  if (a >= b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  } else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int q;
  cin>>q;
  while(q--){
    ll a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    ll l=0,r=b-a+1;
    while(r-l>1){
      ll mid=(l+r)/2;
      bool ng=false;
      for(ll i=(mid-10)/2;i<=(mid+10)/2;++i){//上に凸の二次関数より最大値付近を探索
        if((a+i)*(a+mid-i)>=a*b)ng=true;
      }
      if(!ng)l=mid;
      else r=mid;
    }
    cout<<2*(a-1)+l<<"\n";
  }
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	long long a, b, n;

	scanf("%lld %lld %lld", &a, &b, &n);

	if (n >= b)
	{
		n = b - 1;
	}

	printf("%lld\n", a*n / b - n / b*a);

	return 0;
}

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

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

using namespace std;
using graph=vector<vector<int>>;

graph T;

int dist[2][100000];
void dfs(int u,int p,int d,int type){
	dist[type][u]=d;
	for(int v:T[u]) if(v!=p) dfs(v,u,d+1,type);
}

int main(){
	int n,a,b; scanf("%d%d%d",&n,&a,&b); a--; b--;
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	dfs(a,-1,0,0);
	dfs(b,-1,0,1);

	int ans=0;
	rep(u,n) if(dist[0][u]<dist[1][u]) ans=max(ans,dist[1][u]-1);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s;cin>>s;
	int Min=INT_MAX;
	rep(i,s.size()-3+1){
		int a=0;
		rep(j,3){
			a=a*10+s[i+j]-'0';
		}
		Min=min(Min,abs(a-753));
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<double> p(n);
    rep(i,n) cin>>p[i];
    
    double dp[3100][3100];
    dp[0][0] = 1.0;
    //dp[i][j] = 最初のi枚のコインを投げたときに、表がj枚となる確率
    rep(i,n){
        for(int j=0; j<=i;j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0-p[i]);
        }
    }
    double ans = 0.0;
    for(int j=(n+1)/2;j<=n;j++) ans += dp[n][j];
    printf("%.10f",ans);
    return 0;
}

Measured memory_bytes: 74112
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        try(Scanner sc =new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n==0) break;
                int[] scores = new int[n];
                for(int i=0; i<scores.length; i++){
                    scores[i]=sc.nextInt();
                }
                double avg=0, var=0;
                for(int i=0; i<scores.length; i++){
                    avg+=scores[i];
                }
                avg/=scores.length;
                for(int i=0; i<scores.length; i++){
                    var+=Math.pow(avg-scores[i], 2);
                }
                var/=scores.length;
                System.out.println(Math.sqrt(var));
            }
        }
        
    }
}


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

const int N = 100100;
s64 fac[N + 1], finv[N + 1];

s64 mypow(s64 x, s64 n)
{
    s64 ret = 1;
    while (n)
    {
        if (n & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return ret;
}

void init()
{
    fac[0] = 1;
    rep (i, N)
    {
        fac[i + 1] = (fac[i] * (i + 1)) % MOD;
    }
    finv[N] = mypow(fac[N], MOD - 2);
    for (int i = N; i > 0; --i)
    {
        finv[i - 1] = (finv[i] * i) % MOD;
    }
}

s64 com(int n, int r)
{
    if (n < r || n < 0 || r < 0) return 0;
    return fac[n] * finv[n - r] % MOD * finv[r] % MOD;
}

void prime_factorization(s64 x, map<s64, int>& m)
{
    for (s64 i = 2; i * i <= x; ++i)
    {
        while (x % i == 0)
        {
            ++m[i];
            x /= i;
        }
    }
    if (x != 1) ++m[x];
}

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

    init();
    s64 n, m;
    cin >> n >> m;

    map<s64, int> f;
    prime_factorization(m, f);

    s64 ans = 1;

    for (auto& x : f)
    {
        ans = ans * com(n + x.second - 1, x.second) % MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int i,tmp,N,ans=0;

	scanf("%d",&N);

	int V[N],C[N];

	for(i=0;i<N;i++){
		scanf("%d",&V[i]);
	}
	for(i=0;i<N;i++){
		scanf("%d",&C[i]);
		tmp=V[i]-C[i];
		if(tmp>0)	ans+=tmp;

	}

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

	return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    A = int(input())
    B = int(input())

    if A > B:
        ans = "GREATER"
    elif A < B:
        ans = "LESS"
    else:
        ans = "EQUAL"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
using System;


namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int a = 1; a <= 10000; a++)
            {
                string B = Console.ReadLine();
                int b = int.Parse(B);
                if (b == 0)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Case " + a + ": " + b);
                }
            }
        }
    }
}

Measured memory_bytes: 9372
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c = map(int, input().split())
if a+b+1 < c:
    print(b+(a+b+1))
else:
    print(b+c)


Measured memory_bytes: 38512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M,com,x,y;
int height[100000],parent[100000];

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(height[x] < height[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(height[x] == height[y])height[x]++;
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i = 0; i < N; i++){
			height[i] = 0;
			parent[i] = i;
		}

		int a,b;

		for(int i = 0; i < M; i++){
			scanf("%d %d",&a,&b);
			a--,b--;
			unite(a,b);
		}

		int count = 0;
		for(int i = 0; i < N; i++){
			if(parent[i] == i)count++;
		}

		ll ans = 1;
		for(int i = 0; i < count; i++)ans = ans*2%MOD;

		if(count != N){
			ans = (ans+1)%MOD;
		}

		printf("%lld\n",ans%MOD);
	}

	return 0;
}

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

using namespace std;

double findval(double arr[],int n)
{
  double inv = 0;

  for(int i=0; i<n; i++) inv += 1/arr[i];

  return 1/inv;
}

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

  double arr[n];

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

  cout << findval(arr,n) << endl;

  return 0;

}


Measured memory_bytes: 256
from sys import stdin
#import numpy as np


def merge_sort(lst, low, high):
    if low >= high:
        return
    mid = int((low+high)/2)
    merge_sort(lst, low, mid)
    merge_sort(lst, mid+1, high)
    for i in range(low, mid+1):
        tmp_array[i] = lst[i]
    j = high
    for i in range(mid+1, high+1):
        tmp_array[i] = lst[j]
        j -= 1
    i = low
    j = high
    for k in range(low, high+1):
        if tmp_array[i] <= tmp_array[j]:
            lst[k] = tmp_array[i]
            i += 1
        else:
            lst[k] = tmp_array[j]
            j -= 1


S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)

tmp_array = [None for _ in range(N)]
res_map[N-1] = int(S[N-1])
index=1
for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1

res_map.sort()
temp_num=int(res_map[0])
index=1
tot = 0

for i in range(1,N):
    if temp_num==int(res_map[i]):
        index+=1
        continue
    else:
        if temp_num==0:
            tot += int(index*(index+1)/2)
        elif index>1:
            tot += int(index*(index-1)/2)
        index=1
        temp_num=int(res_map[i])


aa_table = [0 for i in range(2019)]
for i in range(len(res_map)):
    aa_table[res_map[i]]+=1

aa_table[0]+=1

tot = 0
for i in range(2019):
    tot+=int((aa_table[i]-1)*aa_table[i]/2)



#for i in range(2018):
#    num = np.sum(np.array(res_map)==i)
#    if i ==0:
#        num+=1
#    tot += int(num*(num-1)/2)
    

print(tot)



Measured memory_bytes: 25916
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vi rs(n),ws(n);
		rep(i,n) cin>>rs[i]>>ws[i];
		
		rep(i,n) per(j,i) if(rs[j]<rs[j+1]){
			swap(rs[j],rs[j+1]);
			swap(ws[j],ws[j+1]);
		}
		
		int rsum=accumulate(all(rs),0),wsum=accumulate(all(ws),0);
		if(2*rs[0]<=rsum){
			cout<<rsum+wsum<<endl;
			continue;
		}
		
		int gap=2*rs[0]-rsum;
		vi dp(gap+1); dp[0]=1;
		repi(i,1,n) peri(j,ws[i],gap+1)
			dp[j]|=dp[j-ws[i]];
		int overlap=-1;
		rep(i,gap+1) if(dp[i]) overlap=i;
		
		cout<<rsum+wsum+gap-overlap<<endl;
	}
}

Measured memory_bytes: 1204
#include <stdio.h>
int main(void)
{
	int a[100][100], b[100], n, m, temp;
	scanf("%d%d", &n, &m);
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0;i < m;i++)
	{
		scanf("%d", &b[i]);
	}
	for (int i = 0;i < n;i++)
	{
		temp = 0;
		for (int j = 0;j < m;j++)
		{
			temp += a[i][j] * b[j];
		}
		printf("%d\n", temp);
	}
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s; int k; cin >> s >> k;
	
	int cur = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '1') cur += 1;
		else break;
	}

	if(k - 1 < cur) cout << 1 << endl;
	else cout << s[cur] << endl;
	return 0;
}


Measured memory_bytes: 256
number=list(map(int,input().split()))
N,M,K=number[0],number[1],number[2]
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]
b=[0]
for i in range(1,len(A)+1):
    tmp=a[i-1]+A[i-1]
    a.append(tmp)
    
for i in range(1,len(B)+1):
    tmp=b[i-1]+B[i-1]
    b.append(tmp)

ans=0
j=M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 134084
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,N;
int sx,sy;
string s,t;
main()
{
	cin>>H>>W>>N>>sx>>sy>>s>>t;
	for(int r=0;r<4;r++)
	{
		char ss="LRUD"[r];
		char tt="RLDU"[r];
		int cnt=r==0?sy:r==1?W-sy+1:r==2?sx:H-sx+1;
		for(int i=0;i<N;i++)
		{
			if(s[i]==ss)cnt--;
			if(cnt<=0)
			{
				cout<<"NO"<<endl;
				return 0;
			}
			if(t[i]==tt&&cnt<(r<2?W:H))cnt++;
		}
	}
	cout<<"YES"<<endl;
}


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

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int>& rvnSort, int& rnSortCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vnLeft, vnRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;

  vnLeft.resize(nLeftSiz + 1);
  vnRight.resize(nRightSiz + 1);

  for (int i = 0; i < nLeftSiz; i++)
    vnLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vnRight[i] = rvnSort[nMid + i];

  vnLeft[nLeftSiz] = INT_MAX;
  vnRight[nRightSiz] = INT_MAX;
  int i = 0, j = 0;

  for (int n = nLeft; n < nRight; n++)
  {
    if (vnLeft[i] <= vnRight[j])
      rvnSort[n] = vnLeft[i++];
    else
      rvnSort[n] = vnRight[j++];
    rnSortCnt++;
  }
}

void fnMergeSort(vector<int>& rvnSort, int& rnSortCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnSortCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnSortCnt, nMid, nRight);
    fnMerge(rvnSort, rnSortCnt, nLeft, nMid, nRight);
  }
}

void fnResult(const vector<int>& cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i != 0)  cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnSort;

  fnInput(vnSort);

  int nLeft = 0;
  int nRight = vnSort.size();
  int nSortCnt = 0;
  fnMergeSort(vnSort, nSortCnt, nLeft, nRight);

  fnResult(vnSort, nSortCnt);

  return 0;
}

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

int main(){
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin >> A.at(i);
  }
  int count=0;
  sort(A.begin(),A.end());
  while(A.at(1)!=A.at(2)){
    A.at(0)++;
    A.at(1)++;
    count++;
  }
  while(A.at(0)<A.at(2)){
    A.at(0)+=2;
    count++;
  }
  if(A.at(0)==A.at(2)){
    cout << count << endl;
  }else{
    cout << count+1 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  long double d = sqrtl(a);
  long double e = sqrtl(b);
  long double f = sqrtl(c);
  if (d + e < f -1e-14){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = 0
for i in range(N):
  ans +=B[A[i]-1]
  if i!=0 and A[i]-A[i-1]==1:
    ans +=C[A[i-1]-1]
  #print(ans)
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int i = Integer.parseInt(sa[0]);
        int o = Integer.parseInt(sa[1]);
        int j = Integer.parseInt(sa[3]);
        int l = Integer.parseInt(sa[4]);
        br.close();
      
        long ans = o;
        boolean x=(j!=0);
        boolean y=(l!=0);
        boolean z=(i!=0);
      
      
        while ((j>0) && (l>0) && (i>0)) {
    		ans += 3;
            i--;
            j--;
            l--;
		}
                  
        if(j==0 && l%2==1 && i%2==1 && x){
            ans +=1;
            j++;
            i--;
            l--;
        }
        if(l==0 && j%2==1 && i%2==1 && y){
            ans +=1;
            l++;
            i--;
            j--;
        }
		if(i==0 && l%2==1 && j%2==1 && z){
            ans +=1;
            i++;
			j--;
			l--;
		}

		ans += i / 2 * 2;
		ans += j / 2 * 2;
		ans += l / 2 * 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include <stdio.h>
int a=0;
int b=0;
int c=0;
int m,i;
int main(){
	for(i=0;i<10;i++){
		m=0;
		scanf("%d",&m);
		if(m>c){
			if(m>b){
				if(m>a){
					c=b;
					b=a;
					a=m;
					continue;
				}
				c=b;
				b=m;
				continue;
			}
			c=m;
			continue;
		}
		
	}
	printf("%d\n%d\n%d\n",a,b,c);
	return 0;
}

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

int main() {
  ll n,m,x; 
  cin >> n >> m >> x;
  
  vector<ll> C(n);
  vector<vector<ll>> A(n, vector<ll>(m));
  
  rep(i, n){
    cin >> C[i];
    rep(j, m)
      cin >> A[i][j];
  }
  
  ll ans, sum;
  rep(i, n)
    sum += C[i]; sum++;
  ans = sum;
   
  rep(i, 1<<n){
    ll cost = 0; vector<ll> a(m);
    rep(k, n){
      if((1<<k)&i) continue;
      rep(j, m) a[j] += A[k][j];
      cost += C[k];
      
      rep(j,m){
        if (a[j] < x) break;
        if (j == m - 1) ans = min(ans, cost);
      }
    }
  }
  if(ans == sum){
    cout << -1 << endl; return 0;}
  cout << ans << endl;
}

Measured memory_bytes: 3632
N = int(input())

A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = int(input())
    xy[i] = [list(map(int, input().split())) for _ in range(A[i])]

ans = 0
for i in range(1<<N):
    honest = []
    unkind = []
    for j in range(N):
        if i & (1<<j):
            honest.append(j)
        else:
            unkind.append(j)
    
    flag = True
    for h in honest:
        for x, y in xy[h]:
            if y == 0 and (x-1) in unkind:
                continue
            if y == 1 and (x-1) in honest:
                continue

            flag = False
    
    if flag:
        ans = max(ans, len(honest))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int n, i;
  n = N;
  for (i = 0; pow(K, i) <= n; i++) {
    N = N / K;
}
  cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
struct data {
ll height;  // 名前
int x; // 価格
int y;

};

bool asc( const data& left, const data& right ) {
    return left.height == right.height ? left.x < right.x : left.height > right.height;
}

bool judge(data& center,data& data){
  int estimate;
  estimate= data.height+abs(center.x-data.x)+abs(center.y-data.y);
  if (estimate==center.height){
    return true;
  }else if(data.height==0&&estimate>center.height){
    return true;
  }else{
    return false;
  }

}

int main() {
  int n;
  scanf("%d \n",&n);
  std::vector<data> a(n);

  for (size_t i = 0; i < n; i++) {
    scanf("%d %d %llu\n",&a[i].x, &a[i].y,&a[i].height);
  }
  sort(a.begin(), a.end(),asc);

  data center;
  int flag=0;

  for (int j = 0; j <= 100; j++) {
    for (int k = 0; k <= 100; k++) {
      center.x=j;
      center.y=k;
      center.height=a[0].height+abs(a[0].x-j)+abs(a[0].y-k);

      for (int l = 1; l < n; l++) {
        if(judge(center,a[l])==false){
          flag=0;
          break;
        }else{
          flag=1;
        }
      }

      if(flag==1){
        printf("%d %d %llu\n",j,k,center.height);
        return 0;
      }
    }
  }
}


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

#define ll long long int
#define pi pair<ll,ll>

void solve(){
    int n, m;   cin >> n >> m;
    int ans = 0;
    vector<ll> v(n);
    for (int i = 0; i < n; i += 1) {
        cin >> v[i];
    }

    ll sum = accumulate(v.begin(), v.end(), 0LL);
    for (int i = 0; i < n; i += 1) {
        if (v[i]*4*m >= sum)
            ans += 1;
    }
    
    if (ans >= m)
        cout << "Yes\n";
    else 
        cout << "No\n";
}

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

    int test = 1;
    // cin >> test;
    while(test--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
map<int,int> m;
int main(void){
	ll N,W;
	cin >> N >> W;
	ll w1,v1;
	cin >> w1 >> v1;
	vector<vector<ll>> v(4);
	v[0].push_back(v1);
	for(int i=1;i<N;i++){
		int a,b;
		cin >> a >> b;
		a -= w1;
		v[a].push_back(b);
	}
	for(int i=0;i<4;i++){
		sort(ALL(v[i]),greater<>());
	}
	ll ans = 0;
	for(int a=0;a<=N;a++)for(int b=0;b<=N;b++)for(int c=0;c<=N;c++)for(int d=0;d<=N;d++){
		if(a+b+c+d>N)continue;
		if(a>v[0].size())continue;
		if(b>v[1].size())continue;
		if(c>v[2].size())continue;
		if(d>v[3].size())continue;
		ll Wsum = 0,Vsum = 0;
		Wsum = a*w1 + b*(w1+1) + c*(w1+2) + d*(w1+3);
		if(Wsum > W)continue;
		for(int i=0;i<a;i++)Vsum += v[0][i];
		for(int i=0;i<b;i++)Vsum += v[1][i];
		for(int i=0;i<c;i++)Vsum += v[2][i];
		for(int i=0;i<d;i++)Vsum += v[3][i];
		ans = max(ans,Vsum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>


/*
auto fib(int x)->int {

	return
		x <= 1 ? 1 : fib(x - 1) + fib(x - 2);
}*/

using ull = unsigned long long;

int main() {

	int n;
	std::cin >> n;
	
	ull tab[45]{};

	auto ans = [](auto f_, auto x) {
		return 
			f_(f_, x);
	}(
		[&](auto f, auto n) ->ull {
		return
			n <= 1 ? 1 :
			tab[n] == 0 ? tab[n] = f(f, n - 1) + f(f, n - 2) : tab[n];

		} ,	n);
	
//	std::cout << fib(3) << "\n";
	std::cout << ans << "\n";

//	std::cin >> ans;

	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int DP[100001];

signed main() {
    int n;
    cin>>n;
    int H[n+1];
    for(int i=1;i<=n;i++)
    cin>>H[i];
    DP[n]=0;
    DP[n-1] = abs(H[n]-H[n-1]);
    for(int i=n-2;i>=1;i--)
    {
        DP[i] = min(abs(H[i]-H[i+1]) + DP[i+1], abs(H[i]-H[i+2]) +DP[i+2]);
    }

    cout<<DP[1];

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long n,w,h;
  for(n=1;n<=3500;n++){
    for(w=1;w<=3500;w++){
      if((4*n*w-w*N-n*N)>0&&(N*n*w)%(4*n*w-w*N-n*N)==0){
        cout << (N*n*w)/(4*n*w-w*N-n*N) << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int N;
vector<vector<int> > p_infos;
bool is_finished;

int main()
{
    scanf("%d", &N);    
    for (int i = 0; i < N; i++) {
        int x, y, h;
        scanf("%d%d%d", &x, &y,&h);
        vector<int> v;
        v.push_back(x); v.push_back(y); v.push_back(h);
        if (h == 0) {
            p_infos.push_back(v);
        } else {
            p_infos.insert(p_infos.begin(), v);
        }
    }

    is_finished = false;
    for (int c_x = 0; c_x <= 100 && !is_finished; c_x++) {
        for (int c_y = 0; c_y <= 100 && !is_finished; c_y++) {
            int c_h = -1;
            for (int i = 0; i < N; i++) {
                int x, y, h, x_d, y_d;
                x = p_infos[i][0]; y = p_infos[i][1]; h = p_infos[i][2];
                x_d = abs(x - c_x); y_d = abs(y - c_y);

                if (h > 0) {
                    if (c_h == -1) {
                        c_h = h + x_d + y_d;
                    } else if (c_h != h + x_d + y_d) {
                        break;
                    }
                } else if (c_h - x_d - y_d > 0) {
                    break;
                }

                if (i == N - 1) {
                    printf("%d %d %d\n", c_x, c_y, c_h);
                    is_finished = true;
                }
            }
        }
    }
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int x[N],y[N];
    int ind[N];
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
        ind[i]=i;
    }
    double ans=0;
    int cnt=0;
    do{
        cnt++;
        double res=0;
        for(int i=0;i<N-1;i++){
            double tmp=0;
            tmp+=(x[ind[i+1]]-x[ind[i]])*(x[ind[i+1]]-x[ind[i]])*1.0;
            tmp+=(y[ind[i+1]]-y[ind[i]])*(y[ind[i+1]]-y[ind[i]])*1.0;
            res+=sqrt(tmp);
        }
        ans+=res;
    }while(next_permutation(ind,ind+N));
    ans/=cnt;
    cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256