akhauriyash/Code-Regression huggingface dataset:
N=int(input())
a=list(map(int,input().split()))
dp=[[0]*(N+1) for i in range(N+1)]
for W in range(N):
    for l in range(N-W):
        r=l+W
        if (N-W+1)%2==0:
            dp[l][r]=max(a[l]+dp[l+1][r],dp[l][r-1]+a[r])
        else:
            dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r])
print(dp[0][N-1])

Measured memory_bytes: 113244
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 200005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
#define FUCK_YEAH ios_base::sync_with_stdio(false);cin.tie(NULL)
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
	ll res=1;
	a%=mod; 
	assert(b>=0); 
	for(;b;b>>=1)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
	if(!b)return 0;
	ll x = mulmod(a, b/2, c);
	if (b & 1)return (x+x+a)%c;
	return (x+x)%c;
}

ll cnt[MAX];

int main()
{
	FUCK_YEAH;
	ll n, k, x;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> x;
		cnt[x]++;
	}
	set <pair<int,int> > s;
	for(int i = 0; i < MAX; i++) {
		if(cnt[i] != 0) {
			s.insert(mp(cnt[i],i));
		}
	}
	pair<int,int> mn,mx,temp;
	ll tot = 0;
	while(s.size() > k) {
		mn = *s.begin();
		mx = *s.rbegin();
		temp = mx;
		mx.fi += mn.fi;
		s.erase(s.begin());
		s.erase(s.find(temp));
		s.insert(mx);
		tot+= mn.fi;
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123456], uiop[123456];
signed main() {
    int n, a, b, ans = 0; cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << abs(a - b) / 2 << endl;
    }
    else {
        cout << min(min(a, b) - 1, n - max(a, b)) + 1 + (abs(a - b) - 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
wv = [list(map(int,input().split())) for i in range(N)]

wv.sort()
wv.reverse()

dp = [[0]*(W+1) for i in range(N+1)]

for i, x in enumerate(wv,1):
    w = x[0]
    v = x[1]
    for j in range(w,W+1):
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)
        
print(dp[N][W])

Measured memory_bytes: 119788
a,b,c,x,y = gets.split.map &:to_i

if a + b > 2 * c then
	if x > y then
		if a > 2 * c then
			puts x * 2 * c
		else
			puts (x - y) * a + y * 2 * c
		end
	else
		if b > 2 * c then
			puts y * 2 * c
		else
			puts (y - x) * b + x * 2 * c
		end
	end
else
	puts a * x + b * y
end

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

using LL = long long;
using Graph = vector<vector<int>>;

const LL INF = 1e18;

vector<LL> bfs(auto G, auto C, auto S, auto P, auto Q) {
  vector<LL> cost(G.size(), P);
  vector<bool> used(G.size());
  queue<pair<int, int>> q;
  for(auto i: C) q.emplace(i, 0);
  while(!q.empty()) {
    auto cur = q.front().first, step = q.front().second;
    q.pop();
    if(step > S) break;
    if(used[cur]) continue;
    used[cur] = true;
    cost[cur] = step ? Q : INF;
    for(auto nex: G[cur]) if(!used[nex]) q.emplace(nex, step + 1);
  }
  cost.front() = cost.back() = 0;
  return cost;
}

LL Dijkstra(auto G, auto cost) {
  vector<LL> d(G.size(), -1);
  using Q = pair<LL, int>;
  priority_queue<Q, vector<Q>, greater<Q>> q;
  q.emplace(0, 0);
  while(!q.empty()) {
    auto c = q.top().first;
    auto cur = q.top().second;
    q.pop();
    if(cur == G.size() - 1) return c;
    if(~d[cur]) continue;
    d[cur] = c;
    for(auto nex: G[cur]) if(! ~d[nex]) q.emplace(c + cost[nex], nex);
  }
  return -1;
}

int main() {
  int N, M, K, S;
  cin >> N >> M >> K >> S;

  LL P, Q;
  cin >> P >> Q;

  vector<int> C(K);
  for(auto& i: C) cin >> i;
  for(auto& i: C) --i;

  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    int A, B;
    cin >> A >> B;
    --A;
    --B;
    G[A].emplace_back(B);
    G[B].emplace_back(A);
  }

  auto cost = bfs(G, C, S, P, Q);

  cout << Dijkstra(G, cost) << endl;
}

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

