akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
    int x, y; cin >> x >> y;
    int ans = 0;
    if(x == 1) {
        ans += 300000;
    }
    if(x == 2) {
        ans += 200000;
    }
    if(x == 3) {
        ans += 100000;
    }
    if(y == 1) {
        ans += 300000;
    }
    if(y == 2) {
        ans += 200000;
    }
    if(y == 3) {
        ans += 100000;
    }
    if(x == 1 && y == 1) {
        ans += 400000;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
  string s;
  long long n;
  char ans;
  long long sum=0;
  cin>>s>>n;
  for(int i=0;i<s.size();i++){
  	if(n==i+1&&s[i]=='1'){
      cout<<'1'<<endl;
      return 0;
    }
    if(s[i]!='1'){
    	ans=s[i];
    	break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

N, D = stdin.readline().rstrip().split()
DD = int(D) ** 2
N = int(N)

CNT = 0

for i in range(N):
  X, Y = stdin.readline().rstrip().split()
  XX = int(X) ** 2
  YY = int(Y) ** 2
  ZZ = XX + YY
  if ZZ <= DD:
    CNT += 1
      
print(CNT)

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

int main() {
  string s;
  cin >> s;

  int ans = 1000;
  for (int i = 2; i < s.size(); i ++) {
    int tmp = (s.at(i - 2) - '0') * 100 + (s.at(i - 1) - '0') * 10 + (s.at(i) - '0');
    if (ans >= abs(753 - tmp)) {
      ans = abs(753 - tmp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        for(int i=0;i<5;i++)
        {
            if(Integer.parseInt(str[i])==0)
            {
                pw.println(i+1);
                break;
            }
        }
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32712
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  int s, w; cin >> s >> w;
  if (w >= s) {
    cout << "un";
  }
  cout << "safe\n";

  return 0;
}



Measured memory_bytes: 3816
import std.stdio;
import std.string;
import std.conv;

int main()
{
	int number[];
	number.length = 5;
	string s[] = readln.chomp.split();	

	foreach(i;0..5)
	{
		number[i] = to!int(s[i]);
	}

	foreach(i;0..5)
	{
		for(int j=4;j>i;j--)
		{
			if(number[j] > number[j-1])
			{
				auto temp = number[j];
				number[j] = number[j-1];
				number[j-1] = temp;
			}
		}
	}

	foreach(i;0..4)
	{
		write(number[i]," ");
	}
	writeln(number[4]);

	return 0;
}

Measured memory_bytes: 1060
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string sInput;
	int i,ans=0;
	cin >> sInput;
	for (i = 1; i < sInput.length(); ++i){
		if (sInput[i] != sInput[i - 1])
			++ans;
	}
	cout << ans << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

using namespace std;

/**
 * THREE = P W G
 * FOUR  = P W G Y
 */

int main() {
  int N;
  vector<char> S;
  char temp;

  cin >> N;

  // 格納
  for (int i = 0; i < N; i++) {
    cin >> temp;
    S.push_back(temp);
  }

  // ソート
  sort(S.begin(), S.end());

  // 重複要素を削除
  auto last = unique(S.begin(), S.end());
  S.erase(last, S.end());

  // 結果を出力
  if (S[0] == 'G' && S[1] == 'P' && S[2] == 'W' && S[3] == 'Y') {
    cout << "Four" << endl;
  } else if (S[0] == 'G' && S[1] == 'P' && S[2] == 'W') {
    cout << "Three" << endl;
  }
}


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

using namespace std;

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

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#define loga(array, val) cout << #array << "[" << val << "] " << array [ val ] << endl
#else
#define log(item)
#define loga(array, val)
#endif

int gcd(int number1,int number2){
	int m = number1;
	int n = number2;

	if(number2 > number1){
		m = number2;
		n = number1;
	}

	while(m != n){
		int temp = n;
		n = m - n;
		m = temp;
	}

	return m;
}
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}

//--------------------


signed main()
{
    int K, X;
    cin >> K >> X;

    int minv = max(X - K + 1, (int)-1000000);
    int maxv = min(X + K - 1, (int)1000000);

    for(int i = minv; i <= maxv; i++)
    {
        cout << i;
        if(i != maxv)
        {
            cout << " ";
        }
    }

    cout << endl;

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if (s.size() < 6 || s.size() > 6)
    {
        cout << "No" << endl;
        return 0;
    }
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int height = int.Parse(input[0]);
            int weight = int.Parse(input[1]);
            if(height==0&&weight==0)break; 
            //出力
            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < weight; i++)
                {
                    Console.Write("#");
                }
                Console.Write("\n");
            }
            Console.WriteLine("");

        }
    }
}


Measured memory_bytes: 18000
/*
 ------------------------------------------------------Read question very carefully------------------------------------------------------
 
                       In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
#include <cstdint>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
 #define pi                   pair<int,int>
 #define pll                  pair<ll,ll>
 #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
 using namespace std;

//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
 //const ll inf=1ll<<60;
 //const double pi = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
const ll int  N=2e5+5;
/*vector<ll> adj[N];
vector<ll> vis(N,0);
*/
//int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll n,k;
ll arr[N];
ll helper(ll x,ll curr)
{
    ll ans=0;
    F(i,1,n)
    {
        if(!curr)
        {
            ans++;
            curr^=1;
        }
        else
        {
            if(arr[i]<=x)
            {
                ans++;
                curr^=1;
            }
        }
    }
    return ans>=k;
}

 int main()
 {
     IOS;
     ll n; cin>>n;
     ll arr[n+2];
     F(i,0,n-1)
     {
         cin>>arr[i];
     }
     vector<ll > pref(n+2,0),ans(n+2,0);
     pref[n-1]=arr[n-1];
     RF(i,n-2,0)
     {
         pref[i] = pref[i+1]^arr[i];
     }
     ll val=0;
     F(i,0,n-2)
     {
         ans[i] = val^pref[i+1];
         val = val^arr[i];
     }
     ans[n-1] = val;
     F(i,0,n-1)
     {
         cout<<ans[i]<<" ";
     }
     cout<<endl;
 }



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int64 x;
  cin >> x;
  int64 ans = x / 11 * 2;
  if (x % 11 > 0) {
    if (x % 11 >= 7) {
      ans += 2;
    } else {
      ans += 1;
    }
  }
  cout << ans << endl;
}

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

