akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int K;
int A[100004];

signed main(){
    scanf("%lld",&K);
    rep(i,K){
        scanf("%lld",&A[i]);
    }
    A[K]=1;
    int L=2,R=2;
    rep(i,K){//N_jの値を求めて次に進むループ
        int j=K-1-i;
        L%A[j]?L=((int)(L/A[j])+1)*A[j]:L=L ;
        R=(R-R%A[j])+A[j]-1;
       if(L>R){printf("-1\n");return 0;}
    }
    printf("%lld %lld\n",L,R);
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    int cnt = 0;
    rep(i, n)if(a[i] % 2 == 1)cnt++;
    if(cnt % 2 == 0)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

const int MAXN = 1e5 + 10;

long long n, T, k, m;

long long a[MAXN], dp[MAXN][110], w[MAXN], v[MAXN];

string s, t;

const int MOD = 1e9 + 7;

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

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

    for (int i = 0; i <= k; i++) {
        long long cur = -1e18;
        for (int j = 1; j <= n; j++) {
            if (i - w[j] >= 0)
                cur = max(cur, dp[i - w[j]][j - 1] + v[j]);
            
            cur = max(cur, dp[i][j - 1]);

            dp[i][j] = cur;
        }
    }

    cout << dp[k][n];
}


Measured memory_bytes: 89484
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

    public static void main(String[] args) throws IOException {
        int overCount = 0, empValue, n, empID;
        long price, quantitiy;
        long total;
        long[] emp = new long[4001];

        Queue<Integer> iQueue = new LinkedList<Integer>();

        BufferedReader bReader =
                new BufferedReader(new InputStreamReader(System.in));

        aryClear(emp);

        while ((empValue = Integer.parseInt(bReader.readLine())) != 0) {
            n = 0;

            while (n < empValue) {
                String str = bReader.readLine();
                String[] editedstr = str.split(" ");
                empID = Integer.parseInt(editedstr[0]);         //社員番号
                price = Integer.parseInt(editedstr[1]);         //単価
                quantitiy = Integer.parseInt(editedstr[2]);     //販売個数
                total = price * quantitiy;                      //実績

                if (emp[empID] == -1) {                         //初めての入力
                    emp[empID] = total;
                    iQueue.offer(empID);
                } else if (emp[empID] <= 1000000) {   //2回目以降の入力かつ100万を超えない値の場合
                    emp[empID] += total;
                    
                } else {
                }
                n++;
            }

            for (int a : iQueue) {
                //System.out.println(a);        //debug
                if (emp[a] >= 1000000) {
                    System.out.println(a);
                    overCount++;
                }
            }
            if (overCount == 0) {
                System.out.println("NA");
            }
            overCount = 0;
            iQueue.clear();
            aryClear(emp);
            //emp = new long[4001];
        }
    }

    public static void aryClear(long[] ary) {
        for (int i = 0; i <= 4000; i++) {
            ary[i] = -1;
        }
    }
}

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

int main() {
  ll n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n){
    cin>>h[i];
  }
  int max_ans=0,ans=0;
  rep(i,n-1){
    if(h[i]<h[i+1]){
      max_ans=max(max_ans,ans);
      ans=0;
      continue;
    }
    ans++;
  }
  max_ans=max(max_ans,ans);
  cout<<max_ans<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int d = int.Parse(Console.ReadLine());
            string christmas = "Christmas ";
            string eve = "";
            while (d != 25)
            {
                eve = "Eve " + eve;
                d++;
            }
            
            Console.WriteLine((christmas + eve).Trim());

        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int MAXN=3e5+10;
