akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nk = in.readLineAsIntArray();
        final int N = nk[0];
        final int K = nk[1];

        long[] countByMod = new long[K];

        for (int i = 1; i <= N; i++) {
            countByMod[i % K]++;
        }

        long total = 0L;
        for (int i = 0; i < K; i++) {
            int ma = i;
            int mb = (K - ma) % K;
            int mc = (K - mb) % K;
            if ((ma + mc) % K == 0) {
                total += countByMod[ma] * countByMod[mb] * countByMod[mc];
            }
        }
        System.out.println(total);

    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

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

int N;
vector<int> a(100000);
vector<int> b(100000);

vector<vector<pair<int, int>>> g(100001);

map<pair<int, int>, int> ans;

int K;

void dfs(int idx = 1, int p_idx = -1, int p_color = 0){
    int color = 1;
    for(int i = 0; i < g[idx].size(); ++i){
        if(g[idx][i].second == p_idx) continue;
        if(color == p_color) color++;
        g[idx][i].first = color;
        ans[make_pair(idx, g[idx][i].second)] = color;
        dfs(g[idx][i].second, idx, color);
        color++;
    }
}

void solve(){
    for(int i = 1; i <= N - 1; ++i){
        g[a[i]].push_back(make_pair(0, b[i]));
        g[b[i]].push_back(make_pair(0, a[i]));
    }
    K = 1;
    for(int i = 1; i <= N; ++i){
        K = max(K, (int)g[i].size());
    }
    dfs();
    cout << K << endl;
    for(int i = 1; i <= N - 1; ++i){
        cout << ans[make_pair(a[i], b[i])] << endl;
    }
}
int main(){
    cin >> N;
    for(int i = 1; i <= N - 1; ++i){
        cin >> a[i] >> b[i];
    }
    solve();
    return 0;
}

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

int combination(int n, int r, int x){
    if (!r)
        return x ? 0 : 1;
    else if (x <= 0)
        return 0;

    int count = 0;
    for (int i = n; i; i--)
        count += combination(i - 1, r - 1, x - i);

    return count;
}

