akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	ll ans = 0;
	if(a+b >= 2*c){
		int minxy = min(x,y);
		ans += minxy*2*c;
		x -= minxy;
		y -= minxy;
	}
	else{
		ans = x*a + y*b;
		x = 0;
		y = 0;
	}
	if(x){
		if(a>=2*c){
			ans+= x*2*c;
		}
		else ans+=x*a;
	}
	else if(y){
		if(b>=2*c){
			ans+=y*2*c;
		}
		else ans+=y*b;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))

Median_1_i=N//2-1
Median_2_i=N//2

X_=X[:]
X_.sort(reverse=True)
Median_1=X_[Median_1_i]
Median_2=X_[Median_2_i]

for x in X:
    if x<Median_1:
        print(Median_1)
    else:
        print(Median_2)

Measured memory_bytes: 26016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = 1;

		for (int i = 0; i < n; i++) {
			if (i == 0) {
				ans *= k;
			} else {
				ans *= (k - 1);
			}
		}

		System.out.print(ans);
	}
}

Measured memory_bytes: 22356
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cost = 0;
		if (a >= 13) {
			cost = b;
		} else if (a >= 6 && a <= 12) {
			cost = b /2;
		} else {
			cost = 0;
		}
		System.out.println(cost);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2)
    cout<<s[i];
  cout<<endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 760
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W,K;
string C[6];

LL ans = 0;

void solve(){
	//yの下位ibit目が目が立っているときi行目を選んでいる
	for(int y=0;y<(1<<H);y++){
		for(int x=0;x<(1<<W);x++){
			LL numof_black = 0;
			for(int i=0;i<H;i++){
				if((y>>i)&1) continue;
				for(int j=0;j<W;j++){
					if(C[i][j]=='#' && !((x>>j)&1)) numof_black++;
				}
			}
			if(numof_black==K) ans++;
		}
	}
}

int main(){
    cin >> H >> W >> K;
    for(int i=0;i<H;i++){
    	cin >> C[i];
    }

    solve();

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

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

int main()
{
    string S;
    cin >> S;
    bool flg = false;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == S[i + 1])
        {
            flg = true;
        }
    }
    if (flg)
    {
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main(){
     int N,Y;
     int x=-1;
     int y=-1;
     int z=-1;
     cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            int k=N-i-j;
            if(10000*i+5000*j+1000*k==Y){
                x=i;y=j;z=k;
            }
        }
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
 }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
using System.Reflection;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] dp = new int[n + 1];
            dp[0] = 1;
            dp[1] = 1;
            for (int i = 2; i <= n; i++)
            {
                dp[i] = dp[i - 1] + dp[i - 2];
            }
            WriteLine(dp[n]);
        }
    }
}


Measured memory_bytes: 17932
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()


int main(){
  int n,c=0,mini=1000000;
  cin >> n;
  for(int k=1;k<=n/2+1;k++){
    c=0;
    int keta = log10(k)+1;int tmp = k;
    //printf("keta:%d\n",keta);
    int num[keta];
    for(int i=0;i<keta;i++){
       num[i]=tmp%10;
       tmp = (tmp-num[i])/10;
    }
    for(int i=0;i<keta;i++)c+=num[i];

    int keta2 = log10(n-k)+1;int tmp2 = n-k;
    //printf("keta:%d\n",keta);
    int num2[keta2];
    for(int i=0;i<keta2;i++){
       num2[i]=tmp2%10;
       tmp2 = (tmp2-num2[i])/10;
    }
    for(int i=0;i<keta2;i++)c+=num2[i];
    mini=min(c,mini);
  }
  cout << mini;
}

Measured memory_bytes: 512
l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def root(x):
  if p[x]<0:return x
  p[x]=root(p[x]);return p[x]
