akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

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

    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];

    int n2d = 0, n4d = 0, rest = 0;
    REP(i,N) {        
        if (a[i] % 4 == 0) n4d++;
        else if (a[i]%2 == 0) n2d++;
        else rest++;
    }

    string ans = "No";
    if (n2d == 0) {
        if (rest <= n4d + 1) ans = "Yes";
    } else {
        if (rest <= n4d) ans = "Yes";
    }        
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

S = sum(p[:K])
maxS = S
for i in range(1, N - K + 1):
    S = S - p[i - 1] + p[i + K - 1]
    maxS = max(maxS, S)

print((K + maxS) / 2)

Measured memory_bytes: 25188
k, s = map(int,input().split())

count = 0

if s > 3 * k:
    print(count)

else:
    for i in range(k + 1):
        x = i
        if x < s:
            for j in range(k + 1):
                y = j
                if s - (x + y) <= k and x + y <= s:
                    count = count + 1
                elif x + y > s:
                    break
        elif x == s:
            count = count + 1
        else:
            break

print(count)


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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    rep(i, N){
        int num;
        cin >> num;
        if(num % 2 == 0) A.push_back(num);
    }
    for(int num: A){
        if(num % 3 != 0 && num % 5 != 0){
            cout << "DENIED" <<endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  int bit = (1 << m) - 1;
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    int curr = 0;
    while (k--) {
      int a; cin >> a, --a;
      curr |= 1 << a;
    }
    bit &= curr;
  }
  cout << __builtin_popcount(bit) << '\n';
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       n: i32, 
    }
    println!("{}", n / 3);
}


Measured memory_bytes: 4352
//    ____       ____                 _           
//   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___  
//   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
//   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
//   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/ 
//                                                

 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;



int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	ll sum1 = 0;
	ll sum2 = 0;
	ll ans = 0;
	
	repA(i,1,k-1)
	{
		sum1 = (sum1+n-i+1+MOD)%MOD;
		sum2 = (sum2+i-1)%MOD;
	}
	
	repA(i,k,n+1)
	{
		sum1 = (sum1+n-i+1+MOD)%MOD;
		sum2 = (sum2+i-1)%MOD;
		//db2(sum1,sum2);
		ans = (ans+sum1-sum2+1+MOD)%MOD;
	}
	printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  ll k, x;
  scanf("%lld %lld", &k, &x);

  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println((x / 3600) + ":" + (x % 3600 / 60) + ":" + (x % 60));
	}
}

Measured memory_bytes: 26180
#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <assert.h>
#include <bitset>
#include <string>
#include <cstdio>
#include <math.h>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
using namespace std;

#define int64 long long
#define mp make_pair
#ifdef _DEBUG
const int N = 2010;
#else
const int N = 2010;
#endif

const int MOD = 924844033;

int n, k, fact[N], chainNum, chainLens[N], chainTypes[N];
int f1[N][N][2], f2[N][N][2], dp[N][N];

void add(int &a, int b)
{
	a += b;
	if (a >= MOD) a -= MOD;
}

void mult(int &a, int b)
{
	a = (1ll * a * b) % MOD;
}

int product(int a, int b)
{
	return (1ll * a * b) % MOD;                                                                                                                                               
}

void calc1()
{
	memset(f1, 0, sizeof(f1));
	f1[1][0][0] = 1;
	f1[1][0][1] = 1;
	f1[1][1][0] = 2;
	f1[1][1][1] = 1;
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			f1[i][j][0] = f1[i][j][1] = f1[i - 1][j][0];
			if (j > 0) 
			{
				add(f1[i][j][0], f1[i - 1][j - 1][0]);
				add(f1[i][j][0], f1[i - 1][j - 1][1]);
				add(f1[i][j][1], f1[i - 1][j - 1][1]);
			}
		}
	}
	memset(f2, 0, sizeof(f2));
	f2[1][0][0] = 1;
	f2[1][0][1] = 1;
	f2[1][1][0] = 1;
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			f2[i][j][0] = f2[i][j][1] = f2[i - 1][j][0];
			if (j > 0) 
			{
				add(f2[i][j][0], f2[i - 1][j - 1][0]);
				add(f2[i][j][0], f2[i - 1][j - 1][1]);
				add(f2[i][j][1], f2[i - 1][j - 1][1]);
			}
		}
	}
}

int getVal(int len, int type, int bad)
{
	if (type == 0) return f1[len][bad][0];
	if (type == 1) return f2[len][bad][0];
	return f2[len][bad][1];
}

