akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	H, W := readInt2()
	if H == 1 || W == 1 {
		fmt.Println(1)
		return
	}
	a := int(math.Ceil(float64(H) / 2.0))
	b := H / 2
	if W%2 == 0 {
		fmt.Println((W / 2) * (a + b))
		return
	}
	fmt.Println((W/2)*(a+b) + a)
}


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

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int j=0; j<N; j++) {
    cin >> B[j];
  }
  for (int k=0; k<N-1; k++) {
    cin >> C[k];
  }
  for (int l=0; l<N; l++) {
    ans=ans+B[l];
  }
  for (int m=0; m<N-1; m++) {
    if (A[m]+1==A[m+1]) {
      ans=ans+C[A[m]-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <set>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

ll dp[405][405];

int main() {

	for (int i = 0; i < 405; i++)
		for (int j = 0; j < 405; j++)
			dp[i][j] = 1e18;
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll &x : a)
		cin >> x;
	std::vector<ll> prefix_sum(n);
	prefix_sum[0] = a[0];
	for (int i = 1; i < n; ++i) {
		prefix_sum[i] = prefix_sum[i - 1] + a[i];
	}
	for (int l = n - 1; l >= 0; l--) {
		for (int r = l; r < n; r++) {
			if (l == r)
				dp[l][r] = 0;
			for (int i = l; i < r; i++)
				if (l == 0)
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + prefix_sum[r]);
				else
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + prefix_sum[r] - prefix_sum[l - 1]);
		}
	}
	cout << dp[0][n - 1];

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll h,w,n;
    cin>>h>>w>>n;
    ll ans=0;

    if(h >= w){
        ans = (n+h-1)/h;
    }else{
        ans = (n+w-1)/w;
    }

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


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

int main(){
  int N,M;
  cin >> N >> M;
  priority_queue<int64_t,vector<int64_t>,greater<int64_t> > pq;
  for(int i=0;i<N;i++){
    int64_t A;
    cin >> A;
    pq.push(A);
  }
  vector< pair<int64_t,int64_t> > vp(M);
  for(int i=0;i<M;i++){
    int64_t B,C;
    cin >> B >> C;
    vp.at(i)=make_pair(C,B);
  }
  sort(vp.begin(),vp.end());
  reverse(vp.begin(),vp.end());
  for(int i=0;i<M;i++){
    for(int j=0;j<vp.at(i).second;j++){
      if(pq.top()<vp.at(i).first){
        pq.push(vp.at(i).first);
        pq.pop();
      }else{
        break;
      }
    }
  }
  int64_t ans=0;
  while(!pq.empty()){
    ans+=pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,x,p,q;
    cin>>n;
    deque<int>dq;
    for(i=0;i<n;i++){
        cin>>x;
        if(x==0){
          cin>>p;
          if(p==0){
            cin>>q;
            dq.push_front(q);
          }
          else if(p==1){
              cin>>q;
            dq.push_back(q);
          }
        }
        else if(x==2){
            cin>>p;
            if(p==0){
                dq.pop_front();
            }
            else if(p==1){
                dq.pop_back();
            }
        }
        else if(x==1){
            cin>>p;
            cout<<dq[p]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4612
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define pi pair <int , int >
#define pii pair <pi , int >
#define mp make_pair
using namespace std;
#define MOD 1000000007
int cnt[505][505];
vector< pii > v;
int done[505];
int fans[100010];
int main(int argc, char const *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w", stdout);
    int n,m,q;
    int x,y;
    cin >> n >> m >> q;
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d", &x, &y);
        cnt[x][y]++;
    }
    for(int i = 1; i <= 502; i++)
    {
        for(int j = 1; j <= 502; j++)
            cnt[i][j] += cnt[i][j - 1];

    }
    //cout << cnt[4][6] << "\n";
    for(int i = 0; i < q; i++)
    {
        scanf("%d%d", &x, &y);
        v.pb(mp(mp(x,y),i));
    }
    int cans = 0;
    for(int i = 0; i < q; i++)
    {
        pii cur = v[i];
        int ff = cur.F.F;
        int ss = cur.F.S;
        for(int j = ff; j <= ss; j++)
        {
            fans[cur.S] += cnt[j][ss] - cnt[j][ff - 1];
        }
    }
    for(int i = 0; i < q; i++)
        printf("%d\n", fans[i]);
    return 0;
}

Measured memory_bytes: 3572
S=input()
ks='keyence'
f=False
for i in range(8):
    # print(S[:i],S[-(7-i):],ks[:i],ks[-(7-i):]) #DB
    if S[:i]==ks[:i] and S[-(7-i):]==ks[-(7-i):]: # i=7で怪しい
        f=True
        break

print('YES' if f else 'NO')

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    vector<pair<int,int>> l(5);
    for(int i = 0; i < 5; i++){
        int a,b = 0;
        scanf("%d",&a);
        if(a % 10 == 0)
            b = 10;
            else
            {
                b = a % 10;
            }
        l[i] = make_pair(b,a);
    }
    ll sum = 0;
    sort(l.rbegin(),l.rend());
    for(int i = 0; i < 4; i++){
        if(l[i].first == 10)
        sum += l[i].second;
        else
        {
            sum += (l[i].second / 10 * 10 + 10);
        }
    }
    sum += l[4].second;
        printf("%lld",sum);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dx,dy,ans;
int fun(int M,int D)
{
	ans=0;
	for(int i=3;i<=M;i++)
	{
		for(int j=1;j<=D;j++)
		{
			dx=j%10;
			dy=j/10;
			if((dx>=2) && (dy>=2))
			{
				if(dx*dy==i)
					ans++;
			}
		}
	}
	return ans;
}
int main()
{
	int M,D;
	cin >> M >> D;
	cout << fun(M,D) << endl;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a[3], masatoy = 0;
	char str[1000][1000];
	bool temp = true;
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i<a[0]; i++) {
		cin >> str[i];
	}
	for (int i = 0; i < a[0]; i++) {
		for (int j = 0; j < a[1]; j++) {
			if (str[i][j] == '.') {
				for (int x = 0; x<a[2]; x++) {
					if (str[i + x][j] != '.'&&temp == true) {
						temp = false;
					}
					if (x == a[2] - 1 && temp == true)masatoy++;
				}
			}
			temp = true;
			if (str[i][j] == '.') {
				for (int x = 0; x < a[2]; x++) {
					if (str[i][j + x] != '.'&&temp == true) {
						temp = false;
					}
					if (x == a[2] - 1 && temp == true)masatoy++;
				}
			}
			temp = true;
		}
	}
	cout << masatoy << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=s.size();
    for(int i=1;i<s.size();i++){
        if(s.at(i)==s.at(i-1)){ans--;i+=2;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end

--
local S = str2tbl(io.read("l"))
local N = #S
assert(S[1] == 'R')
assert(S[N] == 'L')

local anstbl = {}
for i=1,N do
    anstbl[i] = 0
end

local function inc(i)
    anstbl[i] = anstbl[i] + 1
end

local dst = {}
local nearest_left_R = 1
for i=2, N do
    if S[i] == 'R' then
        nearest_left_R = i
    else
        dst[i] = {'L', nearest_left_R}
    end
end

local nearest_right_L = N
for i=N-1, 1, -1 do
    if S[i] == 'L' then
        nearest_right_L = i
    else
        dst[i] = {'R', nearest_right_L}
    end
end

for i=1, N do
    local lr, nearest_x = dst[i][1], dst[i][2]
    if lr == 'R' then
        local nearest_right_L = nearest_x
        if (nearest_right_L - i) % 2 == 0 then
            inc(nearest_right_L)
        else
            inc(nearest_right_L-1)
        end
    else
        -- lr == 'L'
        local nearest_left_R = nearest_x
        if (i - nearest_left_R ) % 2 == 0 then
            inc(nearest_left_R)
        else
            inc(nearest_left_R+1)
        end
        
    end
end

print(table.concat(anstbl, ' '))


Measured memory_bytes: 17520
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }
template<class T> using V = vector<T>;

int main() {
    ll n;
    cin >> n; n++;
    ll base = 1;
    int c = 0;
    while (base*2 <= n) {
        base *= 2;
        c++;
    }
    //1...c, 1...c
//    cout << c << " " << base << endl;
    n -= base;
    ll u = base;
    V<int> res;
    V<int> add;
    for (int i = 0; i < c; i++) {
        res.push_back(2*i);
    }
    for (int i = 0; i <= c; i++) {
        if (u <= n) {
            n -= u;
            res.push_back(2*i+1);
            add.push_back(2*i+1);
        }
        u /= 2;
        if (i == c) break;
        res.push_back(2*i);
    }
    while (add.size()) {
        res.push_back(add.back());
        add.pop_back();
    }
    cout << res.size() << endl;
    for (int d: res) {
        cout << d+1 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if((B-A) == (C-B)) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35592
#include <iostream>

using namespace std;

void solve(int n, int t)
{
    int c1, t1;
    int cost = 0;

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

        if (t1 <= t)
        {
            if (cost == 0)
            {
                cost = c1;
            }
            else if (c1 < cost)
            {
                cost = c1;
            }
        }
    }

    if (cost == 0)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << cost << endl;
    }
    
}

int main()
{
    ios::sync_with_stdio(false);
    
    int n , t;

    cin >> n >> t;

    solve(n, t);
    
    return 0;
}

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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

const int N = 1e3 + 9, M = 1e4 + 9, OO = 0x3f3f3f3f;
const ll llOO = 1e18;

int n, a[N], b[N], dp[N][M];

int solve(int i, int rem){
    if(rem <= 0)    return 0;
    if(i == n)  return ((rem <= 0) ? 0 : OO);

    int &ret = dp[i][rem];
    if(~ret)    return ret;

    ret = min(solve(i, rem - a[i]) + b[i], solve(i + 1, rem));

    return ret;
}

int main(){
    init();

    int h;  cin >> h >> n;
    for(int i = 0;i < n;i++) cin >> a[i] >> b[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, h);
}


Measured memory_bytes: 40192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    int n,a,b;
    int x=0,y=0,z=0;
    cin>>n>>a>>b;
    vector<int> p(n);
    rep(i, n){
        cin>>p[i];
        if (p[i]<=a) x++;
        else if(p[i]>a && p[i]<=b) y++;
        else z++;
    }
    cout<<min({x,y,z})<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

char str[12345];

int main(){
int joi_ans;
int ioi_ans;
	while (1){
		memset(str, 0, sizeof(str));
		if (scanf("%s", str) == EOF) return 0;
		joi_ans = 0;
		ioi_ans = 0;
		for (int a = 0;; a++){
			if (str[a] == 'J' &&
				str[a + 1] == 'O' &&
				str[a + 2] == 'I') joi_ans++;
			if (str[a] == 'I' &&
				str[a + 1] == 'O' &&
				str[a + 2] == 'I') ioi_ans++;
			if (str[a + 1] == 0) break;
		}
		printf("%d\n%d\n", joi_ans, ioi_ans);
	}
}

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

const int N=1e5+5;
const long long INF=100000000000ll;
int n,T,E;
int a[N],p[N];

struct Tree{
	int left,right;
	long long val,tag;
	Tree *left_child,*right_child;
};

void build(Tree *pos,int x,int y){
	pos->left=x;pos->right=y;pos->val=pos->tag=0ll;
	if(x==y) return;
	int mid=(x+y)>>1;
	pos->left_child=new Tree();
	pos->right_child=new Tree();
	build(pos->left_child,x,mid);
	build(pos->right_child,mid+1,y);
}

long long VAL(Tree *pos){
	return pos->val+pos->tag;
}

void pushdown(Tree *pos){
	pos->left_child->tag+=pos->tag;
	pos->right_child->tag+=pos->tag;
	pos->tag=0ll;
}

void pushup(Tree *pos){
	pos->tag=0ll;
	pos->val=min(VAL(pos->left_child),VAL(pos->right_child));
}

long long query(Tree *pos,int x,int y){
	if(x>y) return INF;
	if(pos->left>=x&&pos->right<=y) return VAL(pos);
	if(pos->left>y||pos->right<x) return INF;
	pushdown(pos);
	long long ret=min(query(pos->left_child,x,y),query(pos->right_child,x,y));
	pushup(pos);
	return ret;
}

void modify(Tree *pos,int x,int y,long long v){
	if(pos->left>=x&&pos->right<=y){
		pos->tag+=v;
		return;
	}
	if(pos->left>y||pos->right<x) return;
	pushdown(pos);
	modify(pos->left_child,x,y,v);
	modify(pos->right_child,x,y,v);
	pushup(pos);
}

Tree *rt,*dp;

int main(){
	scanf("%d%d%d",&n,&E,&T);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++){
		int l=0,r=i;
		while(l<=r){
			int mid=(l+r)>>1;
			if((a[i]-a[mid])*2<=T) r=mid-1;
			else l=mid+1;
		}
		p[i]=r;
	}
//	for(int i=1;i<=n;i++) printf("%d ",p[i]);puts("");
	rt=new Tree();
	dp=new Tree();
	build(rt,0,n);
	build(dp,0,n);
	for(int i=1;i<=n;i++){
		if(i!=1) modify(rt,0,i-2,2ll*(a[i]-a[i-1]));
		long long DP=min(query(rt,0,p[i]-1),query(dp,p[i],i-1)+T);
//		printf("%d %lld\n",i,DP);
		modify(dp,i,i,DP);
		modify(rt,i,i,DP);
	}
	printf("%lld\n",query(rt,n,n)+E);
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
typedef long long ll;
typedef pair<int,int> pi;

const int INF = 1e9+7, MAXN = 1e3+5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int N,M;
	cin >> N >> M;
	vector<int> adj[MAXN], cost(MAXN);
	for (int i = 0; i < M; i++) {
		int b; cin >> cost[i] >> b;
		for (int j = 0; j < b; j++) {
			int x; cin >> x;
			x--;
			adj[i].emplace_back(x);
		}		
	}
	vector<int> dp(1<<N,INF);
	dp[0] = 0;
	for (int i = 0; i < M; i++) {
		int mask = 0;
		for (auto it: adj[i]) {
			mask |= (1<<it);
		}
		for (int j = 0; j < (1<<N); j++) {
			dp[j|mask] = min(dp[j|mask],dp[j]+cost[i]);
		}
	}
	//for (int i = 0; i < (1<<N); i++) cerr<<dp[i]<<' ';
	if (dp[(1<<N)-1] == INF) cout << -1;
	else cout << dp[(1<<N)-1];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>

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

using namespace std;

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int a;
	char s[10];
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> perfectPower;
	int maximo = 0;
	for(int i=1;i<35;i++){
		for(int j=2;j<10;j++){
			perfectPower.push_back(pow(i, j));
			if(pow(i, j)>1000){
				break;
			}
		}
	}
	for(int i=0;i<int(perfectPower.size());i++){
		if(perfectPower[i]<=n){
			maximo=max(perfectPower[i], maximo);
		}
	}
	cout << maximo << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  bool f=1;
  for(int i=0;i<s.size();i++)
    if(s.at(i)!=t.at(i))
      f=0;
  cout<<(f?"Yes":"No")<<endl;
  
}

Measured memory_bytes: 3624
import sys
s = input()
t = s.replace('x', '')
if t != t[::-1]:
    print(-1)
    sys.exit()
if not t:
    print(0)
    sys.exit()
H = []
ctr = 0
for i in s:
    if i != 'x':
        H.append(ctr)
        ctr = 0
        continue
    ctr += 1
H.append(ctr)
print(sum([abs(i-j) for i, j in zip(H, H[::-1])])//2)

Measured memory_bytes: 5620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x,y = LI()
    r = 0
    if x <= 3:
        r += 4 - x
    if y <= 3:
        r += 4 - y
    if x == 1 and y == 1:
        r += 4

    return r * 10**5


print(main())





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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b; cin >>a>>b;
  if(a>b) print(a-1);
  else print(a);

  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int Q; scanf("%d", &Q);
  while (Q-- > 0) {
    ll A, B; scanf("%lld %lld", &A, &B);
    if (A > B) { swap(A, B); }

    ll ans = 2 * (A - 1);
    ll low = 0, high = 1e9;
    while (high - low > 1) {
      ll mid = (high + low) / 2;
      bool ok = true;

      if (A + mid > B) { ok = false; }
      for (ll i = mid / 2 - 2; ok and i <= mid / 2 + 2; ++i) {
        if (i <= 0 or i > mid) { continue; }
        if (A + mid - i >= B) { continue; }
        if ((A + i) * (A + mid - i) >= A * B) {
          ok = false;
          break;
        }
      }
      if (ok) { low = mid; }
      else { high = mid; }
    }
    ans += low;
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

//atcoder need change class name to Main
//I - Coins
//https://atcoder.jp/contests/dp/tasks/dp_i

// need read other guy code
public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
  
        int N = nextInt(); 
   
        // Dp array 
        double[][] dp = new double[2][2*N+1]; 
        // 0 row store Temp result
        // 1 row store final result
        // -3 -2 -1 0 1 2 3  --> H-T
        // 0  1  2  3 4 5 6  --> need convert

        // Dp array 
        
        double h = 0;
        double t = 0;
        
        // Let N be a positive odd number.
        h = nextDouble();
        dp[1][N+1] = h;
        dp[1][N-1] = 1 - h;
  
        for (int i=2; i<=N;  i++) {
            h = nextDouble();
            t = 1 - h;
            for (int j=i+N-1; j>0;  j--) {
                dp[0][j+1] += dp[1][j] *h; 
            }
            for (int j=i+N-1; j>0;  j--) {
                dp[0][j-1] += dp[1][j]*t; 
            }
            for (int j=i+N; j>=0;  j--) {
                dp[1][j] = dp[0][j]; 
                dp[0][j] = 0; 
            }
        }


        double sum = 0;
        for (int i=N+1; i<2*N+1;  i++) {
            sum += dp[1][i];
        }
        
        System.out.println(sum);
  
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 25608
#include <iostream>
using namespace std;
int main()
{
	int n,m,y,z=0;
	cin >> n;
	y = n-1;
	int a[200010], b[200010];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	if ((n-1) % 2 == 0)
	{
		for (int j = n-1; j >=0; j--)
		{
			if (j % 2 == 0)
			{
				b[z] = a[j];
				z++;
			}
			else {
				b[y] = a[j];
				y--;
			}		
		}
	}
	else
	{
		for (int j = n-1; j >= 0; j--)
		{
			if (j % 2 != 0)
			{
				b[z] = a[j];
				z++;
			}
			else {
				b[y] = a[j];
				y--;
			}		
		}
	}
	
	for (int x = 0; x < n-1; x++)
	{
		cout << b[x] << " ";
	}
	cout << b[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int N, Y;
    cin >> N >> Y;

    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= N-i; ++j)
        {
            if (10000*i + 5000*j + 1000*(N-(i+j)) == Y)
            {
                printf("%d %d %d\n", i, j, N - (i+j));
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, C, ans int
	fmt.Scan(&A, &B, &C)
	m := max(A, B, C)

	if (3*m)%2 == (A+B+C)%2 {
		// 3つの数字がそろうのはm
		ans += ((3 * m) - (A + B + C)) / 2
	} else {
		// 3つの数字がそろうのはm+1
		ans += ((3 * (m + 1)) - (A + B + C)) / 2
	}

	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int K;
	while(1){
		cin>>K;if(K==0)break;

		int g=K*(K-1)/2;

		int n[5010]={};
		int s=0;

		for(int i=0;i<g;i++)
		{int x;cin>>x;s+=x;}
		s=s/(K-1);
		cout<<s<<endl;
	}
	return 0;
}

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

int main(){
	bool hasCard[4][13] = {false};
	int n, rank;
	char suit;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> suit >> rank;
		rank--;
		switch(suit){
		case 'S':
			hasCard[0][rank] = true;
			break;
		case 'H':
			hasCard[1][rank] = true;
			break;
		case 'C':
			hasCard[2][rank] = true;
			break;
		case 'D':
			hasCard[3][rank] = true;
			break;
		}
	}

	for(int i = 0; i < 4; i++){
		for(rank = 0; rank < 13; rank++){
			if(!hasCard[i][rank]){
				switch(i){
				case 0:
					cout << "S ";
					break;
				case 1:
					cout << "H ";
					break;
				case 2:
					cout << "C ";
					break;
				case 3:
					cout << "D ";
					break;
				}
				cout << rank+1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3092
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9
for i in range(n-k+1):
    t = min(abs(x[i]), abs(x[i+k-1]))
    ans = min(ans, t + abs(x[i]-x[i+k-1]))
print(ans)

Measured memory_bytes: 15020
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int cnt[100001];
int main(){
  int Lj4PdHRW, i, res=0, x;
  rd(N);
  for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
    rd(x);
    if(x>N){
      res++;
    }
    else{
      cnt[x]++;
    }
  }
  for(i=0;i<(N+1);i++){
    if(cnt[i] >= i){
      res += cnt[i] - i;
    }
    else{
      res += cnt[i];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, cnt[100001];
// {
//   int i, x, res = 0;
//   rd(N);
//   rep(N){
//     rd(x);
//     if(x>N) res++;
//     else    cnt[x]++;
//   }
//   
//   rep(i,N+1){
//     if(cnt[i] >= i) res += cnt[i] - i;
//     else            res += cnt[i];
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define hi ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define emb emplace_back
#define mp make_pair
#define srt(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define count(a, n) count(a.begin(), a.end(), n)
#define reverse(a) reverse(a.begin(), a.end())
#define F first
#define S second
#define pii pair<int, int>
#define vi vector<int>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define de(x) cout << #x << " is " << x << '\n'
typedef long long ll;
using namespace std;
int main()
{
    hi;
    ll x, y;
    cin >> x >> y;
    for (ll i = 0; i < 100; i++)
    {
        ll t = pow(2, i - 1) * x;
        if (t > y)
        {
            cout << i - 1 << '\n';
            break;
        }
    }
    return 0;
}


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

using namespace std;

int main() {
    long long int N, K, Q;
    cin >> N >> K >> Q;

    long long int players[N] = { 0 };

    int A = 0;
    for (int i = 0; i < Q; i++)
    {
        cin >> A;
        players[A - 1] = players[A - 1] + 1;
    }

    for (int i = 0; i < N; i++)
    {
        if (Q - players[i] < K)
        {
            cout << "Yes" << "\n";
        } else {
            cout << "No" << "\n";
        }
    }
}



Measured memory_bytes: 1408
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];int u,v;
    int in[n+1];
    memset(in,0,sizeof(in));
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        in[v]++;
    }
    set<pair<int,int> >s;
    set<pair<int,int> >::iterator it;vector<int>topo;
    for(int i=1;i<=n;i++)
        s.insert(m1(in[i],i));
    pair<int,int>p;
    while(!s.empty())
    {
        p=(*s.begin());
        s.erase(s.begin());
        u=p.second;
        topo.pb(u);
        for(int i=0;i<adj[u].size();i++)
        {
            v=adj[u][i];
            it=s.find(m1(in[v],v));
            if(it!=s.end())
            {
                in[v]--;
                s.erase(it);
                s.insert(m1(in[v],v));
            }
        }
    }
    int d[n+1];
    memset(d,0,sizeof(d));int ans=0;
    for(int i=0;i<topo.size();i++)
    {
        u=topo[i];
        for(int j=0;j<adj[u].size();j++)
        {
            v=adj[u][j];
            d[v]=max(d[v],1+d[u]);
        }
    }
    for(int i=1;i<=n;i++)
        ans=max(ans,d[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if(N%10==3)  cout<< "bon" <<endl;
  else if(N%10==0||N%10==1||N%10==6||N%10==8)  cout<< "pon" <<endl;
  else cout<< "hon" <<endl;
  return 0;
}

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

int main(void){
    int n, sum = 0;
    cin >> n;
    vector<int>x(n),y(n);
    for (int i = 0; i < n; i++)cin >> x.at(i);
    for (int i = 0; i < n; i++)cin >> y.at(i);
    for (int i = 0; i < n; i++){
        if (x.at(i) > y.at(i))
            sum += (x.at(i) - y.at(i));
        }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    FOR(i, 10, d + 1) {
        int f = i % 10;
        int s = (i - f) / 10;
        if (f < 2 or s < 2) continue;
        if (f * s <= m and f * s > 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
int main(void){
    ll n;cin>>n;
    //vector<vector<ll>> dp(n+10,vector<ll>(3,0));
    vector<ll> dp(3,0);
    ll res=1;
    vector<ll> x(n);
    rep(i,n){
        cin>>x[i];
    }
    rep(i,n){
        //cout<<x[i]<<endl;
        ll buf=0;
        bool jud=false;
        rep(j,3){
            if(dp[j]==x[i]){
                buf++;
                if(!jud){
                    jud=true;
                    dp[j]++;
                }
            }
        }
        res*=buf;
        res%=mod;
        //cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
    }
    cout<<res<<endl;
}

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

const int mxN=5e3;
int n, k;
string s;

struct suffixarray {
	static const int mxN=1e4;
	int n, m, sa[mxN], sa2[mxN], cl[2*mxN], cl2[mxN], cnt[mxN+1];
	void ac() {
		for(int l=1; l<n; l*=2) {
			for(int i=0; i<n; ++i)
				++cnt[cl[i+l]];
			for(int i=0; i<m; ++i)
				cnt[i+1]+=cnt[i];
			for(int i=0; i<n; ++i)
				sa2[--cnt[cl[i+l]]]=i;
			memset(cnt, 0, 4*m+4);
			for(int i=0; i<n; ++i)
				++cnt[cl[i]];
			for(int i=0; i<m; ++i)
				cnt[i+1]+=cnt[i];
			for(int i=n-1; ~i; --i)
				sa[--cnt[cl[sa2[i]]]]=sa2[i];
			memset(cnt, 0, 4*m+4);
			m=0;
			for(int i=0; i<n; ++i) {
				if(!i||cl[sa[i-1]]^cl[sa[i]]||cl[sa[i-1]+l]^cl[sa[i]+l])
					++m;
				cl2[sa[i]]=m;
			}
			memcpy(cl, cl2, 4*n);
		}
	}
} sa;

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

	cin >> n >> k >> s, --k;
	string s2=s;
	reverse(s2.begin(), s2.end());
	s+=s2;
	sa.n=2*n;
	sa.m=26;
	for(int i=0; i<2*n; ++i)
		sa.cl[i]=s[i]-'a'+1;
	sa.ac();
	int t=-1, l=0, m;
	while(sa.sa[++t]>n);
	t=sa.sa[t];
	while(++l<n&&s[t]==s[t+l]);
	for(m=l; k--&&m<n; m=min(m*2, n));
	for(int i=0; i<m; ++i)
		cout << s[t];
	for(int i=0; i<n-m; ++i)
		cout << s[t+l+i];
}

Measured memory_bytes: 512
// https://beta.atcoder.jp/contests/cf17-relay-open/submissions/1812544
// user: dotorya

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-9;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[200050];
int main() {
	int N, i;
	scanf("%d", &N);
	N *= 2;
	for (i = 1; i <= N; i++) scanf("%lld", &in[i]);
	sort(in + 1, in + N + 1);

	db ans = 0;
	for (i = 1; i <= N; i++) ans += (i - 1) * in[i];
	return !printf("%.20lf\n", ans / (N - 1));
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
V g[inf];//隣接リスト;
int n,m;
int dfs(int);
V memo(100001,-1);//memo[i]:i番目を頂点とする有向グラフの最大数を格納する
int main(){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;//0-index;
        g[a].PB(b);
    }
    int ans=0;
    rep(i,n){
        ans=max(ans,dfs(i));
    }
    cout<<ans<<endl;
}
int dfs(int now){
    if(memo[now]!=-1)return memo[now];//探索済みならスルー；
    int remain=(int)g[now].size();
    int tmp=0;
    for(int i=0;i<remain;i++){
        tmp=max(dfs(g[now][i])+1,tmp);
    }
    memo[now]=tmp;
    //printf("memo[%d]=%d\n",now,memo[now]);
    return memo[now];
}

Measured memory_bytes: 29184
use v5.18;
use warnings;
use List::Util qw( min );
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }
my @nums = sort { $b <=> $a } splited_read_line;
my ($max, $middle, $min) = @nums;
my $one_conut = $max - $middle;
$middle += $one_conut, $min += $one_conut;
my $two_count = $max - $min;
$one_conut++ if $two_count % 2;
$two_count = int( ($two_count + 1)  / 2);
say $one_conut + $two_count;


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

int main() {
  int x;
  scanf("%d", &x);

  int ans = 0;
  int cur = 0;
  do {
    (cur += x) %= 360;
    ++ans;
  } while (cur != 0);

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        if(str.length() % 2 != 0){ 
            System.out.println("No");
            return;
        }
        for (int i = 0; i < str.length(); i++) {
            if(i % 2 == 0 && str.charAt(i) != 'h'){ 
                System.out.println("No");
                return;
            }
            if(i % 2 != 0 && str.charAt(i) != 'i'){ 
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,k;
  cin >> a >> b >>k;
  int counter = 0;
  for( int i = min(a,b) ; i > 0 ;i--){
    if( a % i == 0 && b % i == 0){
      counter +=1;
      if( counter == k){
        cout << i;
        break;
      }
    }
  }
}

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

const long MAXN=5050;
int n,K;
int p[MAXN];long long c[MAXN];
bool book[MAXN];
int seq[MAXN],length;
long long sum,pre[2*MAXN];

int main() {
	cin>>n>>K;register int i,j,k;
	for(i=1;i<=n;++i)
		scanf("%d",&p[i]);
	for(i=1;i<=n;++i)
		scanf("%lld",&c[i]);
	
	int now_node;
	long long ans1,ans2,real_ans=-9223372036854775800;
	for(i=1;i<=n;++i)
		if(!book[i]) {
			memset(seq,0,sizeof(seq));
			memset(pre,0,sizeof(pre));
			book[i]=1;
			seq[1]=i;
			length=1;
			sum=c[i];
			now_node=p[i];
			pre[1]=c[i];
			
			while(now_node!=i) {
				book[now_node]=1;
				seq[++length]=now_node;
				sum+=c[now_node];
				pre[length]=pre[length-1]+c[now_node];
				now_node=p[now_node];
			}
			
			for(j=1;j<=length;++j)
				pre[length+j]=pre[j]+sum;
		#ifdef debug
			printf("SEQ ");
			for(int f=1;f<=length;++f)
				printf("%d ",seq[f]);
			printf("\nlength=%d sum=%d\nPRE ",length,sum);
			for(int f=1;f<=2*length;++f)
				printf("%lld ",pre[f]);
			printf("\n\n");
		#endif
			ans1=-9223372036854775800;ans2=-9223372036854775800;
			for(j=1;j<=length;++j) {
				if(K>=length)
					for(k=j+1;k<=j+length;++k)
						ans1=max(ans1,pre[k]-pre[j]);
				for(k=j+1;k<=j+(K%length);++k)
					ans2=max(ans2,pre[k]-pre[j]);
			}
			
			if(sum>0) {
				real_ans=max(real_ans,ans2+(K/length)*sum);
				if(K>=length)
					real_ans=max(real_ans,ans1+((K/length)-1)*sum);
			}
			else {
				real_ans=max(real_ans,ans2);
				if(K>=length)
					real_ans=max(real_ans,ans1);
			}
		}
	
	cout<<real_ans<<endl;
	return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    vector<int> plus(N);
    for (int i = 0; i < N; i++) {
        plus[p[i] - 1] = i+1;
    }
    vector<int> a(N), b(N);
    a[0] = plus[0];
    b[N-1] = plus[N-1];
    for (int i = 1; i < N; i++) {
        a[i] = a[i-1] + plus[i];
    }
    for (int i = N-2; i >= 0; i--) {
        b[i] = b[i+1] + plus[i];
    }
    for (int i = 0; i < N; i++) {
        printf("%d ", a[i]);
    }
    cout << endl;
    for (int i = 0; i < N; i++) {
        printf("%d ", b[i]);
    }
    cout << endl;


}

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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    ll n, a, b;
    cin >> n >> a >> b;

    if (a >= n) cout << n << endl;
    else {
        if (a + b >= n) {
            cout << a << endl;
        }
        else {
            ll ans = 0;
            ans += ( n / (a + b) ) * a;
            ans += min(n % (a + b), a);
            cout << ans << endl;
        }
    }





    return 0; 
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); i++)
 
int main() {
 ll n,ans;
  cin>>n;
  rep(i,100000){
    if(i*i>n){
      break;
    }
    ans=i*i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256