akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
long long n,k,h=0;
int a[10001];
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=n-1;i>=n-k;i--)
    {
        h+=a[i];
    }
    cout<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 55
#define maxm 125005
#define int long long
#define INF 1e9 + 10
int n, X, D, ans, cnt, dp[maxm];
int w[maxn], val[maxn], pos[maxn];
int tot, V[maxn * maxn], W[maxn * maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

struct edge
{
    int cnp, to[maxn], last[maxn], head[maxn];
    edge() { cnp = 1; }
    void add(int u, int v)
    { to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++; }
}E1;

void dfs(int u)
{
    val[u] = 1;
    for(int i = E1.head[u]; i; i = E1.last[i])
    {
        int v = E1.to[i];
        dfs(v);
        w[u] += w[v]; val[u] += val[v];
    }
    pos[u] = u;
}

bool cmp(int x, int y) { return val[x] * w[y] > val[y] * w[x]; }
void Get_min(int &x, int y) { x = x < y ? x : y; }

int num[60];

signed main()
{
    n = read(), X = read(), D = read();
    w[1] = read();
    for(int i = 2; i <= n; i ++)
    {
        w[i] = read(); int x = read();
        E1.add(x, i);
    }
    dfs(1);
    memset(dp,63,sizeof dp);dp[0]=0;
    for(int i = 1; i <= n; i ++)
    {
        int len = 1, lim = X/w[i];
		if(i>1) lim=min(lim,D);

		if(lim>n) num[i]=lim-n,lim=n;

        while(lim>0)
        {
			if(lim<len) len=lim;
            V[++ tot] = len * val[pos[i]];
            W[tot] = len * w[pos[i]];
			for(int j = n*n*n;j>=V[tot]; j --) Get_min(dp[j], dp[j - V[tot]] + W[tot]);
		    lim -= len, len <<= 1;
        }
    }

	sort(pos + 1, pos + n + 1, cmp);
    int ans = 0;
    for(int i = 0; i <= n*n*n; i ++)
       {
        if(dp[i] > X) continue;
        int ret = i, left = X - dp[i];
        for(int j = 1; j <= n; j ++)
        {
            int tem = pos[j];
			int used = min(num[tem], left / w[tem]);

            left -= w[tem] * used;
            ret += val[tem] * used;
        }
        ans = max(ans, ret);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());

        if(K % 2 == 0){

            System.out.println( (K/2)*(K/2));

        }else{

            System.out.println( (K/2)*(K/2+1));
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const int mod = 1e9 + 7;
const int MX = 1e5 + 5;
ll fact[MX];
ll mulmod(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }

void factorial() {
    fact[0] = 1;
    fact[1] = 1;
    for (ll i = 2; i < MX; i++) {
        fact[i] = mulmod(fact[i - 1], i);
    }
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    factorial();
    int n;
    cin >> n;
    cout << fact[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string s;cin>>s;
	stack<char>st;
	for(char c:s){
		if(st.empty()||st.top()==c)st.push(c);
		else st.pop();
	}
	cout<<len(s)-len(st)<<endl;
}


Measured memory_bytes: 3824
package main

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

var fsc = NewFastScanner()

func main() {
	rate := fsc.NextInt()
	if rate < 1200 {
		fmt.Println("ABC")
	} else if rate < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

void maxHeapify( int* a, int i, int n )
{
    int l = i * 2 + 1, r = i * 2 + 2;
    int large;
    large = ( l < n && a[l] > a[i] ) ? l : i;
    large = ( r < n && a[r] > a[large] ) ? r : large;

    if( large != i )
    {
        int t = a[i];
        a[i] = a[large];
        a[large] = t;
        maxHeapify( a, large, n );
    }
}

int main()
{
    int n;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];

    for( int i = n / 2; i >= 0; i-- )
        maxHeapify( a, i, n );

    for( int i = 0; i < n; i++ )
        cout << " " << a[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 5008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll t[n];
    ll tmp = 0;
    rep(i, n){
        tmp += a[i];
        t[i] = tmp;
    }
    int ans = 1;
    rrep(i, n - 1){
        if (a[i + 1] <= t[i] * 2){    
            ans++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a*b>c*d)
            printf("%d\n",a*b);
        else
            printf("%d\n",c*d);
    }
    return 0;
}


Measured memory_bytes: 128
import scala.io.Source.stdin

object Main {
  def v(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => (x1-x0,y1-y0) }
  def cross(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => x0*y1-x1*y0 }

  def main(args:Array[String]) = {
    val b = new StringBuilder

    for(l<-stdin.getLines.map(s=>s.split(",").map(_.toDouble))) {
      val v01 = v((l(0),l(1)), (l(2),l(3)))
      val v02 = v((l(0),l(1)), (l(4),l(5)))
      val v03 = v((l(0),l(1)), (l(6),l(7)))
      val v10 = v((l(2),l(3)), (l(0),l(1)))
      val v12 = v((l(2),l(3)), (l(4),l(5)))
      val v13 = v((l(2),l(3)), (l(6),l(7)))
      if(cross(v02, v01)*cross(v02,v03) < 0
          && cross(v13,v12)*cross(v13,v10) < 0)
        b.append("YES\n")
      else
        b.append("NO\n")
    }
    print(b.result)
  }
}

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

template<class T>
struct BIT {
    vector<T> v;
    const int n;

    BIT(int _n) : v(_n + 1, 0), n(_n) {}

    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += v[i];
            i -= (i & (-i));
        }
        return s;
    }

    // [i, j]の要素の和
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            v[i] += x;
            i += (i & (-i));
        }
    }
};

int main() {
    BIT<int> bit(201010);

    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    ll ans = 0;
    rep(i, N) {
        if (bit.sum(P[i], N) == i) ans++;
        bit.add(P[i], 1);
    }

    cout << ans << endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

// 約数列挙
template <class T>
vector<T> dividers(T n) {
    vector<T> ret;
    for (T x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            ret.push_back(x);
            if (x * x != n) ret.push_back(n / x);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    lint N;
    cin >> N;

    vector<lint> divs(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= (int)N; j += i) {
            divs[j]++;
        }
    }

    lint ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += divs[i] * i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81296
#include<iostream>
#include<cstdio>
#define N (4009)
#define MOD (924844033)
using namespace std;

long long n,k,vis[N],tot,g[N],f[N][N][2],fac[N];

int main()
{
	scanf("%lld%lld",&n,&k);
	for (int t=1; t<=2; ++t)
		for (int i=1; i<=k; ++i)
			for (int j=i; j<=n; j+=k)
			{
				tot++;
				if (j!=i) vis[tot]=true; 
			}
	f[0][0][0]=1;
	for (int i=1; i<=2*n; ++i)
		for (int j=0; j<=n; ++j)
		{
			(f[i][j][0]+=f[i-1][j][0]+f[i-1][j][1])%=MOD;
			if (vis[i]) (f[i][j][1]+=f[i-1][j-1][0])%=MOD;
		}
	for (int i=0; i<=n; ++i)
		g[i]=(f[2*n][i][0]+f[2*n][i][1])%MOD;
	
	fac[0]=1;
	for (int i=1; i<=n; ++i) fac[i]=fac[i-1]*i%MOD;
	long long ans=fac[N];
	for (int i=0,j=-1; i<=n; ++i,j=-j)
		(ans-=j*g[i]*fac[n-i]%MOD)%=MOD;
	printf("%lld\n",(ans+MOD)%MOD);
}

Measured memory_bytes: 249728
import scala.io.StdIn.{readLine, readInt}

object Main extends App {

  val Array(n, m) = readLine().split(" ").map { _.toInt }

  val lines = Seq.fill(n)(readLine())
  val ys    = Seq.fill(m)(readInt())

  val xss = for {
    line <- lines
    xs    = line.split(" ").map { _.toInt }
  } yield xs.toSeq

  val result = xss.map { xs =>
    val zs = (xs zip ys).map { case (x, y) => x * y }
    zs.sum
  }

  result.foreach(println)
}



Measured memory_bytes: 48564
using System;
class Program {
    static void Main(string[] args) {
        string[] input = Console.ReadLine().Split();
        long x = long.Parse(input[0]);
        long y = long.Parse(input[1]);
        long mod = 1000000007;

        if ((x + y) % 3 != 0) {
            Console.WriteLine("0");
            return;
        }

        long a = (2 * x - y) / 3;
        long b = (2 * y - x) / 3;

        //片方でも負の数があれば、答えはゼロとなる
        if (a < 0 || b < 0) {
            Console.WriteLine("0");
            return;
        }
        ////片方でも0があれば、答えは1となる
        //if (a == 0 || b == 0) {
        //    Console.WriteLine("1");
        //    return;
        //}

        //逆元の配列を作る
        long[] inv = new long[a];
        
        //まずは分子のmodを計算する
        long ans = FactorialMod(a + b, mod);

        //分母の逆元modをかける
        ans = ans * FactoricalModInv(a, mod) % mod * FactoricalModInv(b, mod) % mod;

        Console.WriteLine(ans);
    }

    //mod付き階乗の計算
    static long FactorialMod(long n, long m) {
        if (n <= 1) {
            return 1;
        }
        return n * FactorialMod(n - 1, m) % m;
    }

    //aの逆元を求める
    static long ModInv(long a, long M) {
        if (a <= 1) {
            return 1;
        }
        long m = (-(ModInv(M % a, M) * (M / a))) % M;
        if (m < 0) {
            m += M;
        }
        return m;
    }

    //分母の階乗をしながら逆元を求めていく
    static long FactoricalModInv(long a, long M) {
        if (a <= 1) {
            return 1;
        }
        return FactoricalModInv(a - 1, M) * ModInv(a, M) % M;
    }
}

Measured memory_bytes: 31952
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int a, b;
	cin >> a >> b;
	printf("%d\n", b%a == 0 ? a + b : b - a);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = 1e13;
 
//vector<vector<pair<ll, ll>>> dp(100 + 2, vector<pair<ll, ll>>(50700)); // dp[i][j] := i日目にj円持ってるときに持ってる500円の枚数と支払った金額
pair<ll, ll> dp[200][50700];
 
int main() {
    ll n, i, j;
    while(cin >> n, n) {
        vector<ll> p(n);
        for(i = 0; i < n; i++) {
            cin >> p[i];
        }
        pair<ll, ll> x = make_pair(0LL, INF);
        for(i = 0; i <= n; i++) {
            for(j = 0; j <= 50100; j++) {
                dp[i][j] = x;
            }
        }
        dp[0][0] = make_pair(0LL, 0LL);
        for(i = 0; i < n; i++) {
            for(j = 0; j < 50000; j++) {
                if(dp[i][j].second == INF) continue;
                if(dp[i][j].first > dp[i + 1][j].first)
                    dp[i + 1][j] = dp[i][j]; //何もしないとき
                else if(dp[i][j].first == dp[i + 1][j].first) {
                    dp[i + 1][j].second = min(dp[i + 1][j].second, dp[i][j].second);
                }
                // 買うとき
                ll otsuri = (1000 - (p[i] % 1000)) % 1000; // 小銭を使わないで得られるお金
                if(otsuri >= 500) {
                    // cerr << j+otsuri-500 << endl;
                    if(dp[i + 1][j + otsuri - 500].first < dp[i][j].first + 1)
                        dp[i + 1][j + otsuri - 500] = make_pair(dp[i][j].first + 1, dp[i][j].second + p[i]);
                    else if(dp[i + 1][j + otsuri - 500].first == dp[i][j].first + 1)
                        dp[i + 1][j + otsuri - 500].second = min(dp[i + 1][j + otsuri - 500].second, dp[i][j].second + p[i]);
                } else {
                    ll must = (p[i] % 1000) - 500; // 500円を得るのに最低必要な小銭
                    if(must == -500) must = 500;
                    if(must <= j) {
                        if(dp[i + 1][j - must].first < dp[i][j].first + 1)
                            dp[i + 1][j - must] = make_pair(dp[i][j].first + 1, dp[i][j].second + p[i]);
                        else if(dp[i + 1][j - must].first == dp[i][j].first + 1)
                            dp[i + 1][j - must].second = min(dp[i + 1][j - must].second, dp[i][j].second + p[i]);
                    }
                    //とりあえずお金を稼ぐ
                    if(dp[i + 1][j + otsuri].first < dp[i][j].first)
                        dp[i + 1][j + otsuri] = make_pair(dp[i][j].first, dp[i][j].second + p[i]);
                    else if(dp[i + 1][j + otsuri].first == dp[i][j].first)
                        dp[i + 1][j + otsuri].second = min(dp[i][j].second + p[i], dp[i + 1][j + otsuri].second);
                }
            }
        }
        pair<ll, ll> ret(0LL, INF);
        for(i = 0; i < 50000; i++) {
            if(dp[n][i].first > ret.first) {
                ret = dp[n][i];
            } else if(dp[n][i].first == ret.first) {
                ret.second = min(ret.second, dp[n][i].second);
            }
        }
        cout << ret.first << " " << ret.second << endl;
        //cout << dp[2][200].first << " " << dp[2][200].second << endl;
    }
    return 0;
}


Measured memory_bytes: 82552
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl; 
    }
    else cout << "No" << endl;
}



Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
n = N // 2
if N % 2 == 1:
  ans = sum(A[:n]) + sum(A[1:n+1])
else:
  ans = sum(A[:n]) + sum(A[1:n])
print(ans)

Measured memory_bytes: 31340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll n, k;
vector<ll> a;
vector<ll> f;


bool isOK(ll x, ll key) {
    ll cost = 0;
    rep(i, n){
        if (a[i] * f[i] > x) cost += a[i] - x/f[i];
    }
    if (cost <= key) return true;
    else return false;
}

ll binary_search(ll key) {
    ll ng = -1;
    ll ok = 1e+18+7;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin >> n >> k;

    rep(i, n) {
        ll p;
        cin >> p;
        a.push_back(p);
    }
    rep(i, n){
        ll p;
        cin >> p;
        f.push_back(p);
    }

    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());

    cout << binary_search(k) << endl;

    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string w;
  cin >> w;
  map<char,int> mp;
  rep(i,w.size()){
    mp[w.at(i)]++;
  }
  bool a = true;
  for(auto p:mp){
    if(p.second%2!=0){
      a = false;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);

int n;
int a[3][N];
int dp[N][3];

int getmax(int idx, int del){
	int ret = 0;
	for(int i = 0 ; i < 3 ; i++)
		if(i!=del)
			ret = max(ret,dp[i][idx-1]);
	return ret;
}

int main() {
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ;j < 3 ; j++)
			scanf("%d",a[j]+i);

	for(int i = 0 ; i < 3 ; i++)
		dp[i][0]=a[i][0];

	for(int i = 1 ; i < n ; i++)
		for(int j = 0 ; j < 3 ; j++)
			dp[j][i]=a[j][i]+getmax(i,j);

	int ans = max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	cout << ans << endl;

    return 0;
}

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

int main() {
    ll A,B1;
    long double B;
    cin >> A >> B;
    // B1 = B*100;
    // A *= B1;
    // string str;
    // str = to_string(A);
    // if(A == 0 || B1 == 0 || A < 100){
    //     cout << 0 << endl;
    // }else{
    //     cout << str.substr(0,str.size()-2) << endl;
    // }
    A = A*B;
    cout << A << endl;
    
    return 0;
}

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

int main() {
  int N, M, city;
  cin >> N >> M;
  vector<int> numroad(N, 0);
  for (int i=0; i < 2 * M; i++) {
    cin >> city;
    numroad.at(city - 1)++;
  }
  for (int i=0; i < N; i++) {
    cout << numroad.at(i) << endl;
  }
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        # self.group_num -= 1

n, k = LI()
P = LI()
C = LI()
U = UnionFind(n)
for i in range(n):
    U.union(P[i] - 1, i)

D = defaultdict(int)
for i in range(n):
    D[U.root(i)] += C[i]

ans = -INF
k -= 1
for j in range(n):
    now = P[j] - 1
    r = D[U.root(now)]
    m = U.get_size(now)
    ret = C[now]
    ans = max(ans, ret)
    if k // m and r >= 0:
        ret += k // m * r
        ans = max(ans, ret)
        for l in range(k % m):
            now = P[now] - 1
            ret += C[now]
            ans = max(ans, ret)
    ret = C[now]
    for l in range(min(m, k)):
        now = P[now] - 1
        ret += C[now]
        ans = max(ans, ret)

print(ans)







Measured memory_bytes: 85688
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n,a;
    int al=0;
    int bo=0;
    cin>>n;
    vector<int>v(n);
    for(int i=0; i<n; i++){
        cin>>a;
        v.at(i)=a;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int k=0; k<n; k++){
        if(k==0 || k%2==0){
            al += v.at(k);
        }else{
            bo += v.at(k);
        }
    }
    cout<<al-bo<<endl;
}

Measured memory_bytes: 3620
using System;

namespace C___Train_Ticket
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ();
            var a = int.Parse (input[0].ToString ());
            var b = int.Parse (input[1].ToString ());
            var c = int.Parse (input[2].ToString ());
            var d = int.Parse (input[3].ToString ());
            if (a + b + c + d == 7)
                Console.WriteLine ($"{a}+{b}+{c}+{d}=7");

            else if (a + b + c - d == 7)
                Console.WriteLine ($"{a}+{b}+{c}-{d}=7");

            else if (a + b - c + d == 7)
                Console.WriteLine ($"{a}+{b}-{c}+{d}=7");

            else if (a - b + c + d == 7)
                Console.WriteLine ($"{a}-{b}+{c}+{d}=7");

            else if (a - b - c + d == 7)
                Console.WriteLine ($"{a}-{b}-{c}+{d}=7");

            else if (a + b - c - d == 7)
                Console.WriteLine ($"{a}+{b}-{c}-{d}=7");

            else if (a - b + c - d == 7)
                Console.WriteLine ($"{a}-{b}+{c}-{d}=7");

            else if (a - b - c - d == 7)
                Console.WriteLine ($"{a}-{b}-{c}-{d}=7");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int R,G,B,N;

	cin >> R >> G >> B >> N ;

	int ans = 0;
	int rlim = N/R;
	int glim = N/G;

	for (int r = 0; r<= rlim; r++){
		for (int g = 0; g <= glim; g++){
			if (N >= r*R+g*G){
				if ( (N-(r*R+g*G)) % B == 0  ){
					ans += 1;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007
#define M_MAX 1111

typedef long long ll;
typedef pair<ll,ll> P;

int xx[M_MAX*M_MAX];
int yy[M_MAX*M_MAX];
pair<int,int> dp[M_MAX][M_MAX];
bool isp[M_MAX*M_MAX];
int mp[M_MAX][M_MAX];
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

void f(){
	int x = M_MAX-1;
	int y = M_MAX-1;
	int now = M_MAX*M_MAX;
	int cou = 0;
	
	while(now > 0){
		mp[y][x] = now;
		xx[now] = x;
		yy[now] = y;
		now--;
		int tmpx = x + dx[cou];
		int tmpy = y + dy[cou];
		
		if(tmpx >= 0 && tmpx < M_MAX && tmpy >= 0 && tmpy < M_MAX && 
		mp[tmpy][tmpx] == 0){
			x = tmpx;
			y = tmpy;
		}
		else{
			cou = (cou + 1) % 4;
			x += dx[cou];
			y += dy[cou];
		}
	}
	
	REP(i,M_MAX*M_MAX)isp[i] = true;
	isp[0] = isp[1] = false;
	for(int i = 2;i < M_MAX*M_MAX;i++){
		if(isp[i]){
			for(int j = 2*i;j < M_MAX*M_MAX;j += i)isp[j] = false;
		}
	}
}

int main(){
	
	f();
	
	int n,m;
	
	while(cin >> m >> n,n|m){
		
		REP(i,M_MAX)REP(j,M_MAX)dp[i][j] = MP(-1,-1);
		
		dp[yy[n]][xx[n]] = MP(0,0);
		
		REP(i,M_MAX){
			REP(j,M_MAX){
				if(dp[i][j] != MP(-1,-1) && mp[i][j] <= m){
					DBG(cout << "NOW : " << mp[i][j] << endl;)
					if(isp[mp[i][j]]){
						dp[i][j] = MP(dp[i][j].FI+1,mp[i][j]);
					}
					REP(k,3){
						int x = j + dx[k];
						int y = i + 1;
						DBG(cout << "xy : " << x << ' ' << y << endl;)
						if(x >= 0 && x < M_MAX && y >= 0 && y < M_MAX){
							dp[y][x] = max(dp[i][j],dp[y][x]);
							DBG(cout << "DP : " << dp[y][x].FI << ' ' << dp[y][x].SE << endl;)
						}
					}
				}
			}
		}
		
		pair<int,int> ans = MP(0,0);
		
		REP(i,M_MAX){
			REP(j,M_MAX){
				if(mp[i][j] <= m)ans = max(ans,dp[i][j]);
			}
		}
		
		cout << ans.FI << ' ' << ans.SE << endl;
	}

	return 0;
}


Measured memory_bytes: 28392
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();

            if (C % gcd(A, B) == 0) out.println("YES");
            else out.println("NO");
        }

        public int gcd(int a, int b) {
            if (b == 0) return a;
            return gcd(b, a % b);
        }

    }
}



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

int main() {
	ll n, a, b, c, d, e;
	cin >> n;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	ll ans = 4 + ceil((double)n / min(a, min(b, min(c, min(d, e)))));
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, m, e, size):
        self.m = m  # monoid
        self.e = e  # identity element
        self.size = size  # limit for array size
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


e = 0
size = 10**6
ST = SegmentTree(A, m=gcd, e=e, size=size)

ans = 1
for i, a in enumerate(A):
    ST.modify(i, 0)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


Measured memory_bytes: 128792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#include <math.h> 


int main(){
    double L;
    cin >> L;
    double l = L/3.00000000000;
    printf("%le\n",l*l*l);
    
    

    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();

		if (T.substring(0, S.length()).equals(S)) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

	}

}


Measured memory_bytes: 35652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		long a,b;
		if(K<=A) {
			a=A-K;
			b=B;
		}else if(A<K && K<= (A+B)) {
			a=0;
			b=B-K+A;
		}else {
			a=0;
			b=0;
		}
		System.out.println(a+" "+b);
	}

}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;

  for (int i=0; i<n; i++) {
    char s;
    cin >> s;
    if (s=='Y') {
      printf("Four\n");
      return 0;
    }
  }

  printf("Three\n");
  return 0;
}

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

