akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/

struct Sieve {//
	int n;
	vector<int> f, primes;
	Sieve(int N ): n(N), f(N + 1) {//コンスタクタでNまでの素数列挙 以下に現れるxはN以下
		f[0] = f[1] = -1;//factorList()のため
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.emplace_back(i);
			f[i] = i;//素数は自分を保持
			for (ll j = i * i; j <= n; j += i) {  //例えばi==7の時、7*5等は先に５の方で試してるから7*7以降、つまりi*i以降を試していけばいい
				if (!f[j]) f[j] = i;//何かしらが代入されていない時は、f[j]の約数であるiを代入
			}
		}
	}

	bool isPrime(int x) { return (f[x] == x);}//印が素数自身ならば素数

	vector<int> factors(int x) {//素因数リスト　重複あり ex)100==2*2*5*5
		vector<int> res;
		while (x != 1) {
			res.emplace_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	set<int> factorList(int x) {//素因数の集合　ex)100..(2,5)
		set<int> res;
		while (x != 1) {
			res.insert(f[x]);
			x /= f[x];
		}
		return res;
	}

	vector<pair<ll, int>> factor(int x) {
		vector<int> fl = factors(x); //ex)100...{2,2,5,5}
		if (fl.size() == 0) return {};
		vector<pair<ll, int>> res(1, PII(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			} else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	ll N;
	cin>>N;

	ll ans=0;

	FOR(b,1,N-1){
		ans+=(N-1)/b ;
	}
	cout<<ans<<endl;
	

		return 0;
}


Measured memory_bytes: 3648
from collections import Counter

n = int(input())
a = Counter(list(map(int,input().split())))

m1 = 0

key = sorted(a.keys(), reverse = True)

for i in key:

    if a[i]>1 and m1==0:
        m1 = i
        if a[i]>3:
            print(i**2)
            exit()

    elif m1!=0 and a[i]>1:
        print(m1*i)
        exit()

print(0)

Measured memory_bytes: 18600
#include <stdio.h>


int main(void) {

  int n;
  scanf("%d",&n);

  int b[n-1];
  for (int i=0; i < n-1; i++){
      scanf("%d", &b[i]);
  }

  int a[n];
  a[0] = b[0];
  a[1] = b[0];
  for (int i=1; i < n-1; i++){
      if (a[i] > b[i]){
          a[i] = b[i];
      }
      a[i+1] = b[i];
  }



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



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


  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        System.out.println(A <= C && C <= B ? "Yes": "No");
    }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            int ret = 0;
            while (r[0] != r[1] || r[0] != r[2])
            {
                if (r[0] == r[1])
                {
                    ret += r[2] - r[0];
                    break;
                }
                else
                {
                    ret++;
                    r[0] += 2;
                    r = r.OrderBy(x => x).ToArray();
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

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

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

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

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n; ll k;
    cin >> n >> k;
    struct P {
        ll first, second, third;
    };
    V<P> v(n);
    for (int i = 0; i < n; i++) {
        v[i].first = k; k++;
    }
    for (int i = n/2; i < n; i++) {
        v[i].second = k; k++;
    }
    for (int i = 0; i < n/2; i++) {
        v[i].second = k; k++;
    }

    set<ll> st;
    for (int i = 0; i < n; i++) {
        st.insert(k); k++;
    }

    for (int i = 0; i < n; i++) {
        ll sm = v[i].first + v[i].second;
        auto it = st.lower_bound(sm);
        if (it == st.end()) {
            cout << -1 << endl;
            return 0;
        }
        v[i].third = *it;
        st.erase(it);
    }

    for (auto p: v) {
        cout << p.first << " " << p.second << " " << p.third << "\n";
    }


    return 0;
}


Measured memory_bytes: 9344
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if (500 * a + 100 * b + 50 * c == X):
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,k; cin >> n >> k;
    if(k == 0){
        return cout << n*n << endl,0;
    }
    int ans = 0;
    for(int b = 1; b<=n;b++){
        int p = n/b;
        int r = n%b;
        ans += p*max(0LL,b-k)+max(0LL,r-k+1);
    }
    cout << ans << endl;
}






Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ret = "";
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == '1') ret += '9';
            else ret += '1';
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<cctype>
#include<queue>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int N = 550;
struct node{
	int xi;
	int yi;	
}a[N];
int in[N];
vector<int> G[N]; 
inline int read(){
    int v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar(); 
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar(); 
    }
    return v * c;
}
int n,f[N];
inline int work(int x,int sum){
	f[x] = 1;
	for(int i = 0;i < (int)G[x].size();++i){
		if(in[G[x][i]]) in[G[x][i]]--;
		//int y = G[x][i];
		//if(!f[y]) (y,sum + 1);	
	}
	for(int i = 0;i < (int)G[x].size();++i){
		int y = G[x][i];
		if(!f[y]) {in[y] = 0;return work(y,sum + 1);}	
	}
	return sum;
}
int main(){
	//	freopen("data.in","r",stdin);
	//freopen("b1.out","w",stdout);
	n = read();int ans = n == 1 ? 1 : n - 1;
	for(int i = 1;i <= n;++i){
		a[i].xi = read();
		a[i].yi = read();
	}
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= n;++j){
			if(j == i) continue;
			for(int k = 1;k <= n;++k) G[k].clear();
			long long p = a[i].xi - a[j].xi;long long q = a[i].yi - a[j].yi;
		//	printf("%d %d\n",p,q);
		//	if(p == 0 && q == 0) continue;
			memset(in,0,sizeof(in));
			for(int l = 1;l <= n;++l){
				for(int r = 1;r <= n;++r){
					if(l == r) continue;
					if(1ll * a[l].xi - a[r].xi == p && 1ll * a[l].yi - a[r].yi == q) G[r].push_back(l),in[l]++;
				}
			}
		//	for(int i = 1;i <= n;++i) printf("%d ",G[i].size());puts("");
			int now = 0;
			memset(f,0,sizeof(f));
			for(int i = 1;i <= n;++i) if(in[i] == 0 && f[i] == 0) now += work(i,1) - 1;
		//	printf("%d\n",now);
		
			ans = min(ans,n - now);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A >= B){
        swap(A, B);
    }
    
    if(C >= A && C <= B){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
dist = [-1] * n
dist[0] = 0
now = 0
while True:
    next = a[now] - 1
    if dist[next] == -1:
        dist[next] = dist[now] + 1
    else:
        hajimari = next
        loopnum = dist[now] + 1 - dist[hajimari]
        town = 0
        if k <= dist[hajimari]:
            for _ in range(k):
                town = a[town] - 1
        else:
            town = hajimari
            for _ in range((k - dist[hajimari]) % loopnum):
                town = a[town] - 1
        print(town + 1)
        exit()
    now = next

Measured memory_bytes: 32216
a=input()
b = list(map(int,input().split()))
t=0
for i in range(int(a)):

    if(b[i]%2==0):
        if(b[i]%3==0 or b[i]%5==0):
            t+=1
    else:
        t+=1
if t==int(a):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
n,k=map(int,input().split())

x=list(map(int,input().split()))
ans=[]
for i in range(n-k+1):
    ans.append(min(abs(x[i])+x[i+k-1]-x[i] , abs(x[i+k-1])+(x[i+k-1]-x[i])))
    
print(min(ans))

Measured memory_bytes: 14252
import Data.List
main = do
       e <- getLine
       let (x:y:[])=map read (words e)::[Int]
           t = [(e1,e2,e3)| e1<-[0..x],e2<-[0..(x-e1)],e3<-[(x-e1-e2)..(x-e1-e2)],y==e1*10000+e2*5000+e3*1000]
       putStrLn $ if null t then "-1 -1 -1"
                            else let (a1,b1,c1)=head t
                                 in (show a1)++" "++(show b1)++" "++(show c1)

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d[120],ans=0;
bool flag[120];
int main()
{
  scanf("%d %d",&a,&b);
  for(int i=1;i<=a;i++)
    flag[i]=false;
  for(int i=1;i<=b;i++)
  {
    scanf("%d",&c);
    for(int j=1;j<=c;j++)
    {
      scanf("%d",&d[j]);
      flag[d[j]]=true;
    }
  }
  for(int i=1;i<=a;i++)
    if(flag[i]==false)ans++;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int get_sum(int index)
{
    int ret = 0;
    for (int i = 1; i <= index; i++){
        ret += i;
    }
        
    return ret;
}


int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N;
    cin >> K;
    
    vector<int> p;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    
    // init
    uint64_t sum = 0;
    for (int i = 0; i < K; i++){
        sum += p[i];
    }
    uint64_t max = sum;
    int max_index = 0;
    
    // calc max
    for (int i = 1; i <= N - K; i++) {
        sum -= p[i-1];
        sum += p[i+(K-1)];
        if (max < sum) {
            max = sum;
            max_index = i;
        }
    }
    
    // 期待値.
    double ans = 0.0;
    for (int i = max_index; i < max_index+K; i++) {
        ans += double(get_sum(p[i])) / double(p[i]);
    }
    
    cout << scientific << setprecision(12) << ans;
    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	
	public static void main( String[]args ){
		
		Scanner sc = new Scanner( System.in );
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		 
		int p_number = 0;//ロープのほどく可能ナンバー
		int b = 0;//一個前のロープの長さ
		boolean l_flag = false; // ここがfalseだったらほどけないということ
		for( int i = 0;i < n;i++ ){
			
			int a = sc.nextInt();
			if( i == 0 && !l_flag ){
				if( a == l ){
					l_flag = true;
					p_number = i;
				}
			}else if( !l_flag ){
				
				if( l > a + b )
					l_flag = false;
				else{
					l_flag = true;
					p_number = i;
				}
			}
			b = a;
		}
		
		if( l_flag ){
			System.out.println("Possible");
			
				for( int i = n - 1;i > p_number;i-- )
					System.out.println(i);
				for( int i = 1;i <= p_number;i++ )
					System.out.println(i);
		
		}else{
			System.out.println("Impossible");
		}
		
	}

}

Measured memory_bytes: 47060
//#include <bits/stdc++.h>
#include <utility>
#include <math.h>
#include <string.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second


int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;

	vector<int> a;
	for (int i = 2; i <= 100; ++i)
	{
		bool p = true;
		for (int j = 2; j < i; ++j)
			p &= i % j != 0;
		if (p)
			a.push_back(i);
	}

	int sz = a.size();
	vector<int> f(sz);
	for (int i = 2; i <= n; ++i)
	{
		for (auto &j : a)
		{
			int t = i;
			while (t % j == 0) t /= j, ++f[&j-&a[0]];
		}
	}

	int ans = 0;
	for (int i = 1; i < 1<<sz; ++i)
	{
		int bp = __builtin_popcount(i);
		if (bp < 4)
		{
			vector<int> b;
			for (int m = i; m; m ^= m&-m)
				b.push_back(__lg(m&-m));

			if (bp == 1)
			{
				if (f[b[0]] >= 74)
					++ans;
			}
			if (bp == 2)
			{
				if (f[b[0]] >= 14 && f[b[1]] >= 4)
					++ans;
				if (f[b[0]] >= 4 && f[b[1]] >= 14)
					++ans;
				if (f[b[0]] >= 24 && f[b[1]] >= 2)
					++ans;
				if (f[b[0]] >= 2 && f[b[1]] >= 24)
					++ans;
			}
			if (bp == 3)
			{
				if (f[b[0]] >= 2 && f[b[1]] >= 4 && f[b[2]] >= 4)
					++ans;
				if (f[b[0]] >= 4 && f[b[1]] >= 2 && f[b[2]] >= 4)
					++ans;
				if (f[b[0]] >= 4 && f[b[1]] >= 4 && f[b[2]] >= 2)
					++ans;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();

			int remainA = a - 1;
			int remainB = b - 1;

			int v = 0;
			int h = 100;
			var sb = new StringBuilder();
			while (remainA > 0) {
				++v;
				for (int j = 0; j < 100; j++) {
					sb.Append('#');
				}

				sb.AppendLine();

				++v;
				for (int j = 0; j < 100; j++) {
					if (remainA == 0) {
						sb.Append('#');
					} else {
						if (j % 2 == 0) {
							sb.Append('#');
						} else {
							sb.Append('.');
							remainA--;
						}
					}
				}

				sb.AppendLine();
			}

			++v;
			for (int j = 0; j < 100; j++) {
				sb.Append('#');
			}

			sb.AppendLine();

			++v;
			for (int j = 0; j < 100; j++) {
				sb.Append('.');
			}

			sb.AppendLine();

			while (remainB > 0) {
				++v;
				for (int j = 0; j < 100; j++) {
					if (remainB == 0) {
						sb.Append('.');
					} else {
						if (j % 2 == 0) {
							sb.Append('.');
						} else {
							sb.Append('#');
							remainB--;
						}
					}
				}

				sb.AppendLine();

				++v;
				for (int j = 0; j < 100; j++) {
					sb.Append('.');
				}

				sb.AppendLine();
			}

			Console.WriteLine($"{v} {h}");
			Console.WriteLine(sb);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n,a;
    cin >> n >> a;
    int cnt = 0;
    while(n--){
        int x;
        cin >> x;
        if(x >= a) cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 3640
n = int(input())
h = list(map(int, input().split()))

def cut(list_i):
  list_r = []
  tmp_list = []
  for i in list_i:
    if i == 0:
      if tmp_list != []:
        list_r.append(tmp_list)
      tmp_list = []
    else:
      tmp_list.append(i)
  else:
    if tmp_list != []:
      list_r.append(tmp_list)
  return list_r

ans = 0
def search(list_i):
  
  global ans
  ans += min(list_i)
  list_i = list(map(lambda x: x - min(list_i), list_i))
  for list_r in cut(list_i):
    search(list_r)
    
search(h)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    map<int,int> m;
    int no,freq,total=0;
    for(int i =0;i < n;i++){
        cin>>no>>freq;
        m[no] = m[no] + freq;
    }
    /*tr(it,m){
        cout<<it->first<<" "<<it->second<<endl;
    }
    */

    tr(it,m){
        total +=it->second;
        if(k<=total){
            cout<<it->first<<endl;
            return 0;
        }


    }













}




















Measured memory_bytes: 4224
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  
  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else{
    y->parent->right=x;
  }
  
  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  //code
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }
  else if(z->key < y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}

void inorder(Node u){

  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20448
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int n;
  scanf("%d",&n);
  char w[100][11];
  char str[11];
  int flag = 1;

  scanf("%s",w[0]);
  for(int i=1;i<n;i++){
    scanf("%s",w[i]);
	strcpy(str,w[i-1]);
  
    if(w[i][0]!=str[strlen(str)-1]){
        flag = 0;
    }

    for(int j=i-1;j>=0;j--){
      if(strcmp(w[i],w[j])==0)
        flag = 0;
    }
  }
  if(flag==1)
    printf("Yes");
  else
    printf("No");
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

ll v[N], ans[N];

void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> v[i];
	for(int i = 32; i >= 0; i--){
		ll value = (1LL<<i), x = 0, valid = 1;
		for(int j = 0; j < n; j++)
			x ^= ((v[j]&value)==value);
		for(int j = 0; j < n; j++){
			ll newx = x ^ ((v[j]&value)==value);
			if(newx != ((v[j]&value)==value))
				valid = 0;
		}
		//cout << i <<" " << valid << endl;
		if(valid){
			for(int j = 0; j < n; j++)
				ans[j] += (((v[j]&value)==value) ? value:0);
		} else {
			for(int j = 0; j < n; j++)
				ans[j] += (!((v[j]&value)==value) ? value:0);
		}
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] <<" ";
	}cout << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 6716
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $c = 1+int($n/2);

my %path = ();
my $j = $c-1;
for(my $i=$c;$i<=$n;$i++){
  for(my $k=1;$k<=$n;$k++){
    next if( $k==$i or $k==$j );
    if( $k<$i ){
      $path{"$k $i"} = 1;
    } else {
      $path{"$i $k"} = 1;
    }
    if( $j>=1 ){
      if( $k<$j ){
        $path{"$k $j"} = 1;
      } else {
        $path{"$j $k"} = 1;
      }
    }
  }
  $j--;
}
my @path = keys %path;
my $np = 1 + $#path;
print "$np\n";
foreach my $k (@path){
  print "$k\n";
}

exit(0);



Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 200000;

int main() {
    int N, K, H[MAX_N];
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    // HPの多い順にソート
    sort(H, H + N, greater<int>());

    // K回は必殺技で倒せるので0に
    for (int i = 0; i < K; i++) {
        H[i] = 0;
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += H[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
        #define NUMBER 200005
        int main(){
         int i = 0;
          int ans = 0;
        char S[NUMBER],T[NUMBER];
        scanf("%s",S);
        scanf("%s",T);
         
         
        while(S[i]){
          if(S[i] != T[i]){
          ans++;
          
          }
          i++;
          }
        printf("%d",ans);
          
          return 0;
        }

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

const int maxn=100005;
const int mod=998244353;
const int base=716070898;
const int inv2=(mod+1)/2;
int n,m,sz;
vector<int>edge[maxn];
int pw[maxn],dp[maxn],F[4][maxn*4];
bool occ[maxn];

void fwt(int *x,int sz,int tp){
	for(int m=2;m<=sz;m<<=1){
		int mm=m>>1;
		for(int i=0;i<sz;i+=m){
			int *p1=x+i,*p2=x+i+mm;
			for(int j=0;j<mm;j++,p1++,p2++){
				int u=*p1,v=*p2;
				*p1=u+v>=mod?u+v-mod:u+v;
				*p2=u-v<0?u-v+mod:u-v;
				if(tp<0){
					*p1=1LL*(*p1)*inv2%mod;
					*p2=1LL*(*p2)*inv2%mod;
				}
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;i++)pw[i]=1LL*pw[i-1]*base%mod;
	for(sz=1;sz<n;sz<<=1);
	for(int t=1;t<=3;t++){
		for(int i=1;i<=n;i++){
			dp[i]=0;
			edge[i].clear();
		}
		scanf("%d",&m);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			edge[u].push_back(v);
			edge[v].push_back(u);
		}
		for(int i=n;i>=1;i--){
			for(int j=0;j<int(edge[i].size());j++)
				if(edge[i][j]>i)occ[dp[edge[i][j]]]=true;
			while(occ[dp[i]])dp[i]++;
			F[t][dp[i]]+=pw[i];
			if(F[t][dp[i]]>=mod)F[t][dp[i]]-=mod;
			for(int j=0;j<int(edge[i].size());j++)
				if(edge[i][j]>i)occ[dp[edge[i][j]]]=false;
		}
		fwt(F[t],sz,1);
	}
	for(int i=0;i<sz;i++)F[0][i]=1LL*F[1][i]*F[2][i]%mod*F[3][i]%mod;
	fwt(F[0],sz,-1);
	printf("%d\n",F[0][0]);
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int kanou = 0;
    string s,t,a;
    cin >> s >> t;
    for (int i = 0;i <s.size();i++) {
        s.insert(s.begin() + 0, s[s.size()-1]);
        s.pop_back();
        if (s == t) {
            kanou = 1;
            cout << "Yes";
            break;
        }
    }
    if (kanou == 0) {
        cout << "No";
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x2 = 0;
  rep(i,n) {
    if (i%2) x2 -= a[i];
    else x2 += a[i];
  }
  vector<int> ans(n);
  ans[0] = x2/2;
  rep(i,n-1) {
    ans[i+1] = a[i]-ans[i];
  }
  rep(i,n){
    ans[i] *= 2;
    cout << ans[i] << " ";
  } 
}

Measured memory_bytes: 2048
def main():
    N, W = map(int, raw_input().split())
    Items = [list(map(int, raw_input().split())) for i in range(N)]
    
    # dp[i] := 容量Wのナップサックにおける価値の総和の最大値
    dp = [0] * (W + 1)
    
    for w, v in Items:
        for i in range(W, -1, -1):
            if i < w:
                continue
            dp[i] = max(dp[i], dp[i - w] + v)
    
    print(dp[-1])

main()


Measured memory_bytes: 31468
import sys
input = sys.stdin.readline

X = int(input())

dp = [False] * (X+1)
dp[0]=True

c = [100,101,102,103,104,105]

for i in range(len(c)):
	for j in range(c[i],X+1):
		if(dp[j-c[i]]):
			dp[j]=True
if(dp[X]):print(1)
else:print(0)

Measured memory_bytes: 39792
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long total = 0;
		for (int i = 0; i < n - 2; i++) {
		    int left = i + 1;
		    int right = i + 1;
		    while(left < n - 1) {
		        while (right < n - 1 && arr[right + 1] < arr[i] + arr[left]) {
		            right++;
		        }
		        total += Math.max(right - left, 0);
		        left++;
		    }
		}
		System.out.println(total);
   }
}




Measured memory_bytes: 27236
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int k,d[100005];
bool used[100005];
priority_queue <pair<int,int> > pq;
vector <pair<int,int> > ve[100005];
int main(){
	cin>>k;
	for (int i=0;i<k;i++){
		ve[i].push_back(mp((i+1)%k,1));
		ve[i].push_back(mp(i*10%k,0));  
	}
	pq.push(mp(0,1));
	while (!pq.empty()){
		int x=pq.top().second;
		int v=pq.top().first;
		pq.pop();
		if (x==0){
			cout<<-v+1;
			return 0;
		}
		if (used[x]) continue;
		used[x]=true;
		for (int i=0;i<ve[x].size();i++){
			if (!used[ve[x][i].first]){
				pq.push(mp(v-ve[x][i].second,ve[x][i].first));
			}
		}
	}
}

Measured memory_bytes: 6396
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
	int k,t;
	cin >> k >> t;
	VI a(t);
	REP(i,0,t) cin >> a[i];
	sort(all(a));
	int target = a[t-1];
	int over = target - (k+1)/2;
	if (over > 0) cout << over * 2 + k % 2 - 1 << endl;
	else cout << 0 << endl;
	
	return 0;
}

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

int main(void) 
{
    ll n,k;
    cin >> n >> k;
    ll mini = n;

    mini = mini % k;
    while(true)
    {
        ll tmp = llabs(mini - k);

        if(tmp < mini) 
        {
            mini = tmp;
            continue;
        }
        else
           break;
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
n = int(input())
H = list(map(int, input().split()))
flag = 0

if n == 1:
    flag = 0
else:
    for i in range(n-1):
        idx = n-1-i
        if (H[idx-1] - H[idx]) == 1:
            H[idx-1] -= 1
        elif (H[idx-1] - H[idx]) > 1:
            flag = 1
            break

if flag == 0:
    print("Yes")
else:
    print("No")

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


Measured memory_bytes: 1720
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T, vector<T>, greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<int,P> PP;
const int mod = 1e9 + 7, inf = 1e16;
const int dy[4]={0,1,0,-1},dx[4]={1,0,-1,0};

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n & 1) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}
 
int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}
 
int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}
 
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
 
bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int h,w;
char s[1010][1010];
int d[1010][1010];
queue<PP>que;
int ans;
signed main() {
	cin>>h>>w;
	rep(i,h) {
		rep(j,w) {
			cin>>s[i][j];
			d[i][j]=inf;
			if(s[i][j]=='#') {
				que.push({0,P(i,j)});
				d[i][j]=0;
			}
		}
	}
	while(!que.empty()) {
		PP p=que.front(); que.pop();
		rep(i,4) {
			int ny=p.second.first+dy[i],nx=p.second.second+dx[i];
			if(0<=ny&&ny<h&&0<=nx&&nx<w&&d[ny][nx]==inf) {
				d[ny][nx]=p.first+1;
				que.push({p.first+1,P(ny,nx)});
			}
		}
	}
	rep(i,h) {
		rep(j,w) {
			if(d[i][j]==inf) continue;
			ans=max(ans,d[i][j]);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 33332
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  long long N = 0,D = 0,X = 0,Y = 0,count = 0;
  cin >> N >> D;
  for(int i = 0;i < N;i++){
    cin >> X >> Y;
    if(sqrt(X*X + Y*Y) <= D){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3676
// 5/24
// 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

    ll ans_t, ans_a;

    if (K <= A) {
        ans_t = A - K;
        ans_a = B;
    } else if (K <= A + B) {
        ans_t = 0;
        ans_a = B - K + A;
    } else {
        ans_t = ans_a = 0;
    }

    cout << ans_t << " " << ans_a << endl;
}


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

int main(){
    ll a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;
    }else{
        cout<<b-a<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x)
{
    while (x->left != NIL) x = x->left;
    return x;
}

Node *find(Node *u, int k)
{
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }

    return u;
}

Node *treeSuccessor(Node *x)
{
    Node *y;

    if (x->right != NIL) return treeMinimum(x->right);
    y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z)
{
    Node *y;    // 削除する対象
    Node *x;    // y の子

    // 削除する節点を決める
    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    // y の子 x を決める
    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            Node *t;
            scanf("%d", &x);
            t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(3*n);
	rep(i,3*n){
		cin >> a[i];
	}
	sort(a.rbegin(),a.rend());
	ll ans = 0;
	rep(i,n){
		ans += a[2*i+1];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
/*
 *created by Kraken on 12-04-2020 at 17:13
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) sum += i;
        }
        System.out.println(sum);
    }

    static class FastReader {

        BufferedReader br;

        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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


Measured memory_bytes: 32724
Input = input()

v_lakes =[]  #個々の湖の面積管理用のstack
idx_stack = [] #地形のindex管理用のstack

for i, c in enumerate(Input):
    if c == "\\":
        idx_stack.append(i)
    elif c == "/" and idx_stack:
        j = idx_stack.pop()
        v = i - j

        while v_lakes and j < v_lakes[-1][0]:
            v += v_lakes.pop()[1]

        v_lakes.append((j,v))

ans = [len(v_lakes)]
v = [v[1] for v in v_lakes]
ans.extend(v)

print(sum(v))
print(*ans)


Measured memory_bytes: 6508
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int goal[]=new int[n];
        for (int i=0;i<n;i++){
            goal[i]=0;
        }
        for (int i=1;i<=k;i++){
            int d=sc.nextInt();
            for(int j=0;j<d;j++){
                goal[sc.nextInt()-1]++;
            }
        }

int num=0;
        for (int i=0;i<n;i++){
            if(goal[i]==0){
                num++;
            }
        }

   System.out.println(num);











    }
}


Measured memory_bytes: 45968
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n,a,b,Ans=0;
	scanf ("%d%d",&n,&a);
	for (int i=1;i<=n;++i)
	{
		scanf ("%d",&b);
		if (b>a/2) Ans+=(a-b)*2;
		else Ans+=b*2;
	}
	return !printf ("%d\n",Ans);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int solve(int d)
{
  d *= d;
  d -= (d / 1000000) * 1000000;
  return d / 100;
}

int main()
{
  int n, s;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> s;
    cout << "Case " << i + 1 << ":\n";
    for(int j = 0; j < 10; j++)
      cout << (s = solve(s)) << endl;
  }
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
    string s;
    cin >> s;
    ll ans = 0;
    if (s == "SUN") {
      ans = 7;
    } else if (s == "MON") {
      ans = 6;
    } else if (s == "TUE") {
      ans = 5;
    } else if (s == "WED") {
      ans = 4;
    } else if (s == "THU") {
      ans = 3;
    } else if (s == "FRI") {
      ans = 2;
    } else if (s == "SAT") {
      ans = 1;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() 
{
    int a,b,c,s;
    cin>>a>>b>>c;
    s=a+b+c;
    if(s>=22)
    {
        cout<<"bust";
    }
    else
    {
        cout<<"win";
    }
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)


def main():
    s = input()

    ls = ["000", "111", "222", "333", "444", "555", "666", "777", "888", "999"]
    for x in ls:
        if x in s:
            print("Yes")
            return
    print("No")


main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007

int lc(const void *a,const void *b){
    if(*(long*)a - *(long*)b){
        return  *(long*)a < *(long*)b?-1:1;
    }
    return 0;
}

static inline long mdml(long a,long b){
    long long res = (long long)a * b;
    return res % MOD;
}

static inline long mdpow(long num,long ind){
    unsigned long ibit = (unsigned long)ind;
    long res = 1;
    while(ibit){
        if(1lu & ibit)res = mdml(res,num);
        num = mdml(num,num);
        ibit >>= 1;
    }
    return res;
}

static inline long mdadd(long a,long b){
    return (a + b) % MOD;
}

int main(void){
    int n;
    scanf("%d",&n);
    long c[n];
    for(int i = 0;i < n;i++)scanf("%ld",&c[i]);
    qsort(c,n,sizeof(long),lc);
    long ans = 0;
    for(int i= 0;i < n;i++)ans = mdadd(ans,mdml(c[i],mdadd(mdpow(2,n-1),mdml(mdpow(2,n-2),n-i-1))));
    ans = mdml(ans,mdpow(2,n));
    printf("%ld",ans);
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

long long gcd(long long a, long long b) {
  long long r = 1;
  while (r != 0) {
    r = a%b; a = b; b = r;
  }
  return a;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, x; cin >> n >> x;

  int ret = 0;

  rep(i, n) {
    int a; cin >> a;
    ret = gcd(ret, abs(x-a));
  }
  cout << ret << endl;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n,m;
    cin>>n>>m;
    
    if(n==m) dunk("Yes");
    else dunk("No");
}



Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

cnt = 0
for a, b in zip(A[::-1], B[::-1]):
    v = (a + cnt) % b
    # print(f'{v=}')
    if v == 0:
        continue
    cnt += b - v
print(cnt)


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

int main()
{
	int X, Y;
	cin >> X >> Y;
	cout << (X == 1 && Y == 1 ? 400000 : 0) + (X == 1 ? 300000 : X == 2 ? 200000 : X == 3 ? 100000 : 0) + (Y == 1 ? 300000 : Y == 2 ? 200000 : Y == 3 ? 100000 : 0) << endl;
	return 0;
}


Measured memory_bytes: 764