akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),a=read(),b=read();
	if((b-a)%2==1){
		cout<<"Borys"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <numeric>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int r = 0, b = 0;
  string s;

  cin >> s;

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == '0')
    {
      r++;
    }
    else
    {
      b++;
    }
  }

  cout << 2 * min(r, b) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    vector<char>A(4);
    for(int i = 0;i < 4;i++)
        cin >> A.at(i);
    
    vector<int>B(4);
    for(int i = 0;i < 4;i++)
        B.at(i) = A.at(i) - 48;

    vector<char>op(3);

    bool fla = false;

    for(int tmp=0;tmp < (1 << 3);tmp++){
        bitset<3>s(tmp);

        int sum =B.at(0);

        for(int i = 0;i < 3;i++){
            if(s.test(i)){
                sum += B.at(i+1);
                op.at(i) = '+';
            }else{
                sum -= B.at(i+1);
                op.at(i) = '-';
            }
        }

        if(sum == 7){
            fla = true;
            break;
        }

    }

    cout << B.at(0) << op.at(0) << B.at(1) << op.at(1) << B.at(2) << op.at(2) << B.at(3);
    cout << "=7" << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

#define MAX 100001

using namespace std;

// input
int n;

int field[MAX];

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

    cin >> n;

    int a;
    for(int i = 0;cin >> a;i++){
        field[a]++;
    }

    int ans = 0;

    for(int i = 1;i < MAX-1;i++){
        if(ans < field[i-1]+field[i]+field[i+1]){
            ans = field[i-1]+field[i]+field[i+1];
        }
    }

    cout << ans << "\n";
    
}

Measured memory_bytes: 640
while True:
    l = []
#    x , y = reversed(list(map(int, input().split())))
    x , y = map(int, input().split())
    if (x,y) == (0,0):
        break
    #print(x,y,"*")

    if x<=y :
        def gcd(y, x):
            if x == 0:
                #print(l,x,y,"$")
                return y
            else:
                l.append(1)
                #print(l,x,y)
                return gcd(x, y % x) #再帰
        print(gcd(y,x),end="")
        print("",sum(l))
    elif x == y :
        print(x,1)

    else:
        def gcd(x, y):
            if y == 0:
                #print(l,x,y,"*")
                return x

            else:
                l.append(1)
                #print(l,x,y)
                return gcd(y, x % y) #再帰

        print(gcd(x,y),end="")
        print("",sum(l))


Measured memory_bytes: 5612
# include <stdio.h>
int main()
{
int n,k;
  scanf("%d %d",&n,&k);
  int a[n];
  for(int i=0;i<n;i++)
    a[i]=1;
  for(int i=0;i<k;i++)
  {
    int d;
    scanf("%d",&d);
    for(int j=0;j<d;j++)
    {
      int x;
      scanf("%d",&x);
      a[x-1]=0;
    }
  }
  int ctr=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]!=0)
      ctr++;
  }
  printf("%d",ctr);
  return 0;
}
  

