akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

Measured memory_bytes: 256
#include <bits/stdc++.h>          
using namespace std;               
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int A = 0;
    int k = 0;
    for(int i = 0; i < N; i++){
        A++;
        if(a.at(k) == 2) {
            break;
        }
        k = a.at(k) - 1;
    }
    if(A < N){
        cout << A << endl;
    }
    else{
        cout << -1 << endl;
    }
}


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

int main() {
  int N, Sum=0;
  string tmp;
  cin >> N;
  vector<string> A;
  rep(i, N){
    cin >> tmp;
    A.push_back(tmp);
  }
  sort(A.begin(), A.end());
  rep(i, N){
    int cnt=1;
    for(int j=i+1; j<N; j++){
      if(A.at(i)==A.at(j)){
        cnt++;
        i++;
      }
      else break;
    }
    Sum+=cnt%2;
  }
  cout << Sum << endl;
}

Measured memory_bytes: 7284
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			int x = scan.nextInt();
			int a,b,c = 1;
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}
			for(a = 1;a<=n;a++){
				for(b = a;b<=n;b++){
					for(c = b;c<=n;c++){
						if(x == (a+b+c) && (a!=b) && (b!=c) && (c!=a)){
							count ++;
							//break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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

int main(){
  ll a, b, c;
    cin >> a >> b >> c;
    ll ans;
      ans = min(a*b*abs(c-c/2-c/2), min(a*c*abs(b-b/2-b/2), c*b*abs(a-a/2-a/2)));
      cout << ans << endl;
}


Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const N = Number(input[0]);
  const line2_arr = input[1].split(" ");
  let ans = 0;
  for (let i = 0; i < N - 1; i++) {
    if (Number(line2_arr[i]) > Number(line2_arr[i + 1])) {
      ans += Number(line2_arr[i]) - Number(line2_arr[i + 1]);
      line2_arr[i + 1] = line2_arr[i];
    }
  }
  console.log(ans);
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 49156
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    ll a=0;
    for(int i=0;i<n-1;i++){
        if(str[i]=='L' && str[i+1]=='L') a++;
    }
    for(int i=0;i<n-1;i++){
        if(str[i]=='R' && str[i+1]=='R') a++;
    }
    a=min(n-1,a+2*k);
    cout<<a;
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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



int main() {
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int dx,dy;
dx=x2-x1;
dy=y2-y1;
cout<<x2-dy<<" "<<y2+dx<<" "<<x1-dy<<" "<<y1+dx<<endl;
}

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

int main()
{
    int W, H;


    while ( cin >> W >> H, W || H ) {
        int dp[22][22] = {};
        int mas[22][22] = {};

        for ( int i = 0; i < H; i++ ) {
            for ( int j = 0; j < W; j++ ) {
                cin >> mas[i][j];
            }
        }

        for ( int i = 0; i < W; i++ ) {
            if ( mas[0][i] == 0 ) {
                dp[0][i] = 1;
            }
        }

        for ( int i = 0; i < H - 1; i++ ) {
            for ( int j = 0; j < W; j++ ) {
                if ( mas[i][j] == 2 ) {
                    if ( mas[i + 2][j] != 1 ) {
                        dp[i + 2][j] += dp[i][j];
                    }
                } else {
                    for ( int k = -1; k <= 1; k++ ) {
                        if ( 0 <= j + k && j + k < W ) {
                            if ( mas[i + 1][j + k] == 0 ) {
                                dp[i + 1][j + k] += dp[i][j];
                            } else if ( k == 0 && mas[i + 1][j] == 2 ) {
                                dp[i + 1][j] += dp[i][j];
                            }
                        }
                    }
                }
            }
        }
        int sum = 0;
        for ( int i = 0; i < W; i++ ) {
            sum += dp[H - 1][i] + dp[H][i];
        }

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



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

ll dp[101][100001] = { inf };

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

	// long long?
	ll N, W;
	cin >> N >> W;

	vector<int> vw(N, 0);
	vector<int> vv(N, 0);
	rep(i, N) {
		cin >> vw[i] >> vv[i];
	}

	rep(i, 101) {
		rep(j, 100001) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;

	for (int i = 0; i != N; ++i) {
		for (int j = 0; j != 100001; ++j) {
			if (j >= vv[i]) {
				dp[i + 1][j] = min(dp[i][j - vv[i]] + vw[i], dp[i][j]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	ll ans = 0;
	for (int j = 0; j != 100001; ++j) {
		if (dp[N][j] <= W) {
			ans = max(ans, (ll)j);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 79232
import sys
sys.setrecursionlimit(10**7)

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
visited = [[False] * w for _ in range(h)]

def dfs(y, x):
    visited[y][x] = True
    blk, wht = 0, 0

    for dy, dx in ((-1, 0), (0, -1), (1, 0), (0, 1)):
        ny, nx = y+dy, x+dx
        if (not (0 <= ny < h)) or (not (0 <= nx < w)) or visited[ny][nx]: continue
        if s[y][x] != s[ny][nx]:
            nb, nw = dfs(ny, nx)
            blk += nb; wht += nw
    
    if s[y][x] == "#": blk += 1
    else: wht += 1

    return blk, wht

ans = 0
for i in range(h):
    for j in range(w):
        if not visited[i][j]:
            blk, wht = dfs(i, j)
            ans += blk * wht

print(ans)


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<int> a(n);
  cin >> a;

  int cnt[101010] = {};
  for (auto i : a) cnt[i]++;

  int ans = 0;
  for (int i = 1; i + 1 < 101010; ++i) chmax(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    /*
    int a, b;
    cin >> a >> b ;
    //*/

    //*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( vec.at(0) != vec.at(2) && ( vec.at(0) == vec.at(1) || vec.at(2) == vec.at(1) ) ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << b + 100 * ( 10 - min(a, 10) ) << endl;
    
    //printf("%lf\n", ((a / 2 + a % 2) / a));

    return 0; 
}


Measured memory_bytes: 3604
n = int(input())
half_n = int(n//2)
ans = []

if n == 2:
    print(2)
    exit()
else:
    for i in range(1, half_n):
        a = str(i)
        b = str(n-i)
        count_a = 0
        count_b = 0
        for ai in a:
            count_a += int(ai)
        for bi in b:
            count_b += int(bi)
        ans.append(count_a + count_b)

print(min(ans))

Measured memory_bytes: 3480
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        char[] cline = new char[10];
        String key = "";
        long tmpCount = 0;
        long count = 0;//結果
        
        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < N; i++) {
            tmpCount = 0;

            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);
            tmpCount = map.getOrDefault(key, 0);

            count += tmpCount;

            map.put(key, (int) (tmpCount + 1));
        }
        
        System.out.println(count);
    }
}


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

int main()
{
    long long n;
    cin >> n;
    long long x = 100;
    for (long long d = 0; ; d++)
    {
        if (x >= n)
        {
            cout << d << endl;
            break;
        }
        x += x/100;
    }
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int blue[2005][2005];
int Vedges[2005][2005];
int Ledges[2005][2005];
string field[2005];
int main() {
    //cout.precision(10);
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 1; i <= n; i++){
        cin >> field[i];
        field[i] = "#" + field[i];
    }
    if(field[1][1] == '1') blue[1][1] = 1;
    for(int i = 2; i <= n; i++){
        blue[i][1] = blue[i - 1][1];
        if(field[i][1] == '1') blue[i][1]++;
    }
    for(int i = 2; i <= m; i++){
        blue[1][i] = blue[1][i - 1];
        if(field[1][i] == '1') blue[1][i]++;
    }
    for(int i = 2; i <= n; i++){
        for(int j = 2; j <= m; j++){
            blue[i][j] = blue[i - 1][j] + blue[i][j - 1] - blue[i - 1][j - 1];
            if(field[i][j] == '1') blue[i][j]++;
        }
    }
    if(n > 1){
        for(int i = 1; i <= m; i++){
            Vedges[1][i] = Vedges[1][i - 1];
            if((field[1][i] == '1') && (field[2][i] == '1')) Vedges[1][i]++;;
        }
    }
    for(int i = 2; i < n; i++){
        Vedges[i][1] = Vedges[i - 1][1];
        if((field[i][1] == '1') && (field[i + 1][1] == '1')) Vedges[i][1]++;
    }
    for(int i = 2; i < n; i++){
        for(int j = 2; j <= m; j++){
            Vedges[i][j] = Vedges[i - 1][j] + Vedges[i][j - 1] - Vedges[i - 1][j - 1];
            if((field[i][j] == '1') && (field[i + 1][j] == '1')) Vedges[i][j]++;
        }
    }
    if(m > 1){
        for(int i = 1; i <= n; i++){
            Ledges[i][1] = Ledges[i - 1][1];
            if((field[i][1] == '1') && (field[i][2] == '1')) Ledges[i][1]++;;
        }
    }
    for(int i = 2; i < m; i++){
        Ledges[1][i] = Ledges[1][i - 1];
        if((field[1][i] == '1') && (field[1][i + 1] == '1')) Ledges[1][i]++;
    }
    for(int i = 2; i <= n; i++){
        for(int j = 2; j < m; j++){
            Ledges[i][j] = Ledges[i - 1][j] + Ledges[i][j - 1] - Ledges[i - 1][j - 1];
            if((field[i][j] == '1') && (field[i][j + 1] == '1')) Ledges[i][j]++;
        }
    }
    for(int i = n; i >= 1; i--){
        for(int j = 1; j <= m; j++){
            //cout << blue[i][j] << " ";
        }
        //cout << endl;
    }
    for(int time = 1; time <= q; time++){
        int x1, y1, x2, y2;
        cin >> y1 >> x1 >> y2 >> x2;
        //cout << blue[y2][x2] << " " <<  blue[y1 - 1][x2] << " "<<  blue[y2][x1 - 1] << " " <<  blue[y1 - 1][x1 - 1];
        int points = blue[y2][x2] - blue[y1 - 1][x2] - blue[y2][x1 - 1] + blue[y1 - 1][x1 - 1];
        //cout << endl << points << " ";
        int edge = 0;
        edge += Vedges[y2 - 1][x2] - Vedges[y1 - 1][x2] - Vedges[y2 - 1][x1 - 1] + Vedges[y1 - 1][x1 - 1];
        //cout << edge << " ";
        edge += Ledges[y2][x2 - 1] - Ledges[y1 - 1][x2 - 1] - Ledges[y2][x1 - 1] + Ledges[y1 - 1][x1 - 1];
        //cout << edge << endl;
        cout << points - edge << endl;
    }
    return 0;
}


Measured memory_bytes: 52864
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint n,ans=0,i,mae,x,sa,rui=1,wa=0;cin>>n;
	cin>>mae;
	for(i=1;i<n;i++){
		cin>>x;
		sa=x-mae;
		ans*=i;wa*=i;wa+=rui;rui*=i;wa%=mod;rui%=mod;
		ans+=sa*wa;ans%=mod;
		mae=x;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>

int main(){
	double a,b,c,d;
	scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
	printf("%.8lf\n",sqrt(pow(c-a,2.0)+pow((d-b),2.0)));
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
#define MAX_N 8
int N, A, B, C;
int L[MAX_N + 1];
int ans = 10000000;
void func(int i, int keep , int sa, int sb, int sc){

	if(i == N){

	 if(0 < sa && 0 < sb && 0 < sc){
	  keep += abs(A - sa) + abs(B - sb) + abs(C - sc);
      ans = min(ans , keep - 30);
	 }

	}else{

	 func(i + 1 , keep + 10 , sa + L[i + 1] , sb , sc);
	 func(i + 1 , keep + 10 , sa , sb + L[i + 1] , sc);
	 func(i + 1 , keep + 10 , sa , sb , sc + L[i + 1]);
	 func(i + 1 , keep , sa , sb , sc); 		//i番目は使わない

	}

}

int main(void){

	cin >> N >> A >> B >> C;
	for(int i = 0 ; i < N ; i++)
	 	cin >> L[i];

	 func(0 , 10 , L[0] , 0 , 0);
	 func(0 , 10 , 0 , L[0] , 0);
	 func(0 , 10 , 0 , 0 , L[0]);
	 func(0 , 0 , 0 , 0 , 0);

	 cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0;
        return 0;
    }
    ll best = 1e18;
    best = min(best, min(h, w));
    for (int it = 0; it < 2; it++) {
        for (int sz = 0; sz <= h; sz++) {
            ll ar = sz * w;
            ll other_ar = (h - sz) * (w / 2);
            ll other_ar2 = (h - sz) * ((w + 1) / 2);
            best = min(best, max({abs(other_ar - other_ar2), abs(ar - other_ar), abs(ar - other_ar2)}));
        }
        swap(h, w);
    }
    cout << best;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n>=1800)
      printf("1\n");
    else if(n>=1600)
      printf("2\n");
    else if(n>=1400)
      printf("3\n");
    else if(n>=1200)
      printf("4\n");
    else if(n>=1000)
      printf("5\n");
    else if(n>=800)
      printf("6\n");
    else if(n>=600)
      printf("7\n");
    else
      printf("8\n");
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n, k; cin >> n >> k;
    long long ans = 0;
    vector<ll> cnt(k+1);
    for(int i = k; i >= 1; i--) {
        cnt[i] = power(k/i, n);
        for(int j = 2*i; j <= k; j += i) {
            cnt[i] = (cnt[i] - cnt[j] + mod) % mod;
        }
        ans = (ans + cnt[i] * i % mod) % mod;
    }
    cout << ans << "\n";







    return 0;
    
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>  
    using namespace std;  
    inline int read()  
    {  
        int x=0;char ch=getchar();  
        while(ch>'9'||ch<'0')ch=getchar();  
        while(ch<='9'&&ch>='0')x=x*10+ch-'0',ch=getchar();  
        return x;  
    }  
    int n,a[200010],t;  
    int main()  
    {  
        n=read();  
        for(int i=1;i<=n;i++)  
        {  
            a[i]=read();      
        }     
        sort(a+1,a+n+1,greater<int>());  
        for(;a[t]>=t;t++);  
        t--;  
        if((a[t]-t)%2==0)  
        {  
            int j=0;  
            for(;a[t+j]>=t;j++);  
            if(j%2)  
            {  
                cout<<"Second"<<endl;  
                return 0;  
            }  
        }  
        cout<<"First"<<endl;  
        return 0;  
    }  

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

uint32_t gcd( uint32_t a, uint32_t b, uint32_t c ){
  uint32_t minVal = min( a, b );
  minVal = min( minVal, c );

  uint32_t result = 1;
  uint32_t x = 2;
  while(1){

    if( x > a || x > b || x > c ){
      break;
    }
    
    if( a % x == 0 && b % x == 0 && c % x == 0 ){
      result *= x;
      a /= x; b /= x; c /= x;
    }else{
      ++x;
    }
  }
  
  return result;
}

int main(){
  uint32_t K;
  cin >> K;
  uint64_t sum = 0;
  for( uint32_t i = 1; i <= K; ++i ){
    for( uint32_t j = 1; j <= K; ++j ){
      for( uint32_t k = 1; k <= K; ++k ){
        sum += gcd( i, j , k);
      }
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3672
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: u32 = s.trim_right().to_owned().parse().unwrap();

    let mut an: Vec<u32> = Vec::new();
    an.push(s);
    loop {
        let m = an.len();
        let am = {
            if &an[m - 1] % 2 == 0 {
                an[m - 1] / 2
            } else {
                3 * an[m - 1] + 1
            }
        };
        an.push(am);
        for n in 0..(an.len()-1) {
            if an[n] == am {
                println!("{}", m + 1);
                std::process::exit(0);
            } 
        };
    };

}

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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

int a[N];

void Solve() {
	int n, c, k;
	cin >> n >> c >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	sort(a + 1, a + 1 + n);

	int ans = 0, left = 0, last = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= last + k) {
			if (left) left--;
			else ans++, left = c - 1, last = a[i];
		}
		else ans++, left = c - 1, last = a[i];
	}

	cout << ans << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3976
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        HashSet<Integer> list = new HashSet<Integer>();

        for(int i =a;i<a+k;i++){
            list.add(i);
            if(i==b)break;
        }
        for(int i = b;i>b-k;i--){
            list.add(i);
            if(i==a)break;
        }

        List<Integer> list2 = new ArrayList<>(list);
        Collections.sort(list2);
        for(int i : list2){
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 22736
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int h,m,s;
    cin >> s;
    h = int(s / 3600);
    s -= h * 3600;
    m = int(s / 60);
    s -= m * 60;
    cout << h << ':' << m << ':' << s << endl;
}


Measured memory_bytes: 3076
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int x, num, ans = 1;
	cin >> x;
	for (int i = 2; i<32; i++) {
		num = i * i;
		while (num <= x) {
			ans = max(ans, num);
			num *= i;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int>x;

signed main()
{
   cin>>N;
   x.resize(N);
   rep(i,N){
       cin>>x[i];
   }

    vector<int>y;
    y=x;

    sort(all(y));

    int mid = y[N/2];

    rep(i,N){
        if(x[i]<mid){
            cout << y[N/2]<<endl;
        }
        else{
            cout<<y[N/2-1]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>
#define MAX 1001

void length(char *,char *);

int main(){
  
  int n,i;
  char x[MAX],y[MAX];
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s%s",x,y);
    length(x,y);
  }
  
  return 0;
}

void length(char *x,char *y){
  
  int i,j,n,m;
  int c[MAX][MAX];
  
  m = strlen(x);
  n = strlen(y);
  for(i = 1; i <= m; i++)
    c[i][0] = 0;
  for(j = 0; j <= n; j++)
    c[0][j] = 0;
  for(i = 1;i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i-1] == y[j-1])
	c[i][j] = c[i - 1][j - 1] + 1;
      else if(c[i - 1][j] >= c[i][j - 1])
	c[i][j] = c[i - 1][j];
      else
	c[i][j] = c[i][j-1];
    }
  }
  
  printf("%d\n",c[m][n]);
}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+7];
    int x=-1,c=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>=x)
        {
            c++;
            x=a[i];
        }
    }
cout<<c<<endl;
    return 0;
}


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

#define M 1000000007

typedef pair<int, int> P;
struct edge { int to, cap, cost, rev; };

int V = 366;
vector<edge> G[400];
int h[400];
int dist[400];
int prevv[400], preve[400];
void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){ to, cap, cost, (int)G[to].size() });
    G[to].push_back((edge){ from, 0, -cost, (int)G[from].size() - 1 });
}

// ??????????????´??????M
int min_cost_flow(int s, int t, int f) {
    int res = 0;
    fill(h, h + V, 0);
    while (f > 0) {
        priority_queue<P, vector<P>, greater<P> > q;
        fill(dist, dist + V, M);
        dist[s] = 0;
        q.push(P(0, s));
        while (!q.empty()) {
            P p = q.top();
            q.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (int i = 0; i < (int)G[v].size(); ++i) {
                edge &e = G[v][i];
                if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
        if (dist[t] == M) return M;
        for (int v = 0; v < V; ++v)
            h[v] += dist[v];

        int d = f;
        for (int v = t; v != s; v = prevv[v])
            d = min(d, G[prevv[v]][preve[v]].cap);

        f -= d;
        res += d * h[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        for (int i = 0; i < 400; ++i) {
            G[i].clear();
            h[i] = 0;
            dist[i] = 0;
            prevv[i] = 0;
            preve[i] = 0;
        }
        for (int i = 0; i < V - 1; ++i) {
            add_edge(i, i + 1, 2, 0);
        }
        for (int i = 0; i < n; ++i) {
            int a, b, w;
            cin >> a >> b >> w;
            add_edge(a - 1, b, 1, -w);
        }
        cout << -min_cost_flow(0, V - 1, 2) << "\n";
    }
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define N 40 + 5
#define M 131075
#define Mod 1000000007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, x, y, z, S, ans, maxl, final, dp[N][M];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){
    return (a += b) >= Mod ? a - Mod : a;
}
int Dec(int a, int b){
    return (a -= b) < 0 ? a + Mod : a;
}
int Mul(int a, int b){
    return 1ll * a * b % Mod;
}
int Qpow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1) ans = Mul(ans, a);
        a = Mul(a, a), b >>= 1;
    }
    return ans;
}
int main(){
    n = read(), x = read(), y = read(), z = read();
    maxl = (1 << (x + y + z)) - 1;
    final = (1 << (x - 1));
    final = (final << y) + (1 << (y - 1));
    final = (final << z) + (1 << (z - 1));
    dp[0][0] = 1;
    rep(i, 1, n) rep(j, 0, maxl) rep(k, 1, 10){
        S = (((j << k) + (1 << (k - 1))) & maxl);
        if((S & final) == final) continue;
        dp[i][S] = Inc(dp[i][S], dp[i - 1][j]);
    }
    rep(i, 0, maxl) ans = Inc(ans, dp[n][i]);
    printf("%d", Dec(Qpow(10, n), ans));
    return 0;
}

Measured memory_bytes: 24184
X, Y = map(int, input().split())
if X == 1 and Y == 1:
  print(1000000)
  exit(0)
code_prize = 0
if X == 1:
  code_prize = 300000 
elif X == 2:
  code_prize = 200000
elif X == 3:
  code_prize = 100000
device_prize = 0
if Y == 1:
  device_prize = 300000
elif Y == 2:
  device_prize = 200000
elif Y == 3:
  device_prize = 100000
print(code_prize + device_prize)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> ipair;
const int MAX_V = 100010;
const int MAX_LOG_V = 17;
vector<ipair> G[MAX_V];
int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];
vector<int> eulerT;
 
template<class T> class TREE {
 
   public:
      int k = 0;
      T distance[MAX_V];
      int begin[MAX_V * 2];
      int end[MAX_V * 2];
 
      // vertex, parent, depth, distance
      void dfs(int v, int p, int d, T l) {
         parent[0][v] = p;
         depth[v] = d;
         distance[v] = l;
         begin[v] = k;
         eulerT.push_back(v);
         k++;
         for (auto& g : G[v]) {
            if (g.first != p) {
               dfs(g.first, v, d + 1, l + g.second);
               eulerT.push_back(v);
               k++;
            }
         }
         end[v] = k;
      }
 
      void init(int V, int root) {
         dfs(root, -1, 0, 0);
         for (int k = 0; k + 1 < MAX_LOG_V; k++) {
            for (int v = 0; v < V; v++) {
               if (parent[k][v] < 0) parent[k + 1][v] = -1;
               else parent[k + 1][v] = parent[k][parent[k][v]];
            }
         }
      }
 
      int lca(int u, int v) {
         if (depth[u] > depth[v]) swap(u, v);
         for (int k = 0; k < MAX_LOG_V; k++) {
            // if k th digit of depth[v] - depth[u] is 1
            if ((depth[v] - depth[u]) >> k & 1) {
               v = parent[k][v];
            }
         }
         if (u == v) return u;
         for (int k = MAX_LOG_V - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
               u = parent[k][u];
               v = parent[k][v];
            }
         }
         return parent[0][u];
      }

      T dist2(int u, int v) {
         return distance[u] + distance[v] - 2 * distance[lca(u, v)];
      }
};

int main() {
   int N;
   cin >> N;
   int u, v, w;
   for (int i = 0; i < N - 1; i++) {
      cin >> u >> v >> w;
      u--;
      v--;
      G[u].push_back(ipair(v, w));
      G[v].push_back(ipair(u, w));
   }

   TREE<ll> tree;
   tree.init(N, 0);

   for (int i = 0; i < N; i++) {
      if (tree.distance[i] % 2 == 0) cout << 0 << endl;
      else cout << 1 << endl;
   }
   return 0;
}


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

int main() {
  long long x,y;
  cin >> x >> y;
  if( ( 0<=x && x<y )||( x<y && y<=0 ))
    cout << y-x << endl;
  else if(x*y>0)
    cout << x-y+2 << endl;
  else
  {if(x+y>0)
    cout << x+y+1 << endl;
  else
    cout << 1-x-y << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    vec.at(i) = a;
  }
  int counter = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0 && vec.at(i) % 2 == 1)
    counter++;
  }
  cout << counter << endl;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int N;

  cin >> N;

  map< double, vector< int > > mp;
  for(int i = 0; i < N; i++) {
    double a;
    cin >> a;
    mp[a].push_back(i);
  }

  int64 sum = 0;
  vector< int64 > sc(N);

  for(auto &s : mp) {
    int64 curr = sum * 3 + s.second.size() - 1;
    for(auto &v : s.second) sc[v] = curr;
    sum += s.second.size();
  }

  for(int i = 0; i < N; i++) {
    cout << sc[i] << endl;
  }
}

Measured memory_bytes: 4788
using System;

namespace aoj1147 {
	class Program {
		static void Main (string[] args) {
			int n;
			do {
				n = int.Parse(Console.ReadLine());
				int min = 1000, max = 0, sum = 0;
				int[] points = new int[n];
				for (int i = 0;i < n;i++) {
					points[i] = int.Parse(Console.ReadLine());
					if (points[i] < min)
						min = points[i];
					if (max < points[i])
						max = points[i];
				}
				for (int i = 0;i < n;i++) {
					if (points[i] <= min) {
						min--;
						continue;
					}
					if (max <= points[i]) {
						max++;
						continue;
					}
					sum += points[i];
				}
				if(n!=0)
					Console.WriteLine(sum / (n - 2));
			} while (n != 0);
		}
	}
}

Measured memory_bytes: 5664
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;

    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    
    vector<ll> v1(n), v2(n);
    rep(i, n) {
        v1[i] = x[i] + y[i];
        v2[i] = x[i] - y[i];
    }


    ll res = *max_element(all(v1)) - *min_element(all(v1));
    res = max(res, *max_element(all(v2)) - *min_element(all(v2)));

    put(res);

}
signed main(){ Main();return 0;}

Measured memory_bytes: 9584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	
	if (n % 2 == 1){
		cout << (double)(n/2+1) / n << endl;
	}
	else{
		cout <<(double)(n/2)/ n << endl;
	}


	return 0;
}

