akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template<typename T> struct BIT{
    vector<T> dat;
    ll sz;
    //all 1-indexed
    BIT(ll sz) : sz(sz){
        dat.assign(++sz, 0);
    }

    T sum(ll k){
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += dat[k];
        return (ret);
    }

    void add(ll k, T x){
        for(++k; k < dat.size(); k += k & -k) dat[k] += x;
    }
    
    ll get(T k){
        if(k <= 0) return 0; 
        ll ret = 0;
        int n = 1; while(n < sz) n *= 2;
        for(int i=n/2; i>0; i/=2){
            if(ret+i < sz && dat[ret+i] < k){
                k -= dat[ret+i];
                ret += i;
            }
        }
        return ret;
    }
};

int main(){
	int n,q; cin >> n >> q;
	BIT<ll> bit(n);
	rep(i,n){
		int a; cin >> a;
		bit.add(i,a);
	}
	while(q--){
		int t,a,b; scanf("%d%d%d",&t,&a,&b);
		if(!t){
			bit.add(a,b);
		}else{
			cout << bit.sum(b-1) - bit.sum(a-1) << "\n";
		}
	}
}

Measured memory_bytes: 8204
#include<iostream>
#include<functional>
#include<vector>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

void d(){
    ll n; cin >> n;
    auto a = v<>(n,0);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll min_ =INF;
  	ll ans=0;
  	rep(i,n){
      	if(abs(a[i] - (a[n-1]+1)/2)< min_){
    	  ans = a[i];	
          min_ = abs(a[i] - (a[n-1]+1)/2);
        }
    }
  	cout << a[n-1] << " " << ans << endl;
}

int main(){
    d();
    return 0;
}

Measured memory_bytes: 1024
#include<stack>
#include<iostream>

using namespace std;

int main()
{
	stack<int> in,out;
	int i;
	while(cin>>i){
		if(i)	in.push(i);
		else	out.push(in.top()),in.pop();
	}
	while(!out.empty())	in.push(out.top()),out.pop();	// reverse
	while(!in.empty()){
		printf("%d\n",in.top());
		in.pop();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(void)
{
    int D;

    cin >> D;

    cout << "Christmas";

    if(D<=24){
        cout << " Eve";
    }
    if(D<=23){
        cout << " Eve";
    }
    if(D<=22){
        cout << " Eve";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import Data.List

findPrime' :: ([Int], [Int]) -> ([Int],[Int])
findPrime' ([], primes) = ([], primes)
findPrime' (prime:numbers, primes) =
    findPrime' (filter (\x -> x `mod` prime /= 0) numbers, prime:primes)

findPrime :: Int -> [Int]
findPrime x = reverse . snd $ findPrime' ([2 .. x], [])

lowerBound' :: (Ord a) => a -> Int -> Int -> [a] -> Int
lowerBound' num left right array
    | right == left + 1 = right
    | midValue < num = lowerBound' num mid right array
    | otherwise = lowerBound' num left mid array
    where mid = (left + right) `div` 2
          midValue = array !! mid

lowerBound :: (Ord a) => a -> [a] -> Int
lowerBound num array
    | num <= head array = 0
    | last array < num = length array
    | otherwise = lowerBound' num 0 (length array - 1) array

lowerBoundValue :: (Ord a) => a -> [a] -> Maybe a
lowerBoundValue num array
    | i == length array = Nothing
    | otherwise = Just (array !! i)
    where i = lowerBound num array

isPrime :: Int -> Bool
isPrime 1 = False
isPrime 2 = True
isPrime num = foldl (\acc x -> acc && (num `mod` x /= 0)) True [2 .. mx]
    where mx = (ceiling . sqrt $ fromIntegral num) + 1

main = do
    [x] <- map read . words <$> getLine
    -- let ans = head . filter (>x) . findPrime $ 2 * x
    -- let Just ans = lowerBoundValue x (findPrime $ 2*x)
    let Just ans = find isPrime [x ..]
    putStrLn $ show ans


Measured memory_bytes: 508
'''
import sys
input=sys.stdin.readline
n,m,c = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
from math import ceil
from collections import defaultdict ,Counter
'''
a,b = map(int,input().split())
print(max(0,a - b*2))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b < c + d)puts("Right");
	if (a + b == c + d) puts("Balanced");
	if (a + b > c + d) puts("Left");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val s = string()
    val k = "^keyence$"
    val rs = Array(8){
        val sb = StringBuilder(k)
        sb.insert(it+1, ".+")
        sb.toString()
    }
    println(if (rs.map { it.toRegex().matches(s) }.contains(true) || k.toRegex().matches(s)) "YES" else "NO")
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 29728
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int F = sc.nextInt();

		int max_sugar = 0;
		int max_sugarwater = 0;
		double max_percent = 0;
		for(int i=0;100*A*i <= F;i++) {
			for(int j=0;100*B*j <= F - 100*A*i;j++) {

				for(int k=0;C*k <= E*(A*i + B*j) && C*k <= F - (A*i + B*j);k++) {
					for(int l=0;D*l <= E*(A*i+B*j) - C*k && D*l <= F - 100*(A*i+B*j) - C*k;l++) {
						double water = 100*(A*i + B*j);
						double sugar = C*k + D*l;
						double percent = (100*sugar) / (water +sugar);

						if(percent >= max_percent) {
							max_sugar = (int)sugar;
							max_sugarwater = (int)(water+sugar);
							max_percent = percent;
						}
					}
				}
			}
		}

		System.out.println(max_sugarwater + " " + max_sugar);
	}

}


Measured memory_bytes: 21588
n, k = map(int, input().split())

roads = list(map(int, input().split()))

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Measured memory_bytes: 32396
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(;;){
            int n = sc.nextInt();
            if(n == 0) break;
            Integer[] a = new Integer[n];
            for (int i = 0; i < a.length; i++) {
                a[i] = sc.nextInt();
            }

            Arrays.sort(a, Comparator.reverseOrder());

            for (int i = 1; i < a.length; i++) {
                a[i - 1] -= a[i];
            }
            a[n - 1] = Integer.MAX_VALUE;
            Arrays.sort(a);
            System.out.println(a[0]);
        }
    }
}

