akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main(){
	    int N, M; cin >> N >> M;
        cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,int> P;
typedef long double ld;

const ll MAX_LEN = 500;
int dp[101][101][MAX_LEN] = {};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, w; cin >> n >> w;
    vector<P> wv(n); rep (i, n) cin >> wv[i].first >> wv[i].second;
    sort(all(wv));
    ll w_std = wv[0].first;
    rep (i, n) wv[i].first -= w_std;
    rep (i, n) {
        rep (j, i + 1) {
            reprev (k, min(MAX_LEN - 3, w - j * w_std + 1LL)) {
                chmax(dp[i + 1][j + 1][k + wv[i].first], dp[i][j][k] + wv[i].second);
                chmax(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
        rep (j, i + 1) {
            rep (k, min(MAX_LEN, w - i * w_std + 1LL)) {
                eprintf("%d ", dp[i + 1][j + 1][k]);
            }
            eprintf("\n");
        }
        eprintf("\n");
    }
    int ans = 0;
    rep (i, n + 1) {
        rep (j, min(MAX_LEN, w - i * w_std + 1LL)) chmax(ans, dp[n][i][j]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=998244353;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
const int INF=1000000000000000000;
//000111000111  1c7
//4x-2a=y 2i+4x-4i
int32_t main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	string ans="No";
	for(int i=0;i<=a;++i)
	{
		if(b==4*a-2*i)
		{
			ans="Yes";
			break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(void)
{
    int a,b;
    cin >> a >> b;
    int total = 1;
    int i = 0;
    while (total < b) {
        total += a - 1;
        i++;
    }
    cout << i << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

ll imos[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	vector<int> p(m);
	for(int i=0;i<m;i++){
		cin >> p[i];
		p[i]--;
	}
	vector<ll> a(n-1),b(n-1),c(n-1);
	for(int i=0;i<n-1;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i=0;i<m-1;i++){
		int st=p[i],ed=p[i+1];
		if(st>ed)swap(st,ed);
		imos[st]++;
		imos[ed]--;
	}
	for(int i=0;i<n;i++){
		imos[i+1]+=imos[i];
	}
	ll ans=0;
	for(int i=0;i<n-1;i++){
		ans+=min(a[i]*imos[i],c[i]+b[i]*imos[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
const int N=500010,mod=19260817,qs=19491001;
#define ull unsigned long long
char c[N];
int n;
unsigned long long h[N],qp[N];
unsigned int h1[N],qp1[N];
ull gh(int l,int r)
{
	return (h[r]-1ll*h[l-1]*qp[r-l+1]%qs+qs)%qs;
}
unsigned int gh1(int l,int r)
{
	return (h1[r]-1ll*h1[l-1]*qp1[r-l+1]%mod+mod)%mod;
}
int len[N],len1[N];
int main()
{
	scanf("%s",c+1);
	n=strlen(c+1);
	qp[0]=1;
	for(int i=1;i<=n;i++)
		h[i]=1ll*h[i-1]*mod%qs+c[i]-'a'+1,h1[i]=1ll*h1[i-1]*qs%mod+c[i]-'a'+1;
	qp1[0]=1;
	for(int i=1;i<=n;i++)
		qp[i]=1ll*qp[i-1]*mod%qs,qp1[i]=1ll*qp1[i-1]*qs%mod;
	for(int i=1;i<=n/2;i++)
		if(!len[i*2] && gh(1,i)==gh(i+1,i*2) && gh1(1,i)==gh1(i+1,i*2))
		{
			len[i*2]=i;
			ull p=gh(1,i);
			unsigned int q=gh1(1,i);
			for(int j=i*3;j<=n;j+=i)
				if(gh(j-i+1,j)==p && gh1(j-i+1,j)==q)
					len[j]=i;
				else
					break;
		}
	for(int i=1;i<=n/2;i++)
		if(!len1[n-i*2+1] && gh(n-i+1,n)==gh(n-2*i+1,n-i) && gh1(n-i+1,n)==gh1(n-2*i+1,n-i))
		{
			len1[n-i*2+1]=i;
			ull p=gh(n-i+1,n);
			unsigned int q=gh1(n-i+1,n);
			for(int j=i*3;j<=n;j+=i)
				if(gh(n-j+1,n-j+i)==p && gh1(n-j+1,n-j+i)==q)
					len1[n-j+1]=i;
				else
					break;
		}
	if(len[n]==1)
	{
		printf("%d\n1\n",n);
		return 0;
	}
	if(!len[n])
	{
		printf("1\n1\n");
		return 0;
	}
	int ans=0;
	for(int i=1;i<n;i++)
		if(!len[i] && !len1[i+1])
			ans++;
	printf("2\n%d\n",ans);
	return 0;
}//

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll A, B, N;
    cin >> N >> A >> B;
    if(N==1){
        cout << (A==B) << endl;
    }else{
        if(A>B){
            cout << 0 << endl;
        }else if(A==B){
            cout << 1 << endl;
        }else{
            cout << A+B*(N-1) - A*(N-1)-B+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1e9.toLong() + 7

    val fact = LongArray(200000)
    fact[0] = 1L
    for (i in 1 until fact.size) {
        fact[i] = i * fact[i - 1] % mod
    }

    fun factorial(n: Long): Long {
        return fact[n.toInt()]
    }

    fun div(a: Long, b: Long): Long {

        fun calc(a: Long, b: Long): Long {
            if (b == 0L) return 1L
            if (b % 2L == 0L) {
                val d = calc(a, b / 2)
                return d * d % mod
            }
            return a * calc(a, b - 1) % mod
        }

        return a * calc(b, mod - 2) % mod
    }

    fun conb(n: Long, k: Long): Long {
        return div(div(factorial(n), factorial(n - k)), factorial(k))
    }

    fun factorize(n: Int): MutableMap<Int, Int> {
        val r = mutableMapOf<Int, Int>()
        var x = n
        var i = 2
        while (i * i <= n) {
            while (x % i == 0) {
                r[i] = (r[i] ?: 0) + 1
                x /= i
            }
            i++
        }
        if (x > 1) {
            r[x] = (r[x] ?: 0) + 1
        }
        return r
    }

    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    factorize(m).values
            .map { it.toLong() }
            .fold(1L) { acc, i -> acc * conb(i + n - 1, i) % mod }
            .let { println(it) }
}


Measured memory_bytes: 42980
#include<stdio.h>
int main()
{
    long long int a,b,k;
    long long int r1,r2;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(k>=(a+b))
    {
        r1=0;
        r2=0;
        
    }
    else if(k>=a)
    {
        r1=0;
        r2=b-(k-a);
    }
    else
    {
        r1=a-k;
        r2=b;
    }
    printf("%lld %lld\n",r1,r2);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

int main(void){

int N,K,i,j,c;
double x=0;

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

for(j=1;j<=N;j++){
   i=j;
   c=0;
   while(i<=(K-1)){
     i+=i;
     c++;
   }
   x=x+(1/(N*pow(2,c)));
}
   printf("%1.12lf\n",x);

return 0;
}


Measured memory_bytes: 256
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                val = x ** 2 + y ** 2 + z ** 2 + x * y + z * y + x * z
                #print(x, y, z, ":", val)
                if val <= n:
                    res[val - 1] += 1
    for r in res:
        print(r)
    return




n = RN()
res = [0] * n
solve()


Measured memory_bytes: 73292
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll modAdd(ll a, ll b, ll mod) {
	return ((a % mod) + (b % mod)) % mod;
}

ll modSub(ll a, ll b, ll mod) {
	ll c = ((a % mod) - (b % mod)) % mod;
	return ((c < 0) ? c + mod : c);
}
ll modMul(ll a, ll b, ll mod) {
	return ((a % mod) * (b % mod)) % mod;
}

ll modPow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0)
	{
		if (n & 1) {
			res = modMul(res, a, mod);
		}
		a = modMul(a, a, mod);
		n >>= 1;
	}
	return res;
}

ll modDiv(ll a, ll b, ll mod) {
	return modMul(a, modPow(b, mod - 2, mod), mod);
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	vector<ll> b(60);
	for (int k = 0; k < 60; k++) {
		ll b0 = 0;
		ll b1 = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				b0++;
			} else {
				b1++;
			}
			a[i] >>= 1;
		}
		b[k] = b0 * b1;
	}

	ll cnt = 0;
	ll mod = 1000000000 + 7;
	for (int k = 0; k < 60; k++) {
		ll t = modPow(2, k, mod);
		t = modMul(b[k], t, mod);
		cnt = modAdd(cnt, t, mod);
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;

constexpr int MAX_N = 200005;

typedef pair<int, int> pii;

int n, m, L[MAX_N], R[MAX_N];

vector<pii> rob;

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

    fill(L, L + MAX_N, 1);
    fill(R, R + MAX_N, 1);

    cin >> n >> m;
    L[0] = R[0] = R[1] = L[n + 1] = 0;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        rob.emplace_back(x, y);
    }
    sort(rob.begin(), rob.end());

    for (const auto r : rob)
    {
        const int y = r.second;
        R[y + 2] += R[y + 1];
        R[y + 1] = 0;
        L[y] += L[y + 1];
        L[y + 1] = 0;
    }

//    for (int i = 1; i <= n + 1; i++)
//    {
//        cerr << i << ": " << L[i] << " " << R[i] << endl;
//    }

    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        cnt += L[i] - R[i];
        cout << cnt;
        if (i != n) cout << " ";
    }
    cout << endl;
}



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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, A[300030];

  void init() {
    scanf("%lld", &N);
    rep(i, N) scanf("%lld", A+i);
  }

  void solve() {
    ll ans = 0;
    rep(d, 62) {
      ll zero = 0, one = 0;
      rep(i, N) {
        if((A[i]>>d)&1) one++;
        else zero++;
      }
      ans += (one * zero % MOD_1_000_000_007) * ((ll)pow(2, d) % MOD_1_000_000_007);
      ans %= MOD_1_000_000_007;
    }
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

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

int main() {

	int d, g; cin >> d >> g;
	vector<int> p(d), c(d);
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}
	int ans = 2147483647;
	for (int bit = 0; bit < (1 << d); ++bit) {
		int tmpAns = 0;
		int tmpScore = 0;
		for (int i = 0; i < d; ++i) {
			if (bit & (1 << i)) {
				tmpAns += p[i];
				tmpScore += 100 * (i + 1) * p[i];
				tmpScore += c[i];
			}
		}
		if (g <= tmpScore) {
			ans = min(ans, tmpAns);
		}
		else {
			for (int i = d - 1; i >= 0; i--) {
				if (bit & (1 << i)) continue;
				for (int j = 0; j < p[i] - 1; j++) {
					tmpAns += 1;
					tmpScore += 100 * (i + 1);
					if (g <= tmpScore) {
						ans = min(ans, tmpAns);
						break;
					}
				}				
			}
		}
	}

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

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

int main() {
  int N;
  int x =0;
  cin >> N;
  vector<int> A(N);
  
  for ( int i=0; i< N; i++) {
    cin >> A.at(i);
    while (A.at(i)%2 == 0) {
      A.at(i) = A.at(i)/2;
      x++;
    }
  }
  cout << x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;


    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int sx, sy, tx, ty;
    scan(sx, sy, tx, ty);

    int dx = tx - sx;
    int dy = ty - sy;
    string ans =
        string(dx, 'R') + string(dy, 'U') + string(dx, 'L') + string(dy, 'D');
    ans += "D" + string(dx + 1, 'R') + string(dy + 1, 'U') + "LU" +
           string(dx + 1, 'L') + string(dy + 1, 'D') + "R";
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int dp[100005][3];//0:r 1:s 2:p

int main()
{
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;


	for (int i = 1; i <= n; i++) {
		char t;
		cin >> t;
		if (i <= k) {
			int lm = 0;
			if (t == 'r') {
				dp[i][0] = 0;
				dp[i][1] = 0;
				dp[i][2] = p;
			}else if (t == 's') {
				dp[i][0] = r;
				dp[i][1] = 0;
				dp[i][2] = 0;
			}else{
				dp[i][0] = 0;
				dp[i][1] = s;
				dp[i][2] = 0;
			}
		}
		else {
			int lm = 0;
			if (t == 'r') {
				dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
				dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
				dp[i][2] = max(dp[i - k][1], dp[i - k][0]) + p;
			}
			else if (t == 's') {
				dp[i][0] = max(dp[i - k][1], dp[i - k][2]) + r;
				dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
				dp[i][2] = max(dp[i - k][1], dp[i - k][0]);
			}
			else {
				dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
				dp[i][1] = max(dp[i - k][0], dp[i - k][2]) + s;
				dp[i][2] = max(dp[i - k][1], dp[i - k][0]);
			}
		}
	}
	int res=0;
	for (int i = n; i > n - k; i--) {
		res += max(dp[i][0], max(dp[i][1], dp[i][2]));
	}
	cout << res;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n, m;
	scanf("%lld %lld", &n ,&m);

	ll ans = min(m/2,(2*n+m)/4);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>P(N);for(long i=0;i<N;i++)cin>>P[i];
  long M=LONG_MAX;long ans=0;
  for(long i=0;i<N;i++)if(P[i]<M){ans++;M=P[i];}
  cout<<ans;
}

Measured memory_bytes: 1792
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = [0] * N
    for i in range(N):
        A[i] = [int(s) - 1 for s in readline().split()]

    M = N * (N - 1) // 2

    total_mathces = 0
    changed = set(range(N))
    for day in range(M):
        matches = 0
        changed_prev, changed = changed, set()
        for i in changed_prev:
            if i in changed or not A[i]:
                continue
            j = A[i][-1]
            if j not in changed and i == A[j][-1]:
                changed.add(i)
                changed.add(j)
                A[i].pop()
                A[j].pop()
                matches += 1

        if matches == 0:
            ans = -1
            break

        total_mathces += matches
        if total_mathces == M:
            ans = day + 1
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 91684
program hina_arare
  implicit none
  integer :: n, i
  character(1) :: s(100)
  read(*,*) n
  read(*,*) s(1:n)
  do i = 1, n
    if (s(i) /= "Y") cycle
    write(*,'(a)') "Four"
    stop
  end do
  write(*,'(a)') "Three"
end program hina_arare

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double prob[n];
  for(int i=0;i<n;i++)
    cin>>prob[i];
  double dp[n+1][n+1];
 dp[0][0]=1.0;
  for(int i=1;i<=n;i++)
    dp[0][i]=0.0;
  for(int i=1;i<n+1;i++)
    dp[i][0]=dp[i-1][0]*(1-prob[i-1]);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j>i)
        dp[i][j]=0.0;
      else
        dp[i][j]=prob[i-1]*dp[i-1][j-1]+(1-prob[i-1])*(dp[i-1][j]);
    }
  }
  double sum=0.0;
  for(int i=(n/2)+1;i<=n;i++){
    sum+=dp[n][i];
  }
  cout<<setprecision(9);
  cout<<fixed;
  cout<<sum<<endl;
}

Measured memory_bytes: 74064
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

char S[10];

int main()
{
  cin >>S;
  if(S[0]=='7' || S[1]=='7' || S[2]=='7')
  {
    cout <<"Yes";
  }
  else
  {
    cout << "No";
  }
  
  
  
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int a, b;
signed main() {
    cin >> a >> b;
    if (make_pair(a, b) < make_pair(b, a)) { rep(i, b) { cout << a; }}
    else { rep(i, a) { cout << b; }}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	char a[3];
	for (int b = 0; b < 3; b++) {
		cin >> a[b];
	}
	if (a[0] >= a[1] && a[0] >= a[2]) cout << a[0] << a[0] << a[0] << endl;
	else { a[0] += 1; cout << a[0] << a[0] << a[0] << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}

string s;
ModularInt three[1000005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s;

    three[0] = 1;
    for(int i = 1; i <= s.size(); i++)
        three[i] = three[i - 1] * 3;

    ModularInt ans = 0;
    ModularInt cnt = 1;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0')
            continue;

        ans += cnt * three[s.size() - i - 1];
        cnt *= 2;
    }
    ans += cnt;
    cout << ans << endl;
}

Measured memory_bytes: 4480
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long
#define Linf (LL)1e18
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };

string date[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
	string s;
	cin >> s;
	for(int i=0; i<7; i++){
		if(s==date[i])cout << 7-i << endl;
	}

	return 0;
}

Measured memory_bytes: 764
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

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

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 105;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

void solve()
{
    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        sum += A[i];
    }
    if (sum % 10 != 0) {
        printf("%d\n", sum);
    } else {
        int ans = 0;
        for (int i = 1; i <= N; ++i) {
            if ((sum - A[i]) % 10 != 0)
                chkmax(ans, sum - A[i]);
        }
        printf("%d\n", ans);
    }
}

int main()
{
#ifdef __DEBUG
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 春色满园关不住，一枝红杏出墙来。
//     -- 叶绍翁《游园不值》


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

int main() {
    int n,K;    cin>>n>>K;
    int a[n];
    long long dp[n];
    for(int i=0;i<n;i++)        cin>>a[i];
    
    dp[0]=0;
    
    for(int i=1;i<n;i++){
        long long add=1e9;
        for(int k=1;k<=K;k++)if(i-k>=0){
            add=min(add, dp[i-k] + abs(a[i]-a[i-k]));
        }
        dp[i]= add; 
        
    }
    cout<<dp[n-1]<<endl;    
    return 0;
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll r, d, x; cin >> r >> d >> x;
    for (int i = 0; i < 10; ++i){
    	x = r*x-d;
    	cout << x << endl;
    }

    return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int aa;
		cin >> aa;
		N = N - aa;
	}
	
	if(N < 0){
		cout << -1 << endl;
	}else{
		cout << N << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 205;
long long bas[maxn], idx[maxn];
long long k; //当前质因子个数

int divide(long long n) {
	k = 0;
	for(long long i = 2; i * i <= n; i++) {
		if(n % i == 0) {
			bas[++k] = i;
			idx[k] = 0;
			while(n % i == 0) {
				n /= i;
				idx[k]++;
			}
		}
	}
	if(n > 1) {
		bas[++k] = n;
		idx[k] = 1;
	}
	return k;
} 
long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a%b);
}
int main() {
	long long a, b;
	cin >> a >> b;
	cout << divide(gcd(a, b))+1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x, y, z;
	char s;
	while(1){
	scanf("%d %c %d", &x, &s, &y);
	switch(s){
		case '?': return 0;
		case '+': z = x+y; break;
		case '-': z = x-y; break;
		case '*': z = x*y; break;
		case '/': z = x/y;
	}
	printf("%d\n", z);
	}
	return 0;
}


Measured memory_bytes: 2724
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]	

dic = dict()

for a in A:
	if a in dic:
		dic[a] ^= 1
	else:
		dic[a] = 1

#print(dic)
ans = 0
for x in dic:
	ans += dic[x]
print(ans)
	


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b%a, a);
}

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

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

	ll a,b,c;

	cin >> a >> b >> c;

	if(a%b == 0)
		cout << (a/b)*c << endl;
	else
		cout << ((a/b)+1)*c << endl;

}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int a, b, c, d, e;
string s, t;

int main(){
  cin >> a >> b >> c >> d >> e;
  int k = (c - a) * 60 + d - b;
  cout << k - e <<endl;
}
 

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

int N, K, L;

class UnionFind {
	public:
		vector<int> par, rank;
		void init(int n) {
			par = vector<int>(n);
			rank = vector<int>(n);
			for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0;
		}
		// 木の根を求める
		int root(int x) {
			return (par[x] == x) ? x : par[x] = root(par[x]);
		}
		// xとyの属する集合を併合
		void unite(int x, int y) {
			x = root(x), y = root(y);
			if (x == y)return;
 
			if (rank[x] < rank[y]) par[x] = y;
			else {
				par[y] = x;
				if (rank[x] == rank[y]) rank[x]++;
			}
		}
		// xとyが同じ集合に属するか否か
		bool same(int x, int y) {
			return root(x) == root(y);
		}
};

int main(void){
    
    scanf("%d %d %d", &N, &K, &L);
    
    UnionFind uf1, uf2;
    uf1.init(N + 1), uf2.init(N + 1);
    
    for(int i = 0; i < K; ++i){
        int p, q; scanf("%d %d", &p, &q); uf1.unite(p, q);
    }
    for(int i = 0; i < L; ++i){
        int r, s; scanf("%d %d", &r, &s); uf2.unite(r, s);
    }
    
    vector<P> v(N + 1);
	map<P, int> mp;
	for(int i = 1; i <= N; i++){
		v[i].first = uf1.root(i);
		v[i].second = uf2.root(i);
		mp[v[i]]++;
	}

	for(int i = 1; i <= N; i++){
	    if(i != 1) printf(" ");
		printf("%d", mp[v[i]]);
	}
	printf("\n");
    
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    ll n,cnt = 0;
	cin >> n;
    
    map<char,ll> m;
    rep(i,0,n){
        string t;
        cin >> t;

        switch(t[0]){
            case 'M':
            case 'A':
            case 'R':
            case 'C':
            case 'H':
                m[t[0]]++;
                cnt++;
                break;
        }
    }

    string ss = "MARCH"; 
    ll ans = 0;
    rep(i,0,3){
        rep(j,i+1,4){
            rep(k,j+1,5){
                ans +=  m[ss[i]] *  m[ss[j]] *  m[ss[k]]; 
            }
        }
    }
    P(ans);
	
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

int cnt[111111];

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    rep(i, 0, n) {
        int x;
        cin >> x;
        cnt[x]++;
        cnt[x + 1]++;
        cnt[x + 2]++;
    }
    int mx = 0;
    rep(i, 1, 111111) {
        if (cnt[i] > cnt[mx]) {
            mx = i;
        }
    }
    cout << cnt[mx];
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i=0;i<3*N;++i) cin >> a[i];
  sort(a.begin(),a.end());
  long long sum = 0;
  for(int i=0;i<N;++i){
    sum += a[3*N-i*2-2];
    //cout<<i<<" "<<3*N-i*2<<endl;
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 1408
#include <stdio.h>

int gcd(int a, int b){
    if (b > a){
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int k_divisor(int A, int K){
    int count = 0;
    int ans = 0;
    for (int i = A; i > 0; i--){
        if(A % i == 0){
            count += 1;
        }
        if(count == K){
            ans = i;
            break;
        }
    }
    return ans;
}

int main(void){
    int A, B, K;
    scanf("%d %d %d", &A, &B, &K);
    int g = gcd(A, B);
    int ans = k_divisor(g, K);
    printf("%d\n", ans);
    return 0; 
}

Measured memory_bytes: 128
n = raw_input()
n = int(n)
w = []
for i in range(n):
	v = raw_input()
	w.append(v)

words = dict()
for i in w:
	words[i] = words.get(i,0)+1

for i in words:
	if words[i]>1:
		print("No")
		exit(0)

for i in range(1,len(w)):
	if w[i][0]!=w[i-1][-1]:
		print("No")
		exit(0)

print("Yes")

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var x = int.Parse(_[1]);
            var l = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var d = 0;
            var count = 1;
            for(var i = 1; i < n + 1; i++){
                d += l[i - 1];
                if(d <= x){
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll W, H, N;
	cin >> W >> H >> N;
	ll l = 0;
	ll r = W;
	ll d = 0;
	ll u = H;

	repn(i, N) {
		ll x, y, a;
		cin >> x >> y >> a;

		if (a == 1) { l = max(l, x); }
		if (a == 2) { r = min(r, x); }
		if (a == 3) { d = max(d, y); }
		if (a == 4) { u = min(u, y); }
	}

	cout << max((r - l),0)*max((u - d),0);



	system("PAUSE");
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool ans=false;
    for(int i=1;i<=b;i++){
        if(a*i%b==c) ans=true;
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

string s;

int main()
{
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3648
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut n: Vec<i32> = (0..4).map(|_| read()).collect();

    n.sort();
    let ans = if n == vec![1, 4, 7, 9] { "YES" } else { "NO" };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(void){
    string A,B;
    cin>>A>>B;
    if (A.size()>B.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }
    else if (A.size()<B.size()){
        cout<<"LESS"<<endl;
        return 0;
    }
    else {
        for (int i=0;i<A.size();i++){
            if (A[i]>B[i]) {
                cout<<"GREATER"<<endl;
                return 0;
            }
            else if (A[i]<B[i]) {
                cout<<"LESS"<<endl;
                return 0;
            }
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}

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

using namespace std;

const int M = 1e9+7;

int H, W, perms[1005][1005];
string grid[1005];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> H >> W;
	for (int i=1;i<=H;++i) cin >> grid[i];
	perms[1][1] = 1;
	for (int i=1;i<=H;++i) {
		grid[i] = "!"+grid[i];
		for (int j=1;j<=W;++j) {
			if (grid[i][j] == '.') {
				if (grid[i-1][j] == '.') perms[i][j] = (perms[i][j]+perms[i-1][j])%M;
				if (grid[i][j-1] == '.') perms[i][j] = (perms[i][j]+perms[i][j-1])%M;
			}
		}
	}
	cout << perms[H][W] << '\n';
	return 0;
}

Measured memory_bytes: 8612
#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<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin >> S[i];
  }
  vector<bool> h(H,false);
  vector<bool> w(W,false);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j] == '#'){
        h[i] = true;
        w[j] = true;
      }
    }
  }
  for(int i=0; i<H; i++){
    if(!h[i]){
      continue;
    }
    for(int j=0; j<W; j++){
      if(w[j]){
        cout << S[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  char A[2][3];
  for(int i=0;i<2;i++){
    for(int j=0;j<3;j++){
      cin >> A[i][j];
    }
  }
  if(A[0][0] == A[1][2] && A[0][1] == A[1][1] && A[0][2] == A[1][0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main() {
  int count=0;
  int N;
  long long A,B,K;
  cin>>A>>B>>K;
  if(A+B<=K){
    cout<<0<<" "<<0;
    return 0;
  }
  if(A<=K){
    cout<<0<<" ";
    cout<<B-(K-A);
    return 0;
  }
  cout<<A-K<<" "<<B;
}

Measured memory_bytes: 256
import bisect
a,b,q = map(int,input().split())
s = []
ans = []
for i in range(a):
    s0 = int(input())
    s.append(s0)
t = []
for i in range(b):
    t0 = int(input())
    t.append(t0)
for i in range(q):
    x = int(input())
    m = bisect.bisect_left(s,x)
    n = bisect.bisect_left(t,x)
    ai = []
    bi = []
    ansl = []
    if m > 0 and m < a:
        ai.append(s[m])
        ai.append(s[m-1])
    elif m == 0:
        ai.append(s[m])
    else:
        ai.append(s[m-1])
    if n > 0 and n < b:
        bi.append(t[n])
        bi.append(t[n-1])
    elif n == 0:
        bi.append(t[n])
    else:
        bi.append(t[n-1])
    for j in ai:
        for k in bi:
            if (j-x)*(k-x) > 0:
                ansl.append(max(abs(j-x),abs(k-x)))
            else:
                ansl.append(abs(j-k)+abs(j-x))
                ansl.append(abs(j-k)+abs(k-x))
    ans.append(min(ansl))
for i in ans:
    print(i)

Measured memory_bytes: 16408
N,M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
L1 = []
R1 = []
for i in range(M):
    L1.append(LR[i][0])
    R1.append(LR[i][1])
if min(R1)>=max(L1):
    print(min(R1)-max(L1)+1)
else:
    print(0)

Measured memory_bytes: 29088