Measured memory_bytes: 888
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {

    const lines = input.split('\n')
    const [X, Y, A, B, C] = lines[0].split(' ').map(Number)
    const p = lines[1].split(' ').map(Number).sort((a, b) => a - b)
    const q = lines[2].split(' ').map(Number).sort((a, b) => a - b)
    const r = lines[3].split(' ').map(Number).sort((a, b) => a - b)

    const S = [
        ...p.splice(A - X, X),
        ...q.splice(B - Y, Y),
        ...r
    ]

    S.sort((a, b) => b - a)

    let ans = 0
    for (let i = 0; i < X + Y; i++) {
        ans += S[i]
    }

    console.log(ans)

})(input)


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

using namespace std;

vector<int> s;

int main(){
    
    int n;
    cin >> n;
    
    for(int i=0; i< n; i++){
        int temp;
        cin >> temp;
        s.push_back(temp);
    }
    
    sort(s.begin(), s.end());
    
    /*for(auto i : s)
        cout << i << " ";
    cout << endl;*/
    long long res = ((long long) n)*(n-1)*(n-2)/6;
    
    for(int i=0; i<n; i++){
        
        for(int j=i+1; j<n; j++){
            //cout << "i: " << i << " j: " << j << endl;
            int a = s[i];
            int b = s[j];
            
            int l = j;
            int r = n;
            while(l < r){
                int mid = (l+r+1)/2;
                //cout << mid << endl;
                if(s[mid] < a+b){
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            if(l < n && s[l] < a+b)
                l++;
                
            res -= n-l;
            //cout << "menor que nao da: " << l << endl;
        }
    }
    
    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    double A,B,X;cin>>A>>B>>X;
    double S=X/A;
    
    double left=0.0,right=M_PI/2.0;
    
    for(int i=0;i<300;i++){
        double mid=(left+right)/2.0;
        double l=A*sin(mid),h=B*sin(M_PI/2.0-mid);
        double size;
        
        if(l<=h){
            size=A*B-A*A*tan(mid)/2.0;
        }else{
            size=B*B*tan(M_PI/2.0-mid)/2.0;
        }
        
        if(size>=S) left=mid;
        else right=mid;
    }
    
    printf("%.12lf\n",left*90.0/(M_PI/2.0));
    //cout<<setprecision(25)<<left*90.0/(M_PI/2.0)<<endl;
}




Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
struct st{int a,b,c;};
bool operator <(st x,st y) {return x.c>y.c;}
unordered_map<int,vi> E[100000];
vi G[100000];
unordered_map<int,int> d[100000];
int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int x,y,z;cin>>x>>y>>z;--x,--y;
		E[x][z].pb(y);E[y][z].pb(x);
		G[x].pb(z);G[y].pb(z);
	}
	priority_queue<st> pq;
	d[0][0]=0;pq.push({0,0,0});
	while(!pq.empty()){
		st p=pq.top();pq.pop();
		if (p.c>d[p.a][p.b]) continue;
		if (d[p.a].find(0)==d[p.a].end()||d[p.a][0]>p.c){
			d[p.a][0]=p.c;pq.push({p.a,0,p.c});
		}
		if (p.b==0){
			for (int v:G[p.a]){
				if (d[p.a].find(v)==d[p.a].end()||d[p.a][v]>p.c+1){
					d[p.a][v]=p.c+1;pq.push({p.a,v,p.c+1});
				}
			}
			continue;
		}
		for (int v:E[p.a][p.b]){
			if (d[v].find(p.b)==d[v].end()||d[v][p.b]>p.c){
				d[v][p.b]=p.c;pq.push({v,p.b,p.c});
			}
		}
	}
	int ans=INF;
	for (auto i:d[n-1]) ans=min(ans,i.second);
	cout<<(ans==INF? -1:ans);
	return 0;
}