void calc2()
{
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 1; i <= chainNum; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			for (int k = 0; k <= min(j, chainLens[i]); k++)
			{
				add(dp[i][j], product(dp[i - 1][j - k], getVal(chainLens[i], chainTypes[i], k)));
			}
		}
	}
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> k;
	fact[0] = 1;
	for (int i = 1; i <= n; i++) fact[i] = product(fact[i - 1], i);
	calc1();
	chainNum = min(n, 2 * k);
	for (int i = 1; i <= chainNum; i++)
	{
		chainLens[i] = 0;
		int first = i;
		int last = i;
		int cur = i;
		while (cur <= n)
		{
			last = cur;
			chainLens[i]++;
			cur += 2 * k;
		}
		if (first - k > 0 && last + k <= n) chainTypes[i] = 0;
		else if (first - k <= 0 && last + k > n) chainTypes[i] = 2;
		else chainTypes[i] = 1;
	}
	calc2();
	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		int tmp = product(fact[n - i], dp[chainNum][i]);
		if (i & 1)
		{
			if (tmp != 0) tmp = MOD - tmp;
		}
		add(ans, tmp);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 79232
s = gets.chomp
p = gets.chomp

result = 'No'

if s.match(/#{p}/)
  result = 'Yes'
else
  i = 1
  while i < s.length
    p2 = p[i..-1]
    if p2 && s[0..(p2.length)-1] == p2 && s[(-1*i)..-1] == p[0..(i-1)]
      result = 'Yes'
      break
    end
    i += 1
  end
end

puts result

Measured memory_bytes: 6100
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int tmp=n;
		while(tmp>0) {
			tmp = tmp -1000;
		}
		System.out.println(-1*tmp);

	}
}

Measured memory_bytes: 35716
A, B, C, D, E, F = map(int, input().split())
max_a = int(3000 / (100 * A))
max_b = int(3000 / (100 * B))
max_c = int(3000 / C)
max_d = int(3000 / D)
max_dens = 0
max_sugar = 0
max_sugar_water = 0
for i in range(max_a + 1):
  water_A = 100 * A * i
  if water_A > F:
    break
  for j in range(max_b + 1):
    water = 100 * B * j + water_A
    if water > F:
      break
    max_solvable_sugar = E * water
    for s in range(max_c + 1):
      sugar_C = C * s
      if sugar_C * 100 > max_solvable_sugar:
        break
      for t in range(max_d + 1):
        sugar = D * t + sugar_C
        if sugar * 100 > max_solvable_sugar:
          break
        sugar_water = water + sugar
        if sugar_water > F or sugar_water == 0:
          break
        dens = 100 * sugar / sugar_water
        if dens >= max_dens:
          max_dens = dens
          max_sugar = sugar
          max_sugar_water = sugar_water
print("{} {}".format(max_sugar_water, max_sugar))

Measured memory_bytes: 74100
Program Main

    Implicit None

    Integer, Allocatable :: X(:),P(:)
    Integer(8)           :: i,j,N,dum

    N = 0
    Read(*,*) N
    Allocate (P(100)); P(:) = 100000
    Allocate (X(N)); X(:) = 0
    Read(*,*)(X(i),i=1,N)

    Do i = 1,100
       dum = 0
       Do j = 1,N
          dum = dum + (X(j) - i)**2
       Enddo
       P(i) = dum 
    Enddo

    Do i = 1,99
       Do j = i+1,100
          If (P(i) < P(j)) then
             dum  = P(i)
             P(i) = P(j)
             P(j) = dum
          Endif
       Enddo
    Enddo

    Write(*,"(I0)") P(100)

  End Program


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll dp[110][4][4][4];