using namespace std;

int main(void){
    int N, cnt;

    cin >> N;

    vector<int> l(N);

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

    cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int k=j+1; k<N; k++){
                if(l[i] < l[j] + l[k] &&
                   l[j] < l[k] + l[i] &&
                   l[k] < l[i] + l[j]  ){
                       cnt++;
                   }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<long double>> memo(2, std::vector<long double>(n / 2 + 1, 0));
	memo[0][0] = 1;
	for (auto i = 1; i <= n; ++i) {
		long double p; std::cin >> p;
		memo[i % 2][0] = memo[(i + 1) % 2][0] * p;
		for (auto j = 1; j < memo[i % 2].size(); ++j) {
			memo[i % 2][j] = memo[(i + 1) % 2][j] * p + memo[(i + 1) % 2][j - 1] * (1 - p);
		}
	}
	std::cout << std::setprecision(15) << std::fixed << std::accumulate(memo[1].begin(), memo[1].end(), 0.0l) << std::endl;
}

Measured memory_bytes: 384
n = int(input())
masu = list(map(int, input().split(' ')))

masu_odd = masu[::2]
masu_odd_len = len(masu_odd)

ans=0
for i in range(masu_odd_len):
  if masu_odd[i]%2==1:
    ans+=1
    
print(ans)

Measured memory_bytes: 9052
#include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    int n;
    while(cin >> n) {
        vector<int> v;
        while(n != 0) {
            v.pb(n % 2);
            n /= 2;
        }
        //reverse(v.begin(), v.end());
        int j;
        rep(i,0,v.size()) {
            if(v[i] * pow(2,i) != 0) {
                j = i;
                cout << v[i] * pow(2,i);
                break;
            }
        }
        if(j != v.size()-1)
            rep(i,j+1,v.size()) (v[i] * pow(2,i) == 0) ? : cout << " " << v[i] * pow(2,i);
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1324
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int N, arr[maxn];
inline int getdis(int x)
{
    int fuck = 0;
    for (ri i = 1; i <= N; ++i) {
        fuck += (x - arr[i]) * (x - arr[i]);
    }
    return fuck;
}
signed main()
{
    N = read();
    for (ri i = 1; i <= N; ++i) {
        arr[i] = read();
    }
    int mn = inf;
    for (ri i = 1; i <= N; ++i) {
        for (ri j = -100; j <= 100; ++j) {
            int dis = getdis(j);
            mn = Min(mn, dis);
        }
    }
    writeln(mn);
    return 0;
}

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

int main(){
    ll h,n;
    string ans = "No";
    cin >> h >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end(),greater<ll>());
    rep(i,n){
        h -= a[i];
        if(h<=0)ans = "Yes";
    }
    cout << ans;
    return 0;
}


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

#define int long long
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define veci vector<int>
#define pii pair<int,int>
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define repi(i,a,b) for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define fi first 
#define se second
#define all(v) v.begin(),v.end()

int mod=1e9+7;

