akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	int A, B;
	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n; cin>>n;
    ll mod=1e9+7;
    vector<vector<ll>> dp(101, vector<ll>(256, 0));
    rep(i, 4) dp[1][i]=1;
    rep(i, 4){
        rep(j, 4){
            dp[2][i*4+j]+=dp[1][i];
        }
    }
    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                if( i*16+j*4+k == 9) continue;
                if( i*16+j*4+k == 33) continue;
                if( i*16+j*4+k == 6) continue;
                dp[3][i*16+j*4+k]+=dp[2][i*4+j];
            }
        }
    }

    for(ll i=4; i<=100; i++){
        rep(j, 256){
            rep(k, 4){
                ll next=(j*4 + k)%256;
                if(next%64 == 9) continue; //xAGC
                if(next/4 == 9) continue; //AGCx
                if(next%64 == 33) continue; // xGAC
                if(next%64 == 6) continue; //xACG
                if(next/64==0 && (j*4 + k)%16==9) continue; //AxGC
                if(next/16==2 && (j*4 + k)%4==1) continue; //AGxC
                dp[i][next%256] += dp[i-1][j];
                dp[i][next%256] %= mod;
            }
        }
    }
    ll res=0;
    rep(i, 256){
        res+=dp[n][i];
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll X;
    cin >> X;
    ll cnt = 0;
    double x = 0, y = 0;
    double eps = 1e-8;
    while (true) {
        x += cos(X * cnt * M_PI / 180.0);
        y += sin(X * cnt * M_PI / 180.0);
        ++cnt;
        if (abs(x) < eps && abs(y) < eps) {
            break;
        }
    }
    cout << cnt << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 4000
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<set>
#define LL long long int
using namespace std;

const int maxn = 120000;
map <LL,int> mp;
map <LL,int> ::reverse_iterator riter1,riter2;
set<int> st;

void init()
{
	mp.clear();
	st.clear();
}

int main()
{
	int n;
	while(cin >> n)
	{
		init();
		int cnt = 0;
		for(int i = 0;i<n;i++)
		{
			LL x;
			scanf("%lld",&x);
			mp[x] ++;
		}
		LL ans = 0;
		for(riter1 = mp.rbegin();riter1!=mp.rend();riter1++)
		{
			if(riter1->second >= 2)
			{
				mp[riter1->first] -= 2;
				ans = (riter1->first);
				for(riter2 = riter1;riter2 != mp.rend();riter2++)
				{
					if(riter2->second >= 2)
					{
						ans *= (riter2->first);
						break;
					}
				}
				break;
			}
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
 
int main(){
    int a, b;
    while(cin >> a >> b && !(a == 0 && b == 0)){
        for(int i = 0; i < b; i++){
            cout << '#';
        }
        cout << endl;
        for(int i = 1; i < a-1; i++){
            cout << '#';
            for(int j = 1; j < b-1; j++){
                cout << '.' ;
            }
            cout << '#' << endl;
        }
        for(int i = 0; i < b; i++){
            cout << '#';
        }
        cout << endl << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 1 && a <= 9 && b >= 1 && b <= 9 ) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
        sc.close();
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	vector<int> in(N);
	for (auto i = 0; i < N - 1 + M; ++i)
	{
		int A, B;
		cin >> A >> B;
		G[A - 1].push_back(B - 1);
		++in[B - 1];
	}

	stack<int> s;
	auto root = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (in[i] == 0)
		{
			root = i;
			s.push(i);
			break;
		}
	}

	vector<int> index(N);
	auto next = 1;
	while (!s.empty())
	{
		auto u = s.top();
		s.pop();
		index[u] = next;
		++next;

		for (auto v : G[u])
		{
			--in[v];
			if (in[v] == 0)
			{
				s.push(v);
			}
		}
	}

	vector<int> maxIndex(N);
	vector<int> result(N);
	for (auto i = 0; i < N; ++i)
	{
		for (auto v : G[i])
		{
			if (maxIndex[v] < index[i])
			{
				maxIndex[v] = index[i];
				result[v] = i + 1;
			}
		}
	}

	for (auto i = 0; i < N; ++i)
	{
		cout << result[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
#include <iostream>

int main () {
  int alice_num, bob_num;
  std::cin >> alice_num >> bob_num;

  if (alice_num == 1) {
    alice_num = 14;
  }
  if (bob_num == 1) {
    bob_num = 14;
  }
  if (alice_num == bob_num) {
    std::cout << "Draw" << std::endl;
  } else if (alice_num > bob_num) {
    std::cout << "Alice" << std::endl;
  } else {
    std::cout << "Bob" << std::endl;
  }
}


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

int main() {
	int N;
	char clr;
	int jg = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {

		cin >> clr;

		if (clr == 'Y') {
			jg += 1;
		}
	}
	if (jg != 0) {
		cout << "Four";
	}
	else {
		cout << "Three";
	}
}


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

class union_find {
	vector<int> data;
public:
	union_find(int n) : data(n, -1) {}
	int find(int x) {
		return data[x] < 0 ? x : data[x] = find(data[x]);
	}
	bool unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return false;
		if (data[a] < data[b]) {
			data[a] += data[b];
			data[b] = a;
		}
		else {
			data[b] += data[a];
			data[a] = b;
		}
		return true;
	}
};

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	auto xs = x;
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	auto ys = y;
	sort(ys.begin(), ys.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	const int n = xs.size(), m = ys.size();
	union_find uf(n + m);
	for (int i = 0; i < N; i++) {
		int tx = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
		int ty = lower_bound(ys.begin(), ys.end(), y[i]) - ys.begin();
		uf.unite(tx, n + ty);
	}
	vector<ll> xcnt(n + m), ycnt(n + m);
	for (int i = 0; i < n + m; i++) {
		++(i < n ? xcnt : ycnt)[uf.find(i)];
	}
	ll res = -N;
	for (int i = 0; i < n + m; i++) if (uf.find(i) == i) {
		res += xcnt[i] * ycnt[i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3712
fun main(args: Array<String>) {
	val s = readLine() ?: return
	val t = readLine() ?: return
	
	println(theNumberOfDifference(s, t))
}

fun theNumberOfDifference(baseString: String, partOfString: String) : Int {

	var difference: Int
	var minDifference = partOfString.length
	
	for (i in 0..(baseString.length - partOfString.length)) {
		difference = 0
		for ((index, char) in partOfString.withIndex()) {
			if (char != baseString[i+index]) {
				difference++
			}
		}
		minDifference = minOf(difference, minDifference)
	}
	
	return minDifference
}

Measured memory_bytes: 36196
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long A[100001];
	long i, j;
	long ans = 0;
	long m = 0;
	
	scanf("%ld", &N);
	for(i=1;i<=N;i++) {
		scanf("%ld", &A[i]);
		ans += (A[i] + m) / 2;
		m = (A[i] + m) % 2;
		if(A[i] == 0) m = 0;
	}
	
	printf("%ld\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

template <typename T>
bool isPrime(T x) {
    if(x==1) return false;
    for(T i = 2; i*i <= x; ++i) {
        if(x%i==0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> s(100010);
    s[0]=0;
    REPP(i,s.size()) {
        s[i] = s[i-1];
        if(i%2==1 && isPrime(i) && isPrime((i+1)/2)) ++s[i];
    }
    int q; cin >> q;
    int ans;
    REP(i,q) {
        int l,r; cin >> l >> r;
        ans = s[r]-s[l-1];
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> s >> t;
	string judge = s + t;
	int num = atoi(judge.c_str());
	for (int i = 1; i < 350;i++) {
		if (num / i == i && num % i == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 500001

//struct Node{
//	int val;
//	Node *p, *l, *r;
//};

struct Node {
	int val;
	Node *p, *l, *r;
	Node(int v) :val(v), p(NULL), l(NULL), r(NULL){}
	Node() :val(0), p(NULL), l(NULL), r(NULL){}
};

Node T[N];
int D[N], H[N];

Node *root;

void insert(int k){
	Node *y = NULL;
	Node *x = root;
	Node *z = new Node(k);

	while (x != NULL && x->val != k){
		y = x;
		if (k > x->val) x = x->r;
		else x = x->l;
	}
	z->p = y;
	if (y == NULL) root = z;
	else{
		if (k < y->val) y->l = z;
		else y->r = z;
	}
}

Node *find(int val){
	Node *p = root;
	while (p != NULL && p->val != val) {
		if (val > p->val) p = p->r;
		else p = p->l;
	}
	return p;
}

void ino(Node *p){
	if (p == NULL) return;
	ino(p->l);
	printf(" %d", p->val);
	ino(p->r);
}

void preo(Node *p){
	if (p == NULL) return;
	printf(" %d", p->val);
	preo(p->l);
	preo(p->r);
}


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

	int val;
	string com;
	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com[0] == 'f'){
			cin >> val;
			Node *p = find(val);
			cout << ((p == NULL) ? "no" : "yes") << endl;
		}
		else if (com[0] == 'i'){
			cin >> val;
			insert(val);
		}
		else if (com[0] == 'p'){
			ino(root); cout << "\n";
			preo(root); cout << "\n";
		}
	}

	return 0;
}

//Yes
//No
//1 12 17 20 25 30 88
//30 12 1 20 17 25 88

Measured memory_bytes: 37560
#include <bits/stdc++.h>
#define ll long long
#define L long
#define endl "\n"
#define set0(x) memset(x, 0, sizeof(x))
#define setT(x) memset(x, true, sizeof(x))
#define setF(x) memset(x, false, sizeof(x))
#define For(i, init, n) for (ll int i = init; i < n; i++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const double PI = acos(-1), E = exp(1.0), EPS = DBL_EPSILON;
const ll int MOD = (ll int)1e9 + 7, N = (int)1e5;

int a[100];

bool canFormTriangle(int x, int y, int z)
{
    int b[3] = {x, y, z};
    sort(b, b + 3);
    return b[0] + b[1] > b[2];
}

int main()
{   
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (a[j] == a[i])
                continue;
            for (int k = j + 1; k < n; k++)
            {
                if (a[k] == a[j] || a[k] == a[i])
                    continue;
                if (canFormTriangle(a[i], a[j], a[k]))
                    cnt++;
            }
        }
    }
    
    cout<< cnt;

    return 0;
}

Measured memory_bytes: 3652
import sys

input = sys.stdin.readline


def main():
    N = list(map(int, input().split()))

    if (1 in N) and (9 in N) and (7 in N) and (4 in N):
        ans = "YES"
    else:
        ans = "NO"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll arr[105],dp[105][100005];
void solve(ll caseno){
	ll i,j,n,k;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>arr[i];
	fo(i,0,k+1) dp[0][i]=1;
	for(i=1;i<=n;i++){
		for(j=0;j<=k;j++){
			ll mn=j-arr[i]-1;
			dp[i][j]=dp[i-1][j];
			if(mn>=0) dp[i][j]-=dp[i-1][mn];
			dp[i][j]=(dp[i][j]+MOD)%MOD;
		}
		if(i==n){
			cout<<dp[n][k]<<endl;
			return;
		}
		for(j=1;j<=k;j++) {
			dp[i][j]+=dp[i][j-1];
			dp[i][j]%=MOD;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int maxN = 1e5+5;
const int mod = 1e9+7;
int arr[maxN];
bool dp[maxN];
int n,k;


void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=1;i<k+1;i++){
        for(int j=0;j<n;j++){
            if(i-arr[j]>=0){
                if(dp[i-arr[j]]==false){
                    dp[i] = true;
                    break;
                }
            }
            else{
                break;
            }
        }
    }
    if(dp[k]==true)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

int main()
{
    FASTIO
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}






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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, K;
  cin >> N >> K;

  ll ans = K;
  
  rep(i, N-1){
    ans *= (K-1);
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    cin >> N;
    vector< vs32 > v(3, vs32(N));
    rep (i, N)
    {
        cin >> v[0][i] >> v[1][i] >> v[2][i];
    }

    int dp[3][100000];
    dp[0][0] = v[0][0];
    dp[1][0] = v[1][0];
    dp[2][0] = v[2][0];

    for (int i = 1; i < N; ++i)
    {
        rep (j, 3)
        {
            dp[j][i] = MAX(dp[(j + 1) % 3][i - 1] + v[j][i], dp[(j + 2) % 3][i - 1] + v[j][i]);
        }
    }

    cout << MAX(dp[0][N - 1], MAX(dp[1][N - 1], dp[2][N - 1])) << "\n";
    return 0;
}



Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
int d[5002];
int main(){
    int k, q;
    scanf("%d%d", &k, &q);
    for(int i=0;i<k;i++) scanf("%d", &d[i]);
    for(int i=0;i<q;i++){
        int n, x, m;
        scanf("%d%d%d", &n, &x, &m);

        long long sum = 0;
        for(int j=0;j<k;j++){
            int d2 = d[j]%m;
            if(d2 == 0) d2 = m;
            sum += d2;
        }
        long long an = x%m;
        an += (n-1)/k*sum;
        for(int j=0;j<(n-1)%k;j++){
            int d2 = d[j]%m;
            if(d2 == 0) d2 = m;
            an += d2;
        }
        printf("%lld\n", n-1-an/m);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> height(N);
    for (int i = 0; i < N; i++) {
      cin >> height.at(i);
    }

    int count = 0;

    for (int i = 0; i < N; i++) {
      if (height.at(i) >= K) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_ll.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bll = mp::cpp_ll; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bll>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define size(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

map<ll,ll> ma;
vector<ll> v(0);

signed main(){
    ll n,m,x=0,ans=0;
    cin>>n>>m;
    ma.emplace(0,1);
    v.pb(x);
    for(ll i=0;i < n;i++)
    {
        ll in;cin>>in;
        x+=in;x%=m;

        if(!ma.count(x)){
            ma.emplace(x,1);
            v.pb(x);
        }else{
            ma.at(x)++;
        }

    }

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

    for(auto& i : v){
        ll y=ma.at(i);//iはv.at(i)
        ans+=y*(y-1)/2;
    }

    cout << ans << endl;
}
/* */

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;

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

  int n; cin >> n;
  string s1,s2; cin >> s1 >> s2;

  vector<int> dp(n+1);
  dp[0] = 1;
  if(s1[0] == s2[0]) dp[1] = 3;
  else dp[1] = 6;
  for(int i = 1; i < n; i++){
    if(s1[i-1] == s1[i] && s2[i-1] == s2[i]){
      dp[i+1] = dp[i];
      continue;
    }
    if(s1[i-1] == s2[i-1]){
      //X->X
      if(s1[i] == s2[i]){
        dp[i+1] = dp[i] * 2;
      }
      //X->Y
      else {
        dp[i+1] = dp[i] * 2;
      }
    }
    else{
      //Y->X
      if(s1[i] == s2[i]){
        dp[i+1] = dp[i];
      }
      //Y->Y
      else {
        dp[i+1] = dp[i] * 3;
      }
    }
    dp[i] %= MOD;
  }
  cout << dp[n]%MOD << endl;

  return 0;
}


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

typedef struct UnionFind{
  int *parent;
  int n;
} UnionFind;

UnionFind* newUnionFind(int n){
  UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
  u->parent=(int *)calloc(n,sizeof(int));
  u->n=n;
  for(int i=0;i<n;i++) u->parent[i]=-1;
  return u;
}

int root(UnionFind *u,int x){
  if(u->parent[x]<0) return x;
  return u->parent[x]=root(u,u->parent[x]);
}

int same(UnionFind *u,int x,int y){
  return root(u,x)==root(u,y);
}

int getSize(UnionFind *u,int x){
  return -u->parent[root(u,x)];
}

void unite(UnionFind *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  if(u->parent[x]>u->parent[y]){
    int swap=x;
    x=y;
    y=swap;
  }
  u->parent[x]+=u->parent[y];
  u->parent[y]=x;
}

typedef long long int int64;

typedef struct weightEdge{
  int a,b;
  int64 c;
} edge;

int cmpEdge(const void *a,const void *b){
  int64 p=((edge *)a)->c;
  int64 q=((edge *)b)->c;
  return p==q?0:p<q?1:-1;
}

void run(void){
  int n;
  scanf("%d",&n);
  edge *e=(edge *)calloc(n-1,sizeof(edge));
  int i;
  for(i=0;i<n-1;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a--;b--;
    e[i]=(edge){a,b,c};
  }
  qsort(e,n-1,sizeof(edge),cmpEdge);
  int *r=(int *)calloc(n,sizeof(int));
  for(i=0;i<n;i++) r[i]=i;
  edge *binaryTreeEdge=(edge *)calloc(2*n,sizeof(edge));
  int len=0;
  UnionFind *u=newUnionFind(n);
  for(i=0;i<n-1;i++){
    int a=e[i].a;
    int b=e[i].b;
    int64 c=e[i].c;
    int64 sa=getSize(u,a);
    int64 sb=getSize(u,b);
    binaryTreeEdge[len++]=(edge){n+i,r[root(u,a)],sb*c};
    binaryTreeEdge[len++]=(edge){n+i,r[root(u,b)],sa*c};
    unite(u,a,b);
    r[root(u,a)]=n+i;
  }
  int64 *dp=(int64 *)calloc(2*n,sizeof(int64));
  for(i=len-1;i>=0;i--){
    int from=binaryTreeEdge[i].a;
    int to=binaryTreeEdge[i].b;
    int64 weight=binaryTreeEdge[i].c;
    dp[to]=dp[from]+weight;
  }
  for(i=0;i<n;i++) printf("%lld\n",dp[i]);
}

int main(void){
  run();
  return 0;
}


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

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

    if (n == k) cout << "0";
    else if (n > k) cout << min(n % k, abs((n%k)-k));
    else cout << min(n, abs(n-k));
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int saitan(int x,int y,int z){
	int sum=0,tmp=0;
	tmp=y-x;
	if(tmp<0)tmp*=-1;
	sum=tmp;
	tmp=z-y;
	if(tmp<0)tmp*=-1;
	sum+=tmp;
	return sum;

}

int main(){
	int x,y,z,w=1000;
	int i=0;
	int val[6];
	scanf("%d %d %d",&x,&y,&z);
	val[0]=saitan(x,y,z);
	val[1]=saitan(x,z,y);
	val[2]=saitan(y,x,z);
	val[3]=saitan(y,z,x);
	val[4]=saitan(z,x,y);
	val[5]=saitan(z,y,x);
	for (i=0;i<6;i++){
		if(w>=val[i])w=val[i];
	}
	printf("%d",w);
	return 0;

}

Measured memory_bytes: 128
s=gets.chomp
n=s.size
a=(n-1)/2
b=(n+3)/2
i=1
if s==s.reverse
  if s[0..a-1]==s[0..a-1].reverse
  	if s[(b-1)..(n-1)] == s[(b-1)..(n-1)].reverse
    	puts "Yes"
        i=0
  	end
  end
end

if i==1
  puts "No"
end


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

int main(){
  int i,j,n,m[100],a[100],b[100];
  bool ans;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++) cin >> m[i] >> a[i] >> b[i];

    ans = false;
    for(i=0;i<n;i++){
      int c = m[i];
      for(j=0;j<n;j++){
	if(i == j) continue;
	if(a[j] <= a[i] && a[i] < b[j]) c += m[j];
      }
      if(c > 150){
	ans = true;
	break;
      }
    }

    if(ans) cout << "NG" << endl;
    else cout << "OK" << endl;

  }
  return 0;
}

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


int main(){
    int n; cin >> n;
    vector<string> s(n+1,"zzzzzzzzzz");
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
   
    vector<pair<string,int>> p(n);
    int cnt = 1;
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            cnt++;
        }else{
            p[i].first = s[i];
            p[i].second = cnt;
            cnt = 1; //reset
        }
    }
    int maxps = 0;
    for(int i=0;i<n;i++){
        maxps = max(p[i].second,maxps);
    }
    for(int i=0;i<n;i++){
        if(p[i].second == maxps){
            cout << p[i].first << endl;
        }
    }
}

Measured memory_bytes: 17408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 20, M = (1 << 16) + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, m, S, a[N], inv[M], fac[M], dp[N][M];
int ksm(int x, int y) {
	int res = 1;
	for( ; y; x = x * x % mod, y >>= 1) {
		if(y & 1) res = res * x % mod;
	}
	return res;
}
void init(int n) {
	fac[0] = 1;
	for(int i = 1; i <= n; ++ i) fac[i] = fac[i - 1] * i % mod;
	inv[n] = ksm(fac[n], mod - 2);
	for(int i = n - 1; ~i; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;
}
bool cmp(int x, int y) {return x > y;}
int C(int n, int m) {return n < m ? 0 : fac[n] * inv[m] % mod * inv[n - m] % mod;}
signed main() {
	n = read(); m = read(); init(1 << n);
	for(int i = 1; i <= m; ++ i) a[i] = read();
	sort(a + 1, a + m + 1, cmp);
	S = (1 << n) - 1; dp[0][0] = 1;
	for(int i = 0; i < m; ++ i) {
		for(int s = 0; s <= S; ++ s) {
			int les = S + 1 - a[i + 1] - s;
			dp[i + 1][s] = (dp[i + 1][s] + dp[i][s]) % mod;
			for(int j = 0; j < n; ++ j) if(((s >> j) & 1) == 0) {
				(dp[i + 1][s | (1 << j)] += dp[i][s] * C(les, (1 << j) - 1) % mod * fac[1 << j] % mod) %= mod;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= S; ++ i) {
		int cnt = 0, s = i;
		while(s) ++ cnt, s -= s & (-s);
		if(cnt & 1) (ans += mod - dp[m][i] * fac[S - i] % mod) %= mod;
		else (ans += dp[m][i] * fac[S - i]) %= mod;
	}
	ans = ans * (S + 1) % mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef vector< PII > VPII;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 998244353;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

struct OP{
	int B, C;
	
	bool operator< (const OP &x) const{
		if(C == x.C) return B > x.B;
		return C > x.C;
	}
};

int N, M;
int A[maxN];
OP op[maxN];
LL ans;


int main(){
	INIT(); 
	cin >> N >> M;
	Rep(i, N) cin >> A[i];
	sort(A, A + N);
	Rep(i, M) cin >> op[i].B >> op[i].C;
	sort(op, op + M);
	
	int j = 0;
	Rep(i, M) {
		while(j < N && op[i].B) {
			if(A[j] < op[i].C) {
				ans += op[i].C;
				++j;
				--op[i].B;
			}
			else {
				i = M;
				break;
			}
		}
	}
	
	For(i, j, N - 1) ans += A[i];
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
int n, i, m, min, max;
long long sum = 0;
scanf("%d", &n);
min = 1000001;
max = -1000001;
for (i=1; i<n+1; i++){
scanf("%lld", &m);
if (m > max ) {max =m;}
if (m < min ) {min = m;}
sum =sum + m;
}
printf("%d %d %lld\n", min, max, sum);
return 0;
}





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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    vector<int> wyst(26, 0);
    for (int i = 0; i < nap.size(); ++i)
        ++wyst[nap[i] - 'a'];
    bool db = true;
    for (int i = 0; i < 26; ++i)
        if (wyst[i] % 2 == 1)
            db = false;
    if (db)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
using namespace std;
using ll = long long;

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

bool solve(ll a, ll b, ll c, ll d) {
  if (a < b) {
    return false;
  }
  if (b > d) {
    return false;
  }
  if (b <= c) {
    return true;
  }
  ll g = gcd(b, d);
  if (b - g + a % g > c) {
    return false;
  }
  return true;
}

bool solve2(ll a, ll b, ll c, ll d) {
  if (a < b) {
    return false;
  }
  if (b > d) {
    return false;
  }
  if (b <= c + 1) {
    return true;
  }
  if (b == d) {
    if (a - b * (a / b) < c) {
      return true;
    } else {
      return false;
    }
  }
  if (a % b > c) {
    return false;
  }
  ll t = gcd(d - b, b);
  ll s = a - t * (a / t);
  ll x = s + t * ((c + t - s) / t);
  if (x < b) {
    return false;
  }
  return true;
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (solve2(a, b, c, d)) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A,B,K = list(map(int, input().rstrip().split()))
#-----

divisor_list=[]
for i in range(1,min(A,B)+1):
    if A%i == 0 and B%i == 0:
        divisor_list.append(i)

print(divisor_list[-K])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a1,a2,a3; cin>>a1>>a2>>a3;
	cout<<(a1+a2+a3>21 ? "bust" : "win")<<endl;	
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    map<int,int> m;
    for (int j = N; j >= 1; j--){
        if (j == 1) continue;
        else{
            int k = j;
            for (int i = 2; i <= 1000; i++){
                while (k % i == 0){
                    if (!m.count(i)) m[i] = 1;
                    else m.at(i)++;
                    k /= i;
                }
            }
            
        }
        
    }
    int64_t ans = 1;
    for (auto x : m){
        auto value = x.second;
        ans *= (value + 1);
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while 1:
    N = int(input())
    if N == 0:
        break
    y = int(input())
    v = 0; k = None
    for i in range(N):
        b, r, t = map(int, input().split())
        if t == 1:
            w = 1 + y * r /100
        else:
            w = (1 + r / 100) ** y
        if v < w:
            v = w
            k = b
    print(k)


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

int main() {
    int N; cin >> N;
    string S; cin >> S;

    if (N % 2 != 0)
    {
        cout << "No" << endl;
    }
    else {
        string S1 = "", S2 = "";
        for (int i = 0; i < N/2; i++)
        {
            S1 += S[i];
        }
        for (int i = N/2; i < N; i++)
        {
            S2 += S[i];
        }

        if (S1 == S2)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
        
                }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; ll b; ll c; ll d; cin >> a >> b >> c >> d;
    if ((a+d-1)/d < (c+b-1)/b){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = c-(a-b);
    if (ans > 0) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3512
n,k = gets.chomp.split.map(&:to_i)
s = gets.chomp.chars
count_l = 0
count_r = 0
s.each do|c|
  if c == "L"
    count_l += 1
  else
    count_r += 1
  end
end

current = s.shift
sum = 0

s.each do |c|
  if current == "L" && c == "L"
    sum += 1
  elsif current == "R" && c == "R"
    sum += 1
  end
  current = c
end
puts [sum + 2*k , n-1].min

Measured memory_bytes: 9468
bill=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]

n=int(input())
for i in range(n):
  b,f,r,v=map(int,input().split())
  bill[b-1][f-1][r-1]+=v

for i in range(4):
  for j in range(3):
    for k in range(10):
      if k!=9:
        print("",bill[i][j][k],end="")
      else:
        print("",bill[i][j][k])
  if i!=3:
     print("#"*20)


Measured memory_bytes: 5636
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define int long long
using namespace std;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-max(max(a,b),c)<<endl;
    return 0;
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// // Declaring ordered_set
// typedef tree<ll, null_type, less<ll>, rb_tree_tag,
//             tree_order_statistics_node_update>
//    ordered_set;

#define _start_ auto __start__ = high_resolution_clock::now();
#define _stop_ cerr << "\n" \
                    << duration_cast<microseconds>(high_resolution_clock::now() - __start__).count() / (double)1000000 << " sec\n";
#define mod 998244353
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define ideb \
    int _p_; \
    cin >> _p_;
typedef long long int ll;
typedef unsigned long long int ull;
long long power(long long x, long long n)
{
    long long result = 1;
    while (n > 0)
    {
        if (n % 2 == 1)
            result = (result % mod * x % mod) % mod;
        x = (x % mod * x % mod) % mod;
        n = n / 2;
    }
    return result % mod;
}

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

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

    int dp[n + 1];
    for (int i = 0; i <= n; i++)
        dp[i] = INT_MAX;
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++)
    {
        for (int j = 1; j <= min(k, i - 1); j++)
        {
            dp[i] = min(abs(a[i] - a[i - j]) + dp[i - j], dp[i]);
        }
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $b = explode(" ", trim(fgets(STDIN)));
  $a=[];
  for($i=0;$i<$n;$i++){
    $a[$b[$i]]=true;
  }

  if(count($a)==4) echo "Four";
  else echo "Three";
  echo PHP_EOL;
  

Measured memory_bytes: 15544
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=5e5+50;

int n,a[N]; 
long long ans;

int main(int argc,char *argv[]){
#ifdef DCURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	read(n); 
	rep(i,1,3*n)read(a[i]); 
	sort(a+1,a+n*3+1); 
	int p=n*3;
	rep(i,1,n){
		ans+=a[p-1],p-=2;
	}
	printf("%lld\n",ans); 
	return 0;
}

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

int wh[100001] = {};

int main(void) {
	int w, h, n;
	cin >> w >> h >> n;
	int at_most_w=0,at_most_h=0;
	for (int i = 0; i<n; i++) {
		int x, y; 
		scanf("%d%d",&x,&y);
		wh[y] = max(wh[y], x);
		at_most_w=max(x,at_most_w);at_most_h=max(y,at_most_h);
	}
	
	int x_position, y_position, MIN;
    MIN = wh[h - 1] + (h - 1);
    x_position = wh[h - 1];
    y_position = h - 1;
	
	for (int i = 0; i<h - 1; i++) {
		y_position--;
		int a = x_position, b = y_position;
		MIN = min(MIN, a+b);
		
		if (a < wh[b]) {
			x_position = wh[y_position];
			int a = x_position, b = y_position;
			
			MIN = min(MIN, a+b);
		}
	}
		
	cout << min(MIN,min(at_most_w,at_most_h)) << endl;

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    string s;
    cin >> s;
    rep(i, 0, 3) cout << s[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

ll GCD(ll a,ll b,ll c){
	return gcd(c,gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
	int k;
	cin >> k;
	ll ans=0;
	for(ll a=1;a<=k;a++){
		for(ll b=1;b<=k;b++){
			for(ll c=1;c<=k;c++){
				ans+=GCD(a,b,c);
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll> arr(n),rightMax(n);
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    rightMax[n-1]=arr[n-1];
    for(int i=n-2;i>=0;i--){
        rightMax[i]=max(rightMax[i+1],arr[i]);
    }
    vector<ll> ans;
    //cout<<"fknskznb"<<endl;
    for(int i=0;i<n;i++){
        ans.push_back(rightMax[i]-arr[i]);
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    int cnt=1;
    for(int i=1;i<n;i++){
        if(ans[0]==ans[i]) cnt++;
    }
    cout<<cnt;
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    map<char, Int> mp;
    cin >> n;
    for (Int i = 0; i < n; i++) {
        char c;
        cin >> c;
        mp[c]++;
    }
    dump(mp.size() == 3 ? "Three" : "Four");
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

k = list(map(int, input().split()))[0]

if (k % 7 == 0):
    l = 9*k/7
else:
    l = 9*k
dprint('k, l = ', k, l)

i = 1
n = 10
while(i < 10**6):
    m = n % l
    if (m == 1): # (10^i mod L = 1)
        print(i)
        exit()
    dprint('i, n, m = ', i, n, m)

    i = i + 1
    n = m * 10
else:
    print(-1)


Measured memory_bytes: 9140
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll h;
	cin>>h;
	ll sum=0,n=0;
	while(h!=1){
	    sum+=pow(2,n);
	    n++;
	    h/=2;
	}
	sum+=pow(2,n);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

const int MAX_V=200000;
const ll INF=pow(10,17);
int V;
struct edge{int to,cost;};//Dijkstra
vector<edge> G[MAX_V];
bool used[MAX_V];
ll d[MAX_V];
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+V+1,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
void solve(){
    cin>>V;
    int from;
    fol(i,V-1){
        edge t;
        cin >> from>>t.to>>t.cost;
        G[from].pb(t);
        swap(from,t.to);
        G[from].pb(t);
    }
    int q,k;
    cin>>q>>k;
    dijkstra(k);
    int x,y;
    fol(i,q){
        cin>>x>>y;
        cout <<d[x]+d[y]<<endl;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 11764
#include<iostream>
#include<cctype>
#include<string>

std::string toUpper(std::string s){
	std::string t = s;
	for(int i=0; i < t.size(); i++){
		t[i] = toupper(s[i]);
	}
	return t;
}

std::string clearSt(std::string s){
	int counter = 0;
	std::string cleared = s;
	for(int i = 0; i< s.size(); i++){
		if (isalpha(s[i])){
			cleared[counter] = s[i];
			counter +=1;
		}
	}
	cleared = cleared.substr(0, counter);
	return cleared;
}

int main(void){
	
	std::string W, st;
	int count = 0;
	
	std::cin >> W;
	W = toUpper(W);
	//std::cout  << W << std::endl;
	
	while(1){
		std::cin >> st;
		if(st == "END_OF_TEXT") break;
		st = toUpper(st);
		st = clearSt(st);
		//std::cout << st << std::endl;
		if(st == W) count += 1;
		//std::cout << "count is "  << count << std::endl;
	}
	
	std::cout << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 500100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
}


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


    

    
    return 0;
}

Measured memory_bytes: 256