int n,ans_fin,a[MAXN],f[MAXN],b[MAXN],s_max;
int tree[MAXN];
ll sum;
int lowbit(int x)
{
	return x&(-x);
}
void add(int x)
{
	while (x<=s_max)
	{
		tree[x]++; x+=lowbit(x);
	}
}
int find(int x)
{
	int ans=0;
	while (x)
	{
		ans+=tree[x]; x-=lowbit(x);
	}
	return ans;
}
int pan(int x)
{
	for (int i=1;i<=n;i++)
	if (a[i]<=x) f[i]=f[i-1]+1; else f[i]=f[i-1];
	for (int i=1;i<=n;i++) f[i]=f[i]*2-i+n+1;
	memset(tree,0,sizeof(tree));
	add(n+1);
	ll ans=0;
	for (int i=1;i<=n;i++) 
	{
		ans+=(ll)find(f[i]-1);
		add(f[i]);
	}
	return ans>=sum;
}
void s(int l,int r)
{
	if (l>r) return;
	int mid=(l+r)/2;
	bool t=pan(b[mid]);
	if (t) {
		ans_fin=b[mid]; s(l,mid-1);
	}
	else 
	{
	s(mid+1,r);
    }
}
int main(){
	scanf("%d",&n);
	s_max=n*3+1;
	sum=((ll)n*(ll)(n-1)/2+(ll)n)/2+1;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	s(1,n);
	printf("%d",ans_fin);
}

Measured memory_bytes: 3840
def a165(k, a, b):

    ans = "NG"
    count = k
    while count <= 1100:
        if a <= count <= b:
            ans = "OK"
            break
        else:
            count += k

    return ans
def main():
    k = int(input())
    a, b = map(int, input().split())
    print(a165(k, a, b))

if __name__ == '__main__':
    main()

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d){
    cout << "Left" << endl;
  }else if (a + b < c + d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;


int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a % 2 == 0 || b % 2 == 0) {
		PRINTS("Even");
	}
	else {
		PRINTS("Odd");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

int main(){
    int n; cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; ++i){
    	int tmp; cin >> tmp;
        ++mp[tmp];
    }
    int total = mp.size();
    int num = 0;
    for(auto it : mp){
    	if(it.second % 2 == 0){++num;}
    }
    if(num % 2 == 1){--total;}
    cout << total << endl;
    return 0;
}

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

int main()
{
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<int> s;
	vector<int> ord(n + 1, -1);
	int v = 1;
	int c = 1;
	int l = 0;
	while (ord[v] == -1) {
		ord[v] = s.size();
		s.push_back(v);
		v = a[v - 1];
	}
	c = s.size() - ord[v];
	l = ord[v];

	if (k < l) cout << s[k] << endl;
	else cout << s[(k - l) % c + l] << endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, n, m, p);
  vector<vector<pair<ll, ll>>> g(n + 1);
  vector<vector<int>> bg(n + 1);
  rep(i, m) {
    in(int, a, b, c);
    g[a].push_back({b, c});
    bg[b].push_back(a);
  }

  vector<bool> seen(n + 1);
  seen[n] = true;
  queue<int> que;
  que.push(n);
  while (!que.empty()) {
    int here = que.front();
    que.pop();
    for (int there : bg[here]) {
      if (!seen[there]) {
        seen[there] = true;
        que.push(there);
      }
    }
  }

  vector<bool> v(n + 1);
  vector<ll> d(n + 1);
  v[1] = true;
  d[1] = 0;
  int updated = -1;
  rep(i, n * 2) {
    for (int a = 1; a <= n; ++a) {
      if (!v[a]) continue;
      for (const auto [b, c] : g[a]) {
        if (!seen[b]) continue;
        ll nd = d[a] + c - p;
        if (!v[b] || d[b] < nd) {
          updated = i;
          v[b] = true;
          d[b] = nd;
        }
      }
    }
  }
  if (updated < n) {
    out(max(d[n], 0LL));
    return 0;
  } else {
    out(-1);
    return 0;
  }
}


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

int main() {
  string s; cin >> s;
  //YYMMかMMYY
  int a, b;
  a = stoi(s.substr(0,2));
  b = stoi(s.substr(2,2));
  bool a_bool = false, b_bool = false;
  if (1 <= a && a <= 12) a_bool = true;
  if (1 <= b && b <= 12) b_bool = true;
  if (a_bool && b_bool) cout << "AMBIGUOUS" << endl;
  else if (a_bool) cout << "MMYY" << endl;
  else if (b_bool) cout << "YYMM" << endl;
  else cout << "NA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
#define endl '\n'
#define pb push_back
#define mpr make_pair
#define ff first
#define ss second
#define PI 3.1415926535897932384626
#define mod 1000000007
#define modd 998244353

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n;
	return 0;
}