int powerm(int x,int y, int M){ int res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
int  power(int x,int y){ int res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
bool isprime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
int twoStacks(int x, vector<int> a, vector<int> b){
     int sum=0;
     int ans=0;
     int i=0; int j=0;
     while(i<a.size() && sum+a[i]<=x){
         sum+=a[i];
         i++;
     }
     ans=i;
     while(j<b.size() && i>=0){
         sum+=b[j];
         j++;

         while(sum>x && i>0){
             i--;
             sum-=a[i];
         }
         if(sum<=x && ans<i+j) ans=i+j;
     }
     return ans;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
    T=1;
//    cin>>T;
while(T--){
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    veci a(n), b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    ans = twoStacks(k, a, b);
    cout<<ans<<endl;
}
    
    return 0;
}

Measured memory_bytes: 9504
import math
import itertools
N = int(input())


n = N + 1
m = math.floor(math.sqrt(n))

ans = [0] * (N + 1)
#    print(s , m)        
for x, y, z  in itertools.product(range(1, m+1), repeat=3):
    www = x * x + y * y + z* z + x*y + y *z + z * x
    if www <= N :
        ans[x * x + y * y + z* z + x*y + y *z + z * x] += 1

ans = ans[1:]
for a in ans:
    print(a)


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

int main(void){
    int n;
    long min = 1000000, max = -1000000, sum = 0, a[10000];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(min > a[i]) min = a[i];
        if(max < a[i]) max = a[i];
        sum += a[i];
    }

    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int bubbleSort(int A[], int N){
    int s = 0;
    bool flag = 1;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j=N-1; j>=i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag=1;
                s++;
            }
        }
    }
    return s;
}

int main(void){
    int N, s;
    int A[101];
    
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    
    s = bubbleSort(A, N);
    
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << s << endl;
    
    return 0;
}



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

using namespace std;

typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> comp;
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        comp.push_back(a[i]);
        comp.push_back(b[i]);
    }
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());

    int t = comp.size();
    vector<int> imos(t + 1, 0);

    auto g = [&](int x){
        return distance(comp.begin(), lower_bound(comp.begin(), comp.end(), x));
    };

    for(int i = 0; i < n; ++i){
        ++imos[g(a[i])];
        --imos[g(b[i]) + 1];
    }
    for(int i = 0; i < t; ++i){
        imos[i + 1] += imos[i];
    }
    cout << *max_element(imos.begin(), imos.end()) << endl;



}



Measured memory_bytes: 5484
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Set<Character> set = new HashSet<>();

		for (char c : s) {
			if (!set.add(c)) {
				System.out.println("no");
				return;
			}
		}

		System.out.println("yes");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

//ACL
#include <atcoder/all>
using namespace atcoder;
//ACL END

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

//using bint = boost::multiprecision::cpp_int;


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;

int op(int a,int b){
    return max(a,b);
}

int e(){
    return (int)(-1e9);
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n,k;
    cin>>n>>k;
    segtree<int,op,e> seg(300001);
    rep(i,n){
        int a;
        cin>>a;
        seg.set(a,seg.prod(max(a-k,0ll),min(a+k+1,300001ll))+1);
        if(seg.get(a)<0){
            seg.set(a,1);
        }
    }
    cout<<seg.all_prod()<<endl;
}


Measured memory_bytes: 13792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, m, i, p[100000], suc[100100]={0}, sei=0,
         pena[100100]={0}, sumpena=0;
    string s[101000];
    cin >> n >> m;
    for(i=0;i<m;i++){
        cin >> p[i] >> s[i];
    }
    for(i=0;i<m;i++){
        if(s[i]=="WA"){
            if(suc[p[i]]==0) pena[p[i]]++;
        }
        else if(s[i]=="AC"){
            if(suc[p[i]]==0){
                sei++;
                sumpena+=pena[p[i]];
            }
            suc[p[i]]++;
        }
    }
    cout << sei << " " << sumpena <<endl;
    return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

ll A, B;

