akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VI a(n);
  REP (i, n) cin >> a[i];
  VI acc(n + 1);
  REP (i, n) acc[i + 1] = acc[i] + a[i];
  VVI dp(n, VI(n, 1e18));
  REP (i, n) {
    dp[i][i] = a[i];
  }
  REPI (k, 1, n) {
    REP (i, n) {
      int j = i + k;
      if (j >= n) continue;
      dump(i, j);
      int tmp = acc[j + 1] - acc[i];
      REPI (m, i + 1, j + 1) {
        dp[i][j] = min(dp[i][j], tmp + dp[i][m - 1] + dp[m][j]);
      }
    }
  }
  cout << dp[0][n - 1] - acc[n] << endl;
}


Measured memory_bytes: 1536
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

vector<int> v[100005];
int dp[100005];

void DFS(int i){
	int maxn=0;
	for(auto a:v[i])
		if(dp[a]) maxn=max(maxn,dp[a]);
		else DFS(a),maxn=max(maxn,dp[a]);
	dp[i]=maxn+1;	
}

int main() {
	ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	
	for(int i=0,l,r;i<m;i++)
		cin>>l>>r,v[l].push_back(r);
	
	
	for(int i=1;i<=n;i++)
		if(!dp[i])
			DFS(i);

	int maxn=0;
	for(int i=1;i<=n;i++)
		maxn=max(dp[i],maxn);
	cout<<maxn-1<<'\n';
}

Measured memory_bytes: 8192
import itertools
N=int(input())
key='MARCH'
cnt=[0]*5
for i in range(N):
    S=input()
    for j in range(5):
        if(S[0]==key[j]):
            cnt[j]+=1
ans=0
for v in itertools.combinations(cnt,3):
    ans+=v[0]*v[1]*v[2]
print(ans)

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

