akhauriyash/Code-Regression huggingface dataset:
//⣿⣿⣿⣿⣿⣿⠟⠋⠁⣀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿
//⣿⣿⣿⣿⠋⠁⠀⠀⠺⠿⢿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠻⣿
//⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⣤⠀⠀⠀⠀⠀⣤⣦⣄⠀⠀
//⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⠏⣿⣿⣿⣿⣿⣁⠀⠀⠀⠛⠙⠛⠋⠀⠀
//⡿⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⣰⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀
//⡇⠀⠀⠀⠀⠀⠀⠀⠸⠇⣼⣿⣿⣿⣿⣿⣷⣄⠘⢿⣿⣿⣿⣅⠀⠀⠀⠀⠀⠀⠀⠀
//⠁⠀⠀⠀⣴⣿⠀⣐⣣⣸⣿⣿⣿⣿⣿⠟⠛⠛⠀⠌⠻⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣶⣮⣽⣰⣿⡿⢿⣿⣿⣿⣿⣿⡀⢿⣤⠄⢠⣄⢹⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣿⣿⣿⣿⣿⡘⣿⣿⣿⣿⣿⣿⠿⣶⣶⣾⣿⣿⡆⢻⣿⣿⠃⢠⠖⠛⣛⣷⠀
//⠀⠀⢸⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣮⣝⡻⠿⠿⢃⣄⣭⡟⢀⡎⣰⡶⣪⣿⠀
//⠀⠀⠘⣿⣿⣿⠟⣛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿⢁⣾⣿⢿⣿⣿⠏⠀
//⠀⠀⠀⣻⣿⡟⠘⠿⠿⠎⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣵⣿⣿⠧⣷⠟⠁⠀⠀
//⡇⠀⠀⢹⣿⡧⠀⡀⠀⣀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⢰⣿⠀⠀⠀⠀
//⡇⠀⠀⠀⢻⢰⣿⣶⣿⡿⠿⢂⣿⣿⣿⣿⣿⣿⣿⢿⣻⣿⣿⣿⡏⠀⠀⠁⠀⠀⠀⠀
//⣷⠀⠀⠀⠀⠈⠿⠟⣁⣴⣾⣿⣿⠿⠿⣛⣋⣥⣶⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⡀ 
//
//⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣴⢟⣛⡀⠀⠀⣸⢿⣇⠀ 
//⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⢿⣮⣽⡇⠀⢠⡿⠶⣿⡄ 
#include <bits/stdc++.h>
#define DEBUG false
#define debugf if (DEBUG) printf
#define MAXN 150001
#define MAXM 900009
#define MAXLOGN 20
#define ALFA 256
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define PI 3.141592653589793238462643383279502884
#define FOR(x,n) for(int x=0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) for(int x=int(n)-1; (x)>=0; (x)--)
#define REP1(x,n) for(int x=(n); (x)>0; (x)--)
#define pb push_back
#define pf push_front
#define pr printf
#define sc(x) scanf("%d", &x)
#define sc2(x, y) sc(x);sc(y)
#define sc3(x, y, z) sc2(x, y);sc(z)
#define scll(x) scanf("%lld", &x)
#define sc2ll(x, y) scll(x);scll(y)
#define sc3ll(x, y, z) sc2ll(x, y);scll(z)
#define ff first
#define ss second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x,y) memset(&x, (y), sizeof(x))
#define LOWBIT(A) (A & -A)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair <ll, ll> pll;
typedef pair < pll, ll > plll;

int main(){
    ll n;
    scll(n);
    pr("%lld\n", n * n);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

ll lucas(ll n, vector<ll> &memo) {
  if (n == 0) {
    return 2;
  } else if (n == 1) {
    return 1;
  }
  if (memo[n] != -1) {
    return memo[n];
  }
  return memo[n] = lucas(n - 1, memo) + lucas(n - 2, memo);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> memo(n + 1, -1);
  cout << lucas(n, memo) << endl;

  return 0;
}

Measured memory_bytes: 256
k = int(input())
X = [1,2,3,4,5,6,7,8,9]

start = 0
end = 9
while k > len(X):
    for i in range(end-start):
        n = str(X[start+i])
        # print(n)
        if int(n[-1])-1 >= 0:
            X.append(int(n+str(int(n[-1])-1)))
        X.append(int(n+str(n[-1])))
        if int(n[-1])+1 <= 9:
            X.append(int(n+str(int(n[-1])+1)))
    start = end
    end = len(X)
    # print(X)
print(X[k-1])        


Measured memory_bytes: 10968
package main

import (
	"bufio"
	"fmt"
	"os"
)

var H, W int

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1000000)
	fmt.Scan(&H, &W)

	q := make([][]int, 0)
	m := make([][]bool, H)

	for i := 0; i < H; i++ {
		line, _, _ := reader.ReadLine()
		m[i] = make([]bool, W) // Falseで初期化されている

		for j, v := range line {
			if string(v) == "#" {
				q = append(q, []int{i, j})
				m[i][j] = true
			}
		}
	}
	fmt.Println(bfs(q, m))
}