ll f(ll x) {
  ll f_x = 0;

  if ((x + 1) % 2 == 0) {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2 == 0;
  } else {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2 == 0;
    f_x ^= x;
  }

  return f_x;
}

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

  if (A == 0 && B == 0) {
    cout << 0 << endl;
    return 0;
  }
  // if (A == 0) {
  //   cout << f(B) << endl;
  //   return 0;
  // }

  A--;

  // F(0, A-1)
  ll f_a = f(A);

  // F(0, B)
  ll f_b = f(B);

  cout << (f_a ^ f_b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

const ll INF = 1e9;

struct segtree {
  int i, j, val, temp_val = INF;
  segtree *l, *r;
  segtree(int n, int _i, int _j) : i(_i), j(_j) {
    if (i == j) {
      val = n;
      l = r = NULL;
    } else {
      int k = (i + j) >> 1;
      l = new segtree(n, i, k);
      r = new segtree(n, k+1, j);
      val = std::min(l->val, r->val);
    }
  }
  void visit() {
    if (temp_val != INF) {
      val = std::min(val, temp_val);
      if (l) {
        l->temp_val = std::min(l->temp_val, temp_val);
        r->temp_val = std::min(l->temp_val, temp_val);
      }
      temp_val = INF;
    }
  }
  void update(int _i, int _j, int nv) {
    visit();
    if (_i <= i && j <= _j) {
      temp_val = std::min(temp_val, nv);
      visit();
    } else if (_j < i or j < _i) {
      // do nothing
    } else {
      l->update(_i, _j, nv);
      r->update(_i, _j, nv);
      val = std::min(l->val, r->val);
    }
  }
  int query(int _i, int _j) {
    visit();
    if (_i <= i and j <= _j) {
      return val;
    } else if (_j < i || j < _i) {
      return INF;
    } else {
      return std::min(l->query(_i, _j), r->query(_i, _j));
    }
  }
};

ll N, Q;

int main() {
  std::cin >> N >> Q;
  segtree *top_root = new segtree(N, 1, N);
  segtree *left_root = new segtree(N, 1, N);

  ll ans = (N-2)*(N-2);
  while (Q--) {
    int t, x; std::cin >> t >> x;
    if (t == 1) {
      int y = top_root->query(x, x);
      ans -= y-2;
      left_root->update(1, y, x);
    } else {
      int y = left_root->query(x, x);
      ans -= y-2;
      top_root->update(1, y, x);
    }
  }
  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 41080
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
using namespace std;
long double ans,a,b,h,m;
int main()
{
	cin>>a>>b>>h>>m;
	ans=sqrt(a*a+b*b-2.0*a*b*cos((30.0*h-5.5*m)/180.0*M_PI));
	printf("%.10Lf",ans);
	return 0;
}

Measured memory_bytes: 4180
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

ll power1(ll x, ll y)  
{  
    ll res = 1;     // Initialize result  
  	ll p=mod;
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
} 

ll power(ll a, ll b){
	ll ans = 1;
	while(b>0){
		if(b%2==1){
			ans*=a;
			ans%=mod;
		}
		a=a*a;
		a%=mod;
		b/=2;
	}
	return ans;
}

int main()
{
	fastio;
	ll n;
	cin>>n;
	if(n==1){
		cout<<"0"<<endl;
		return 0;
	}
	if(n==2){
		cout<<"2"<<endl;
		return 0;
	}
	ll minres = power1(10,n);
	ll minus = power1(9,n);
	ll plus = power1(8,n);
	minres = minres+(((mod-minus)%mod+(mod-minus)%mod))%mod;
	minres%=mod;
	minres+=plus;
	minres%=mod;
	cout<<minres<<endl;
	return 0;
}

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

int main()
{
cout << fixed << setprecision(14);
ll n,m,sum=0;
cin>>n>>m;
ll a[m],i;
for(i=0;i<m;i++){
	cin>>a[i];
	sum+=a[i];
}
if(sum>n)
{
	cout<<-1;
	return 0;
}
else
{
	cout<<n-sum;
	return 0;
}

}



Measured memory_bytes: 3708
program taman;
uses crt;
var
A,B:Integer;
function luas:Integer;
begin
luas:=(A*B)-A-B+1
end;
begin
clrscr;
read(A);
readln(B);
if (2<=A) and (A<=100) and (2<=B) and (B<=100) then
writeln(luas);
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
vector < vector<int> >ed;
vector < vector<int> >ind;
vector < vector<int> >w;
int mn;
int X;
int aim;
vector<int> path;
bool out = false;
void dfs(int a, int p) {
	if (a == aim) {
		out = true;
		return;
	}
	for (int i = 0; i < ed[a].size(); i++) {
		if (ed[a][i] != p) {
			path.push_back(w[a][i]);
			dfs(ed[a][i], a);
			if (out)return;
			path.pop_back();
		}
	}
	return;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	cin >> X;
	ed.resize(N);
	w.resize(N);
	vector<pair<int, pair<int, int> > >A(M);
	int res = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i].second.first >> A[i].second.second >> A[i].first;
		A[i].second.first--;
		A[i].second.second--;
	}
	sort(A.begin(), A.end());
	UnionFind uf(N);
	mn = 0;
	vector<int> u;
	for (int i = 0; i < M; i++) {
		if (!uf.findSet(A[i].second.first, A[i].second.second)) {
			//st.insert(make_pair((A[i].second.first, A[i].second.second));
			mn += A[i].first;
			uf.unionSet(A[i].second.first, A[i].second.second);
			ed[A[i].second.first].push_back(A[i].second.second);
			w[A[i].second.first].push_back(A[i].first);
			ed[A[i].second.second].push_back(A[i].second.first);
			w[A[i].second.second].push_back(A[i].first);
		}
		else {
			u.push_back(i);
		}
	}
	int c1 = 0;
	int c2 = 0;
	int mx;
	for (auto i : u) {
		out = false;
		path.clear();
		aim = A[i].second.second;
		dfs(A[i].second.first, -1);
		mx = -1;
		for (int j = 0; j < path.size(); j++) {
			mx = max(path[j], mx);
		}
		if (mn + A[i].first - mx == X) {
			c1++;
		}
		if (mn + A[i].first - mx > X) {
			c2++;
		}
	}
	//cerr << c1 << " " << c2 << endl;
	if (mn != X) {
		res = 1;
		for (int i = 0; i < c1; i++) {
			res = (res * 2) % MOD;
		}
		res = (res - 1 + MOD) % MOD;
		for (int i = 0; i < c2 + 1; i++) {
			res = (res * 2) % MOD;
		}
	}
	else {
		res = 1;
		for (int i = 0; i < N - 1 + c1; i++) {
			res = (res * 2) % MOD;
		}
		res = (res - 2 + MOD) % MOD;
		for (int i = 0; i < M - (N - 1 + c1); i++) {
			res = (res * 2) % MOD;
		}

	}
	cout << res << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0)break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if((i+j)%2 == 0)System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 31452