using namespace std;
using ll = long long;
const double 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 rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
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<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;
	vector<ll> v;
	ll ans = 0;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
	}

	REP(i, n - 1) {
		ans += v[i] / 2;
		v[i] = v[i] % 2;
		ll x = min(v[i], v[i + 1]);
		ans += x;
		v[i] -= x;
		v[i + 1] -= x;
	}

	ans += v[n - 1] / 2;

	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int tuuka = 0;
    int kaigai = 1;
    rep(i, n) {
        if (s[i] == 'a') {
            yns(tuuka < a+b);
            tuuka++;
        }
        if (s[i] == 'b') {
            if (tuuka < a+b && kaigai <= b) {
                tuuka++;
                puts("Yes");
            }
            else puts("No");
            kaigai++;
        }
        if (s[i] == 'c') puts("No");
    }
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int a[1000],b[1000],leng=0;
int f(){
    int i,j;
    for(i=1;i<=leng;i++)
    if(b[a[i]]>0)return 1;
    return 0;
}
int main(){
    int i,j,l;
    long long k,n,m;
    cin>>k>>n;
    for(i=1;i<=n;i++)cin>>l,b[l]++;
    m=k;
    while(m>0){
        a[++leng]=m%10;
        m/=10;
    }
    while(f()){
        int s1=f();
        a[s1]++;
        k++;
        while(a[s1]>=10)a[s1]=0,s1++,a[s1]++;
        leng=max(leng,s1);
    }
    cout<<k<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;
int main()
{
	int X, ans = 1;
	scanf("%d", &X);
	bool expo[X + 1];
	expo[1] = 1;
	for (int i = 1; i <= X; i++) {
		for (int j = 2; j <= X; j++) {
			int tmp = pow(i, j);
			if (tmp <= X && tmp > ans)
				ans = tmp;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long llong;

#define MAX 100
const llong mod = 1000000000 + 7;

int main()
{
  char S[MAX];
  int N;
  int isA = 1, isB = 1, isC = 1;
  scanf("%s", S);

  N = strlen(S);
  for (int i = 0; i < N / 2; i++)
  {
    if (S[i] != S[N - 1 - i])
      isA = 0;
  }

  int L = (N - 1) / 2;
  for (int i = 0; i < L / 2; i++)
  {
    if (S[i] != S[L - 1 - i])
      isB = 0;
  }

  int m = (N + 3) / 2;
  int M = N - m;
  for (int i = 0; i < M / 2; i++)
  {
    if (S[m - 1 + i] != S[N - 1 - i])
      isC = 0;
  }

  if (isA && isB && isC)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 k, a, b; cin >> k >> a >> b;
	if(a >= k) {
		cout << 1 << endl;
		return 0;
	}
	k -= a;
	a -= b;
	if(a <= 0) {
		cout << -1 << endl;
		return 0;
	}
	
	cout << 1 + (k + a - 1) / a * 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s; cin >> s;

	vector<int> ans(s.size());

	int i = 0;
	while (i < s.size()) {

		{
			int rs = 0;
			int org = i;
			while (s[i] == 'R') {
				rs++;
				i++;
			}
			if (rs & 1) {
				ans[org + rs - 1] += rs / 2 + 1;
				ans[org + rs]     += rs / 2;
			}
			else {
				ans[org + rs - 1] += rs / 2;
				ans[org + rs]     += rs / 2;
			}
		}

		{
			int ls = 0;
			int org = i;

			while (s[i] == 'L') {
				ls++;
				i++;
			}
			if (ls & 1) {
				ans[org]     += ls / 2 + 1;
				ans[org - 1] += ls / 2;
			}
			else {
				ans[org]     += ls / 2;
				ans[org - 1] += ls / 2;
			}
		}



	}

	for (int a : ans) {
		cout << a << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1104
#include<stdio.h>
int main(void){

int p[21];
int n;
int i;
int flag=0;
  
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&p[i]);
}

for(i=0;i<n-2;i++){

if(p[i]<p[i+1] && p[i+1]<p[i+2]){
flag++;
}
if(p[i]>p[i+1] && p[i+1]>p[i+2]){
flag++;
}
  
}
  
printf("%d",flag); 
  
return 0;
  
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
typedef std::vector<std::vector<int>> graph_t;

boost::optional<std::vector<int>> run(int N, graph_t const& edge)
{
	boost::multi_array<int, 2> prev(boost::extents[N][N]);
	boost::multi_array<bool, 2> flag(boost::extents[N][N]);
	std::queue<std::pair<int, int>>queue;
	for (auto i : boost::irange(0, N))
	{
		queue.emplace(i, i);
	}
	while (queue.size())
	{
		int first, now;
		std::tie(first, now) = queue.front();
		queue.pop();
		if (flag[first][now])
		{
			continue;
		}
		flag[first][now];
		for (auto n : edge[now])
		{
			if (n == first)
			{
				std::vector<int> ret;
				auto k = now;
				while (k != first)
				{
					ret.emplace_back(k);
					k = prev[first][k];
				}
				ret.emplace_back(first);
				return ret;
			}
			else
			{
				prev[first][n] = now;
				queue.emplace(first, n);
			}
		}
	}
	return boost::none;
}

void Main()
{
	int N, M;
	std::cin >> N >> M;
	graph_t edge(N);
	for (int _ : boost::irange(0, M))
	{
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		edge[a].emplace_back(b);
	}
	auto result = run(N, edge);
	if (result)
	{
		std::cout << result->size() << std::endl;
		for (auto v : *result)
		{
			std::cout << v + 1 << std::endl;
		}
	}
	else
	{
		std::cout << -1 << std::endl;
	}
}

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

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

int main(){

 int x, y;

 for (x = 1; x < 10; x++) {
  for (y = 1; y < 10; y++) {
   cout << x << "x" << y << "=" << x * y << "\n";
  }
 }

 return 0;
}

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

int main() {
    int N, W;
    ll weight[110];
    ll value[110];
    ll dp[110][100010] = {0}; /////変数宣言はmain()の外側でしないとSegmentation faultが発生？
 
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
    
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            if (sum_w >= weight[i]) dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]] + value[i]);
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }       
    }
    cout << dp[N][W] << endl;
    
    return 0;
}

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

