akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(a),d(a),e(a);
  rep(i,a)
    cin>>b[i];
  rep(i,a)
    cin>>c[i];
  rep(i,a)
    d[i]=b[i];
  rep(i,a)
    e[i]=c[i];
  int g=1,h=1;
  sort(all(b));
  sort(all(c));
  do{
    rep(i,a){
    if(b[i]!=d[i])
      break;
    if(i==a-1)
      goto A;
    }
      
        g++;
  }while(next_permutation(all(b)));
  A:
   do{
    rep(i,a){
    if(c[i]!=e[i])
      break;
      
    else if(i==a-1)
      goto B;
      else
        continue;
    }
      
        h++;
  }while(next_permutation(all(c)));
B:
  cout<<abs(g-h)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<string>
#include<cstdint>

int main() {
  int N, M; std::cin >> N >> M;
  std::set<int> ac;
  std::map<int,int> wa;
  int64_t nWA = 0;
  for(int i = 0; i < M; ++i) {
    int p; std::string S; std::cin >> p >> S;
    if(S == "AC" ) {
      if(ac.count(p) < 1) { ac.insert(p); nWA += wa[p]; }
    } else ++wa[p];
  }
  std::cout << ac.size() << " " << nWA << std::endl;
  return 0;
}


Measured memory_bytes: 9600
#include<iostream>

using namespace std;

int main() {
	bool flag=true;
	int i, j,tmp;
	int a[3];
	int sum = 0;

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

	while (flag) {
		flag = false;
		for (i = 0; i < 2; i++) {
			for (j = 0; j < 2; j++) {
				if (a[j] < a[j + 1]) {
					tmp = a[j];
					a[j] = a[j + 1];
					a[j + 1] = tmp;
					flag = true;
				}
			}
		}
	}
	sum += a[0] - a[1];
	sum += a[1] - a[2];

	cout << sum;

	return 0;
}

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

int main() {
  char c;
  cin >> c;

    if (c == 'a' ||  c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
  cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var list = input.Split(" ");
            int n = Int32.Parse(list[0]), k = Int32.Parse(list[1]);

            var nc2 = (n - 1) * (n - 2) / 2;

            if (k > nc2)
            {
                Console.WriteLine(-1);
                return;
            }

            var ret = new List < (int x, int y) > ();

            int index = 0;
            for (var i = 1; i < n; i++)
            {
                for (var j = i + 1; j <= n; j++)
                {
                    if (i > 1)index++;
                    if (index > nc2 - k)break;
                    ret.Add((i, j));
                }
                if (index > nc2 - k)break;
            }

            Console.WriteLine(ret.Count);
            foreach (var r in ret)
            {
                Console.WriteLine(String.Format("{0} {1}", r.x, r.y));
            }
        }
    }
}

Measured memory_bytes: 28044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }

int n;
ll a, b;
ll s[100010];

const ll mod = ll(1e9) + 7;
const ll inf = ll(1e18) + 10;

ll ca[100010];
ll cb[100010];
ll pca[100010];
ll pcb[100010];

int iha(ll x){
    return upper_bound(s, s+n+1, x) - s - 1;
}

int main()
{
    read(n, a, b);
    for(int i=1; i<=n; ++i) read(s[i]);
    s[0]=-inf;
    
    int za=-1, zb=-1;
    
    auto f=[&](ll* arr,int zero,int x){
        if(x < zero) return 0LL;
        ll ret=arr[x] + mod;
        if(zero >= 0) ret -= arr[zero];
        return ret%mod;
    };
    
    ca[0]=pca[0]=1;
    cb[0]=pcb[0]=1;
    
    for(int i=2; i<=n; ++i){
        int ia=min(iha(s[i]-a), i-2);
        int ib=min(iha(s[i]-b), i-2);
        cb[i-1]=f(pca, za, ia);
        ca[i-1]=f(pcb, zb, ib);
        pca[i-1]=(pca[i-2]+ca[i-1])%mod;
        pcb[i-1]=(pcb[i-2]+cb[i-1])%mod;
        if(s[i]-s[i-1]<a) zb=i-2;
        if(s[i]-s[i-1]<b) za=i-2;
    }
    
    printf("%lld\n", (f(pca, za, n-1)+f(pcb, zb, n-1))%mod);
    return 0;
}