Measured memory_bytes: 80304
import java.util.Scanner;

public class Main {

	static long euclid(long x, long y) {
		if (y == 0) {
			return x;
		} else {
			return euclid(y, x%y);
		}
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T[] = new long[N];
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextLong();
		}
		long gcd=T[0];
		long lcm=T[0];
		for (int i = 1; i < N; i++) {
			gcd=euclid(lcm,T[i]);
			lcm=lcm/gcd*T[i];
		}

		System.out.println(lcm);
	}
}


Measured memory_bytes: 23508
#include <iostream>
#include <vector>

using namespace std;

int main(){
    string s; cin >> s;
    int i=s.size()-1;
    while(i>=0){
        if(s[i]=='r'){
            if(i-7+1>=0 && s.substr(i-7+1, 7)=="dreamer"){
                i-=7;
            } else if(i-6+1>=0 && s.substr(i-6+1, 6)=="eraser"){
                i-=6;
            } else{
                break;
            }
        } else if(s[i]=='m' && i-5+1>=0 && s.substr(i-5+1, 5)=="dream"){
            i-=5;
        } else if(s[i]=='e' && i-5+1>=0 && s.substr(i-5+1, 5)=="erase"){
            i-=5;
        } else{
            break;
        }
    }
    cout << (i<0 ? "YES" : "NO") << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if((a == 1 && b == 2)||(b == 1 && a == 2)) cout << 3 << endl;
    else if((a == 2 && b == 3)||(b == 2 && a == 3)) cout << 1 << endl;
    else cout << 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll a[3], n;
    rep(i, 3) cin >> a[i];
    cin >> n;
    ll dp[n+1]; mem(dp , 0);
    dp[0] = 1;
    rep(j, 3)
    {
        rep(i, n)
        {
            if(dp[i] != 0 && i+a[j] <= n) dp[i+a[j]] += dp[i];
        }
    }
    cout << dp[n];
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256