func bfs(q [][]int, m [][]bool) int {
	var ans int

	for len(q) != 0 {
		ans++
		len := len(q)

		for i := 0; i < len; i++ {
			var y, x int = q[0][0], q[0][1]
			q = append(q[1:])

			if 0 <= y+1 && y+1 < H && m[y+1][x] == false {
				m[y+1][x] = true
				q = append(q, []int{y + 1, x})
			}
			if 0 <= y-1 && y-1 < H && m[y-1][x] == false {
				m[y-1][x] = true
				q = append(q, []int{y - 1, x})
			}
			if 0 <= x+1 && x+1 < W && m[y][x+1] == false {
				m[y][x+1] = true
				q = append(q, []int{y, x + 1})
			}
			if 0 <= x-1 && x-1 < W && m[y][x-1] == false {
				m[y][x-1] = true
				q = append(q, []int{y, x - 1})
			}
		}
	}
	return ans - 1
}


Measured memory_bytes: 114688
#include <bits/stdc++.h>
using namespace std;
int test(int n, int k) {
    int cnt = 0;
    for(int a = 1;a <= n;a++) {
        for(int b = 1; b <= n;b++){
            for(int c = 1; c <= n;c++) {
                if(((a + b) % k) == 0 && ((b + c) % k) == 0 && ((a + c) % k) == 0) {
                    cnt++;
                    //cout << a << "," << b << "," << c << endl;
                }
            }
        }

    }
    return cnt;
}

long long Ansm(long long n, long long k) {
    long long n0 = n / k;
    long long nk2 = 0;
    if(k % 2 == 0 && n >= (k / 2)) {
        nk2 = (n - (k / 2)) / k + 1;
    }
    long long result = n0 * n0 * n0;
    long long result2 = nk2 * nk2 * nk2;
    long long cnt = result + result2;
    return cnt;
}

int main() {
    long long n, k;
    cin >> n;
    cin >> k;

    cout << Ansm(n, k) << endl;
    //cout << test(99, 99);
/*    for(n = 1;n < 200;n++) {
        for(k = 1;k < 200;k++) {
            if(Ansm(n, k) != test(n, k)) {

                cout << n << "," << k  << "," << Ansm(n, k) << "," << test(n, k) << endl;
            }

        }

    }*/
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	map<string,ll> mp;
	while(n--)
	{
		string s;cin>>s;mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=n;
		int[] num = new int[n];
		for (int a=0;a<x;a++){
			n=sc.nextInt();
			num[a]=n;
		}
		for (int b=x-1;b>0;b--){
			System.out.print(num[b]+" ");
		}
		System.out.println(num[0]);
	}
}

Measured memory_bytes: 19216
import sys
input = lambda: sys.stdin.readline().rstrip()

A,B,M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

disc = []
for i in range(M):
    x,y,c = map(int, input().split())
    disc.append(a[x-1]+b[y-1]-c)

disc.sort()
min_ab = min(a) + min(b)

if disc[0] <= min_ab:
    print(disc[0])
else:
    print(min_ab)

Measured memory_bytes: 67596
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    bool can_devide = true;
    int max_devide_count = 999999999;
    vector<int> vec(200);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
	int value = vec[i];
	if (value % 2 != 0) {
		can_devide = false;
		break;
	} else {
	    int count = 0;
	    int try_val = value;
	    while (try_val % 2 == 0) {
		    try_val = try_val / 2;
		    count += 1;
	    }

	    if (max_devide_count > count) {
		    max_devide_count = count;
	    }
	}
    }

    if (!can_devide) {
	    cout << "0" << endl;
    } else {
	    cout << max_devide_count << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())
R=[]
B=[]
for i in range(n):
    r=[int(i) for i in input().split()]
    R.append(r)