const int N_MAX = 200005;

double S[N_MAX];
int P[N_MAX];

int main(){
    int n, k;
    cin >> n >> k;
    S[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> P[i];
        S[i] = S[i-1] + ((double)P[i] + 1)/2;
    }
    double ans = 0;
    for(int i = k; i <= n; i++){
        ans = max(ans, S[i] - S[i-k]);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    unordered_set<int> dset;
    rep(i,n)
    {
        int d;
        cin >> d;
        dset.insert(d);
    }

    cout << dset.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/


void proc() {
	LOAD(int, N);
	LOAD(int, Q);
	std::string s;
	std::vector<char> t(Q), d(Q);
	cin >> s;
	for (int q = 0; q < Q; ++q) {
		cin >> t[q] >> d[q];
	}
	auto destiny = [&](int n) {
		if (n == -1)return 0;
		if (n == N)return 2;
		int pos = n;
		for (int i = 0; i < Q; ++i) {
			if (t[i] == s[pos]) {
				if (d[i] == 'L') {
					--pos;
				}
				else {
					++pos;
				}
				if (pos == -1)return 0;
				if (pos == N)return 2;
			}
		}
		return 1;
	};
	int a = -1, b = N;
	int n0, n1;
	for (int k = 0; k < 30; ++k) {
		if (a == b || k == 29) {
			n0 = a;
			break;
		}
		int r = (a + b + 3) / 2 - 1;
		if (0 < destiny(r)) {
			b = r;
		}
		else {
			a = r;
		}
	}
	a = -1, b = N;
	for (int k = 0; k < 30; ++k) {
		if (a == b || k == 29) {
			n1 = a;
			break;
		}
		int r = (a + b + 3) / 2 - 1;
		if (1 < destiny(r)) {
			b = r;
		}
		else {
			a = r;
		}
	}
	cout << n1 - n0;
}


#endif


Measured memory_bytes: 1104
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix

def nextRR(N):
    for i in range(0, len(N)-1):
        if (N[i] <= N[i+1]) and N[i] != 9:
            m = N[i] + 1
            for j in range(i, -1, -1):
                N[j] = m
                if m > 0:
                    m -= 1
            return N

    if N[-1] == 9:
        N = [0] * len(N) + [1]
        return N

    m = N[-1] + 1
    for i in range(len(N)-1, -1, -1):
        N[i] = m
        if m > 0:
            m -= 1
    return N


def solv(K):
    if K <= 12:
        return str(K)
    N = [1, 2]
    for i in range(13, K):
        N = nextRR(N)
    return "".join(map(str, reversed(N)))


if __name__ == "__main__":
    K = int(input())
    ans = solv(K)
    print(ans)


Measured memory_bytes: 3064
import sys

N, M = map(int, input().split())

graph = [0] * (M)
for m in range(M):
    a, b, c = map(int, input().split())
    graph[m] = (a, b, -c)

INF = 1e18
distance = [INF] * N
distance[0] = 0

for n in range(N):
    for i in range(M):
        a, b, c = graph[i]
        if INF != distance[a - 1] and distance[b - 1] > distance[a - 1] + c:
            distance[b - 1] = distance[a - 1] + c
            if b == N and n == N - 1:
                print("inf")
                sys.exit()

print(-distance[N - 1])

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	vector<int> h(n);
	for (int i=0; i<n; i++) cin>>h[i];
	int ret=2e9;
	sort(h.begin(), h.end(), greater<int>());
	for (int i=0; i<=n-k; i++)
		ret=min(ret,h[i]-h[i+k-1]);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)

	var res int
	var has bool

	for i := 0; i < 100000; i++ {
		fa := float64(i) * 0.08
		fb := float64(i) * 0.1

		ta := int(fa) == a
		tb := int(fb) == b

		// fmt.Println(i, fa, fb, int(fa), int(fb), ta, tb)
		if ta && tb {
			res = i
			has = true
			break
		}
	}

	if has {
		fmt.Println(res)
	} else {
		fmt.Println(-1)
	}
}


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