Measured memory_bytes: 3636
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

// int a[200001],b[200001];

int32_t main()
{
    FIO
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c=c-b;
        if(c<=0) break;
        a=a-d;
        if(a<=0) break;
    }
    if(c<=0) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,N,n) for(int i=N;i>=n;i++)
#define CH(n,a,b) (a)<=(n)&&(n)<(b)
#define p(s) cout<<s<<endl;
typedef long long ll;
using namespace std;

int main() {
	int x, y, s;
	while(cin>>x>>y>>s, x||y||s){
		int ans=0;
		REP(i, 1, s){
			REP(j, 1, s){
				int tax_x=i*(100+x)/100 + j*(100+x)/100;
				if(tax_x == s){
					int val;
					val=i*(100+y)/100 + j*(100+y)/100;
					ans=max(ans, val);
				}
			}
		}

		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
int main(void){
    int count, x;
    scanf("%d", &count);
    for(int i=1; i<=count; i++){
    	x = i;
        if(!(x%3)){
            printf(" %d", i);
            continue; 
        }
        while(x){
            if(x%10 == 3){
                printf(" %d", i);
                break;
            }
            x /= 10;
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define count(v, t) count(v.begin(), v.end(), t)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

int main() {
  string s;
  cin >> s;
  int r = count(s, '1');
  cout << r << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N, M;
    int sum = 0;

    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }

    for (int i = 0; i < N; i++) {
        int count = 0;
        string cmd = s.at(i);
        for (int j = 0; j < N; j++) {
            if (s.at(j) == cmd) {
                count++;
            }
        }
        for (int j = 0; j < M; j++) {
            if (t.at(j) == cmd) {
                count--;
            }
        }
        sum = max(sum, count);
    }

    cout << sum << endl;

    return 0;
}

// ABC


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = list(tuple(map(int, input().split())) for i in range(N)) #改行行列

    S.sort(key=itemgetter(1))
    cur=0
    for a,b in S:
        cur+=a
        if b<cur:
            print('No')
            return
        
        

    print('Yes')




if __name__ == "__main__":
    main()

Measured memory_bytes: 113048
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll i,j,k;
  ll A[N],B[N];
  rep(i,N) cin>>A[i];
  rep(i,N) B[i]=A[i];
  ll plus=0,minus=0,zero=0;
  rep(i,N){
    if(A[i]>0) plus++;
    else if(A[i]<0) minus++;
    else zero++;
  }
  ll ans=0;
  rep(i,N) ans+=abs(A[i]);
  sort(A,A+N);
  if(minus==0){
    ans-=abs(2*A[0]);
  }
  else if(plus==0){
    ans-=abs(2*A[N-1]);
  }
  cout<<ans<<endl;
  ll l=0,r=N-1;
  rep(i,N){
    if(r-l==1){
      cout<<A[r]<<" "<<A[l]<<endl;
      return 0;
    }
    else if(plus>minus){
      cout<<A[l]<<" "<<A[r]<<endl;
      A[l]=A[l]-A[r];
      r--;
      plus--;
    }
    else{
      cout<<A[r]<<" "<<A[l]<<endl;
      A[r]=A[r]-A[l];
      l++;
      minus--;
    }
  }
}


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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int l, u;
    l = max(a, c);
    u = min(b, d);

    cout << max(u - l, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())  
    H = list(map(int, input().split()))
    cnt = 0
    maxcnt = 0
    for i in range(0,N-1):
        if H[i] >= H[i+1]:
            cnt += 1
        else:
            maxcnt = int(max([maxcnt,cnt]))
            cnt = 0

    print(int(max([maxcnt,cnt])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int n = in.nextInt();
		int[] a = new int[n * 3];
		for(int i = 0; i < n * 3; i++) a[i] = in.nextInt();
		Arrays.sort(a);
		long sum = 0;
		for(int i = 0; i < n; i++) {
			sum += a[3 * n - 2 - 2 * i];
		}
		System.out.println(sum);
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

Measured memory_bytes: 47272
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    if(n%2 == 1){
        for(int i = n; 0 < i; i -= 2) cout << a[i-1] << " ";
        for(int i = 2; i < n; i += 2) cout << a[i-1] << " ";
    }
    else{
        for(int i = n; 0 < i; i -= 2) cout << a[i-1] << " ";
        for(int i = 1; i < n; i += 2) cout << a[i-1] << " ";
        
    }
}


Measured memory_bytes: 3840
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{
	return (M*m) / GCD(max(M, m), min(M, m));

}



int n, n2, k;
string s, s2;
int dp[3005][3005];
int solve(int i,int j)
{
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	if (i >= n||j>=n2)
		return 0;
	if (s[i] == s2[j])
	{
		return dp[i][j] = 1 + solve(i + 1, j + 1);
	}
	int m = 0, im = -1;


	return dp[i][j] = max(solve(i,j+1),solve(i+1,j));

}
void fun(int i, int j)
{
	if (i >= n || j >= n2)
		return;
	if (s[i] == s2[j])
	{
		cout << s[i] ;
		fun(i+1, j + 1);
	}


	else if (dp[i][j] == (solve(i, j + 1)))
	{
		fun(i, j + 1);
	}
	else if (dp[i][j] == solve(i + 1, j))
	{
		fun(i+1, j);

	}

}

int main()
	{
	cin >> s >> s2;
	memset(dp, -1, sizeof dp);
	n = s.size(); n2 = s2.size();
	int x=solve(0, 0);
	fun(0, 0);
}


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

int solve(int, int, int, int);

int main(){
	int N,x,y,b,p;
	cin >> N;
	while(N-- != 0){
		cin >> x >> y >> b >> p;
		cout << solve(x, y, b, p) << endl;
	}
	return 0;
}

int solve(int x, int y, int b, int p){
	int ans = x*b + y*p;
	if(b<5 && p<2){
		if(ans > (x*5 + y*2)*0.8)
			ans = (x*5 + y*2)*0.8;
	}else if(b < 5){
		if(ans > (x*5 + y*p)*0.8)
			ans = (x*5 + y*p)*0.8;
	}else if(p < 2){
		if(ans > (x*b + y*2)*0.8)
			ans = (x*b + y*2)*0.8;
	}else{
		ans *= 0.8;
	}
	return ans;
}

Measured memory_bytes: 1160
/*
No not today :3
*/
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define mp make_pair
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
using namespace std;
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))); }
ll POWER(ll x,ll y, ll m){
    if(y==0) return 1;
    if(y%2==0) { ll temp= POWER(x,y/2,m);   temp*=temp; temp%=m;	return temp;}
    ll temp= POWER(x,y-1,m);    temp*=x;	temp%=m;	return temp;
}