# ABC096B - Maximum Sum
a, b, c = sorted(list(map(int, input().rstrip().split())), reverse=True)
k = int(input())
if k == 1:
    print(a * 2 + b + c)
else:
    for i in range(1, k + 1):
        A = a * 2 + b + c
        B = a + b * 2 ++ c
        C = a + b + c * 2
        if max(A, B, C) == A:
            a *= 2
        elif max(A, B, C) == B:
            b *= 2
        else:
            c *= 2
    print(a + b + c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll cnt = 0;
    while(a >= b) {
        cnt++;
        b *= 2;
    }
    while(b >= c) {
        cnt++;
        c *= 2;
    }
    cout << ((cnt > k) ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>

using namespace std;

#define H 20

string field[H];
int w, h; 

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

int no_black = 0;
void count(int x, int y) {
    if (x < 0 || w <= x || y < 0 || h <= y || field[y][x] == '#') return;
    field[y][x] = '#'; no_black++;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        count(nx, ny);
    }
}

void init() {
    no_black = 0;
}

int main() {
    int x, y;
    while (cin >> w >> h) {
        if (w == 0 && h == 0) break;
        init();
        for (int i = 0; i < h; i++) {
            cin >> field[i];
            for (int j = 0; j < w; j++) {
                if (field[i][j] == '@') {
                    x = j;
                    y = i;
                }
            }
        }
        count(x, y);
        cout << no_black << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main()
{
	int i,l;
	char s[108];
	scanf("%s",s);
	l=strlen(s);
	for(i=0;i<=l-1;i++)
	{
		if(s[i]=='C')break;
	}
	if(i>=l-1)
	{
		printf("No\n");
		return 0;
	}
	else
	{
		for(i=i;i<=l-1;i++)
		{
			if(s[i]=='F')break;
		}
	}
	if(i>l-1)
	{
		printf("No\n");
		return 0;
	}
	else printf("Yes\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll f(ll x) {
  if (x == 1) return 1;
  return 2*f(x/2)+1;
}

int main () {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}

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

int main(){
  int serchn,numn;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    int outp = 0;
    int gh = 0;
    vector<int> num(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num[n];
    }
    for(int n = 0;n<serchn;n++){
      outp += num[n];
    }
    gh = outp;
    for(int a = 0,b=serchn;b<numn;a++,b++){
      gh += num[b];
      gh -= num[a];
      if(gh > outp)outp = gh;
    }
    cout << outp << endl;
  }
  return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
#define ll long long

using namespace std;


int main()
{

    ll n;
    cin >> n;
    ll a[n + 1][4], b[n + 1], c[n + 1];
    for (int i = 1; i <= n; i++)cin >> a[i][1] >> a[i][2] >> a[i][3];
    ll dp[n + 1][4];
    memset(dp, 0, sizeof(dp));

    dp[1][1] = a[1][1], dp[1][2] = a[1][2], dp[1][3] = a[1][3];
    for (int i = 1; i < n; i++) {

        for (int j = 1; j <= 3; j++)for (int k = 1; k <= 3; k++)if (j != k)dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]);


    }

    ll ans = 0;
    for (int i = 1; i <= 3; i++)ans = max(ans, dp[n][i]);
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define int long
signed main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  int t=0,u=0;

  rep(i,31)rep(j,31){
    if(100*a*i+100*b*j > f) continue;
    int cap = min(e*(a*i+b*j), f-100*(a*i+b*j));
    for(int k=0; k<=cap; k+=c){
      int dd = (cap-k)/d;
      dd *= d;
      int tot = 100*a*i+100*b*j+k+dd;
      if(tot > f) continue;
      if(tot*u <= (k+dd)*t){
        t = tot;
        u = k+dd;
      }
    }
  }

  assert(t!=0);
  cout << t << " " << u << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair

#define mod 1000000007LL
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define sq(x) ((x)*(x))

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define EPS 1e-7

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef long double T ;

const T PI = ( acosl(-1.0) ) ;

#define maxn 200005

char s[maxn] ;

int main()
{
    scanf("%s",s) ;

    int n = strlen(s) ;

    int cnt = 0 ;

    int ans = n ;

    for(int i=1 ; i<n ; i++)
    {
        if( s[i]==s[i-1] )
        {
            ans-- ;
            i+=2 ;
        }
    }

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

    return 0 ;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <ctype.h>
            
int main(void)
{
int i,sum[26]={0};
char ABC,j;
 
while(scanf("%c",&ABC) != EOF)
            
/*EOF(ファイル終了[End Of File])でないかどうか確認*/
            
{
if (isalpha(ABC))
            
/*入力されたものがアルファベットかどうか確認*/
            
{
j = tolower(ABC);
sum[j - 'a'] += 1;
            
/*入力されたアルファベットを小文字に変換&0~25の数値に変換*/
            
}
 
}
for(i = 'a';i <= 'z';i++)
{
printf("%c : %d\n",i,sum[(i -'a')]);
}
return 0;
}


Measured memory_bytes: 2096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String args[]) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		if(line.equals("5 5 7") || line.equals("5 7 5")||line.equals("7 5 5")){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		
	}
}


Measured memory_bytes: 7636
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    a = nl()
    ng = 0
    ok = max(a) + 1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        cnt = 0
        for x in a:
            cnt += (x - 1)//mid
        if cnt > k:
            ng = mid
        else:
            ok = mid
    print(ok)
    return

solve()


Measured memory_bytes: 30780
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func resolve(x, y int) string {
	if x*2 > y {
		return "No"
	}

	if x*4 < y {
		return "No"
	}

	if y%2 != 0 {
		return "No"
	}

	return "Yes"
}

func main() {
	x, y := scanInt(), scanInt()

	fmt.Println(resolve(x, y))
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K; cin>>N>>K;
  ll K2=K*2;
  vector<vector<ll>> Z(K2,vector<ll>(K,0)), Sr(K2,vector<ll>(K,0)),Sc(K2,vector<ll>(K,0));
  for(ll i=0; i<N; i++){
    ll p,q; char c;
    cin>>p>>q>>c;
    p%=K2; q%=K2; 
    if(q>=K){
      q-=K;
      c=(c=='B')?'W':'B';
    }
    if(c=='W') (p+=K)%=K2;
    Z[p][q]++;
  }
  Sr=Z; Sc=Z;
  for(ll i=0; i<K; i++) for(ll j=1; j<K2; j++) Sr[j][i]+=Sr[j-1][i];
  for(ll i=0; i<K2; i++) for(ll j=1; j<K; j++) Sc[i][j]+=Sc[i][j-1];
  ll ans=0,tmp=0;
  for(ll i=0; i<K; i++) tmp+=Sr[K-1][i];
  ll ytmp=tmp, xtmp;
  for(ll sy=0; sy<K; sy++){
    if(sy>0) ytmp+=Sr[K2-1][sy-1]-Sr[K-1][sy-1]*2;
    for(ll sx=0; sx<K; sx++){
      if(sx==0) xtmp=ytmp;
      else if(sx>0){
        xtmp-=Sc[K-sx][K-1];
        if(sy>0) xtmp+=Sc[K-sx][sy-1]*2;
        xtmp+=Sc[K2-sx][K-1];
        if(sy>0) xtmp-=Sc[K2-sx][sy-1]*2;
      }
      ans=max(ans,max(xtmp,N-xtmp));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    rep(i, x){
        pq.push(p[i]);
    }
    rep(i, y){
        pq.push(q[i]);
    }
    rep(i, min(x+y, c)){
        ll tmp = pq.top();
        if (tmp >= r[i]){
            break;
        }else{
            pq.pop();
            pq.push(r[i]);
        }
    }
    ll ans = 0;
    rep(i, x+y){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

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

    int cnt=0;
    while(true){
        if(1>=b){
            break;
        }

        if((1+a*cnt - cnt)>=b){
            break;
        }
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.size()==2)
    cout<<s<<endl;
  else
    cout<<s[2]<<s[1]<<s[0]<<endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();

    public void run() {
    	TCase:while(true){
    		int n=sc.nextInt();
    		if(n==0)return;
    		int res=0;
    		for(int a=0;a*a<=n;a++)
        		for(int b=a;a*a+b*b<=n;b++)
            		for(int c=b;a*a+b*b+c*c<=n;c++)
            			for(int d=c;a*a+b*b+c*c+d*d<=n;d++){
            	if(a*a+b*b+c*c+d*d==n)res++;
             }
    		ln(res);
    	}
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

Measured memory_bytes: 20040
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int k;

	cin >> k;

	int gu = k / 2;
	int ki = ( k % 2 == 0 ? k / 2 : k / 2 + 1);



	cout << gu * ki << endl;


	return 0;
}

Measured memory_bytes: 256
//PRZEMYSL ASSERTY

//SPRAWDZ CORNER CASE'Y, MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE

//MODULO = 1

//while (clock()<=69*CLOCKS_PER_SEC)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it) 
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

#define shandom_ruffle random_shuffle

const int nax=1000*1007;
const long long mod=1000*1000*1000+7;
const int d=3;

struct mac
{
	long long war[d][d];
	mac()
	{
		for (int i=0; i<d; i++)
			for (int j=0; j<d; j++)
				war[i][j]=0;
	}
	mac(int v)
	{
		for (int i=0; i<d; i++)
			for (int j=0; j<d; j++)
				war[i][j]=0;
		for (int i=0; i<d; i++)
			war[i][i]=v;
	}
	void wypisz()
	{
		for (int i=0; i<d; i++)
			debug() << range(war[i], war[i]+d);
		debug();
	}
};

mac operator *(mac a, mac b)
{
	mac ret=mac();
	for (int i=0; i<d; i++)
		for (int j=0; j<d; j++)
			for (int l=0; l<d; l++)
				ret.war[i][j]=(ret.war[i][j]+a.war[i][l]*b.war[l][j])%mod;
	return ret;
}

mac operator +(mac a, mac b)
{
	mac ret=mac();
	for (int i=0; i<d; i++)
		for (int j=0; j<d; j++)
			ret.war[i][j]=(a.war[i][j]+b.war[i][j])%mod;
	return ret;
}

mac operator -(mac a, mac b)
{
	mac ret=mac();
	for (int i=0; i<d; i++)
		for (int j=0; j<d; j++)
			ret.war[i][j]=(a.war[i][j]-b.war[i][j]+mod)%mod;
	return ret;
}

mac pot(mac a, int wyk)
{
	mac ret=mac(1);
	while(wyk)
	{
		if (wyk&1)
			ret=ret*a;
		a=a*a;
		wyk>>=1;
	}
	return ret;
}

mac ta_fajna;

long long magic_f(int v)
{
	mac ret=pot(ta_fajna, v);
	
	return ret.war[0][2];
}

int n, m;

int tab[nax];

mac dp[nax];
mac sum[nax];

long long wyn[nax];

int main()
{
	
	mac wez=mac();
	wez.war[0][0]=1;
	wez.war[0][1]=1;
	wez.war[0][2]=1;
	wez.war[1][1]=1;
	wez.war[1][2]=2;
	wez.war[2][2]=1;
	
	mac wez2=mac();
	wez2.war[0][0]=1;
	wez2.war[1][1]=1;
	wez2.war[2][2]=1;
	wez2.war[2][0]=1;
	
	ta_fajna=wez*wez2;
	
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++)
		scanf("%d", &tab[i]);
	tab[m+1]=n;
	//dp[0]=sum[0]=mac(1);
	wyn[0]=1;
	for (int i=1; i<=m+1; i++)
	{
		wez=sum[i-1]*pot(ta_fajna, tab[i]-tab[i-1]);
		
		wyn[i]=magic_f(tab[i])-wez.war[0][2]+mod;
		wyn[i]%=mod;
		
		dp[i]=mac(0);
		
		dp[i].war[0][0]=wyn[i];
		
		sum[i]=dp[i]+wez;
	}
	printf("%lld\n", wyn[m+1]);
	return 0;
}


Measured memory_bytes: 146432
a, b, c = map(int, input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    li_wk = sorted([a, b, c], reverse=True)
    print(li_wk[1] * li_wk[2])


Measured memory_bytes: 9064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String result = "No";
		for(int i = 0; i <= 100/4;i++) {
			for(int j = 0; j <= 100/7;j++) {
				int total = 4 * i + 7 * j;
				if(total == N) {
					result = "Yes";
					break;
				}
			}
		}
		System.out.println(result);

	}

}

Measured memory_bytes: 23764