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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define N 200010
vi par(N); //親
vi ran(N); //木の深さ

	
int main() {
	string s;
	cin >> s;
	int i=0, n = s.size();
	while (i < n) {
		if (s.substr(i, 6) == "eraser") {
			i += 6;
		}
		else if (s.substr(i, 5) == "erase") {
			i += 5;
		}
		else if (s.substr(i, 5) == "dream") {
			if (s.substr(i + 5, 2) != "er") {
				i += 5;
			}
			else {
				if (s.substr(i + 5, 5) == "erase") {
					i += 5;
				}
				else {
					i += 7;
				}
			}
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int main(){
  double v,t,y,N;
  while(scanf("%lf",&v) != EOF){
    t = v / 9.8;
    y = t*t * 4.9;
    N=1;
    while(1){
      if(N*5-5 >= y){
	break;
      }
      N++;
    }
    cout << N << endl;
  }
}

Measured memory_bytes: 1272
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long s = sqrt(n);
  long long ans = n-1;
  vector<long long> v;
  for (long long i = 2ll; i <= s; ++i) {
    if (n % i == 0) {
      long long x = (n / i) + i - 2;
      if (x < ans) {
        ans = x;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  string s;
  cin >> s;
  for(char i = 'a'; i <= 'z'; i++){
    bool ok = true;
    rep(j,s.size()){
      if(i == s[j]) ok = false;
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>W(N);
    for (int i = 0; i < N; ++i) {
      cin >> W[i];
    }
    int sum = 0;
    int ans = mod;
    for (int i = 0; i < N; ++i) {
        sum += W[i];
    }
    int part = 0;
    for (int i = 0; i < N; ++i) {
        part += W[i];
        int temp = abs(sum-part-part);
        ans = min(ans, temp);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<long double> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 1; i < n; ++i)
		a[i] = (a[i] + a[i - 1]) / 2.L;
	cout << a.back() << endl;

	char I;
	cin >> I;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

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

	vector<int> a(n);

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


	int ans = a[n - 1] - a[0];


	for (int i = 1; i < n; ++i) {
		ans = min(ans, k - (a[i] - a[i - 1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
a = n.times.map{gets.to_i - 1}
b = Array.new(n)
n.times{|i|b[a[i]] = i}

res = 1
m = 1

(1...n).each do |i|
  if b[i - 1] < b[i]
    m += 1
  else
    res = [res, m].max
    m = 1
  end
end

res = [res, m].max

puts n - res

Measured memory_bytes: 5428
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  int R=0;
  int B=0;
  string s;
  cin >> N >> s;

for (int i = 0; i < N; i++){
    if(s[i] == 'R'){
        R++;
    } else {
        B++;
    }
}

if (R > B){
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
}

}

Measured memory_bytes: 256
use std::io::Read;

// fn is_prime(n: usize) -> bool {
//     if n == 1 {
//         return false;
//     }
//
//     for i in 2..n {
//         if i * i > n {
//             break;
//         }
//         if n % i == 0 {
//             return false;
//         }
//     }
//     return true;
// }

fn gcd(x: usize, y: usize) -> usize {
    // return y ? gcd(y, x % y) : x;
    if y == 0 {
        return x;
    }
    return gcd(y, x % y);
}

fn factorize(n: &mut usize) -> Vec<(usize, usize)> {
    let mut res: Vec<(usize, usize)> = vec![];
    for i in 2..*n {
        if (i * i) >= *n {
            break;
        }

        if *n % i != 0 {
            continue;
        }

        // res.push((i, 0));
        let mut cnt = 0;
        while *n % i == 0 {
            (*n) /= i;
            cnt += 1;
            // res.last().unwrap().1 += 1;
        }
        res.push((i, cnt));
    }
    if *n != 1 {
        res.push((*n, 1));
    }
    return res;
}

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    let mut g: usize = gcd(a, b);
    let f = factorize(&mut g);
    // println!("{:?}", f);
    println!("{}", f.len() + 1);

    // for i in 2..std::num::sqrt(g) {}

    // let mut ans = 1;
    // let mut i = 2;
    //
    // while (i * i) <= std::cmp::max(a, b) {
    //     if !is_prime(i) {
    //         i += 1;
    //         continue;
    //     } else if a % i == 0 && b % i == 0 {
    //         ans += 1;
    //     }
    //
    //     i += 1;
    // }
    //
    // println!("{}", ans);
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	r := []rune(io.Next())
	if r[2] == r[3] && r[4] == r[5] {
		io.Println("Yes")
	} else {
		io.Println("No")
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int getgcd(int v1, int v2) {

	int w;
	if (v1 < v2) {
		w = v1;
		v1 = v2;
		v2 = w;
	}
	while (v2 > 0) {
		w = v1 % v2;
		v1 = v2;
		v2 = w;
	}

	return v1;
}

int i;
int n;

int fnc() {

	n = geti();
	int icnt = 0;
	int zcnt = 0;
	ll sum = 0;
	int min = INT_MAX;
	for (i = 0; i < n; i++) {
		int v = geti();
		if (v < 0) {
			icnt++;
		}
		else if (v == 0) {
			zcnt++;
		}
		v = abs(v);
		sum += v;
		if (min > v) {
			min = v;
		}
	}
	if (icnt % 2 == 1) {
		if (zcnt == 0) {
			sum -= min * 2;
		}
	}

	outll(sum);

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

bool flg[10002];
int cnt[10002];

int main(){
  int n;

  while(cin >> n, n){
    memset(flg, 0, sizeof(flg));
    memset(cnt, 0, sizeof(cnt));

    for(int i = 1; i < n; i++){
      flg[(i * i) % n] = true;
    }

    for(int i = 0; i < n; i++){
      if(!flg[i]) continue;

      for(int j = i + 1; j < n; j++){
	if(!flg[j]) continue;

	int cal = j - i;
	if(cal > (n - 1) / 2) cal = n - cal;
	cnt[cal]++;

	cal = i - j + n;
	if(cal > (n - 1) / 2) cal = n - cal;
	cnt[cal]++;
      }
    }

    for(int i = 1; i <= (n - 1) / 2; i++){
      cout << cnt[i] << endl;
    }
  }
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	print(num2alpha(N).swapcase())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 70844
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    a,b = mi()
    print(max(a+b,a-b,a*b))

main()




Measured memory_bytes: 4212
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

char a[100][100];//gridの情報
int h,w;
vector<pair<int,int>> G[100][100];//グラフの隣接リスト

int main(){
    cin>>h>>w;
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='#') cnt++;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='.'){
                if(a[i-1][j]=='.') G[i][j].push_back(P(i-1,j));
                if(a[i][j-1]=='.') G[i][j].push_back(P(i,j-1));
                if(a[i+1][j]=='.') G[i][j].push_back(P(i+1,j));
                if(a[i][j+1]=='.') G[i][j].push_back(P(i,j+1));
            }
        }
    }
    vector<vector<int>> dist(h,vector<int>(w,-1));
    queue<pair<int,int>> que;
    dist[0][0]=0;
    que.push(P(0,0));//bfsのスタート地点
    while(!que.empty()){
        P p=que.front();
        que.pop();
        int u=p.ft,v=p.sc;
        for(P pp:G[u][v]){
            int s=pp.ft,t=pp.sc;
            if(dist[s][t]!=-1) continue;
            dist[s][t]=dist[u][v]+1;
            que.push(P(s,t));
        }
    }
    if(dist[h-1][w-1]==-1) cout<<-1<<endl;
    else cout<<h*w-(cnt+dist[h-1][w-1]+1)<<endl;
}

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

int main(){

    ll a,b;
    cin >> a >> b;
    if(a > 0 && b > 0){
        cout << "Positive" << endl;
    }
    else if(a < 0 && b < 0){
        int size = abs(a) - abs(b) + 1;
        if(size %2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
    else{
        cout << "Zero" << endl;
    }
}

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

int main(void){
  char o[50],e[50];
  int len,i,j,k;
  scanf("%s",o);
  scanf("%s",e);
  len = strlen(o)+strlen(e);
  j=k=0;
  for(i=0;i<len;i++){
    if(i%2==0){
      printf("%c",o[j]);
      j++;
    }else{
      printf("%c",e[k]);
      k++;
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b;
  cin >> a >> b;
  if(a==1) a = 10000;
  if(b==1) b = 10000;
  if(a==b){
    cout <<"Draw\n";
  }else if(a<b){
    cout <<"Bob\n";
  }else{
    cout <<"Alice\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    if (s == "ABC") s = "ARC";
    else s = "ABC";
    cout << s << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

map<char,string> btn = {
    {'1', "',.!?"},
    {'2', "abcABC"},
    {'3', "defDEF"},
    {'4', "ghiGHI"},
    {'5', "jklJKL"},
    {'6', "mnoMNO"},
    {'7', "pqrsPQRS"},
    {'8', "tuvTUV"},
    {'9', "wxyzWXYZ"}
};

string push(string s) {
    string ret = "";
    if (s[0] == '0') {
        for (int i=1; i<(int)s.size(); ++i) {
            ret += " ";
        }
    } else {
        int k = (s.size() - 1) % btn[s[0]].size();
        ret = btn[s[0]][k];
    }
    return ret;
}

int main() {
    string s;
    while (cin >> s) {
        string res = "", t = "";
        for (int i=0; i<(int)s.size(); ++i) {
            if (i == 0 || s[i] == s[i-1]) {
                t += s[i];
            } else {
                res += push(t);
                t = s[i];
            }
        }
        res += push(t);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
n = int(input())

primes = []
nums = list(range(2, 55556))
while True:
    p = nums[0]
    if p > int(55556**(1/2)):
        primes += nums
        break
    primes.append(p)
    nums = [num for num in nums if num%p > 0]
# print(primes[:20])

ans = [p for p in primes if str(p)[-1] == '1']
print(' '.join(list(map(str, ans[:n]))))


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

int main()
{
    int H, A;
    cin >> H;
    cin >> A;
    
    if(H % A == 0){
        cout << H/A << endl;
    }
    else{
        cout << H/A + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<ll, ll>P;
typedef vector<int>vec;
ll mod = pow(10, 9) + 7;

int main(){
    string s;cin>>s;
    int g=0,p=0;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='g'){
            g++;
        }
        else{
            p++;
        }
    }
    int P=n/2;
    int lose=max(0,p-P);
    int win=max(P-p,0);
    cout<<win-lose<<endl;
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;


int n, x;
int a[100005];
int main(){
	scanf("%d %d ", &n, &x);
	FORI(0,n) {
		scanf("%d ", &a[i]);
	}
	ll ans = 0LL;
	for (int i = 0; i < n - 1; i++) {
		if ((a[i] + a[i + 1]) > x) {
			int d = max((a[i] + a[i + 1]) - x,0);
			if (d > a[i + 1])
				a[i + 1] = 0;
			else
				a[i + 1] -= d;
			ans += d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

ans = s.count('R') * s.count('G') * s.count('B')
for i in 0..n
  t = 1
  while i + 2 * t < n
    ans -= 1 if s[i] != s[i+t] && s[i+t] != s[i+2*t] && s[i] != s[i+2*t]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14376
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;




//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;
int i, j, k, tmp, ans, cnt, N, M, T, K;
bool flag = true;


int main(void) {
	scanf("%d %d", &N, &K);
	REP(i, N) {
		scanf("%d", &tmp);
		if (tmp >= K) {
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


class BIT:
	def __init__(self, n):
		self.n = n
		self.data = [0]*(n+1)
		self.el = [0]*(n+1)
	def sum(self, i):
		s = 0
		while i > 0:
			s += self.data[i]
			i -= i & -i
		return s
	def add(self, i, x):
		# assert i > 0
		self.el[i] += x
		while i <= self.n:
			self.data[i] += x
			i += i & -i
	def get(self, i, j=None):
		if j is None:
			return self.el[i]
		return self.sum(j) - self.sum(i)


def main():
	n,q=MI()
	C=[0]+LI()

	lr=[]

	for i in range(q):
		l,r=MI()
		lr.append([l,r,i])
	lr.sort(key=lambda x:x[1])
	#print(lr)
	R=[-1]*(n+1)

	B=BIT(n)
	now=1
	ans=[-1]*(q)
	for l,r,i in lr:
		while now<=r:
			if R[C[now]]!=-1:
				B.add(R[C[now]],-1)
			R[C[now]]=now
			B.add(R[C[now]],1)
			now+=1
		#print(R)
		#print(B.el)
		ans[i]=B.get(l-1,r)
	print(*ans,sep="\n")



if __name__ == "__main__":
	main()


Measured memory_bytes: 224464
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(M);
  rep(i, M) cin >> A.at(i);

  int res = N;
  rep(i, M) {
    res -= A.at(i);
  }

  if (res < 0) res = -1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
const ll mod=1e9+7;
char s[N];
int dp[N][2];
int main()
{
    dp[0][1]=1;
    cin>>s+1;
    int len=strlen(s+1);
    for(int i=1;i<=len;i++)
    {
        if(s[i]=='1')
        {
            dp[i][1]=(2ll*dp[i-1][1])%mod;
            dp[i][0]=(3ll*dp[i-1][0]%mod+dp[i-1][1])%mod;
        }
        else
            dp[i][1]=dp[i-1][1],dp[i][0]=3ll*dp[i-1][0]%mod;
    }
    cout<<(dp[len][0]+dp[len][1])%mod;
    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_C
{
    class _003
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[][] array = new int[n][];
            for(int i = 0; i < n; i++)
            {
                array[i] = new int[2] { ReadInt(), i };
            }
            Array.Sort(array, (a, b) => a[0] - b[0]);
            int cnt = 0;
            for(int i = 0; i < n; i += 2)
            {
                if (array[i][1] % 2 == 1) cnt++;
            }
            WriteLine(cnt);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 22236
# https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC(heapq)%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
# ↓
# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4265763
# 頂点数10^5の時の高速化(🦍)
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

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

#n = map(int,input().split()) #n:頂点数　w:辺の数  s:始点
n = int(input()); w = n - 1;s = 0 # in case that graph is tree

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1
    edge[x].append([z,y])
    edge[y].append([z,x]) 

d = dijkstra_heap(s,edge)
# for i in range(len(ans)):
#     if d[i] == 10**20:
#         d[i] = "INF"

# print("\n".join([ for a in d]))
print("\n".join([str(t%2) for t in d]))

Measured memory_bytes: 54452
import math
n,m = map(int,input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print((math.factorial(n) * math.factorial(m))%(10**9+7))
else:
    print((2 * math.factorial(n) * math.factorial(m))%(10**9+7))


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

int main(){
vector<int>vec(3);
  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());


cout << vec[2]*10 + vec[1] + vec[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char a=scan.next().charAt(0);
		char b=scan.next().charAt(0);
		char c=scan.next().charAt(0);
		scan.close();
		System.out.println(String.valueOf(a).toUpperCase()
				+String.valueOf(b).toUpperCase()
				+String.valueOf(c).toUpperCase());
	}
}

Measured memory_bytes: 21844
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const [N, M, Q] = input[0].split(" ").map(el => parseInt(el));
    let list = []
    for(let i = 1; i<=Q; i++){
        list.push(input[i].split(" ").map(el => parseInt(el)))
    }
    let ans = 0
    const dfs = function(parent, sub){
        if(sub.length == N){
            let tmp = 0
            for(let i = 0; i<Q; i++){
                if(sub[list[i][1]-1] - sub[list[i][0]-1] == list[i][2]){
                    tmp += list[i][3]
                }
            }
            ans = Math.max(ans, tmp)
            return
        }
        for(let i = parent; i<=M; i++){
            sub.push(i)
            dfs(i, sub)
            sub.pop()
        }
    }
    dfs(1, [])
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 32456
import numpy as np
import heapq

(n,k),p = [list(map(int, s.split())) for s in open(0)]

p_np = np.array(p)
p_cumsum = (p_np[1:]>p_np[:-1]).cumsum()

c = [False] * n

_min = p[:k].copy()
_max = [-x for x in p[:k]]
heapq.heapify(_min)
heapq.heapify(_max)

ans = n - k + 1
no_change = False
if p_cumsum[k-2]==k-1:
    no_change = True

for i in range(n-k):
    decrease = False
    
    heapq.heappush(_min, p[i+k])
    heapq.heappush(_max, -p[i+k])
    
    while c[_min[0]]:
        heapq.heappop(_min)
    while c[-_max[0]]:
        heapq.heappop(_max)
    
    if (_min[0]==p[i] and -_max[0]==p[i+k]):
        ans -= 1
        decrease = True
    
    c[p[i]] = True
    
    if p_cumsum[i]+k-1 == p_cumsum[i+k-1]:
        if no_change and not decrease:
            ans -= 1
        no_change = True

print(ans)

Measured memory_bytes: 37388
/**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = (((1ll<<59ll)-1ll)*2ll)+1ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
/// My Code -------------------------------------------------

int arr[maxn], n, m, sum, ans;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    cin >> n >> m;

    for(int i=1; i<=n; i++){
        cin >> arr[i];
        sum += arr[i];
    }

    for(int i=1; i<=n; i++)
        if( arr[i] >= ( sum + 4 * m - 1 ) / ( 4 * m ) )
            ans++;

    if( ans >= m ) cout << "Yes\n";
        else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
  int i, cnt=0;
  string w, T;
  cin >> w;
  for (i=0; i<w.size(); i++) {
    w[i] = tolower(w[i]);
  }
  
  while(1){
    cin >> T;
    if (T=="END_OF_TEXT") break;
    for (i=0; i<T.size(); i++) {
      T[i] = tolower(T[i]);
    }
    if (T==w) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3208
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
vector<ll>dp(6050,-INF);
int main()
{
	int n,t;
	cin>>n>>t;
	vector<PII>p(n);
	for(int i=0;i<n;i++)cin>>p[i].fi>>p[i].se;
	sort(all(p));
	dp[0] = 0;
	for(int i=0;i<n;i++){
		for(int j=6001;j-p[i].fi>=0;j--){
			if(dp[j-p[i].fi] == -INF)continue;
			if(j > t && j-p[i].fi < t)dp[j] = max(dp[j],dp[j-p[i].fi]+p[i].se);
            else if(j<=t)dp[j] = max(dp[j],dp[j-p[i].fi]+p[i].se);
		}
	}
	ll ans = 0;
	for(int i=0;i<6050;i++)ans = max(ans,dp[i]);
	cout<<ans;
	
}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int n = S.size();
    for (int i = 0; i < S.size()-1; i++)
    {
        if(S[i+1]==S[i]) n--;
    }
    cout << n << endl;
}


Measured memory_bytes: 512
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return s
    
A = sieve(100000)

A[0] = A[1] = False
#A = [False]+A

B=[0]*100002

for i in range(100000):
    if A[i] and (i+1)%2 == 0:
        if A[int((i+1)/2)]:
            B[i] = B[i-1]+1
        else:
            B[i] = B[i-1]          
    else:
        B[i] = B[i-1]
        
q = int(input())

for i in range(q):
    l,r = [int(i) for i in input().split()]
    print(B[r] - B[l-1])

Measured memory_bytes: 4980
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        long nrow = Long.parseLong(s[0]);
        long mcol = Long.parseLong(s[1]);
        long ans;
        
        if (nrow == 2 || mcol == 2) {
            ans = 0;
        }
        else if (nrow > 2 && mcol > 2) {
            ans = (nrow-2) * (mcol-2);
        }
        else if (nrow == 1 && mcol == 1) {
            ans = 1;
        }
        else {
            ans = Math.max(nrow, mcol)-2;
        }
        
        System.out.println(ans);
    }
}





Measured memory_bytes: 22100
fun main() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0L
    for (b in 1..n) {
        ans += (n / b) * (b - k).coerceAtLeast(0)
        ans += ((n % b) - k + 1).coerceAtLeast(0)
    }
    if (k == 0) {
        ans -= n
    }
    println(ans)
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll h, w, n, a, b;

	cin >> h >> w >> n;

	vector<pair<ll, ll>> v;

	REP(i, n) {
		cin >> a >> b;
		REP(j, 3) {
			REP(k, 3) {
				if (a - j > 0 && a - j + 2 <= h && b - k > 0 && b - k + 2 <= w) {
					v.push_back(make_pair(a - j, b - k));
				}
			}
		}
	}

	sort(v.begin(), v.end());

	v.push_back(make_pair(-1, -1));
	
	ll cnt = 0;
	ll sum = 0;
	vector<ll> ans(10, 0);

	REP(i, v.size() - 1) {
		cnt++;
		if (v[i] != v[i + 1]) {
			ans[cnt]++;
			sum++;
			cnt = 0;
		}
	}

	ans[0] = (h - 2) * (w - 2) - sum;

	REP(i, 10) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 18792
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
int q;
int type[200005];
int f[200005];
char c[200005];

int main(void){
	cin >> s;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf(" %d",&type[i]);
		if(type[i]==2){
			scanf(" %d %c",&f[i],&c[i]);
			f[i]--;
		}
	}
	deque<char> res[2];
	int flag=0;
	for(int i=q-1;i>=0;i--){
		if(type[i]==1){
			flag=1-flag;
		}else{
			if((flag+f[i])%2==0)res[(flag+f[i])%2].push_back(c[i]);
			else{
				res[(flag+f[i])%2].push_front(c[i]);
			}
		}
	}
	string ans="";
	for(int i=0;i<res[0].size();i++){
		ans+=res[0][i];
	}
	if(flag==0){
		for(int i=0;i<s.size();i++){
			ans+=s[i];
		}
	}else{
		for(int i=s.size()-1;i>=0;i--){
			ans+=s[i];
		}
	}
	
	for(int i=0;i<res[1].size();i++){
		ans+=res[1][i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
N,A,B,C=map(int,input().split())
S = [input() for _ in range(N)]
table = [A,B,C]
ans = []

def ci(s):
    if s == 'AB':
        return 0,1
    elif s == 'BC':
        return 1,2
    else:
        return 0,2

if A+B+C == 0:
    print('No')
    exit()
elif A+B+C == 1:
    for s in S:
        i,j = ci(s)
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        else:
            if table[i] == 0:
                table[i] = 1
                table[j] = 0
                ans.append(i)
            else:
                table[j] = 1
                table[i] = 0
                ans.append(j)

else:
    for k in range(N):
        i,j= ci(S[k])
        if table[i] > table[j]:
            i,j = j,i
        # print(table,i,j)
        if k + 1 < N:
            i2,j2 = ci(S[k+1])
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        elif table[i] == 0 and table[j] > 0:
            table[i] += 1
            table[j] -= 1
            ans.append(i)
        else:
            table[i] += 1
            table[j] -= 1
            if k + 1 < N:
                if table[i2] == 0 and table[j2] == 0:
                    table[i] -= 2
                    table[j] += 2
                    ans.append(j)
                else:
                    ans.append(i)
            else:
                ans.append(i)

print('Yes')
L = ['A','B','C']
for a in ans:
    print(L[a])

Measured memory_bytes: 17096
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	m := map[int]bool{}
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			m[a] = true
		}
	}
	fmt.Println(n - len(m))
}


Measured memory_bytes: 2544
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5],b,c;
int main()
{
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[2]-a[1]==a[3]-a[2])
        puts("YES");
    else
        puts("NO");
}

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A = cin.ArrayLong(3 * N);
        long ans = 0;
        Array.Sort(A);
        Array.Reverse(A);

        for (int i = 0; i < N; i++)
        {
            ans += A[1 + i * 2];
        }

        Console.WriteLine(ans);
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

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

    public long nextLong()
    {
        return long.Parse(next());
    }

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

    public double nextDouble()
    {
        return double.Parse(next());
    }


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



Measured memory_bytes: 41676
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll a,b,c ;
	cin >> a >> b >> c ;
	cout << b/c-(a-1)/c << endl ;
}

Measured memory_bytes: 3624
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int num[100009]={0},a[100009]={0},f=0;
int main()
{
    int n,i,mi;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        int n1;
        scanf("%d",&n1);
        num[i]=n1;
    }
    a[1]=num[1];
    f++;
    mi=a[1];
    for(i=2;i<=n;i++){
        if(num[i]<=mi){
            mi=num[i];
            a[++f]=num[i];
        }
        else{
                for(int j=1;j<=f;j++){
                    if(a[j]<num[i]){
                        a[j]=num[i];
                        if(j==f)
                            mi=num[i];
                            break;
                    }
                }
        }
        //printf("%d  %d\n",mi,f);

    }
    printf("%d\n",f);

    return 0;
}


Measured memory_bytes: 4480
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] s = new int[N];
        for (int i = 0; i < N; ++i) {
            s[i] = sc.nextInt();
        }

        int sum = Arrays.stream(s).sum();
        if (sum % 10 != 0) {
            _out.println(sum);
        } else {
            Arrays.sort(s);
            for (int i = 0; i < N; ++i) {
                if (s[i] % 10 != 0) {
                    int sum2 = 0;
                    for (int j = 0; j < N; ++j) {
                        sum2 += s[j];
                        if (sum2 % 10 != 0 && sum2 < s[i]) {
                            _out.println(sum - sum2);
                            return;
                        }
                    }
                    _out.println(sum - s[i]);
                    return;
                }
            }
            _out.println(0);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 28620
N = int(input())
A = [int(input()) for i in range(N)]
A_Index = sorted(range(len(A)), key = lambda k: A[k])
A = sorted(A)

for i in range(len(A)):
    if i == A_Index[-1]:
        print(A[-2])
    else:
        print(A[-1])


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, k;
  cin >> a >> b >> k;
  int num = a;
  for(num; num <= min(a + k - 1, b); ++num)
  {
    cout << num << endl;
  }
  for(num = max(num, b - k + 1); num <= b; ++num)
  {
    cout << num << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(){
	int a, b, c, i=0,j;
	scanf("%d%d%d", &a, &b, &c);
	for (j=a; j<=b; j++){
		if(c%j==0){
			i++;
		}
	}
	printf("%d\n", i);
}


Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>

using namespace std;

int main(void){

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<int> total(n);
    int ans = 0;
    for(int i = 0;i < n;i++) cin >> p[i];
    for(int i = 0;i < n;i++) p[i]++;

    total[0] = 0;
    for(int i = 1;i < n+1;i++) total[i] = p[i-1] + total[i-1];

    for(int i = 0;i < n-k+1;i++){
        ans = max(ans, total[i+k]-total[i]);
    }

    printf("%.12lf\n",ans/2.0);


    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>

int main() {
 
  int n,q,i,j,C;

  scanf("%d", &n);

  long X[n];

  for(i = 0; i < n; i++) scanf("%ld", X+i);

  scanf("%d", &q);

  long T;C = 0;

  for(i = 0; i < q; i++) {

    scanf("%ld",&T);

    for(j = 0; j < n; j++) if(T == X[j]) { C++;break;}
   
   }

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

   return 0;

}

Measured memory_bytes: 1848
N = int(input())
A = input().split()
Q = int(input())
BC = []
for _ in range(Q):
    b,c = input().split()
    BC.append([b,c])
dic = {}
for i in range(N):
    if A[i] in dic:
        dic[A[i]] += 1
    else: dic[A[i]] = 1
S = sum([int(a) for a in A])
for i in range(Q):
    b,c = BC[i]
    if b in dic:
        num = dic[b]
        S += num*(int(c)-int(b))
        print(S)
        if c in dic:
            dic[c] += num
            dic.pop(b)
        else:
            dic[c] = num
            dic.pop(b)
    else: print(S)

Measured memory_bytes: 43824