ll POWER(ll x,ll y){
    if(y==0) return 1;
    if(y%2==0) { ll temp= POWER(x,y/2);   temp*=temp;  return temp;	}
    ll temp= POWER(x,y-1);    temp*=x;	return temp;
}
int n,k;
vector<int>v[2010];
int ans=20010;
int dis[2010][2010];
bool vis[2010];
int xx[2010],yy[2010];
void bfs(int x){
    dis[x][x]=0; vis[x]=1;
    queue<int>q;
    q.push(x);
    int cnt=0;
    memset(vis,0,sizeof vis);
    vis[x]=1;
    while(!q.empty()){
        int node=q.front(); q.pop();
        int sz=v[node].size();
        for(int i=0;i<sz;i++){
            int nx=v[node][i];
            if(!vis[nx]){
                dis[x][nx]=dis[x][node]+1; vis[nx]=1;
                q.push(nx);
                //if(dis[nx]>k/2 && k%2==0)cnt++;
                //if(k%2==1 && (dis[nx]>(k-1)/2 || dis[node]>(k-1)/2))cnt++;
            }
        }
    }
    //cout<<x<<" "<<cnt<<endl;
    //ans=min(ans,cnt);
}
void _1(){
    for(int i=1;i<=n;i++){
        int cnt=0;
        for(int j=1;j<=n;j++){
            if(dis[i][j]>k/2)cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}
void _2(){
    for(int i=0;i<n-1;i++){
        int cnt=0;
        for(int j=1;j<=n;j++){
            int u=xx[i], vv=yy[i];
            if(dis[u][j]> (k-1)/2 && dis[vv][j]>(k-1)/2)cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}
int main(){
    //cout.precision(12);
    ifstream fin("ali");
    cin>>n>>k;
    //k++;
    for(int i=0;i<n-1;i++){
        cin>>xx[i]>>yy[i]; v[xx[i]].pb(yy[i]); v[yy[i]].pb(xx[i]);
    }
    for(int i=1;i<=n;i++)bfs(i);
    if(k%2==0)_1();
    else _2();
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
string s; int a, b, c, d;
int main() {
	while(cin >> s, s != "#") {
		cin >> a >> b >> c >> d; s += '/'; a--, b--, c--, d--;
		int pre = 0; vector<string> t;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == '/') {
				t.push_back(s.substr(pre, i - pre));
				pre = i;
			}
		}
		vector<vector<int> > v(t.size());
		for(int i = 0; i < t.size(); i++) {
			for(int j = 0; j < t[i].size(); j++) {
				if(t[i][j] == 'b') v[i].push_back(1);
				else for(int k = 0; k < t[i][j] - 48; k++) v[i].push_back(0);
			}
		}
		v[a][b] = 0; v[c][d] = 1;
		for(int i = 0; i < v.size(); i++) {
			if(i) cout << '/';
			string ret; int pre2 = 0; v[i].push_back(-1);
			for(int j = 1; j < v[i].size(); j++) {
				if(v[i][j] != v[i][j - 1]) {
					if(v[i][j - 1] == 0) ret += (j - pre2) + 48;
					pre2 = j;
				}
				if(v[i][j - 1] == 1) ret += 'b';
			}
			cout << ret;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import numpy as np 
from collections import Counter

N, K, Q = map(int, input().split())
A = np.array([K]*N)-Q

correct = Counter([int(input())-1 for _ in range(Q)])
#correct = sorted(correct.;items(), key:lambda x: x[0])

for i in range(N):
  if i in correct.keys():
    A[i] += correct[i]
  print("No" if A[i] < 1 else "Yes")



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

typedef long long ll;

int main(){
	char x[105];
	int n;
	scanf("%d",&n);
	getchar();
	scanf("%s",x);
	if(n%2==1){
		printf("No");
		return 0;
	}
	n/=2;
	for(int i=0;i<n;i++){
		if(x[i]!=x[i+n]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll x,y;
  cin >> x >> y;
  if(x==4||x==6||x==9||x==11){
    x=11;
  }
  else if(x==2){
    x=2;
  }
  else{
    x=1;
  }
  if(y==4||y==6||y==9||y==11){
    y=11;
  }
  else if(y==2){
    y=2;
  }
  else{
    y=1;
  }
  if(x==y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e9+18
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=105;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.14159265359
#define mod 1000000007
 ll dp[102][1000005];
int main()
{   fastio;
	ll  n,k,i,j;
	cin>>n>>k;
	ll  a[n];
	for(i=0;i<n;i++)
   {
   	cin>>a[i];

   }
  
  for(i=0;i<=k;i++)
  {
  	
  	if(i<=a[0])
  		dp[1][i]=1;
  	else
  		dp[1][i]=0;

  }
  for(i=2;i<=n;i++)
  {
    for(j=0;j<=k;j++)
    {
    	if(j==0)
    		dp[i][j]=dp[i-1][j];
    	else{
    		dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
    		if(j-a[i-1]-1>=0)
    			dp[i][j]=(dp[i][j]+mod-dp[i-1][j-a[i-1]-1])%mod;
    	}
    }
  
  }

cout<<dp[n][k];
 
}

Measured memory_bytes: 289024
def resolve():
    x = int(input().strip())
    a =int( x // 1.08 )
    b =int( -1 * (-1 * x // 1.08))
    ans = ':('
    if int(a * 1.08) == x:
        ans = int(a)
    if int(b * 1.08) == x:
        ans = int(b)
    print(ans)
resolve()


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int64_t, int>> A;
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        A.push_back(make_pair(a, b));
    }

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

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        if (m > A[i].second){
            ans += A[i].first * A[i].second;
            m -= A[i].second;
        }else{
            ans += A[i].first * m;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  map<ll,ll> memo;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    memo[a]++;
  }
  ll four=0;
  ll ue=0,shita=0;
  for(auto itr=memo.begin();itr!=memo.end();itr++){
    if((itr->second)>=4) four=itr->first;
    if((itr->second)>=2){
      if((itr->first)>=ue) {
        shita=ue;
        ue=itr->first;
      }
      else if((itr->first)>=shita) shita=itr->first;
    }
  }
  cout<<max(four*four,ue*shita)<<endl;
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	
	cout<<max(A*B,C*D)<<endl;
	
    return 0;
}



Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,a[100005],ans;
int main(){
    ans=orz;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n-k+1;++i){
        int j=i+k-1;
        if(a[j]<=0)ans=min(ans,-a[i]);
        else if(a[i]>=0)ans=min(ans,a[j]);
        else ans=min(ans,a[j]-a[i]+min(a[j],-a[i]));
    }
    printf("%d\n",ans);
	//system("pause");
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




void smain() {

    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;

    for(int i=0;i<n;i++){
        int u=i,v=n-1-i;
        int y=a+c*u-d*v;
        int w=a+d*u-c*v;
        if(y<=b&&b<=w){
            cout<<"YES";
            return;
        }
    }

    cout<<"NO";




}

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

int main(void) {
    int d, n, t, ans, tmp, d_cnt, n_cnt;
    cin >> d >> n;
    ans = 0;
    if(d == 0) t = 1;
    else if(d == 1) t = 100;
    else if(d == 2) t = 10000;
    while(1){
        ans += t;
        tmp = ans;
        d_cnt = 0;
        while(1){
            if(tmp % 100 == 0){
                d_cnt++;
                tmp /= 100;
            }
            else break;
        }
        if(d_cnt == d){
            n_cnt++;
        }
        if(n_cnt == n) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+10;
int gcd(int n,int m)
{
	if(n==0)
		return m;
	else
		return gcd(m%n,n);
}
int dp[N][4];
int a[N][4];
int n;
int go(int pos,int last)
{
	if(pos==n+1)
		return 0;
	int &ans=dp[pos][last];
	if(ans!=-1)
		return ans;
	ans=0;
	if(pos==1)
	{
			ans=max(ans,a[pos][2]+go(pos+1,2));
			ans=max(ans,a[pos][3]+go(pos+1,3));
			ans=max(ans,a[pos][1]+go(pos+1,1));

	}
	else
	{
		if(last==1)
		{
			ans=max(ans,a[pos][2]+go(pos+1,2));
			ans=max(ans,a[pos][3]+go(pos+1,3));
		}
		else if(last==2)
		{
			ans=max(ans,a[pos][1]+go(pos+1,1));
			ans=max(ans,a[pos][3]+go(pos+1,3));
		}
		else
		{
			ans=max(ans,a[pos][2]+go(pos+1,2));
			ans=max(ans,a[pos][1]+go(pos+1,1));
		}
	}
	return ans;
}
int32_t main()
{
	
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	}
	cout<<go(1,0)<<endl;

}

Measured memory_bytes: 11136
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i - 1 >= 0 and i + 1 < n:
        if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


struct Enemy {
    ll hp;
    ll ap;
    ll sp;
    ll dp;
};

ostream& operator<<(ostream& os, const Enemy& v)
{
    os << "[hp:" << v.hp << ",ap:" << v.ap << ",sp:" << v.sp << ",dp:" << v.dp << "]" << endl;
    return os;
}

int main()
{
    ll n;
    cin >> n;

    ll H, A, D, S;
    cin >> H >> A >> D >> S;
    vector<Enemy> enemy;
    for (int i = 0; i < n; i++) {
        ll h, a, d, s;
        cin >> h >> a >> d >> s;
        if (a - D <= 0) {
            continue;
        }
        if (A - d <= 0) {
            cout << -1 << endl;
            return 0;
        }
        enemy.push_back(Enemy{
            h,
            max(a - D, 0LL),
            s - S,
            max(A - d, 0LL),
        });
    }
    const int size = enemy.size();
    //    show(enemy);
    vector<ll> turns(size);
    using P = pair<ll, ll>;
    vector<P> p(size);
    ll sum = 0;
    for (int i = 0; i < size; i++) {
        const auto& e = enemy[i];
        if (e.sp < 0) {
            sum -= e.ap;
        }
        const ll t = (e.hp + (e.dp) - 1) / e.dp;
        turns[i] = t;
        p[i] = make_pair(e.ap, t);
    }
    auto comp = [](const P& p1, const P& p2) -> bool {
        return p1.first * p2.second > p1.second * p2.first;
    };
    sort(p.begin(), p.end(), comp);
    //    show(p);
    vector<ll> tsum(size);
    for (int i = 0; i < size; i++) {
        if (i == 0) {
            tsum[i] = p[i].second;
        } else {
            tsum[i] = tsum[i - 1] + p[i].second;
        }
        sum += p[i].first * tsum[i];
        if (sum >= H) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sum << endl;

    return 0;
}

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

int main(){
    int a;
    scanf("%d",&a);
    int ar[a];
    vector<int> v;
    for(int i=0;i<a;i++){
        scanf("%d",&ar[i]);
        v.push_back(ar[i]);
    }
    long sum=0;
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=1;i<v.size();i++){
        sum+=(v[i]-v[i-1]);
    }
    cout<<sum<<endl;
    
    return 0;
}

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

int main(){
  int r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x=x*r-d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int[] takos = new int[n];
		for(int i = 0; i < n; i++) {
			takos[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				ans += takos[i] * takos[j];
			}
		}
		System.out.println(ans);
		

	}

}


Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a + b == 4){
    cout << "2"  << endl;
  }
  else if(a + b == 5){
    cout << "1" << endl;
  }
  else if (a + b == 3){
    cout << "3" << endl;
  }
}

Measured memory_bytes: 256
S = gets.chomp.chars
score = 0
p_count = 0
S.reverse.each.with_index do |ch, i|
  g_count = S.size - p_count
  can_p = g_count - 1 >= p_count + 1
  if can_p
    score += ch == 'g' ? 1 : 0
    p_count += 1
  else
    score += ch == 'g' ? 0 : -1
  end
end
puts score


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

using LL = long long;
using Point = pair<int, int>;
using Interval = pair<int, int>;
using Event = pair<int, bool>;
const bool IN = false;
const bool OUT = true;

int N, K;
string S;

LL loop(auto& p) {
  set<Point> s(begin(p), end(p));
  LL res = 0;
  for(auto i: s) {
    auto x = i.first, y = i.second;
    if(s.count({x+1, y}) && s.count({x, y+1}) && s.count({x+1, y+1})) ++res;
  }
  return res;
}

LL solve(auto& p, int a, int b) {
  // vectorize
  map<Point, set<Interval>> vec;
  for(auto i: p) {
    auto k = i.first / a;
    auto x = i.first % a;
    auto y = i.second - b * k;
    if(x < 0) {
      --k;
      x += a;
      y += b;
    }
    vec[{x, y}].emplace(k, k + K - 1);
  }

  // merge
  map<Point, set<Event>> event;
  for(auto& i: vec) {
    auto cur = begin(i.second);
    auto l = cur->first, h = cur->second;
    for(auto pre = cur++; pre != end(i.second); pre = cur++) {
      if(cur == end(i.second)) {
        event[i.first].emplace(l, IN);
        event[i.first].emplace(h, OUT);
        break;
      }
      if(cur->first - 1 <= pre->second) h = cur->second;
      else {
        event[i.first].emplace(l, IN);
        event[i.first].emplace(h, OUT);
        l = cur->first;
        h = cur->second;
      }
    }
  }

  // intersect
  LL res = 0;
  for(auto i: event) {
    auto cur = i.first;
    multiset<Event> q;
    for(auto neighbor: {cur, {cur.first + 1, cur.second}, {cur.first + 1, cur.second + 1}, {cur.first, cur.second + 1}}) {
      auto dif = 0;
      if(neighbor.first >= a) {dif = 1; neighbor = {neighbor.first - a, neighbor.second - b};}
      if(!event.count(neighbor)) break;
      for(auto e: event[neighbor]) q.emplace(e.first - dif, e.second);
    }
    // count
    auto cnt = 0, begin = 0;
    for(auto e: q) {
      if(e.second == IN) {
        ++cnt;
        begin = e.first;
      } else {
        if(cnt == 4) res += e.first - begin + 1;
        --cnt;
      }
    }
  }
  return res;
}

LL solve() {
  // simulate
  auto x = 0, y = 0;
  vector<Point> p;
  p.emplace_back(x, y);
  for(auto i: S) {
    x += (i=='E') - (i=='W');
    y += (i=='N') - (i=='S');
    p.emplace_back(x, y);
  }

  if(x == 0 && y == 0) return loop(p);

  if(x == 0) {swap(x, y); for(auto& i: p) swap(i.first, i.second);}
  if(x < 0) {x *= -1; for(auto& i: p) i.first *= -1;}
  return solve(p, x, y);
}

int main() {
  cin >> N >> K >> S;
  cout << solve() << endl;
}

Measured memory_bytes: 36568
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());//int型
		int k = Integer.parseInt(sc.next());
		String sline = sc.next();
		int[] s = new int[n];
		for (int i=0; i<n; i++){
			s[i] = Integer.parseInt(String.valueOf(sline.charAt(i)));
		}
		sc.close();
		// 1-0-1-...でいくつセットで並んでいるか.00011100101=0332101(最初1は0個並んでいる.
		
		ArrayList<Integer> nums = new ArrayList<Integer>();
		
		int now = 1;// 今見ている数
		int cnt = 0;// nowがいくつ並んでいるか
		for (int i=0; i<n; i++){
			if (s[i] == now) {
				cnt++;
			} else {
				nums.add(cnt);
				now = 1 - now;// これで0,1の入れ替えができる.
				cnt = 1;
			}
		}
		if(cnt != 0){
			nums.add(cnt);
		}
		// 1-0-1-...-0-1という形でほしい
		// 0で終わっている時は一つ足す
		if (nums.size() % 2 == 0) {
			nums.add(0);
		}

		int Add = 2*k + 1;
		/*
		 * 累積和を作る
		 * 0 1 2 3 4 5 6 累積和のインデックス
		 *  0 1 2 3 4 5  もとのインデックス
		 * s[i+1]=(i番目までの累積した和)
		 */
		
		int[] sum = new int[n+1];
		sum[0] = 0;
		for (int i = 0; i< nums.size(); i++) {
			sum[i+1] = sum[i] + nums.get(i);
		}
		
		int ans = 0;
		
		// 1-0-1-0-1と続くので偶数番目だけ見る
		for (int i = 0; i < nums.size(); i += 2) {
			/*
			 * 次のleft, rightを計算 [left, right)
			 */
			int left = i;
			int right = Math.min(i+Add, nums.size());
			int tmp = sum[right] - sum[left];
			
			ans = Math.max(tmp, ans);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 31888