int main(void){
    std::string S;
    std::cin >> S;
    char A[S.length()];
    for(int i=0; i<S.length(); i++){
        A[i] = 'x';
    }
    A[S.length()] = '\0';
    std::cout << A << std::endl;
    
    return 0;
}

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

int main(){
	int n;
	int a[5][5];
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3; j++)
			cin >> a[i][j];
	}
	cin >> n;
	bool f = false;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		for(int k = 1; k <= 3; k++)
			for(int j = 1; j <= 3; j++)
				if(a[k][j] == x) a[k][j] = -1;
		for(int k = 1; k <= 3; k++){
			if(a[k][1] == -1 && a[k][2] == -1 && a[k][3] == -1) f = true;
			if(a[1][k] == -1 && a[2][k] == -1 && a[3][k] == -1) f = true;
		}
		if(a[1][1] == -1 && a[2][2] == -1 && a[3][3] == -1) f = true;
		if(a[1][3] == -1 && a[2][2] == -1 && a[3][1] == -1) f = true;
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

bool bs(int l, int r, int* a, int target);

int main() {
	int n;
	cin >> n;
	int* s = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> s[i];
	}
	int q;
	cin >> q;
	int tmp,cnt=0;
	for (int i = 0;i < q;i++) {
		cin >> tmp;
		if (bs(0, n - 1, s, tmp))cnt++;
	}
	cout << cnt << endl;
	
}