int main()
{
  int n;
  cin>>n;
  int x;
  unordered_map<int, int>mp;
  while(cin>>x)
  {
    mp[x]++;
  }

  for(int i=1;i<=n;i++)
  {
    cout<<mp[i]<<" ";
  }
  cout<<"\n";
}


Measured memory_bytes: 11476
/*     !ya khoda!     */
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define I insert
#define E erase

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll poow(ll x,ll n,ll Mod=1e9+7) { return (n==0?1:poow(x*x%Mod,n/2)*(n&1?x:1)%Mod); }
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=1e5+100 , M=1e6+10  , SQ=550 , LG=21 , base=2;
const int mod=1e9+7 , MOD=1e9+9;
const ll  INF=1e9   , inf=1e18 , super_inf=~0ull/4;
ll n,ans;
string s;
map<pair<string,string>,ll>w;
/*==========================================================================*/
int main()
{
    IOS;
	cin>>n>>s;

	for(int mask=0;mask<(1<<n);mask++)
    {   string z="",e="";
        for(int i=0;i<n;i++)
            if(BIT(mask,i))   z+=s[i];
            else              e+=s[i];

        w[mkp(z,e)]++;;
    }

    for(int mask=0;mask<(1<<n);mask++)
    {   string z="",e="";
        for(int i=0;i<n;i++)
            if(BIT(mask,i))   z=s[n+i]+z;
            else              e=s[n+i]+e;
        ans+=w[mkp(z,e)];
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 87040
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        sc.close();
        int cnt = 0;
        for (int i = l; i <= r; i++) {
            if (i % d == 0) cnt++;
        }
       
        System.out.println(cnt);
    }
}