def union(x,y):
  x,y=root(x),root(y)
  if x==y: return
  p[x]+=p[y]
  p[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  union(a-1,b-1)
print(-min(p))

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

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

    vector<int> dp(n,0);
    vector<int>h(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

cout<<dp[n-1];
return 0;

}

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

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

int n;
void input() {
    cin >> n;
}

int A[505][505];
void calc() {
    int l = 0;
    while ((1 << l) < n) l++;
    for (int i = 0; i < l; i++) {
        vector<int> v[2];
        for (int j = 0; j < n; j++) {
            v[(j >> i) & 1].push_back(j + 1);
        }
        for (int j : v[0]) for (int k : v[1])
            A[j][k] = A[k][j] = i + 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << A[i][j] << ' ';
        }
        cout << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    calc();
    return 0;
}

Measured memory_bytes: 1536
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let n: Int = Int(split[0])!
let m: Int = Int(split[1])!

let input_line2: String = readLine()!
let split2: [String] = input_line2.components(separatedBy: " ") //ブランクで区切られている場合
var array: [Int] = []

for a in split2 {
    array.append(Int(a)!)
}

var ans = 0


var all = 0
for c in array {
    all += c
}

if all > n {
    ans = -1
} else {
    ans = n - all
}

print(ans)

Measured memory_bytes: 14564
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[2] * 10 + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    SCIN(str);
    bool flag1=false;
    bool flag2 = false;
    for(int a = 0;a < str.size();a++){
        if(str.at(a) == 'C'){
            flag1=true;
        }
        if(flag1 && str.at(a) == 'F'){
            flag2 = true;
        }
    }
    Yes(flag2);
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, q;
int a, b;
vector<int> g[202020];
LL cnt[202020];
int p, x;

int main(){
    cin >> n >> q;
    REP(i, n - 1){
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    REP(i, q){
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    queue<pair<int, int>> q;
    q.push(make_pair(0, -1));
    while(!q.empty()){
        int cur = q.front().first;
        int pre = q.front().second;
        q.pop();
        REP(i, (int)g[cur].size()){
            if(g[cur][i] == pre)continue;
            cnt[g[cur][i]] += cnt[cur];
            q.push(make_pair(g[cur][i], cur));
        }
    }
    REP(i, n){
        if(i)cout << " ";
        cout << cnt[i];
    }
    cout << endl;
}

Measured memory_bytes: 17140
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<class Monoid> struct SegmentTree {
    using func = function<Monoid(Monoid, Monoid)>;
    int n;
    Monoid ie;
    func f;
    vector<Monoid> node;

    SegmentTree(){};
    SegmentTree(int n, Monoid ie, func f) : n(n), ie(ie), f(f) {
        const int cn = n;
        n = 1; while(n < cn)  n *= 2;
        node.assign(2*n, ie);
    }

    void update(int i, Monoid x) {
        i += n;
        node[i] = x;
        while(i /= 2)  node[i] = f(node[2*i], node[2*i+1]);
    }

    // [l, r)
    Monoid query(int l, int r) {
        l = max(l, 0);  r = min(n, r);
        if(l >= r)  return ie;

        Monoid res = ie;
        for(l += n, r += n; l != r; l /= 2, r /= 2) {
            if(l % 2)  res = f(res, node[l++]);
            if(r % 2)  res = f(res, node[--r]);
        }
        return res;
    }

    Monoid operator[](int i) {
        assert(0 <= i && i < n);
        return node[i+n];
    }
};

void leave(string message) {
    cout << message << endl;
    exit(0);
}

int main() {
    lint n, m;
    cin >> n >> m;

    string s;
    cin >> s;

    SegmentTree<bool> can_reach(n+1, false, bit_or<bool>());
    can_reach.update(0, true);

    for(lint i=1; i<=n; i++) {
        if(s[i] == '1')  continue;
        can_reach.update(i, can_reach.query(i-m, i));
    }

    vector<lint> ans;
    lint node = n;
    while(node != 0) {
        for(lint next=node-m; next<=node; next++) {
            if(next == node)  leave("-1");
            if(next < 0)  continue;
            if(!can_reach[next])  continue;

            ans.push_back(node-next);
            node = next;
            break;
        }
    }

    reverse(begin(ans), end(ans));
    for(auto& e : ans)  cout << e << " \n"[&e == &ans.back()];
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200005];
ll res;
bool cmp(int x,int y){return x>y;}
int main()
{
	int n,f=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=2,j=1;i<=n;i++)
	{
		res+=a[j];
		if(f)f=0,j++;
		else f=1;
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

vector<int> r, g, w, res;
int x, y, a, b, c;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; i++){
        int cur;
        cin >> cur;
        r.pb(cur);
    }
    for (int i = 0; i < b; i++){
        int cur;
        cin >> cur;
        g.pb(cur);
    }
    for (int i = 0; i < c; i++){
        int cur;
        cin >> cur;
        w.pb(cur);
    }
    sort(all(r), greater<int>());
    sort(all(g), greater<int>());
    sort(all(w), greater<int>());
    for (int i = 0; i < x; i++){
        res.pb(r[i]);
    }
    for (int i = 0; i < y; i++){
        res.pb(g[i]);
    }
    sort(all(res));
    for (int i = 0; i < min(c, x + y) && w[i] > res[i]; i++){
        res[i] = w[i];
    }
    ll ans = 0;
    for (int i : res){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 2552
calc :: Int -> Int -> Int -> Int
calc a b c
  | a <= c && b <= c = a + b + c * 10
  | b <= a && c <= a = 10 * a + b + c
  | c <= b && a <= b = a + 10 * b + c

main = do
  [a,b,c] <- map read . words <$> getLine
  print $ calc a b c


Measured memory_bytes: 508
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2018-04-28	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=200050;
long long ans=0;
int n;
long long s[MAXN];
int main()
{
	long long cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		s[i]+=s[i-1];
	}
	sort(s+1,s+n+1);
	for(int i=1;i<=n+1;i++)
	{
		if(i==n+1||s[i]!=s[i-1])
		{
			if(s[i-1]==0) cnt++;
			ans+=(long long)cnt*(cnt-1)/2LL;;
			cnt=1;
		}
		else if(s[i]==s[i-1])
			cnt++;
	}
	printf("%lld",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[[0] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(h[b-1])
    road[b-1].append(h[a-1])
cnt=0
for i in range(n):
    if h[i]>max(road[i]):
        cnt+=1
print(cnt)



Measured memory_bytes: 25976
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string s,t;
  int a = 0;
  cin >> s >> t;
  a = s.size();
  rep(i,a){
    if(s[i] != t[i]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
  

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,f[1100000],w[1100000],k;
int main ()
{
	cin>>n>>k;
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
	}
	f[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j<=0) break;
			f[i]=min(f[i],f[i-j]+abs(w[i-j]-w[i]));
		}
	}	
	cout<<f[n];
}

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

int main(){
	int t,tg,a,ag;
	cin >> t >> tg >> a >> ag;
	
	while(t >0 && a >0){
		a -= tg;
		t -= ag;
	}
	
	if(a<=0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3636
using System;

public class p0014
{
	p0014(){
		string str;
		
		while((str = Console.ReadLine()) != null)
			Console.WriteLine("{0}", func(long.Parse(str)));
	}
	
	private long func(long d){
		long res = 0;
		
		for(long i = d; i < 600; i += d)
			res += (d*i*i);
		
		return res;
	}
	
	public static int Main(string[] args){
		new p0014();
		return 0;
	}
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
const int N = 25001,M = 1e9 + 7;
int n,m,k,a[N],ans,freq[N],dp[N][401],dp1[N][401];
int power(int base,int to){
	int ret = 1;
	while(to){
		if(to&1)ret = ret*1LL*base%M;
		to>>=1;
		base = base*1LL*base%M;
	}
	return ret;
}
void add(int &a,int b){
	a+=b;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d%d",&n,&k,&m);
	for(int i = 0;i < m;i++)scanf("%d",a + i);
	ans = (n - m + 1LL)*power(k,n - m)%M;
	bool dup = 0,good = 0;
	int has = 0;
	for(int i = 0;i < m;i++){
		if(i - k >= 0)has-=!--freq[a[i - k]];
		if(freq[a[i]]++)dup = 1;
		else has++;
		if(has == k)good = 1;
	}
	if(good)return printf("%d\n",ans),0;
	if(!dup){
		dp[0][0] = 1;
		for(int i = 1,s,e;i <= n;i++){
			s = 0,e = 0;
			for(int j = k - 1;j > 0;j--){
				add(s,dp[i - 1][j]);
				add(e,dp1[i - 1][j]);
				add(dp[i][j],dp[i - 1][j - 1]*1LL*(k - j + 1)%M);
				add(dp1[i][j],dp1[i - 1][j - 1]*1LL*(k - j + 1)%M);
				add(dp[i][j],s);
				add(dp1[i][j],e);
				if(j >= m)add(dp1[i][j],dp[i][j]);
			}
		}
		int temp = 0,a = 1,b = 1;
		for(int i = 1;i < k;i++)add(temp,dp1[n][i]);
		for(int i = 1;i <= k;i++)a = a*1LL*i%M;
		for(int i = 1;i <= k - m;i++)b = b*1LL*i%M;
		temp = temp*1LL*b%M;
		temp = temp*1LL*power(a,M - 2)%M;
		add(ans,-temp);
		printf("%d\n",ans);
	}
	else{
		int l = 0,r = 0;
		memset(freq,0,sizeof freq);
		for(int i = 0;i < m;i++)
			if(freq[a[i]]++)break;
			else l++;
		memset(freq,0,sizeof freq);
		for(int i = m - 1;i > -1;i--)
			if(freq[a[i]]++)break;
			else r++;
		dp[0][l] = dp1[0][r] = 1;
		for(int i = 0;i < n;i++){
			int s = 0,e = 0;
			for(int j = k - 1;j > 0;j--){
				add(s,dp[i][j]);
				add(e,dp1[i][j]);
				add(dp[i + 1][j + 1],dp[i][j]*1LL*(k - j)%M);
				add(dp[i + 1][j],s);
				add(dp1[i + 1][j + 1],dp1[i][j]*1LL*(k - j)%M);
				add(dp1[i + 1][j],e);
			}
		}
		for(int i = 0,s,e;i < n - m + 1;i++){
			s = 0,e = 0;
			for(int j = 1;j < k;j++)
				add(s,dp[i][j]),
				add(e,dp1[n - m - i][j]);
			add(ans,-s*1LL*e%M);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 78720
import sys
from itertools import product


read = sys.stdin.readline
X, Y, Z, K = map(int, read().split())
lst_A = list(map(int, read().split()))
lst_B = list(map(int, read().split()))
lst_C = list(map(int, read().split()))


lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
lst_C_K = lst_C[:K]


lst_AB = sorted([a+b for a, b in product(lst_A, lst_B)], reverse=True)
lst_AB_K = lst_AB[:K]


lst_ABC = sorted([ab+c for ab, c in product(lst_AB_K, lst_C_K)], reverse=True)
lst_ABC_K = lst_ABC[:K]


print(*lst_ABC_K, sep="\n")


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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
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>;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n , x;
   cin >> x >> n;
   map<int , int> mark;
   for(int i = 0 ; i < n ; ++i){
      int r;
      cin >> r;
      mark[r] = 1;
   }
   int best = inf , rs = -1;
   for(int i= -100 ; i < 200 ; ++i){
      if(mark[i])continue;
      if(abs(x - i) < best){
         best = abs(x - i);
         rs = i;
      }
   }
   cout << rs << "\n";
}


Measured memory_bytes: 3672
import itertools
N = int(input())
P = [ int(i) for i in input().split()]
Q = [ int(i) for i in input().split()]

i = 0
p, q = 0, 0
for v in itertools.permutations(range(1,N+1)):
    if P == list(v):
        p = i
    if Q == list(v):
        q = i
    i += 1

print(abs(p-q))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var abcd = ReadIntArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];
            Console.WriteLine(Math.Max(a * b, c * d));
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

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

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0; 
}


Measured memory_bytes: 256
using System;

namespace MyTest
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			double N = double.Parse(Console.ReadLine());
			int oddCount = 0;

			for (int i = 1; i <= N; i++)
			{
				if (i % 2 == 1)
				{
					oddCount++;
				}
			}

			double ret = oddCount / N;
			Console.Write(ret);
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, m;
	cin >> n >> m;
	int a[n], b[n];
	vector<pair<int, int>> shops(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
		shops[i] = make_pair(a[i], b[i]);
	}
	SORT(shops);
	ll sum = 0;
	int cnt = 0;
	rep(i, n){
		if(shops[i].second + cnt <= m){
			sum += (ll) shops[i].first * shops[i].second;
			cnt += shops[i].second;
		}
		else {
			sum += (ll) shops[i].first * (m - cnt);
			break;
		}
	}
	cout << sum << endl;

	return 0;
}


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


using namespace std;

int INF = 1 << 16;

int N, A, B, C;
vector<int> l;
int min(int a, int b)
{
    if (a < b) {
        return a;
    }
    else {
        return b;
    }
}

int rec(int i, int a, int b, int c)
{
    if (i == N) {
        if (!a || !b || !c) {
            return INF;
        }
        return abs(a-A) + abs(b-B) + abs(c-C);
    }

    int res = rec(i+1, a, b, c);
    res = min(res, rec(i+1, a + l[i], b, c) + (a ? 10 : 0));
    res = min(res, rec(i+1, a, b + l[i], c) + (b ? 10 : 0));
    res = min(res, rec(i+1, a ,b, c + l[i]) + (c ? 10 : 0));

    return res;
}

int main()
{
    //vector<int> v;

    cin >> N >> A >> B >> C;

    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }

    int res = rec(0, 0, 0, 0);
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t,ans="";
    cin>>s>>t;
    int flag=0;
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    std::deque<string> words;
    for (int i=0;i+t.size()<=s.size();i++) {
        ans="";
        string tmp=s.substr(i,t.size());
        flag=0;
        for (int j=0;j<t.size();j++) {
            if (tmp[j]!='?'&&t[j]!=tmp[j]) {
                flag=1;
                break;
            }
        }
        if (flag==0) {
            for (int k=0;k<i;k++) {
                if (s[k]=='?') {
                    ans+='a';
                } else {
                    ans+=s[k];
                }
            }
            ans+=t;
            if (i+t.size()!=s.size()) {
                for (int l=i+t.size();l<s.size();l++) {
                    if (s[l]=='?') {
                        ans+='a';
                    } else {
                        ans+=s[l];
                    }
                }
            }
            reverse(ans.begin(),ans.end());
            words.emplace_back(ans);
        }
    }
    sort(words.begin(),words.end());
    if (words.size()!=0) {
        cout<<words[0]<<endl;
    } else {
        cout<<"UNRESTORABLE"<<endl;
    }
}


Measured memory_bytes: 256
from collections import deque

H,W  = [int(v) for v in input().split()]
S = ['#'+input()+'#' for _ in range(H)]
S.insert(0,"#"*(W+2))
S.append("#"*(W+2))

ans = 0

for y in range(1,H+1):
    for x in range(1,W+1):
        if S[y][x] == "#": continue
        queue = deque([[x,y,0]])
        visited = [[False] * (W+2) for _ in range(H+2)]
        visited[y][x] = True

        while queue:
            x,y,c = queue.pop()
            for ny,nx in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
                if visited[ny][nx] or S[ny][nx] == '#': continue
                visited[ny][nx] = True
                queue.appendleft([nx,ny,c+1])
            ans = max(ans,c)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;

int main(){
    int n;
    cin>>n;
    ll ans;
    ll x= (n/500)*1000;
    ans = x+((n%500)/5)*5;
    cout<<ans<<nl;
  return 0;
}

Measured memory_bytes: 3584
def main():
    a, b, c, k = map(int, input().split())
    ans = 0

    if k > a:
        ans = a
        k = k-a
    else:
        ans = k
        k = k-a
    # print(ans)
    if k > 0:
        k = k-b
        # print(ans)
        if k > 0:
            ans = ans-k

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
N = int(input())

xuList = []
for i in range(N):
    x, u = input().split()
    x = float(x)
    xuList.append((x,u))

BTCRate = 380000.0

result = 0
for x, u in xuList:
    if u == 'JPY':
        result += x
    else:
        result += (BTCRate * x)

print(result)

Measured memory_bytes: 3060
N, M = map(int, input().split())
H = list(map(int, input().split()))
load_list = []
for m in range(M):
    A, B = map(int, input().split())
    load_list.append((A, B))

highest_list = []
for i in range(N):
    highest_list.append(1)

for m in range(M):
    if H[load_list[m][0] - 1] > H[load_list[m][1] - 1]:
        highest_list[load_list[m][1] - 1] = 0
    elif H[load_list[m][1] - 1] > H[load_list[m][0] - 1]:
        highest_list[load_list[m][0] - 1] = 0
    else:
        highest_list[load_list[m][0] - 1] = 0
        highest_list[load_list[m][1] - 1] = 0

print(highest_list.count(1))

Measured memory_bytes: 27260
#include <bits/stdc++.h>
using namespace std;
int a[100003];
int main()
{ 
    int n;  
   cin >> n;    
   while (n--) 
  {        
      int x;       
      cin >> x;        
      a[x]++;
      a[x + 1]++;       
      a[x+ 2]++;    
  }   
     cout << *max_element(a + 2, a + 100000) << endl;  
  return 0;
}

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

int main() {
  int N; cin >> N;
  
  vector<int> t(N+1, 0), x(N+1, 0), y(N+1, 0);
  for (int i = 1; i < N+1; i++) cin >> t[i] >> x[i] >> y[i];
  
  bool can = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i+1]-t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}
     
  


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
int main(){
    char str1[55];
    char str2[55];
    char ans[120];
    scanf("%s",str1);
    scanf("%s",str2);
    int cnt = 1;
    int len1 = strlen(str1);
    for(int i=0;i<len1;i++){
        ans[cnt] = str1[i];
        cnt+=2;
    }
    int len2=strlen(str2);
    cnt = 2;
    for(int i=0;i<len2;i++){
        ans[cnt] = str2[i];
        cnt+=2;
    }
    for(int i=1;i<=len1+len2;i++){
        printf("%c",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 128
n = gets.to_i
h = Array.new(n + 1)
m = Array.new(n + 1){Array.new(n + 1){0}}
1.upto n do |i|
	h[i - 1], h[i] = gets.split.map(&:to_i)
end

2.upto n do |l|
	1.upto n - l + 1 do |i|
		j = i + l - 1
		m[i][j] = Float::INFINITY
		i.upto j - 1 do |k|
			m[i][j] = [m[i][j], m[i][k] + m[j][k] + m[k + 1][j] + h[i - 1] * h[k] * h[j]].min
		end
	end
end

puts m[1][n]

Measured memory_bytes: 8880
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

long calc(long x) {
	if (x % 2 == 1) {
		return ((x + 1) / 2) % 2;
	}
	else {
		return (((x / 2) % 2) ^ x);
	}
}

int main(void)
{
	long A, B, ans;
	cin >> A >> B;

	if (A > 0) {
		A = A - 1;
	}

	ans = ((calc(A)) ^ (calc(B)));

	cout << ans << endl;

	return 0;
}




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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>p(m),y(m);
	vector<vector<int>>v(n);
	for(int i=0;i<m;++i){
		cin>>p.at(i)>>y.at(i);
		v.at(p.at(i)-1).emplace_back(y.at(i));
	}
	for(int i=0;i<n;++i){
		sort(v.at(i).begin(),v.at(i).end());
	}
	for(int i=0;i<m;++i){
		cout<<setfill('0')<<setw(6)<<p.at(i)<<setfill('0')<<setw(6)<<lower_bound(v.at(p.at(i)-1).begin(),v.at(p.at(i)-1).end(),y.at(i))-v.at(p.at(i)-1).begin()+1<<"\n"s;
	}
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}

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

  if (a <= c && c <= b) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    boolean answer = false;
    if(N%2==0){
      for(int i = 0;i<N/2;i++){
        if(S.charAt(i)==S.charAt(i+N/2)){
          if(i==N/2-1){
            answer = true;
          }
        }else{
          break;
        }
      }
    }
    if(answer){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
const ll MAX = 510000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
using namespace std;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> a(N+10,1); //累積積
    rep1(i,N+5) a[i+1] = (a[i]*(M-1))%MOD;
    COMinit();
    ll ans = 0;
    rep1(i, K+1){
        ans += ((M*a[N-1-i]%MOD)*COM(N-1,i))%MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

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

using namespace std;

int A;
int B;
int C;
int X;


int bfs(int n, int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0) return 0;
    if (n == 0) return 1;
    return bfs(n - 500, a - 1, b, c) + bfs(n - 100, a, b - 1, c) + bfs(n - 50, a, b, c - 1);
}


void solve() {
    int num = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500 * i + 100 * j + 50 * k == X) {
                    num++;
                }
            }
        }
    }
    printf("%d\n", num);
}

int main() {
    cin >> A >> B >> C >> X;
    solve();
    return 0;
}

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

int main() {
	int num, K;
    cin >> num >> K;
    
    int ans = 0;
    for (int i = 0; i < num; i++){
    	int p;
        cin >> p;
        int a = p - 0;
        int b = p - K;
        
        if(a < 0) a = -a;
        if(b < 0) b = -b;
        
        if(a < b) {
			ans += (a * 2);        	
        } else {
        	ans += (b * 2);
        }        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int dp[100005];
int n, m;
vector<int>adj[100005];

int func(int i)
{
    if(dp[i]!=-1) return dp[i];
    if(adj[i].size()==0) return 0;
    int ans=0;
    for(int j=0; j<adj[i].size(); j++) {
        ans=max(ans, 1+func(adj[i][j]));
    }
    dp[i]=ans;
    return dp[i];
}

main()
{
    fastio;
    int ans=0;
    cin>>n>>m;
    for(int i=0; i<m; i++) {
        int x, y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));
    for(int i=1; i<=n; i++) ans=max(ans, func(i));
    cout<<ans;
}


Measured memory_bytes: 8576
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    System.out.println(S.equals("Sunny") ? "Cloudy" : S.equals("Cloudy") ? "Rainy" : "Sunny");
  }
}


Measured memory_bytes: 26588
n=list(input())
k=int(input())
if len(n)==1 and n[0]=='1':
  print('1')
else:
  one_list=[]
  while len(n)!=0:
    if n[0]=='1':
      one_list.append(n.pop(0))
    else:
      break
  if k<=len(one_list):
    print('1')
  else:
    print(n[0])



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 105
using namespace std;
typedef long long ll;
ll f(ll x){
  ll res = 0;
  for(ll i = x / 4 * 4;i <= x;i++) res = res ^ i;
  return res;
}
int main(){
  ll a,b;
  scanf("%lld%lld",&a,&b);
  if(a == 0) a++;
  printf("%lld\n",f(b) ^ f(a - 1));
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){

    val (w,h,x,y) = readLine()!!.split(" ").map(String::toDouble)

    var way = 0

    if(x == w/2 && y == h/2){
        way = 1
    }

    val a1: Double = h / w
    val a2: Double = -h / w

    //if(w == a1*x || w == a2*x + h){
    //    way = 0
    //}

    //println("$a1,$a2")

    val ans:Double = w * h / 2

    println("$ans $way")
}

Measured memory_bytes: 36168
#include<string>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<iostream>
using namespace std;
const int N= 21;
int a[N],b[N],c[N];
int main(){
	int n;
	cin >>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<n;i++)
		cin >>c[i];
	int sum=0,t=a[1];
	for(int i=1;i<=n;i++){
		sum+=b[a[i]];
		if(a[i]-t==1){
			sum+=c[a[i-1]];
		}
		t=a[i];
	}
	cout<<sum<<endl;
	return 0;
} 
	
    


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
int X[200000];
int Y[200000];

int main(){
    cin>>N;
    rep(i,N) cin>>X[i];
    rep(i,N) Y[i]=X[i];

    sort(Y,Y+N);

    rep(i,N){
        int ans;
        if(X[i]<=Y[(N-1)/2]) ans=Y[N/2];
        else ans=Y[(N-1)/2];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
#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 Graph = vector<vector<int>>;
using ll = long long;


int main() {
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,k){
        ans+=p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include<boost/multiprecision/cpp_dec_float.hpp>
using namespace boost;
#define float_cpp multiprecision::cpp_dec_float_100

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

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

  int a;
  float_cpp b;
  cin>>a>>b;
  b *= 100;
  b *= a;
  cout<<int(b/100)<<'\n';
  return 0;
}

Measured memory_bytes: 3780
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	string a, b, c;
	cin >> a >> b >> c;
	YES(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]);
	please AC;
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;cin >>n;
	int m=n%10;
	if (m==3) cout <<"bon";
	else if (m==0 ||m==1 ||m==6 ||m==8) cout <<"pon";
	else cout <<"hon";
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3636
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long[] num;
	foreach (i; 0..S.length)
	{
		num ~= S[i..i+1].to!long;
	}
	long ans;
	foreach (i; 0..2^^(num.length-1))
	{
		long begin;
		auto x = num.dup;
		foreach (j; 0..num.length-1)
		{
			auto bit = 1LU << j;
			if (i & bit)
			{
				begin = j+1;
			}
			else
			{
				foreach (k; begin..j+1)
				{
					x[k] *= 10;
				}
			}
		}
		foreach (e; x)
			ans += e;
	}
	
	writeln(ans);
	stdout.flush();
	//readln();
}

Measured memory_bytes: 380