bool bs(int l, int r, int* a, int target) {
	if (a[l] > target)return false;
	if (a[r] < target)return false;
	if (a[r] == target)return true;
	if (r - l <= 1) {
		if (a[l] == target)return true;
		else return false;
	}
	int mid = (r + l) / 2;
	if (a[mid] > target) {
		return bs(l, mid, a, target);
	}
	else {
		return bs(mid, r, a, target);
	}
}


Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	V count(n, 0);
	ll ans = 1;
	rep(i, n) {
		int a;
		cin >> a;
		count[a]++;
		if (i == 0 && a != 0) {
			// cout << "E1" << endl;
			cout << 0 << endl;
			return 0;
		}
		if (count[a] >= 4 || i < a) {
			// cout << "E2" << endl;
			cout << 0 << endl;
			return 0;
		}
		if (a == 0) {
			ans *= 4 - count[a];
			// cout << 3 - count[a] << endl;
		}
		else {
			int tmp = count[a - 1] - count[a];
			if (tmp < 0) {
				cout << 0 << endl;
				return 0;
			}
			tmp++;
			ans *= max(tmp, 0);
			// cout << tmp << endl;
		}
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = input()
As = map(int,raw_input().split())

msk = 0
sm = 0
l = 0
r = 0

while r < N:
    while As[r]&msk != 0:
        msk^=As[l]
        l+=1
    msk|=As[r]
    sm+=(r-l+1)
    r+=1
print sm


Measured memory_bytes: 20020
from collections import defaultdict
import heapq
N,M = map(int,input().split())
D = defaultdict(list)
for i in range(N):
    A,B = map(int,input().split())
    A = M - A
    D[A].append(B)

h = []

su = 0
hlen = 0
for i in range(M-1,-1,-1):
    for b in D[i]:
        heapq.heappush(h,-b)
        hlen += 1
    if hlen:
        su -= heapq.heappop(h)
        hlen -= 1

print(su)

Measured memory_bytes: 77528
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll x; cin >> x;
    ll q = x%100;
    ll cnt = 0;
    for(ll i=5; i>0; i--){
        cnt += q/i;
        q %= i;
    }
    cout << ((x/100 < cnt) ? 0 : 1) << endl;
}