int main()
{
	int n;
	cin >> n;
	dp[0][3][3][3] = 1;
	for(int i = 0; i < n; i++){
		for(int x1 = 0; x1 < 4; x1++){
			for(int x2 = 0; x2 < 4; x2++){
				for(int x3 = 0; x3 < 4; x3++){
					for(int k = 0; k < 4; k++){
						if(k == 1 && x1 == 2 && x2 == 0) continue;
						if(k == 1 && x1 == 0 && x2 == 2) continue;
						if(k == 2 && x1 == 1 && x2 == 0) continue;
						if(k == 1 && x1 == 2 && x3 == 0) continue;
						if(k == 1 && x2 == 2 && x3 == 0) continue;
						dp[i+1][x2][x1][k] += dp[i][x3][x2][x1];
						dp[i+1][x2][x1][k] %= MOD;
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int x1 = 0; x1 < 4; x1++){
		for(int x2 = 0; x2 < 4; x2++){
			for(int x3 = 0; x3 < 4; x3++){
				ans += dp[n][x3][x2][x1];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

void replaceAll(string &s,string from,string to){
	int pos=s.find(from);
	for(;pos!=string::npos;pos=s.find(from)){
		s.replace(pos,from.size(),to);
	}
}
void solve(){
	string s="";
	for(string::iterator it=str.begin();it!=str.end();it++){
		if((*it)=='('||(*it)==')'||(*it)=='['||(*it)==']')s+=(*it);
	}
	while(s!=""){
		string _s=s;
		if(s[0]==')'||s[0]==']')break;
		replaceAll(s,"()","");
		replaceAll(s,"[]","");
		if(s==_s)break;
	}
	if(s=="")cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}
int main(){
	while(getline(cin,str)&&str[0]!='.'){
		solve();
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long i, j, k;

struct SegtreeMin {
    long long n;
    long long inf;
    vector<long long> dat;

    void initialize(long long n_input, long long inf_input){
        inf = inf_input;
        n = 1;
        while(n < n_input)n <<= 1;
        dat.resize(2*n-1);
        for(int i = 0; i<2*n-1; i++) dat[i] = inf;
    }

    void update(long long k, long long a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = min(dat[2*k+1], dat[2*k+2]);
        }
    }

    long long min_between(long long a, long long b){
        return query(a, b+1, 0, 0, n);
    }

    long long query(long long a, long long b, long long k, long long l, long long r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b)return dat[k];
        long long vl = query(a, b, 2*k+1, l, (l+r)/2);
        long long vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

long long N;
long long P[200000];
long long INF = 1<<30;
SegtreeMin st[2];
long long pos[200001];
long long range_l[200001];
long long range_r[200001];
long long l, r, in_l, in_r, out_l, out_r, parity;

int main(){
    cin >> N;
    st[0].initialize(N, INF);
    st[1].initialize(N, INF);
    for(i=0; i<N; i++){
        cin >> P[i];
        pos[P[i]] = i;
        st[i%2].update(i, P[i]);
    }
    long long min = st[0].min_between(0, N-1);
    priority_queue<long long> pque;
    pque.push(-min);
    range_l[min] = 0;
    range_r[min] = N-1;
    vector<long long> ans = {};

    for(i=0; i<N/2; i++){
        l = -pque.top();
        pque.pop();
        out_l = range_l[l];
        out_r = range_r[l];
        in_l = pos[l];
        parity = in_l % 2;
        r = st[1-parity].min_between(in_l, out_r);
        in_r = pos[r];
        ans.push_back(l);
        ans.push_back(r);
        if(out_l != in_l){
            j = st[parity].min_between(out_l, in_l-1);
            pque.push(-j);
            range_l[j] = out_l;
            range_r[j] = in_l-1;
        }
        if(in_l != in_r-1){
            j = st[1-parity].min_between(in_l+1, in_r-1);
            pque.push(-j);
            range_l[j] = in_l+1;
            range_r[j] = in_r-1;
        }
        if(in_r != out_r){
            j = st[parity].min_between(in_r+1, out_r);
            pque.push(-j);
            range_l[j] = in_r+1;
            range_r[j] = out_r;
        }
    }
    for(i=0; i<N; i++){
        cout << ans[i] << " \n"[i==N-1];
    }
    return 0;
}

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

                                                                                                
  
int main(void){
                                                                                                
   
    long long n, i;

    long long a;

    long long *b;

    long long m = 0;
   
      
    scanf("%lld", &n );


    b = (long long *)malloc( sizeof( long long ) * ( 300030 ) );


    for( i = 0 ; i <= 3 * n ; i = i + 1 ){

         b[i] = 0;

         }        
   

    for( i = 0 ; i < n ; i = i + 1 ){

         scanf("%lld", &a );

         b[a] += 1;

         b[a + 1] += 1;

         if( a > 0 ) b[a - 1] += 1;         

         }


    for( i = 0 ; i <= 3 * n ; i = i + 1 ){

         if( b[i] > m ) m = b[i];

         }

 
    if( n == 1 ){

        printf("1\n");

        return 0;

        }



    printf("%lld\n", m );


    free(b);

    return 0;
                                                          
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int mid = n/2,near=n/2 -1;
  
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  cout << v.at(mid) - v.at(near) << endl;
}
  


Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
	int k, x;
	scanf("%d %d",&k,&x);
	int i = -1000000;
	int c = 1;
	while (i <= 1000000)
	{
		if(i>= x - k + 1 && i <= x + k -1)
		{
			if (k*2 - 1 == c)
				printf("%d\n",i);
			else
				printf("%d ",i);
			c++;
		}
		i++;
	}
	return(0);
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>m;
	pll v;
	rep(i,0,n){
		cin>>j>>k;
		v.pb(mp(j,k));
	}	
	sort(all(v));
	rep(i,0,n){
		if(m>v[i].S) ans+=v[i].F*v[i].S;
		else ans+=v[i].F*m;
		m-=min(m,v[i].S);
	}
	ret(ans)
	
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
using namespace std;

int main (void) {
  string S;
  int ans=700;
  cin >> S;
  for (int i=0; i<=2; i++) {
    if (S[i]=='o'){
      ans=ans+100;
    }
  }
  cout << ans;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int cnt4 = 0, cnt6 = 0;
    for (int i = 0; i < n; i++) {
        if (adj[i].size() & 1) {
            cout << "No" << endl;
            return 0;
        }
        if (adj[i].size() == 4) cnt4++;
        if (adj[i].size() == 6) cnt6++;
    }
    if (cnt6) {
        cout << "Yes" << endl;
        return 0;
    }
    if (cnt4 > 2) {
        cout << "Yes" << endl;
        return 0;
    }
    if (cnt4 < 2) {
        cout << "No" << endl;
        return 0;
    }

    int u = -1, v = -1;
    for (int i = 0; i < n; i++) {
        if (adj[i].size() == 4) {
            if (u == -1) {
                u = i;
            } else {
                v = i;
            }
        }
    }

    vector<bool> visited(n);

    bool ok = false;
    function<void(int, int)> dfs = [&](int a, int p) {
        visited[a] = true;
        for (int s : adj[a]) {
            if (s != p && s != u) {
                if (s == v) ok = true;
                if (!visited[s]) {
                    dfs(s, a);
                }
            }
        }
    };
    dfs(v, -1);
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 7680
///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl; 
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
// <=================================================================================================================================
// <=================================================================================================================================


void fun(){
    int n;cin>>n;
    if(n>=400 && n<=599){
        cout<<8;
    }else if(n>=600 && n<=799){
        cout<<7;
    }else if(n>=800 && n<=999){
        cout<<6;
    }else if(n>=1000 && n<=1199){
        cout<<5;
    }else if(n>=1200 && n<=1399){
        cout<<4;
    }else if(n>=1400 && n<=1599){
        cout<<3;
    }else if(n>=1600 && n<=1799){
        cout<<2;
    }else if(n>=1800 && n<=1999){
        cout<<1;
    }
}

signed  main() {
    lets_go

      int t;
      t=1;
// cin >> t;
    while (t--) {            
         fun();             
    }                        
                            
                            
    return 0;

}


Measured memory_bytes: 3640
N = (list(input()))
N =N[::-1]
N_int = [int(i) for i in N]
N_int.append(0)
maisu = 0
keta = False
for i in range(len(N_int)-1):
    if keta ==True:
        N_int[i] +=1
    if N_int[i]<5:
        maisu +=N_int[i]
        keta =False
    elif N_int[i]==5 :
        if N_int[i+1]>4:
            keta =True
            maisu +=(10-N_int[i])
        else:
            keta =False
            maisu += N_int[i]
    else:
        keta =True
        maisu +=(10-N_int[i])  
if keta ==True:
    maisu +=1
print(maisu)

Measured memory_bytes: 20836
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
const long long inf=6000000000000000000ll;
int Q,n,m,D,c[27],a[N][27],t[N],s[27],ans,i,j;
int main()
{
	scanf("%d",&D);
	for(i=1;i<=26;++i)
		scanf("%d",&c[i]);
	for(i=1;i<=D;++i)
		for(j=1;j<=26;++j)
			scanf("%d",&a[i][j]);
	for(i=1;i<=D;++i)
		scanf("%d",&t[i]);
	for(i=1;i<=D;++i)
	{
		for(j=1;j<=26;++j)
			++s[j];
		s[t[i]]=0;
		for(j=1;j<=26;++j)
			ans-=s[j]*c[j];
		ans+=a[i][t[i]];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3700
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  string s;cin>>s;
  rep(i,0,5){
    cout<<s[i];
  }
  cout<<" ";
  rep(i,6,13){
    cout<<s[i];
  }
  cout<<" ";
  rep(i,14,19){
    cout<<s[i];
  }
  cout<<endl;
}




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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, k;
int b[2001][2001], d[2001][2001];
int D;

int main(){
    cin >> n >> k;
    rep(i,n) {
        int x, y; char c;
        cin >> x >> y >> c;
        x = (x-(k-1)+2*k)%(2*k);
        y = (y-(k-1)+2*k)%(2*k);
        if (c == 'W') {
            D++;
            if (x <= k && y <= k) {
                d[x][y]--; d[x+k][y]++; d[x][y+k]++; d[x+k][y+k]--;
            } else if (x <= k) {
                d[x][y]--; d[x+k][y]++; d[x][2*k]++; d[x+k][2*k]--;
                d[x][0]--; d[x+k][0]++; d[x][y-k]++; d[x+k][y-k]--;
            } else if (y <= k) {
                d[x][y]--; d[2*k][y]++; d[x][y+k]++; d[2*k][y+k]--;
                d[0][y]--; d[x-k][y]++; d[0][y+k]++; d[x-k][y+k]--;
            } else {
                d[x][y]--; d[2*k][y]++; d[x][2*k]++; d[2*k][2*k]--;
                d[x][0]--; d[2*k][0]++; d[x][y-k]++; d[2*k][y-k]--;
                d[0][y]--; d[x-k][y]++; d[0][2*k]++; d[x-k][2*k]--;
                d[0][0]--; d[x-k][0]++; d[0][y-k]++; d[x-k][y-k]--;
            }
        } else {
            if (x <= k && y <= k) {
                b[x][y]++; b[x+k][y]--; b[x][y+k]--; b[x+k][y+k]++;
            } else if (x <= k) {
                b[x][y]++; b[x+k][y]--; b[x][2*k]--; b[x+k][2*k]++;
                b[x][0]++; b[x+k][0]--; b[x][y-k]--; b[x+k][y-k]++;
            } else if (y <= k) {
                b[x][y]++; b[2*k][y]--; b[x][y+k]--; b[2*k][y+k]++;
                b[0][y]++; b[x-k][y]--; b[0][y+k]--; b[x-k][y+k]++;
            } else {
                b[x][y]++; b[2*k][y]--; b[x][2*k]--; b[2*k][2*k]++;
                b[x][0]++; b[2*k][0]--; b[x][y-k]--; b[2*k][y-k]++;
                b[0][y]++; b[x-k][y]--; b[0][2*k]--; b[x-k][2*k]++;
                b[0][0]++; b[x-k][0]--; b[0][y-k]--; b[x-k][y-k]++;
            }
        }
    }
    rep(i,2*k) for (int j = 1; j < 2*k; j++) {
        b[i][j] += b[i][j-1];
        d[i][j] += d[i][j-1];
    }
    for (int i = 1; i < 2*k; i++) rep(j,2*k) {
        b[i][j] += b[i-1][j];
        d[i][j] += d[i-1][j];
    }
    int ans = -n-1;
    rep(i,2*k) rep(j,2*k) {
        int tmp = b[i][j];
        int tmp2 = d[i][j];
        if (i-k >= 0) {
            if (j-k >= 0) {
                tmp += b[i-k][j-k];
                tmp2 += d[i-k][j-k];
            }
            if (j+k < 2*k) {
                tmp += b[i-k][j+k];
                tmp2 += d[i-k][j+k];
            }
        }
        if (i+k < 2*k) {
            if (j-k >= 0) {
                tmp += b[i+k][j-k];
                tmp2 += d[i+k][j-k];
            }
            if (j+k < 2*k) {
                tmp += b[i+k][j+k];
                tmp2 += d[i+k][j+k];
            }
        }
        tmp += D+tmp2;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}
































Measured memory_bytes: 31488
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100
#define MAX_W 10000

using namespace std;

int cost[9] = {2,5,5,4,5,6,3,7,6};

int n;
int nums[MAX_N];     //ソート済
int W;


int ddp[MAX_N][MAX_W + 1][MAX_N];
void sort(int *array, int left, int right);

int max(int left, int right) {
    return left > right ? left : right;
}

void array_copy(int *orig, int *copy, int left, int right) {
    for(int i = left; i < right; ++i)
        copy[i] = orig[i];
}

void print(int *array, int length) {
    for(int i = n - 1; i >= 0; --i)
        for(int j = 0; j < array[i]; ++j)
            printf("%i", nums[i]);
    printf("\n");
}

int cmp_value(int index, int *prev, int *cur, int cur_k) {
  
    int prev_sum = 0, cur_sum = cur_k;
    for(int i = index; i <= n; ++i) prev_sum += prev[i];
    for(int i = index + 1; i <= n; ++i) cur_sum += cur[i];
    if(prev_sum != cur_sum) return prev_sum - cur_sum;

    for(int i = n - 1; i >= index + 1; --i)
        if(prev[i] != cur[i])
            return prev[i] - cur[i];
    
    if(prev[index] != cur_k) return prev[index] - cur_k;
    return 0;
}

int main(int argc, char **argv) {
    scanf("%d", &W);
    scanf("%d", &n);

    for(int i = 0; i < n; ++i) {
        int tmp;
        scanf("%d", &tmp);
        nums[i] = tmp;
    }
    sort(nums, 0, n);

  
    for(int w = 1; w <= W; ++w)
        ddp[n][w][n] = -INF;    


    for(int index = n - 1; index >= 0; --index)
        for(int volume = 1; volume <= W; ++volume)
        {
            array_copy(ddp[index + 1][volume], ddp[index][volume], index + 1, n + 1);
            ddp[index][volume][index] = 0;
            for(int k = 1; true; ++k) {
                if(volume < cost[nums[index] - 1] * k) break;

                if(cmp_value(index, ddp[index][volume], ddp[index + 1][volume - k * cost[nums[index] - 1]], k) < 0) {
                    array_copy(ddp[index + 1][volume - k * cost[nums[index] - 1]], ddp[index][volume], index + 1
                        , n + 1);
                    ddp[index][volume][index] = k;
                }
            }
            
        }

    print(ddp[0][W], n);
}


int buf[10];
void sort(int *array, int left, int right) {
    right--;
    if(left < right)
    {
        int mid = (left + right) / 2;

        sort(array, left, mid + 1);
        sort(array, mid + 1, right + 1);

        //merge
        int left_len = mid - left + 1;
        int right_len = right - mid;

        int i_left = 0;
        int i_right = 0;


        for(int i = 0; i < left_len + right_len; ++i)
        {
            if (i_left < left_len &&
                (i_right >= right_len || array[left + i_left] <= array[mid + 1 + i_right]))
                buf[i] = array[left + i_left++];
            else if (i_right < right_len)
                buf[i] = array[mid + 1 + i_right++];
            else
                break;
        }

        for(int i = 0; i < left_len + right_len; ++i)
            array[left + i] = buf[i];
    }
}


Measured memory_bytes: 41088
#include<cstdio>
long long a,b,k;
main(){
	scanf("%lld%lld%lld",&k,&a,&b);
	if(k<=a)return puts("1"),0;
	else if(a<=b)return puts("-1"),0;
	else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll a[111],b[111],dp[111][111];

ll rec(int l,int r){
    if(dp[l][r]!=0)return dp[l][r];
    if(l==r)return 0;
    if(l+1==r)return dp[l][r]=a[l]*b[l]*a[r]*b[r];
    ll ret=longinf;
    REP(i,l,r){
        ret=min(rec(l,i)+rec(i+1,r)+a[l]*b[i]*a[i+1]*b[r],ret);
    }
    return dp[l][r]=ret;
}

int main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i]>>b[i];
    cout<<rec(0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 3168
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------- 
    n = int(input())
    s,t = input().split()
    ans = []
    for i in range(n):
        ans.append(s[i])
        ans.append(t[i])
    print("".join(ans))



if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5172
#include<cstdio>
#include<cctype>
#include<string>
#include<iostream>
using namespace std;


int sum = 0;
string s, t;
int a,b;

int main(void){
    while(1){
        cin >> s;
        if (s == "-") break;
        scanf("%d", &a);
        for (int i = 0; i < a; i++){
            scanf("%d", &b);
            t = s.substr(0, b);
            s.erase(0, b);
            s = s + t;
        }
        cout << s << endl;
    }
    return 0;
}

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

int main()
{
    int a,b,c,s,ans=0;
    cin>>a>>b>>c;
    s=(a+b+c)/2;
    ans=sqrt(s*(s-a)*(s-b)*(s-c));
    cout<<ans;

    return 0;
}


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

int main(){
  string O, E;
  cin >> O >> E;
  string P;
  for(int i=0; i<E.size(); i++){
    P.push_back(O.at(i));
    P.push_back(E.at(i));
  }
  if(O.size()!=E.size()) P.push_back(O.at(O.size()-1));
  cout << P << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int k;

int main(void){
	scanf("%d%d%d",&n,&m,&k);
	bool flag=false;
	for(int i=0;i<=n;i++){
		int cnt=m*i;
		for(int j=0;j<=m;j++){
			int cnt2=j*n;
			int cnt3=i*j;
			if((cnt+cnt2-cnt3*2)==k)flag=true;
		}
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include<string>
#include <numeric>
using namespace std;
int a[810];
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	int iwa = 0;
	int ans = 1000;
	rep(i, n) {
		cin >> a[i];
		iwa += a[i];
		if ((iwa / (i+1))<= ans) { ans = iwa / (i+1); }
	}
	cout << ans << endl;
}






Measured memory_bytes: 3124
#include<stdio.h>

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	
	if(a == b)
		printf("%d", c);
	else if(a == c)
		printf("%d", b);
	else 
		printf("%d", a);
		
	return 0;
}

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

int main(){
  int a;
  cin >> a;
  vector<double>N(a);
  for(int i=0; i<a; i++){
    cin >> N.at(i);
  }
  for(int i=0; i<a-1; i++){
    double A;
    sort(N.begin(), N.end());
    A=(N.at(0)+N.at(1))/2;
    reverse(N.begin(), N.end());
    N.pop_back();
    N.pop_back();
    N.push_back(A);
  }
  cout << N.at(0) << endl;
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,sum,ans;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<=s.size()-1;i++) 
		if(s[i]=='R')sum++;
	ans=sum;
	for(int i=0;i<=sum-1;i++) 
		if(s[i]=='R')
			ans--;
	cout<<ans;
}


Measured memory_bytes: 3764
#!/usr/bin/env python3
import string

N = int(input().split()[0])
a_list = list(string.ascii_lowercase)

amari_list = []
n = N
while n > 0:
    n -= 1
    amari = n % 26
    amari_list.append(a_list[amari])
    n = n // 26

ans = "".join(reversed(amari_list))

print(ans)


Measured memory_bytes: 9892
($n,$k) = split(' ', <>);


while (<>) {
    ($a,$b) =split(' ', $_);

    if (!$cnt{$a}) {
        push(@a, $a);
    }
    $cnt{$a} += $b;
}
@a = sort {$a <=> $b} @a;

for (@a) {
    $sum += $cnt{$_};
    if ($sum >= $k) {
        print "$_\n";
        exit;
    }
}


Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
bool check(vector<vector<int> > &v)
{
  bool c=true;
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)
    	if(v[i][j]!=0)
          c=false;
    if(c)
      return true;
    else
      c=true;
  }
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)
    	if(v[j][i]!=0)
          c=false;
    if(c)
      return true;
    else
      c=true;
  }
  if(v[1][1]==0 &&((v[0][0]==0 && v[2][2]==0)|| (v[0][2]==0 && v[2][0]==0)))
    return true;
  return false;
}
int main()
{
  vector<vector<int> > v(3,vector<int>(3));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>v[i][j];
  int n;cin>>n;
  int b;
  bool c;
  for(int i=0;i<n;i++)
  {
    cin>>b;
    for(int i=0;i<3;i++)
    {
      for(int j=0;j<3;j++)
        if(v[i][j]==b)
        {
          v[i][j]=0;
        }
    }
  }
  c=check(v);
  if(c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
      

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

int main(void) {
	char w[100];
	int count[26] = {0};
	scanf("%s", w);
	int len = strlen(w);
	for (int i = 0; i < len; ++i) {
		++count[w[i] - 97];
	}
	for (int i = 0; i < 26; ++i) {
		if (count[i] % 2 != 0) {
			printf("No");
			return 0;
		}
	}

	printf("Yes");

	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
maxA=max(A)
minA=min(A)
ans=0
Num=[0 for i in range(maxA-minA+1)]
nC2=[0 for i in range(maxA-minA+1)]
nC21=[0 for i in range(maxA-minA+1)]

for i in A:
    Num[i-minA]+=1

for i in range(maxA-minA+1):
    nC2[i]=(Num[i]*(Num[i]-1))//2
    ans+=nC2[i]
    if Num[i]!=0:
        nC21[i]=((Num[i]-1)*(Num[i]-2))//2

for i in range(N):
    print(ans-nC2[A[i]-minA]+nC21[A[i]-minA])

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x[5],y[5];
    cin>>x[1]>>y[1]>>x[2]>>y[2];
    x[3]=x[2]-(y[2]-y[1]);
    y[3]=y[2]+(x[2]-x[1]);
    x[4]=x[3]-(x[2]-x[1]);
    y[4]=y[3]-(y[2]-y[1]);
    cout<<x[3]<<" "<<y[3]
        <<" "<<x[4]<<" "<<y[4]<<endl;
    return 0;
}

Measured memory_bytes: 256
class SA
  attr_accessor :tube

  def initialize
    @tube = [ ]
  end

  def insert obj
    b = 0
    e = @tube.length - 1

    if @tube.empty? or @tube[e] < obj
      @tube.push obj
      return
    elsif obj < @tube[b]
      @tube.unshift obj
      return
    end

    loop do
      c = b + (e - b) / 2
      case obj <=> @tube[c]
      when -1
        e = c - 1
      when 0
        @tube.insert(c, obj)
        break
      when +1
        b = c + 1
      end
      if e < b
        @tube.insert(b, obj)
        break
      end
    end
  end
end

def getline
  gets.split(/\s/).map(&:to_i)
end

x,y,z,k = getline
a = getline.sort
b = getline.sort
c = getline.sort

sa = SA.new

a.reverse_each do |ai|
  b.reverse_each do |bi|
    flag = true
    c.reverse_each do |ci|
      cake = ai + bi + ci
      if k <= sa.tube.length
        if sa.tube.first < cake
          sa.tube.shift
        else
          break
        end
      end
      sa.insert cake
      flag = false
    end
    break if flag
  end
end

for x in sa.tube.reverse_each
  p x
end


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
   
typedef long long lo;
   
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 233;
struct E {
  int nxt, to, w;
}e[N << 2];
int head[N], e_cnt = 0;
int all, root, n, a[N];
int f[N], sz[N], die[N];
inline void adde(int x, int y, int w) {
  e[++e_cnt] = (E) {head[x], y, w}; head[x] = e_cnt;
}

namespace solver {
  const int M = 1e7 + 233;
  struct R {
    int x, y; long long w;
  }r[M]; int r_cnt;
  int pre[N];
  inline void link(int x, int y, long long w) {
    // cout << x << " " << y << " " << w << "\n";
    r[++r_cnt] = (R) {x, y, w}; 
  }
  inline int find(int x) {
    return pre[x] == x ? x : pre[x] = find(pre[x]);
  }
  long long doit() {
    rep (i, n) pre[i] = i;
    sort(r + 1, r + r_cnt + 1, [](R a, R b) {return a.w < b.w;});
    long long ans = 0;
    rep (i, r_cnt)
      if (find(r[i].x) != find(r[i].y)) {
	pre[find(r[i].x)] = find(r[i].y);
	ans += r[i].w;
      }
    return ans;
  }
}

inline void frt(int u, int fat) {
  sz[u] = 1; f[u] = 0;
  travel (i, u) {
    int v = e[i].to;
    if (!die[v] && v != fat) {
      frt(v, u);
      sz[u] += sz[v];
      f[u] = max(f[u], sz[v]);
    }
  }
  f[u] = max(f[u], all - sz[u]);
  if (!root || f[root] > f[u]) root = u;
}

inline int fsz(int u, int fat) {
  int sz = 1;
  travel (i, u) {
    int v = e[i].to;
    if (!die[v] && v != fat) {
      sz += fsz(v, u);
    }
  }
  return sz;
}

vector < pair <long long, int> > vec;

inline void dfs(int u, int fat, long long d) {
  vec.push_back(make_pair(d + a[u], u));
  travel (i, u) {
    int v = e[i].to;
    if (!die[v] && v != fat) {
      dfs(v, u, d + e[i].w);
    }
  }
}

inline void work(int u) {
  vec.clear();
  dfs(u, 0, 0);
  sort(vec.begin(), vec.end());
  // cout << u << "\n";
  // for (auto i : vec)
  //   cout << i.first << " " << i.second << "\n";
  // cout << "-0-\n";
  for (int i = 1; i < vec.size(); i++) {
    solver::link(vec[0].second, vec[i].second, vec[0].first + vec[i].first);
  }
}

inline void divide(int u, int fat) {
  // cout << u << " " << fat << "\n";
  work(u); die[u] = true;
  travel (i, u) {
    int v = e[i].to;
    if (v != fat && !die[v]) {
      all = fsz(v, u);
      frt(v, root = 0);
      divide(root, u);
    }
  }
}

int main(void) {
  read(n);
  rep (i, n) read(a[i]);
  rep (i, n - 1) {
    int x, y, w; read(x); read(y); read(w);
    adde(x, y, w); adde(y, x, w);
  }
  all = n; frt(1, root = 0);
  divide(root, 0);
  cout << solver::doit() << "\n";
}


Measured memory_bytes: 74476
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
        int k = s.nextInt();
      int [] p = new int[n];
      
      for(int i=0; i<n; i++ ) 
         p[i] = s.nextInt();
           Arrays.sort(p);
           int sum=0;
	    for(int i=0;i<k;i++)
	    sum+=p[i];
	    System.out.println(sum);
	
}
}


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

#def height(x, y, h, cx, cz):

def city_dist(x1, y1, x2, y2):
    return(abs(x1-x2)+abs(y1-y2))

def height(x1, y1, cx, cy, H):
    return max(H-city_dist(x1, y1, cx, cy), 0)

x = []
y = []
h = []
non_zero_index = -1

for i in range(N):
    line = [int(a) for a in input().split()]
    x.append(line[0])
    y.append(line[1])
    h.append(line[2])
    if line[2] != 0:
        non_zero_index = i


for cx in range(101):
    for cy in range(101):
        H = h[non_zero_index] + city_dist(x[non_zero_index], y[non_zero_index], cx, cy)
        answer = True
        for i in range(N):
            #print(cx, cy, H, i, x[i], y[i], h[i], height(x[i], y[i], cx, cy, H))
            if h[i] != height(x[i], y[i], cx, cy, H):
                answer = False
                break
        if answer:
            print("{} {} {}".format(cx, cy, H))
            break            
    if answer:
        break


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 3005;
const ll mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    ll n, s, dp[N] = {0}, a, ans = 0;
    cin >> n >> s;
    for (int i=1; i<=n; i++) {
        cin >> a;
        if (a > s) continue;
        if (a == s) {
            (ans += i*(n-i+1)) %= mod;
            continue;
        }
        for (int j=s-a; j>=1; j--) {
            if (j == s-a) {
                (ans += dp[s-a]*(n-i+1)) %= mod;
            }
            (dp[j+a] += dp[j]) %= mod;
        }
        dp[a] += i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())

q, mod = divmod(n,111)

if mod == 0:
    print(q*111)
else:
    print((q+1)*111)



Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(ALL(A));

    double ans = 0, dev = 2;

    for (int i = N - 1; i > 0; --i)
    {
        ans += A[i] / dev;
        dev *= 2;
    }
    ans += (A[0] * 2) / dev;

    print(ans);

    return 0;
}

Measured memory_bytes: 256