akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>A;

LL f(LL b)
{
	LL res = 0;
	rep(i, N) res += abs(A[i] - b);
	return res;
}

int main()
{
	in >> N;
	A.resize(N);
	rep(i, N)
	{
		in >> A[i];
		A[i] += N-i;
	}
	LL l = -1123456789, r = 1123456789;
	while (r - l > 1)
	{
		LL m = (l + r) / 2;
		if (f(m - 1) < f(m + 1)) r = m;
		else l = m;
	}
	out << f((l+r)/2) << std::endl;
	return 0;
}


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

using namespace std;

int CalcNum(int n, const vector<int> a){
  int ret = 0;
  vector<int> v(n);
  iota(v.begin(), v.end(), 1);
  do{
    bool bSame = true;
    for(int i=0; i<n; i++){
      if (a[i] != v[i]){
        bSame = false;
      }
    }
    
    if(bSame) break;
    ++ret;
  }while(next_permutation(v.begin(), v.end()));
   
  return ret;       
}

int main(){
  int N;
  cin >> N;
  
  vector<int> P(N);
  vector<int> Q(N);
  
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];
  
  int a = CalcNum(N, P);
  int b = CalcNum(N, Q);
  
  cout << abs(a-b);
  return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;
int a[MAX_N];

int main(){
  ll N; cin >> N;
  ll ss = 0LL;
  rep(i,N){
    scanf("%d",a+i);
    ss += a[i];
  }
  bool ans = (ss%(N*(N+1)/2) == 0LL);
  ss /= (N*(N+1)/2);
  rep(i,N){
    ll b = (a[(i+1)%N] - a[i]);
    b -= ss;
    ans &= (b<=0LL && b%N==0LL);
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int a, b, ans = 0, i;
    scanf("%d%d", &a, &b);

    for ( i = 0; i < 2; i++ ) {
        if ( a > b ) {
            ans += a;
            a--;
        }
        else {
            ans += b;
            b--;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    long long int N, C, K;
    cin >> N >> C >> K;
    long long int T[N];
    for (int i=0; i<N; ++i) cin >> T[i];

    long long int first, num, ans;
    sort(T, T+N);
    first = T[0];
    num = 1;
    ans = 1;
    for (int i=1; i<N; ++i) {
        if ((num < C) && (T[i] <= first + K)) ++num;
        else {
            num = 1;
            ++ans;
            first = T[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(false)
	a := r.nextInt()

	r.Scan(false)
	s := r.nextString()

	msg := "red"
	if a >= 3200 {
		msg = s
	}

	fmt.Fprintln(stdout, msg)
}


Measured memory_bytes: 640
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sat Oct 14 21:26:32 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  int32_t A, B, C;
  cin >> A >> B >> C;

  if (A == B) {
    cout << C << endl;
  } else if (B == C) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int k, a, b, flag = 0;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            flag = 1;
        }
    }
    if (flag == 1)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,m,c; cin >> n >> m >> c; vl ai(m); ll ans = 0;
  vl bi(m); rep(i,m){ ll x; cin >> x; bi[i] = x; }
  
  for(ll i=0; i < n; i++){
    ll sum = 0;
    rep(i,m){ ll x; cin >> x; ai[i] = x; }
    
    for(ll j=0; j < m; j++){
      sum += ai[j]*bi[j];
    }
    
    if(sum + c > 0) ans++;
  }
  
  cout << ans << endl;
}
      

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    for(int mask = 0; mask < (1 << n); mask++){
        bool f = false;
        int tmp = 1;
        rep(i, 0, n){
            if(mask & (1 << i)){
                if(a[i] % 2 == 0){
                    f = true;
                }
            }else{
                if(a[i] % 2 == 1){
                    f = true;
                }
                tmp *= 2;
            }
        }
        if(f) ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514];
ll num[2];
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	if(n%2){
		for(int i=0;i<(n-1)/2;i++){
			num[1]+=2*a[n-1-i];
			num[0]-=2*a[i];
		}
		num[1]-=a[n-1-(n-1)/2]+a[n-2-(n-1)/2];
		num[0]+=a[(n-1)/2]+a[(n-1)/2+1];
		for(int i=(n-1)/2+2;i<n;i++){
			num[1]-=2*a[n-1-i];
			num[0]+=2*a[i];
		}
		ans=max(num[1],num[0]);
	}else{
		for(int i=0;i<n/2-1;i++)ans-=2*a[i];
		ans+=a[n/2]-a[n/2-1];
		for(int i=n/2+1;i<n;i++)ans+=2*a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll a[6] = {};
    string t = "";
    bool plus = true;
    for(char c : s){
        if(c == '+' || c == '-'){
            if(t.back() == 'x'){
                a[1] = (plus ? 1 : -1) * (t.length() < 2 ? 1 : stoi(t.substr(0,t.length()-1)));
            }else if(t.length() > 1 && t[t.length()-2] == '^'){
                a[t.back()-'0'] = (plus ? 1 : -1) * (t.length() < 4 ? 1 : stoi(t.substr(0, t.length()-3)));
            }
            t = "";
            plus = c=='+';
        }else{
            t += c;
        }
    }
    if(t.back() == 'x'){
        a[1] = (plus ? 1 : -1) * stoi(t.substr(0,t.length()-1));
    }else if(t.length() > 1 && t[t.length()-2] == '^'){
        a[t.back()-'0'] = (plus ? 1 : -1) * stoi(t.substr(0, t.length()-3));
    }else{
        a[0] = (plus ? 1 : -1) * stoi(t);
    }
    auto f = [=](ll x)->ll{
        ll ret = 0;
        for(int i = 0; i <= 5; i++){
            ll tmp = a[i];
            for(int j = 0; j < i; j++)  tmp *= x;
            ret += tmp;
        }
        return ret;
    };
    vector<int> v;
    for(ll i = 2000; i >= -2000; i--){
        if(f(i) == 0)   v.push_back(-i);
    }
    for(int i = 0; i < v.size(); i++){
        cout << "(x" << (v[i]>0 ? '+' : '-') << abs(v[i]) << ")";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3208
d, n=gets.chomp.split(" ").map(&:to_i);
if d == 0 then
    if n == 100 then
        puts n+1
    else
        puts n
    end
else
    if n == 100 then
        puts (100**d)*(n+1)
    else
        puts (100**d)*n
    end
end

Measured memory_bytes: 1788
def check(t, n, k, p):
    i = 0
    for j in range(k):
        s = 0
        while (s + t[i] <= p):
            s += t[i]
            i += 1
            if i == n:
                return n
    return i

if __name__ == "__main__":
    n, k = [int (x) for x in input().split()]
    t = []
    for i in range(n):
        t.append(int(input()))

    start, end = 0, 10000 * 100000

    while (end - start > 1):
        mid = (start + end) // 2
        v = check(t, n, k, mid)
        if v >= n:
            end = mid
        else:
            start = mid

    print(end)


Measured memory_bytes: 9560
import sys

W, H, N = map(int, sys.stdin.readline().split())
top = H
left = 0
right = W
down = 0
for _ in xrange(N):
    x, y, a = map(int, sys.stdin.readline().split())
    if a == 1:
        left = max(left,x)
    elif a == 2:
        right = min(right,x)
    elif a == 3:
        down = max(down,y)
    elif a == 4:
        top = min(top,y)
    else:
        pass

print (max(top - down, 0)) * (max(right - left, 0))


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,=pin()

    print(10-N//200)
#%%submit!
resolve()


Measured memory_bytes: 9164
#include <stdio.h>
int main()
{
	int a,b,c,d;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	if(-d<=a-c){
		if(a-c<=d){
			printf("Yes");
		}else{
			if(-d<=b-c){
				if(b-c<=d){
					if(-d<=a-b){
						if(a-b<=d){
							printf("Yes");
						}else{
							printf("No");
						}
					}else{printf("No");
					}
				}else{printf("No");
				}
			}else{printf("No");
			}
		}
	}else{
			if(-d<=b-c){
				if(b-c<=d){
					if(-d<=a-b){
						if(a-b<=d){
							printf("Yes");
						}else{
							printf("No");
						}
					}else{printf("No");
					}
				}else{printf("No");
				}
			}else{printf("No");
			}
		}
	return 0;
}

Measured memory_bytes: 128
#define F(a,b,c) for(a=b;a<=c;++a)
#define upd(a,b) (a<b?a=b:0)
char s[301];c,i,j,k,n,f[301][301][301],a;main(){
scanf("%s%d",s,&c);for(n=0;s[n];++n);F(i,0,n)f[0][i][i]=1;
F(k,0,c)F(i,1,n)F(j,i,n-1)
if(s[j-i]-s[j]){if(k)upd(f[k][j-i][j],f[k-1][j-i+1][j-1]+2);
upd(f[k][j-i][j],f[k][j-i+1][j]);upd(f[k][j-i][j],f[k][j-i][j-1]);
}else upd(f[k][j-i][j],f[k][j-i+1][j-1]+2);
F(i,0,c)upd(a,f[i][0][n-1]);printf("%d\n",a);exit(0);}

Measured memory_bytes: 106752
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
	int n; cin>>n;
	vector<int> array(n);
	int V_MAX = 100100;
	vector<ip> ecnt(V_MAX);
	vector<ip> ocnt(V_MAX);
	rep(i,V_MAX){
		ecnt[i].first = i;
		ecnt[i].second = 0;
		ocnt[i].first = i;
		ocnt[i].second = 0;
	}
	rep(i,n){
		int t;
		cin>>t;
		if(i%2==0){
			ecnt[t].second++;
		}else{
			ocnt[t].second++;
		}
	}
	sort(all(ecnt),compare_by_b);
	sort(all(ocnt),compare_by_b);
	if(ecnt[V_MAX-1].first == ocnt[V_MAX-1].first){
		if(ecnt[V_MAX-1].second == ecnt[V_MAX-1].second){
			cout<<n - ecnt[V_MAX-1].second - max(ecnt[V_MAX-2].second, ocnt[V_MAX-2].second)<<endl;
		}else{
			int a,b;
			if(ecnt[V_MAX-1].second > ocnt[V_MAX-1].second){a = ecnt[V_MAX-1].second; b = ocnt[V_MAX-2].second;}
			else {a = ecnt[V_MAX-2].second; b = ocnt[V_MAX-1].second;}
			cout<<n - a - b<<endl;
		}
	}else{
		cout<<n - ecnt[V_MAX-1].second - ocnt[V_MAX-1].second<<endl;
	}
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  bool flag=false;
  for(int i=1;i<=9;i++){
    if(N%i==0){
      int ans=N/i;
      if((ans>=1)&&(ans<=9)){
        flag=true;
        break;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
for _ in range(m):
  n = heapq.heappop(a)
  n = -1*n//2
  heapq.heappush(a,(-1)*n)
print(-sum(a))

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

int main(){
    int n;
    cin >> n;
    long long a[n];
    int pos = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] >= 0) pos++;
    }
    auto max = max_element(a,a+n);
    auto min = min_element(a,a+n);
    if(*max <= 0){
        cout << n-1 << endl;
        for(int i=n; i>=2; i--){
            cout << i << ' ' << i-1 << endl;
        }
    }
    else if(*min >= 0){
        cout << n-1 << endl;
        for(int i=1; i<=n-1; i++){
            cout << i << ' ' << i+1 << endl;
        }
    }
    else if(*max >= -*min){
        int max_index = max - a + 1;
        cout << n-1+(n-pos) << endl;
        for(int i=0; i<n; i++){
            if(a[i] < 0){
                cout << max_index << ' ' << i+1 << endl;
            }
        }
        for(int i=1; i<=n-1; i++){
            cout << i << ' ' << i+1 << endl;
        }
    }
    else{
        int min_index = min -a +1;
        cout << n-1+pos << endl;
        for(int i=0; i<n; i++){
            if(a[i] >= 0){
                cout << min_index << ' ' << i+1 << endl;
            }
        }
        for(int i=n; i>=2; i--){
            cout << i << ' ' << i-1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math
import re

sys.setrecursionlimit(1000000)

K = input()
A = map(int, raw_input().split())[::-1]

minN = 2
maxN = 2

for num in A:
    minN = (minN / num + (minN % num != 0)) * num
    maxN = maxN / num * num + num - 1
    if maxN < minN:
        print -1
        exit()

print minN, maxN

Measured memory_bytes: 11552
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector<vector<ll>> g;
vector<ll> d;
vector<ll> f;
ll cnt;

void dfs(ll v) {
  if (d[v] >= 0) { return; }
  d[v] = cnt++;
  for (ll u : g[v]) {
    dfs(u);
  }
  f[v] = cnt++;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  g.resize(n);
  rep(i,n) {
    ll u,k;
    cin >> u >> k;
    --u;
    rep(iter,k) {
      ll v;
      cin >> v;
      --v;
      g[u].push_back(v);
    }
  }
  d.assign(n,-1);
  f.assign(n,-1);
  // printtree(g);
  rep(i,n) {
    dfs(i);
  }
  rep(i,n) {
    cout << i+1 << " " << d[i]+1 << " " << f[i]+1 << endl;
  }
}



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

int main() {
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        int m = n * 2 - 1;
        if ((m + 1) / 2 <= x) {
            for (int i = m / 2; i >= 1; i--) {
                cout << i << endl;
            }
            cout << x << endl;
            for (int i = m; i >= (m + 1) / 2; i--) {
                if (i == x) continue;
                cout << i << endl;
            }
        }
        else {
            for (int i = (m + 1) / 2; i >= 1; i--) {
                if (i == x) continue;
                cout << i << endl;
            }
            cout << x << endl;
            for (int i = m; i >= (m + 1) / 2 + 1; i--) {
                cout << i << endl;
            }
        }
    }
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private final byte MASK_RIGHT = 0x0F;//右4bit数値化用マスク
	private int[][] paper = new int[10][10];//都合の良い方眼紙

	public static void main(String[] args) throws NumberFormatException, IOException {
		new Main().execute();
	}

	private void execute() throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > max) {
					max = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16852
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 x, a, b;
    std::cin >> x >> a >> b;
    std::cout << (b<=a ? "delicious" : b<=a+x ? "safe" : "dangerous") << '\n';
}


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

int main(){
    int n;
    cin >> n;
    bool flg[4] = {false, false, false, false};
    rep(i, n) {
        char tmp_c;
        cin >> tmp_c;
        if ( tmp_c == 'P' ) {
            flg[0] = true;
        }
        if ( tmp_c == 'W' ) {
            flg[1] = true;
        }
        if ( tmp_c == 'G' ) {
            flg[2] = true;
        }
        if ( tmp_c == 'Y' ) {
            flg[3] = true;
        }
    }

    int ans = 0;
    rep(i, 4) {
        if ( flg[i] ) {
            ++ans;
        }
    }

    if ( ans == 3 ) {
        cout << "Three" << endl;
    }
    else {
        cout << "Four" << endl;
    }

    return 0;
}


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

int main() {
	int a[5][4][11];
	for (int i = 1; i < 5; ++i)
	{
		for (int j = 1; j < 4; ++j)
		{
			for (int k = 1; k < 11; ++k)
			{
				a[i][j][k]=0;/* code */
			}	/* code */
		}/* code */
	}
	int n,b,f,r,v;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>b>>f>>r>>v;
		a[b][f][r]+=v;
		/* code */
	}

	for(int j=1; j<=3;j++)
	{
		for(int k=1; k<=10; ++k)
		{
			cout<<" "<<a[1][j][k];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
	for(int j=1; j<=3;j++)
	{
		for(int k=1; k<=10; ++k)
		{
			cout<<" "<<a[2][j][k];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
	for(int j=1; j<=3;j++)
	{
		for(int k=1; k<=10; ++k)
		{
			cout<<" "<<a[3][j][k];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
	for(int j=1; j<=3;j++)
	{
		for(int k=1; k<=10; ++k)
		{
			cout<<" "<<a[4][j][k];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main() {
    int y, b;
    scanf("%d %d",&y,&b);
    if(y <= 5) {
        puts("0");
    } else if (y <= 12) {
        printf("%d\n", b / 2);
    } else {
        printf("%d\n", b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

double ANGLE = 3.14159265359 * 60 / 180;
int N;
struct point {
	double x;
	double y;
};


void co(int N, point stt, point end) {
	if (N == 0) return;
	point right, left, mid;
	right.x = (stt.x + 2.0 * end.x) / 3.0;
	right.y = (stt.y + 2.0 * end.y) / 3.0;
	left.x  = (2.0 * stt.x + end.x) / 3.0;
	left.y  = (2.0 * stt.y + end.y) / 3.0;
	mid.x = (right.x - left.x) * cos(ANGLE)
		- (right.y - left.y) * sin(ANGLE) + left.x;
	mid.y = (right.x - left.x) * sin(ANGLE)
		+ (right.y - left.y) * cos(ANGLE) + left.y;

	co(N - 1, stt, left);
	printf("%.8lf %.8lf\n", left.x, left.y);
	co(N - 1, left, mid);
	printf("%.8lf %.8lf\n", mid.x, mid.y);
	co(N - 1, mid, right);
	printf("%.8lf %.8lf\n", right.x, right.y);
	co(N - 1, right, end);
	return;
}

int main() {
	cin >> N;
	point a; a.x = 0.0; a.y = 0.0;
	point b; b.x = 100.0; b.y = 0.0;

	printf("%.8lf %.8lf\n", a.x, a.y);
	co(N, a, b);
	printf("%.8lf %.8lf\n", b.x, b.y);


	return 0;
}





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

int main()
{
    char forecast[3];
    char actual[3];
    cin >> forecast[0] >> forecast[1] >> forecast[2];
    cin >> actual[0] >> actual[1] >> actual[2];
    int counter = 0;
    for (int i = 0; i < 3; i ++) {
        if (forecast[i] == actual[i]) {
            counter ++;
        }
    }
    cout << counter;
    return 0;
}


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

using namespace std;

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

typedef long long ll;

int main()
{
  char s[3];
  cin >> s;

  rep(i,3){
    if (s[i] == '9') s[i] = '1';
    else s[i] = '9';
  }

  cout << atoi(s) << endl;
  
  return 0;
}


Measured memory_bytes: 256
K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//7
else:
  L = 9*K
  
t = 1
ans = -1
for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L
print(ans)

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

using namespace std;

int main(){
    int H,W;
    bool flag = true;
    cin >> H >> W;
    vector<string> s(H+2);
    for(int i=1;i<=H;i++){
        cin >> s[i];
        s[i] = '.' + s[i];
        s[i] = s[i] + '.';
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(s[i][j] == '#'){
                if(s[i+1][j] != '#' && s[i][j+1] != '#' && s[i-1][j] != '#' && s[i][j-1] != '#'){
                    flag = false;
                    break;
                }
            }
        }

        if(!flag){
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  vector<int> vec(5);
  
  for(int i = 0; i < 5; i++){
    cin >> vec.at(i);
  }
  
  for(int i = 0; i < 5; i++){
    if(vec.at(i) == 0){
      cout << i + 1;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while (x <= y)
  {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repb(i,n) for(ll i=(n-1);i>=0;i--)
#define all(a) a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

int main(){
    ll n; cin >> n;
    v<string> ss(n,"");
    ll ans = 0;
    ll a =0;
    ll b =0;
    ll ba =0;
    rep(i,n) {
        cin >> ss[i];
        size_t it=0;
        if(ss[i].front()=='B'&&ss[i].back()!='A')b++;
        if(ss[i].front()!='B'&&ss[i].back()=='A')a++;
        if(ss[i].front()=='B'&&ss[i].back()=='A')ba++;
        
        while(it!=string::npos){
            it=ss[i].find("AB",it);
            if(it!=string::npos){
                it++;
                ans++;
            }
        }
    }
    ans += min(a,b); //XB AX
    ans += min(ba,max(a,b)-min(a,b)); // BA BX or XA BA
    ba -= min(ba,max(a,b)-min(a,b));  // not use BA
    ans += (!max(a,b)&&ba>0)?ba-1:ba; 
    cout << ans<<endl;
}



Measured memory_bytes: 768
/*
Dear ToM,
Congratulations on your graduation!
You did a great job!
     ☆ﾟ*＠*ﾟ☆
　　(＠*｡☆｡*＠
　 /☆｡*＠ﾟ*☆
▲/／｡＠｡*☆＠*
　▼―ｰ｡*＠ﾟ*☆
*/

#include <bits/stdc++.h>
using namespace std;

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){
	ll n, m;
	while(cin >> n >> m, n, m){
		ll ans = 0;
		map<string, ll> mp;
		rep(i, n){
			string s;
			ll num;
			cin >> s >> num;
			mp[s] = num;
		}
		rep(i, m){
			string my;
			cin >> my;
			for(auto it:mp){
				bool flag = true;
				rep(j, (int)my.size()){
					if(it.first[j] == '*') continue;
					if(my[j] != it.first[j]){
						flag = false;
						break;
					}
				}
				if(flag) ans += (it.second);
			}
		}
		cout << ans << endl;
	}



	return 0;
}



Measured memory_bytes: 3068
let s = read_line ()
let h l g = let a, b = max l g, min l g in (a * (a + 1) + b * (b - 1)) / 2
let rec f l g p i a = if i >= String.length s then a + h l g else if s.[i] = p then if s.[i] = '<' then f (l + 1) g p (i + 1) a else f l (g + 1) p (i + 1) a else if s.[i] = '<' then f 1 0 s.[i] (i + 1) (a + h l g) else f l (g + 1) s.[i] (i + 1) a
let _ = Printf.printf "%d\n" @@ f 0 0 s.[0] 0 0

Measured memory_bytes: 5376
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> h(n); cin >> h;
  const ll M = 310;
  vector<vector<double>> dp(n+1, vector<double>(M+1, -1));
  dp[0][1] = 0;
  rep(i, n) rep(j, 1, M+1) {
    if (dp[i][j] < 0) continue;
    rep(k, 1, M+1) {
      double cost;
      if (j <= h[i] && k <= h[i]) {
        cost = (h[i]-j + h[i]-k) / 2.;
      }
      else if (j >= h[i] && k >= h[i]) {
        cost = ((j-h[i]) + (k-h[i])) / 2.;
      }
      else {
        ll a = abs(j - h[i]);
        ll b = abs(k - h[i]);
        cost = (a * a + b * b) / 2. / (a + b);
      }
      if (dp[i+1][k] < 0) dp[i+1][k] = dp[i][j] + cost;
      else chmin(dp[i+1][k], dp[i][j] + cost);
    }
  }
  double ans = linf;
  rep(i, 1, M+1) {
    if (dp[n][i] < 0) continue;
    chmin(ans, dp[n][i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3460
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> G[10010];
int ans[10010];
int c[10010];
int M = 0;
vector<int> leaf;
bool visited[10010];
int t = 0;
int K[10010];
void bfs() {
    queue<int> q;
    rep(i, leaf.size()) {
        q.push(leaf[i]);
        visited[leaf[i]] = true;
    }
    while(q.size()) {
        int v = q.front();
        q.pop();
        ans[v] = c[t++];
        K[v]--;
        for(auto to: G[v]) {
            if (visited[to]) continue;
            K[to]--;
            if (K[to] == 1){
                q.push(to);
                visited[to] = true;
            }
        }
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int s, t; cin >> s >> t;
        s--; t--;
        K[s]++;
        K[t]++;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    rep(i, N) cin >> c[i];
    sort(c, c + N);
    rep(i, N - 1) M += c[i];
    cout << M << endl;
    rep(i, N) {
        if (G[i].size() == 1) {
            leaf.push_back(i);
            //cout << i << " ";
        }
    }
    bfs();
    rep(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;



    return 0;
}


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

using namespace std;
static const int INF = 999999999;
vector<int> tetrahedral;
int min_depth;
int min_odd_depth;
int n;

void DFS(int pos, int depth, int sum)
{
	if(depth >= min_depth)
	{
		return;
	}
	if(sum == n)
	{
		if(depth < min_depth)
		{
			min_depth = depth;
		}
		return;
	}
	else if(sum > n)
	{
		return;
	}
	else
	{
		for(int i = pos; i >= 0; --i)
		{
			DFS(i, depth + 1, sum + tetrahedral[i]);
		}
	}
}

void DFS2(int pos, int depth, int sum)
{
	if(depth >= min_odd_depth)
	{
		return;
	}
	if(sum == n)
	{
		if(depth < min_odd_depth)
		{
			min_odd_depth = depth;
		}
		return;
	}
	else if(sum > n)
	{
		return;
	}
	else
	{
		for(int i = pos; i >= 0; --i)
		{
			if(tetrahedral[i] % 2)
			{
				DFS2(i, depth + 1, sum + tetrahedral[i]);
			}
		}
	}
}

void solve()
{
	for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; ++i)
	{
		tetrahedral.push_back(i * (i + 1) * (i + 2) / 6);
	}
	while(cin >> n, n)
	{
		min_depth = INF;
		min_odd_depth = INF;
		int pos = 0;
		while(tetrahedral[pos] < n)
		{
			++pos;
		}
		for(int i = pos; i >= 0; --i)
		{
			DFS(i, 1, tetrahedral[i]);
		}
		while(tetrahedral[pos] % 2 == 0)
		{
			--pos;
		}
		for(int i = pos; i >= 0; --i)
		{
			if(tetrahedral[i] % 2)
			{
				DFS2(i, 1, tetrahedral[i]);
			}
		}
		cout << min_depth << " " << min_odd_depth << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Distance2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> vectorX = new List<int>();
            List<int> vectorY = new List<int>();
            Console.ReadLine();

            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            foreach (string str in strs){
                vectorX.Add(int.Parse(str));
            }

            line = Console.ReadLine();
            strs = line.Split(' ');
            foreach (string str in strs)
            {
                vectorY.Add(int.Parse(str));
            }

            DistanceCalculator problem = new DistanceCalculator(vectorX, vectorY);

            Console.WriteLine(problem.GetDistance(1).ToString("F6"));
            Console.WriteLine(problem.GetDistance(2).ToString("F6"));
            Console.WriteLine(problem.GetDistance(3).ToString("F6"));
            Console.WriteLine(problem.GetChebyshevDistance().ToString("F6"));

        }
    }

    public class DistanceCalculator
    {
        private List<int> vectorX;
        private List<int> vectorY;

        public DistanceCalculator(List<int> vectorX, List<int> vectorY)
        {
            this.vectorX = vectorX;
            this.vectorY = vectorY;
        }

        public double GetDistance(int power)
        {
            double distance = 0;

            for (int i = 0; i < vectorX.Count; i++)
            {
                distance += Math.Pow(Math.Abs(vectorX[i] - vectorY[i]), power);
            }

            return Math.Pow(distance, (1.0 / power));
        }

        /// <summary>
        /// 2ベクトル間のチェビシェフ距離を取得する
        /// </summary>
        /// <returns>チェビシェフ距離</returns>
        public double GetChebyshevDistance()
        {
            double distance = 0;

            for (int i = 0; i < vectorX.Count; i++)
            {
                if (distance < Math.Abs(vectorX[i] - vectorY[i]))
                {
                    distance = Math.Abs(vectorX[i] - vectorY[i]);
                }
            }

            return distance;
        }

    }
}

Measured memory_bytes: 15980
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N= sc.nextInt();
    int[] count = new int[N+1];
    long ans =1;
    for (int i =2; i<=N; i++) {
      int a =2, b =i;
        while (a <= b) {
          if (b % a == 0) {
            count[a]++;
            b /= a;
            continue;
          }
          a++;
        }
    }
    for (int i =2; i<=N; i++) {
      ans *= (count[i] + 1);
      ans %= 1000000007;
    }
    System.out.print(ans); 
  }
}

Measured memory_bytes: 22612
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e7+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
    
    int x,y;
    scf(x),scf(y);
    
    int b=y/2-x;
    int a=2*x-y/2;
    
    if(y%2!=0||a<0||b<0)
    cout<<"No\n";
    
    else
    {
        if(a+b==x)
        cout<<"Yes\n";
        
        else
        cout<<"No\n";
    
    }

}


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

struct UnionFind {
    vector<ll> par;  // par[i]: parent of i
    vector<ll> siz;

    UnionFind(ll N) : par(N + 1), siz(N + 1, 1ll) {  // initialize by making every node a root node
        for (int i = 0; i <= N; i++) par[i] = i;
    }

    ll root(ll x) {  // find the root of a given node
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return;
    }

    bool issame(ll x, ll y) {  // return true if x and y belong to the same tree
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind railsTree(n), roadsTree(n);
    while (k--) {
        int p, q;
        cin >> p >> q;
        p--, q--;
        railsTree.unite(p, q);
    }
    while (l--) {
        int r, s;
        cin >> r >> s;
        r--, s--;
        roadsTree.unite(r, s);
    }
    map<pair<int, int>, int> counter;
    rep(i, n) {
        int ai = railsTree.root(i);
        int bi = roadsTree.root(i);
        counter[make_pair(ai, bi)]++;
    }
    rep(i, n) {
        int ai = railsTree.root(i);
        int bi = roadsTree.root(i);
        cout << counter[make_pair(ai, bi)] << (i == n-1 ? "\n" : " ");
    }
}

Measured memory_bytes: 20444
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int t = scanner.nextInt();
        int[] a = new int[n];
        int[] min = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            min[i] = i == 0 ? a[i] : Math.min(min[i - 1], a[i]);
        }

        int ans = 0;
        int diff = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (diff < a[i] - min[i]) {
                diff = a[i] - min[i];
                ans = 1;
            } else if (diff == a[i] - min[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
	long long int n,count=0,subcount=1;
	cin>>n;
	for(long long int i=0;i<n;i++)
	{
		long long int p;
		cin>>p;
		if(subcount == p)
		{
			subcount++;
		}else{
			count++;
		}
	}
	if(count<n)
	{
		cout<<count;
	}
	else{
		cout<<-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	vi v(3);
	int n,ans=0;
	rep(i, 3) {
		cin >> v[i];
	}
	sort(all(v));
	cin >> n;
	rep(i, n) {
		v[2] *= 2;
	}
	rep(i, 3){
		ans += v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String word = kb.readLine();
	        word = word.toUpperCase();
	        
	        String str;
	        int cnt = 0;
	       	boolean endoftext = false;
	       	int i=0;
	        while( null != ( str = kb.readLine() ) ) {
	        	for( String wd: str.split( " ", 0 ) ) {
					if( wd.equals( "END_OF_TEXT" ) ) {
		        		endoftext = true;
		        		break;
		        	}
		        	wd = wd.toUpperCase();
		        	i++;
		        	if( wd.equals( word ) ) {
		        		cnt++;
		        	}
		        }
	        	if( endoftext ) { break; }
	        }
			System.out.println( cnt );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

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

#define INF 0x3F3F3F3F

int getNum(long long x){
	int count=0;
	while(x>0){
		count++;
		x=x/10;
	}
	return count;
}

int F(long long x,long long y){
	int a=getNum(x);
	int b=getNum(y);
	return a>b?a:b;
}

int main(){
	long long N;
	cin>>N;	
	int min=getNum(N);
	for(long long i=2;i<=sqrt(N);i++){
		if(N%i==0){
			int temp=F(i,N/i);
			if(temp<min)
				min=temp;			
		}	
	}	
	cout<<min<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b, k;
  cin >> k >> a >> b;
  int x = (b / k) * k;
  if(a <= x){
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }

	return 0;
}

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

int main(){
	int n,y;cin>>n>>y;
	bool chk=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j+i<=n;j++){
			int k=n-i-j;
			if(y==i*10000+j*5000+k*1000){
				chk=1;
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256