Measured memory_bytes: 35648
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = IR(5)
    k = II()
    if max(a) - min(a) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    a = IR(5)
    b = a[0]
    ans = 0
    for a_ in a:
        if a_ % 10 != 0:
            if b % 10> a_ % 10:
                b = a_
    flg = 0
    for a_ in a:
        if a_ != b or flg:
            ans += math.ceil(a_ / 10) * 10
        else:
            ans += b
            flg = 1
    print(ans)
            
    
    return

#C
def C():
    n = II()
    ai = IR(5)
    print(math.ceil(n / min(ai)) + 4)
        
        
    return

#D
def D():
    x, y, z, K = LI()
    a = LI()
    a.sort(reverse=True)
    b = LI()
    b.sort(reverse = True)
    c = LI()
    c.sort(reverse=True)
    ab = []
    for a_ in a:
        for b_ in b:
            ab.append(a_ + b_)
    ab.sort(reverse = True)
    ab = ab[:min(x * y, K)]
    ans = []
    for ab_ in ab:
        for c_ in c:
            ans.append(ab_ + c_)
    ans.sort(reverse = True)
    for k in range(K):
        print(ans[k])



        
                    

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()

Measured memory_bytes: 137048
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列

using namespace std;


int main()
{
	int n;
	cin >> n;

	vector<int> usCol(9, 0);

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;

		if (a > 3200) { a = 3200; }
		usCol[a / 400] += 1;
	}

	int ans = 0;

	for (int i = 0; i < 8; ++i) {
		if (usCol[i] != 0) {
			ans += 1;
		}
	}

	if (ans == 0 && usCol[8] != 0) {
		cout << 1 << flush;
	}
	else {
		cout << ans << flush;
	}

	cout << " " << flush;

	cout << ans + usCol[8] << 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;

