akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);



using namespace std;

vector<pii> ind;
int main()
{
    fast;
    int n; cin >> n;
    ld sum = 0;
    FOR(i, n, 0)
    {
        ld x; cin >> x;
        sum += (1 / x);
    }
    sum = (1 / sum);
    cout << fixed << setprecision(6) << sum << endl;
    return 0;
}


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

int main(){
    int N,M,money=0;
    string temp;
    map<string,int> mp;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> temp;
        if(mp.find(temp)!=mp.end()){
            mp[temp]++;
        }
        else{
            mp[temp]=1;
        }
    }
    
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> temp;
        if(mp.find(temp)!=mp.end()){
            mp[temp]--;
        }
    }

    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second>money) money=itr->second;
    }
    
    cout << money << "\n";
    return 0;
}

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

using namespace std;

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

int BFS(vector<string> v)
{
	map<vector<string>, int> d; d[v] = 1;

	queue<pair<vector<string>, int> > que; que.push(make_pair(v, 1));

	for (int i = 0; i < 15; i++)
	{
		if (v[18][i] == 'O')
		{
			return 0;
		}
	}

	while (!que.empty())
	{
		vector<string> v1 = que.front().first;

		int dist = que.front().second; que.pop();

		int sx = -1, sy = -1;

		for (int i = 0; i < 19; i++)
		{
			for (int j = 0; j < 15; j++)
			{
				if (v1[i][j] == 'O')
				{
					sx = j; sy = i;
				}
			}
		}

		for (int dir = 0; dir < 8; dir++)
		{
			if (0 <= sx + dx[dir] && sx + dx[dir] < 15 && 0 <= sy + dy[dir] && sy + dy[dir] < 19)
			{
				if (v1[sy + dy[dir]][sx + dx[dir]] == 'X')
				{
					if (sx == 3 && sy == 8)
					{
						int a = 3;
					}
					int x = sx + dx[dir] * 2;
					int y = sy + dy[dir] * 2;

					while (true)
					{
						if (y > 18) { return dist; }

						if (x < 0 || 15 <= x || y < 0) { break; }

						if (y > 17) { return dist; }

						if (v1[y][x] == '.')
						{
							vector<string> v2 = v1;

							int rx = sx, ry = sy;

							for (; x != rx || y != ry;)
							{
								v2[ry][rx] = '.';

								rx += dx[dir];
								ry += dy[dir];
							}

							v2[y][x] = 'O';

							if (d[v2] == 0)
							{
								d[v2] = dist + 1;

								que.push(make_pair(v2, dist + 1));
							}

							goto Exit;
						}

						x += dx[dir];
						y += dy[dir];
					}
				}
			}

		Exit:;
		}
	}

	return -1;
}

int main()
{
	vector<string> v(19);

	for (int i = 0; i < 19; i++) { cin >> v[i]; }

	cout << BFS(v) << endl;

	return 0;
}

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

ans_list = [["WA", 0] for i in range(N)]

AC_count = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][1] += 1
        else:
            pass
    else:
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][0] = 'AC'
            AC_count += 1
        else:
            pass

WA_count = 0
for i in range(N):
    if ans_list[i][0] == 'AC':
        WA_count += ans_list[i][1]

print(AC_count, WA_count)    

Measured memory_bytes: 13172
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <map>
#include <stdlib.h>
#include <stdint.h>

using namespace std;

typedef long long	    ll;
typedef  intmax_t     intt;
typedef uintmax_t    uintt;
#define MAXX INTMAX_MAX

#define PI M_PI

//デバッグ、数値確認用
#define DBG(X) cout<< X <<endl

//繰り返し構文
#define REP(i, n)		for(intt i = 0;i < (n);i++)
#define FORL(i,m,a,n)	for(intt i = m;i <= (n);i+=a)	//CMDのfor/l
//#define FORL(i,m,a,n)	for(intt i = m;i <  (n);i+=a)	//CMDのfor/l
#define FORRL(i,m,a,n)	for(intt i = m;i >= (n);i+=a)
//#define FORRL(i,m,a,n)	for(intt i = m;i <  (n);i+=a)
#define ITEFOR(i,list)    for (auto i = list.begin();i != list.end();i++)