int main(){
    int N,K;
    int h[100000];
    int count=0;
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> h[i];

    for(int i=0;i<N;i++){
        if(h[i]>=K) count++;
    }
    cout << count;
}

Measured memory_bytes: 640
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	
	int n;
	int m;
	cin>>n>>m;
	int max=m;
	int a,b;
	bool f=true;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		m+=a;
		m-=b;
		if(m<0){
			f=false;
		}
		if(max<m)
			max=m;
	}
	if(!f)
		cout<<0<<endl;
	else
		cout<<max<<endl;
	
	
}

Measured memory_bytes: 1164
#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() {
  int n,k;
  ll cnt1 = 0,cnt2 = 0,ans;
  cin >> n >> k;
  for(int i = 1;i <= n;i++){
    if(i%k == 0) cnt1++;
    if(i%k == k/2) cnt2++;
  }
  ans = cnt1*cnt1*cnt1;
  if(k%2 == 0) ans += cnt2*cnt2*cnt2;
  cout << ans << endl;
}

Measured memory_bytes: 256
class Card
  attr_reader :type, :num
  def initialize(type, num)
    @type = type
    @num = num
  end
end

def quicksort(a, p, r)
  if p < r then
    q = partition(a, p, r)
    quicksort(a, p, q-1)
    quicksort(a, q+1, r)
  end
end

def partition(a, p, r)
  x = a[r].num
  i = p - 1
  p.upto(r-1){|j|
    if a[j].num <= x then
      i += 1
      a[i], a[j] = a[j], a[i]
    end
  }
  a[i+1], a[r] = a[r], a[i+1]
  return i+1
end

def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  _L = a[left..mid-1]
  _R = a[mid..right-1]
  _L[n1] = Card.new(" ", 1.0 / 0.0)
  _R[n2] = Card.new(" ", 1.0 / 0.0)
  i = j = 0
  left.upto(right-1){|k|
    if _L[i].num <= _R[j].num then
      a[k] = _L[i]
      i += 1
    else
      a[k] = _R[j]
      j += 1
    end
  }
  return right - left
end

def mergeSort(a, left, right)
  count = 0
  if left+1 < right then
    mid = (left + right) / 2
    count += mergeSort(a, left, mid)
    count += mergeSort(a, mid, right)
    count += merge(a, left, mid, right)
  end
  return count
end

n = gets.to_i
arr = $stdin.readlines
a = []
i = 0
arr.each{|card|
  type, num = card.split
  a[i] = Card.new(type, num.to_i)
  i += 1
}
b = a.clone
quicksort(a, 0, n-1)
mergeSort(b, 0, n)
puts a == b ? "Stable" : "Not stable"
0.upto(n-1){|j|
  printf "%s %d\n", a[j].type, a[j].num
}

Measured memory_bytes: 38532
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 1000000000000000

type dest struct {
	num  int
	cost int
}

type heapDest []dest

func (h heapDest) Len() int {
	return len(h)
}

func (h heapDest) Less(i, j int) bool {
	return h[i].cost < h[j].cost
}

func (h heapDest) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *heapDest) Push(x interface{}) {
	*h = append(*h, x.(dest))
}