int main() {
  int n;
  cin >> n;
  int count = 0;
  for(int i = 1; i <= n; i++) {
    string s = to_string(i);
    if((s.size())%2 == 1) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

using namespace std;

int main() {
	int n, a[100010], total = 0, ans[100010];

	cin >> n;

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

	a[0] = 0; //原点からスタートして
	a[n + 1] = 0; //原点で終了する

	for (int i = 0; i <= n; i++) {
		total += abs(a[i + 1] - a[i]);
	}

	for (int i = 1; i <= n; i++) {
		ans[i] = total + abs(a[i + 1] - a[i - 1]) - (abs(a[i + 1] - a[i]) + abs(a[i - 1] - a[i]));
	}

	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
import sys


def resolve(in_):
    N = int(next(in_))
    A = tuple(map(int, next(in_).split()))

    stool = 0
    height = A[0]
    for h in A[1:]:
        if height <= h:
            height = h
        else:
            stool += height - h

    return stool

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32996
#include<bits/stdc++.h>
using namespace std;
using l1 = long long;

int main(){
    l1 X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    l1 straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if(K % 2 == 0){
        cout << X << endl;

    }else{
        cout << D - X << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct robot{
    ll x,l;
}s[100050];
bool cmp(robot a,robot b){
    return a.x<b.x;
}
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&s[i].x,&s[i].l);
    sort(s,s+n,cmp);
    ll mx=s[0].x+s[0].l;
    for(int i=1;i<n;i++){
        if(s[i].x-s[i].l<mx){
            ans++;
            mx=min(mx,s[i].x+s[i].l);
        }else mx=s[i].x+s[i].l;
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 1792