akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
d = LIST()
a = 0

c = list(combinations(d, 2))
# print(c)
for l in c:
  a += l[0] * l[1]
print(a)

Measured memory_bytes: 5768
#include <stdio.h>
#include <limits.h>


int main(void){
    // Your code here!
    long N,X;
    long sou[51], patty[51],ans = 0;
    scanf("%ld %ld",&N,&X);
    sou[0] = 1;
    patty[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        sou[i] = sou[i-1]*2 + 3;
        patty[i] = patty[i-1]*2 + 1;
        //printf("sou[%d]=%ld\n",sou[i]);
        //printf("patty[%d]=%ld\n",patty[i]);
    }
    /*
    for(int i = 0; i <= N; i++)
    {
        printf("(%d): sou: %ld, patty: %ld\n",i,sou[i],patty[i]);
    }
    */
    int flag = 0; int i = 0;
    for(i = N; i >= 0 && flag == 0; i--)
    {
        //printf("i: %d\n",i);
        if(X==1)
        {
            flag = 1;
            if(i == 0)
                ans += 1;
            else
                ans += 0;
        }
        else if(1<X && X<sou[i]/2+1)
        {
            X -= 1;
        }
        else if(X == sou[i]/2+1)
        {
            ans += patty[i-1] + 1;
            flag = 1;
        }
        else if(sou[i]/2+1 < X && X < sou[i])
        {
            X -= sou[i]/2+1;
            ans += patty[i-1] + 1;
        }
        else if(X == sou[i])
        {
            flag = 1;
            ans += patty[i];
        }
        //printf("X = %ld\n",X);
        //printf("patty = %ld\n",ans);
    }
    printf("%ld\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template<int M>
struct ModInt {
public:
	using value_type = long long;
	
	ModInt(value_type val = 0) : val(val < 0 ? (M - (-val % M)) % M : val % M) {}
	
	explicit operator bool() const noexcept { return val; }
	bool operator ==(const ModInt & rhs) const noexcept { return val == rhs.val; }
	bool operator !=(const ModInt & rhs) const noexcept { return !(*this == rhs); }
	ModInt operator +() const noexcept { return ModInt(*this); }
	ModInt operator -() const noexcept { return ModInt(0) -= *this; }
	ModInt operator +(const ModInt & rhs) const noexcept { return ModInt(*this) += rhs; }
	ModInt operator -(const ModInt & rhs) const noexcept { return ModInt(*this) -= rhs; }
	ModInt operator *(const ModInt & rhs) const noexcept { return ModInt(*this) *= rhs; }
	ModInt operator /(const ModInt & rhs) const noexcept { return ModInt(*this) /= rhs; }
	
	ModInt & operator +=(const ModInt & rhs) noexcept {
		val += rhs.val;
		if (val >= M) val -= M;
		return *this;
	}
	ModInt & operator -=(const ModInt & rhs) noexcept {
		if (val < rhs.val) val += M;
		val -= rhs.val;
		return *this;
	}
	ModInt & operator *=(const ModInt & rhs) noexcept {
		val = val * rhs.val % M;
		return *this;
	}
	ModInt & operator /=(const ModInt & rhs) noexcept {
		*this *= rhs.inverse();
		return *this;
	}
	
	ModInt pow(value_type n) const {
		ModInt res = 1, x = val;
		if (n < 0) { x = x.inverse(); n = -n; }
		while (n) { if (n & 1) res *= x; x *= x; n >>= 1; }
		return res;
	}
	
	ModInt inverse() const {
		long long a = val, a1 = 1, a2 = 0, b = M, b1 = 0, b2 = 1;
		while (b > 0) {
			value_type q = a / b, r = a % b;
			value_type nb1 = a1 - q * b1, nb2 = a2 - q * b2;
			a = b; b = r;
			a1 = b1; b1 = nb1;
			a2 = b2; b2 = nb2;
		}
		assert(a == 1);
		return a1;
	}
	
	const value_type & get() const noexcept { return val; }
	static decltype(M) get_mod() noexcept { return M; }
	
	friend std::ostream & operator <<(std::ostream & os, const ModInt & rhs) { return os << rhs.val; }
	friend std::istream & operator >>(std::istream & is, ModInt & rhs) {
		value_type x;
		is >> x;
		rhs = ModInt(x);
		return is;
	}
private:
	value_type val;
};
using mint = ModInt<MOD>;

int main() {
	int S;
	cin >> S;
	
	vector<mint> dp(S + 1), ndp;
	dp[0] = 1;
	
	mint ans = 0;
	while (true) {
		bool update = false;
		ndp.assign(S + 1, 0);
		
		REP(i, S) dp[i + 1] += dp[i];
		FOR(i, 3, S + 1) {
			if (dp[i - 3] != 0) update = true;
			ndp[i] = dp[i - 3];
		}
		
		swap(dp, ndp);
		ans += dp[S];
		if (!update) break;
	}
	cout << ans << endl;
	return 0;
}


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

string s;
int N;
ll m,a,r,c,h;
ll D[5];
int P[10]={0,0,0,0,0,0,1,1,1,2}; 
int Q[10]={1,1,1,2,2,3,2,2,3,3}; 
int R[10]={2,3,4,3,4,4,3,4,4,4}; 

int main (){
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> s;
    if(s[0]=='M'){
      m++; 
    }
    if(s[0]=='A'){
      a++; 
    }
    if(s[0]=='R'){
      r++; 
    }
    if(s[0]=='C'){
      c++;
    }
    if(s[0]=='H'){
      h++;
    }
  }
  
  D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h; 
  ll res = 0;
  
  for(int d = 0; d < 10; d++){
    res += D[P[d]] * D[Q[d]] * D[R[d]]; 
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

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

	cout << (n - 2) * 180 << endl;
    
    return 0;
}


Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#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) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}
constexpr int MOD = 998244353;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> d(n),vec(n+1);
	int maxv = 0;
	rep(i,n){
		cin >> d[i];
		++vec[d[i]];
		chmax(maxv,d[i]);
		if(i == 0 && d[i] != 0){
			cout << 0 << '\n';
			return 0;
		}
	}
	if(vec[0] == 0 || vec[0] > 1){
		cout << 0 << '\n';
		return 0;
	}
	rep(i,maxv){
		if(vec[i] == 0){
			cout << 0 << '\n';
			return 0;
		}
	}
	int ans = 1;
	rep(i,maxv+1){
		int x = 1;
		rep(j,vec[i+1]){
			(x *= vec[i]) %= MOD;
		}
		(ans *= x) %= MOD;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {
    int n,K;
    cin>>n>>K;
    
    vi x(n);
    vi y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll ans=LLINF;
    for(int i=0;i<n;i++){//上
        for(int j=0;j<n;j++){//した
            for(int k=0;k<n;k++){//右
                for(int l=0;l<n;l++){//左
                    if(y[i]<y[j]||x[k]<x[l])continue;
                    // cout<<i<<j<<k<<l<<endl;;
                    int co=0;
                    for(int m=0;m<n;m++){
                        if(x[m]<=x[k]&&x[m]>=x[l]&&y[m]<=y[i]&&y[m]>=y[j]){
                            co++;
                        }
                    }
                    if(co>=K){
                        ans=min(ans,(ll)(x[k]-x[l])*(y[i]-y[j]));
                    }
                }
            }
        }
    }
    fin(ans);


}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

int main() {
    int n, w;
    cin >> n >> w;
    int weight[n] = {0};
    int value[n] = {0};
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }

    vector<vector<ll>> dp(
        n,
        vector<ll>(100001, INF));  // n個目までの荷物で価値v以上となる最小重量

    // 価値0以上は何も入れない
    dp[0][0] = 0;

    // 価値1以上で1個目の荷物を入れるかどうか
    for (int j = 1; j < 100001; j++) {
        if (j <= value[0]) {
            dp[0][j] = weight[0];
        }
    }

    // 2~n個目の荷物を入れるかどうか
    for (int i = 1; i < n; i++) {           // 荷物
        for (int j = 0; j < 100001; j++) {  // 価値
            // i個目の荷物を入れるとき
            if (j - value[i] >= 0) {
                dp[i][j] =
                    min(dp[i - 1][j], dp[i - 1][j - value[i]] + weight[i]);
            }
            // 入れないとき
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }

    // n個目までの荷物で重さw以下となるときの最大価値
    ll ans = 0;
    for (int i = 0; i < 100001; i++) {
        if (dp[n - 1][i] <= w) ans = i;
    }

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

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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int x = 0;
  for(int i = 0; i < 3; ++i) {
    int z;
    cin >> z;
    x = x*10 + z;
  }

  cout << (x % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
  long long a;
  cin>>a;
  vector<long long> vec(a-1);
  vector<long long> mp(a,0);
  rep(i,a-1){
      cin>>vec.at(i);
      mp.at(vec.at(i)-1)++;
  }
  rep(i,a){
      cout<<mp.at(i)<<endl;
  }
  

}



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

int main(void){
    int H1,H2,M1,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int start = H1 * 60 + M1;
    int end = H2 * 60 + M2;
    cout << end-start-K << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
const int MOD1 = 998244353;
ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main() {
  int n;
  cin >> n;
  vector<ll>a(n+1);
  vector<ll>b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll sum=0;
  rep(i,n){
    if(a[i]>=b[i])sum+=b[i];
    else{
      sum+=a[i];
      b[i]-=a[i];
      if(a[i+1]>=b[i]){
        sum+=b[i];
        a[i+1]-=b[i];
      }
      else{
        sum+=a[i+1];
        a[i+1]=0;
      }
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 1792
// A - Don't be late
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    double d, t, s;
    cin >> d >> t >> s;
    if(d/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	t := 753

	dif := 10000000000
	for i := 0; i < len(s)-2; i++ {
		now := int(s[i]-'0')*100 + int(s[i+1]-'0')*10 + int(s[i+2]-'0')

		if abs(dif-t) > abs(now-t) {
			dif = now
		}
	}

	fmt.Println(abs(dif - t))

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	string s;
	cin >> s;
	
	ll dp[100005][13];
	for(int i = 0; i < 13; ++i) dp[0][i] = 0;
	dp[0][0] = 1;

	int len = s.length();
	for(int i = 0; i < len; ++i)
	{
		for(int j = 0; j < 13; ++j) dp[i + 1][j] = 0;

		int num = ((s[i] == '?') ? -1 : s[i] - '0');
		for(int j = 0; j < 10; ++j)
		{
			// num が数字の時はその数のみ、? のときは0~9について計算
			if (num != -1 && num != j) continue;
			for(int k = 0; k < 13; ++k)
			{
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		for (int j = 0; j < 13; ++j)
		{
			dp[i + 1][j] %= MOD;
		}
	}
	cout << dp[len][5];

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

vector<ll> dp(2e5+1);
vector<ll> r(3e5+1);
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N;
    cin >> N ;
    vector<ll> a(3*N);
    rep(i,3*N)cin >> a[i];
    priority_queue<int, vector<int>, greater<int> > queue;
    for(int i=0;i<N;i++){
        queue.push(a[i]);
        if(i==0)dp[i] = a[i];
        else dp[i] = dp[i-1] + a[i];
    }
    for(int i=N;i<N+N;i++){
        queue.push(a[i]);
        dp[i] = dp[i-1] + a[i] - queue.top();
        queue.pop();
    }
    //cout << dp[5] << endl;
    priority_queue <int> q;
    for(int i=3*N-1;i>=2*N;i--){
        q.push(a[i]);
        r[i] = r[i+1] + a[i];
    }
    for(int i=2*N-1;i>=N;i--){
        q.push(a[i]);
        r[i] = r[i+1] + a[i] - q.top();;
        q.pop();
    }
    ll ans = -1e18;
    for(int i=N-1;i<2*N;i++){
        ans = max(ans,dp[i] - r[i+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7672
#include <iostream>
#include <algorithm>

using namespace std;

int digits(long long n)
{
	if (n == 0) {
		return 0;
	}
	else {
		return 1 + digits(n / 10);
	}
}

int main()
{
	long long N;
	cin >> N;
	int ans = 100;
	for (long long A = 1; A * A <= N; ++A) {
		if (N % A == 0) {
			long long B = N / A;
			int tmp = max(digits(A), digits(B));
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    int p = 0, w = 0, g = 0, y = 0;
    for (int i = 0; i < n; i++) {
        string a;
        cin >> a;
        if (a == "P") {
            p++;
        }else if (a == "W") {
            w++; 
        }else if (a == "G") {
            g++;
        }else if (a == "Y") {
            y++;
        }
    }
    if (p >= 1 && w >= 1 && g >= 1 && y >= 1) {
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }
    }

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

int main(){
    string s; cin >> s;
    ll ans = 0;
    int b = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'B') b++;
        else{
            ans += b;
        }
    }
    put(ans);
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int n,a,b,i,j,k,s=0;
    scanf("%d%d%d",&n,&a,&b);
    for(i=0;i<=n;i++){
        j=i;
        k=0;
        while(j/10!=0){
            k+=j%10;
            j=j/10;
        }
        k+=j;
        if((k>=a)&&(k<=b))
            s+=i;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    vector<int> b;
    for (int i = N - 1; i >= 0; i -= 2)
        b.push_back(a[i]);
    for (int i = (N % 2 != 0); i < N; i += 2)
        b.push_back(a[i]);

    for (int i = 0; i < N; ++i) {
        if (i > 0)
            cout << ' ';
        cout << b[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b, c, d; string s;
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	s = "#" + s;
	for (int i = a + 1; i < c + 1; ++i) {
		if (s[i] == '#' && s[i] == s[i + 1]) {
			puts("No");
			return 0;
		}
	}
	for (int i = b + 1; i < d + 1; ++i) {
		if (s[i] == '#' && s[i] == s[i + 1]) {
			puts("No");
			return 0;
		}
	}
	if (c < d) {
		puts("Yes");
	}
	else {
		bool elf = false;
		for (int i = b; i < d + 1; ++i) {
			if (s.substr(i, 3) == "...") elf = true;
		}
		puts(elf ? "Yes" : "No");
	}


	return 0;
}

Measured memory_bytes: 720
#include <iostream>

int main() {
  // n is an integer between 1 and 10,000 (inclusive)
  // n is the length of 'true' elements of array a[10'000]
  int n, a[10'000], sum;
  std::cin >> n;

  sum = 0;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      sum += 1;
    }
  }
  std::cout << sum;
  return 0;
}


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

typedef long long ll;
const int N = 3005;
int n;
ll a[N], f[N][N];

ll dp(int l, int r){
    if (l > r) return 0;
    if (f[l][r]) return f[l][r];
    return (f[l][r] = max(a[l] + min(dp(l+1,r-1), dp(l+2,r)),
                          a[r] + min(dp(l+1,r-1), dp(l,r-2))));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
  //  freopen("Deque.inp", "r", stdin);
  //  freopen("Deque.out", "w", stdout);
    cin >> n;
    ll sum = 0;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    ll x = dp(1,n);
    ll y = sum - x;
    cout <<x - y;
}


Measured memory_bytes: 70144
def can_vote(A, m):
    if m == 1:
        return True
    A.sort()
    total = sum(A)
    tt = total * (1/(4*m))
    
    counter = 0

    for i in range(len(A)-1, -1, -1):
        if A[i] >= tt:
            counter += 1
        else:
            break
    if counter >= m:
        return True
    else:
        return False

n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
if can_vote(A, m):
    print("Yes")
else:
    print("No")

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

using namespace std;using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< pair< int, int > > e(N);
  for(auto &p : e) cin >> p.second >> p.first;
  sort(begin(e), end(e));
  int64 now = 0;
  for(int i = 0; i < N; i++) {
    now += e[i].second;
    if(now > e[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}




Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int cost = 0;
    int m = 0;
    int p = 0;
    for(int i = 0; i < n; i++){
        cin >> p;
        cost += p;
        m = max(m, p);
    }
    cost -= m / 2;
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
n, d = gets.chomp.split(' ').map(&:to_i)
list = []
count = 0

n.times do
  list << gets.chomp.split(' ').map(&:to_i)
end

(n-1).times do |i|
  pop = list[i]
  (i..(n-1)).each do |j|
    pop2 = list[j]
    sum = 0
    d.times do |k|
      sum += ((pop[k] - pop2[k]) ** 2)
    end
	sum = (sum**(1/2.0))
	if sum.to_i.to_f == sum && sum.to_i >= 1
      count += 1
    end
  end
end

print count

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

int m;
int a[30];
bool rec(int i,int j){
    if(j==0) return true;
    if(i==m||j<0)return false;
    return rec(i+1,j)||rec(i+1,j-a[i]);
}

int main(){
    int n;
    cin>>m;
    rep(i,m)cin>>a[i];
    cin>>n;
    vector<int> b(n);
    rep(i,n)cin>>b.at(i);
    
    rep(j,n)cout<<(rec(0,b.at(j))?"yes":"no")<<endl;    
}



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

int main(){
    string s;
    cin >> s;
    int a[4],n=stoi(s);
    for(int i=3;i>=0;i--){
        a[i] = n%10;
        n = n/10;
    }

    string op[3];
    for(int i=0;i < (1 << 3);i++){
        int ans=a[0];
        for(int j=0;j<3;j++){
            if((i>>j)%2==0){
                op[j] = "+";
                ans += a[j+1];
            }
            else{
                op[j] = "-";
                ans -= a[j+1];
            }        
        }


        if(ans == 7){
            string eq=s.substr(0,1);
            for(int i=1;i<4;i++){
                eq = eq+op[i-1]+s.substr(i,1);
            }
            eq += "=7";
            cout << eq << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    sort(a, a + n);
    reverse(a, a + n);

    double r, r_thresh;
    r = double(a[m - 1]) / accumulate(a, a + n, 0LL);
    r_thresh = 1.0 / 4.0 / m;

    // printf("%f, %f\n", r, r_thresh);

    if(r < r_thresh){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m,k;cin >> n >> m >> k;
    vi ruia(n+1),ruib(m+1);
    ruia[0]=0,ruib[0]=0;
    rep(i, n) {
        int a;cin >> a;
        ruia[i+1]=a+ruia[i];
    }
    rep(i, m) {
        int b;cin >> b;
        ruib[i+1]=b+ruib[i];
    }
    int ma = -1;
    rep(i, n+1) {
        if(ruia[i]>k)break;
        int count=i+(upper_bound(all(ruib),k-ruia[i]))-ruib.begin()-1;
        chmax(ma,count);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 6484
while True:
    a,b=map(int,input().split())
    if a==b==0:
        break
    else:
        if a>=b:
            x=a
            y=b
        else:
            x=b
            y=a
        
        s=0
        while True:
            x=x%y
            x,y=y,x
            
            s+=1
            if y==0:
                break
        print(x,s)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
	int N, a;
	cin >> N;
	priority_queue<int> pq;
	rep(i, N){
		cin >> a;
		pq.push(a);
	}
	int x = 0;
	int y = 0;
	rep(i, N){
		if(i % 2 == 0){
			x += pq.top();
			pq.pop();
		}else{
			y += pq.top();
			pq.pop();
		}
	}
	cout << abs(x - y) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 100127
int n,m,c[N],ans[N];
struct C{int l,r;}q[N*3];
inline bool cmp(C x,C y){return (x.r-x.l)<(y.r-y.l);}
inline void change(int x,int v)
{for(;x<=n;x+=x&(-x))c[x]+=v;}
inline int Ask(int x)
{int res=0;for(;x;x-=x&(-x))res+=c[x];return res;}
int main(){
	scanf("%d%d",&m,&n);int i,j,p;
	for(i=1;i<=m;i++)scanf("%d%d",&q[i].l,&q[i].r);
	sort(q+1,q+m+1,cmp);p=1;
	for(i=1;i<=n;i++)
	{
		while((p<=m)&&(q[p].r-q[p].l+1<i))
		{change(q[p].l,1);change(q[p].r+1,-1);++p;}
		ans[i]=m-p+1;
		for(j=0;j<=n;j+=i)ans[i]+=Ask(j);
	}
	for(i=1;i<=n;i++)
	printf("%d\n",ans[i]);return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli k;
    vector<lli> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    lli i,j;
    cin>>k;
    cout<<vec[k-1]<<endl;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
import math
import bisect


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if not arr:
        arr.append([n, 1])

    return arr


def solve(n):
    if n == 1:
        return 0
    ans = 0
    acc = list(accumulate(list(range(int(math.log2(n) + 2)))))
    arr = factorization(n)
    for e in arr:
        ans += bisect.bisect_right(acc, e[1]) - 1
    return ans


def main():
    input = sys.stdin.buffer.readline
    n = int(input())

    print(solve(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64128
<?php

$suffles = array();

while (false !== ($line = fgets(STDIN))) {
    $line = trim($line);
    if ('-' === $line) {
        break;
    }
    $cards = preg_split('//', $line, -1, PREG_SPLIT_NO_EMPTY);

    $h = intval(trim(fgets(STDIN)));

    $start = 0;
    for ($i = 0; $i < $h; $i++) {
        fscanf(STDIN, "%d", $n);
        $start += $n;
    }
    $start = $start % count($cards);

    $suffled = '';
    for ($i = 0; $i < count($cards); $i++) {
        $m = ($start + $i) % count($cards);
        $suffled .= $cards[$m];
    }

    $suffles[] = $suffled;
}

foreach ($suffles as $suffle) {
    echo "$suffle\n";
}

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

int main() {
    vector<int> s(10000);
    vector<int> t(500);
    int p, q;
    cin >> p;
    for (int i = 0; i < p; i++) {
        cin >> s[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t[i];
    }

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < p; j++) {
            if (t[i] == s[j]) {
                cnt++;
                break;
            }
        }
    }

    cout << cnt << '\n';
}





Measured memory_bytes: 3148
import math
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
p1 = sum([math.fabs(x[i]-y[i]) for i in range(n)])
p2 = math.sqrt(sum([math.fabs(x[i]-y[i])**2 for i in range(n)]))
p3 = math.pow(sum([math.fabs(x[i]-y[i])**3 for i in range(n)]), 1/3)
pp = max([math.fabs(x[i]-y[i]) for i in range(n)])
print("{0:.6f}".format(p1))
print("{0:.6f}".format(p2))
print("{0:.6f}".format(p3))
print("{0:.6f}".format(pp))

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

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

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int i = 0;
	while (a > 0 && c > 0) {
		if (i % 2 == 0) {
			c -= b;
		} else {
			a -= d;
		}
		i++;
	}

	cout << (a <= 0 ? "No\n" : "Yes\n");

	return 0;
}

Measured memory_bytes: 3600
s = input()
lst = list(s)
st = set(s)
if len(st) == 2 and (lst[0]==lst[1] and lst[2] == lst[3]):
    print("Yes")
elif len(st) == 2 and (lst[0]==lst[2] and lst[1] == lst[3]):
    print("Yes")
elif len(st) == 2 and (lst[0]==lst[3] and lst[1] == lst[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n,m,x,y=map(int,input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.append(x)
b.append(y)

a.sort()
b.sort()

if a[n]<b[0]:
  flag="No War"
else:
  flag="War"

print(flag)

Measured memory_bytes: 3064
def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best)

abc156c_rally()

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	ll a, b, x;
	cin >> a >> b >> x;
	ll l, r;
	r = b / x + 1;
	if (a == 0)
		l = 0;
	else
		l = (a-1) / x + 1;
	cout << r - l << endl;

	return 0;
}


Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


n,m,s,t=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]

def dijkstra(s,e):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost

e1 = [[] for _ in range(n)]
e2 = [[] for _ in range(n)]
for i in range(m):
    a,b,en,su = uvab[i]
    a,b = a-1, b-1
    e1[a].append((en, b))
    e1[b].append((en, a))
    e2[a].append((su, b))
    e2[b].append((su, a))

c1=dijkstra(s-1,e1)
c2=dijkstra(t-1,e2)
# print(c1)
# print(c2)
hlst=[]
for i in range(n):
    hlst.append((c1[i]+c2[i],i))
# print(hlst)
heapq.heapify(hlst)
# print(hlst)
for i in range(n):
    while hlst[0][1]<i:
        heapq.heappop(hlst)
    print(10**15-hlst[0][0])

Measured memory_bytes: 144116
#include<stdio.h>
#include<string.h>
#define LEN 100005 // プロセスの制約 100000 のため

// 構造体
// P という別名をつけている
typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN]; // P structの配列
int head, tail, n; // head ... 先頭ポインタ, tail ... 末尾ポインタ

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b ) { return a < b ? a : b; }

int main()
{
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for ( i = 1; i <= n; i++)
	{
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;

	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0){
			enqueue(u);
		}else{
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}


Measured memory_bytes: 12852
#include <iostream>
 
using std::cin;
using std::cout;
using std::endl;
 
int main()
{
    int64_t K, A, B, N, num, i, j, k, l;
 
    cin >> K;
    cin >> A;
    cin >> B;
 
    N = 1;
    if (A + 1 < B)
    {
        for (i = 0; i < K; i++)
        {
            if (N < A)
            {
                N += 1;
            }
            else
            {
                if (K > i + 1)
                {
                    N -= A;
                    N += B;
                    K -= 1;
                }
                else
                {
                    N += 1;
                }
            }
        }
    }
    else
    {
        N = K + 1;
    }
 
    cout << N << endl;
 
    return 0;
};

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(3*n);
    for(int i=0; i<3*n; i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    long long sm=0;
    for(int i=0; i<2*n; i++){
        if(i%2==1){
//            cout << a[i] << endl;
            sm += a[i];
        }
    }
    cout << sm << endl;
}




Measured memory_bytes: 5580
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);

		List<String> list = new ArrayList<String>();

		int number = stdIn.nextInt();

		for(int i = 0; i < number; i++)
		{
			int a = (int) Math.pow(stdIn.nextInt(), 2);
			int b = (int) Math.pow(stdIn.nextInt(), 2);
			int c = (int) Math.pow(stdIn.nextInt(), 2);

			if (a + b == c || a + c == b || b + c == a)
			{
				list.add("YES");
			} else
			{
				list.add("NO");
			}
		}

		for (String str : list)
		{
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 24028
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	list<ll> lst;
	map<ll, int> num;
	REP(i, n) {
		string s;
		cin >> s;
		if (s == "insert") {
			ll x;
			cin >> x;
			lst.push_front(x);
			num[x]++;
		}
		if (s == "delete") {
			ll x;
			cin >> x;
			if (num[x]) {
				list<ll>::iterator itr;
				for (itr = lst.begin(); itr != lst.end();itr++) {
					if (*itr == x) {
						lst.erase(itr);
						num[x]--;
						break;
					}
				}
			}
		}
		if (s == "deleteFirst") {
			num[*(lst.begin())]--;
			lst.pop_front();
		}
		if (s == "deleteLast") {
			num[*(--lst.end())]--;
			lst.pop_back();
		}
	}
	list<ll>::iterator itr;
	for (itr = lst.begin();itr != lst.end();itr++) {
		if (itr != --lst.end()) cout << *itr << " ";
		else cout << *itr << "\n";
	}

	return 0;
}


Measured memory_bytes: 96892
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define int long long
using namespace std;
int mod=1e9+7;
int cnth[300000]={},cntw[300000]={};
signed main(void){
    int H,W,m,h,w;
    cin>>H>>W>>m;
    map<int,map<int,int>>mp;
    while(cin>>h>>w){
        cnth[h-1]++;
        cntw[w-1]++;
        mp[h-1][w-1]=1;
    }
    int maxh=0,maxw=0;
    for(int i=0;i<H;i++)
        maxh=max(maxh,cnth[i]);
    for(int i=0;i<W;i++)
        maxw=max(maxw,cntw[i]);
    vector<int>vec;
    for(int i=0;i<W;i++)
        if(cntw[i]==maxw)
            vec.push_back(i);
    for(int i=0;i<H;i++){
        if(cnth[i]!=maxh)
            continue;
        for(int j=0;j<vec.size();j++){
            if(cntw[vec[j]]!=maxw)
                continue;
            if(mp[i][vec[j]]==0){
                cout<<maxw+maxh<<endl;
                return 0;
            }
        }
    }
    cout<<maxw+maxh-1<<endl;
}

Measured memory_bytes: 58932
def call(n):
    ans = []

    for i, x in enumerate(range(1, n + 1), 1):
        if x % 3 == 0:
            ans.append(i)
            continue

        while x:
            if x % 10 == 3:
                ans.append(i)
                break
            x //= 10

    print(" " + " ".join(map(str, ans)))


if __name__ == '__main__':
    from sys import stdin

    n = int(stdin.readline().rstrip())

    call(n)



Measured memory_bytes: 6104
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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

int N, A[200001];

int main() {
    cin >> N;
    REP (i, N) {
        cin >> A[i];
    }
    VI B(A, A + N);
    sort(ALL(B), greater<int>());
    REP (i, N) {
        if (A[i] == B[0]) {
            cout << B[1];
        }
        else {
            cout << B[0];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
from functools import lru_cache
N, X = map(int, input().split())
a = [0] * (N)
p = [0] * N
a[0] = 1
p[0] = 1
for i in range(1, N):
    a[i] = a[i-1]*2 + 3
    p[i] = p[i-1]*2 + 1
@lru_cache(maxsize=1000)
def f(n, x):
    if n == 0 and x == 0:
        return 0
    elif n == 0:
        return 1
    if x == 1:
        return 0
    elif x<=1+a[n-1]:
        return f(n-1, x-1)
    elif x == 2+a[n-1]:
        return p[n-1]+1
    elif x <= 2+2*a[n-1]:
        return p[n-1]+1+f(n-1, x-2-a[n-1])
    else:
        return 2*p[n-1]+1
print(f(N, X))

Measured memory_bytes: 67296
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
    int a, b; cin >> a >> b;
    cout << (a < 9 && b < 9 ? "Yay!" : ":(");
}

Measured memory_bytes: 764
#include<stdio.h>
long long int dp[101][21];
int main(void)
{
	int n,i,j,m[101];
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&m[i]);
	for(i=1;i<=n;i++){
		for(j=0;j<=20;j++) dp[i][j]=0;
	}
	dp[1][m[1]]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(20>=j+m[i+1]) dp[i+1][j+m[i+1]]+=dp[i][j];
				if(0<=j-m[i+1]) dp[i+1][j-m[i+1]]+=dp[i][j];
			}
		}
	}
/*	for(i=1;i<=n;i++){
		for(j=0;j<=20;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/	
	printf("%lld\n",dp[n-1][m[n]]);
	return 0;
}

Measured memory_bytes: 2652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  int x = 1, tot = 0, m = 2019;
  vector<int> cut(m);
  ll ans = 0;
  rep(i,n) {
    cut[tot]++;
    tot += (s[i] - '0') * x;
    tot %= m;
    ans += cut[tot];
    x = x * 10 % m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3756
//AtCoder Grand Contest 006 A問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	int ok = 0;
	int n;
	scanf("%d", &n);
	char s[n];
	char t[n];
	scanf("%s", s);
	scanf("%s", t);
	int ans = n*2;
	for(int i=0; i<n; i++){
		if(t[0] == s[i] && ok == 0){
			for(int j=i; j<n; j++){
				if(s[j] == t[j-i]){
					ans--;
					if(j == n-1){
						ok = 1;
					}
				}
				else {
					ans = n*2;
					break;
				}
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
from heapq import heapify,heappop,heappush
n,m=map(int,input().split())#n:num m:ticket
a=[-int(_) for _ in input().split()]
heapify(a)
for i in range(m):
	num=heappop(a)*-1
	heappush(a,(num//2)*-1)
print(sum(a)*-1)

Measured memory_bytes: 14380
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int b[12]={(1<<29),2,5,5,4,5,6,3,7,6};
  int INF=(1<<29);
  int n,m,a,i,j;
  vector<int> x(12),dp(10010,-INF);
  vector<int> ans;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d ",&a);
    x[a]=1;
  }
  dp[0]=0;
  for(i=0;i<=n;i++){
    for(j=1;j<10;j++){
      if(x[j]==0){
        continue;
      }
      if(i+b[j]<=n){
        dp[i+b[j]]=max(dp[i+b[j]],dp[i]+1);
      }
    }
  }
  for(i=n;i>0;){
    for(j=9;j>0;j--){
      if(x[j]==0){
        continue;
      }
      if(i-b[j]>=0 && dp[i]==dp[i-b[j]]+1){
        ans.push_back(j);
        i=i-b[j];
        break;
      }
    }
  }
  sort(ans.begin(),ans.end(),greater<int>());
  for(i=0;i<ans.size();i++){
    printf("%d",ans[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 384