akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  zjsdut
 *    created: 2020/01/18 20:34:12
**/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
    fast_ios() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    };
} fast_ios_;

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
    for (auto &x : vec) stream >> x;
    return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
    cin >> a;
    scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template<typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
    if (!vec.empty()) {
        stream << vec[0];
        for (size_t i = 1; i != vec.size(); ++i)
            stream << ' ' << vec[i];
    }
    return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
    for (const auto &row : t) {
        print(row);
    }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
    print(t);
    print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
    print(t);
    println(rest...);
}

int main() {
#if defined LOCAL
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, k, s;
    scan(n, k, s);
    rng (i, 0, k) {
        print(s);
    }
    int t = s == 1000000000 ? 1 : s + 1;
    rng (i, k, n) {
        print(t);
    }
    cout << '\n';
    return 0;
}

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

int main( void )
{
  int b[2], o[3], max;
  for ( int i = 0; i < 2; i++ )
  {
    cin >> b[i];
  }
  
  o[0] = b[0] + b[0] - 1;
  o[1] = b[1] + b[1] - 1;
  o[2] = b[0] + b[1];
  
  max = o[0];
  
  if( o[0] < o[1] )
  {
  	max = o[1];
  }
  
  if( max < o[2] )
  {
    max = o[2];
  }
  
  cout << max;
}

Measured memory_bytes: 256
n= int(input())
a = list(map(int,input().split()))
ans = 1
mx = int(1e10)
for i in range(n-1,-1,-1):
    if a[i]>mx:
        a[i]-=1
    if a[i]>mx:
        ans = 0
        break
    mx = a[i]
print('Yes' if ans else 'No')



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

int main() {
  string s;
  int n, k;

  cin >> n >> k >> s;

  if (s[k-1] == 'A') {
    s[k-1] = 'a';
  } else if (s[k-1] == 'B') {
    s[k-1] = 'b';
  } else {
    s[k-1] = 'c';
  }

  cout << s << endl;

  return 0;

}

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

int main() {
    int h,w;
    while(1) {
        scanf("%d%d",&w,&h);
        if(w==0 && h==0) break;
        for(int i=0;i<h;i++) printf("#");
        cout << endl;
        for(int i=1; i<w-1; i++) {
            for(int j=0; j<h; j++) {
                if(!j || j==h-1)printf("#");
                else printf(".");
            }
            printf("\n");
        }
        for(int i=0;i<h;i++) printf("#");
        printf("\n");
        printf("\n");
    }

    return 0;

}



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

ll C[2010][2010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                C[i][j] = 1LL;
            }
            else {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
            }
        }
    }
    eFOR(i, 1, k)cout << C[n - k + 1][i] * C[k - 1][i - 1] % mod << endl;
}

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

using namespace std;

int main()
{
	int N;
	string s;

	cin >> N;

	cin >> s;

	int cnt = 0;
	for (int i = 0; i < N; i++)
		if (s[i] == 'R')
			cnt++;

	int ans = 0;
	for (int i = 0; i < cnt; i++)
		if (s[i] == 'W')
			ans++;

	cout << ans;
}

Measured memory_bytes: 3704
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        List<Integer> list = new ArrayList<Integer>();
        list.add(1);
        for (int i = 100; i >= 2; i--) {
            int tmp = i * i;
            while (tmp <= n) {
                list.add(tmp);
                tmp *= i;
            }
        }
        list.sort(Comparator.reverseOrder());
        System.out.println(list.get(0));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<long int>v;
vector<long int>v_ansl;
/*taro tenn,hanako_ten,sum*/

bool cmp(P h, P r){
  return h.second < r.second;
}
int main(){
    int R_0,W_0,C,R;
    cin >>R_0>>W_0>>C>>R;
    while(R_0 != 0 and W_0 != 0 and C != 0 and R != 0){
      if(C*W_0-R_0  <= 0){
        cout <<0<<endl;
      }
      else{
        int ans = 1;
        while (ans*R < C*W_0-R_0 ) {
          ans++;
        }
        cout <<ans<<endl;
      }


      cin >>R_0>>W_0>>C>>R;
    }
  return 0;
}