Measured memory_bytes: 3648
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int N;
    cin >> N;

    vector<int> A(N);
    map<int, int> mp;

    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
        mp[A[i]]++;
    }

    set<int> S;

    for(int i = 0; i < N; i++)
    {
        S.insert(A[i]);
    }

    if(S.find(1) != S.end())
    {
        if(mp[1] == 1)
        {
            cout << "1\n";
            return;
        }
        cout << "0\n";
        return;
    }

    map<int, int> is_valid;

    for(int i = 0; i < N; i++)
    {
        for(int j = 2; j * j <= A[i]; j++)
        {
            if(A[i] % j == 0)
            {
                //cout << i << " " << j << endl;
                
                if(S.find(j) != S.end() || S.find(A[i] / j) != S.end())
                {
                    is_valid[A[i]] = -1;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(is_valid[A[i]] != -1 && mp[A[i]] == 1)
        {
            //cout << A[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;
}

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

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




Measured memory_bytes: 32236
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
win = [True] * len(T)

dic = {'r':P, 's':R, 'p':S}

sum = 0
for i in range(K):
  sum += dic[T[i]]
for i in range(K, len(T)):
  if T[i] == T[i - K] and win[i - K]:
    win[i] = False
  else:
    sum += dic[T[i]]
print(sum)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    string s;cin>>s;
    int sum=0;
    FOR(i,0,s.size())
        sum+=s[i]-'0';
    if(sum%9)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}

Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
using namespace std;

int frequency = 0;
bool flag = false;


void selectionSort(int A[], int N){
	for (int i = 0; i<N-1 ; i++){
		int minj = i;
		flag = false;
		for (int j = i; j < N; j++){
			if (A[j] < A[minj]){
				minj = j;
				flag = true;
			}
		}
		if (flag) {
			swap(A[i], A[minj]);
			frequency++;
		}
	}
}

int main(){

	int N;

	int A[100];

	cin >> N;
	
	for (int i = 0; i < N; i++) cin >> A[i];

	selectionSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i<N - 1) cout << A[i] << " ";
		else cout << A[i] << endl;
	}
	cout << frequency << endl;

	return 0;
}

Measured memory_bytes: 1164
def solve():
  n, l = map(int,input().split())
  ans = 0
  pre = 0
  up_acc = 0
  down_acc = 0
  for i in range(n):
    length = int(input())
    time = l - length
    if length > pre:
      up_acc += time
      if down_acc > ans:
        ans = down_acc
      down_acc = time
    else:
      down_acc += time
      if up_acc > ans:
        ans = up_acc
      up_acc = time
    pre = length
  else:
    ans = max(ans, up_acc, down_acc)
  print(ans)
solve()


Measured memory_bytes: 5620
def exception_handling(n, a)
  ans = Array.new(n)
  sorted = a.sort
  a.each_with_index do |n, i|
    ans[i] = n == sorted[-1] ? sorted[-2] : sorted[-1]
  end
  ans
end

n = gets.chomp.to_i
a = []
n.times{ a << gets.chomp.to_i }
puts exception_handling(n, a)

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


int main(){
	string a,b,c;
	char A,B,C;
	cin >> a >> b >> c;
	A=a[0]-32;
	B=b[0]-32;
	C=c[0]-32;
	cout << A << B << C << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
vans = 0
cans = 0
for i in range(n):
    if v[i]> c[i]:
        vans += v[i]
        cans += c[i]
print(vans - cans)

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

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

MOD = 1000000007
m, n = map(int, input().split())


def pow_fast(m, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return pow_fast(m * m % MOD, n / 2)
    else:
        return pow_fast(m * m % MOD, int(n / 2)) * m % MOD


print(pow_fast(m, n))



Measured memory_bytes: 6604
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int h, w;
    cin >> h >> w;

    rep(i, h) {
        rep(j, w) {
            string word;
            cin >> word;
            if (word == "snuke") {
                cout << (char)('A' + j) << (i + 1);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}

	public void exec() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		PriorityQueue pq = new PriorityQueue(2000000);
		String str = null;
		while(true){
			str=br.readLine();
			if(str.charAt(0)=='i'){
				pq.insert(Integer.parseInt(str.substring(7)));
			}else if(str.charAt(1)=='x'){
				out.println(pq.extract());
			}else{
				break;
			}
		}
		out.flush();
	}
}


class PriorityQueue  {
	protected int[] data = null;
	protected int dataPtr = -1;

	public PriorityQueue(int maxNodes) {
		data = new int[maxNodes+1];
		dataPtr = 1;
	}
	
	public int removeLast() {
		if(dataPtr <= 1) return -1;
		return data[--dataPtr];
	}
	
	public int addLast(int value) {
		if(dataPtr >= data.length) return -1;
		int ret = dataPtr++;
		data[ret] = value;
		return ret;
	}

	public int getParent(int i){
		if(i<=1 || dataPtr<=i) return -1;
		return i/2;
	}

	public int getLeft(int i){
		int leftId = i*2;
		return (i<=0 || dataPtr<=leftId) ? -1 : leftId;
	}

	public int getRight(int i){
		int rightId = i*2 + 1;
		return (i<=0 || dataPtr<=rightId) ? -1 :rightId;
	}
	
	public void insert(int value) {
		int id = addLast(value);
		for(int pid = getParent(id); pid != -1 && value>data[pid]; pid=getParent(id=pid)){
			data[id] = data[pid];
		}
		data[id]=value;
	}
	
	public int extract() {
		if(dataPtr<=1)
			throw new IllegalStateException();
		int ret = data[1];
		data[1] = removeLast();
		if(dataPtr>1){
			maxHeapify(1);
		}
		return ret;
	}
	
	protected void maxHeapify(int i) {
		int largest = i,leftId,rightId;
		while(true){
			leftId = getLeft(i);
			rightId = getRight(i);
			if(leftId != -1 && data[largest] < data[leftId]) largest = leftId;
			if(rightId != -1 && data[largest] < data[rightId]) largest = rightId;
			if(largest != i){
				data[0] = data[i]; data[i] = data[largest]; data[largest] = data[0];
				i = largest;
			}else{
				break;
			}
		}
	}
}

Measured memory_bytes: 102400
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	int k,n;
	cin>>n>>k;
	vector<int> p(n);
	rep(i,n)cin>>p[i];
	double ans=0,cnt=0;
	rep(i,k){
	    cnt+=(double)(p[i]+1)/2;
	}
	ans=cnt;
	rep(i,k,n){
	    cnt+=(double(p[i]+1)/2);
	    cnt-=(double)(p[i-k]+1)/2;
	    ans=max(ans,cnt);
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 1792
while 1:
    n = int(input())
    if n == 0:
        break
    alist = list(map(int, input().split()))

    ohajiki = 32
    cnt = 0
    while ohajiki != 0:
        taro = (ohajiki - 1) % 5
        ohajiki -= taro
        print(ohajiki)

        jiro = alist[cnt % n]
        ohajiki -= jiro
        if ohajiki < 0:
            ohajiki = 0
        print(ohajiki)
        cnt += 1



Measured memory_bytes: 5588
#include<iostream>

using namespace std;


int main(){
	int n,m,k;
	cin >>n>>m>>k;
	long a[n+1],b[m+1];
	a[0]=0;
	for(int i=1;i<n+1;i++){
		cin >>a[i];
		a[i]+=a[i-1];
	}
	b[0]=0;
	for(int i=1;i<m+1;i++){
		cin >>b[i];
		b[i]+=b[i-1];
	}
	int max=0;
	int j=m;
	for(int i=0;i<n+1;i++){
		if(a[i]>k) break;
		while(a[i]+b[j]>k){
			j--;
		}
		if(i+j>max) max=i+j;
	}
	cout <<max;
	return 0;
}


Measured memory_bytes: 6692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
  ll N,ans=0;
  cin>>N;
  set<ll> S;
  for(int i=2; i<=sqrt(N); ++i){
    ll P=N;
    while(P%i==0) P/=i;
    if(P%i==1) S.insert(i);
  }
  for(int i=2; i<=sqrt(N-1); ++i){
    if((N-1)%i==0){
      S.insert(i);
      if(N-1!=i) S.insert((N-1)/i);
    }
  }
  if(N>2) S.insert(N-1);
  S.insert(N);
  ans=S.size();
  co(ans);
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  bool a=false;
  if(N%2==0){
    a=true;
    for(int i=0;i<N/2;i++){
      if(S.at(i)!=S.at(N/2+i)){
        a=false;
        break;
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    unordered_map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a]++;
        if(mp[a] >= 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8520
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
up = III()
down = III()

s = sum(up)+sum(down)

x = []
for i in range(N):
    x.append(sum(down[:i]+up[i+1:]))

print(s-min(x))

Measured memory_bytes: 38384
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    if (2 * b > h || 2 * a > w)
    {
        cout << "No" << endl;
    }
    else
    {
        for (int i = 0; i < b; i++)
        {
            for (int j = 0; j < a; j++)
            {
                cout << 0;
            }
            for (int j = a; j < w; j++)
            {
                cout << 1;
            }
            cout << endl;
        }
        for (int i = b; i < h; i++)
        {
            for (int j = 0; j < a; j++)
            {
                cout << 1;
            }
            for (int j = a; j < w; j++)
            {
                cout << 0;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int a[6];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n=5;
	FOR(i,1,n)cin>>a[i];
	FOR(i,1,n)if(!a[i])cout<<i; 
	RE 0;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  string s;
  cin >> n >> s;

  int cnt = 0;
  re(i, n-2) {
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

int main() {
  int N;
  char C;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> C;
    if ( C=='Y' ) {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
b = ''
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = a[X_dumy%n-1]+out
        if a[X_dumy%n-1] == 'z':
          X_dumy -= 26
        X_dumy = X_dumy//n
    return out
 
z = Base_10_to_n(n, 26)
print(z)

Measured memory_bytes: 9204
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll x[99],y[99],z[99],r[99],s[99];
int main(){
	ll n,q;
	scanf("%lld%lld",&n,&q);
	rep(i,0,n)scanf("%lld%lld%lld%lld%lld",x+i,y+i,z+i,r+i,s+i);
	while(q--){
		ll a,b,c,d,e,f;
		scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
		d-=a;e-=b;f-=c;//平行移動して
		ll ss=(d*d+e*e+f*f);
		ll ans=0;
		rep(i,0,n){
			ll xx=x[i]-a;
			ll yy=y[i]-b;
			ll zz=z[i]-c;
			ll coe=(xx*d+yy*e+zz*f);//射影して引く
			ll xxx=xx*ss-coe*d;
			ll yyy=yy*ss-coe*e;
			ll zzz=zz*ss-coe*f;
//			printf("%lld %lld\n",coe,xxx*xxx+yyy*yyy+zzz*zzz);
			if(0<=coe&&coe<=ss){
				if(xxx*xxx+yyy*yyy+zzz*zzz<=r[i]*r[i]*ss*ss)ans+=s[i];
			}
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll n; cin >> n;
    vll a(n); rep(i, n) cin >> a[i];
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll sum = 1;
    rep(i, n) {
        if ((ll)1e18 % sum == 0 && 1e18 / sum < a[i]) {
            cout << -1 << endl;
            return 0;
        } else if ((ll)1e18 % sum != 0 && 1e18 / sum <= a[i]) {
            cout << -1 << endl;
            return 0;
        }
        sum *= a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3996
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=4010;
int N;
char S[MAXN];
ll cnt[MAXN][3];
void solve()
{
    cin>>N>>S;
    ll rtot=0,gtot=0,btot=0;
    for(int u=0;u<N;u++){
        cnt[u+1][0]=cnt[u][0];
        cnt[u+1][1]=cnt[u][1];
        cnt[u+1][2]=cnt[u][2];
        if(S[u]=='R')cnt[u+1][0]++,rtot++;
        if(S[u]=='G')cnt[u+1][1]++,gtot++;
        if(S[u]=='B')cnt[u+1][2]++,btot++;
    }
    ll ans=0;
    for(int u=0;u<N;u++){
        for(int v=0;v<u-1;v++){
            if((u-v)%2==1)continue;
            int k=(u+v)/2;
            if(S[u]!=S[v]&&S[u]!=S[k]&&S[v]!=S[k]){
                ans++;
            }
        }
    }
    ll tot=0;
    for(int u=1;u<N-1;u++){
        if(S[u]=='R'){
            tot+=cnt[u][1]*(btot-cnt[u+1][2]);
            tot+=cnt[u][2]*(gtot-cnt[u+1][1]);
        }
        if(S[u]=='G'){
            tot+=cnt[u][0]*(btot-cnt[u+1][2]);
            tot+=cnt[u][2]*(rtot-cnt[u+1][0]);
        }
        if(S[u]=='B'){
            tot+=cnt[u][0]*(gtot-cnt[u+1][1]);
            tot+=cnt[u][1]*(rtot-cnt[u+1][0]);
        }
    }
    cout<<tot-ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 3660
import java.io.*;
import java.util.StringTokenizer;

import static java.lang.Integer.*;
import static java.lang.Long.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);

        int n = parseInt(read.readLine());
        long[] arr = new long[n];
        StringTokenizer st = new StringTokenizer(read.readLine());
        for (int i = 0; i < n; i++) {
            arr[i] = parseLong(st.nextToken());
        }
        prnt.println(getMinimumTotalHeight(arr, n));
        prnt.close();
    }

    static long getMinimumTotalHeight(long[] arr, int n) {
        long heightOfstool = 0;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] > arr[i]) {
                heightOfstool += (arr[i - 1] - arr[i]);
                arr[i] += (arr[i - 1] - arr[i]);
            }
        }
        return heightOfstool;
    }
}

Measured memory_bytes: 56040
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;cin>>n;
    map<ll,int> m;
    rep(i,n){
        ll tmp;cin>>tmp;
        m[tmp]++;
    }
    ll ans=0;
    for(auto i:m){
        if(i.second%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
		return 0;
	}
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::cmp::min;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let vs: Vec<i64> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let n = vs[0];
  let a = vs[1];
  let b = vs[2];
  let d = b - a;
  let ans = if d % 2 == 0 {
    d / 2
  } else {
    min((n - b) + (n - a) + 1, a + b - 1) / 2
  };
  println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main (void){
  int a,b,c,d;
  int budget=0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  
  a < b ? (budget += a) : (budget += b);
  c < d ? (budget += c) : (budget += d);
  
  printf("%d\n",budget);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n;
	cin >> n;
	vector<ll> a(3 * n);
	for (int i = 0; i < n * 3; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<ll>());
	ll ans =0;
	for (int i = 1; i < n * 2; i += 2)
	{
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val to = Array<MutableList<Int>>(N, { mutableListOf() } )
    repeat(M) {
        val (u, v) = listOfInt(-1)
        to[u].add(v)
    }
    val (S, T) = listOfInt(-1)
    val INF = -1
    var dist = Array<Array<Int>>(N + 1) { Array<Int>(3, { INF }) }

    var q = Queue<Pair<Int, Int>>()
    q.enqueue(Pair(S, 0))
    dist[S][0] = 0
    while (!q.isEmpty()) {
        val e = q.dequeue()!!
        val v = e.first
        val l = e.second
        to[v].forEach {
            val nl = (l + 1) % 3
            if (dist[it][nl] == INF) {
                dist[it][nl] = dist[v][l] + 1
                q.enqueue(Pair(it, nl))
            }
        }
    }
    var ans = dist[T][0]
    if (ans == INF) ans = -1 else ans /= 3
    println(ans)
}

class Queue<T> {
    val elements: MutableList<T> = mutableListOf()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
    override fun toString(): String = elements.toString()
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 97428
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[50];

int main(){
  ll N,K,A[100007],M=0,sum=0;
  cin >> N >> K;
  rep(i,N){
    cin >> A[i];
    ll P = A[i];
    ll T = 0;
    while(P>0){
      if(P%2==1){
        C[T]++;
      }
      T++;
      P/=2;
    }
  }
  ll X=pow(2,40);
  rRep(i,40,0){
    if(X>K){
      X/=2;
      continue;
    }
    if(C[i]<=(N-1)/2 && M+X<=K){
      M+=X;
    }
    X/=2;
  }
  rep(i,N){
    sum+=A[i]^M;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  //配列に入力
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
 
  sort(a.begin(), a.end());
  //配列を大きい順に並べ替え
  reverse(a.begin(), a.end());
  
  int Alice = 0;
  int Bob = 0;
  //aliceは偶数 bobは奇数の添え字の値の総和を求める
  for (int i = 0; i < N; i++){
  	if( i % 2 == 0) {
      Alice += a.at(i);
    }else {
      Bob += a.at(i);
    }
  }
  // 合計の差を出力
  cout << Alice - Bob << endl;		  
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int K; cin >> K;
	int s=0;
	for(int i=1; i<=K; i++){
		for(int j=1; j<=K; j++){
			for(int k=1; k<=K; k++){
				s += gcd(i, gcd(j, k));
			}
		}
	}
	cout <<s<<endl ;
	return 0;
}


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

using namespace std;
using ll = long long;

ll mod = 1000000007;
ll C[2004][2004];
ll dp[2004][2004];

void make_C(){
  memset(C, 0, (int)sizeof(C));
  for(int i = 0; i < 2004; i++){
    C[i][0] = C[i][i] = 1;
    for(int j = 1; j < i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
  }

  memset(dp, 0, (int)sizeof(dp));
  dp[0][0] = 1;
}

ll count9_2(ll n, ll m){
  if(dp[n][m]!=0)
    return dp[n][m];
  // O((n^2)*m) です
  for(int i = 0; i <= n; i++){
    for(int j = 1; j <= m; j++){
      for(int k = 0; k <= i; k++){
        // j番目の箱にはk個入れる。合計i個になるように。
        dp[i][j] = (dp[i][j] + dp[i-k][j-1]) % mod;
      }
    }
  }
  return dp[n][m];
}

ll count7(ll n, ll m){
  if(n < m) return 0;
  return C[n-1][m-1];
  // 包除原理でもできるはずです
}
int main() {
  ll N, K;
  cin >> N >> K;
  make_C();
  for (int i = 0; i < K; ++i) {
    ll ret = 0;
    if(i==0)
      ret = count9_2(N-K,2);
    else {
      for (int j = i; j <= N - K; ++j) {
        ll a= count7(j, i);
        ll b= count7(K, i+1);
        ll c= count9_2(N-K-j, 2);
        ret = (ret +  ((a* b)%mod *c)  % mod) % mod;
      }
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 62976
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Codeforces
{
	internal class Template
	{

		private void Solve()
		{
			var n = cin.NextLong();
			var t = cin.NextLong();
			var lastTo = 0L;
			var res = 0L;
			for (var i = 0; i < n; i++)
			{
				var from = cin.NextLong();
				var to = from + t;
				if (from < lastTo)
				{
					from = lastTo;
				}
				res += to - from;
				lastTo = to;
			}
			Console.WriteLine(res);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 28832