akhauriyash/Code-Regression huggingface dataset:
import heapq
n, m, s = map(int, input().split())
s = min(s, 2499)
UV = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    UV[u].append((v, a, b))
    UV[v].append((u, a, b))
CD = [tuple(map(int, input().split()))for _ in range(n)]
MAXS = 2500
NV = MAXS*n
edges = [[] for _ in range(NV)]


def to_v(i, j):
    return MAXS*i+j

for i, (c, d) in enumerate(CD):
    for j in range(MAXS-c):
        edges[to_v(i, j)].append((d, to_v(i, j)+c))

for i in range(n):
    for i2, a, b in UV[i]:
        for j in range(MAXS-a):
            edges[to_v(i, a+j)].append((b, to_v(i2, j)))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*NV
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


INF = 10**18
dist = dijkstra(s)
for i in range(1, n):
    ans = INF
    for j in range(MAXS):
        ans = min(ans, dist[to_v(i, j)])
    print(ans)

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

int main(){
	int N;
	cin >> N;
	vector<int> L(2*N);
	for(auto &i:L)cin >> i;
	sort(L.begin(),L.end());
	int ans=0;
	for(int i=0;i<N;i++){
		ans+=min(L[2*i],L[2*i+1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007

 signed main(){
    gok
    string s;
    cin>>s;
    bool ch=true;
    for(int i=1;i<s.size();i+=2)
    {
        if(s[i]!='i'||s[i-1]!='h')
            ch=false;
    }
    if(!ch || s.size()%2==1)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    while (1)
    {
        int m, f, r;
        cin >> m >> f >> r;
        int score = m + f;
        if (m == -1 && f == -1 && r == -1)
            break;
        if (m == -1 || f == -1)
            cout << "F" << endl;
        else if (score >= 80)
            cout << "A" << endl;
        else if (score >= 65)
            cout << "B" << endl;
        else if (score >= 50)
            cout << "C" << endl;
        else if (score >= 30)
        {
            if (r >= 50)
                cout << "C" << endl;
            else
                cout << "D" << endl;
        }
        else
            cout << "F" << endl;
    }
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

int main(){
    vector<ll> vec(3);
    cin >> vec[0] >> vec[1] >>vec[2];
    sort(vec.begin(),vec.end());
    cout << vec[0]+vec[1] << endl;
    return 0;
}


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

const ll MOD = 1000000007;
vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(26, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}


int main(void){
    // Your code here!
    string S;
    cin >> S;
    auto ns = calcNext(S);
    string T = S;
    reverse(T.begin(), T.end());
    auto nt = calcNext(T);
    
    int N = (int)S.size();
    vector<vector<ll> > dp(N+1, vector<ll>(N+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < 26; k++){
                if(ns[i][k] + nt[j][k] + 2 > N) continue;
                dp[ns[i][k] + 1][nt[j][k] + 1] += dp[i][j];
                dp[ns[i][k] + 1][nt[j][k] + 1] = dp[ns[i][k] + 1][nt[j][k] + 1] % MOD;
            }
        }
    }
    
    ll res = 0;
    for(int i = 0; i<= N; i++) {
        for(int j = 0; j <= N; j++){
            int num = 1;
            for(int k = 0; k < 26; k++){
                if(ns[i][k] + 1 + j <= N) num++;
                
            }
            res += (num * dp[i][j]) % MOD;
            res =  res % MOD;
        }
    }
    cout << res-1 << endl;
}



Measured memory_bytes: 34884
def popcount(n):
    return bin(n).count("1")

n=int(input())
a=list(map(int,input().split()))
 
l,r=0,0
ans = 0
nsome = a[0]
nxor = a[0]
while(l < n and r<n):
    if nsome  == nxor:
        ans+=r-l+1
        r+=1
        if(r>=n):
            break
        nsome+=a[r]
        nxor ^=a[r]

    else:
        nsome-=a[l]
        nxor^=a[l]
        l+=1

print(ans)


Measured memory_bytes: 24840
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}

int N;
i64 a[200010];

signed main()
{
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        a[i] += a[i-1];
    }

    unordered_map<i64, int> cnt;
    for (int i = 0; i <= N; ++i) {
        cnt[a[i]] += 1;
    }

    auto f = [](i64 n) -> i64 {
        return n * (n-1) / 2;
    };

    i64 ans = 0;
    for (auto e : cnt) {
        ans += f(e.second);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10056
import math
A, B, H, M = map(int, input().split())

if 30 * H == 6 * M + (30 * M / 60):
    kakudo = 0
elif 30 * H > 6 * M + (30 * M / 60):
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H < 6 * M + (30 * M / 60):
    kakudo = 6 * M - 30 * H - (30 * M / 60)


ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(kakudo))

print(ans ** (1/2))

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

int main(){

int S; 
  cin >> S;
int A[4]; 
  for(int i = 3;i >= 0;i--){
    A[i] = S % 10;
    S /= 10;
  }
char a, b, c; 
  
  if(A[0]+A[1]+A[2]+A[3] == 7){a = '+'; b = '+'; c = '+';}
  else if(A[0]+A[1]+A[2]-A[3] == 7){a = '+'; b = '+'; c = '-';}
  else if(A[0]+A[1]-A[2]+A[3] == 7){a = '+'; b = '-'; c = '+';}
  else if(A[0]-A[1]+A[2]+A[3] == 7){a = '-'; b = '+'; c = '+';}
  else if(A[0]-A[1]-A[2]+A[3] == 7){a = '-'; b = '-'; c = '+';}
  else if(A[0]-A[1]+A[2]-A[3] == 7){a = '-'; b = '+'; c = '-';}
  else if(A[0]+A[1]-A[2]-A[3] == 7){a = '+'; b = '-'; c = '-';}
  else if(A[0]-A[1]-A[2]-A[3] == 7){a = '-'; b = '-'; c = '-';}

cout << A[0] << a << A[1] << b << A[2] << c << A[3] << "=7" << endl;          
return 0;
  
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto A = scanChar;
  auto B = scanChar;
  if(A<B)end("<");
  if(A>B)end(">");
  end("=");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {

	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	vector<int> x(n,0);
	rep(i,n){
		int sgn = (i+1)%2 ? 1 : -1;
		x[0] += sgn*a[i];
	}
	rep2(i,1,n){
		x[i] = 2*a[i-1]-x[i-1];
	}
//	rep(i,n) cout << x[i] << " ";
	rep(i,n) printf("%d ",x[i]);
	cout << endl;
}




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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  int s_min, sum;
  sum = a[0] + a[1] + a[2];
  s_min = sum;
  
  for (int i=0; i<3; i++){
    s_min = min(s_min, sum-a[i]);
  }
  cout << s_min << endl;
    
  return 0;
}


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

char map[21][21];
int width, height;
int x, y;

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

int parse()
{
	scanf("%d %d", &width, &height);
	if (width == 0 || height == 0)
		return 0;
	fors(i, 21) fors(j, 21) map[i][j] = 'F';
	fors(i, height)
	{
		scanf("%s", map[i]);
		fors(j, width)
		{
			if (map[i][j] == '@')
				x = j, y = i;
		}
	}
	return 1;
}

int dfs(int y, int x)
{
	if (map[y + 1][x] == '.')
		map[y + 1][x] = '@', dfs(y + 1, x);
	if (map[y - 1][x] == '.')
		map[y - 1][x] = '@', dfs(y - 1, x);
	if (map[y][x + 1] == '.')
		map[y][x + 1] = '@', dfs(y, x + 1);
	if (map[y][x - 1] == '.')
		map[y][x - 1] = '@', dfs(y, x - 1);
}

int main()
{
	while (parse())
	{
		int res = 0;
		dfs(y, x);
		fors(i, width)
		{
			fors(j, height)
			{
				if (map[j][i] == '@')
					res++;
			}
		}
		printf("%d\n", res);
	}
}


Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	set<int> tes;
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		if(tes.count(A)){
			tes.erase(A);
		}
		else
			tes.insert(A);
	}
	cout<<tes.size()<<endl;
    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<vector<P>> A(N,vector<P>(0));

    rep(i,N) {
        int a;
        cin >> a;
        rep(j,a) {
            int x,y;
            cin >> x >> y;
            x--;
            A[i].push_back(make_pair(x,y));
        }
    }
    
    int ans = 0;
    for (int bit = 0; bit< 1<<N; bit++) {
        bool t = true;
        rep(i,N) {
            if (bit & 1<<i) {
                rep(j,A[i].size()) {
                    int x,y;
                    x = A[i][j].first;
                    y = A[i][j].second;
                    if (y==0 and bit & 1<<x) {
                        t = false;
                    }
                    else if (y==1 and !(bit & 1<<x)) {
                        t = false;
                    }
                }
            }
        }
        int tmp;
        if (t) {
            tmp = 0;
            rep(i,N) {
                if (bit & 1<<i) {
                    tmp++;
                }
            }

        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    int n, l; cin >> n >> l;
    vector<string> v(n);
    repeat(i, 0, n) cin >> v[i];
    sort(all(v));
    for(auto it:v) cout << it;

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)cout << "0" << endl;
	else cout << "10" << endl;
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,d,ans=0;
    cin >> n >> d;
    for(int i=0;i<n;i++){
    	int x,y;
    	cin >> x >> y;
    	if(x*x+y*y<=d*d)ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    static int solve(long[] nums, int k) {
        final int n = nums.length;
        Arrays.sort(nums);
        long product = 1;
        if (nums[n - 1] <= 0 && k % 2 != 0) {
            for (int i = n - 1; i >= n - k; i--) {
                product = (product * nums[i]) % MOD;
            }
            return Math.floorMod(product, MOD);
        }
        int i = 0;
        int j = n - 1;
        if (k % 2 != 0) {
            product = (product * nums[j]) % MOD;
            j--;
            k--;
        }
        k >>= 1;
        for (int itr = 0; itr < k; itr++) {
            final long left = nums[i] * nums[i + 1];
            final long right = nums[j] * nums[j - 1];
            if (left > right) {
                product = (product * (left % MOD)) % MOD;
                i += 2;
            } else {
                product = (product * (right % MOD)) % MOD;
                j -= 2;
            }
        }
        return Math.floorMod(product, MOD);
    }

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final int k = in.nextInt();
        in.nextLine();
        final long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        in.nextLine();
        System.out.println(solve(arr, k));
    }
}


Measured memory_bytes: 62876
#include <stdio.h>

int main()
{
	int i, N, T, c, t, min = 10000;
	scanf("%d %d", &N, &T);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &c, &t);
		if (t <= T && c < min) min = c;
	}
	if (min == 10000) printf("TLE\n");
	else printf("%d\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split("\n");
var nq=arr[0].split(" ").map(Number);
var str = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<str.length;i++){
   if(str[i]=="C" && str[i-1]=="A")cnt++;
   a.push(cnt);
}
var ans=[];
for(var i=2,len=nq[1]+2;i<len;i++){
   var lr=arr[i].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
}
console.log(ans.join("\n"));

Measured memory_bytes: 34640
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
  
        int x; cin >> x;
        x ^= 1;
        cout << x;
        return 0;
}

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

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

  if (a+b>c+d) cout << "Left" << endl;
  else if (a+b==c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;

  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int A,B;
int main() {
    cin>>A>>B;

    if((A+B)%2==0)cout<<(A+B)/2<<endl;
    else cout<<(A+B)/2+1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int M = 998244353;
long long fact[300002], facti[300002];

int modinv(int a, int m) {
    int x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        int u = x / y;
        int x0 = y; y = x - y * u; x = x0;
        int r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

long long comb(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * facti[k] % M * facti[n-k] % M;
}

int main() {
    long long n, a, b, k; cin >> n >> a >> b >> k;
    fact[0] = 1; facti[0] = 1;
    for (int i = 1; i <= n+1; i++) {
        fact[i] = (fact[i-1] * i) % M;
        facti[i] = modinv(fact[i], M);
    }
    long long ans = 0;
    for (int p = 0; p <= n; p++) {
        // a*p + b*q = k
        if ((k - a*p) % b) continue;
        long long q = (k - a*p) / b;
        ans += comb(n, p) * comb(n, q) % M;
        if (ans >= M) ans -= M;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A,B,C;
        A=s.nextInt();
        B=s.nextInt();
        C=s.nextInt();
        
        System.out.println((A*B)/2);
    }  
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,ans;
	rep(i,3){
		cin>>s;
		if(i==1)ans=s[0];
	}
	cout<<"A"<<ans<<"C"<<endl;
	return 0;
}

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

const int MAX = 100000;
const int NIL = -1;

struct Node{
    int parent;
    int left;
    int right;
};

Node T[MAX];
int n,D[MAX],H[MAX],Deg[MAX]; //depth,height,degree


int getSibling(int u){
    if(T[u].parent == NIL ) return NIL;
    if(T[T[u].parent].left != u and T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right != u and T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

int getDegree(int u){
    int deg = 0;
    if(T[u].left != NIL) deg ++;
    if(T[u].right != NIL) deg ++;
    return deg;
}

int getDepth(int u){
    int d = 0;
    while(T[u].parent != NIL){
        u =T[u].parent;
        d++;
    }
    return d;
}

int setHeight(int u){
    int h1 = 0 , h2 = 0;
    if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = max(h1,h2);
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    //getSibling
    cout << "degree = " << Deg[u] << ", ";
    //getDegree
    cout << "depth = " << D[u] << ", ";
    //getDepth
    cout << "height = " << H[u] << ", ";
    //getHeight
    if(T[u].parent == NIL) cout << "root";
    else if (T[u].left == NIL && T[u].right == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}


int main(){
    int n,num,left,right;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for (int i = 0; i < n; ++i) {
        cin >> num >> left >> right;
        T[num].left = left;
        T[num].right = right;
        if (left != NIL) T[left].parent = num;
        if (right != NIL) T[right].parent =num;
    }

    for (int i = 0; i < n ; ++i) {
        D[i] = getDepth(i);
        H[i] = setHeight(i);
        Deg[i] = getDegree(i);
    }

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

Measured memory_bytes: 1172
#include<stdio.h>

int main()
{
  int i,N,A,B,C,X,n;
  int Y[101];
  
  while(1){
    scanf("%d%d%d%d%d",&N,&A,&B,&C,&X);
    if(N==0&&A==0&&B==0&&C==0&&X==0)break;
    for(i=0;i<N;i++)scanf("%d",&Y[i]);
    n=0;
    for(i=0;i<10001;i++){
      if(X==Y[n])n++;
      if(n==N)break;
      X=(A*X+B)%C;
     
    }
    if(i!=10001)printf("%d\n",i);
    else printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 612
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [0] * N
for i in range(N):
    B[i] = int(input())


def f(A,n):
    for i in range(3):
        for j in range(3):
            if A[i][j] == n:
                A[i][j] = 0
    return A

for b in B:
    A = f(A,b)
ret = "No"
for i in range(3):
    if sum(A[i]) == 0:
        ret = "Yes"

for i in range(3):
    t = A[0][i] + A[1][i] + A[2][i]
    if t == 0:
        ret = "Yes"

if A[0][0] + A[1][1] + A[2][2] == 0:
    ret = "Yes"

if A[0][2] + A[1][1] + A[2][0] == 0:
    ret ="Yes"

print(ret)



Measured memory_bytes: 38256
using System;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			string input = Console.ReadLine();
			int retval;
			if (!int.TryParse(input, out retval))
			{
				Console.WriteLine("NA");
				return;
			}

			string firstHalf = input.Substring(0, 2);
			bool isFirstMonth = IsMonthString(firstHalf);

			string latterHalf = input.Substring(2, 2);
			bool isLatterMonth = IsMonthString(latterHalf);

			if (isFirstMonth)
			{
				if (isLatterMonth)
				{
					Console.WriteLine("AMBIGUOUS");
					return;
				}
				else
				{
					Console.WriteLine("MMYY");
					return;
				}
			}
			else
			{
				if (isLatterMonth)
				{
					Console.WriteLine("YYMM");
					return;
				}
				else
				{
					Console.WriteLine("NA");
					return;
				}
			}
		}

		static bool IsMonthString(string input)
		{
			int retval;
			if (!int.TryParse(input, out retval))
			{
				return false;
			}
			return 1 <= retval && retval <= 12;
		}
	}
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=1e5+5;
struct Node{
	int l,r,len;
	bool operator<(const Node&t)const{
		return r-l<t.r-t.l;
	}
} p[N*3];
int c[N],n,m;
void updata(int x,int v){
	while(x<=m){
		c[x]+=v;
		x+=(x&-x);
	}
}
int query(int x){
	int ret=0;
	while(x){
		ret+=c[x];
		x^=(x&-x);
	}
	return ret;
}
int main(){
	n=rd(),m=rd();
	rep(i,1,n){
		p[i].l=rd(),p[i].r=rd();
		p[i].len=p[i].r-p[i].l+1;
	}
	sort(p+1,p+n+1);
	int now=1;
	rep(i,1,m){
		while(now<=n&&p[now].len<i){
			updata(p[now].l,1);
			updata(p[now].r+1,-1);
			now++;
		}
		/*debug(now);
		debug(p[now].l);
		debug(p[now].r);*/
		int tmp=0;
		for(int j=i;j<=m;j+=i)tmp+=query(j);
		printf("%d\n",n-now+1+tmp);
	}
}

Measured memory_bytes: 4864
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			StringBuilder sb = new StringBuilder();
			int weight = sc.nextInt();
			int temp;
			for (int i=9; i>=0; i--) {
				temp = (int)Math.pow(2,i);
				if (weight >= temp) {
					weight -= temp;
					sb.insert(0,temp+" ");
				}
			}
			out.println(sb.delete(sb.length()-1,sb.length()));
		}
	}
}


Measured memory_bytes: 26424
// ALDS1_1_C Prime Numbers
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         int cnt = 0;
         int n = Integer.parseInt(br.readLine());
         int[] x = new int[n];
         for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(br.readLine());
         }
         for (int i = 0; i < n; i++) {
            if (isPrime(x[i])) cnt++;
         }
         System.out.println(cnt);
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static boolean isPrime(int x) {
      if (x == 2) return true;
      if (x < 2 || x % 2 == 0) return false;
      int i = 3;
      while (i <= Math.sqrt(x)) {
         if (x % i == 0) return false;
         i = i + 2;
      }
      return true;
   }
}

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

int main()
{
    long long n, k;
    cin >> n >> k;
    n = n - k * (n / k);
    cout << min(n, abs(n - k)) << endl;
    return 0;
}


Measured memory_bytes: 888
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    # 白と黒が入れ替わった箇所をカウントする
    flip = [[f_inf for _ in range(W)] for _ in range(H)]

    if S[0][0] == "#":
        flip[0][0] = 1
    else:
        flip[0][0] = 0

    que = deque([[0, 0]])
    while que:
        h, w = que.popleft()
        for dh, dw in ((0, 1), (1, 0)):
            next_h, next_w = h + dh, w + dw
            if next_h >= H or next_w >= W:
                continue

            if flip[next_h][next_w] == f_inf:
                que.append([next_h, next_w])

            # 白と黒が入れ替わったらカウントアップ
            if S[h][w] != S[next_h][next_w]:
                flip[next_h][next_w] = min(flip[next_h][next_w], flip[h][w] + 1)
            else:
                flip[next_h][next_w] = min(flip[next_h][next_w], flip[h][w])

    if S[H - 1][W - 1] == "#":
        flip[H - 1][W - 1] += 1

    # 操作の回数は白と黒が入れ替わった回数の半分（切り捨て）である
    print(flip[H - 1][W - 1] // 2)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41328
// Created by Davidia on 2018-12-17.
//

// copyright@ Dr. Davidia


#include <bits/stdc++.h>

using namespace std;


int main(){
    int n, w; cin >> n >> w;
    vector<pair<int,int>> sack(n);
    for (int i = 0; i < n; i++)
        cin >> sack.at(i).first >> sack.at(i).second;
    vector<vector<long long>> dp(n+1, vector<long long>(w+1,0));

    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= w; j++){ // loop through weights
            if (i==0 || w == 0)
                continue;
            if (sack.at(i-1).first <= j){
                dp.at(i).at(j) = max(sack.at(i-1).second + dp.at(i-1).at(j-sack.at(i-1).first), dp.at(i-1).at(j)); // not include or include?
            }
            else{
                dp.at(i).at(j) = dp.at(i-1).at(j); // cannot include the current item
            }
        }
    }
    cout << dp.at(n).at(w) << '\n';

    return 0;
}

Measured memory_bytes: 80256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  perm <- map (read::String -> Int) . words <$> getLine
  scores <- listArray (1, n) . map (read::String -> Int) . words <$> getLine
  combis <- listArray (1, n) . map (read::String -> Int) . words <$> getLine
  print . fst $ foldl (\(sum, prv) crt -> if crt == prv + 1 then (sum + scores ! crt + combis ! prv, crt) else (sum + scores ! crt, crt)) (0, -1) perm

Measured memory_bytes: 764
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> b;
    REP(i, n) b.push_back(a[i] - i - 1);
	sort(b.begin(), b.end());
	
	ll med, medu;
	if(n%2 == 0){
		med = (b[n/2] + b[n/2 - 1])/2;
		if(med < 0)medu = med -1;
		else medu = med + 1;
	}
	else{
		med = b[n/2];
		medu = med;
	}
	//cout << med << " " << medu << endl;
	ll us = 0, ls = 0;
    REP(i, n) us += abs(a[i] - med - i - 1);
    REP(i, n) ls += abs(a[i] - medu - i - 1);
    cout << min(us, ls) << endl;
}