Measured memory_bytes: 4096
N = int(input())
nums = list(map(int, input().split()))
n_sums = [0 for _ in range(N)]
n_sums[0] = nums[N-1]
MOD = 10**9 + 7
for i in range(N-1):
  n_sums[i+1] = n_sums[i] + nums[N-i-2]
  answer = 0
for i in range(N-1):
  answer += n_sums[N-i-2] * nums[i]
  answer = answer%MOD
print(answer)

Measured memory_bytes: 101912
/*input
100 100
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+5;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a*b);
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll ans = InfLL;
	string S, T;
	cin >> S >> T;
	int N = S.length();
	int M = T.length();
	rep(i, N - M + 1) {
		ll anstmp = 0;
		rep(j, M) {
			if (S[i + j] != T[j])
				anstmp++;
		}
		ans = min(ans, anstmp);
	}

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

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int N, K;
	cin >> N >> K;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end(),greater<>());
	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	int n,s,ans;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			s = sc.nextInt();
			if((n|s) == 0) break;
			ans = 0;
			dfs(0,0,-1);
			System.out.println(ans);
		}
	}
	
	private void dfs(int deep, int sum, int preb){
		if(deep == n){
			if(sum == s) ans++;
			return;
		}
		if(sum > s) return;
		for(int i=preb+ 1; i < 10; i++){
			int nextsum = sum + i;
			dfs(deep + 1, nextsum, i);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 11000
s, t = input(), input()

sl = list(s)
tl = list(t)
sl.sort()
tl.sort()

if sl != tl:
    print('No')
    quit()

for _ in range(len(s)):
    if s == t:
        print('Yes')
        quit()
    s = s[-1] + s[:-1]
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int len=a.length();
	for(int i=0;i<len-1;i++)
	{
		for(int j=i+1;j<len;j++)
		{
			if(a[i]=='C'&&a[j]=='F')
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

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

#define fastIO                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
	fastIO;
	int K;
	cin >> K;
	string ans;
	while (K--)
		ans += "ACL";
	cout << ans;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var x = new int[4];
        var y = new int[2];
        for (int i = 0; i < 4; i++)
        {
            x[i] = int.Parse(Console.ReadLine());
        }
        for (int i = 0; i < 2; i++)
        {
            y[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine(x.Sum() - x.Min() + y.Sum() - y.Min());
    }
}


Measured memory_bytes: 18196
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    rep(i,n){cin>>a[i];a[i]--;}
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    int ret=0;
    rep(i,n)
    {
        ret+=b[a[i]];
        if(i!=n-1&&a[i]+1==a[i+1])ret+=c[a[i]];
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int n, x=0;
	string s;
	cin >> n >> s;

	int ans=0;

	for(int i=0;i<n;i++) {
		if(s.at(i) == 'I') x++;
		if(s.at(i) == 'D') x--;

		ans = max(ans, x);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-x for x in a]
heapq.heapify(a)
for i in range(m):
	p = heapq.heappop(a)
	p = - (-p // 2)
	heapq.heappush(a, p)
print(-sum(a))

Measured memory_bytes: 73196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    ll N, ans = LLINF;
    cin >> N;
    for(int i = 1; i <= sqrt(N); ++i) {
        if(N % i == 0) {
            ans = min(ans, N / i + i - 2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 15;
const int MAXP = (1 << MAXN);
 
int N, M;
int edge[MAXN][MAXN];
int cscore[MAXP];
int dp[MAXN][MAXP]; // last, cset
vector<int>Mask[MAXP];
int main()
{
    ios_base::sync_with_stdio(0);
 
    cin >> N >> M;
   	for(int i=0;i<(1<<N);i++){
   		for(int j=0;j<N;j++){
   			if(i&(1<<j))Mask[i].push_back(j);
		}
	}
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edge[a][b] = edge[b][a] = c;
    }
 
 vector<int> v;
    for (int i = 1; i < (1 << N); i++)
    {
		v.clear();
		for(int j=0;j<N;j++) if(i&(1<<j)){
			v.push_back(j);
		}
		cscore[i]=cscore[i^(1<<v[0])];
		for(int j=1;j<v.size();j++){
			cscore[i]+=edge[v[0]][v[j]];
		}
    }
 
    for (int i = 0; i < MAXN; i++)
        for (int j = 0; j < MAXP; j++)
            dp[i][j] = -1e9;
    for (int i = 1; i < (1 << N); i += 2)
        dp[0][i] = cscore[i];
 
    for (int i = 0; i < (1 << N); i++)
    {
        for (int j = 0; j < N; j++) if(i&(1<<j))
        {
            if (dp[j][i] < 0) continue;
            int mask = (1 << N) - 1 - i;
            for (int sub = mask; sub > 0; sub = (sub - 1) & mask)
            {
                for (auto k:Mask[sub])
                {
                    if (edge[j][k])
                        dp[k][i+sub] = max (dp[k][i+sub], dp[j][i] + cscore[sub] + edge[j][k]);
                }
            }
        }
    }
    cout << cscore[(1<<N)-1] - dp[N-1][(1<<N)-1] << "\n";
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int n, u, v, q, k ;
lli w ;
vector<vector<pair<int, lli>>> adj ;
vlli dist ;

void dfs(int u, int prev, lli d)
  {
    dist[u]=d ;
    for(int i=0 ; i<adj[u].size() ; i++)
      {
        pair<int, lli> temp=adj[u][i] ;
        int v=temp.fi ;
        lli x=temp.se ;
        if(v!=prev)
          dfs(v, u, d+x) ;
      }

  }

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n ;
    adj.resize(n+1) ;
    dist.assign(n+1, 0) ;
    for(int i=0 ; i<n-1 ; i++)
      {
        cin>> u >> v >> w ;
        adj[u].pb(mp(v, w)) ;
        adj[v].pb(mp(u, w)) ;
      }
    cin>> q >> k ;
    dfs(k, -1, 0) ;
    for(int i=0 ; i<q ; i++)
      {
        cin>> u >> v ;
        cout<< dist[u]+dist[v] << endl ;
      }
  }


Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    int ans = 1;
    bool smaller = false, upper = false;
    rep(i, N - 1) {
        if(A[i] == A[i + 1]) continue;
        if(!smaller && !upper) smaller = (A[i] > A[i + 1]), upper = (A[i] < A[i + 1]);
        else if(A[i] < A[i + 1] && smaller) ++ans, smaller = false, upper = false;
        else if(A[i] > A[i + 1] && upper) ++ans, smaller = false, upper = false;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100][100]={0},i,j,b,c,q;
  for(cin>>n,i=0;i<n;i++){
    cin>>b>>q;b--;
    for(j=0;j<q;j++){
      cin>>c;
      a[b][--c]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)cout<<' ';
      cout<<a[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3136
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long count = Math.abs((n-2)*(m-2));
		
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 2e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();


void solve() {
	LL n, d, ans = 0;
	cin >> n >> d;
	for (int i=0;i<n;++i) {
		LL x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d) ++ans;
	}
	cout << ans << '\n';
}
 
int main() {
	FASTIO;
	int T = 1;
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
	return 0;
} 

Measured memory_bytes: 3636
import numpy as np

a,b,x=map(int,input().split())
S=a**2*b-x

if a**2*b/2 <= x:
    z=S*2/(a**2)
    rad=np.arctan(z/a)
else:
    z=x*2/(a*b)
    rad=np.arctan(b/z)
print(np.rad2deg(rad))


Measured memory_bytes: 12488
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  int n,C;
  cin>>n>>C;
  vii d=vii(C,vi(C));
  vii c=vii(n,vi(n));
  rep(i,C){
    rep(j,C){
      cin>>d[i][j];
    }
  }
  rep(i,n){
    rep(j,n){
      cin>>c[i][j];
      c[i][j]--;
    }
  }
  vii modcolor(3,vi());
  rep(i,n){
    rep(j,n){
      modcolor[(i+j)%3].pb(c[i][j]);
    }
  }
  /*sort(modcolor[0].begin(),modcolor[0].end());
  sort(modcolor[1].begin(),modcolor[1].end());
  sort(modcolor[2].begin(),modcolor[2].end());*/
  //cout<<"e";
  vii cost=vii(3,vi(C));
  int tmp=0;
  rep(i,C){
    tmp=0;
    rep(i2,modcolor[0].size()){
      tmp+=d[modcolor[0][i2]][i];
    }
    cost[0][i]=tmp;
  }
  rep(i,C){
    tmp=0;
    rep(i2,modcolor[1].size()){
      tmp+=d[modcolor[1][i2]][i];
    }
    cost[1][i]=tmp;
  }
  rep(i,C){
    tmp=0;
    rep(i2,modcolor[2].size()){
      tmp+=d[modcolor[2][i2]][i];
    }
    cost[2][i]=tmp;
  }
  int ans=intMAX;
  rep(i,C){
    rep(j,C){
      rep(k,C){
        if(i==j || j==k || k==i)continue;
        ans=min(ans,cost[0][i]+cost[1][j]+cost[2][k]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2428
#include<iostream>

#include<string.h>

#include<math.h>

using namespace std;

long int n;

#define PI 3.14159265358979323846  

int main() 

{

	double x, y, h, m;	cin >> x >> y >> h >> m;

	double angle1 = m * 6;

	double angle2 = (h * 60 + m) * 0.5;

	double z = sqrt(x * x + y * y - x * y * 2 * cos(abs(angle1 - angle2) * PI / 180.0));

	printf("%0.20f", z);

}

Measured memory_bytes: 4216
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define MAX_N 100000
typedef long long ll;

int main(){
    vector<ll> A;
    int N;
    cin >> N;
    REP(i,3*N){
        ll input;
        cin >> input;
        A.push_back(input);
    }
    sort(A.begin(),A.end(),greater<int>());
    ll ans = 0;
    REP(i,N){
        ans += A[2*i+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int a[3];
int main() {
  IOS;
  for (int i = 0; i < 3; i++)
    cin >> a[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    if (a[1] > a[0] && a[2] > a[1]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (a[1] <= a[0])
      a[1] *= 2;
    else if (a[2] <= a[1])
      a[2] *= 2;
    }
  if (a[1] > a[0] && a[2] > a[1]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;

typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<int> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

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

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;

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

void solve() {
    int k;
    cin >> k;
    vector<vi> gc(k + 1, vi(k + 1));
    rep(i, 0, k + 1) rep(j, 0, k + 1) gc[i][j] = gcd(i, j);
    int res = 0;
    rep(i, 1, k + 1) rep(j, 1, k + 1) rep(l, 1, k + 1) res += gc[i][gc[j][l]];
    put(res);
}


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

//    freopen("input.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while (t--) solve();
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define reg register
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int MN=2e5+5;
const int mod=1e9+7;
int to[MN<<3],nxt[MN<<3],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int n,X,Y;
int fac[MN],inv[MN];
int c[MN],w[MN];
vector<pii>nd[MN],q;
bool vis[MN],used[MN];
int tot,pcnt[MN];
void dfs(int st){
	vis[st]=true;tot++;
	pcnt[c[st]]++;used[c[st]]=true;
	for(reg int i=h[st];i;i=nxt[i])
		if(!vis[to[i]])dfs(to[i]);
}
int main(){
	scanf("%d%d%d",&n,&X,&Y);
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(reg int i=2;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	for(reg int i=2;i<=n;i++)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(reg int i=2;i<=n;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for(reg int i=1;i<=n;i++){
		scanf("%d%d",c+i,w+i);
		nd[c[i]].push_back(make_pair(w[i],i));
	}
	for(reg int i=1;i<=n;i++)
		if(nd[i].size()){
			sort(nd[i].begin(),nd[i].end());
			q.push_back(nd[i][0]);
			for(reg int j=1;j<nd[i].size();j++)
				if(nd[i][j].first+nd[i][0].first<=X)
					ins(nd[i][j].second,nd[i][0].second);
		}
	sort(q.begin(),q.end());
	if(q.size()){
		reg int pos=q[0].second;
		for(reg int i=1;i<=n;i++)
			if(c[i]!=c[pos]&&w[i]+w[pos]<=Y)
				ins(i,pos);
	}
	if(q.size()>1){
		reg int pos=q[1].second,col=c[q[0].second];
		for(reg int i=0;i<nd[col].size();i++)
			if(w[pos]+nd[col][i].first<=Y)
				ins(pos,nd[col][i].second);
	}
	dfs(q[0].second);
	reg int Ans=fac[tot];
	for(reg int i=1;i<=n;i++)
		if(used[i])Ans=1ll*Ans*inv[pcnt[i]]%mod;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 22388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,l;
    vector<string >v;
    vector<string >:: iterator it;
    string s1;
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
        cin>>s1;
        v.push_back(s1);
    }
    sort(v.begin(),v.end());
    for( it=v.begin();it!=v.end();it++)
    {
        cout<<*it;
    }

}


Measured memory_bytes: 3632
#include <stdio.h>

char s[100001];

void swap(int l, int r) {
   char c,d;

   while (l<=r) {
      if (s[l]=='L') c='R';
      else           c='L';
      if (s[r]=='L') d='R';
      else           d='L';
      s[l]=d;
      s[r]=c;
      l++;r--;
   }
}

int main(){
   int n,k,i,j,l,a;
 
   scanf("%d %d",&n,&k);
   scanf("%s",s);
   for (j=i=0;i<k;i++) {
      for (;j<n-2;j++)
         if (s[j]=='L' && s[j+1]=='R') {
            for (l=j+1;l<n-1;l++)
               if (s[l]=='R' && s[l+1]=='L') break;
            if (l==n-1) continue;
            swap(j+1,l);
            break;
         } else if (s[j]=='R' && s[j+1]=='L') {
            for (l=j+1;l<n-1;l++)
               if (s[l]=='L' && s[l+1]=='R') break;
            if (l==n-1) continue;
            swap(j+1,l);
            break;
         }
      if (j==n-2) break;
   }
   if (i<k) {
      for (i=1;i<n;i++)
         if (s[0]!=s[i]) break;
      if (i<n) {
         j=i;
         for (;i<n;i++)
            if (s[0]==s[i]) break;
         if (i==n) swap(j,n-1);
      }
   }
   for (a=i=0;i<n;i++)
      if (s[i]=='L' && i>0 && s[i-1]=='L') a++;
      else if (s[i]=='R' && i<n-1 && s[i+1]=='R') a++;
   printf("%d",a);
   return 0;
}


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

int main(void) {
  ll X;
  cin >> X;

  cout << "ai1333";
  REP(i, 0, X / 100) cout << "3";
  cout << endl;
}



Measured memory_bytes: 3100
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

int dp[101][1025];
bool valid[101][11];
int solve(int i, int mask, int n){
    if(i == 100){
        return (mask == 0) ? 1 : 0;
    }
    if(dp[i][mask] != -1) return dp[i][mask];
    long long ans = 0ll;
    ans = solve(i+1, mask, n);
    for(int j=0;j<n;j++){
        if((mask&(1<<j)) && valid[i][j]){
            ans = ((ans%mod) + (solve(i+1, mask^(1<<j), n)%mod))%mod;
        }
    }
    return dp[i][mask] = ans;
}

void solve(){
	int n; cin>>n;
	cout<<(n^1)<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

  int max = 0;
  n = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'D') {
      n--;
    }else {
      n++;
    }
    if(max < n) {
      max = n;
    }
  }

  cout << max << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N;
int L[200];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < 2*N; ++i) scanf("%d", L+i);

	sort(L, L+2*N);

	int res = 0;
	for (int i = 0; i < 2*N; i+=2) {
		res += L[i];
	}

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

	return 0;
}


Measured memory_bytes: 256
import math
def B_121(a , b):

    ans = "No"
    ab = a + b

    if int(math.sqrt(int(ab))) ** 2 == int(ab):
        ans = "Yes"

    return ans

def main():
    a , b = map(str , input().split())
    print(B_121(a , b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
  int n,cnt1=0,cnt2=0,ok=1,a[11000];
  cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  sort(a,a+n);
  for(int i=n-1;i>=0;--i)
  {
  	if(ok) { cnt1+=a[i]; ok=0; }
  	else { cnt2+=a[i]; ok=1; }
  }
  cout<<cnt1-cnt2<<endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 504
#include <iostream>

using namespace std;

int main()
{
    int a,b,r;
    
    cin >> a >> b;
    
    //int area;
    //area = a*b/2;
    
    if((a*b*1)%2==0){
        r = 1;
    }else{
        r = 0;
    }
    
    if((a*b*2)%2==0){
        r=1;
    }else{
        r = 0;
    } 
    
    if((a*b*3)%2==0){
        r = 1;
    }else{
        r = 0;
    }
    
    
    if(r == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    

    

    return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def primeFact(n):
    factors = set()
    factors.add(1)
    i = 2
    while i*i <= n:
        if n % i == 0:
            n //= i
            factors.add(i)
        else:
            i += 1
    if n > 1:
        factors.add(n)
    return factors


A, B = map(int, input().split())
print(len(primeFact(A) & primeFact(B)))


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

// aの約数を全て返す
vector<int> divisor(int a){
	vector<int> res;
	for(int i = 1; i*i <= a; i++){
		if(a%i == 0){
			res.push_back(i);
			if(i != a/i) res.push_back(a/i);
		}
	}
	return res;
}
int main(){
	int n;
	cin >> n;
	
	vector<int> a;
	rep(i,n){
		int aa;
		cin >> aa;
		a.push_back(aa);
	}
	
	vector<int> b(n); // 0埋め
	vector<int> ans;
	for(int i=n-1 ;i>=0 ;i--){
		// 大きい方から決める
		if(a[i]!=b[i]){
			// i+1の約数に入れる
			for(int j: divisor(i+1)) b[j-1] = b[j-1] ^ 1;
			ans.push_back(i+1); //i+1にボールを入れる
		}
	}
	
	if(b==a){
		cout << ans.size() << endl;
		rep(i,ans.size()){
			printf("%d%c", ans[i], i==n-1? '\n':' ');
		}
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
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 n,m;
string a,b;
int main(){
	cin>>n>>m>>a>>b;
	for(int i=0;i<n;i++){
		ll x = 1LL*i*m;
		if(x%n != 0) continue;
		int j = (int)(x/n);
		if(a[i] != b[j]){
			puts("-1");
			return 0;
		}
	}
	ll ans = 1LL*n*m;
	ans /= __gcd(n,m);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, C; cin>>n>>C;
  vector<int> t(100010);
  vector<vector<int>> cst(n, vector<int>(3));
  rep(i, n) {
    cin>>cst[i][1]>>cst[i][2]>>cst[i][0];
    --cst[i][1]; --cst[i][2];
  }
  sort(cst.begin(), cst.end());
  REP(j, cst[0][1], cst[0][2]+1) ++t[j];
  REP(i, 1, n) {
    REP(j, cst[i][1], cst[i][2]+1) {
      if (cst[i-1][0] == cst[i][0] and cst[i-1][2] == cst[i][1] and j == cst[i][1]) continue;
      ++t[j];
    }
  }
  
  int ans = 0;
  rep(i, 100010) ans = max(ans, t[i]);
  print(ans);

  return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n,m,k,A,num[200]={0},ans=0;
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k) cin>>A,num[A]++;
    }
    rep(i,m+1) if(num[i]==n) ans++;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
N=list(input())
ans=0

if all(N[i]=="9" for i in range(len(N))):
	ans=9*(len(N))

elif N[0]!="9" and all(N[i]=="9" for i in range(1,len(N))):
	for i in range(len(N)):
		ans+=int(N[i])

else:
	ans=int(N[0])-1
	for i in range(1,len(N)):
		ans+=9

print(ans)

Measured memory_bytes: 3064
PROGRAM brickBreak
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: a(:)
      integer(16) :: i,j,skip
      
      read*,n
      allocate( a(n) )
      read*,a
      
      
      
      j = 1
      skip = 0
      do i = 1,n
        if( a(i)==j )then
          j = j + 1
        else
          skip = skip + 1
        end if
      end do
      
      if( j==1 .and. skip==n )then
        print*,'-1'
      else
        print*,skip
      end if
      
      
      
      END PROGRAM

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

int main(){
    int a=0,b=0,ans=0;
    string s;
    char c;

    cin >> s;
    for (int i = 0; i < s.length(); i++){
        if(i%2==1)c='1';
        else c='0';
        
        if(s[i]==c){
            a++;
        }else{
            b++;
        }
    }
    
    ans = min(a,b);
    cout << ans <<endl;
    return 0;
}


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

int main(){
    int N = 0, A_sum = 0, B_sum = 0;
    cin >> N;
    //card情報の取得
    vector<int> card(N);
    rep(i, N){
        cin >> card.at(i);
    }
    //逆ソート
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    
    //rep(i,N){
    //    cout << card.at(i) << " " << endl;
    //}

    //偶数はAliceに足して、奇数はBobに足す
    rep(j, N){
        if(j%2 == 0){
            A_sum += card.at(j);
        }
        else{
            B_sum += card.at(j);
        }
    }

    // 出力
    //cout << A_sum << "," << B_sum << endl;
    cout << (A_sum - B_sum) << endl;

}

Measured memory_bytes: 256
from math import gcd

n, m = map(int, input().split())
g = gcd(n, m)
s = input()
t = input()
f = True
for i in range(g):
    a = i * n // g
    b = i * m // g
    f &= (s[a] == t[b])

if f:
    print((n * m) // g)
else:
    print(-1)


Measured memory_bytes: 9316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,p;cin>>n>>p;
    vector<ll> dp(6000,0);
    dp[0]=1;
    rep(i,n){
        int a;cin>>a;
        for(int j=5000;j-a>=0;j--){
            if(dp[j-a]!=0)dp[j]+=dp[j-a];
        }
    }
    ll res=0;
    rep(i,5001){
        if(i%2==p)res+=dp[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3604
use proconio::{input, fastout};
use std::process;

#[fastout]
fn main() {
    input!{
        n: usize,
    }
    let mut ret: u64 = 0;
    let mut prev: u64 = 2;
    let mut curr: u64 = 1;
    if n == 1 {
	println!("1");
    } else {
	for i in 2..(n+1) {
	    ret = prev + curr;
	    prev = curr;
	    curr = ret;
	}
	println!("{}", ret);
    }
}


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

long long modPow(long long x, long long n){
    if(n == 0)
        return 1;
    if(n % 2 == 0)
        return modPow(x * x % MOD, n / 2);
    else
        return x * modPow(x, n - 1) % MOD;
}

long long modcmb(long long n, long long k, long long mod){
    long long tmp = n;
    for(long long i = 1; i < k; i++){
            tmp *= (n-i)*modPow(i+1, mod-2)%mod;
            tmp %= mod;
    }
    return tmp;
}

int main(){
    long long n, a, b;
    cin >> n >> a >> b;

    long long sum;
    sum = (modPow(2,n) - 1 - modcmb(n, a, MOD) - modcmb(n,b, MOD)) % MOD;
    if(sum<0) sum += MOD;

    cout << sum << endl;
    return 0;
}

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


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    int a[6] = {0};
    cin >> n;
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M'){
            a[0]++;
        }
        else if(s[0] == 'A'){
            a[1]++;
        }
        else if(s[0] == 'R'){
            a[2]++;
        }
        else if(s[0] == 'C'){
            a[3]++;
        }
        else if(s[0] == 'H'){
            a[4]++;
        }
    }
    long long ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += 1ll * a[i] * a[j] * a[k];
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n,m,i,l=1,r,li,ri,ans;
  cin >> n >> m;
  r=n;
  for (i=0;i<m;i++){
    cin >> li >> ri;
    if (l<li) l=li;
    if (r>ri) r=ri;
  }
  ans=r-l+1;
  if (ans<0) ans=0;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> 
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
inline int read()
{
	int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=-1,ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();
	return x*t;
}
typedef long long ll;
typedef pair<int,int> P;
int main(void){
  	int a,b; cin >> a >> b;
  	int i = 1;
  	while(i < 10000){
    	if(i*8/100==a&&i*10/100==b){
      	cout << i << endl;
      	return 0;
    	}
    	i++;
  	}
  	printf("%d",-1);
  	return 0;
}

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

int main() {
    int N;
    std::cin >> N;

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

    long long xor_A = 0;
    for (int i = 0; i < N; i++) xor_A ^= A[i];

    std::vector<long long> v(N);
    for (int i = 0; i < N; i++) v[i] = A[i] & ~xor_A;

    long long rank = 0;
    for (int i = 59; i >= 0; i--) {
        for (int j = rank; j < N; j++) {
            if (v[j] & 1LL << i) {
                if (j > rank) v[rank] ^= v[j];

                for (int k = 0; k < N; k++) {
                    if (k != rank && v[k] & 1LL << i)
                        v[k] ^= v[rank];
                }

                rank++;
                break;
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < N; i++) res ^= v[i];

    std::cout << res * 2 + xor_A << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int ls[MX];
	
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    int sum = 0;
    fi(0, n + 1) {
    	cin >> ls[i];
    	sum += ls[i];
    }
    int ans = 0;
    int all = 1;
    fi(0, n + 1) {
    	ans += all;
    	all -= ls[i];
    	sum -= ls[i];
    	if (all < 0 || (all == 0 && sum != 0)) {
    		cout << "-1\n";
    		return 0;
    	}
    	if (2 * all >= sum) {
    		all = sum;
    	} else {
    		all *= 2;
    	}
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4432
type Score =Double

main :: IO()
main = getContents >>= putOut.formatOut.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
   
formatIn :: String -> [[Score]]
formatIn = map (map read.words).f.lines
    where f []       = []
          f (_:[])   = []
          f ("0":_)  = []
          f (_:x:xs) = x : f xs 

formatOut :: [Double] -> String
formatOut = unlines.map (show.(/100000).realToFrac.floor.(*100000))
 
solve :: [[Score]] -> [Double]
solve xs = map (sqrt.disp) xs

disp :: [Score] -> Double
disp x =  (/n).sum $map (\y -> (y-m)^2) x
    where n = realToFrac $length x
          m = (/n).realToFrac $sum x

Measured memory_bytes: 5172
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 a[100000];

 bool solve() {
    indef(i32, n);
    i32 maxa = 0, mina = INT_MAX;
    times(n, ai) {
        in(a[ai]);
        maxa = max(maxa, a[ai]);
        mina = min(mina, a[ai]);
    }
    i32 mincnt = 0;
    times(n, ai) {
        mincnt += a[ai] == mina;
    }
    if (maxa - mina > 1) return false;
    if (maxa - mina == 1) {
        return maxa - mincnt > 0 && 2 * maxa <= n + mincnt;
    }
    return maxa == n-1 || maxa * 2 <= n;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    out(solve() ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 640