R.sort(key=lambda x:x[0])
for i in range(n):
    b=[int(i) for i in input().split()]
    B.append(b)
B.sort(key=lambda x:x[0])
ans=0
for b in B:
    stock=[]
    for r in R:
        if r[0]<b[0] and r[1]<b[1]:
            stock.append(r)
    if 0<len(stock):
        stock.sort(key=lambda x:x[1],reverse=True)
        red=stock[0]
        ans+=1
        R.remove(red)
#        print(b)
#        print(red)
print(ans)


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned long, unsigned long>> stk;
    unsigned long ans{0}, now{0};
    const auto& pop = [&stk, &now](){
        now -= stk.back().first * stk.back().second;
        stk.pop_back();
    };
    const auto& push = [&stk, &now, &pop](unsigned long x){
        pair<unsigned long, unsigned long> tmp{x, 1};
        while(!stk.empty() && stk.back().first > x){
            tmp.second += stk.back().second;
            pop();
        }
        now += tmp.first * tmp.second;
        stk.push_back(move(tmp));
    };
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        push(a);
        ans += now;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int H,W;
while(1){
cin>>H>>W;
if(H==0&&W==0) break;
else for(int i=0;i<H;i++){
for(int x=0;x<W;x++){
cout<<'#';
}
cout<<endl;
}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3068
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int a, b;

    cin >> a >> b;

    if(a > 0 && b > 0){
        cout << "Positive" << endl;
    } else if(a < 0 && b < 0){
        int tmp = abs(a) - abs(b);
        if(tmp % 2 == 0){
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    } else if(a < 0 && b > 0){
        cout << "Zero" << endl;
    }
}

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

int main()
{
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for(int x=0; x<=k; x++)
    {
        for(int y=x; y<=k; y++)
        {
            int z = s - x - y;
            if(y <= z && z <= k)
            {
                set<int> s{x, y, z};
                if(s.size() == 1) cnt++;
                else if(s.size() == 2) cnt += 3;
                else cnt += 6;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=55;
int dp[N][N*N],n,m,s,c[N],d[N],ans[N];
struct zh
{
	int x,y,z;
	bool operator<(const zh k)const
	{
		return z>k.z;
	}
	zh(){}
	zh(int _x,int _y,int _z):x(_x),y(_y),z(_z){}
};
vector<zh>e[N];
priority_queue<zh>pq;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>s;
	if(s>2500) s=2500;
	for(int i=1;i<=n;i++)
	{
		ans[i]=1e18;
		for(int j=0;j<=2500;j++)
			dp[i][j]=1e18;
	}
	for(int i=1;i<=m;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(c>2500) c=2500;
		e[a].push_back(zh(b,c,d));
		e[b].push_back(zh(a,c,d));
	}
	for(int i=1;i<=n;i++)
		cin>>c[i]>>d[i];
	dp[1][s]=0;
	pq.push(zh(1,s,0));
	while(!pq.empty())
	{
		auto k=pq.top();
		pq.pop();
		int x=k.x,y=k.y,z=k.z;
		if(dp[x][y]!=z)
			continue;
		ans[x]=min(ans[x],dp[x][y]);
		if(y+c[x]<=2500)
		{
			if(dp[x][y+c[x]]>dp[x][y]+d[x])
			{
				dp[x][y+c[x]]=dp[x][y]+d[x];
				pq.push(zh(x,y+c[x],dp[x][y+c[x]]));
			}
		}
		for(auto i:e[x])
		{
			int v=i.x,p=i.y,q=i.z;
			if(y>=p)
			{
				if(dp[v][y-p]>dp[x][y]+q)
				{
					dp[v][y-p]=dp[x][y]+q;
					pq.push(zh(v,y-p,dp[v][y-p]));	
				}
			}
		}
	}
	for(int i=2;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 7488
N, M = map(int, input().split())
A_array = list(map(int, input().split()))
item = 0
vote_sum = sum(A_array)
boarder = vote_sum / (4 * M)

for a in A_array:
    if a >= boarder:
        item += 1
if item >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38512
#include<stdio.h>
#include<math.h>
int main(){
  long long n,a,b;
  scanf("%lld",&n);
  a=sqrt(n);
  if(n!=a*a)a++;
  b=a*a-n;
  printf("0 0 %lld %lld 1 %lld \n",a,b,a);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    while(true)
    {
        vector<string> field(12);
        
        rep(h, 12)
            cin >> field[h];
        if(cin.eof()) break;
        
        int res = 0;
        rep(h, 12) rep(w, 12) if(field[h][w] - '0')
        {
            res++;
            queue<pint> que;
            for(que.push(mp(h, w)); !que.empty(); que.pop())
            {
                pint p = que.front();
                int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
                rep(i, 4)
                {
                    int nx = p.second + dx[i], ny = p.first + dy[i];
                    if(0 <= nx && nx < 12 && 0 <= ny && ny < 12 && field[ny][nx] - '0')
                    {
                        field[ny][nx] = '0';
                        que.push(mp(ny, nx));
                    }
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 0
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}


	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double k) { return Point(x * k, y * k); }
	Point operator / (double k) { return Point(x / k, y / k); }
	bool operator < (const Point &p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator ==(const Point &p)const { return fabs(x - p.x) < EPS&&fabs(y - p.y) < EPS; }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }
};
typedef Point Vector;
struct Segment
{
	Point p1, p2;
};
typedef Segment Line;
class Circle
{
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};

double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; }//??????
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }//??????
bool isOrthogonal(Vector a, Vector b) { return fabs(dot(a, b)) < EPS; }//??´??????
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); }
bool isOrthogonal(Line l1, Line l2) { return fabs(dot(l1.p2 - l1.p1, l2.p2 - l2.p1)) < EPS; }
bool isParallel(Vector a, Vector b) { return fabs(cross(a, b)) < EPS; }//?????????
bool isParallel(Point a1, Point a2, Point b1, Point b2) { return isParallel(a1 - a2, b1 - b2); }
bool isParallel(Line l1, Line l2) { return fabs(cross(l1.p2 - l1.p1, l2.p2 - l2.p1)) < EPS; }
Point project(Line s, Point p)
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base*r;
}



int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		string a;
		cin >> a;
		vector<char> v;
		v.push_back(a[0]);
		auto it = v.begin();
		for (int i = 2; i < a.size();i+=3)
		{
			if (a[i] == '>')
			{
				it++;
				if (it == v.end())it=v.insert(it, a[i + 1]);
			}
			else
			{
				if(it==v.begin())it = v.insert(v.begin(), a[i + 1]);
				else it--;
			}
		}
		for (int i = 0; i < v.size(); i++)
		{
			cout << v[i];
		}
		cout << endl;

	}
}

Measured memory_bytes: 3104
from sys import stdin

INF = 10 ** 16

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A = A + [0]

"""
dp[i][j]を j=1 ならiを選んで反転した場合（すなわち A_i+1 の符号が反転している状態）
の A_1, A_2, ... , A_i の最大値として定義する

今反転しない & 前の状態（反転してない or 反転した）
今反転する & 前の状態（反転してない or 反転した）
といったような4状態から最大値をみつけていく感じ
"""
dp = [[None] * 2 for _ in range(N+10)]

dp[0][0] = 0
dp[0][1] = -INF # Invalid

for i in range(N):
    # A[i]を反転させない状態の最大値
    # dp[i][0]なら前の操作でA[i]は反転されていないのでそのまま足す
    # dp[i][1]なら前の操作でA[i]が反転されているので反転して足す
    dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i])

    # A[i]を反転させた状態の最大値
    # dp[i][0]なら前の操作でA[i]が反転されていないので反転して足す
    # dp[i][1]なら前の操作でA[i]が反転されているので反転の反転（元の値）を足す
    dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i])