Measured memory_bytes: 3000
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String b = sc.next();
        System.out.println(pair(b));
    }
    public static String pair(String b){
        final String A = "A",
        C = "C",
        G = "G",
        T = "T";
        switch(b){
            case A:
            return T;
            case T:
            return A;
            case G:
            return C;
            case C:
            return G;
            default :
            return "";
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int INF=10000;
int N,A,B,C;

int dfs(int now,int a,int b,int c,std::vector<int> l){
    if(now==N){
        if(std::min(a,std::min(b,c))>0){
            return abs(A-a)+abs(B-b)+abs(C-c)-30;
        }
        else return INF;
    }
    else{
        int res0=dfs(now+1,a,b,c,l);
        int res1=dfs(now+1,a+l[now],b,c,l)+10;
        int res2=dfs(now+1,a,b+l[now],c,l)+10;
        int res3=dfs(now+1,a,b,c+l[now],l)+10;
        return std::min({res0,res1,res2,res3});
    }
}

int main(){
    cin>>N>>A>>B>>C;
    std::vector<int> l(N);
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    cout<<dfs(0,0,0,0,l)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2010;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int f[N],v[N],g[N];
int main()
{
	int n=gi(),a=gi(),b=gi(),i,j;
	for (i=1;i<=n;i++) v[i]=gi();
	for (i=n-1;i;i--) {
		f[i]=g[i]=abs(v[i]-v[n]);
		for (j=i+1;j<n;j++)
			f[i]=min(f[i],g[j]),g[i]=max(g[i],f[j]);
	}
	int ans=abs(v[n]-b);
	for (i=1;i<n;i++)
		ans=max(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int N,A,x,y;
  cin >> N;
  for (int i = 0; i < N; i++) {
    y=0;
    cin >> A;
    for (int ii = 0; ; ii++) {
      if (A % 2!= 0){
      break;
      }
      A /= 2;
      y++;
    }
    if ( y == 0) {
      x = 0;
      break;
    }
    else if (i == 0) {
      x = y;
    }
    else if (y < x) {
      x = y;
    }
  }
  cout << x << endl;
} 

Measured memory_bytes: 3592
#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;

const int MAX = 200200;
int A[MAX];

int no()
{
	cout << "Impossible" << endl;
	return 0;
}

int yes()
{
	cout << "Possible" << endl;
	return 0;
}


int main()
{

	//freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(0);cin.tie(0);
	
	int n;
	cin >> n;
	int mx = 0;
	FOR(i, 0, n)
	{
		int x;
		cin >> x;
		A[x]++;
		mx = max(mx, x);
	}

	int lo = (mx+1) / 2;
	int hi = mx;

	//cout << lo << ' ' << hi << endl;

	FOR(i, lo+1, hi + 1)
	{
		if (A[i] < 2) return no();
	}

	if (mx % 2 == 1) if (A[lo] != 2) return no();
	if (mx % 2 == 0) if (A[lo] != 1) return no();

	FOR(i, 0, lo)
	{
		if (A[i] != 0) return no();
	}

	return yes();

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

template <class Abel> struct BIT1D_MaxChmax {
    const Abel e;
    size_t n;
    vector<Abel> d;

    BIT1D_MaxChmax(size_t n, Abel e = numeric_limits<Abel>::min()) : n(n), e(e), d(n + 1, e) {}

    // max{d[1], ..., d[i]} (i : 1-indexed)
    Abel max(size_t i) {
        Abel res = e;
        while (i > 0) {
            res = std::max(res, d[i]);
            i -= i & -i;
        }
        return res;
    }

    // d[i] = max(d[i], x) (i : 1-indexed)
    void chmax(size_t i, Abel x) {
        while (i <= n) {
            d[i] = std::max(d[i], x);
            i += i & -i;
        }
    }
};

int n;
int x[100010];
int dp[100010];

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

    cin >> n;
    REP (i, n) cin >> x[i];
    BIT1D_MaxChmax<int> bit(n, 0);
    REP (i, n) {
        dp[i] = bit.max(x[i] - 1) + x[i];
        bit.chmax(x[i], dp[i]);
    }
    cout << n * (n + 1) / 2 - bit.max(n) << endl;
}


Measured memory_bytes: 5212
#include<iostream>
#include<cmath>
#include<cstdio>

struct P{
	double x, y;
};

struct Circle{
	P cp;
	double r;
};

double dist(Circle a, Circle b){
	double dx = a.cp.x - b.cp.x,
		dy = a.cp.y - b.cp.y;
	return sqrt(dx*dx+dy*dy);
}

double abs(double a){
	return (a>0)?(a):(-a);
}

int main(){
	int n;
	std::cin >> n;
	for(int i=0;i<n;i++){
		Circle a, b;
		std::cin >> a.cp.x >> a.cp.y >> a.r >> b.cp.x >> b.cp.y >> b.r;
		double d = dist(a, b),
			sum = a.r+b.r,
			diff = abs(a.r-b.r);
		if(d > a.r+b.r){//重ならない
			puts("0");
		}else if(diff <= d && d <= sum){//交わる
			puts("1");
		}else if(d < diff){//内包
			if(a.r > b.r){
				puts("2");
			}else{
				puts("-2");
			}
		}
	}
}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, k+a-1); i++) {
		cout << i << endl;
	}
	for (int i = max(b-k+1, a+k); i <= b; i++) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

tiles = input()
pattern0 = ''
pattern1 = ''
l = len(tiles)
sum0 = 0
sum1 = 0

for i in range(l):
  if i % 2 == 0:
    pattern0 += '0'
    pattern1 += '1'
  else:
    pattern0 += '1'
    pattern1 += '0'

for i in range(l):
  if tiles[i] != pattern0[i]:
    sum0 += 1
  if tiles[i] != pattern1[i]:
    sum1 += 1

if sum0 < sum1:
  print(sum0)
else:
  print(sum1)

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,m,q=MI()
strs=[[[] for i in range(m)] for i in range(n)]
for i in range(m):
    strs[0][i].append(str(i))
#print(strs)
for i in range(n-1):
    for j in range(m):
        for k in range(j,m):
            for s in strs[i][k]:
                strs[i+1][j].append(str(j)+s)
#print(strs)

L=strs[n-1]
#print(L)
lis=[]
for i in range(m):
    for s in L[i]:
        lis.append(s)
#print(lis)
mx=0
zyou=[LI() for i in range(q)]
for u in lis:
    po=0
    for k in range(q):
        a,b,c,d=zyou[k]
        if int(u[b-1])-int(u[a-1])==c:
            po+=d
    if po>mx:
        mx=po
print(mx)


Measured memory_bytes: 83948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum=0;
	map<ll,ll> mp;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
		mp[a[i]]++;
	}
	ll q;
	cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		if(mp.find(b)!=mp.end()){
			ll cnt=mp[b];
			sum-=b*cnt;
			sum+=c*cnt;
			mp[b]=0;
			mp[c]+=cnt;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 9272
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (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)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int n = in(), k = in();
  int sum = 0;
  rep(i, n) {
    int a = in();
    sum += 2 * min(a, abs(k - a));
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int n, r;
  cin >> n >> r;
  
  if(n <= 10) r += 100 * (10 - n);
  
  cout << r << endl;
  
  return 0;
}


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

void swap(int *x, int *y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int euclid(int small, int big){
    int res = 0;
    if(small > big) swap(&small,&big);

    while(true){
        res = big%small;
        if(res == 0) return small; 
        big = small;
        small = res;
    }
    return 0;
}

int main(){
    int x;
    cin >> x;
    long long sm=0;
    for(int i=1; i<=x; i++){
        for(int j=1; j<=x; j++){
            for(int k=1; k<=x; k++){
                sm = sm + euclid(euclid(i,j),k);
            }
        }
    }
    cout << sm << endl;
    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=105;
int f[N][5][2],n,k;
char s[N];

int dp(int x,int k,bool op){
	if(x==n+1) return k==0;
	int &now=f[x][k][op];
	if(now!=-1) return now;
	now=0;
	if(s[x]=='0') now+=dp(x+1,k,op);
	else now+=dp(x+1,k,1);
	if(!k||(s[x]=='0'&&!op)) return now;
	if(op) now+=9*dp(x+1,k-1,1);
	else now+=(s[x]-'0'-1)*dp(x+1,k-1,1)+dp(x+1,k-1,0);
	return now;
}

signed main(){
	scanf("%s",s+1);read(k);n=strlen(s+1);
	memset(f,-1,sizeof f);
	write(dp(1,k,0));
}


Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g




n,m = map(int,input().split())
a = {}
base = 1000000007
for i in range(m):
    temp = int(input())
    a[temp] = 0
steps = [0 for i in range(n+2)]
steps[0] = 0
steps[1] = 1

for i in range(2,n+2):
    if i-1 not in a:
        steps[i] = steps[i-1] + steps[i-2]
        steps[i] %= base
    else:
        steps[i] = 0

print(steps[-1])








Measured memory_bytes: 15068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    map<int,int> m;
    for(int j=1;j<=n;j++){
        ans += m[j-a[j]];
        m[a[j]+j]++;
    }

    cout << ans << endl;
}

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


int main() {
  int n;
  cin >> n;
  vector<int> v(0);
  string s;
  cin >> s;
  rep(i,n-1){
    if(s[i+1] == s[i]){
      v.push_back(1);
      if(i != n-2){
        i++;
      }
    }
    else{
      v.push_back(2);
    }
  }
  if(s[n-2] != s[n-1]){
    v.push_back(2);
  }
  ll ans = 0;
  ll m = v.size();
  
  if(m == 1){
    if(v[0] == 2){
      cout << 3;
    }
    else{
      cout << 6;
    }
  }
  else{
    if(v[0] == 2){
        ans = 3;
      }
      else{
        ans = 6;
      }
    
    rep(i,m-1){
    
    
      if(v[i] == 2 && v[i+1] == 2){
        ans = (ans * 2) % 1000000007;
      }
      else if(v[i] == 2 && v[i+1] == 1){
        ans = (ans * 2) % 1000000007;
      }
      else if(v[i] == 1 && v[i+1] == 1){
        ans = (ans * 3) % 1000000007;
      }
     
      }
    cout << ans << endl;
  }
  
 
   
  return 0;
}




Measured memory_bytes: 3608
def main():

    a, b, c, x, y = map(int,input().split())
    ans = 0
    if a + b > c * 2:
        ans += c * 2 * min(x, y)
        if x < y:
            ab = b * (y-x)
        else:
            ab = a * (x-y)
        cc = c * 2 * max(x, y)
        ans = min(ans + ab, cc)
    else:
        ans = a * x + b * y
    print(ans)
if __name__ =='__main__':
    main()


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

bool t_h;
long long int year,var,tesuryo;
double riritu,hukuiri;

long long int T(long long int shikin){
  int rishi=0;
  for(int i=0;i<year;i++){
    rishi+=riritu*shikin;
    shikin-=tesuryo;
  }
  return rishi+shikin;
}

long long int H(long long int shikin){
  //cout<<"H"<<endl;
  for(int i=0;i<year;i++){
    shikin=shikin*riritu+shikin-tesuryo;
    //cout<<"shikin "<<shikin<<endl;
  }
  //cout<<"end"<<endl;
  return shikin;
}

int main(){
  int n;
  long long int shikin;
  vector<long long int> ans;
  cin>>n;
  for(int i=0;i<n;i++){
    //cout<<"i is "<<i<<endl;
    ans.clear();
    cin>>shikin>>year>>var;
    for(int j=0;j<var;j++){
      //cout<<"j is "<<j<<endl;
      cin>>t_h>>riritu>>tesuryo;
      //cout<<t_h<<endl;
      if(t_h==1)
	ans.push_back(H(shikin));
      else
	ans.push_back(T(shikin));
      //cout<<"LKJL"<<endl;
    }
    sort(ans.begin(),ans.end());
    //cout<<"sort"<<endl;
    cout<<ans.back()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
from collections import deque
import sys
import time
input = sys.stdin.readline


def main():
    t1 = time.time()
    N, M = map(int, input().split())
    adj = [[] for _ in range(N + 1)]
    for _ in range(M):
        L, R, D = map(int, input().split())
        adj[L].append((R, D))
        adj[R].append((L, -D))
    seen = [0] * (N + 1)

    def dfs(adj, seen, start):
        inf = 10 ** 10
        que = deque()
        que.append(start)
        x = [inf] * (N + 1)
        x[start] = 0
        while que:
            v = que.pop()
            seen[v] = 1
            for u, d in adj[v]:
                if seen[u] == 0:
                    que.append(u)
                    if x[u] == inf:
                        x[u] = x[v] + d
                    else:
                        if x[u] != x[v] + d:
                            print('No')
                            sys.exit()
            t2 = time.time()
            if t2 - t1 > 1.8:
                print('Yes')
                sys.exit()
        return seen

    for i in range(1, N + 1):
        if seen[i] == 0:
            seen = dfs(adj, seen, i)

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 137876
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var arrays = Console.ReadLine().Split(' ').Select(num => long.Parse(num)).OrderBy(num => num).ToArray();
            var limit = (long) Math.Pow(10.0, 18.0);
            var big = new BigInteger(1);
            for (var i = 0; i < arrays.Length; i++)
            {
                big = BigInteger.Multiply(big, arrays[i]);
                if (big.CompareTo(limit) == 1)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(big.ToString());
        }
    }
}

Measured memory_bytes: 50912
import java.util.*;
class Main {
  public static void main(String[] args) {
    HashSet<Integer> set = new HashSet<>();
    Scanner sc = new Scanner (System.in);
    int a = sc.nextInt(); 
    int b = sc.nextInt(); 
    int c = sc.nextInt();
    set.add(a); 
    set.add(b); 
    set.add(c);  
    if (set.size() == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
int main() {
	int a;
	string s;
	cin >> a ;
	if (a / 100 > 12||a/100==0) {
		if (a % 100 > 12||a%100==0)s = "NA";
		else s = "YYMM";
	}
	else {
		if (a % 100 > 12||a%100==0)s = "MMYY";
		else s = "AMBIGUOUS";
	}
	cout << s << endl;
	

		please AC;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    if (n - i != i) {
      ++ans;
    }
  }
  printf("%d\n", ans / 2);
}


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

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n,p; cin >> n >> p;
    ll all = pow(2,n);
    COMinit();
    vector<int> a(n);
    map<int,int> mp;
    rep(i,n){
        int a; cin >> a;
        mp[a%2]++;
    }
    if(mp[1]==0) cout << (p==0?(1LL<<n):0) << endl;
    else cout << (1LL<<(n-1)) <<endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int n, a;
  cin >> n >> a;
  if ((n - ((n / 500) * 500)) <= a){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
 #include <stdlib.h>
    
 int n, m;
    
 void merge(int *u, int *net, int oldnet, int newnet);
    
 int main(int argc, char *argv[])
 {
   int i, s, t, p, q;
   int *u;
   int *net;
    
   scanf("%d", &n);
   scanf("%d", &m);
   u = (int *)malloc(sizeof(int) * n);
   net = (int *)malloc(sizeof(int) * (m + 1));
   for (i = 0; i < n; i++) u[i] = -1;
   for (i = 0; i <= m; i++) net[i] = 0;
    
   p = 1;
    
   for (i = 0; i < m; i++) {
     scanf("%d", &s);
     scanf("%d", &t);
     if (s != t) {
       if (u[s] == -1 && u[t] == -1) {
     u[s] = p;
     u[t] = p;
     net[p] += 2;
     p++;
       } else {
     if (u[s] != -1 && u[t] == -1) {
       u[t] = u[s];
       net[u[s]]++;
     } else if (u[s] == -1 && u[t] != -1) {
       u[s] = u[t];
       net[u[t]]++;
     } else {
       if (u[s] != u[t]) {
         if (net[u[s]] > net[u[t]]) merge(u, net, u[t], u[s]);
         else merge(u, net, u[s], u[t]);
       }
     }
       }
     }
   }
    
  scanf("%d", &q);
   
  for (i = 0; i < q; i++) {
    scanf("%d", &s);
    scanf("%d", &t);
   
    if (s == t) printf("yes\n");
    else {
      if (u[s] == u[t] && u[s] != -1 && u[t] != -1) printf("yes\n");
      else printf("no\n");
    }
  }
   
  return 0;
}
   
void merge(int *u, int *net, int oldnet, int newnet)
{
  int i;
     
  for (i = 0; i < n; i++) {
    if (u[i] == oldnet) u[i] = newnet;
  }
   
  net[newnet] += net[oldnet];
  net[oldnet] = 0;
}

Measured memory_bytes: 1368
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Map
import scala.collection.mutable.Queue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toInt

  //
  var ans = 0
  for (i <- 1 to N)
    if(i % 2 == 1)
      ans += A(i)
    else
      ans -= A(i)
  ans /= 2


  val memo = new Array[Int](N+1)
  val com = new Array[Int](N+1)
  memo(1) = ans
  memo(N) = ans
  com(1) = ans
  for (i <- 2 to N) {
    val tmp = A(i-1) - memo(i-1)
    com(i) = tmp
    memo(i-1) += tmp
    memo(i) += tmp
  }

  val res = A(N) - memo(N)
  Math.abs(res)

  pw.print(com(1)*2)
  for(i <- 2 to N)
    pw.print(s" ${com(i)*2}")
  pw.println
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 58040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n % 1000 == 0) {
			System.out.print(0);
		}else {
			System.out.print(1000 - n%1000);
		}
	}

}


Measured memory_bytes: 35696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long int ll;

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

  int N, W;
  cin >> N >> W;
  vector<ll> w, v;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    w.push_back(x);
    v.push_back(y);
  }

  vector<vector<ll> > dp(N+2, vector<ll>(W+2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (w[i] > j) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], v[i] + dp[i][j - w[i]]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 81024
import sys

N = int(input())
S=[]

m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(N):
    tmp = input()
    if tmp[0:1] == "M": # 先頭一文字
      m += 1
      S.append(tmp[0:1]) 
    elif tmp[0:1] == "A":
      a += 1
      S.append(tmp[0:1]) 
    elif tmp[0:1] == "R":
      r += 1
      S.append(tmp[0:1]) 
    elif tmp[0:1] == "C":
      c += 1
      S.append(tmp[0:1]) 
    elif tmp[0:1] == "H":
      h += 1
      S.append(tmp[0:1]) 

# 重複を削除
editedArray = list(set(S))

if len(editedArray) < 3:
  print(0)
  sys.exit()

ans = (m * a * r) + (m * a * c) + (m * a * h) + (m * r * c) + (m * r * h) + (m * c * h) + (a * r * c) + (a * r * h) + (a * c * h) +(r * c * h)

print(ans)




Measured memory_bytes: 4016
#include "iostream"
#include "string"
#include "iomanip"
using namespace std;

int main()
{
	string str;
	int ans = 0;
	while (1)
	{
		cin >> str;
		if (str[0] == '0')
		{
			break;
		}
		for (int i = 0; i < str.size(); i++)
		{
			ans += str[i] - '0';
		}
		cout << ans << endl;
		ans = 0;
	}
}


Measured memory_bytes: 3204
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> l = new ArrayList<>();
		int sum = 0;
		int num;
		for(int i = 0; i < n; i++) {
			num = sc.nextInt();
			l.add(num);
			sum += num;
		}
		if(sum > Collections.max(l) * 2) {
			System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
S = input()
T = input()

ans = len(T)
for i in range(len(S)-len(T)+1):
  t = len(T)
  for j in range(len(T)):
    if S[i+j] == T[j]:
      t -= 1
  # print(t)
  ans = min(ans, t)
print(ans)


Measured memory_bytes: 9108
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n % 2 == 0:
  # 同じ長さ
  l = n // 2 - 1
  r = n - 1
  total = 0
  for i in range(n - 1):
    total += A[r] - A[l]
    if i % 2 == 0:
      l = (l + 1) % (n // 2)
    else:
      r -= 1
  print(total)
elif A[n // 2] - A[n // 2 - 1] < A[n // 2 + 1] - A[n // 2]:
  # 小さいほうが両端
  l = n // 2
  r = n - 1
  total = 0
  for i in range(n - 1):
    total += A[r] - A[l]
    if i % 2 == 0:
      l = (l + 1) % (n // 2 + 1)
    else:
      r -= 1
  print(total)
else:
  # 大きいほうが両端
  l = 0
  r = n // 2
  total = 0
  for i in range(n - 1):
    total += A[r] - A[l]
    if i % 2 == 0:
      r -= 1
      if r < n // 2:
        r = n - 1
    else:
      l += 1
  print(total)


Measured memory_bytes: 7512
N, W = map(int, input().split())

dp = [0] * (W+1)

value = []
weight = []

for i in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)

for i in range(N):
    for j in range(W+1):
        if j + weight[i] <= W:
            dp[j+weight[i]] = max(dp[j+weight[i]], dp[j] + value[i])

print(dp[W])


Measured memory_bytes: 5912
#include<iostream>
#include<fstream>


using namespace std;


class Point{
public:
	int x;
	int y;

	Point(){
		this->x = 0;
		this->y = 0;
	};
	Point(int x, int y){
		this->x = x;
		this->y = y;
	}
	Point operator + (Point tmp){
		return Point(this->x + tmp.x, this->y + tmp.y);
	}
};

Point set(int x, int y){
	return Point(x, y);
}


int main(){
	//ifstream fin("in.txt");
	int N = 0;

	const Point move[4] = { Point(-1, 0), Point(0, -1), Point(1, 0), Point(0, 1) };

	while (true){
		cin >> N;
		if (N == 0)break;

		Point a[200];
		a[0] = set(0, 0);

		int n, d;

		for (int i = 1; i < N; i++){
			cin >> n >> d;
			a[i] = a[n] + move[d];
		}

		int max = 0;
		int min = 0;
		for (int i = 0; i < N; i++){
			if (max < a[i].x)max = a[i].x;
			if (a[i].x < min)min = a[i].x;
		}

		cout << max - min + 1 << " ";
		max = 0;
		min = 0;
		for (int i = 0; i < N; i++){
			if (max < a[i].y)max = a[i].y;
			if (a[i].y < min)min = a[i].y;
		}
		cout << max - min + 1 << endl;

	}


	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int pi[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
	int k; scanf("%d",&k);
	printf("%d",pi[k-1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X[i];
  }
  vector<int> T(N);
  T = X;
  sort(T.begin(),T.end());
  for(int i=0; i<N; i++){
    if(X[i] < T[N/2]){
      cout << T[N/2] << endl;
    }else{
      cout << T[N/2-1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
n, m = map(int, input().split())
scs = [tuple(map(int, input().split())) for _ in range(m)]

mi = 0
if 2 <= n:
    mi += 10 ** (n - 1)
ma = 10 ** n
ans = -1

for i in range(mi, ma):
    st = str(i)
    tmp = True
    for j in range(m):
        if (int(st[scs[j][0] - 1]) != scs[j][1]):
            tmp = False
    if tmp:
        ans = i
        break
print(ans)


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, K;
int H[200010];


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];

    sort(H, H+N, greater<int>());

    int ans = 0;
    rep(i, K, N) ans += H[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import math
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
a, b, x = map(int, input().split())

if a*a*b == x:
	print(0)

elif a*a*b/2 < x:
    l = 2*b - 2*x/(a*a)
    print(90 - math.degrees(math.atan(a/l)))

elif a*a*b/2 == x:
    print(90 - math.degrees(math.atan(a/b)))

else:
    l = 2*x / (a*b)
    print(90 - math.degrees(math.atan(l/b)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

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



Measured memory_bytes: 5568
#include <iostream>
#include <set>
#include <vector>

using namespace std;

set<int> S[15];

int N;

int used[150];

vector<int> V, W;

int main(void) {

	cin >> N;

	int sum = 0;

	for (int i = 1; i <= N; i++) {
		sum += i;
	}

	int p = 2;

	for (p = 2;; p++) {
		if ((sum % p) == 0) { break; }
	}

	int tmp_sum;
	for (int k = 0; k <= N; k++) {
		tmp_sum = 0;
		for (int i = N; i >= 1; i--) {
			if ((used[i] == 0) && (i + tmp_sum <= sum / p)) {
				used[i] = 1; S[k].insert(i); tmp_sum += i;
			}
		}
	}


	int K;
	for (int i = 0; i < 15; i++) { if (S[i].size() > 0) { K = i; } }

	/*for (int k = 0; k <= K; k++) {
		cout << "k= " << k << endl;
		for (auto it = S[k].begin(); it != S[k].end(); it++) {
			cout << " " << (*it);
		}
		cout << endl;
	}*/


	for (int i = 0; i < K; i++) {
		for (int j = i + 1; j <= K; j++) {
			for (auto it = S[i].begin(); it != S[i].end(); it++) {
				for (auto itt = S[j].begin(); itt != S[j].end(); itt++) {
					V.push_back(*it); W.push_back(*itt);
				}
			}
		}
	}

	cout << V.size() << endl;
	for (int i = 0; i < (int)V.size(); i++) {
		cout << V[i] << " " << W[i] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    rep(i,N-1) A[i+1]+=A[i];
    A.push_back(0);
    sort(all(A));
    
    
    ll ans = 0;
    ll a = 1;
    rep(i,N+1){
        if(i != 0){
            if(A[i] == A[i-1]) a++;
            else ans += (a*(a-1)/2),a=1;
        }
        if(i == N) ans += (a*(a-1)/2);
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/* --- */

void TestCase() {
    int n;
    scanf("%d", &n);
    ll minval = LINF;
    ll maxval = -LINF;
    for(int i = 1; i <= n; ++i) {
        ll x;
        scanf("%lld", &x);
        minval = min(minval, x);
        maxval = max(maxval, x);
    }
    printf("%lld\n", maxval - minval);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d: ", i);
        TestCase();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,W;
    cin>>n>>W;
    ll sum=0,w[n+1],v[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    
    ll dp[n+1][sum+1];
    for(ll i=0;i<=sum;i++)
        dp[0][i]=LONG_MAX;
    for(ll i=0;i<=n;i++)
        dp[i][0]=0;
    
    ll ans=LONG_MIN;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=sum;j++)
        {
            if(j<v[i]||(dp[i-1][j-v[i]]==LONG_MAX))
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
                
            if(dp[i][j]<=W)
                ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 79104
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int p[] = new int[a];
    int q[] = new int[b];
    int r[] = new int[c];
    int candidate[] = new int[x + y + c];
    for (int i = 0; i < a; i++) {
      p[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(p);
    for (int i = 0; i < x; i++) {
      candidate[i] = p[p.length - 1 - i];
    }

    for (int i = 0; i < b; i++) {
      q[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(q);
    for (int i = 0; i < y; i++) {
      candidate[x + i] = q[q.length - 1 - i];
    }

    for (int i = 0; i < c; i++) {
      r[i] = Integer.parseInt(sc.next());
      candidate[x + y + i] = r[i];
    }
    long ans = 0;
    Arrays.sort(candidate);
    for (int i = 0; i < x + y; i++) {
      ans += candidate[candidate.length - 1 - i];
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 65820
s=input()
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    quit()
for i in range(len(s)-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    quit()  
print(-1,-1)

Measured memory_bytes: 39536
#include <iostream>

using namespace std;

int main() {
    long long int X, Y;
    cin >> X >> Y;
    
    long long int counter=0;
    long long int x=X;
    while(x<=Y) {
        counter++;
        x *= 2;
    }
    
    cout << counter << endl;

    return 0;
    
}

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

int main(){
  ll n;
  cin>>n;
  vector<ll> h(n);
  ll i;
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  if(n==1){
    cout<<0<<"\n";
    return 0;
  }
  vector<ll> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 4700
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr
N=int(input())
arr=factor(N)
ans=0
for x in arr:
    m=N//x-1
    if m<=x:
        continue
    ans+=m
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
struct Point{
    double x,y;

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

    Point operator +(Point p){return Point(x+p.x,y+p.y);}
    Point operator -(Point p){return Point(x-p.x,y-p.y);}
    Point operator *(double a){return Point(a*x,a*y);}
    Point operator /(double a){return Point(x/a,y/a);}

    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}

    bool operator<(const Point &p)const{
        return equals(x,p.x)?(y<p.y):(x<p.x);
    } 

    bool operator==(const Point &p)const{
        return equals(x,p.x)&&equals(y,p.y);
    }
};

typedef Point Vector;

struct Segment{
    Point p1,p2;
};

typedef Segment Line;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int q;
    cin>>q;
    Point p0,p1,p2,p3;
    for(int i=0;i<q;i++){
        cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
        if(isOrthogonal(p0,p1,p2,p3)){
            cout<<1<<'\n';
        }
        else if(isParallel(p0,p1,p2,p3)){
            cout<<2<<'\n';
        }
        else{
            cout<<0<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3304