Measured memory_bytes: 4980
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();++i)
    {
        s[i]=(s[i]-'A'+n)%26 +'A';
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N; cin >> N;
VI a(N); rep(i, 0, N) scanf("%d", &a[i]);
sort(ALL(a));

int maxX =0, cnt, X, j=0;

for (int i = 0; i < N ; ) {
    i = j;
    X = a[i];
    cnt = 0;
    for (; i < N && a[i] == X; ++i ){
        ++cnt;
    }
    j = i;
    for (; i < N && (a[i] == X + 1 || a[i] == X + 2); ++i){
        ++cnt;
    }
    maxX = max(maxX, cnt);
}

cout << maxX << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


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

int main(){
int n,k;
cin>>n;int cnt=0;
for(int i=1;i<=n;i++){
    cin>>k;
    if(i%2&&k%2) cnt++;
}
cout<<cnt;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A = 0;
	string S, T;
	cin >> S >> T;
	for(int i = 0; i < S.length(); i++){
		if(S[i] == T[i]){
			A++;
        }
    }
	if(A == S.length()){
		cout << "Yes";
    } else {
		cout << "No";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    ll ans = 0;
    int N = s.size();
    for (int i = 0; i < 1 << (N - 1); i++) {
        ll sum = 0;
        ll a = s[0] - '0';
        for (int j = 0; j < N - 1; j++) {
            if (i & (1 << j)) {
                sum += a;
                a = 0;
            }
            a = 10 * a + (s[j + 1] - '0');
        }
        sum += a;
        ans += sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long int n;
    cin >> n;
    //n -= 1;
    long long int ans = 0;
    /*
    for (long long int i = 0; n > 0; i++)
    {
        ans += n;
        n -= 1;
    }
    */
    ans = n * (n - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib> //abs() これは整数のみ

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {
	string str;
	int n=0, ans=0,len=0,num;
	cin >> str;
	//vector <int> A(n);
	//string str;
	if(str[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}  
	len = str.size();
	for(int i=2; i<len-1 ; i++){
		if(str[i] == 'C'){ n++; num = i;}
	}
	if(n != 1) {
		cout << "WA" << endl;
		return 0;
	}  
//97 122
	for(int i = 1; i<len; i++){
	    
	    if(i == num) continue;
		if(str[i] < 97 || str[i] >122)  {
			cout << "WA" << endl;
			return 0;
		}  
	}

	cout << "AC" << endl;
	return 0;
}


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

#define lli long long int
#define llf long double
#define ABS(X) ((X>0)?(X):(-1*(X)))

typedef struct s_cell
{
	lli h;
	lli c;
	lli n;
} t_cell;

int	 main(void)
{
	lli n, k;
	scanf("%lld %lld", &n, &k);

	lli index = 0;
	t_cell cells[n];

	while (index < n)
	{
		scanf("%lld",&(cells[index].h));
		cells[index].n = index;
		cells[index].c = 0;
		index++;
	}
	lli j = 0;
	lli w[101];
	//lli min = LLONG_MAX;
	lli min = 9223372036854775806;
	index = 0;
	while (index < n)
	{
		j = 0;
		min = 9223372036854775806;
		while (j < k && j < index)
		{
			w[j] = ABS(cells[index].h - cells[index-j-1].h) + cells[index-j-1].c;
			min = (w[j]<min)?(w[j]):(min);
			//printf("min:%lld, j:%lld, index:%lld, w[j];%lld\n",min, j, index,w[j]);
			//printf("c[i]h:%lld, c[i-j-1]h:%lld, c[i-j-1]c:%lld\n",cells[index].h,cells[index-j-1].h,cells[index-j-1].c);
			j++;
		}
		if(index > 0)
			cells[index].c = min;
		//printf("index:%lld, cost:%lld\n",index,cells[index].c);
		index++;
	}
	printf("%lld\n",cells[n-1].c);
	return(0);
}


Measured memory_bytes: 2560
import sys
import math

n = int(input())

cost = sys.maxsize
tmp = 0
k = math.sqrt(n)
for i in range(1,int(k)+1):
    q, mod = divmod(n,i)
    if(mod==0):
        tmp = i + int(q)
        cost = min(tmp,cost)
        tmp = 0

print(cost-2)


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

int main(){

  vector<int> a(3,0);
  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end(), greater<int>() );
  // cout << a[0] << a[1] << a[2];
  
  int ans = a[0]*10 + a[1] + a[2];

  cout << ans << endl;

}

Measured memory_bytes: 256
N,M=map(int,input().split())
L=list(map(int,input().split()))
B=[1]*N
for i in range(M):
  a,b=map(int,input().split())
  if L[a-1]<L[b-1]:
    B[a-1]=0
  elif L[a-1]==L[b-1]:
    B[a-1]=0
    B[b-1]=0
  else:
    B[b-1]=0
print(sum(B))
  

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void)
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x, y, a, b, c, cnt = 0;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    max_heap<int> que;
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];

    sort(all(p), greater<int>());
    sort(all(q), greater<int>());
    sort(all(r), greater<int>());

    rep(i, 0, x) que.push(p[i]);
    rep(i, 0, y) que.push(q[i]);
    rep(i, 0, c) que.push(r[i]);

    rep(i, 0, x + y)
    {
        cnt += que.top();
        que.pop();
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 8560
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
string s;
cin>>s;
if(s == "ARC") cout<<"ABC";
else cout<<"ARC";
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int x = c-a;
		int y = d-b;
		System.out.println(String.valueOf(c-y)+" "+ String.valueOf(d+x)+" "+ String.valueOf(a-y)
		+" " +String.valueOf(b+x));
	}
}

Measured memory_bytes: 23892
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
























int main(){
    ll n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

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

//Warsaw debug template
#define LOCAL
#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){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    int wr=w%2;
    int hr=h%2;
    long double area=(w*h*1.0)/2.0;
    cout<<fixed<<setprecision(6);
    if(!wr&&!hr){
        if(x==w/2&&y==h/2) cout<<area<<" 1";
        else 
            cout<<area<<" 0";
        return 0;
    }

    cout<<area<<" 0";
    return 0;
}



Measured memory_bytes: 3764