func (h *heapDest) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func dijkstra(n int, s int, adj [][]dest) []int {
	ret := make([]int, n)
	for i := range ret {
		if i != s {
			ret[i] = INF
		}
	}
	h := &heapDest{dest{s, 0}}
	heap.Init(h)
	for len(*h) > 0 {
		d1 := heap.Pop(h).(dest)
		if d1.cost > ret[d1.num] {
			continue
		}
		for _, d2 := range adj[d1.num] {
			if ret[d1.num]+d2.cost < ret[d2.num] {
				ret[d2.num] = ret[d1.num] + d2.cost
				heap.Push(h, dest{d2.num, ret[d1.num] + d2.cost})
			}
		}
	}
	return ret
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, m, s, t := nextInt(), nextInt(), nextInt()-1, nextInt()-1

	adjA, adjB := make([][]dest, n), make([][]dest, n)
	for i := 0; i < m; i++ {
		u, v, a, b := nextInt()-1, nextInt()-1, nextInt(), nextInt()
		adjA[u] = append(adjA[u], dest{v, a})
		adjA[v] = append(adjA[v], dest{u, a})
		adjB[u] = append(adjB[u], dest{v, b})
		adjB[v] = append(adjB[v], dest{u, b})
	}
	costA, costB := dijkstra(n, s, adjA), dijkstra(n, t, adjB)

	ans := make([]int, n+1)
	for i := n - 1; i >= 0; i-- {
		remain := INF - (costA[i] + costB[i])
		switch {
		case remain < ans[i+1]:
			ans[i] = ans[i+1]
		default:
			ans[i] = remain
		}
	}
	for i := 0; i < n; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 28416
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <set>
using namespace std;
int main() {
  int a,b; cin>>a>>b;
  int n,p,q,s,t,ans=0;
  for(int i=a;i<=b;i++){
    n=i;
    p=i/10000; n=n%10000;
    q=n/1000; n=n%1000%100;
    s=n/10; t=n%10;
    if(p==t and q==s) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int f(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}

signed main() {
  cout << fixed << setprecision(15);
  string s,ans="";
  int n;
  cin >> s >> n;
  rep(i,0,s.size()){
    if(i%n==0) ans += s[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

enum JudgeCircleIntersect 
{
	BinA =  2,
	AinB = -2,
	AcrossB = 1,
	AdisB = 0,
	Error = -1
};

struct Circle
{
	Circle()
	{
	}

	Circle(double sx, double sy, double sr):cx(sx), cy(sy), r(sr)
	{
	}

	double cx;

	double cy;

	double r;
};

double Abs(double x)
{
	return x>=0 ?  x : -x;
}

JudgeCircleIntersect Intersect(const Circle& a, const Circle& b)
{
	double distance = sqrt((a.cx-b.cx)*(a.cx-b.cx)+(a.cy-b.cy)*(a.cy-b.cy));


	if(a.r+b.r<distance)
	{
		return AdisB;
	}
	else if((b.r-a.r)>distance && (b.r-a.r)>0)
	{
		return AinB;
	}
	else if((a.r-b.r)>distance && (a.r-b.r)>0)
	{
		return BinA;
	}
	else if(Abs(a.r-b.r)<=distance && (a.r+b.r>=distance))
	{
		return AcrossB;
	}
	else
	{
		return Error;
	}
}

int main()
{
	int n = 0;
	
	double xa, ya, ra, xb, yb, rb;

	std::cin >> n;

	for(int i=0; i<n; ++i)
	{
		std::cin >> xa >> ya >> ra 
			>> xb >> yb >> rb;

		Circle a(xa, ya, ra);

		Circle b(xb, yb, rb);

		std::cout << Intersect(a,b) << '\n';
	}


	/*
	Circle a(20.0,40.0,30.0); // 位置(20,40), 半径 30 の円

	Circle b(30.0,50.0,20.0); // 位置(40,50), 半径 20 の円

	if(Intersect(a,b))
	{
		std::cout << "a と b は交差している\n";
	}
	else
	{
		std::cout << "a と b は交差していない\n";
	}
	*/
}

Measured memory_bytes: 1232
#!/usr/bin/env python3
import sys


def solve(N: int, B: "List[int]"):

    result = B[0] + B[-1]

    for i in range(len(B) - 1):
        result += min(B[i], B[i + 1])

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint a[200100],s[200100];
map<lint,int> me;
int main()
{
	int n;lint k,out=0;
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	s[0]=0;
	rep(i,n) s[i+1]=(s[i]+a[i]-1)%k;
	rep(i,n+1){
		if(i>=k) me[s[i-k]]--;
		out+=me[s[i]];
		me[s[i]]++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main() {
    bool detenai[26];
    for (int j = 0; j < 26; ++j) {
        detenai[j] = true;
    }
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); ++i) {
        if (detenai[S[i] - 97]) {
            detenai[S[i] - 97] = false;
        } else {
            cout << "no";
            return 0;
        }
    }
    cout << "yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))


int main() {
	int N, M;
	cin >> N >> M;
	string s;
	cin >> s;
	string rs = s;
	reverse(rs.begin(), rs.end());
	int c = 0;
	vector<int> v;
	while (c < rs.size() - 1) {
		int nxt = -1;
		for (int i = c + 1; i < rs.size() && i - c <= M; ++i) {
			if (rs[i] == '0') nxt = i;
		}
		if (nxt == -1) {
			PRI(-1);
			return 0;
		}
		v.push_back(nxt - c);
		c = nxt;
	}
	reverse(v.begin(), v.end());
	for (int x : v)printf("%d ", x);
	printf("\n");
	return 0;
}




Measured memory_bytes: 3980
#include <iostream>
#include <vector>
#define llint long long
#define inf 100000000000000000

using namespace std;

llint n;
llint a[5005];
vector<llint> G[5005];
llint dp[5005][5005][2];
llint dp2[5005][5005][2];
llint size[5005];

void dfs(int v, int p)
{
	size[v] = 1;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v);
		size[v] += size[G[v][i]];
	}
	
	llint sum = 1;
	for(int i = 0; i <= sum; i++){
		for(int j = 0; j < 2; j++){
			dp2[0][i][j] = inf;
		}
	}
	if(a[v] < 0) dp2[0][0][1] = a[v];
	else dp2[0][0][0] = a[v];
	
	
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p){
			for(int j = 0; j <= sum; j++){
				for(int k = 0; k < 2; k++){
					dp2[i+1][j][k] = dp2[i][j][k];
				}
			}
			continue;
		}
		int u = G[v][i];
		for(int j = 0; j <= sum+size[u]; j++){
			for(int k = 0; k < 2; k++){
				dp2[i+1][j][k] = inf;
			}
		}
		for(int j = 0; j <= sum; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l <= size[u]; l++){
					for(int m = 0; m < 2; m++){
						dp2[i+1][j+l][max(k, m)] = min(dp2[i+1][j+l][max(k, m)], dp2[i][j][k] + dp[u][l][m]);
						if((m == 0 && dp[u][l][m] < inf/2) || dp[u][l][m] < 0) dp2[i+1][j+l+1][k] = min(dp2[i+1][j+l+1][k], dp2[i][j][k]);
					}
				}
			}
		}
		sum += size[u];
	}
	for(int i = 0; i <= size[v]; i++){
		for(int j = 0; j < 2; j++){
			dp[v][i][j] = dp2[G[v].size()][i][j];
		}
	}
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	dfs(1, -1);
	
	int ans = n;
	for(int i = 0; i <= n; i++){
		if(dp[1][i][0] < inf/2) ans = min(ans, i);
		if(dp[1][i][1] < 0) ans = min(ans, i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 781184
#include<bits/stdc++.h>
#define Int int64_t
#define ll long long
#define pb push_back
using namespace std;
const Int MAXN=2005;
const int ALPHA=26;

Int N,K,M;
Int X,Y,Z;
Int A,B,C;
vector<Int> ID;
vector<Int> SZ;
int find(int x){
    if(ID[x]==x) return x;
    return find(ID[x]);
}
void Union(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(SZ[x]>SZ[y]){
        ID[y]=x;
        SZ[x]+=SZ[y];
    }
    else{
        ID[x]=y;
        SZ[y]+=SZ[x];
    }
    return;
}
string common_prefix(string s,string t){
    string ans="";
    for(int i=0;i<min(s.length(),t.length());++i){
        if(s[i]==t[i]) ans.pb(s[i]);
        else break;
    }
    return ans;
}
string LCP(vector<string> A,int l,int r){
    if(l>r) return "";
    if(l==r) return A[l];
    int mid=(l+r)/2;
    string left=LCP(A,l,mid);
    string right=LCP(A,mid+1,r);
    return common_prefix(left,right);
}
int main()
{
    int t;
    t=1;
    while(t--){
       cin>>N;
       vector<Int> A(N);
       for(auto &x:A) cin>>x;
       vector<Int> news;
       for(int i=0;i<N;++i){
           if(!news.size()||news.back()!=A[i]) news.pb(A[i]);
       }
       Int ans=0;
       Int have=1000;
       
       for(int i=0;i+1<news.size();++i){
           if(news[i]>=news[i+1]) continue;
           Int nbought=have/news[i];
           have-=nbought*news[i];
           have+=news[i+1]*nbought;
       }
       cout<<have<<"\n";
    }
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ll long long
#define uns using namespace std
uns;
ll ans;
void dfs(ll x,ll y)
{
    if(x%y==0)
	{
        ans+=x*2-y;
        return;
    }
    else
	{
        ans+=(x-x%y)*2;
        dfs(y,x%y);
    }
}
main()
{
	ll n,m;
    scanf("%lld%lld",&n,&m);
    ans=n,n-=m;
    dfs(max(n,m),min(n,m));
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

int main() {
    cin >> n;
    VVi edges(n);
    REP(i, n) {
        int u, k;
        cin >> u >> k;
        edges[i] = Vi(k);
        REP(j, k) {
            int v;
            cin >> v;
            v--;
            edges[i][j] = v;
        }
    }

    Vi dis(n, -1);
    queue<int> q;
    q.push(0);
    dis[0] = 0;
    while (!q.empty()) {
        int node = q.front();
        q.pop();
        FOR(i, edges[node]) {
            if (dis[*i] == -1) {
                dis[*i] = dis[node] + 1;
                q.push(*i);
            }
        }
    }
    REP(i, n) {
        printf("%d %d\n", i+1, dis[i]);
    }

    return 0;
}



Measured memory_bytes: 3300
H, W, K = map(int, input().split())
C = []
for _ in range(H):
    C.append(list(input()))

ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        c = C.copy()
        cnt = 0
        for a in range(H):
            for b in range(W):
                cell = c[a][b]
                if cell == '#':
                    cnt += 1
                if (i>>a & 1 or j>>b & 1) and cell == '#':
                    cnt -= 1
                    c[a][b] == '.'
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9204
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def main():
    N, K = iip(True)
    N = N % K
    N = min(N, (K-N))
    print(N)


def solve():
    N = iip(False)
    S = input()


#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_=mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:usize,
        m: usize,
    }

    let result = if n == m { "Yes" } else { "No" };

    println!("{}", result);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;
            var word = Console.ReadLine().Split(' ');
            n =int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);
            x = n * a;
            if (x<b)
            {
                Console.WriteLine(x);
            }
            else
            {
                Console.WriteLine(b);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n,z;
  cin>>n;
  if(n%2==0)
    cout<<n/2<<endl;
  else
  {
   z=n/2;
    cout<<z+1<<endl;
  }



    return 0;
}



Measured memory_bytes: 256
s = input()
od = []
ev = []

if len(s)==1:
    print(0)
else:
    for i in range(len(s)):
        if i%2 == 0:
            od.append(int(s[i]))
        else:
            ev.append(int(s[i]))
    
    a = len(od)-sum(od)+sum(ev)
    b = len(ev)-sum(ev)+sum(od)
    print(min(a,b))

Measured memory_bytes: 4052
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n;cin>>n;
        if(n==0)return 0;
        int a[n];
        rep(i,0,n)cin>>a[i];
        sort(a,a+n);
        int sum=0;
        rep(i,1,n-1)sum+=a[i];
        sum/=(n-2);
        cout<<sum<<endl;
    }
}










Measured memory_bytes: 3188
N, K = map(int, input().split())
A = [0 for i in range(100001)]
for i in range(N):
  a, b = map(int, input().split())
  A[a] += b
for i in range(100001):
  if A[i] < K:
    K -= A[i]
  else:
    print(i)
    break

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

template<class V,int ME>
class BIT{
public:
    V b[1<<ME];
    V operator()(int e){
        if(e < 0) return 0;
        V sum = 0;
        for(e++;e>0;e-=e&-e){
            sum += b[e-1];
        }
        return sum;
    }
    void add(int e,V v){
        for(e++;e<=1<<ME;e+=e&-e){
            b[e-1] += v;
        }
    }
};
BIT<int,20> bi[26];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    for(int i=0;i<n;++i){
        bi[s[i]-'a'].add(i,1);
    }
    for(int i=0;i<q;++i){
        int query;cin>>query;
        switch(query){
            case 1:
                int ir;char c;
                cin>>ir>>c;
                ir--;
                bi[s[ir]-'a'].add(ir,-1);
                s[ir] = c;
                bi[c-'a'].add(ir,1);
                break;
            case 2:
                int l,r;
                cin>>l>>r;
                l--;r--;
                int sum = 0;
                for(int j=0;j<26;++j){
                    if(bi[j](r) - bi[j](l-1))sum++;
                }
                cout << sum << endl;
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 107292
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int x = Integer.parseInt(line[1]);
        String[] xStr = sc.nextLine().split(" ");
        int ans = 0;
        for(int i=0;i<n;i++){
            if(i == 0){
                ans = Math.abs(Integer.parseInt(xStr[i]) - x);
            }else{
                ans = calc(Math.abs(Integer.parseInt(xStr[i]) - x), ans);
            }
        }
        System.out.println(ans);
    }
    
    public static int calc(int a, int b){
        int wk;
        if(a < b){
            wk = a;
            a = b;
            b = wk;
        }
        int rt = a % b;
        
        if(rt != 0){
            return calc(b, rt);
        }else{
            return b;
        }
    }
          
}

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

int main(void)
{
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> v;
    for (int i = 0; i < n; i++) {
        double w;
        cin >> w;
        v.push(w);
    }
    while (v.size() > 1) {
        double a, b;
        a = v.top();
        v.pop();
        b = v.top();
        v.pop();
        v.push((a + b) / 2.0);
    }
    cout << fixed << setprecision(10) << v.top() << endl;

    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    int a[N];
    int x = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < N; i++) {
        printf("%d ", x ^ a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4392
N = int(input())
h = list(map(int, input().split()))

dp = [1e7]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


Measured memory_bytes: 20420
#include <iostream>
#include <functional>

template <typename T>
struct node {
    T key;
    node* left;
    node* right;
    node* parent;
    node(T key):key(key), left(nullptr), right(nullptr), parent(nullptr) {}
};

template <typename T, typename Compare = std::less<T>>
class binary_search_tree {
public:
    binary_search_tree(): root(nullptr) {}

    bool insert(node<T>* z) {
        node<T>* trailer = nullptr;
        node<T>* head = root;
        while(head != nullptr) {
            trailer = head;
            if(Compare()(z->key, head->key)) {
                head = head->left;
            } else if(Compare()(head->key, z->key)){
                head = head->right;
            } else {
                break;
            }
        }

        z->parent = trailer;
        if(trailer == nullptr) {
            root = z;
        } else if(Compare()(z->key, trailer->key)) {
            trailer->left = z;
        } else if(Compare()(trailer->key, z->key)){
            trailer->right = z;
        } else {
            return false;
        }

        return true;
    }

    bool remove(node<T>* z) {

    }

    node<T>* find(T key) {
        node<T>* x = root;
        while(x != nullptr && key != x->key) {
            if(key < x->key) x = x->left;
            else x = x->right; 
        }
        return x;
    }

    void print_inorder() {
        inorder_tree_walk(root);
    }

    void print_preorder() {
        preorder_tree_walk(root);
    }

private:
    node<T>* root;

    void inorder_tree_walk(node<T>* x) {
        if(x == nullptr) return;
        inorder_tree_walk(x->left);
        std::cout << ' ' << x->key;
        inorder_tree_walk(x->right);
    }

    void preorder_tree_walk(node<T>* x) {
        if(x == nullptr) return;
        std::cout << ' ' << x->key;
        preorder_tree_walk(x->left);
        preorder_tree_walk(x->right);
    }
};

#include <string>
int main() {
    binary_search_tree<int> tree;
    int m; std::cin >> m;
    while(m--) {
        std::string query;
        std::cin >> query;
        if(query == "insert") {
            int key; std::cin >> key;
            auto z = new node<int>(key);
            tree.insert(z);
        } else {
            tree.print_inorder(); std::cout << std::endl;
            tree.print_preorder(); std::cout << std::endl;
        }
    }
}


Measured memory_bytes: 26580
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  long long x, y;
  cin >> x >> y;

  long long num = x;
  int count = 0;
  while(num <= y) {
    count++;
    num *= 2;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        #print("a")
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()


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

int lenght(char*str){ 
 int a=strlen(str);
 return a;
}

int main() {
    char str[100]; 
    cin >> str;
    int l = lenght(str);
 	int m = (l+1) / 2;
    int counter = 0;
    for (int i=0 ; i < m ; ++i) {
      	if (str[i] == str[l-i-1]) ++counter;
    }
 	int x = m - counter;
	cout << x << endl;
}

Measured memory_bytes: 256
import kotlin.math.ceil

fun main() {
    val nk = nextString()
    val ans = solve(nk)
    println(ans)



}

/**
777...の倍数　→　111...の7倍
 */
fun solve(k: String): String {
    val a = k.map {
        it.toString().toInt()
    }.sum()
    return if (a % 9 == 0) return "Yes" else "No"
}


fun mod(k: Int): Int {
    tailrec fun innerFunc(modSum: Int, plainMod: Int, count: Int): Int {
        return if (modSum == 0) {
            count
        } else {
            val newPlainMod = plainMod * 10

            val newModSum = if (modSum + newPlainMod < k) {
                modSum + newPlainMod
            } else {
                (modSum + newPlainMod) % k
            }
            innerFunc(newModSum, newPlainMod, count + 1)
        }
    }
    return innerFunc((1 % k), (1 % k), 1)
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 50788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	int x3 = x2 + (y1 - y2);
	int y3 = y2 - (x1 - x2);
	int x4 = x3 + (x1 - x2);
	int y4 = y3 + (y1 - y2);
	
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	
	return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
a = 'U'*abs(ty-sy)
b = 'R'*abs(tx-sx)
c = 'D'*abs(ty-sy)
d = 'L'*abs(tx-sx)
ans =''
ans += a+b+c+d
ans +='D'
ans +=b+'R'
ans += a + 'U'+'L'
ans += 'U'
ans +=d+'L'
ans += c +'D'+'R'
print(ans)

Measured memory_bytes: 61396
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    cin >> N >> K;

    double ans = 0.0;
    for (int n = 1; n <= N; ++n)
    {
        // cout << (1 << (int)ceil(log2((double)K / n))) << "\n";
        if (n < K)
        {
            ans += 1.0 / (1 << (int)ceil(log2((double)K / n))) / N;
        }
        else
        {
            // ans += 1.0 / N;
            ans += (double)(N - n + 1) / N;
            break;
        }
    }

    cout << setprecision(12) << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
let id x = x
let n = Scanf.scanf "%d\n" id
let ar = Array.init n (fun _ -> Scanf.scanf "%s " id)
let addbuf i b = Buffer.add_string b (ar.(i) ^ " ")

let f () =
  let b = Buffer.create n in
  let rec g i forward =
    if forward then
      if i >= n then Buffer.contents b
      else
        let () = addbuf i b in
        g (i + 2) true
    else
      match i with
      | i when i < 0 ->
        let () = addbuf 0 b in
        g 2 true
      | 0 ->
        let () = addbuf 0 b in
        g 1 true
      | _ ->
        let () = addbuf i b in
        g (i - 2) false
  in
  g (pred n) false


let () =
  (match n with 2 -> ar.(1) ^ ar.(0) | 1 -> ar.(0) | _ -> f ()) |> String.trim
  |> print_endline


Measured memory_bytes: 23296