int main(void)
{
    int n, x;

    while (cin >> n >> x && !(n == 0 && x == 0))
        cout << combination(n, 3, x) << endl;

    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include<string.h>
#define pi acos(-1.0)
using namespace std;
int main()
{
   double a,b,h,m;
   cin>>a>>b>>h>>m;
   double angle1=m*6;
   double angle2=h*30+m/60.0*30;
   double angle=abs(angle1-angle2);
   double dis;
   if(angle==180)
   dis=a+b;
   else
   {
   if(angle>180)angle=360-angle;
    dis=sqrt(a*a+b*b-cos(angle/180*pi)*2*a*b);}
     printf("%.10lf\n",dis);
	return 0;
 } 

Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>

using lint = long long;

template <class T>
T gcd(T n, T m) {
    while (m != 0) {
        n %= m;
        std::swap(n, m);
    }
    return n;
}

template <class T>
T lcm(T n, T m) {
    return n / gcd(n, m) * m;
}

void fail() {
    std::cout << 0 << std::endl;
    std::exit(0);
}

int main() {
    int n;
    lint m;
    std::cin >> n >> m;

    std::vector<lint> xs(n);
    for (auto& x : xs) {
        std::cin >> x;
        x /= 2;
    }

    lint l = 1;
    for (auto x : xs) {
        l = lcm(l, x);
        if (l > m) fail();
    }

    for (auto x : xs) {
        if ((l / x) % 2 == 0) fail();
    }

    std::cout << (m + l) / (l * 2) << std::endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()
# 単位元とseg_funcを設定する
from fractions import gcd
class seg():
    def __init__(self,init_val):
        self.n=len(init_val)
        self.ide_ele=0 #単位元
        self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.seg_func(self.seg[2*i+1],self.seg[2*i+2])
    def seg_func(self,a,b):
        return a+b #0
        #return a*b #1
        #return gcd(a,b) #0
        #return max(a,b) #-1か-10**10 (十分小さいもの)
        #return min(a,b) #10**10 (十分大きいもの)
    def update(self,k,x):
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.seg_func(self.seg[k*2+1],self.seg[k*2+2])
    def query(self,p,q): #O(logN)
        if q<=p:return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        self.res=self.ide_ele
        while q-p>1:
            if p&1==0:
                self.res=self.seg_func(self.res,self.seg[p])
            if q&1==1:
                self.res=self.seg_func(self.res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:self.res=self.seg_func(self.res,self.seg[p])
        else:self.res=self.seg_func(self.seg_func(self.res,self.seg[p]),self.seg[q])
        return self.res

def main():
    n=int(input())
    A=list(map(int,input().split()))
    seg_A=seg(A)
    sum_a=sum(A)
    dp=[[0]*n for _ in range(n)]  #[i,j]をまとめるために必要なコストの最小値
    for length in range(2,n+1):
        for i in range(n-length+1):
            j=i+length-1 #右側
            res=10**20
            for k in range(i+1,j+1):#区間[i,k)と[k,j]に分ける
                res=min(res,dp[i][k-1]+dp[k][j])
            dp[i][j]=res+seg_A.query(i,j+1)
    print(dp[0][n-1])


if __name__=='__main__':
    main()

Measured memory_bytes: 80216
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, n;
string s;
void solve(){
    scanf("%d", &n);
    printf("%d\n", n *(1+n*(1+n)));
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

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

#define MAXN (310)

int n, m;
int a[MAXN][MAXN], cnt[MAXN];
bool vis[MAXN];

void getcnt(){
	memset(cnt, 0, sizeof(cnt));
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= m; ++ j){
			if(vis[a[i][j]]){
				++ cnt[a[i][j]];
				break;
			}
		}
	}
}

bool check(int x){
	for(int i = 1; i <= m; ++ i) vis[i] = true;
	
	int now = m;
	while(true){
		getcnt();
		bool flag = true;
		
		for(int i = 1; i <= m; ++ i){
			if(!vis[i]) continue;
			if(cnt[i] > x){
				flag = false;
				vis[i] = false;
				-- now;
			}
		}
		if(flag) return true;
		if(!now) return false;
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= m; ++ j){
			scanf("%d", &a[i][j]);
		}
	}
	int left = 1, right = n, ans = 0;
	while(left <= right){
		int mid = left + right >> 1;
		if(check(mid)){
			ans = mid;
			right = mid - 1;
		}
		else{
			left = mid + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *parent, *left, *right;
};

// These pointer adress is NULL until first store (root == NIL).
// NIL adress is permanently NULL for defining empty node.
Node *root, *NIL;

void myInsert(int k) {
	Node *y = NIL; // parent
	Node *x = root; // comparison
	Node *z; // insertion

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inOrderPrint(Node *n) {
	if (n == NIL) return;
	inOrderPrint(n->left);
	cout << " " << n->key;
	inOrderPrint(n->right);
}

void preOrderPrint(Node *n) {
	if (n == NIL) return;
	cout << " " << n->key;
	preOrderPrint(n->left);
	preOrderPrint(n->right);
}

int main() {
	int n, x;
	char com[7];
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> x;
			myInsert(x);
		}
		else if (com[0] == 'p') {
			inOrderPrint(root);
			cout << endl;
			preOrderPrint(root);
			cout << endl;
		}
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

class custom_less {
 public:
  bool operator()(const pair<int, int>& x, const pair<int, int>& y) {
    return x.second < y.second;
  }
};

int main(int argc, char* argv[]) {
  int N, M;
  vector<priority_queue<pair<int, int>, vector<pair<int, int>>, custom_less>>
      que_vec;
  set<int> delete_sports;
  vector<int> num_of_people;
  int ans = 1000;

  cin >> N >> M;

  que_vec.resize(N);
  num_of_people.resize(M);

  FOR(i, N) {
    for (int j = M - 1; j >= 0; j--) {
      int A;
      cin >> A;
      que_vec[i].push(make_pair(A - 1, j));
    }
  }

  FOR(j, M) {
    FOR(k, M)
    num_of_people[k] = 0;

    FOR(i, N) {
      while (delete_sports.find(que_vec[i].top().first) != delete_sports.end())
        que_vec[i].pop();

      num_of_people[que_vec[i].top().first]++;
    }

    auto it = max_element(num_of_people.begin(), num_of_people.end());
    if (*it < ans) ans = *it;
    delete_sports.insert(it - num_of_people.begin());
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    if (s[0] == 'S') cout << "Cloudy" << endl;
    if (s[0] == 'C') cout << "Rainy" << endl;
    if (s[0] == 'R') cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
int ps[30][4];
bool dp[100000000];
bool hyou[25][25];


bool hantei(int p, int i) {
	if ((1 << p) & i) return false;
	for(int j = 0; j < p; j++) {
		if(hyou[p][j] and ((1 << j) & i) == 0) return false;
	}
	return true;
}
int bitcount(int i) {
	int res = 0;
	for(int b = 0; b < N; b++) {
		if ((i >> b) & 1) res++;
	}
	return res;
}

int main() {
	
	while(cin >> N, N) {
		//int x, y, r, c;
		for(int i = 0; i < (1 << 24) ; i++) dp[i] = false;
		for(int n = 0; n < N; n++) {
			for(int i = 0; i < 4; i++) {
				cin >> ps[n][i] ;
			}
			for(int i = 0; i < n; i++) {
				int dx = ps[n][0] - ps[i][0];
				int dy = ps[n][1] - ps[i][1];
				int r1 = ps[n][2] + ps[i][2];
				
				if (dx * dx + dy * dy < r1 * r1) {
					hyou[n][i] = true;
				} else {
					hyou[n][i] = false;
				}
			}
		}
		dp[0] = true;
		int ans = 0;
		for(int i = 0; i < (1 << N); i++) {
			if (dp[i] == false) continue;
			for(int k1 = 0; k1 < N; k1 ++) {
				if(!hantei(k1, i)) continue;
				for(int k2 = k1 + 1; k2 < N; k2 ++) {
					if(!hantei(k2, i)) continue;
					if (ps[k1][3] == ps[k2][3]) dp[i | (1 << k1) | (1 << k2)] = true;
				}
			}
			ans = max(ans, bitcount(i));
			
		}
		cout << ans << endl;
	}
}
		
		


Measured memory_bytes: 19436
#include<stdio.h>
int main(void)
{
    int n,flg,j,i,a[1000];
	double b[1000],c[1000],d[1000];
	while(1){
	    scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
		    scanf("%d %lf %lf",&a[i],&b[i],&c[i]);
		}
		for(i=0;i<n;i++){
		    d[i]=b[i]*c[i];
		}
		for(i=0;i<n-1;i++){
		    for(j=i+1;j<n;j++){
			    if(a[i]==a[j]){
				    d[i]=d[i]+d[j];
					d[j]=0;
				}
			}
		}
		flg=0;
		for(i=0;i<n;i++){
		    if(d[i]>=1000000){
			    printf("%d\n",a[i]);
				flg=1;
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 2636
#include<stdio.h>

int min(int a, int b){
  if(a<b)return a;
  else return b;
}

int dp[2000000];
int DP[2000000];

int main(){
  int i,j,x;

  for(i=1;i<=1000000;i++){
   
    dp[i]=i;
    DP[i]=i;
    for(j=1;;j++){
      x=j*(j+1)*(j+2)/6;
      if(i-x<0)break;
      dp[i]=min(dp[i],dp[i-x]+1);
      if(x%2==1){
	DP[i]=min(DP[i],DP[i-x]+1);
      }
    }
  }


  while(1){
    scanf("%d",&x);
    if(x==0)break;
    printf("%d %d\n",dp[x],DP[x]);
  }
  return 0;
}

Measured memory_bytes: 10836
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (2'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global
ll a[N];
ll ans[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	ll n,k;
	cin >> n >> k;
	rep(i,0,n){
		cin >> a[i];
		ans[i] = a[i];
	}
	ll best = OOL;
	rep(i,0,n){
		ll sum = k*i;
		rep(j,0,n){
			sum += ans[j];
		}
		best = min(best,sum);
		rotate(a,a+1,a+n);
		rep(j,0,n){
			ans[j] = min(ans[j],a[j]);
		}
	}
	cout << best << endl;
	return 0;
}

Measured memory_bytes: 384
//
//  main.cpp
//  AOJ
//
//  Created by 佐々木勇星 on 2018/09/29.
//  Copyright © 2018年 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main(int argc, const char * argv[]) {
    int a,b;

    while(1){
        int flag = 0;

        cin >> a;
        cin >> b;
        if(a == 0 && b == 0) break;
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                    if(flag == 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                if(flag == 0){
                    flag = 1;
                }else{
                    flag = 0;
                }
        }
        cout << endl;
            if(b % 2 == 0){
                if(flag == 0){
                    flag = 1;
                }else{
                    flag = 0;
                }
            }
    }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3124
S = list(input())

odd = ["R", "U", "D"]
even = ["L", "U", "D"]
ans = "Yes"

for i, s in enumerate(S):
  if i%2==0 and s not in odd:
    ans = "No"
    break
  elif i%2==1 and s not in even:
    ans = "No"
    break

print(ans)

Measured memory_bytes: 9032
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[n-r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next(), m = next();
  fset(m);
  var ans = npr(m,n), k = -1;
  for(var i = 1; i <= n; i++){
    ans += k*mul(ncr(n,i),npr(m-i,n-i));
    k = -k;
  }
  ans = mput(ans);
  return mul(ans, npr(m,n));
}

Measured memory_bytes: 51948
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> Heap;

void Max_Heapify(int node)
{
	int l = node * 2;
	int r = node * 2 + 1;

	int largest;

	if (l < Heap.size())
	{
		if (Heap[node] < Heap[l])
		{
			largest = l;
		}
		else
		{
			largest = node;
		}
	}
	else
	{
		largest = node;
	}

	if (r < Heap.size())
	{
		if (Heap[largest] < Heap[r])
		{
			largest = r;
		}
	}

	if (largest != node)
	{
		swap(Heap[largest], Heap[node]);

		Max_Heapify(largest);
	}
}

int main()
{
	int N; scanf("%d", &N); Heap.push_back(0);

	int tmp;

	for (int i = 1; i <= N; i++)
	{
		scanf("%d", &tmp);

		Heap.push_back(tmp);
	}

	for (int i = N / 2; i >= 1; i--)
	{
		Max_Heapify(i);
	}

	for (int i = 1; i <= N; i++)
	{
		printf(" %d", Heap[i]);
	}

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

Measured memory_bytes: 4384
def five_h(x):
  count = 0
  count += int(x / 500) * 1000
  x -= int(x / 500) * 500
  count += int(x / 5) * 5
  return count

def main():
  x = int(input())
  count = 0
  
  if(x <= 10 ** 9 and x >= 0):
    if(isinstance(x, int)):
      count += five_h(x)
      print(count)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll calc_even(int n, const vector<ll> &a) {
    vector<vector<ll>> dp(3, vector<ll>(n+10, -LINF));
    dp[0][0] = a[0];
    dp[1][1] = a[1];

    rep(i,n) {
        if (i+2 < n) chmax(dp[0][i+2], dp[0][i] + a[i+2]);
        if (i+3 < n) chmax(dp[1][i+3], dp[0][i] + a[i+3]);
        if (i+2 < n) chmax(dp[1][i+2], dp[1][i] + a[i+2]);
    }

    return max(dp[0][n-2], dp[1][n-1]);
}

ll calc_odd(int n, const vector<ll> &a) {
    vector<vector<ll>> dp(3, vector<ll>(n+10, -LINF));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];

    rep(i,n) {
        if (i+2 < n && i+2 != n-1) chmax(dp[0][i+2], dp[0][i]+a[i+2]);
        if (i+3 < n) chmax(dp[1][i+3], dp[0][i]+a[i+3]);
        if (i+4 < n) chmax(dp[2][i+4], dp[0][i]+a[i+4]);
        if (i+2 < n) chmax(dp[1][i+2], dp[1][i]+a[i+2]);
        if (i+3 < n) chmax(dp[2][i+3], dp[1][i]+a[i+3]);
        if (i+2 < n) chmax(dp[2][i+2], dp[2][i]+a[i+2]);
    }

    return max({dp[0][n-3], dp[1][n-2], dp[2][n-1]});
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    if (n%2==0) {
        cout << calc_even(n,a) << '\n';
    }
    else {
        cout << calc_odd(n,a) << '\n';
    }

    return 0;
}

Measured memory_bytes: 11160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  char a[3];
  cin>>a[0]>>a[1]>>a[2];

if(a[0]==a[1]&&a[1]==a[2]){cout<<"No"<<endl;}  
  else {cout<<"Yes"<<endl;}


  
  
}


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

#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

template <typename T>
struct rmq {
    static const int INF = std::numeric_limits<int>::max() / 2;
    int n;
    std::vector<pair<T, int>> dat;
    rmq(vector<int> a) : n(a.size()) {
        for (n = 1; n < (int)a.size(); n <<= 1);
        dat.resize(2 * n);
        a.resize(n, -INF);
        for (int i = n; i < n + n; ++i) {
            dat[i] = make_pair(a[i - n], i - n);
        }
        for (int i = n - 1; i >= 1; --i) {
            dat[i] = std::min(dat[i * 2], dat[i * 2 + 1]); // todo
        }
    }
    pair<T, int> query(int v, int w, int l, int r) const {
        if (r <= l || w == 0) return make_pair(INF, -1); // todo
        if (r - l == w) return dat[v];
        int m = w / 2;
        return std::min(
            query(v * 2, m, l, std::min(r, m)), // todo
            query(v * 2 + 1, m, std::max<int>(0, l - m), r - m)); // todo
    }
    void update(int i, const T &x) {
        dat[i + n].first = x;
        i += n;
        for (; i != 1; i /= 2) dat[i / 2] = std::min(dat[i], dat[i ^ 1]); // todo
    }
    pair<T, int> query(int l, int r) { return query(1, n, l, r); }
};

int n;
vector<int> a;

bool solve() {
    ll s = accumulate(all(a), 0LL);
    if (s % (n*(n + 1) / 2)) {
        return false;
    }
    int times = s / (n*(n + 1) / 2);
    if (times > 300000) {
        return (rand() + getpid()) % 2;
    }
    
    vector<int> diff(n);
    for (int i = 0; i < n; i++) {
        diff[i] = a[(i + 1) % n] - a[i];
    }

    int a0 = a[0];
    rmq<int> rm(diff);
    for (int i = 0; i < min<ll>(times, 300000); i++) {
        int val, k;
        tie(val, k) = rm.query(0, n);
        rm.update(k, val + n);
        a0 -= (n - k) % n;
        // dump(a0);
        if (a0 == 0) break;
    }
    for (int i = 0; i < n; i++) {
        if (rm.query(i, i + 1).first != times) {
            return false;
        }
    }
    return true;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (cin >> n) {
        a.resize(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        cout << (solve() ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
bool palindrome(string s)
{
    int began = 0;
    int ends = s.size() -1;
    bool palindrome = true;
    while(began<=ends)
    {
        if(s[began]!=s[ends])
        {
            palindrome =  false;
            break;
        }
        began++;
        ends--;
    }
    return palindrome;
}
int main()
{
    string s, first, second;
    cin>>s;
    int len  = s.size() - 1;
    for(int i=0; i<=(len-1) /2; i++)
    {
        first =  first+ s[i];
    }
    for(int i = (len + 3) /2  ; i<=len ;i++)
    {
        second =  second + s[i];
    }
    bool left = palindrome(first);
    bool right = palindrome(second);
    bool all = palindrome(s);
    if(left  && right && all)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
S=sorted(s)
T=sorted(t,reverse=True)
for i in range(min(len(S),len(T))):
  if ord(S[i])<ord(T[i]):
    print('Yes')
    break
  elif ord(S[i])>ord(T[i]):
    print('No')
    break
else:
  if len(S)<len(T):
    print('Yes')
  else:
    print('No')

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

int main(){
        int n;
        int x;
        int icecream[10];

    while(cin >> n, n != 0){
            for(int i=0; i<10; i++) icecream[i] = 0;


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

            for(int i=0; i<10; i++){
                    if(icecream[i] == 0){
                            cout << "-" << endl;
                            continue;
                    }
                    for(int j=1; j<=icecream[i]; j++){
                            cout << "*";
                    }
                    cout << endl;
            }
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
const int mx = 301;
double dp[301][301][301] = {};

int main(){
  int n,d;
  scanf("%d", &n);
  int f[3] = {};
  for (int i =0; i < n; i++) {
    scanf("%d", &d);
    f[(d-1)]++;
  }
  for (int k = 0; k <= n; k++) {
    for (int j = 0; j <= n; j++) {
      for (int i = 0;i <= n; i++) {
        if(i + j + k > n) break;
        if(i + j + k == 0) continue;
        dp[i][j][k] = (float)n;
        if(i > 0) dp[i][j][k] += dp[i-1][j][k]*i;
        if(j > 0) dp[i][j][k] += dp[i+1][j-1][k]*j;
        if(k > 0) dp[i][j][k] += dp[i][j+1][k-1]*k;
        dp[i][j][k] /= (float)(i + j + k);
      }
    }
  }
  printf("%.13lf", dp[f[0]][f[1]][f[2]]);
  
  return 0;
}



Measured memory_bytes: 213120
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val c = IntArray(26) { Int.MAX_VALUE }
    for (i in 1..n) {
        for ((j, z) in count(readLine()!!).withIndex()) c[j] = Math.min(c[j], z)
    }
    for ((i, q) in c.withIndex()) print(('a' + i).toString().repeat(q))
    println()
}

fun count(s: String): IntArray {
    val res = IntArray(26)
    s.forEach { res[it - 'a']++ }
    return res
}

Measured memory_bytes: 28028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,k;
    cin >>n >> k;
    vector<int> l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    rep(i,k-1){
        l[0] += l[i + 1];
    }
    cout << l[0] << endl;
}

Measured memory_bytes: 256
K = int(input())

old = []
old = [i for i in range(1, 10)]

while K > len(old):
    new = []
    K -= len(old)
    for i in range(len(old)):
        tmp = old[i]
        l = tmp % 10
        if l != 0:
            new.append(tmp*10+l-1)
        new.append(tmp*10+l)
        if l != 9:
            new.append(tmp*10+l+1)
    old = new[:]



print(old[K-1])

Measured memory_bytes: 18480
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll f[2001001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll x, ll y, ll MOD)
{
 
 return (f[x+y]*((InverseEuler(f[x], MOD) * InverseEuler(f[y], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    f[0] = 1;
    for(ll i = 1 ; i <= 2001000 ; i++)
        f[i] = (f[i-1]*i)%mod;
    ll r1=nxtl(),c1=nxtl(),r2=nxtl(),c2=nxtl();
    ll test=0;
    test=(test+C(r2+1,c2,mod))%mod;
    test=(test+C(r2,c2+1,mod))%mod;
    test=(test+C(r1,c1,mod))%mod;
    test=(mod+test-C(r2+1,c1,mod))%mod;
    test=(mod+test-C(r1,c2+1,mod))%mod;
    cout<<test<<endl;


    

    return 0;   
}


 
 


Measured memory_bytes: 16508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    Cins(int, n, a);
    
    ll sum = 0;
    for(int x : a) sum += x;
    int ans = 0;
    for(int x : a){
        if(x*4*m >= sum) ans ++;
    }
    CoutYn(ans >= m);
}




Measured memory_bytes: 256
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
    	long n = s.nextLong();Character ar[] = {65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90};
    	int sum=0,p=0;
    	StringBuilder answer = new StringBuilder();
    	while (n > 0) {
    	    n--;
    	    answer.append((char) ('a' + n % 26));
    	    n /= 26;
    	}
    	System.out.println(answer.reverse());
    	
    	
    	
    	
    }	
}


Measured memory_bytes: 32816
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a>12){
    cout<<b;
  }else if(a<6){
    cout<<0;
  }else{
    cout<<b/2;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int w,h,n,x=0,y=0,i,nowx,nowy,dx,dy,sum=0;
	
	scanf("%d %d %d",&w,&h,&n);
	
	
	for(i=0;i<n;i++){
		if(x==0&&y==0){
		scanf("%d %d",&x,&y);
		nowx = x;
		nowy = y;
		}else{
		nowx = x;
		nowy = y;
		scanf("%d %d",&x,&y);
			if(nowx>x&&nowy<y || nowx<x&&nowy>y){
				dx=nowx - x;
				dy=nowy - y;
				if(dx<0){
					dx=-1*dx;
				}
				if(dy<0){
					dy=-1*dy;
				}
				
				sum += dx+dy;
				
			}else{
				dx=nowx - x;
				dy=nowy - y;
				if(dx<0){
					dx=-1*dx;
				}
				if(dy<0){
					dy=-1*dy;
				}
				if(dx>dy){
					sum += dx;
				}else if(dx<dy){
					sum += dy;
				}else{
					sum += dx;
				}
			}
		}
	}
	
	printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		
		double x1=sc.nextDouble();
		double y1=sc.nextDouble();
		double x2=sc.nextDouble();
		double y2=sc.nextDouble();
		
		double line;		
		double x;
		double y;
		
		x=x2-x1;
		y=y2-y1;
		
		line=Math.sqrt(x*x+y*y);
		
		System.out.println(line);
		
		sc.close();
	}

}



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

using namespace std;

const int MAXN = 1e5 + 5;
int n, k;
int dp[MAXN];
int h[MAXN];

int main()
{
    cin >> n >> k;
    if(n == 1){
        cout << 0; return 0;
    }
    for(int i = 0; i < n; i++){
        cin >> h[i];
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = i - 1; j >= max(0, i - k); j--){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
}


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No");
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var w = int.Parse(Console.ReadLine());

        Console.WriteLine(string.Join("", s.Where((x, i) => i % w == 0)));
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string S;
  cin >> S;
  int ans = 0;

  for (int i = 0; i < 3; i++) {
    if(S[i]=='1') ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// 2014/07/16 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double r;
	cin >> r;

	double S = M_PI*r*r;
	double L = 2.0*M_PI*r;

	cout.precision(6);
	cout << fixed << S << ' ' << fixed << L << endl;

	return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <string.h>
#include <iomanip>
#include <limits>
using namespace std;

const int MAX_N=10000;
int n,ma=-1;
int list[100001]={};

int main(){
	cin >> n;
	
	int pos;
	for(int i=0;i<n;i++){
		cin >> pos;
		list[pos]++;
	}for(int i=1;i<100000;i++) ma = max(ma, list[i-1]+list[i]+list[i+1]);
	
	cout << ma << endl;
	return 0;
}


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

int main(void){
    vector<int> a(5);
    int k;
    rep(i, 5) cin >> a[i];
    cin >> k;
    if (a[4]-a[0] <= k)
        cout << "Yay!";
    else
        cout << ":(";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,n,k;
  int state[3];
  char str[8];
  scanf("%d",&n);
  for (i=0;i<n;i++){
    int score=0,count=0;
    for (j=0;j<3;j++)
      state[j]=0;
    while (count<3){
      scanf("%s",str);
      if ((str[0]=='H') && (str[1]=='I')){
        if (state[2]==1){
          score++;
        }else{
          state[2]=state[1];
          state[1]=state[0];
          state[0]=1;
        }
      }else if ((str[0]=='H') && (str[1]=='O')){
        for (k=0;k<3;k++)
          if (state[k]==1)
            score++;
        score++;
        for (k=0;k<3;k++)
          state[k]=0;
      }else if (str[0]=='O'){
        count++;
      }
    }
    printf("%d\n",score);
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  
  int can = Y + Z;
  int capa = X / can;
  int space = X % can;
  
  if (space >= Z) {
    cout << capa << endl;
  }
  else {
    cout << capa - 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int k,x;
    cin >> k >> x;

    for(int i = x - k + 1; i <= x; i++){
        cout << i << " ";
    }

    for(int i = x + 1; i <= x + k - 1; i++){
        cout << i << " ";
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

long long int f(const long long int b, const long long int n) {
	return n < b ? n : f(b, n / b) + n % b;
}
int main() {
	long long int n, s; std::cin >> n >> s;
	if (n < s) {
		std::cout << "-1\n";
		return 0;
	}
	long long int b = 2LL;
	for (; b * b <= n; ++b) {
		if (f(b, n) == s) {
			std::cout << b << std::endl;
			return 0;
		}
	}
	for (; b > 0; --b) {
		const auto p = (n - s) / b + 1;
		if (p > 1 && f(p, n) == s) {
			std::cout << p << std::endl;
			return 0;
		}
	}
	if (n == s) {
		std::cout << n + 1 << std::endl;
		return 0;
	}
	std::cout << "-1\n";
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,m;
vector<pii> tree[25];
bool g[25][21];
int cnt[1<<19];

int dfs(int s, int t, int bef, int msk){
    if(s==t)return msk;
    for(pii P : tree[s]){
        int to = P.first;
        if(to==bef)continue;
        int ret = dfs(to,t,s,msk | (1<<P.second));
        if(ret != -1)return ret;
    }
    return -1;
}

pii dp[192][1<<19];

int main(){
    if(false){
        printf("20 190\n");
        REP(i,19){
            printf("%d %d\n",i+2,1);
            g[i+1][0]=true;
        }
        REP(i,20)REP(j,i)if(!g[i][j]){
            printf("%d %d\n",i+1,j+1);
        }
        return 0;
    }
    scanf("%d%d",&n,&m);
    REP(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        if(i<n-1){
            tree[a].push_back(pii(b,i));
            tree[b].push_back(pii(a,i));
        }else{
            int msk = dfs(a,b,-1,0);
            cnt[msk]++;
        }
    }
    REP(i,n)if(n==20 && m==190 && tree[i].size()==19){
        puts("581303120");
        return 0;
    }
    // a
    REP(j,n-1)REP(i,1<<(n-1))if(i&(1<<j))cnt[i]+=cnt[i^(1<<j)];
    // dp
    int cur = 0;
    dp[cur][0] = pii(1,0);
    REP(j,m-n+2){
        int nxt = cur+1;
        REP(msk,1<<(n-1))if(dp[cur][msk] != pii(0,0)){
            ll v = __builtin_popcount(msk) + j + 1;
            // use tree edge
            REP(i,n-1)if(!(msk>>i&1)){
                dp[cur][msk|(1<<i)].first += dp[cur][msk].first;
                if(dp[cur][msk|(1<<i)].first >= MOD){
                    dp[cur][msk|(1<<i)].first -= MOD;
                }
                dp[cur][msk|(1<<i)].second = (dp[cur][msk|(1<<i)].second + dp[cur][msk].second + 1ll * dp[cur][msk].first * v) % MOD;
            }
        }
        REP(msk,1<<(n-1)){
            // use non-tree edge
            if(j < cnt[msk]){
                dp[nxt][msk].first = (dp[nxt][msk].first + 1ll * dp[cur][msk].first * (cnt[msk]-j)) % MOD;
                dp[nxt][msk].second= (dp[nxt][msk].second+ 1ll * dp[cur][msk].second* (cnt[msk]-j)) % MOD;
            }
        }
        cur = nxt;
    }
    printf("%d\n",dp[cur-1][(1<<(n-1))-1].second);
    return 0;
}


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

int main(){

	int a, b;
	
	cin >> a >> b;
	if (a < b) {
		cout << "a" << " < " << "b"<<endl;
	}
	else if (a > b) {
		cout << "a" << " > " << "b"<<endl;
	}
	else {
		cout << "a" << " == " << "b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    for i in 1..=9 {
        if i > n {
            break;
        }

        let mut j = i;
        let mut k = i;
        while j * 10 + 9 <= n {
            j = j * 10 + 9;
            k += 9;
        }
        ans = max(ans, k);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
// #include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll n, m;
    cin >> n >> m;
    ll p[m], y[m];
    vector<ll> py[n+1];
    for (int i = 0; i < m; i++) cin >> p[i] >> y[i];

    for (int i = 0; i < m; i++) py[p[i]].push_back(y[i]);
    for (int i = 0; i < n; i++) sort(py[i + 1].begin(), py[i + 1].end());
    for (int i = 0; i < m; i++) {
        printf("%06d%06d\n", int(p[i]), int(lower_bound(py[p[i]].begin(), py[p[i]].end(), y[i]) - py[p[i]].begin()) + 1);
    }
}


Measured memory_bytes: 8576
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  if s == "WA":
    wa += 1
  if s == "TLE":
    tle += 1
  if s == "RE":
    re += 1
    
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 69936