Measured memory_bytes: 1736
#include<stdio.h>
int main(void){
	int a[100];
	int n,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	for(i=1;i<=n;i++){
		if(i!=1)printf(" ");
		printf("%d",a[n-i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	vector<pair<int,int>> Red(N);
	vector<pair<int,int>> Blue(N);
	for(int i = 0;i < N;i++) {
		int A,B;
		cin >> A >> B;
		Red.at(i) = make_pair(B,A);
	}
	for(int i = 0;i < N;i++) {
		int A,B;
		cin >> A >> B;
		Blue.at(i) = make_pair(A,B);
	}
  	sort(Red.begin(),Red.end());
  	reverse(Red.begin(),Red.end());
  	sort(Blue.begin(),Blue.end());
	int ret = 0;
	for(int i = 0;i < N;i++) {
		for(int j = 0;j < Red.size();j++) {
			if(Red[j].second < Blue[i].first && Red[j].first < Blue[i].second) {
				ret++;
              	Red.erase(Red.begin() + j);
				break;
			}
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>

int main(int argc, char* argv[])
{
  int N;  
  std::cin >> N;
  std::vector< int > vp(N, 0);

  for (int i = 0; i < N; i++) {
    std::cin >> vp[i];
  }

  int sum = std::accumulate(vp.begin(), vp.end(), 0);
  int max_val = *std::max_element(vp.begin(), vp.end());

  std::cout << sum - max_val / 2 << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		String s = r.str();		
		print(""+s.charAt(0) + (s.length()-2) +s.charAt(s.length()-1));
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21076
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int CS[] = {1, 5, 10, 50};

/* typedef */

/* global variables */

int ns[4], ds[4], minds[4];

/* subroutines */

int change(int pr) {
  int count = 0;
  for (int i = 3; i >= 0; i--) {
    int d = pr / CS[i];
    pr -= d * CS[i];
    count += d;
  }

  return count;
}

/* main */

int main() {
  for (bool first = true;; first = false) {
    int pr;
    cin >> pr;
    if (pr == 0) break;
    pr /= 10;
    
    for (int i = 0; i < 4; i++)
      cin >> ns[i], ds[i] = 0, minds[i] = 25;

    int minsum = 100;

    for (;;) {
      int pay = 0;
      for (int i = 0; i < 4; i++)  pay += CS[i] * ds[i];

      if (pay >= pr) {
	int count = 0;
	for (int i = 0; i < 4; i++)  count += ns[i] - ds[i];
	count += change(pay - pr);
	if (minsum > count) {
	  minsum = count;
	  for (int i = 0; i < 4; i++)  minds[i] = ds[i];
	}
      }

      int k = 0;
      while (k < 4) {
	ds[k]++;
	if (ds[k] <= ns[k]) break;
	ds[k++] = 0;
      }
      if (k >= 4) break;
    }

    if (! first) putchar('\n');
  
    for (int i = 0; i < 4; i++) {
      if (minds[i] > 0)
	printf("%d %d\n", CS[i] * 10, minds[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 1144
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int x, a;
	while(cin >> x >> a) {
		if(x <a) {
			cout << 0 << endl;
		} else {
			cout << 10 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long>P;
#define F first
#define ll long long
#define S second
int main(){
  long long  n;
  long long  a,b,cost,pos;
  
  long long  INF=1<<27*1<<27;

  vector<P>graph[100002];
  priority_queue<P,vector<P>,greater<P> >p_que;
  long long q,k;
  long long min_cost[100002];
  
  cin >> n;
  for(int i=0;i<n-1;i++){
    scanf("%lld %lld %lld",&a,&b,&cost);
    graph[a].push_back(P(cost,b));
    graph[b].push_back(P(cost,a));
  }
  
  cin >> q >> k;
  
  p_que.push(P(0,k));
  for(int i=0;i<=n;i++){
    min_cost[i]=1000000000;
    min_cost[i]*=10000000;
  }
  min_cost[k]=0;

  while(!p_que.empty()){
    P now=p_que.top();
    p_que.pop();
    cost=now.F;
    pos=now.S;
    for(int i=0;i<graph[pos].size();i++){
      long long next=graph[pos][i].S;
      long long ncost=cost+graph[pos][i].F;
      if(ncost<min_cost[next]){
	min_cost[next]=ncost;
	p_que.push(P(ncost,next));
      }
    }
  }

  for(int i=0;i<q;i++){
    cin >> a >> b;
    long long  ans=min_cost[a]+min_cost[b];
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  Graph sum(2,vector<int>(110,0));
  rep(i,2) rep(j,n){
    int a;
    cin>>a;
    sum[i][j+1]=sum[i][j]+a;
  }
  //rep(i,2) rep(j,n) cout<<sum[i][j+1]<<endl;
  int ans=0;
  rep(i,n){
    int temp=0;
    temp+=sum[0][i+1]-sum[0][0];
    temp+=sum[1][n]-sum[1][i];
    //cout<<temp<<endl;
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
}


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

int p;

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

int inverse(int a){
	return power(a, p - 2);
}

vector<vector<int>> Vandermonde_inverse(){
	int i, j;
	vector<vector<int>> ans(p, vector<int>(p, 0));
	vector<vector<int>> dp(p, vector<int>(p, 0));
	dp[0][0] = 1;
	for(i = 1; i < p; i++){
		dp[i][0] = 1;
		for(j = 1; j < p; j++){
			dp[i][j] = MOD(dp[i - 1][j] + i * dp[i - 1][j - 1]);
		}
	}
/*	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
		}
		printf("\n");
	}
	printf("\n");
*/	for(i = 0; i < p; i++){
		ans[i][p - 1] = 1;
		for(j = p - 2; j >= 0; j--){
			ans[i][j] = MOD(dp[p - 1][p - j - 1] - i * ans[i][j + 1]);
		}
	}
/*	printf("f\n");
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			printf("%d ", ans[i][j]);
		}
		printf("\n");
	}
	printf("\n");
*/	for(i = 0; i < p; i++){
		int c = 1;
		for(j = 0; j < p; j++){
			if(j != i){
				c = MOD(c * (i - j));
			}
		}
//		printf("c1[%d] = %d\n", i, c);
		c = inverse(c);
//		printf("c2[%d] = %d\n", i, c);
		for(j = 0; j < p; j++){
			ans[i][j] = MOD(ans[i][j] * c);
			if((p - j) % 2 == 0){
				ans[i][j] = MOD(-ans[i][j]);
			}
		}
	}
	return ans;
}

vector<vector<int>> mul(vector<vector<int>> a, vector<vector<int>> b){
	vector<vector<int>> c(p, vector<int>(p, 0));
	int i, j, k;
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			for(k = 0; k < p; k++){
				c[i][j] = MOD(c[i][j] + a[i][k] * b[k][j]);
			}
		}
	}
	return c;
}

int main(){
	int i, j;
	scanf("%d", &p);
	vector<int> a(p);
	for(i = 0; i < p; i++){
		scanf("%d", &a[i]);
	}
	vector<vector<int>> V_inv = Vandermonde_inverse();
/*	printf("V_inv\n");
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			printf("%d ", V_inv[i][j]);
		}
		printf("\n");
	}
	vector<vector<int>> V(p, vector<int>(p, 0));
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			V[i][j] = power(j, i);
		}
	}
	printf("V\n");
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			printf("%d ", V[i][j]);
		}
		printf("\n");
	}
	vector<vector<int>> VxV_inv = mul(V, V_inv);
	printf("VxV_inv\n");
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			printf("%d ", VxV_inv[i][j]);
		}
		printf("\n");
	}
*/	vector<int> b(p, 0);
	for(i = 0; i < p; i++){
		for(j = 0; j < p; j++){
			b[i] = MOD(b[i] + a[j] * V_inv[j][i]);
		}
	}
	for(i = 0; i < p; i++){
		printf("%d ", b[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 72884
n, m, x = map( int, input().split())
lis = []
for i in range(n):
    lis.append( list( map( int, input().split())))

pattern = []
for i in range(2**n):
    tmp = [0 for i in range(n)]
    for j in range(n):
        if i >> j & 1:
            tmp[j] = 1
    pattern.append(tmp)

ans = []
for i in pattern:
    l = [0 for j in range(m+1)]
    for j in range(n):
        if i[j]:
            for k in range(m+1):
                l[k] += lis[j][k]
    
    flag = 1
    for j in range(1, m+1):
        if l[j] < x:
            flag = 0
            break
    if flag:
        ans.append(l[0])
if not len(ans):
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 9872
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n,qk;
vector<int> vs[2005];
mp es[2005];

int cun(int no,int p,int d){
	int res=0;
	rep(i,vs[no].size()){
		if(vs[no][i]==p)continue;
		res+=cun(vs[no][i],no,d-1);
	}
	if(d<0)res++;
	return res;
}

int main(void){
	scanf("%d%d",&n,&qk);
	rep(i,n-1){
		int a,b;
		scanf("%d%d",&a,&b);a--; b--;
		vs[a].push_back(b);
		vs[b].push_back(a);
		es[i]=mp(a,b);
	}
	
	int ans=5000;
	rep(i,n){
		int na=cun(i,-1,qk/2);
		ans=min(ans,na);
	}
	
	rep(i,n-1){
		int a=es[i].fir,
			b=es[i].sec;
		int na=cun(a,b,(qk-1)/2);
		na+=cun(b,a,(qk-1)/2);
		ans=min(ans,na);
	}
	
	printf("%d\n",ans);
	return 0;
}






Measured memory_bytes: 512
#include<stdio.h>
#include<ctype.h>
int main(void){
    int c;
    int  cnt[256] = {0};
    while((c = getchar()) != EOF){
        if(isupper(c)){
            c += 32;
        }
        cnt[c] ++;
        
    }
    for(c = 'a'; c <= 'z'; c ++ ){
        printf("%c : %d\n",c,cnt[c]);
    }
    return 0;
    
}

Measured memory_bytes: 524
import math

class dot():
    def __init__(self, x, y):
        self.x = x
        self.y = y


def koch(n, p1, p2):
    if n != 0:
        r = 60.0*math.pi/180.0

        x = (2.0*p1.x+1.0*p2.x)/3.0
        y = (2.0*p1.y+1.0*p2.y)/3.0
        s = dot(x, y)

        x = (1.0*p1.x+2.0*p2.x)/3.0
        y = (1.0*p1.y+2.0*p2.y)/3.0
        t = dot(x, y)

        x = (t.x-s.x)*math.cos(r) - (t.y-s.y)*math.sin(r) + s.x
        y = (t.x-s.x)*math.sin(r) + (t.y-s.y)*math.cos(r) + s.y
        u = dot(x, y)

        koch(n-1, p1, s)
        print(s.x, ' ', s.y)
        koch(n-1, s, u)
        print(u.x, ' ', u.y)
        koch(n-1, u, t)
        print(t.x, ' ', t.y)
        koch(n-1, t, p2)


p1 = dot(0.0, 0.0)
p2 = dot(100.0, 0.0)
n = int(input())

print(p1.x, ' ', p1.y)
koch(n, p1, p2)
print(p2.x, ' ', p2.y)



Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    int a, b, s = 0;
    scan(a, b);
    if(a == 1)
        s += 300000;
    if(a == 2)
        s += 200000;
    if(a == 3)
        s += 100000;
    
    if(b == 1)
        s += 300000;
    if(b == 2)
        s += 200000;
    if(b == 3)
        s += 100000;
    
    if(a == 1 && b == 1)
        s += 400000;
    
    print(s);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define max 100005
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

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

    ll x=n;
    if(n>=b-1){
        x=b-1;
    }
    ll result=(a*x)/b-a*(x/b);
    cout<<result<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,a,b; cin>>n>>a>>b;
  vector<ll> h(n);
  rep(i,n) cin>>h[i];
  
  ll l=0, r=1e9+10;
  while((r-l)>1){
    ll m=(r+l)/2;
    
    bool ok=true;
    ll cnt=0;
    rep(i,n){
      ll rem=h[i]-b*m;
      if(rem<=0) continue;
      cnt+=(rem+(a-b)-1)/(a-b);
      if(cnt>m){
        ok=false;
        break;
      }
    }
    if(ok) r=m;
    else l=m;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   // log(a/b) = log(x^(1/5))
   ll x ;
   cin >> x ;
   ll a = 0 ;
   const ll inf = 1e18 ;
   ll b = inf ;
   while(powl(a,5)<=(1e18)){
        ll d = abs(powl(a,5)-x);
        //cout << a << " " <<  d << "\n" ;
        // 5log z = log d
        ll z = powl(d,0.2);
        if(powl(z,5)==d){
            b = z ;
            if(powl(a,5)-x<0)
                b *=-1;
            break ;
        }
        a++;
   }
   cout << a << " " << b ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}


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

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int[] data=new int[5];
        for(int i=0;i<5;i++){
            data[i]=Integer.parseInt(st.nextToken());
        }Arrays.sort(data);
        for(int i=4;i>0;i--){
            System.out.print(data[i]+" ");
        }System.out.println(data[0]);
    }
}

Measured memory_bytes: 24184
#include <bits/stdc++.h>
using namespace std;
#define For(i, n) for(int i = 1; i <= n; ++i)

int max2(int x, int y) {
    if(x > y) return x;
    else return y;
}

int max3(int x, int y, int z) {
    return max2(x, max2(y, z));
}

int main() {
    int n;
    cin >> n;
    int a[n + 1], b[n + 1], c[n + 1];
    For(i, n) {
        cin >> a[i] >> b[i] >> c[i];
    }
    For(i, n - 1) {
        a[i + 1] += max2(b[i], c[i]);
        b[i + 1] += max2(a[i], c[i]);
        c[i + 1] += max2(a[i], b[i]);
    }
    cout << max3(a[n], b[n], c[n]);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    ll dif = abs(x-y);
    if(dif <= 1){
        cout << "Brown\n";
    }else{
        cout << "Alice\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<queue>
#include<bitset>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
# define Type template<typename T>
# define ll long long
# define ull unsigned ll
# define read read1<int>()
Type inline T read1(){
    T t=0;
    char k;
    bool fl=0;
    do k=getchar(),(k=='-')&&(fl=1);while('0'>k||k>'9');
    while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
    return fl?-t:t;
}
int a[200005];
int main(){
    int s=read;
    ll ans=0;
    for(int i=1;i<=s;++i){
        int v=read;
        if(v<i)ans+=a[i-v];
        if(i+v<=s)++a[i+v];
    }
    printf("%lld",ans);
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  vector<int>a(3);
  for(int i=0;i<3;i++)cin>>a[i];
  sort(rng(a));
  int X=10*a[2]+a[1];
  int Y=a[0];
  cout<<X+Y<<endl;
  return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll A, B; char op;
	cin >> A >> op >> B;

	if (op == '+')cout << A + B << endl;
	else cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  
  	int counter = 1000000000;
  
    for(int i=0; i<N; ++i){
        int A;
        cin >> A;
      	int local_counter = 0;
      
      	while(true){
        	if (A%2 == 0){
            	local_counter += 1;
              	A=A/2;
              	
            }else{
            	break;
            }
        }
      
        if (local_counter < counter) counter = local_counter;

    }
  
  	cout << counter << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

const ll mod = 998244353;
const int h = 90010;
const int m = 310;

int n;
ll a[m];
ll sum;

ll dp[m][h];
//iまでで赤がx
ll dp2[m][h];
//赤か青にしか入れない

ll power_ll_p(ll a, ll b, ll p)	//F_pでのべき
{
  if (b > p)
  {
    b %= (p - 1);//位数p-1
  }
  if (b == 0)
  {
    return 1;
  }
  if (b % 2 == 0)
  {
    ll t = power_ll_p(a, b / 2, p);
    return t * t % p;
  }
  else
  {
    return a * power_ll_p(a, b - 1, p) % p;
  }
}

int main()
{
  cin >> n;
  sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }

  for (int x = 0; x < sum + 1; x++)
  {
    for (int i = 0; i < m; i++)
    {
      dp[i][x] = 0;
      dp2[i][x] = 0;
    }
  }
  dp[0][0] = 1;
  dp2[0][0] = 1;

  for (int i = 1; i <= n; i++)
  {
    for (int x = 0; x < sum + 1; x++)
    {
      dp[i][x] = 2 * dp[i - 1][x];
      dp[i][x] %= mod;
      dp2[i][x] = dp2[i - 1][x];
      dp2[i][x] %= mod;
      if (x >= a[i - 1])
      {
        dp[i][x] += dp[i - 1][x - a[i - 1]];
        dp[i][x] %= mod;
        dp2[i][x] += dp2[i - 1][x - a[i - 1]];
        dp2[i][x] %= mod;
      }
    }
  }

  ll ans = 0;
  ll ans2 = 0;
  for (int x = (sum + 1) / 2; x < sum + 1; x++)
  {
    ans += dp[n][x];
    ans %= mod;
  }
  if (sum % 2 == 0)
  {
    ans2 = dp2[n][sum / 2];
    ans2 %= mod;
  }
  cout << (power_ll_p(3, n, mod) - 3 * ans + 3 * ans2  + 10 * mod) % mod << "\n";
}

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

int n;
priority_queue<double,vector<double>,greater<double> > pq;

int main()
{
	cin>>n;
	for(int i=1,x;i<=n&&cin>>x;i++)
		pq.push(x*1.0);
	for(int i=1;i<n;i++)
	{
		double u=pq.top(),v;
		pq.pop();
		v = pq.top();
		pq.pop();
		pq.push((u+v)/2);
	}
	cout<<pq.top()<<endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    if a + b >= 10 {
        println!("error");
    } else {
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000

int main() {
	string s, ans;
	int k;
	cin >> k >> s;

	if (s.size() > k) {
		ans = s.substr(0, k) + "...";
	} else {
		ans = s;
	}

	cout << ans;
	return 0;
}

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

const int Nmax = 101;

string s[Nmax];
int f[300];
int ct[5];

int main() {

    int n,m,k;
    cin>>n>>m;
    
    for(int i=0; i<n; i++) {
        cin>>s[i];
        for(auto it : s[i]) {
            f[it] ++;
        }
    }
    
    for(char c='a'; c<='z'; c++) {
        ct[f[c]%4]++;
    }
    
    if(n%2 && m%2) {
        if(ct[1]!=0 && ct[3]!=0) {
            cout<<"No\n";
            return 0;
        }
        if(ct[1]!=0) {
            ct[1]--;
        }
        if(ct[3]!=0) {
            ct[3]--;
        }
    }
    
    if(ct[1]!=0 || ct[3]!=0) {
        cout<<"No\n";
        return 0;
    }
    
    int ctl = 0;
    if(n%2){
        ctl += m/2;
    }
    if(m%2){
        ctl += n/2;
    }
    
    if(ct[2] > ctl) {
        cout<<"No\n";
        return 0;
    }

    cout<<"Yes\n";
    return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  fastio();

  string s;
  cin >> s;

  bool ok = true;
  forn(i,s.size()) {
    if (i % 2 == 0) {
      ok &= (s[i] == 'R' || s[i] == 'U' || s[i] == 'D');
    } else {
      ok &= (s[i] == 'L' || s[i] == 'U' || s[i] == 'D');
    }
  }

  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using prior = priority_queue<T>;

const ll MOD = 1e9+7;
const ll SPMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define Unique(v) v.rs(unique(ALL(v))-v.begin())
#define EB emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

// template
ll POW();
int gcd(int a, int b);
// end of template

#define N 200010

void solve(){
    int n, m, k;
    string s;
    
    cin >> n >> m >> k >> s;
    for(auto &i:s) i = (i == 'o');
    
    int l[N] = {}, r[N] = {};
    int mx = 0;
    
    rep1(i, n){
        mx = l[max(0, i-k-1)];
        l[i] = max(l[i-1], mx + s[i-1]);
    }
    
    mx = 0;
    for(int i=n; i>0; i--){
        mx = r[min(n+1, i+k+1)];
        r[i] = max(r[i+1], mx + s[i-1]);
    }
    
    rep1(i, n) if(s[i-1]){
        if(l[i-1] + r[i+1] < m) cout << i << '\n';
    }
    cout << '\n';
}


int main(){
    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


// templates

ll POW(ll a, ll b, ll m = MOD){
    ll res = 1;
    while(b){
        if(b&1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}


Measured memory_bytes: 3348
n = gets.to_i
a = gets.split.map &:to_i
cnt=0
(0..n-1).each do |i|
  (n-1).downto(i+1) do |j|
    if a[j]<a[j-1]
      tmp=a[j]
      a[j]=a[j-1]
      a[j-1]=tmp
      cnt+=1
    end
  end
end

puts a*' '
puts cnt

Measured memory_bytes: 6108
s = list(map(int,input().split()))
a = 0
if s[2] >= s[0]:
    a = s[2] - s[0]
    s[0] = 0
    if a >= s[1]:
        s[1] = 0
    else:
        s[1] = s[1] - a
else:
    s[0] = s[0] - s[2]

print(str(s[0]) + ' ' + str(s[1]))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(3*N);
    rep(i, 3*N) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    for (int i = N; i < 3*N; i+=2) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 100400
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define nl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
ll get(ll n,ll base){
	ld lg=log(n)/log(base);
	ll lo=lg;
	return lo;
}
void solve(){
	ll i,n;
	cin>>n;
	ll ans=n;
	nfl(i,n+1){
		ll lf=i;
		ll temp=0;
		while(lf>0){
			temp+=lf%9;
			lf/=9;
		}
		ll rf=n-i;
		while(rf>0){
			temp+=rf%6;
			rf/=6;
		}
		ans=min(ans,temp);
	}
	cout<<ans<<endl;

}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
*C, = map(int,input().split())

connect = [[] for _ in [0]*N]
for a,b in AB:
    connect[a-1].append(b-1)
    connect[b-1].append(a-1)
d = [-1]*N
d[0] = 0
q = [0]
while q:
    qq = []
    for i in q:
        for j in connect[i]:
            if d[j] == -1:
                d[j] = d[i]+1
                qq.append(j)
    q = qq

o = sorted(zip(d,range(N)),key =lambda x:-x[0])
C.sort()
ans = [0]*N
for j,tmp in enumerate(o):
    d,i = tmp
    ans[i] = C[j]
print(sum(C)-C[-1])
print(*ans)

Measured memory_bytes: 53208
#全然賢いやり方あるはず
(a,b,c,d,e,f,g,h,i_i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)\
    = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
while True:
    try:
        string = list(input())
    except:
        break
    for i in string:
            if i=="a" or i=="A":
                a += 1
            elif i=="b" or i=="B":
                b += 1
            elif i=="c" or i=="C":
                c += 1
            elif i=="d" or i=="D":
                d += 1
            elif i=="e" or i=="E":
                e += 1
            elif i=="f" or i=="F":
                f += 1
            elif i=="g" or i=="G":
                g += 1
            elif i=="h" or i=="H":
                h += 1
            elif i=="i" or i=="I":
                i_i += 1
            elif i=="j" or i=="J":
                j += 1
            elif i=="k" or i=="K":
                k += 1
            elif i=="l" or i=="L":
                l += 1
            elif i=="m" or i=="M":
                m += 1
            elif i=="n" or i=="N":
                n += 1
            elif i=="o" or i=="O":
                o += 1
            elif i=="p" or i=="P":
                p += 1
            elif i=="q" or i=="Q":
                q += 1
            elif i=="r" or i=="R":
                r += 1
            elif i=="s" or i=="S":
                s += 1
            elif i=="t" or i=="T":
                t += 1
            elif i=="u" or i=="U":
                u += 1
            elif i=="v" or i=="V":
                v += 1
            elif i=="w" or i=="W":
                w += 1
            elif i=="x" or i=="X":
                x += 1
            elif i=="y" or i=="Y":
                y += 1
            elif i=="z" or i=="Z":
                z += 1

print("a : "+str(a))
print("b : "+str(b))
print("c : "+str(c))
print("d : "+str(d))
print("e : "+str(e))
print("f : "+str(f))
print("g : "+str(g))
print("h : "+str(h))
print("i : "+str(i_i))
print("j : "+str(j))
print("k : "+str(k))
print("l : "+str(l))
print("m : "+str(m))
print("n : "+str(n))
print("o : "+str(o))
print("p : "+str(p))
print("q : "+str(q))
print("r : "+str(r))
print("s : "+str(s))
print("t : "+str(t))
print("u : "+str(u))
print("v : "+str(v))
print("w : "+str(w))
print("x : "+str(x))
print("y : "+str(y))
print("z : "+str(z))



Measured memory_bytes: 5596
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve=fst.foldl' f(1,EQ).(zipWith compare=<<tail).tail
f(k,a)b
  |b==EQ || a==b=(k,a)
  |a==EQ=(k,b)
  |otherwise=(k+1,EQ)

Measured memory_bytes: 6804
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);

		while(true)
		{
			int n;
			int count = 0;
			try
			{
				n = sc.nextInt();
			}
			catch (Exception e)
			{
				break;
			}
			for (int a = 0; a < 10; a++)
				for (int b = 0; b < 10; b++)
					for (int c = 0; c < 10; c++)
						for (int d = 0; d < 10; d++)
							if (a + b + c + d == n) count++;
			System.out.println(Integer.toString(count));
		}
	}
}

Measured memory_bytes: 12000
# 解説と 提出 #15122924 を参考に作成.
# 遅い. PyPyで出すと通る. はず.

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, X, Y, P):
    inf = 10 ** 18
    cnb_N = 2 ** N
    # 前計算
    # # 集落の部分集合毎の、Y軸X軸へのそれぞれの最短経路
    to_x = [[0] * N for _ in range(cnb_N)]
    to_y = [[0] * N for _ in range(cnb_N)]
    for cn in range(cnb_N):
        for n in range(N):
            to_x[cn][n] = abs(X[n]) * P[n]
            to_y[cn][n] = abs(Y[n]) * P[n]
            for n2 in range(N):
                if cn >> n2 & 1:
                    to_x[cn][n] = min(to_x[cn][n], abs(X[n] - X[n2]) * P[n])
                    to_y[cn][n] = min(to_y[cn][n], abs(Y[n] - Y[n2]) * P[n])

    # 実計算
    # # 各集落の集合に対して、Y軸を取った場合とX軸を取った場合で最短となる経路を算出
    ans = [inf] * (N + 1)
    for cn in range(cnb_N):
        count = 0
        for i in range(N):
            count += 1 if cn >> i & 1 else 0
        cn2 = cn
        while cn2 >= 0:
            cn2 = cn2 & cn
            subsum = 0
            for n in range(N):
                if not (cn >> n & 1):
                    subsum += min(to_x[cn - cn2][n], to_y[cn2][n])
            ans[count] = min(ans[count], subsum)
            cn2 -= 1

    for n in range(N + 1):
        print(ans[n])


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    X, Y, P = [], [], []
    for _ in range(N):
        tmp = [int(i) for i in input().split()]
        X.append(tmp[0])
        Y.append(tmp[1])
        P.append(tmp[2])
    solve(N, X, Y, P)


Measured memory_bytes: 88612
#include<bits/stdc++.h>
using namespace std;
struct Node{
  string name;
  int time, over, id;
  bool operator<(const Node& that)const{
    return over < that.over;
  }
};
int main(){
  int n, q;
  cin >> n >> q;
  vector<Node>v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i].name >> v[i].time;
    v[i].id = i;
  }
  deque<Node>D(v.begin(), v.end());
  int cur = 0;
  while(D.size()){
    Node head = D.front();
    if(head.time <= q){
      cur += head.time;
      v[head.id].over = cur;
    }else{
      head.time -= q;
      cur += q;
      D.push_back(head);
    }
    D.pop_front();
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    cout << v[i].name << " " << v[i].over << endl;
  }
}


Measured memory_bytes: 7560
n=int(input())
a=[int(i) for i in input().split()]
min=0
for i in range(-100,101):
    sum=0
    for j in range(n):
        sum=sum+(a[j]-i)**2
    if i==-100:
        min=sum
    elif sum<min:
        min=sum
print(min)

Measured memory_bytes: 3064
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [A[i]+B[j] for i in range(X) for j in range(Y)]
AB = sorted(AB,reverse=True)[:K]
ABC = [AB[i]+C[j] for i in range(len(AB)) for j in range(Z)]
ABC = sorted(ABC,reverse=True)[:K]
for one in ABC:
    print(one)

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

int SumOfDigits(int a){
    int sum = 0;
    while (a > 0){
        sum += a % 10;
        a /= 10;
    }
    return sum;
}

int main(){
    int N,A,B,sum = 0;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++){
        if (SumOfDigits(i) >= A && SumOfDigits(i) <= B) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int n=s.size();
    int count=0;
    int ans=0;
    int gc=0;
    rep(i,n){
        if(gc==0){
            if(s[i]=='g'){
                //g vs g
                gc++;
            }
            else{
                ans--;
                gc++;
            }
        }
        else{
            if(s[i]=='g'){
                gc--;
                ans++;
            }
            else{          
                gc--;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target ("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int x; cin >> x;
	for(int i{-200}; i<200; ++i)
		for(int j{-200}; j<i; ++j){
			if(pow(i, 5)-pow(j, 5) == x){
				return cout << i << " " << j << "\n", 0;
			}
		}
}


Measured memory_bytes: 4056