Measured memory_bytes: 46940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

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

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  if (a >= b) cout << "delicious" << endl;
  else if (a + x + 1 > b) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int n,m,x,y,i,t;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(i=0;i<n;i++){
		scanf("%d",&t);
		if(t>x)x=t;
	}
	for(i=0;i<m;i++){
		scanf("%d",&t);
		if(t<y)y=t;
	}
	puts(y>x?"No War":"War");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] num = new int[N];
        int[] dis = new int[N];
        num[0] = sc.nextInt();
        for(int i = 1; i < N; i++) {
            num[i] = sc.nextInt();
            dis[i-1] = num[i] - num[i-1];
        }
        dis[N-1] = K + num[0] - num[N-1];
        
        int max = 0;
        for(int i = 0; i < N; i++) {
            if(max < dis[i]){
                max = dis[i];
            }
        }
        System.out.println(K - max);
    }
}


Measured memory_bytes: 77680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;

vpii l[100010],r[100010];
vector<ll> col(100010,0);
vector<int> vis(100010,0);

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        l[a].push_back({b,c});
        r[b].push_back({a,c});
    }
    bool flag=true;
    rep(i,0,n)if(!vis[i]){
        vis[i]=1;
        col[i]=0;
        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int s=q.front();q.pop();
            for(auto j:l[s]){
                if(vis[j.first]){
                    if(col[s]+j.second!=col[j.first]){
                        flag=false;
                        break;
                    }
                }else{
                    vis[j.first]=1;
                    col[j.first]=col[s]+j.second;
                    q.push(j.first);
                }
            }
            for(auto j:r[s]){
                if(vis[j.first]){
                    if(col[s]-j.second!=col[j.first]){
                        flag=false;
                        break;
                    }
                }else{
                    vis[j.first]=1;
                    col[j.first]=col[s]-j.second;
                    q.push(j.first);
                }
            }
        }
    }
    string ans = flag ? "Yes" : "No";
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 13312
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        Map<Integer, Integer> freq = new HashMap<>();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            int curr = in.nextInt();
            sum += curr;
            freq.merge(curr, 1, Integer::sum);
        }
        in.nextLine();
        final int q = Integer.parseInt(in.nextLine());
        for (int i = 0; i < q; i++) {
            final int num = in.nextInt();
            final int val = in.nextInt();
            if (freq.containsKey(num)) {
                int count = freq.remove(num);
                sum += (long) count * (val - num);
                freq.merge(val, count, Integer::sum);
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 69888
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var nf = arr.shift().split(" ").map(Number);
var f = nf[1];
var obj = {};
arr = arr.map(function(v) {
   v = v.split(" ");
   v.shift();
   v.forEach(function(V) {
      obj[V] = {};
   });
   return v;
});
for (var k in obj) {
   for (var K in obj) {
      obj[k][K] = 0;
   }
}
arr.forEach(function(v) {
   for (var i = 0; i < v.length; i++) {
      for (var j = 0; j < v.length; j++) {
         obj[v[i]][v[j]]++;
      }
   }
});
var ans = [];
for (var k in obj) {
   for (var K in obj) {
      obj[K][k] = 0;
      if (obj[k][K] >= f) {
         ans.push([k, K].sort().join(" "));
      }
   }
}
ans.sort();
console.log(ans.length);
if (ans.length != 0) console.log(ans.join("\n"));

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

int main () {
  char x;
  cin >> x;
  if ( x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){
    cout << "vowel\n"; 
  } else {
    cout << "consonant\n";
  }
}

Measured memory_bytes: 3060
// Coder: @SumitRaut
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
const int mod = 1e9+7;
template<typename T> T pwm(T a,T b,T md=mod) { T p=1,one=1; while(b) { if(b&one) p=p*a%md; a=a*a%md; b >>=1; } return p; }

using namespace std;
class Timer { chrono::high_resolution_clock::time_point start_t, end_t; public: Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };

void solve() {
    int S;
    cin>>S;
    vector<ll> dp(S+1);
    dp[0]=1;
    for(int i=3;i<=S;++i)
        dp[i]=(dp[i-1]+dp[i-3])%mod;
    cout<<dp[S]<<'\n';
}
int main()
{
    speedup;
    #ifndef ONLINE_JUDGE
    Timer timer;
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 3660
def main():    
    N, K = map(int, input().split())
    H = [int(i) for i in input().split()]

    dp = [0 for _ in range(N)]
    dp[0] = 0
    for i in range(1, N):
        dp[i] = min([dp[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)])
    print(dp[N-1])

if __name__ == '__main__':
    main()

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

int main(){
  using psi= pair<string, int>;
  int N;
  cin >> N;

  vector<vector<psi>> data(N);

  data.at(0).emplace_back(make_pair("a", 1));

  string word; int Nchar; char c_tail;
  for(int i=1; i<N; i++){
    for(auto elem:data.at(i-1)){
      tie(word, Nchar)= elem;

      for(int j=0; j<Nchar; j++){
        c_tail= 'a'+ j;
        data.at(i).emplace_back(make_pair(word+ c_tail, Nchar));
      }
      c_tail= 'a'+ Nchar;
      data.at(i).emplace_back(make_pair(word+ c_tail, Nchar+1));
    }
  }

  for(auto elem:data.at(N-1)){
    cout << elem.first << endl;
  }
}

Measured memory_bytes: 10736
/**
 * Created by abhishek on 8/12/2016.
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args)throws Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int array[] = new int[n + 1];
        for(int i = 1;i <= n;i++)
            array[i] = Integer.parseInt(st.nextToken());
        int ans = (int)1E9;
        for(int i = -100;i <= 100;i++){
            int cost = 0;
            for(int j = 1;j <= n;j++){
                cost += (array[j] - i)*(array[j] - i);
            }
            ans = Math.min(cost,ans);
        }
        System.out.println(ans);

    }
}


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

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  int a[m];
  int ans, d = 0, u = 0;
  map<int, int> mp;
  rep(i, m) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for(int i = x - 1; i > 0; i--){
    d += mp[i];
  }
  for(int i = x + 1; i < n; i++){
    u += mp[i];
  }
  ans = min(d,u);
  cout << ans<< endl;
    
  return 0;
}

Measured memory_bytes: 3616
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort()
cost = 0
count = 0
for A, B in AB:
    if M-count > B:
        cost += B*A
        count += B
    elif count < M:
        cost += (M-count)*A
        count += M - count
    else:
        break
print(cost)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll mod=998244353;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

using mint = modint998244353;

struct S{
    mint a;
    ll size;
};

struct F{
    mint a,b;
};


S e(){
    return S{0, 0};
}

F id(){
    return F{1, 0};
}

S op(S l, S r){
    return S{l.a + r.a, l.size + r.size};
}

S mapping(F f, S x){
    return S{f.a * x.a + x.size * f.b, x.size};
}

F composition(F f, F node){
    return F{node.a * f.a, f.b + f.a * node.b};
}


int main(){
    int n,q;cin >> n >> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        ll x;cin >> x;
        a[i] = S{x, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    while(q--){
        int t;cin >> t;
        if(t == 0){
            int l,r,a,b;cin >> l >> r >> a >> b;
            seg.apply(l, r, F{a, b});
        }
        else{
            int l,r;cin >> l >> r;
            cout << seg.prod(l, r).a.val() << endl;
        }
    }
}


Measured memory_bytes: 31440
x,y,a,b,c = (int(x) for x in input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
s = []
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()
r.reverse()

if a>=x and b>=y:
    s = p[0:x] + q[0:y]
elif a>=x and b<y:
    s = p[0:a] + q + r[0:y-b]
    del r[0:y-b]
elif a<x and b>=y:
    s = p + r[0:x-a] + q[0:b]
    del r[0:x-a]
else:
    s = p + q + r[0:x+y-a-b]
    del r[0:x+y-a-b]
s.sort()
i = 0
while s[i]<r[i]:
    s[i] = r[i]
    i += 1
    if i>=len(r):
        break

print(sum(s))


Measured memory_bytes: 23344
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int mn = min(a, b) + w;

	cout << max(0, max(a, b) - mn) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
int main() {
    int n; cin >> n;
    vector<P> vc;
    rep(i, n){
        int x; cin >> x;
        vc.push_back(make_pair(x, i));
    }
    sort(vc.begin(), vc.end());
    rep(i, n){
        cout << vc[i].second+1;
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 2017;
 
char a[N], b[N];
char x[N];
pair<int, int > ve[N];
 
int main() {
  scanf("%s", a);
  scanf("%s", b);
  int n = strlen(a);
  int ans = 1e8;
  for (int sl = -n; sl <= n; sl++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      x[i] = a[(i+n-sl) % n];
      cnt += x[i] != b[i];
      ve[i] = make_pair(-1e8, 1e8);
    }
    if (cnt == 0)
      ans = min(ans, abs(sl));
    int last = -1;
    for (int i = 0; i < 3 * n; i++) {
      if (b[i % n] == '1')
        last = i;
      if (x[i % n] != b[i % n]) {
        if (last == -1) continue;
        ve[i % n].first = max(min(last - i + sl, 0), ve[i % n].first);
      }
    }
 
    last = -1;
    for (int i = 3 * n; i >= 0; i--) {
      if (b[i % n] == '1')
        last = i;
      if (x[i % n] != b[i % n]) {
        if (last == -1) continue;
        ve[i % n].second = min(max(last - i + sl, 0), ve[i % n].second);
      }
    }
    vector<pair<int, int > > vv;
    for (int i = 0; i < n; i++) if (b[i] != x[i])
      vv.push_back(ve[i]);
    sort(vv.begin(), vv.end());
    int ri = max(0, sl);
    for (int le = -n, j = 0; le <= min(sl, 0); le++) {
      while (j < vv.size() && vv[j].first < le) ri = max(ri, vv[j].second), j++;
      ans = min(ans, cnt + ri-le + ri - le -abs(sl));
    }
  }
  if (ans >= 1e8)
    ans = -1;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
let area =
  [| [1; 3]
   ; [0; 2; 4]
   ; [1; 5]
   ; [0; 4; 6]
   ; [1; 3; 5; 7]
   ; [2; 4; 8]
   ; [3; 7]
   ; [4; 6; 8]
   ; [5; 7] |]

let m_d =
  [| [|0; 0; 0; 0; 0; 0; 0; 0; 0|]
   ; [|0; 1; 2; 1; 2; 3; 2; 3; 4|]
   ; [|1; 0; 1; 2; 1; 2; 3; 2; 3|]
   ; [|2; 1; 0; 3; 2; 1; 4; 3; 2|]
   ; [|1; 2; 3; 0; 1; 2; 1; 2; 3|]
   ; [|2; 1; 2; 1; 0; 1; 2; 1; 2|]
   ; [|3; 2; 1; 2; 1; 0; 3; 2; 1|]
   ; [|2; 3; 4; 1; 2; 3; 0; 1; 2|]
   ; [|3; 2; 3; 2; 1; 2; 1; 0; 1|] |]

let h a =
  let rec doit i acc =
    if i = 9 then acc
    else doit (i + 1) (acc + m_d.(a.(i)).(i))
  in doit 0 0

let idx_by_val x a =
  let n = Array.length a in
  let rec doit i =
    if i = n then raise Not_found
    else if x = a.(i) then i
    else doit (i + 1)
  in doit 0

let solve a =
  let goal = [|1; 2; 3; 4; 5; 6; 7; 8; 0|] in
  let rec idastar i limit space_i moved lower =
    if i = limit then begin
      if a = goal then (Printf.printf "%d\n" (List.length moved - 1); exit 0)
    end else
      let move j =
        let x = a.(j) in
        if x <> List.hd moved then
          let new_lower = lower - m_d.(x).(j) + m_d.(x).(space_i) in
          if new_lower + i <= limit then begin
            a.(j) <- 0;
            a.(space_i) <- x;
            idastar (i + 1) limit j (x :: moved) new_lower;
            a.(j) <- x;
            a.(space_i) <- 0;
          end in
      List.iter move area.(space_i)
  in
  let lower = h a in
  let rec doit limit =
    if limit < 32 then begin
      idastar 0 limit (idx_by_val 0 a) [-1] lower;
      doit (limit + 1)
    end in
  doit lower

let () =
  solve (Array.init 9 (fun _ -> Scanf.scanf "%d " (fun i -> i)))

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(p);
    int ans = (a * 3 + p) / 2;
    co(ans);
    return 0;
}

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

using str = string;
using ss = stringstream;

int a[30];

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

    str s;
    cin>>s;

    for(int i=0;i<s.size();i++)a[s[i]-'a']++;

    bool ans=true;

    for(int i=0;i<30;i++)if(a[i]>1)ans=false;

    puts(ans?"yes":"no");

    return 0;
}


Measured memory_bytes: 3620
s = input()
N = len(s)

i = 0
j = N - 1
ans = 0
while i < j:
    if s[i] == s[j]:
        i += 1
        j -= 1
    elif s[i] == "x":
        ans += 1
        i += 1
    elif s[j] == "x":
        ans += 1
        j -= 1
    else:
        ans = -1
        break

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int keta(ll x) {
  if (x == 0) return 0;
  else return keta(x/10) + 1;
}

bool func(ll n) {
  if (n%10 == n) return true;
  return (n%10 == 9) && func(n/10);
}

ll lef(ll n) {
  if (n%10 == n) return n;
  return lef(n/10);
}

void solve() {
  ll n;
  cin >> n;
  int k = keta(n);
  bool b = func(n);
  int l = lef(n);
  if (n < 10) {
    cout << n << endl;
    return;
  }
  int ans = (k-1) * 9 + l;
  if (b) cout << ans << endl;
  else cout << ans - 1 << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3660
def check(grid,i)
  flg = true
  grid.each do |line|
    if line[i] == "#"
      flg = false
    end
  end

  return flg
end

def show(grid)
  grid.each do |line|
    puts line.join
  end
end


h,w = gets.chomp.split(" ").map(&:to_i)

grid = []
h.times do
  input = gets.chomp.split("")
  unless input.all?{|cell| cell == "."}
    grid << input
  end
end

w.times do |i|
  if check(grid,i)
    grid.each{|line| line[i] = nil }
  end
end

grid.each do |line|
  line.compact!
end

show(grid)

Measured memory_bytes: 2684
using System;
 
namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var point = new int[2];
            for(int i = int.Parse(Console.ReadLine()); i > 0; --i) {
                var input = Console.ReadLine().Split();
                var comp = input[0].CompareTo(input[1]);
                if(comp == 0) {
                    ++point[0];
                    ++point[1];
                }
                else {
                    point[comp > 0 ? 0 : 1] += 3;
                }
            }
            Console.WriteLine("{0} {1}", point[0], point[1]);
        }
    }
}

Measured memory_bytes: 6400
#include <string>
#include <algorithm>
#include <limits.h>
#include <iostream>

using namespace std;

int main()
{
	int i, j, H, W, cnt = 0;
	string S[52];
	cin >> H; cin >> W;

	for (i = 1; i < H+1; i++) {
		cin >> S[i];
		S[i] = "." + S[i] + ".";
	}

	for (i = 1; i < H + 1; i++) {
		for (j = 1; j < W + 1; j++) {
			if (S[i][j] != '#') {
				if (S[i - 1][j - 1] == '#') cnt++;
				if (S[i - 1][j] == '#') cnt++;
				if (S[i - 1][j + 1] == '#') cnt++;
				if (S[i + 1][j - 1] == '#') cnt++;
				if (S[i][j - 1] == '#') cnt++;
				if (S[i][j + 1] == '#') cnt++;
				if (S[i + 1][j + 1] == '#') cnt++;
				if (S[i + 1][j] == '#') cnt++;
			}

			if (S[i][j] != '#') {
				S[i][j] = '0' + cnt;
				cnt = 0;
			}
		}
	}

	for (i = 1; i < H+1; i++) {
		S[i].erase(S[i].begin() + (W + 1));
		S[i].erase(S[i].begin());
	}

	for (i = 1; i < H+1; i++) {
		cout << S[i] << endl;
	}

	return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b;
    cin>>a>>b;
    rep(i,1000+1){
        if(i*8/100 == a && i*10/100 == b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    bool mat[n][n];
    fill_n(*mat, n*n, true);

    for(int i = 0; i < n; ++i){
        mat[i][i] = false;
    }
    for(int i = 0; i < n-n%2; ++i){
        mat[i][n-i-1-n%2] = false;
    }

    int cnt = 0;
    vector<pair<int, int>> edge;
    for(int i = 1; i <= n; ++i){
        for(int j = i+1; j <= n; ++j){
            if(mat[i-1][j-1]) {
                edge.push_back(make_pair(i,j));
                ++cnt;
            }
        }
    }

    ppp(cnt);
    for(auto e : edge){
        cout << e.first << sp << e.second << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{
		int H1=nextInt();
		int M1=nextInt();
		int H2=nextInt();
		int M2=nextInt();
		int K=nextInt();

		int t1=H1*60+M1;
		int t2=H2*60+M2;

		pw.println(t2-t1-K);
	}
	public static void solutionB(String[] args) throws Exception{
		pw.println(nextString().replaceAll("\\?","D"));
	}
	public static void solutionC(String[] args) throws Exception{
		int N=nextInt();
		int[] A = new int[N+2];
		for(int i=1;i<=N+1;i++) {
			A[i]=nextInt();
		}
		long sum=0;
		for(int i=0;i<A.length;i++) {
			sum+=A[i];
		}
		long ans=1;
		//葉ではないノードの数
		long[] s = new long[N+2];
		s[0]=1;

		for(int i=1;i<=N;i++) {
			long tmp = s[i-1]-A[i];
			sum-=A[i];
			if(tmp<=0) {
				pw.println(-1);
				return;
			}
			//残りの葉の数
			long sub=sum-tmp;
			//この階層で何個ノードを作っても矛盾しないか（2倍以内）
			if(sub<0) {
				pw.println(-1);
				return;
			}else {
				tmp=Math.min(tmp*2, tmp+sub);
			}
			s[i]=tmp;
			ans+=tmp;
		}
		pw.println(ans);
	}
	public static void solutionD(String[] args) throws Exception{


	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25388
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long  ll;
const int MAXN=1e5;
int len[MAXN];
struct edge{
    int x,y;
};

edge dp[MAXN];
int ans[MAXN];
int main()
{
    int h,w,d;
    while (scanf("%d%d%d",&h,&w,&d)!=EOF) {
        memset(len, 0, sizeof(len));
        int id;
        for(int i=1;i<=h;i++)
            for(int j=1;j<=w;j++)
            {
                scanf("%d",&id);
                dp[id]=edge{i,j};
            }
        for(int i=0;i<d;i++)
        {
            ans[i]=0;
            for(int j=1;j*d+i<=h*w;j++)
                ans[i+j*d]=ans[i+(j-1)*d]+abs(dp[i+j*d].x-dp[i+(j-1)*d].x)+abs(dp[i+j*d].y-dp[i+(j-1)*d].y);
        }
        int q,x,y;
        scanf("%d",&q);
        while (q--) {
            scanf("%d%d",&x,&y);
            printf("%d\n",ans[y]-ans[x]);
        }
    }
    return 0;
}

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


int main() {

    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 1000
#define MAX_H 10000
#define INF 922337203685477

i64 H, N;
i64 A[MAX_N * 2];
i64 B[MAX_N * 2];
i64 dp[MAX_N + 1][2 * MAX_H];

i64 solve() {
    i64 min_mp = INF;

    REP(i, N + 1) {
        dp[i][0] = 0;
        FOR(j, 1, 2 * H + 1) {
            dp[0][j] = INF;
        }
    }

    REP(i, N) {
        FOR(j, 0, 2 * H) {
            if (j - A[i] >= 0) {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    FOR(j, H, 2 * H) chmin(min_mp, dp[N][j]);

    return min_mp;
}

int main() {
    cin >> H >> N;
    REP(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] > H) A[i] = H;
    }

    i64 ans = solve();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 156672
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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 <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> L;
    vector<string> v(N);
    cin >> v;
    sort(ALL(v));
    REP(i, N)
    T += v[i];
    cout << T << endl;
}

Measured memory_bytes: 3628
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<pll> edge;
vector<ll> Pr,I,Po;


void dfs(ll where){
    if(where==-1){return;}
    Pr.push_back(where);
    dfs(edge[where].F);
    I.push_back(where);
    dfs(edge[where].S);
    Po.push_back(where);
}


int main(){
    ll n;
    cin>>n;
    vector<ll> parent(n,1);
    edge.resize(n);
    for(int i=0;i<n;i++){
        ll id,l,r;
        cin>>id>>l>>r;
        edge[id]={l,r};
        if(l!=-1){
            parent[l]=0;
        }
        if(r!=-1){
            parent[r]=0;
        }
    }
    for(int i=0;i<n;i++){
        if(parent[i]){dfs(i);}
    }
    cout<<"Preorder"<<endl;
    for(int i=0;i<n;i++){
        cout<<" "<<Pr[i];
    }
    cout<<endl;
    cout<<"Inorder"<<endl;
    for(int i=0;i<n;i++){
        cout<<" "<<I[i];
    }
    cout<<endl;
    cout<<"Postorder"<<endl;
    for(int i=0;i<n;i++){
        cout<<" "<<Po[i];
    }
    cout<<endl;
    
    
    return 0;
}



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

int main(){
  int n,lastn,anst[10],ans;
  cin>>n;
  
  int tmp=1000000000;
  lastn=n;
  rep(i,1,9){
    tmp=tmp/10;
    anst[i]=lastn/tmp;
    lastn=n%tmp;
  }

  rep(i,1,9){ans+=anst[i];}
  ans+=lastn;
  if(n%ans==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

  return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  for(int i = 1; i <= X; i++){
    if(Y == 4 * i + 2 * (X - i) || Y == 2 * i + 4 * (X - i)){
      cout << "Yes" << endl;
      break;
    }
    else if(i == X){
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3628
import std.stdio,
  std.array,
  std.string,
  std.algorithm,
  std.range,
  std.conv;

void main()
{
  int[] xs = readln.split.map!(to!int).array;
  string[] ss;
  foreach (i; 0..xs[0]) {
    ss ~= readln.chomp;
  }

  ss.sort();

  writeln(ss.join(""));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
	        int i=0;
	        for(int j=1; j<=10000; j++){
	            i = sc.nextInt();
	            if(i==0) break;
	            System.out.println("Case "+j+": "+i);
	        }
	        sc.close();
	    }
	}

Measured memory_bytes: 41532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;
typedef pair<ll, ll> PL;
typedef long double ldouble;

const int MOD = 1e9 + 7;

ll F1[2][3030], F2[3030];
ll tmp[2][3030][3030];
ll arr[3030];
ll D[2][3030];

ll P[120][120][120];

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	
	F2[0] = 1;
	for(int i=1;i<=m;i++)F2[i] = F2[i-1] * 4LL % MOD;
	
	tmp[0][0][0] = 1;
	tmp[1][0][1] = 1;
	rep(u, 2){
		for(int i=1;i<=m;i++){
			for(int j=0;j<=n;j++)arr[j] = 0;
			for(int j=1;j<n;j++){
				arr[j] = tmp[u][i-1][j];
				arr[j] = (arr[j] + tmp[u][i-1][j+1]) % MOD;
			}
			for(int j=1;j<=n;j++){
				if(j>1)arr[j] = (arr[j] + tmp[u][i-1][j]) % MOD;
				arr[j] = (arr[j] + tmp[u][i-1][j-1]) % MOD;
			}
			D[u][i] = tmp[u][i-1][n];
			for(int j=0;j<=n;j++)tmp[u][i][j] = arr[j];
		}
	}
	
	memset(tmp, 0, sizeof tmp);
	
	tmp[0][0][0] = 1;
	tmp[1][0][1] = 1;
	F1[0][0] = 1;
	F1[1][0] = 1;
	rep(u, 2){
		for(int i=1;i<=m;i++){
			for(int j=0;j<=n;j++)arr[j] = 0;
			for(int j=0;j<n;j++){
				arr[j] = tmp[u][i-1][j];
				arr[j] = (arr[j] + tmp[u][i-1][j+1]) % MOD;
			}
			for(int j=1;j<=n;j++){
				arr[j] = (arr[j] + tmp[u][i-1][j]) % MOD;
				arr[j] = (arr[j] + tmp[u][i-1][j-1]) % MOD;
			}
			for(int j=0;j<=n;j++)tmp[u][i][j] = arr[j];
			for(int j=0;j<=n;j++)F1[u][i] = (F1[u][i] + tmp[u][i][j]) % MOD;
		}
	}
	
	ll ans = 0;
	
	for(int i=0;i<=m;i++){
		for(int j=0;j+i<=m;j++){
			ans = (ans + ((ll)F1[0][i] * D[0][j]) % MOD * F2[m-i-j]) % MOD;
		}
	}
	
	for(int i=0;i<=m;i++){
		for(int j=0;j+i<=m-1;j++){
			ans = (ans + ((ll)F1[0][i] * D[1][j]) % MOD * F2[m-1-i-j]) % MOD;
		}
	}
	
	for(int i=0;i<=m;i++){
		for(int j=0;j+i<=m;j++){
			ans = (ans + ((ll)F1[1][i] * D[0][j]) % MOD * F2[m-i-j]) % MOD;
		}
	}
	
	for(int i=0;i<=m;i++){
		for(int j=0;j+i<=m-1;j++){
			ans = (ans + ((ll)F1[1][i] * D[1][j]) % MOD * F2[m-1-i-j]) % MOD;
		}
	}
	
	ans *= 2;
	ans = F2[m] - ans;
	ans %= MOD; if(ans < 0)ans += MOD;
	
	printf("%lld\n", ans);
	

}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 145024