#define IN(a,n,b) ((a)<=(n)&&(n)<=(b))



int main()
{
    //intt ;
    //uintt ;
    //double ;
    string s;
    //vector<> ;
    //map<,> ;

    cin >> s;
    REP(i, s.length()) {
        cout << 'x';
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

const int N_MAX = 101;
int N;
int W[N_MAX];
int L[N_MAX], R[N_MAX];
int res = 1000001;
int tmp;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> W[i];
	L[0] = W[0];
	R[0] = W[N - 1];
	for (int i = 1; i < N; i++) {
		L[i] = L[i - 1] + W[i];
	}
	for (int i = 1; i < N; i++) {
		R[i] = R[i - 1] + W[N - 1 - i];
	}
	for (int i = 0; i < N - 1; i++) {
		tmp = abs(R[i] - L[N - 1 - i - 1]);
		res = min(tmp, res);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<i64>();
    let acm: Vec<i64> = v.iter().scan(0,|st, &x| {*st += x; Some(*st)}).collect();
    let mut ans = 0;
    let mut count: HashMap<i64,usize> = HashMap::new();
    for i in 0..n {
        if acm[i] == 0 {
            ans += 1;
        }
        if let Some(c) = count.get_mut(&acm[i]) {
            ans += *c;
            *c += 1;
            continue;
        }
        count.insert(acm[i], 1);
    }
    println!("{}",ans);
}


Measured memory_bytes: 20496
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int x,y,a,b,c;
priority_queue<int>pa,pb,pc;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>x>>y>>a>>b>>c;
    ll ans = 0;
    REP(i,1,a){
    	int v;
    	cin>>v;
    	pa.push(-v);
    	ans += v;
    }
    REP(i,1,b){
    	int v;
    	cin>>v;
    	pb.push(-v);
    	ans += v;
    }
    REP(i,1,c){
    	int v;
    	cin>>v;
    	pc.push(v);
    }
    while(pa.size() > x){
    	ans += pa.top();
    	pa.pop();
    }
    while(pb.size() > y){
    	ans += pb.top();
    	pb.pop();
    }
    while(!pc.empty()){
    	if(-pa.top() <= -pb.top() && pc.top() > -pa.top()){
    		ans += pa.top();
    		ans += pc.top();
    		pa.push(-pc.top());
    		pa.pop();
    		pc.pop();
    	}else if(pc.top() > -pb.top()){
    		ans += pb.top();
    		ans += pc.top();
    		pb.push(-pc.top());
    		pb.pop();
    		pc.pop();
    	}else break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1784
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define mp make_pair
#define what_is(x) cerr << #x << " is " << x << endl;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(vector<int> s)
{
    int n = s.size();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
    return z;
}

mt19937 rnd(time(0));
/*
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct CHT : multiset<Line, less<>> {
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) { // floored division
        return a / b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        auto l = *lower_bound(x);
        return l.k * x + l.m;
    }
};
*/

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

    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<int> b(n+1);
    vector<int> c(n+1);
    for (int i = 1; i<=n; i++) cin>>a[i];
    for (int i = 1; i<=n; i++) cin>>b[i];
    for (int i = 2; i<=n; i++) cin>>c[i];
    int total = 0;
    for (int i = 1; i<=n; i++) total+=b[i];
    for (int i = 2; i<=n; i++) if (a[i]==a[i-1]+1) total+=c[a[i]];
    cout<<total;


}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dp[40][500][500];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	string S;
	cin >> S;

	int ans = 1;
	char before = S[0];
	for (int i = 1; i < N;++i) {
		if (before != S[i])ans++;
		before = S[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 6144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int N0 = in.nextInt();
            int N = N0 * 3;
            long[] a = new long[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextLong();
            }

            PriorityQueue<Long> lp = new PriorityQueue<>();
            PriorityQueue<Long> rp = new PriorityQueue<>();
            long[] ls = new long[N];
            long[] rs = new long[N];
            Arrays.fill(ls, (long) 1E18);
            Arrays.fill(rs, (long) -1E18);
            long l = 0;
            for (int i = 0; i < N; i++) {
                lp.add(a[i]);
                l += a[i];

                if (lp.size() > N0) {
                    l -= lp.poll();
                }
                ls[i] = l;
            }
            long r = 0;
            for (int i = N - 1; i >= 0; i--) {
                rp.add(-a[i]);
                r += a[i];

                if (rp.size() > N0) {
                    r -= -rp.poll();
                }
                rs[i] = r;
            }

            long ma = (long) -1E18;
            for (int i = N0 - 1; i < 2 * N0; i++) {
                ma = Math.max(ma, ls[i] - rs[i + 1]);
            }

            out.println(ma);
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 77940
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long pairs = a[0]/2;
  a[0] %= 2;
  for (long i = 1; i < n; i++) {
    if (a[i-1] == 1 && a[i] >= 1) {
      pairs++;
      a[i]--;
    }
    pairs += a[i]/2;
    a[i] %= 2;
  }
  printf("%ld\n", pairs);

  return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<queue>
using namespace std;
int main(){
  int h,w,a[55][55],d[55][55],ans=0,x,y,i,j;
  char s;
  queue<int> q1;
  queue<int> q2;
  const int INF=(1<<29);
  scanf("%d %d\n",&h,&w);
  for(i=0;i<=h+1;i++){
    for(j=0;j<=w+1;j++){
      a[i][j]=1,d[i][j]=INF;
    }
  }
   for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%c",&s);
      if(s=='.'){
        a[i][j]=0;
        ans++;
      }
    }
     scanf("\n");
  }
  d[1][1]=1;
  q1.push(1),q2.push(1);
  while(!q1.empty()){
    x=q1.front(),y=q2.front();
    q1.pop(),q2.pop();
    if(a[x+1][y]==0 && d[x][y]+1<d[x+1][y]){
      q1.push(x+1),q2.push(y);
      d[x+1][y]=d[x][y]+1;
    }
    if(a[x-1][y]==0 && d[x][y]+1<d[x-1][y]){
      q1.push(x-1),q2.push(y);
      d[x-1][y]=d[x][y]+1;
    }
    if(a[x][y+1]==0 && d[x][y]+1<d[x][y+1]){
      q1.push(x),q2.push(y+1);
      d[x][y+1]=d[x][y]+1;
    }
    if(a[x][y-1]==0 && d[x][y]+1<d[x][y-1]){
      q1.push(x),q2.push(y-1);
      d[x][y-1]=d[x][y]+1;
    }
  }
  if(d[h][w]==INF){
    printf("-1\n");
  }
  else{
  ans=ans-d[h][w];
  printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if ((a == b && b == c) || (a != b && b != c && c != a))
        printf("No\n");
    else
        printf("Yes\n");
    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>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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(){
  string s;
  cin>>s;
  int n=s.size();
  int pos=0;
  vector<int>ans(n);
  while(pos<n){
    int cnt=0,cnt2=0;
    while(s[pos]=='R'){
      ++pos;
      ++cnt;
    }
    int l=pos-1;
    while(pos<n&&s[pos]=='L'){
      ++pos;
      ++cnt2;
    }
    ans[l]=(cnt+cnt2+(cnt)%2)/2;
    ans[l+1]=(cnt+cnt2+(cnt2)%2)/2;//奇数長の方が長くなる
  }
  rep(i,n){
    if(i)cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
}

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


Measured memory_bytes: 1104
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MEM(v,x) memset(v,x,sizeof v)

const double eps=1e-7,PI=3.1415926;
const int N=2e5+10;

using namespace std;

int n,q,m,k,x,y,a[N],mx=-1,mn=1e9,sum,t;
char c[N];
string s,s1,s2;
map < int , int > mp;
vector < int > vec;

 bool ok (LL x){
    for (LL i=2;i*i<=x;i++){
        if (x%i==0)return 0;
    }
    return 1;
 }

int main(){
    cin>>n;
    for (LL i=n;i<n+10000;i++){
        if (ok(i)){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>

int main() {

	/*int N, M, a[100], b[100][100];
	

	std::cin >> N >> M;

	for (int i = 0;i < M;i++) {

		std::cin >> a[i];
	}
	for (int i = 0;i < M;i++) {
		for (int j = 0;j < N;j++) {
		std::cin >> b[i][j];
		int ap(100);
		ap = 0;
		if (a[i] = b[i][j]) {
			ap += 1;

		}
		else {

		}
		}
		

	}
	
	
	*/

	int a, b, c, d, e, f;


	std::cin >> a >> b >> c >> d >> e >> f;

	int N =  std::min({ a, b, c, d });

	int n = a + b + c + d - N;
	
	int M = std::max(e, f);

	std::cout << n + M << std::endl;
	return 0;
}




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

alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))

result = 0

for i in range(n):
    result += blist[alist[i]-1]
    if i != n-1:
        if alist[i+1] == (alist[i] +1):
            result += clist[alist[i]-1]

print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
static const int64_t ANS_MAX = 1000000000000000000;

int main(void){
    int n;
    int64_t ans = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int64_t a;
        cin >> a;
        if(a == 0) {
            ans = 0;
            break;
        }
        if (a <= ANS_MAX / ans) {
            ans *= a;
        } else {
            ans = -1;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author bhatti
 */
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] sk = new int[2 * N];
        for( int i = 0 ; i < 2 * N ; ++i){
            sk[i] = sc.nextInt();
        }
        
        Arrays.sort(sk);
        
        int total = 0;
        for(int  i = 0 ; i < 2 * N ; i += 2){
            total += sk[i];
        }
        System.out.println(total);
    }
        
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(){
  int h, w;
  scanf("%d %d ", &h, &w);
  
  int grid[h + 1][w + 1];
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char c;
      scanf("%c ", &c);
      
      grid[i][j] = (c == '#') ? -1 : 0;
    }
  }
  
  for(int i = 0; i <= h; i++){
    grid[i][w] = 0;
  }
  
  for(int j = 0; j < w; j++){
    grid[h][j] = 0;
  }
  
  int result = 1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(grid[i][j] == -1){
        if(grid[i + 1][j] == 0 && grid[i][j + 1] == 0){
          result = 0;
          break;
        }else{
          if(grid[i + 1][j] == -1) grid[i + 1][j] = 1;
          if(grid[i][j + 1] == -1) grid[i][j + 1] = 1;
        }
      }else if(grid[i][j] == 1){
        if(grid[i + 1][j] == -1) grid[i + 1][j] = 1;
        if(grid[i][j + 1] == -1) grid[i][j + 1] = 1;
      }
    }
    
    if(!result) break;
  }
  
  if(result) puts("Yes");
  else puts("No");
  
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 100010;

int n;
vint graph[MAX_N];

int rev[MAX_N];
Pi dfs(int u, int p) {
  rev[u] = p;

  Pi res = Pi(0, u);
  for(int v : graph[u]) {
    if(v == p) continue;
    Pi temp = dfs(v, u);
    if(temp.first+1 > res.first) {
      res = Pi(temp.first+1, temp.second);
    }
  }
  return res;
}

Pi diameter() {
  Pi p = dfs(0, -1);
  memset(rev, -1, sizeof(rev));
  Pi q = dfs(p.second, -1);
  return Pi(p.second, q.second);
}

bool check(int u, int p, int d) {
  if(d > 0) return false;
  for(int v : graph[u]) {
    if(v == p) continue;
    if(!check(v, u, d+1)) return false;
  }
  return true;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> n;
  rep(i, n-1) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  int a, b;
  tie(a, b) = diameter();
  vint ord;
  for(int u = b; u != -1; u = rev[u]) {
    for(int v : graph[u]) {
      if(rev[u] == v || v == ord.back()) continue;
      if(!check(v, u, 0)) {
	cout << -1 << endl;
	return 0;
      }
    }
    ord.push_back(u);
  }
  vint id(n);
  iota(all(id), 0);
  int idx = 0;
  for(int u : ord) {
    ++idx;
    if(u == a || u == b) continue;
    rep(i, graph[u].size()-2) {
      swap(id[idx-1], id[idx]);
      ++idx;
    }
  }
  vint ans = id;
  reverse(all(ord));
  iota(all(id), 0);
  idx = 0;
  for(int u : ord) {
    ++idx;
    if(u == a || u == b) continue;
    rep(i, graph[u].size()-2) {
      swap(id[idx-1], id[idx]);
      ++idx;
    }
  }
  chmin(ans, id);
  rep(i, n) cout << ans[i]+1 << " \n"[i==n-1];


  return 0;
}


Measured memory_bytes: 15988
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A = LIST()

ans = 3**N
tmp = 1
for a in A:
	if a%2 == 0:
		tmp *= 2
print(ans-tmp)

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

int main()
{
char c;
cin>>c;
if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
{
    cout<<"vowel"<<endl;
}
else{
        cout<<"consonant"<<endl;
}
    return 0;
}



Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let a: i64 = s.trim().parse().unwrap();
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let b: i64 = s.trim().parse().unwrap();
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let h: i64 = s.trim().parse().unwrap();

    println!("{}", (a + b) * h / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200, mod = 1'000'000'007;
int tp[2][64];
void put(int id, long long v){
	for(int i = 0; i < 64; i++, v /= 2) tp[id][i] = v % 2;
}
int dp[64][2][2][2];
int count(int pos, int bg0, int sm1, int some){
	if(pos == -1) return 1;
	int & vdp = dp[pos][bg0][sm1][some];
	if(vdp != -1) return vdp;
	int l0 = bg0 ? 0 : tp[0][pos];
	int l1 = sm1 ? 1 : tp[1][pos];
	int ans = 0;
	for(int v0 = l0; v0 <= 1; v0++){
		for(int v1 = 0; v1 <= l1; v1++){
			if(some){
				if(v1 >= v0)
				       	ans += count(pos - 1, bg0 || (v0 > tp[0][pos]), sm1 || (v1 < tp[1][pos]), some);
			} else {
				if(v1 == v0)
				       	ans += count(pos - 1, bg0 || (v0 > tp[0][pos]), sm1 || (v1 < tp[1][pos]), some || (v1 > 0));
			}
			if(ans >= mod) ans -= mod;
		}
	}
	return vdp = ans;
}
int main(){
	long long a, b; cin >> a >> b;
	put(0, a);
	put(1, b);
	memset(dp, -1, sizeof(dp));
	cout << count(63, 0, 0, 0) << endl;
	return 0;
}


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

int fast_exp(int base,int exp){
    if(base==0){
        return 0;
    }
    if(exp == 0){
        return 1;
    }
    if(exp == 1){
        return base;
    }
    ll t = fast_exp(base,exp/2);
    t = (t*t)%2019;
    if(exp%2==1){
        t *= base;
        t %= 2019;
    }
    return t;
}

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

    string s; cin >> s;
    int c = 0;
    int r[s.size()];

    for(int i=s.size()-1;i>=0;i--){
        if(c==0){
            r[c] = (s[i]-'0');
        }
        else{
            r[c] =(r[c-1]+fast_exp(10,c)*(s[i]-'0'))%2019;
        }
        c++;
    }

    sort(r,r+s.size());

    ll ans = 0;
    map<int,int> M;

    for(int i=0;i<s.size();i++){
        M[r[i]]++;
    }

    for(auto u:M){
        ll a = u.first;
        ll b = u.second;
        if(a==0){
            ans += b;
        }
        ans += (b*(b-1))/2;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4504
N = int(input())
A = list(map(int,input().split()))
S = [0] * (N+1)
total = 0
 
for i in A:
  S[i] =S[i]+ 1
for i in S:
    total = i * (i - 1) // 2 + total
for i in A:
    #print(i,S[i])
    a=total-S[i]+1
    print(a)

Measured memory_bytes: 32272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;



int32_t main()
{
    fast

   int test=1;
   //cin>>test;
  
  while(test--)
  {
    
   int n,k;
   cin>>n>>k;
   set<int> s;
   for(int i=0;i<k;i++)
   {
    int d,x;
    cin>>d;
    for(int j=0;j<d;j++)
    {
        cin>>x;
        s.insert(x);
    }
   }
   cout<<n-s.size();

  // while loop ending
   }
  

return 0;
}

Measured memory_bytes: 3620
import fractions
from functools import reduce

S = list(map(int,input().split()))
N = S[0]
X = S[1]
x = list(map(int,input().split()))
x.append(X)
xmin = min(x)
xlist = list(map(lambda y: y-xmin ,x))
xlist.remove(0)

answer = reduce(fractions.gcd, xlist)
print(answer)

Measured memory_bytes: 16308
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());

long long a, b, c;

int main() {
    cin >> a >> b >> c;
    if (c + b - a < 0) {
        cout << "No" << endl;
        return 0;
    }
    if (4 * b * c < c * c + b * b + a * a + 2 * c * b - 2 * c * a - 2 * a * b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
	return 0;
}


Measured memory_bytes: 888
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long int
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,sz,m,b[li],a[li],k,flag,t,basla[li],bitir[li],x,y,tree[4*li],lazy[li*4],vis[li];
int cev;
string s;
vector<int> v[li];

inline void push(int node,int start,int end){
	if(lazy[node]==0)return ;
	tree[node]+=lazy[node];
	if(start!=end){
		lazy[node*2]+=lazy[node];
		lazy[node*2+1]+=lazy[node];
	}
	lazy[node]=0;
}

inline void update(int node,int start,int end,int l,int r,int val){
	push(node,start,end);
	if(start>end || start>r || end<l)return ;
	if(start>=l && end<=r){
		lazy[node]+=val;
		push(node,start,end);
		return ;
	}
	update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
	tree[node]=tree[node*2]+tree[node*2+1];
}

inline int query(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l)return 0;
	push(node,start,end);
	if(start>=l && end<=r){
		return tree[node];
	}
	return query(node*2,start,mid,l,r)+query(node*2+1,mid+1,end,l,r);
}

inline void dfs(lo node){
	vis[node]=1;
	//~ if()
	a[node]=++sz;
	basla[node]=sz;
	bitir[node]=sz;
	for(lo i=0;i<(lo)v[node].size();i++){
		lo go=v[node][i];
		if(vis[go]==1)continue;
		dfs(go);
		bitir[node]=max(bitir[node],bitir[go]);
	}
	
}

main(void){
	scanf("%lld %lld",&n,&m);
	for(lo i=1;i<n;i++){
		scanf("%lld %lld",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1);
	for(lo i=1;i<=m;i++){
		scanf("%lld %lld",&x,&y);
		update(1,1,n,basla[x],bitir[x],y);
	}
	FOR{
		printf("%lld ",query(1,1,n,a[i],a[i]));
	}
	return 0;
}


Measured memory_bytes: 54528
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define lson (rt << 1)
#define rson ((rt << 1) | 1)
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const LL INF = 1e18 + 10;

int main(){
	LL n, m;	scanf("%lld%lld", &n, &m);
	LL tmp = 1900 * m + 100 * (n - m);
	LL ans = 1;
	for(int i = 1; i <= m; ++i) {
		ans *= 2LL;
	}
	printf("%lld\n", tmp * ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  int sum=0;
   int ans=0;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
    c[i]=a[i]-b[i];
    if(b[i]>a[i]){
      sum+=b[i]-a[i];
      ans++;
    }
  }
  if(sum==0){
    cout<<0<<endl;
    return 0;
  }
  sort(c,c+n);
  repn(i,n-1){
    if(c[i]<=0){
      cout<<-1<<endl;
      return 0;
    }
    else{
      sum-=c[i];
      ans++;
      if(sum<=0){
	cout<<ans<<endl;
	return 0;
      }
    }
  }
      

  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
 public static void main(String[] args)
 {
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    if ((n % 500) > a) {
      System.out.println("No");
    }
   else {
     System.out.println("Yes");
   }
 }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
  ll n, W;
  cin >> n >> W;
  vll w(n + 1), v(n + 1);
  rep(i, 1, n + 1) cin >> w.at(i) >> v.at(i);

  vvll dp(n + 1, vll(100001, inf));
  dp.at(0).at(0) = 0;
  rep(i, 1, n + 1) rep(j, 0, 100001) {
    chmin(dp.at(i).at(j), dp.at(i - 1).at(j));
    if(j - v.at(i) >= 0)chmin(dp.at(i).at(j), dp.at(i - 1).at(j - v.at(i)) + w.at(i));
  }

  ll ans = 0;
  rep(i, 0, 100001) if(dp.at(n).at(i) <= W) chmax(ans, i);
  cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i=0; i<n; i++) cin >> x[i];

    int sum = 0;
    for (int i=0; i<n; i++) {
        int a = x[i]*2;
        int b= (k - x[i])*2;
        sum += min(a, b);
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>
#include<queue>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }
using namespace std;

vector<vector<int>> g;
vector<string> s;
vector<int> col;
int n;

bool is_bi(int node, int c = 0) {
    if (col[node] != -1) return col[node] == c;
    col[node] = c;
    for (int adj : g[node]) {
        if (!is_bi(adj, c == 0 ? 1 : 0)) return false;
    }
    return true;
}

using P = pair<int, int>;
int max_g(int node) {
    vector<bool> visited(n, false);
    queue<P> q;
    q.emplace(node, 1);
    visited[node] = true;
    int ans = 0;
    while (!q.empty()) {
        int i, depth;
        tie(i, depth) = q.front();
        visited[i] = true;
        ans = max(depth, ans);
        q.pop();
        for (auto adj : g[i]) {
            if (visited[adj]) continue;
            q.emplace(adj, depth + 1);
        }
    }
    return ans;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    g = vector<vector<int>>(n, vector<int>());
    s = vector<string>(n);
    col = vector<int>(n, -1);
    REP(i, n) {
        cin >> s[i];
        for (int j = i + 1; j < n; ++j) {
            if (s[i][j] == '1') {
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }
    if (!is_bi(0)) {
        cout << -1 << endl;
        return 0;
    }
    // int ans = 0;
    // REP(i, n) {
    //     // DD(i, max_g(i));
    //     ans = max(max_g(i), ans);
    // }
    int INF = 10000;
    auto d = vector<vector<int>>(n, vector<int>(n, INF));
    REP(i, n) {
        REP(j, n) {
            if (s[i][j] == '1') d[i][j] = 1;
        }
        d[i][i] = 0;
    }
    REP(k, n) REP(i, n) REP(j, n) {
        if (d[i][k] == INF || d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    int ans = 0;
    // REP(i, n) {DV(d[i]);}
    REP(i, n) REP(j, n) {
        if (i == j) continue;
        ans = max(d[i][j] + 1, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int N, W; cin >> N >> W;
	vector<int> w(N + 1);
	vector<ll> v(N + 1);
	rep(i, 1, N)cin >> w[i] >> v[i];

	vector<vector<ll>> dp(N + 1, vector<ll>(200001, 0));
	rep(i, 1, N)rep(j, 0, W)
	{
		if (j < w[i])dp[i][j] = dp[i - 1][j];
		else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
	}
	cout << dp[N][W] << endl;
}

Measured memory_bytes: 159744
#include <stdio.h>

#define WIDTH_MAX 50
#define HEIGHT_MAX 50

int field[ WIDTH_MAX + 2 ][ HEIGHT_MAX + 2 ];
const int dx[ 8 ] = { -1, 0, 1, -1, 1, -1, 0, 1 }, dy[ 8 ] = { -1, -1, -1, 0, 0, 1, 1, 1 };

void del( int x, int y );

int main( void ) {
	int w, h, x, y, sum;

	for ( ; scanf( "%d %d", &w, &h ), w; printf( "%d\n", sum ) ) {
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				scanf( "%d", field[ x ] + y );

		sum = 0;
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				if ( field[ x ][ y ] ) {
					del( x, y );
					sum++;
				}
	}

	return 0;
}

void del( int x, int y ) {
	int i;

	field[ x ][ y ] = 0;

	for ( i = 8; i--;  ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ] )
			del( nx, ny );
	}
}

Measured memory_bytes: 680
#include <stdio.h>
 
int main(){
  int n, x, i, j, k, c = 0;
  while(scanf("%d%d", &n, &x)){
    if(n == 0 && x == 0) break;
    for(i = 1;i < n - 1;i++)
      for(j = i + 1;j < n;j++)
        for(k = j + 1;k < n + 1;k++)
          if((i + j + k) == x) c++;
    printf("%d\n", c);
    c = 0;
  }
  return 0;
}



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

using namespace std;

const int N = 200200;

char s[N];
int l[N], r[N];

int main() {
  int n;
  scanf("%d %s", &n, s + 1);
  for (int i = 1; i <= n; ++i) {
    l[i] = l[i - 1] + (s[i] == '#');
  }
  for (int i = n; i > 0; --i) {
    r[i] = r[i + 1] + (s[i] == '.');
  }
  int ans = n;
  for (int i = 0; i <= n; ++i) {
    ans = min(ans, l[i] + r[i + 1]);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2048
s = io.read()
count = 0
ret = 0
start = false
for i = 1, #s do
	c = string.sub(s, i, i)
	if start then
		count = count + 1
		if  c == "Z" then
			ret = count
		end
	elseif c == "A" then
		start = true
		count = 1
	end
end

print(ret)

Measured memory_bytes: 760
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n , m;
    cin>>n>>m;
    int k = m / 2;
    int sum = 0;
    if(k <= n){
        sum = k;
    }else {
        sum = n;
        m -= n * 2;
        sum += m / 4 ;
    }
    cout<<sum<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000

vector<vector<int>> ng;
vector<bool> vis;
vector<int> ord;
int cnt = 0;
void dfs(int u)
{   
    if(vis[u])return;
    vis[u] = true;
    for(auto x:ng[u])
        dfs(x);

    ord[cnt++] = u;
}

int main()
{   
    fastio
    int n, m;
    cin>>n>>m;

    ng.resize(n);
    vis.resize(n , false);
    ord.resize(n);
    for(int i=0;i<m;i++)
    {
        int u , v;
        cin>>u>>v;
        ng[u-1].pb(v-1);
    }

    for(int i = 0 ; i<n;i++)
    {
        dfs(i);
    }

    int dp[n];
    for(int i=0;i<n;i++)dp[i]=0;
    int ans =0;
    for(int i = 0;i<n;i++)
    {
        int u = ord[i];

        for(auto x:ng[u])
        {
            dp[u] = max(dp[x]+1,dp[u]);
        }
        ans = max(ans , dp[u]);
    }
    
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 7552
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int N, L;
    cin >> N >> L;
    ll sum = 0;
    REP(i, N) {
        sum += L +i;
    }
    ll x=INF;
    REP(i, N){
        if((abs(x) > abs(L+i))) x = L+i;
    }
    cout << sum-x;
    cout << endl;
    return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    string s;
    int ans = 0;
    while(cin>>s) {
        string s2 = s;
        reverse(s);
        if(s==s2) ans++;
    }
    P(ans);
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {

long N;
cin>>N;
vector<long> A(N);
for(long i=0;i<N;i++){
cin>>A.at(i);
}

sort(A.begin(),A.end());
reverse(A.begin(),A.end());

long Answer=A.at(0);

for(long i=1;i<N-1;i++){
int j=i%2;
Answer+=A.at((i/2)+j);
}


cout<<Answer<<endl;

}

Measured memory_bytes: 4844