# for DEBUG
#print(*dp, sep="\n")

# Nは反転できないのでdp[N][0]が結果となる
print(dp[N][0])


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> f(n + 1);
    for (ll x = 1; x <= 100; x++)
    {
        for (ll y = 1; y <= 100; y++)
        {
            for (ll z = 1; z <= 100; z++)
            {
                ll val = x * x + y * y + z * z + x * y + y * z + z * x;
                if (val <= n)
                    f[val]++;
            }
        }
    }
    for (ll i = 1; i <= n; i++)
        cout << f[i] << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int m,n;
    scanf("%d %d",&n,&m);
    while(n>=1&&n<=100&&m>=0&&m<=n)
    {
        if(m==n)
        {
         printf("Yes");
            break;
        }
        else
            {
         printf("No");
            break;
        }
    }

}

Measured memory_bytes: 128
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const pos = (x, y) => {
    return { x : x, y : y};
};

const div = (p1, p2, n) => {
    if (n === 0) return [];
    const cos = Math.cos(Math.PI / 3.0);
    const sin = Math.sin(Math.PI / 3.0);

    const s = pos((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3);
    const t = pos((p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3);
    const u = pos( (t.x - s.x) * cos - (t.y - s.y) * sin + s.x
                 , (t.x - s.x) * sin + (t.y - s.y) * cos + s.y
                 );
    
    return div(p1, s, n - 1)
               .concat(s)
               .concat(div(s, u, n - 1))
               .concat(u)
               .concat(div(u, t, n - 1))
               .concat(t)
               .concat(div(t, p2, n - 1));
};

const solve = (n) => {
    if (n === 0) return [pos(0.0, 0.0), pos(100.0, 0.0)];
    return [pos(0.0, 0.0), ...div(pos(0.0, 0.0), pos(100.0, 0.0), n), pos(100.0, 0.0)];
};

console.log(solve(parseInt(line[0])).map(p => `${p.x.toFixed(8)} ${p.y.toFixed(8)}`).join('\n'));


Measured memory_bytes: 19160
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

int f(int x) {
	if (x & 1) {
		return 1 << (31 - __builtin_clz(x));
	} else {
		return x >> 1;
	}
}

int get(vector<int> a) {
	int n = a.size();
	vector<int> b(n);
	vector<int> bad;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (__builtin_popcount(a[i]) > 1) {
			bad.push_back(i);
			b[i] = 1;
		}
		b[i] += 31 - __builtin_clz(a[i]);
	}
	ans += accumulate(all(b), 0);
	for (int i = 0; i < n - 1; ++i) {
		ans -= min(b[i], b[i + 1]);
	}

	vector<int> really_bad;
	for (int idx : bad) {
		int cnt_near_greater = 0;
		if (idx > 0 && b[idx - 1] >= b[idx]) {
			++cnt_near_greater;
		}
		if (idx < n - 1 && b[idx + 1] >= b[idx]) {
			++cnt_near_greater;
		}
		if (cnt_near_greater == 2) {
			really_bad.push_back(idx);
		}
	}

	for (int i = 0; i < (int)really_bad.size();) {
		ans += 1;
		if (i == (int)really_bad.size() - 1) {
			break;
		}
		if (really_bad[i] + 1 == really_bad[i + 1]) {
			i += 2;
		} else {
			i += 1;
		}
	}

	return ans;
}

int main() {
	int n = nxt();
	vector<int> a(n);
	for (itn i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	int ans = 0;
	vector<int> b;
	for (int x : a) {
		if (x == 1) {
			ans += get(b);
			b.clear();
		} else {
			b.push_back(x);
		}
	}
	ans += get(b);

	printf("%d\n", ans);

	return 0;
}

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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> s(n);
  for(long i=0;i<n;i++) cin >> s[i];
  
  sort(s.begin(),s.end());
  for(long i=0;i<n;i++) {
    ans+=s[i];
  }
  if(ans%10==0) {
    for(long i=0;i<n;i++) {
      if(s[i]%10!=0) {
        ans-=s[i];
        break;
      }
      if(i+1==n) ans=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
H, W = list(map(int, input().split()))
A = [['' for i in range(W + 1)] for j in range(H + 1)]
dp = [[0 for i in range(W + 1)] for j in range(H + 1)]
for i in range(1, H + 1):
    a = input()
    for j in range(W):
        A[i][j + 1] = a[j]
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if A[i][j] == '#':
            dp[i][j] = 0
        elif i == 1 and j == 1:
            dp[i][j] = 1
        elif i == 1:
            dp[i][j] = dp[i][j - 1]
        elif j == 1:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
print(dp[H][W] % 1000000007)


Measured memory_bytes: 250332
#include<bits/stdc++.h>
using namespace std;
map<char,int> mapa;

int main(){
	string str;
	cin >> str;
	bool f = 0;
	for(auto it:str){
		mapa[it]++;
		if(mapa[it]>=2)
			f = 1;
	}
	if(f == 1)
		cout<<"no";
	else
		cout<<"yes";
	

}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<int> K(M);
        rep(i, M) {
            int k; cin >> k;
            vector<int> KK(k); cin >> KK;
            rep(j, k) K[i] |= 1 << (KK[j] - 1);
        }
        vector<int> P(M); cin >> P;
        int ans = 0;
        int bit = 0;
        while(bit < (1 << N)) {
            bool ok = true;
            rep(i, M) {
                int s = __builtin_popcount(bit & K[i]);
                ok &= s % 2 == P[i];
            }
            ans += ok;
            bit++;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ll long long 

int main()
{
	cerr << "Compilation Done." << '\n';
	ll n;
	cin >> n;
	ll ans = 0;
	ans += 1000LL * (n / 500);
	int carry = n%500;
	carry -= (carry%5);
	ans += carry;
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

bool solve(string &s){
  if(s.length() < 6) return 0;
  bool a = 0, b = 0, c = 0;
  REP(i, s.length()){
    if(isdigit(s[i])) a = 1;
    if(isalpha(s[i]) && isupper(s[i])) b = 1;
    if(isalpha(s[i]) && islower(s[i])) c = 1;
  }
  return (a && b && c);
}

int main() {
  string s; cin >>s;
  cout <<(solve(s) ? "VALID" : "INVALID") <<endl;
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll a[200010];
ll b[200010];
ll c[200010];

map<ll, ll> mp;

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];

    rep(i, n) b[i] = i + 1 + a[i];

    rep(j, n) c[j] = j + 1 - a[j];

    // rep(i, n) cout << b[i] << " ";
    // cout << endl;
    // rep(i, n) cout << c[i] << " ";
    // cout << endl;

    ll ans = 0;

    rep(i, n){
        mp[b[i]]++;
        ans += mp[c[i]];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 30832
#include <stdio.h>
#include <string.h>

#define NMAX 1000
#define max(a, b) (a > b ? a : b)

int c[NMAX + 10][NMAX + 10]; // 1-origin

int lcs(char *x, char *y) {
    int m = strlen(x);
    int n = strlen(y);
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (x[i - 1] == y[j - 1]) // 0-origin
                c[i][j] = 1 + c[i - 1][j - 1];
            else
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
        }
    }
    return c[m][n];
}

int main() {
    // init
    for (int i = 1; i <= NMAX; i++) {
        c[0][i] = 0;
        c[i][0] = 0;
    }
    int q;
    scanf("%d", &q);
    char x[NMAX + 10], y[NMAX + 10]; // 0-origin
    for (int i = 0; i < q; i++) {
        scanf("%s %s", x, y);
        printf("%d\n", lcs(x, y));
    }
    return 0;
}


Measured memory_bytes: 6636
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
inline char get() {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n;
int h[N];
int dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n);
  for (int i = 0; i < n; i++) {
    read(h[i]);
  }
  dp[1] = abs(h[1]-h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
  }
  cout << dp[n-1] << nl;
  return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<math.h>

int main(){
	int n;				//ベクトルの次元
	double p1 = 0,p2 = 0,p3 = 0,pi = 0;	//各出力
	
	//nの取得
	scanf("%d",&n);
	
	//n次元ベクトルの定義
	int x[n];
	int y[n];
	
	//xの入力
	for(int i = 0;i < n;i++){
		scanf("%d",&x[i]);
	}
	
	//yの入力
	for(int i = 0;i < n;i++){
		scanf("%d",&y[i]);
	}
	
	//p=1の時の算出
	for(int i = 0;i < n;i++){
		p1 += fabs(x[i] - y[i]);
	}
	
	//p=2の時の算出
	for(int i = 0;i < n;i++){
		p2 += pow(fabs(x[i] - y[i]),2);
	}
	p2 = sqrt(p2);
	
	//p=3の時の算出
	for(int i = 0;i < n;i++){
		p3 += pow(fabs(x[i] - y[i]),3);
	}
	p3 = pow(p3,1.0 / 3.0);
	
	//p=∞の時の算出
	for(int i = 0;i < n;i++){
		if(fabs(x[i] - y[i]) > pi){
			pi = fabs(x[i] - y[i]);
		}
	}
	
	printf("%lf\n%lf\n%lf\n%lf\n",p1,p2,p3,pi);
	
	return 0;
}



Measured memory_bytes: 2060
a, b, c= map(int, input().split())
if a<=b<=c:print(a, b, c)
if b<a<=c:print(b, a, c)
if a<=c<b:print(a, c, b)
if b<c<a:print(b, c, a)
if c<a<b:print(c, a, b)
if c<=b<=a:print(c, b, a)


Measured memory_bytes: 5596
_N = int(input())
S = input()

open_parenthesis = 0
left = 0
right = 0

for s in S:
    if s == '(':
        open_parenthesis += 1
    elif s == ')':
        if open_parenthesis != 0:
            open_parenthesis -= 1
        else:
            left += 1

right = open_parenthesis

ans = '(' * left + S + ')' * right

print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
	int n,d,res = 0;
	cin >> n >> d;
	if(n % (2 * d + 1) == 0)
		res = n / (2 * d + 1);
	else
		res = n / (2 * d + 1) + 1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int A=0;
    queue<pair<int,int> > L;
    string CSD;
    cin >> CSD;
    int n=CSD.size();

    stack<pair<int,int> > S;
    int cur_h=0,max=0,min=0;
    S.push(make_pair(0,0));
    int pret=-1;
    F(i,0,n){
        if(CSD[i]=='\\'){
            --cur_h;
            if(min>cur_h) min=cur_h;
            S.push(make_pair(cur_h,i+1));
        }
        else if(CSD[i]=='/'){
            ++cur_h;
            if(max<cur_h){
                max=cur_h;
                min=max;
                while(!S.empty()){
                    S.pop();
                }
            }
            else{
                while(!S.empty() && min>=S.top().first) S.pop();
                int t=S.top().second;
                min=cur_h;
                int area;
                if(t<pret){
                    A+=area=i-t;
                    int size=L.size();
                    for(int j=0;j<size;++j){
                        if(t<L.front().second && L.front().second<i+1){
                            //cout << " " << L.front().first;
                            area+=L.front().first;
                            L.pop();
                        }
                        else{
                            L.push(L.front());
                            L.pop();
                        }
                    }
                    L.push(make_pair(area,t));
                }
                else{
                    A+=area=i-t;
                    L.push(make_pair(area,t));
                }
                pret=t;
            }
            S.push(make_pair(cur_h,i+1));
        }
        else{
            S.push(make_pair(cur_h,i+1));
        }
    }

    cout << A << endl;
    int k=L.size();
    cout << k;
    for(int i=0;i<k;++i){
        cout << " " << L.front().first;
        L.pop();
    }
    cout << endl;

    return 0;
}


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

int main(){
	ll a,b;
	cin>>a>>b;
	ll x=__gcd(a,b);
	ll cnt=1;
	ll num=sqrt(x);
	for(int i=2;i<=num;i++){
		if(x%i==0){
			cnt++;
			while(x%i==0){
				x/=i;
			}
		}
	}
	if(x>1)cnt++;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
int main (){
    char s[100];
    scanf("%s",&s);
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='R'){
            if(i%2==1){
            printf("No");return EXIT_SUCCESS;}}
        if(s[i]=='L'){
            if(i%2==0){
            printf("No");return EXIT_SUCCESS;}}
    }
    printf("Yes");
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N=I()
    A = list(map(int,input().split()))
    B=LI()
    bef=0
    out=0
    for i in range(N):
        if A[i]>bef:
            en=A[i]-bef
            out+=bef
            if en>B[i]:
                bef=0
                out+=B[i]
            else:
                bef=B[i]-en
                out+=en
        else:
            out+=A[i]
            bef=B[i]
    i=N
    if A[N]>bef:
        en=A[N]-bef
        out+=bef
    else:
        out+=A[N]
        # bef=B[N]

    print(out)

if __name__ == "__main__":
    main()

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1e5 + 5;

int r[N];
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int S;  cin >> S;
    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   cin >> r[i];

    int q;  cin >> q;
    int ptr = 1, val = 0;
    int Min = 0, Max = S;

    bool top = 1;

    while (q--) {
        int t;  cin >> t;
        int a;  cin >> a;

        for(; ptr <= n && r[ptr] <= t ; ++ptr, top ^= 1)    {
            int delta = r[ptr] - r[ptr - 1];

            if (Max == 0)   {
                val += delta * (top ? -1 : 1);
                val = max(val,0);
                val = min(val,S);
            }
            else    {
                if (top)    {
                    int low = Min + val;

                    if (low <  delta)
                        Min += delta - low;
                    
                    val -= delta;
                    if (Max + val <= 0) {
                        val = 0;
                        Min = 0;
                        Max = 0;
                    }
                }
                else    {
                    if (Max + val + delta > S)
                        Max = S - val - delta,
                        val = S - Max;
                    else
                        val += delta;
                    
                    if (Max <= Min) {
                        val += Max;
                        Max = 0;
                        Min = 0;
                    }
                }
            }
        }
        int ans;
        if (a <= Min)   ans = Min + val;
        if (a >= Max)   ans = Max + val;
        if (Min < a && a < Max) ans = a + val;

        ans += (t - r[ptr - 1]) * (top ? -1 : 1);
        ans = max(ans,0);
        ans = min(ans,S);

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

Measured memory_bytes: 4032
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
 

signed main(){
   
   int n,a[111111*4];
   cin>>n;
   rep(i,n*3)cin>>a[i];
   sort(a,a+n*3);
   int co=0,co2=0,ans=0;
   repb(i,n*3){
       co++;
       if(co%2==0){
           co2++;
           ans+=a[i];
           //cout<<a[i]<<endl;
       }
       if(co2==n)break;
   }
   cout<<ans<<endl;
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int a,p;
    scanf("%d%d",&a,&p);
    while(a--){
        p+=3;
    }
    printf("%d",p/2);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K; cin >> N >> K;
    lint ans = 0;
    while (N) {
        ans += 1;
        N /= K;
    }
    cout << ans << "\n";
}

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

int main() {
  int64_t N,P;
  cin>>N>>P;
  vector<int>A(N);
  bool even=true;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]%2!=0){even=false;}
  }
  if(even){
    if(P%2==0){cout<<(int64_t)pow(2,N)<<endl;}
    else{cout<<0<<endl;}
  }
  else{
    cout<<(int64_t)pow(2,N-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define all(v)          v.begin(), v.end()
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mem(dp,x)       memset(dp,x,sizeof dp);
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
// 1, 1, 2, 5, 14, 42, 132, 429, 1430, CATALAN NUMBER
int32_t main()
{
	g_b();
	string s;
	cin >> s;
	int n = s.size();
	char c = s[n - 1];
	if ( c == 's') s += "es";
	else s += "s";
	cout << s;
	return 0;
}

Measured memory_bytes: 3660
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
s = LS()[1]
print("A"+s[0]+"C")
"""
#B
a,b,x = LI()
print(b//x-(a-1)//x)
#C
"""
n,x = LI()
a = LI()
ans = 0
for i in range(n-1):
    if a[i]+a[i+1] > x:
        ans += a[i+1]+a[i]-x
        if x > a[i]:
            a[i+1] = x-a[i]
        else:
            a[i+1] = 0
            a[i] = x
print(ans)
"""

#D
"""
s = S()
l = len(s)
k = (s[0] == s[-1])
if (l%2)^k:
    print("First")
else:
    print("Second")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
INF = 99999999999

n, m, x = map(int, input().split()) 
c_l = []
a_l = []

for _ in range(n):
    a_list = list(map(int, input().split())) 
    c_l.append(a_list[0])
    a_l.append(a_list[1:])

min_c = INF
for i in range(2 ** n):
    bag_c = []
    bag_a = []
    for j in range(n):
        if ((i >> j) & 1):  
            bag_c.append(c_l[j])  
            bag_a.append(a_l[j])
        l = len(bag_a)
        c_sum = 0
        s_sum = [0]*m
        for ii in range(l):
            c_sum += bag_c[ii]
            for mm in range(m):
                s_sum[mm] += bag_a[ii][mm]
        if min(s_sum) >= x and c_sum < min_c:
            min_c = c_sum
if min_c == INF:
    print(-1)
else:   
    print(min_c)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  char C;

  cin >> N;
  cin >> S;
  cin >> K;

  C = S.at(K-1);

  for(int i=0;i<N;i++){
    if(S.at(i)!=C){
      cout << "*";
    }else{
      cout << S.at(i);
    }
  }
}


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

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

  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<'\n';

	return 0;
}


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

using namespace std;

int main() {
    string s, t;
    getline(cin, s);
    getline(cin, t);
    int m = s.length(), n = t.length();
    int minSoFar = INT_MAX;
    for (int i = 0; i <= m - n; ++i) {
        int j = 0, count = 0;
        for (; j < n; ++j) {
            if (s[i + j] != t[j])   ++count;
        }
        minSoFar = min(minSoFar, count);
    }
    cout << minSoFar << endl;
	return 0;
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var st = new int[num][];
        for (var i = 0; i < num; i++)
            st[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        st = st.OrderBy(p=>p[1]).ToArray();
        var queue = new Queue<int[]>();
        for (var i = 0; i < num; i++)
            queue.Enqueue(st[i]);
        var res = 0;
        var t = 0;
        while (queue.Count != 0)
        {
            var ac = queue.Dequeue();
            if (t < ac[0])
            {
                res++;
                t = ac[1];
            }
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 36904