akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

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

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}
long long gcd(long long num1, long long num2) {
	return num2 == 0 ? num1 : gcd(num2, num1 % num2);
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_A_or_C(void) {

	string S; cin >> S;

	cout << (S == "ABC" ? "ARC" : "ABC") << endl;
	return;
}

int main(void) {

	cout << fixed << setprecision(15);
	A_A_or_C();
	return 0;
}


Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
    int n, r;
    int p, c;
    int up[100] = {}, down[100] = {};

    while(cin >> n >> r, n){
        vector<int> cards;
        rep(i, n){
            cards.push_back(n - i);
        }
        rep(i, r) {
            cin >> p >> c;
            rep(j, p-1){
                up[j] = cards[j];
            }
            rep(j, c){
                down[j] = cards[p - 1 + j];
            }
            rep(j, c){
                cards[j] = down[j];
            }
            rep(j, p-1){
                cards[c + j] = up[j];
            }            
        }
        cout << cards[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple


ll n, cnt =0, dp[101010];
vl v;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

ll temp = 1;

rep(i, 1, 12){
v.pb(temp);
temp*=9;
}
temp = 6;
rep(i, 1, 19){
v.pb(temp);
temp*=6;
}



cin >> n;

sort(all(v));

rep(i, 1, n){
dp[i]=inf;
}

dp[0]=0;

rep(i, 1, n){

    int m = lower_bound(all(v), i) - v.begin();

    rep(j, 0, m){
    if(v[j]<=i)
    dp[i] = min(dp[i-v[j]]+1, dp[i]);

    }

}

cout << dp[n] << endl;





return 0;}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h1, h2, k1, k2, a, b, c, d;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
    auto f = [&](int p, int q){ return p*a+q*b+p/10*c+q/20*d; };
    if(f(h1, h2) < f(k1, k2)) puts("kenjiro");
    else if(f(h1, h2) > f(k1, k2)) puts("hiroshi");
    else puts("even");
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define MAX_N 110000

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(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    // dp table
    // init dp table
    // init condition
    // loop

    ll N;
    cin >> N;

    vector<ll> dp(MAX_N, N);

    dp[0] = 0;

    priority_queue<Pll, vector<Pll>, greater<Pll>> que;
    que.push(make_pair(0, 0));

    while (!que.empty()) {
        ll cur = que.top().first;
        ll v = que.top().second;
        que.pop();

        if (cur > dp[v]) {
            continue;
        }

        for (ll pow6 = 1; v+pow6 <= N; pow6 *= 6) {
            ll nv = v+pow6;
            if (chmin(dp[nv], dp[v]+1)) {
                que.push(make_pair(dp[nv], nv));
            }
        }
        for (ll pow9 = 1; v+pow9 <= N; pow9 *= 9) {
            ll nv = v+pow9;
            if (chmin(dp[nv], dp[v]+1)) {
                que.push(make_pair(dp[nv], nv));
            }
        }
    }

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

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    long long q, l[100100], r[100100], i, ans[100100]={0};
    bool a, b;
    cin >> q;
    for(i=0;i<q;i++){
        cin >> l[i] >> r[i];
    }
    for(i=1;i<=100000;i++){
        a=IsPrime(i);b=IsPrime((i+1)/2);
        if(a && b) ans[i]=ans[i-1]+1;
        else ans[i]=ans[i-1];
    }

    for(i=0;i<q;i++){
        cout << ans[r[i]]-ans[l[i]-1] <<endl;
    }
    return 0;
}

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

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int INF = (1<<21);

void dijkstra(void);

int n;
int M[MAX][MAX];

int main(){
  int i,j;
  int c,k,u,v;
  cin >> n;
  for( i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      //M[i][j] = INFINITY;
      M[i][j] = INF;
    }
  }
  for(i = 0; i < n; i++){
    cin >> u;
    cin >> k;
    for(j = 0; j < k; j++){
      cin >> v;
      cin >> c;
      M[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int minV;
  int d[MAX],color[MAX];
  int u,v;
  int i;
  for(i = 0; i < n; i++){
    //d[i] = INFINITY;
    d[i] = INF;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    //minV = INFINITY;
    minV = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(minV > d[i] && color[i] != BLACK){
        u = i;
        minV = d[i];
      }
    }
    if(u == -1){
      break;
    }
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      //if(color[v] != BLACK && M[u][v] != INFINITY){
      if(color[v] != BLACK && M[u][v] != INF){
        if(d[v] > d[u] + M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
    }
    for(i = 0; i < n; i++){
      //cout << i << " " << (d[i] == INFINITY ? -1 : d[i]) << endl;
      cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
  }

Measured memory_bytes: 3116
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<bitset>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,k,t,a[200005],ans;
vector<int> v;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t);
		a[t]++;
	}
	for(int i=1;i<=n;i++)
		if(a[i]!=0)
			v.push_back(a[i]);
	sort(v.begin(),v.end());
	if(v.size()<=k)
	{
		cout<<0;
		return 0;
	}
	for(int i=0;i<v.size()-k;i++)
		ans+=v[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long H = scan.nextLong();
        long step = 0;
        while (0 < H) {
            H /= 2;
            step += 1;
        }
        long answer = pow(step)-1;
        System.out.println(answer);
    }
    private long pow(long N) {
        if (N == 0) {
            return 1;
        }
        if (N % 2 == 1) {
            return 2 * pow(N-1);
        }
        long x = pow(N/2);
        return x * x;
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5 && b==5 && c==7)  || (a==7 && b==5 && c==5) || (a==5 && b==7 && c==5))
    cout<<"YES";
  else 
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c=0;
    int i,count,x=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a; i<=b; i++){
        x = c%i;
        if(x == 0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 596
<?php

$sc = new Scanner();
$out = new out();

$n = $sc->nextInt();
$a = $sc->nextInt();

$d = $n % 500;

if ($d > $a) {
    $out->println('No');
} else {
    $out->println('Yes');
}

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

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

int		main(void)
{
	string a, b;
	
	cin >> a >> b;
	int x = stoi(a + b);
	
	for (int i = 1; i <= x; i++)
	{
		if (i * i == x)
		{
			cout << "Yes" << endl;
			return (0);
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int numX = sc.nextInt();
      	int numA = sc.nextInt();
      
      	if (numX < numA) {
          System.out.println(0);
        } else {
          System.out.println(10);
        }
	}
}



Measured memory_bytes: 23124
/*    特徴    */

/*    教訓    */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

 string s = is();
 cout << s.substr(0, 3) << endl;


  
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int p[6],q[6];
double a[6],b[6];

double calc(double s){
  double t = 1.0-s;
  double ret = 0.0;
  REP(i,6){
    double sp = s*a[i];
    double tq = t*b[i];
    if(sp>=tq){
      // called p
      ret += tq;
    }else{
      ret += sp;
    }
  }
  return ret;
}

int main(){
  REP(i,6)scanf("%d",p+i);
  REP(i,6)scanf("%d",q+i);
  REP(i,6)a[i]=(double)p[i]/100.0;
  REP(i,6)b[i]=(double)q[i]/100.0;
  double low = 0.0, high = 1.0;
  REP(_,1000){
    double midl = (low*2.0+high)/3.0;
    double midr = (low+high*2.0)/3.0;
    if(calc(midl)>calc(midr)){
      high = midr;
    }else{
      low = midl;
    }
  }
  printf("%.12lf\n",1.0 - calc(low));
  return 0;
}


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

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

Measured memory_bytes: 380
// atcoder/panasonic2020/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

int di[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dj[] = {1, 0, 0, -1, 1, -1, -1, 1};
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli h, w;
  while (cin >> h >> w) {
    if (h == 1 || w == 1) cout << 1 << endl;
    else cout << ((h / 2) * w) + (h % 2) * ((w + 1) / 2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int K = in.nextInt();
        long sum = 0;
        for(int i = 1; i<=K; i++){
            for(int j = 1; j<=K; j++){
                for(int k = 1; k<=K; k++){
                    int d = gcd(i,j);
                    d = gcd(k,d);
                    sum+=d;
                }
            }
        }
        System.out.print(sum);
    }

    public static int gcd(int a, int b){
        return (b>0)?gcd(b, a%b):a;
    }

}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            int n;
            cin >> n;
            string s;
            cin >> s;

            int f[n+10][3];
            memset(f, 0, sizeof(f));
            map<char,int> mp;
            mp['R'] = 0;
            mp['G'] = 1;
            mp['B'] = 2;
            for(int i = 0; i < n; i++)
            {
                if(s[i] == 'R')
                    f[i+1][0] = f[i][0] + 1;
                if(s[i] == 'G')
                    f[i+1][1] = f[i][1] + 1;
                if(s[i] == 'B')
                    f[i+1][2] = f[i][2] + 1;
                for(int j = 0; j < 3; j++)
                    f[i+1][j] = max(f[i+1][j], f[i][j]);
            }
            int ans = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    if(s[i] == s[j])
                        continue;
                    int t = 3 - (mp[s[i]] + mp[s[j]]);
                    ans += (f[n][t] - f[j][t]);
                    if(2*j - i < n && mp[s[2*j - i]] == t)
                        ans--;
                }
            }
            cout << ans << endl;




           return 0;
        }
          

Measured memory_bytes: 3676
N = int(input())
F = []
P = []
for i in range(N):
    f = list(map(int, input().split()))
    F.append(f)
for i in range(N):
    p = list(map(int, input().split()))
    P.append(p)



def solve(K):
    ans = 0
    n = 0
    while n < N:
        num = 0
        for i in range(10):
            if int(K[i]) == F[n][i] and K[i] == '1':
                num = num + 1
        ans += P[n][num]
        n += 1
    return ans
Ans = solve('%010d' % 1)
for m in range(1,1024):
    K = []
    L = int(format(m, 'b'))
    L = '%010d' % L
    k = solve(L)
    Ans = max(Ans, k)
print(Ans)


Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	int n, m;
	int x, y, z;
	scanf("%d%d", &n, &m);
	for (x = 0; x <= n; x++)
	{
		for (y = 0; y <= n-x; y++)
		{
			z = n - x - y;
			if (x * 10000 + y * 5000 + z * 1000 == m)
			{
				printf("%d %d %d", x, y, z);
				return 0;
			}
		}
	}
	printf("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7


def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        adj[a].append(b)
        adj[b].append(a)

    queue = deque([0])
    visit = [-1] * N
    visit[0] = 0

    while queue:
        now = queue.popleft()
        for u in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                visit[u] = visit[now] + 1

    queue = deque([N-1])
    visit2 = [-1] * N
    visit2[N-1] = 0

    while queue:
        now = queue.popleft()
        for u in adj[now]:
            if visit2[u] < 0:
                queue.append(u)
                visit2[u] = visit2[now] + 1

    cnt = 0
    for i in range(N):
        if visit[i] <= visit2[i]:
            cnt += 1
    print('Fennec') if cnt > N-cnt else print('Snuke')
    # print(visit2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84156
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
long long int dp[100+5][100+5];
int main()
{
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    ll cash=1000;
    for(long long int i=0;i<n;i++)
    {
        ll now=cash/arr[0];
        ll rem=cash%arr[0];
        now*=arr[i];
        now+=rem;
        dp[0][i]=max(cash,now);
    }


    for(ll i=1;i<n;i++)
    {
        ll cash=1000;
        for(ll k=0;k<=i;k++)
        {
            cash=max(cash,dp[i-1][k]);
        }
        for(ll j=i+1;j<n;j++)
        {
            ll now=cash/arr[i];
            ll rem=cash%arr[i];
            now*=arr[j];
            now+=rem;
            dp[i][j]=max(cash,now);

        }

    }
   /* for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            //cout << dp[i][j]<<" ";
        }
        //cout << endl;
    }*/
    cout << dp[n-2][n-1];
}


Measured memory_bytes: 3684
#include <bits/stdc++.h> 
using namespace std; 
int main (){
    string S,T;
    cin >> S >> T;
    int i,ans=0;
    for(i=0;i<3;i++){
    if(S[i] == T[i])
    ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    long long t, count = 0;
    float n;
    cin >> t >> n;
    for (int i = 0; i < t; i++)
    {
        long long x, y;
        double d;
        cin >> x >> y;
        d = double(sqrt(x * x + y * y));
        if (d <= n) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))

L.sort(reverse = True)
prev = -1
dic = {}
for n in L:
    if prev != n:
        cnt = 0
        prev = n
    elif prev == n:
        cnt += 1
        dic.setdefault(n, cnt)
        dic[n] += 1
if len(dic.keys()) < 1:
    print(0)
else:
    for k, v in sorted(dic.items(), reverse = True):
        if v >= 4:
            print(k * k)
            exit()
        else:
            break
    cand = list(dic.keys())
    cand.sort(reverse=True)
    print(cand[0] * cand[1])




Measured memory_bytes: 59160
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

D=gets.to_i
last=array(26,0)
c=get_i
s=array(D)
D.times do|i|
    s[i]=get_i
end
ans=0
D.times do|i|
    t=gets.to_i
    t-=1
    ans+=s[i][t]
    last[t]=i+1
    26.times do|j|
      ans-=c[j]*(i+1-last[j])
    end
    puts ans
end

Measured memory_bytes: 14240
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, k;
    cin >> n >> k;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int out = -MOD;
    for (int i = 0; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            if (i + n - j > k) {
                continue;
            } else {
                std::vector<int> get;
                for (int t = 0; t < i; t++) {
                    get.pb(v[t]);
                }
                for (int t = j; t < n; t++) {
                    get.pb(v[t]);
                }
                std::sort(get.begin(), get.end());
                int rid = k - (i + n - j);
                int sum = 0;


                for (int idx = 0; idx < get.size(); idx++) {
                    if (get[idx] < 0 && rid > 0) {
                        rid--;
                    } else {
                        sum += get[idx];
                    }
                }
                chmax(out, sum);
            }
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int a[n + 1];
    int b[n + 1] = {};
    repd(i, 1, n + 1) { cin >> a[i]; }

    int ans_num = 0;
    vector<int> ans;
    rep(i, n) {
        int index = n - i;
        int index_temp = index;
        int sum = 0;
        while (index_temp <= n) {
            sum += b[index_temp];
            index_temp += index;
        }

        if (sum % 2 != a[index]) {
            b[index] = 1;
            ans_num++;
            ans.push_back(index);
        }
    }

    cout << ans_num << endl;
    rep(i, ans.size()) { cout << ans[i] << " "; }
    cout << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lo long
const long long lmax=1999999999;
const long long lmx=1999999999999999999;
long long H,cx,cy,x[10003],y[10003],n,h[10003];
bool ok;
long long abs(long long a,long long b)
{
	if(a-b<0)
		return b-a;
	return a-b;
}
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(long long i=0;i<n;i++)
{
	cin>>x[i]>>y[i]>>h[i];
}
for(long long i=0LL;i<=100LL;i++)
{
	for(long long j=0LL;j<=100LL;j++)
	{
//		ok=1;
//		H=h[0]+(abs(x[0],i)+abs(y[0],j));
if(h[0]==0)
		for(long long H=1;H<=(abs(x[0],i)+abs(y[0],j));H++){ok=1;
		for(long long t=1;t<n;t++)
		{
			if(max(0LL,H-(abs(x[t],i)+abs(y[t],j)))!=h[t])
			{
				ok=0;
				break;
			}
		}
		if(ok)
		{
			cout<<i<<" "<<j<<" "<<H<<endl;
			return 0;
		}
	}
	else
	{
			ok=1;
		H=h[0]+(abs(x[0],i)+abs(y[0],j));	
				for(long long t=1;t<n;t++)
		{
			if(max(0LL,H-(abs(x[t],i)+abs(y[t],j)))!=h[t])
			{
				ok=0;
				break;
			}
		}
		if(ok&&H>=1)
		{
			cout<<i<<" "<<j<<" "<<H<<endl;
			return 0;
		}
	}
	}
}
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





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

int main() {
	
	int a,b,c,a1;
	cin>>a>>b>>c;
	a1=a-b;
	
	if(c-a1<0)
	cout<<"0";
	else
	cout<<c-a1;
	return 0;
}

Measured memory_bytes: 256
i,v,s[5000],m,*p;main(n){for(;~scanf("%d",&n);n&&printf("%d\n",m))for(i=0,m=-1e5;i<n;)for(scanf("%d",&v),p=s+i++,*p++=0;p---s;m=*p>m?*p:m)*p+=v;}

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

int main(){
    int k;
    cin >> k;
    string s, ans;
    cin >> s;
 
    int t = s.size();
    if(t <= k) {
        cout << s << endl;
    }else{
      for (int j = 0; j < k; j++){
          cout << s.at(j);
      }
      cout << "..." << endl;
    }

}

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int C[3][3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i, 0, 3) rep(j, 0, 3) {
        cin >> C[i][j];
    }
    rep(i, 0, 3) rep(j, i + 1, 3) {
        rep(k, 0, 3) rep(l, k + 1, 3) {
            int diff1 = C[i][k] - C[i][l];
            int diff2 = C[j][k] - C[j][l];
            if (diff1 != diff2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    branch[a]|={b}
    branch[b]|={a}
dist=[-1]*N
dist[0]=0
check={0}
flag=False
while len(check)>0:
    if flag:
        break
    now=check.pop()
    for nex in branch[now]:
        if dist[nex]==-1:
            dist[nex]=(dist[now]+1)%2
            check|={nex}
        elif dist[nex]!=(dist[now]+1)%2:
            check=set()
            flag=True
            dist=[-1]*N
            break
if dist[0]==-1:
    print(N*(N-1)//2-M)
else:
    odd=dist.count(1)
    even=dist.count(0)
    print(odd*even-M)

Measured memory_bytes: 40004
#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>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
int main() {
	ll n, m;
	cin >> n >> m;
	vl a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	vl ans(m, 0);
	for (int i = 0; i < m; i++) {
		if (i != m - 1) {
			ans[i] = max(abs(a[i] - a[i + 1]), abs(n - abs(a[i] - a[i + 1])));
		}
		else {
			ans[i] = max(abs(a[i] - a[0]), abs(n - (a[i] - a[0])));
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans[0] << endl;
}

Measured memory_bytes: 6388
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    init_comb();
    int h, w, a, b;
    std::cin >> h >> w >> a >> b;

    long long ans = 0;

    for (int i = b; i < w; i++) {
        ans = (ans + comb(i + (h - a - 1), i) * comb((w - 1 - i) + (a - 1), a - 1)) % mod;
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 12160
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[][] arr = new int[2][n];
        for(int i = 0; i<2; i++){
            for(int j = 0; j<n; j++){
                arr[i][j] = in.nextInt();
            }
        }
        int sum = 0;
        for(int i = 0; i<n; i++){
            if(arr[0][i] > arr[1][i]){
                sum+=(arr[0][i]-arr[1][i]);
            }
        }
        out.println(sum);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template

deque <int> q;
int n;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        int temp; cin>>temp;
        if(i%2){q.pf(temp);}
        else{q.pb(temp);}
    }
    while(!q.empty()){
        if(n%2){
            cout<<q.front();q.pof();
            if(q.empty())cout<<newl;
            else cout<<" ";
        }
        else{
            cout<<q.back();q.pob();
            if(q.empty())cout<<newl;
            else cout<<" ";
        }
    }

}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

string s, ans = "None";
map<int, bool> m;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int i=0;i<s.size();i++){
		if(!m[int(s[i]) - 96])
			m[int(s[i]) - 96] = true;
	}
	if(m.size() < 26){
		int i = 1;
		for(auto it=m.begin();it!=m.end();++it){
			if(it->first > i){
				ans = char(i + 96);
				break;
			}
			i++;
		}
		if(ans == "None")
			ans = char(i + 96);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[200001];
int main(){
    int n,x;
    cin>>n>>x;
    if(x==1||x==2*n-1){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    a[n-1]=x;
    a[n-2]=1,a[n]=2*n-1;
    int cur=0;
    FOR(i,1,2*n){
        while(cur==n-2||cur==n-1||cur==n){
            ++cur;
        }
        if(i==x||i==1||i==2*n-1) continue;
        a[cur++]=i;
    }
    rep(i,2*n-1) cout<<a[i]<<endl;
    return 0;
}

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

using namespace std;

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

    double res = 0;
    double tmp;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        res += 1 / tmp;
    }

    cout << 1 / res << "\n";
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()

lr=[]
for _ in range(q):
    D = list(map(int, input().split()))
    lr.append(D)

ac_list=[]

for i in range(len(s)-1):
    if s[i]=="A" and s[i+1]=="C":
        ac_list.append(i)

import bisect

for j in range(q):
    ind1 = bisect.bisect_left(ac_list,lr[j][0]-1)
    ind2 = bisect.bisect_left(ac_list,lr[j][1]-1)

    print(ind2-ind1)

Measured memory_bytes: 30276
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, next, pos, deg[1000], m;
vi v, st;
vector<vi> e;

void rec(int c){
	deg[c] = next;
	st.pb(c);
	rep(i, deg[c] - 1){
		next = v[pos++];
		if(next < 0){
			int to = st[st.size() + next - 1];
			deg[to]--;
			e[c].pb(to);
			e[to].pb(c);
		}
		else{
			e[c].pb(m);
			e[m].pb(c);
			rec(m++);
		}
	}
	st.pop_back();
}

int main(){
	int cs;
	cin >> cs;
	while(cs--){
		v.clear();
		int t;
		m = 0;
		while(cin >> t, t){
			v.pb(t);
			if(t > 0) m++;
		}
		
		e.clear(); e.resize(m);
		next = v[0];
		pos = m = 1;
		rec(0);
		
		rep(i, m){
			sort(all(e[i]));
			cout << (i + 1);
			rep(j, e[i].size()) cout << " " << e[i][j] + 1;
			cout << endl;
		}
	}
	return 0;
}

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

int statable_check(vector<string> inputs, vector<string> sorted) {
	for (unsigned i = 0; i < sorted.size() - 1; i++) {
		if (sorted[i][1] == sorted[i + 1][1]) {
			if (find(inputs.begin(), inputs.end(), sorted[i]) > find(inputs.begin(), inputs.end(), sorted[i + 1])) {
				return false;
			}
		}
	}
	return true;
}

void bubble_out(vector<string> cards) {
	for (int i = 0; i < (int) cards.size(); i++) {
		for (int j = (int) cards.size() - 1; j >= i + 1; j--) {
			if (cards[j][1] < cards[j - 1][1]) {
				swap(cards[j], cards[j - 1]);
			}
		}
	}
	for (unsigned i = 0; i < cards.size(); i++) {
		if (i != 0) cout << ' ';
		cout << cards[i];
	}
	cout << endl;
	cout << "Stable" << endl;
}
void selection_out(vector<string> cards) {
	vector<string> scheck_copy = cards;
	for (unsigned i = 0; i < cards.size(); i++) {
		unsigned mini = i;
		for (unsigned j = i; j < cards.size(); j++) {
			if (cards[j][1] < cards[mini][1]) {
				mini = j;
			}
		}
		swap(cards[i], cards[mini]);
	}
	for (unsigned i = 0; i < cards.size(); i++) {
		if (i != 0) cout << ' ';
		cout << cards[i];
	}
	cout << endl;
	if (statable_check(scheck_copy, cards)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}

int main () {
	int n;
	cin >> n;
	vector<string> cards(n);
	for (int i = 0; i < n; i++) {
		cin >> cards[i];
	}
	bubble_out(cards);
	selection_out(cards);
	return 0;
}

Measured memory_bytes: 1212
def slove():
    import sys
    import collections
    import bisect
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    cnt = 0
    d = collections.defaultdict(int)
    for i in range(n-2):
        for j in range(i+1, n-1):
            ma = l[i] + l[j]
            p = bisect.bisect_left(l, ma)
            if j < p:
                cnt += p - j - 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 44036