akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	lint N;
	cin >> N;

	string ans;
	while (N > 0) {
		ans = char((N % 26 + 25) % 26 + 'a') + ans;
		N--;
		N /= 26;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>a;
    if((a-(10*(a/10)))==a/100)printa("Yes");
    else printa("No");
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int n0=0;
  int n1=0;
  for(char c :S){
    if(c=='0'){
      n0+=1;
    }else{
      n1+=1;
    }
  }
  cout << min(n0,n1)*2 << endl;


  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int m[]={2189,89,1232,866,1796,2603},a,b,c,d,r;char s[99];int main(){for(s[87]=1,s[78]=4,s[69]=3,s[83]=2;~scanf("%s",s);r+=a%3?b%3?(b+6-a)%6<3?2:5:3+!b:a?6:1)d=s[*s],*s<65?printf(r?"%d\n":0,r),a=c=r=0,b=1:d?d=d+c&3,a=m[a]>>3*d&7,b=m[b]>>3*d&7:c+=3+*s;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0;

int32_t main()
{
	IOS
	string s1,s2;cin>>s1>>s2;
	int n1=s1.length(),n2=s2.length();
	s1='0'+s1;s2='0'+s2;
	
	vector<vector<int>>dp(n1+1,vector<int>(n2+1));
	for(int i=1;i<=n1;i++)
	{
		for(int j=1;j<=n2;j++)
		{
			if(s1[i]==s2[j])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}
	
	int current=dp[n1][n2],r=n1,c=n2;
	string ans;
	while(r > 0 && c >0 && current)
	{
		if(dp[r][c-1]==current)
		{
		    c--;
		}
		else if(dp[r-1][c]==current)
		{
			r--;
		}
		else
		{
		   ans+=s1[r];r--;c--;current--;
	    }
	   
	    
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	
	
			
	
	
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 70784
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)
	var count int = 0
	for i := 0; i < (N - 2); i++ {
		if S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C' {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
int main()
  {int H, W, K, ans{}; cin >> H >> W >> K;
  vector<vector<char>> css(H, vector<char>(W)); for (auto &cs : css) for (auto &c : cs) cin >> c;
  for (int i{}; i < 1 << H; ++i) for (int j{}; j < 1 << W; ++j)
    {int b{}; for (int k{}; k < H; ++k) for (int l{}; l < W; ++l) if (!((i >> k & 1) + (j >> l & 1))) b += css[k][l] == '#';
    ans += b == K;}
  cout << ans << endl;}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vll A(n);
    loop(i, 0, n)
        cin>>A[i];
    vector<vector<pii> > dp(n, vector<pii>(n, {0, 0}));
    loop(i, 0, n)
        dp[i][i] = {A[i], 0};
    loop(len, 2, n+1){
        loop(i, 0, n-len+1){
            lli j = i + len - 1;
            lli ans = 1e16;
            lli val = 0;
            loop(k, i, j){
                ans = min(ans, dp[i][k].second + dp[k+1][j].second + dp[i][k].first + dp[k+1][j].first);
                val = dp[i][k].first + dp[k+1][j].first;
            }
            dp[i][j] = {val, ans};
        }
    }
    cout<<dp[0][n-1].second<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 5844
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    let d: i64 = input();
    let e: i64 = input();

    let mn = [a, b, c, d, e].iter().min().unwrap().clone();
    let t = (n + mn - 1) / mn;
    println!("{}", 4 + t);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int dp[15][2];
    dp[0][0] = 1, dp[0][1] = 0;
    REP(i, n){
        if(a[i] & 1){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][0] * 2 + dp[i][1] * 3;
        }else{
            dp[i+1][0] = dp[i][0] * 2;
            dp[i+1][1] = dp[i][1] * 3 + dp[i][0] * 1;
        }
    }
    cout << dp[n][1] << endl;
}


Measured memory_bytes: 256
N = int(input())

X = []
for i in range(N):
    x, y = map(int, input().split())
    
    X.append([x+y,x,y])   


X.sort(reverse=True)

ansA = 0
ansB = 0

for index, i in enumerate(X):
    if index%2 == 0:
        ansA += i[1]
    else:
        ansB += i[2]

print(ansA - ansB)

Measured memory_bytes: 23260
N = int(input())

shogen = []

for _ in range(N):
    A = int(input())
    asho = []
    for i in range(A):
        x, y = map(int, input().split())
        asho.append((x-1, y))
    shogen.append(asho)
# print(shogen)
ans = 0

for i in range(2**N):
    good = [0 for _ in range(N)]
    f = 1
    for j in range(N):
        if ((i >> j)&1):
            good[j] = 1
    # print(f"good{good}")
    for k in range(N):
        # print("k", k)
        if good[k]:
            for l, m in shogen[k]:
                # print(f"l{l} m{m}")
                if good[l] != m:
                    f = 0
    # print("f", f)
    if f:
        ans = max(ans, sum(good))

print(ans)

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N;
int a[200000];

signed main(){
    cin >> N;
    REP(i, N) cin >> a[i];
    int m = 0;
    REP(i, N){
        if(a[i] == m + 1) m++;
    }
    if(m == 0) PRINT("-1");
    else PRINT(N - m);
    return 0;
}

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


def main():
    n = int(input())
    A, B = [], []
    for i in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    A.sort()
    B.sort()

    if n % 2 == 1:
        left = A[n // 2]
        right = B[n // 2]
    else:
        m = n // 2 - 1
        left = A[m] + A[m + 1]
        right = B[m] + B[m + 1]

    ans = right - left + 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25332
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow(((x * x)%mod), n / 2,mod));
	else
		return ((x%mod) * pow(x, n - 1,mod));
}
bool prime(int n) {
	int i = 2;
	if (n == 2)return true;
	else if(n <= 1)return false;
	if (n % i == 0)return false;
	i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0)return false;
		i += 2;
	}
	return true;
}
ll mod = 998244353;
int main() {
	int n; cin >> n;
	vector< int > a(n);
	rip(i, n)cin >> a[i];
	ll nowhigh = a[0];
	ll ans = 0;
	Rip(i, n - 1) {
		if (a[i] < nowhigh)ans -= a[i] - nowhigh;
		else nowhigh = a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4000
#include <stdio.h>

int power(int n,int m) {
 int j,s;
 s=1;
 for (j=0;j<m;j++) {
  s=s*n;
 }
 return s;
}

int main() {
int N;
scanf("%d",&N);
int i,e,o,s;
int buf[10];

for (i=0;i<N;i++) {
 scanf("%d",&buf[i]);
}
e=0;
o=0;
for (i=0;i<N;i++) {
if (buf[i]%2==0)
 e=e+1;
else
 o=o+1;
}
s=power(3,N)-power(1,o)*power(2,e);
printf("%d\n",s);

return 0;
}

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

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    if(A == 0 && B == 0) {
        rep(i, 0, H) {
            rep(j, 0, W) cout << 1;
            cout << '\n';
        }
        return 0;
    }
    rep(i, 0, H - B) {
        rep(j, 0, W - A) cout << 1;
        rep(i, 0, A) cout << 0;
        cout << '\n';
    }
    rep(i, 0, B) {
        rep(j, 0, W - A) cout << 0;
        rep(i, 0, A) cout << 1;
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
S = gets.chomp

rl = [-1]
until rl[-1] == nil do
  rl << S.index('RL', rl[-1] + 1)
end
rl.shift
rl.pop
lr = [0]
until lr[-1] == nil do
  lr << S.index('LR', lr[-1] + 1)
end
lr.shift
lr.pop
rl.map!{|e| e + 1}
lr.map!{|e| e + 1}
lr.unshift(0)
lr.push(S.size)

ans = Array.new(S.size, 0)
rl.each_with_index{|rl, idx|
  r = rl - lr[idx]
  l = lr[idx + 1] - rl
  ans[rl - 1] += (r / 2 + l / 2)
  ans[rl] += (r / 2 + l / 2)
  ans[rl - 1] += 1 if r.odd?
  ans[rl] += 1 if l.odd?
}

puts ans.join(' ')


Measured memory_bytes: 4092
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.math;
import std.format;
import std.datetime;

void main() {
  string[] days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
                   "Friday", "Saturday"];

  foreach (string line; stdin.lines) {
    if (line == "0 0\n") break;
    int m, d;
    line.formattedRead("%d %d", &m, &d);
    int day = Date(2004, m, d).dayOfWeek;
    days[day].writeln;
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
const ll mo=1000000007;
const int prime_max = 1100000;
vector<int> prime;
int NP,divp[prime_max];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		prime.push_back(i); NP++;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}

map<ll,int> enumpr(ll n) {
	map<ll,int> V;
	for(ll i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
	if(n>1) V[n]++;
	return V;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cprime();
	map<int,int> M;
	
	FOR(i,N) {
		cin>>A[i];
		auto P=enumpr(A[i]);
		FORR(p,P) M[p.first]=max(M[p.first],p.second);
	}
	ll S=1;
	FORR(m,M) {
		FOR(i,m.second) S=S*m.first%mo;
	}
	ll ret=0;
	FOR(i,N) ret+=S*modpow(A[i])%mo;
	cout<<ret%mo<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

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



int main(){
    int N, K;
    cin >> N >> K;
    
    vector <int> p(N);
    rep(i,N)cin>> p[i] ;

    sort(p.begin(),p.end());

    int ans = 0;
    rep(i,K){
        ans += p[i];
    }

    cout << ans << endl;

    
}


Measured memory_bytes: 3632
N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

max_x = max(x)
min_y = min(y)
if max_x < min_y and max_x < Y and min_y > X:
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
lst = [i for i in range(1 , N + 1)]
comp = []
for i in itertools.permutations(lst):
    comp.append(list(i))
comp.sort()
print(abs(comp.index(P) - comp.index(Q)))


Measured memory_bytes: 10228
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;

int n, k, dp[maxn][3];
char s[maxn];

inline void upmax(int &x, int y) { x = max(x,y); }

int main() {
//	freopen("data.in","r",stdin);
  scanf("%s", s + 1);
	n = strlen(s + 1);
  memset(dp,-1,sizeof(dp));
	dp[1][1] = 1; dp[1][2] = -1;
	for(int i = 2;i <= n;i ++) {
//		dp[i][1] = dp[i][2] = 0;
		if(s[i] != s[i - 1] && ~ dp[i - 1][1]) dp[i][1] = dp[i - 1][1] + 1;
		if(~ dp[i - 1][2]) upmax(dp[i][1],dp[i - 1][2] + 1);
		if(~ dp[i - 2][2]) upmax(dp[i][2],dp[i - 2][2] + 1);
		if(~ dp[i - 2][1]) upmax(dp[i][2],dp[i - 2][1] + 1);
	}
  int Ans = max(dp[n][1],dp[n][2]);
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll a,b;
std::vector<ll> v;
int main()
{
    gbtb;
    cin>>n;
    cin>>a>>b;
    ll x;
    repd(i,1,n)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int cnt1,cnt2,cnt3;
    cnt1=cnt2=cnt3=0;
    repd(i,0,n-1)
    {
        if(v[i]<=a)
        {
            cnt1++;
        }else if(v[i]>=a+1&&v[i]<=b)
        {
            cnt2++;
        }else if(v[i]>=b+1)
        {
            cnt3++;
        }
    }
    int ans=min(cnt1,min(cnt2,cnt3));
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_d
import sys
from collections import Counter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    sum_ = sum(A)
    cntr = Counter(A)
    Q = i2n()
    for _ in range(Q):
        B, C = i2nn()
        bn = cntr.pop(B, 0)
        sum_ += C * bn - B * bn
        cntr[C] += bn
        print(sum_)
    return

main()


Measured memory_bytes: 24188
#include<stdio.h>
#define LEN 1000050

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

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

P dequeue(){
  return Q[head];
}

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=i-1;
  while(head!=tail+1){
    u=dequeue();

    //printf("head:%d tail:%d u.nam:%s u.t:%d elaps:%d\n",head,tail,u.name,u.t,elaps);
    
    if(head+1==LEN)head=1;
    else head++;
    
    if(u.t>q){
      u.t-=q;
      elaps+=q;
      enqueue(u);
    }
    else{
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
    if(elaps>1000000){
      //printf("..... (terminated because of the limitation)\n");
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 20968
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  vi V(3);
  rep(i, 3) cin >> V[i];
  sort(all(V), greater<int>());
  cout << 10 * V[0] + V[1] + V[2] << endl;
  return 0;
}

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

S = input()
print(S+("s" if S[-1] != "s" else "es"))


Measured memory_bytes: 9908
#include <stdio.h>

int r, D, x[11];

int main(void)
{
  scanf("%d %d %d", &r, &D, &x[0]);
  for (int i = 1; i <= 10; ++i) {
    x[i] = r * x[i - 1] - D;
    printf("%d\n", x[i]);
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int fx = 0;
    int i = N;
    while (i > 0)
    {
        fx += i % 10;
        i /= 10;
    }
    cout << ((N % fx) == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

import math 

for i in range(1):
    n=ii()
    a=li()
    for i in range(n):
        if (a[i]%2==0 and (a[i]%3==0 or a[i]%5==0)) or a[i]%2:
            continue
        else:
            print("DENIED")
            exit()
    print("APPROVED")

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        double[] A = ReadDoubles();
        double sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += 1 / A[i];
        }
        sum = 1 / sum;
        return sum.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);


template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	string S; cin >> S;
	int ans = S.size();
	int cnt = 0;
	for(int i = 0; i < S.size(); ++i){
		char c=(i%2?'0':'1');
		if(S[i]!=c) cnt++;
	}
	chmin(ans,cnt);
	cnt = 0;
	for(int i = 0; i < S.size(); ++i){
		char c=(i%2?'1':'0');
		if(S[i]!=c) cnt++;
	}
	chmin(ans,cnt);
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
	int arr[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> arr[i];
		if (arr[i] == 0)
		{
			cout << i + 1;
			return 0;
		}
	}
}

Measured memory_bytes: 3584
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        long N = scanner.nextLong(); scanner.nextLine();

        Set<String> strs = new HashSet<>();

        String first = scanner.nextLine();
        strs.add(first);

        char tail = first.charAt(first.length() - 1);

        String ans = "Yes";
        for(int i = 1; i < N; i++) {
            String str = scanner.nextLine();
            char h = str.charAt(0);
            char t = str.charAt(str.length() - 1);

            if(tail != h || strs.contains(str)) {
                ans = "No";
                break;
            }
            tail = t;
            strs.add(str);
        }

        scanner.close();

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long int i = (a); i < (b); i++)

using namespace std;
using ll = long long int;
using ld = long double;

auto p = [](auto s){
    cout << s << endl;
};

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

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K, ans, mi, A,x[51],dp[51][51][2501];
string s;
ll ave(ll a, ll b, ll c) {//aまででb枚とって合計c
	if (dp[a][b][c] >= 0)return dp[a][b][c] = dp[a][b][c];
	if (a == 0 && b == 0 && c == 0)return 1;
	if (a > 0 && c < x[a]) return dp[a][b][c]= ave(a - 1, b, c);
	
	if (a > 0 && b>0&&c >= x[a]) return dp[a][b][c] = ave(a - 1, b, c) + ave(a - 1, b-1, c - x[a]);
	return dp[a][b][c] = 0;
}
int main() {
	cin >> N >> A;

	for (int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < N+1; i++) {
		for (int j = 0; j < N+1; j++) {
			for (int k = 0; k < 2501; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += ave(N, i, i*A);
	}
		cout << ans << endl;
						return 0;

}

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

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

	int n, cnt = 0, x;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> x;
		if (x & 1 && i & 1) ++cnt;
	}

	cout << cnt;
	return 0;
}


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

int main()
{
    long long int x;
    cin >> x;
    bitset<32> b(x);

    cout << b << endl
         << ~b << endl
         << (b << 1) << endl
         << (b >> 1) << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;

long n;
char str0[200005];
char str1[200005];

bool solve( long w, long s0, char l, char r )
{
    long lim[2]={0, w+1};
    long i;
    for(i=n-1; i>=0; i--) {
        if(i<n-1) {
            if(str1[i]==l) {
                lim[1]=MIN(lim[1]+1,w+1);
            }
            if(str1[i]==r) {
                lim[0]=MAX(lim[0]-1,0);
            }
        }

        if(str0[i]==r) {
            lim[1]--;
        }
        if(str0[i]==l) {
            lim[0]++;
        }
        //printf("[%ld]%ld,%ld\n", i, lim[0],lim[1]);
        
        if(lim[0]+1>=lim[1]) {
            return false;
        }
        if(i==0) {
            if(s0<=lim[0] || s0>=lim[1]) {
                return false;
            }
        }
    }

    return true;
}

int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld%ld%ld", &h, &w, &n);

    long s0, s1;
    scanf("%ld%ld", &s0, &s1);
    scanf("%s", str0);
    scanf("%s", str1);

    if( !solve( w, s1, 'L', 'R') ) {
        printf("NO\n"); return 0;
    }

    if( !solve( h, s0, 'U', 'D') ) {
        printf("NO\n"); return 0;
    }

    printf("YES\n");
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }else if (a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll gg=gcd(a,b);
    ll k=a*b;
    gg=k/gg;
    cout<<gg<<endl;
    return 0;

}


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

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

    map< string , int >mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    while (n--) {
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;


    return 0;
}



Measured memory_bytes: 3632
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] abc = ReadIntArray();
    Console.WriteLine(abc.All(i => i == abc[0]) ? "Yes" : "No");
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13396
/*...................bismillahir rahmanir rahim.....................*/
#include<bits/stdc++.h>

#define m_p make_pair
#define PB push_back
#define FF first
#define SS second
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define PSS pair<string,string>
#define MX 1000007
#define MOD 1000000007
#define SI(a)({ ;scanf("%d",&a);a;})
#define SC(a)({ ;scanf("%c",&a);a;})
#define SL(a)({ ;scanf("%lld",&a);a;})
#define SD(a)({ ;scanf("%lf",&a);a;})
#define FI freopen("input.txt","r+",stdin);
#define FO freopen("output.txt","w+",stdout);
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

/*............start.............*/
int Set(int n,int pos){ return n=n | (1<<pos); }
int Reset(int n,int pos){ return n=n & ~(1<<pos); }
bool check(int n,int pos){ return (bool)(n & (1<<pos)); }

void solve()
{
    int n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    LL bit0[64]={0};
    // int bit1[64]={0};
    for(int i=0;i<n;i++)
    {

        for(int j=0;j<62;j++)
        {
            LL x=a[i];
            x=(x & (1LL<<j));
            if(x==0)bit0[j]++;
        }
    }
    // for(int i=0;i<62;i++)
    // {
    //     cout<<bit0[i]<<endl;
    // }
    // return;
    LL res=0;
    for(int i=0;i<62;i++)
    {
        // res=(res>>1)%MOD;
        LL x=( ( bit0[i]*(n-bit0[i]) ) )%MOD;
        // cout<<x<<" "<<res<<endl;
        // x=(x<<i);
        // x=(x%MOD);
        for(int j=0;j<i;j++)
        {
            x=x<<1;
            x=(x%MOD);
        }
        res=(res+x)%MOD;
    }
    cout<<(res)<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int q=1;
    // cin>>q;
    for(int kase=1;kase<=q;kase++)
    {
        //cout<<"Case "<<kase<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

using namespace std;

int main()
{
	fast
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(c-(a-b),0);
}


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

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Dictionary<int, int> count = new Dictionary<int, int>();
        foreach (var i in a)
        {
            if (count.ContainsKey(i))
            {
                count[i]++;
            }
            else
            {
                count.Add(i, 1);
            }
        }
        long res = 0;
        foreach (var i in count)
        {
            if (i.Key > i.Value)
            {
                res += i.Value;
            }
            else
            {
                res += i.Value - i.Key;
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 26720
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

s = input()

ans = "consonant"

if s == "a" or s == "e" or s == "i" or s =="o" or s=="u":
    ans = "vowel"
print(ans)


Measured memory_bytes: 9096
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
dct = Counter(a)
ans = 0
mod = 10**9+7

if n%2 == 0:
    r = range(1,n,2)
else:
    if dct[0] != 1:
        print(ans)
        exit()
    r = range(2,n,2)

for i in r:
    if dct[i] != 2:
        print(ans)
        exit()

ans = 2**(n//2)
print(ans%mod)

Measured memory_bytes: 14820
H=int(input())
#0bを除く
N=len(bin(H))-2

count=0
if sum(list(map(int, bin(16)[3:])))==0:
  for i in range(N):
    count+=2**i
else:
  N=N+1
  for i in range(N):
    count+=2**i
    
print(count)

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

int n, r = 0, g = 0, b = 0, evens = 0;
string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            r++;
        }
        if (s[i] == 'G')
        {
            g++;
        }
        if (s[i] == 'B')
        {
            b++;
        }
    }

    for (int spacing = 1; 2 * spacing < n; spacing++)
    {
        int i = 0, j = 1 * spacing, k = 2 * spacing;
        while (k < n)
        {
            if (s[i] + s[j] + s[k] == 'R' + 'G' + 'B')
            {
                evens++;
            }
            i++;
            j++;
            k++;
        }
    }

    cout << (long long)r * (long long)g * (long long)b - (long long)evens;
    cin >> n;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cmath>
using namespace std;
#define df 0

long int sum(long int b,long int n){
  if(df)printf("base: %ld",b);
  long int s=0;
  while(n){
    s+=n%b;
    n/=b;
  }
  if(df)printf("->%ld\n",s);
  return s;
}

int main(){
  if(df) printf("*debug mode*\n");
  long int n,s; cin >> n >> s;
   if(n==s){
    cout << n+1;
    return 0;
   }else if(n<s){
     cout << -1;
     return 0;
   }
  long int limit=sqrt(n-s)+1;
  if(df)printf("%ld",limit);
  long int ans=-1;
  for(long int i=1;i<=limit;i++){
    if((n-s)%i)continue;
    if(sum(i+1,n)==s){
      ans=i+1;
      break;
    }
    if(sum((n-s)/i+1,n)==s)
      ans=(n-s)/i+1;
  }
  cout << ans;
}

/// confirm df==0 ///


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

int mp[5] { 12, 0, 17, 2, 7 };

int main() {
  int N; cin >> N;
  vector<int> c(5);
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    int n { s[0] - 'A' };
    for (int j = 0; j < 5; j++) {
      if (mp[j] == n) c[j]++;
    }
  }
  sort(begin(c), end(c), greater<int>());
  ll ans {};
  for (int i = 0; i < (1 << 5); i++) {
    int s {};
    for (int j = 0; j < 5; j++) if (i >> (4 - j) & 1) s++;
    if (s != 3) continue;
    ll p { 1 };
    for (int j = 0; j < 5; j++) {
      if (i >> (4 - j) & 1) p *= c[j];
    }
    ans += p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w == 0 && h == 0) break;
			Map m = new Map(w, h);
			
			Point p;
			LinkedList<Point> l = new LinkedList<Point>();
			while (true){
				p = m.searchI();
				if (p.getX() == w+1 && p.getY() == h+1) break;
				l.add(p);
				while (!l.isEmpty()) {
					p = l.pollFirst();
					l.addAll(m.getNearF(p));
				}
			}
			System.out.println(m.getI());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	int[] dx = {-1,0,1,1,1,0,-1,-1};
	int[] dy = {-1,-1,-1,0,1,1,1,0};
	class Map{
		int name = 0;
		int w,h;
		int[][] m;
		
		Map (int w,int h) {
			this.w = w;
			this.h = h;
			m = new int[h+2][w+2];
			for (int i=0;i<h+2;i++) {
				for (int j=0;j<w+2;j++)
					m[i][j] = 0;
			}
			for (int i=1;i<=h;i++) {
				for (int j=1;j<=w;j++) {
					m[i][j] = sc.nextInt();
				}
			}
		}
		
		LinkedList<Point> getNearF(Point p) {
			LinkedList<Point> l = new LinkedList<Point>();
			for (int i=0;i<8;i++) {
				if (m[p.getY()+dy[i]][p.getX()+dx[i]] == 1) {
					l.add(new Point(p.getX()+dx[i],p.getY()+dy[i]));
					m[p.getY()+dy[i]][p.getX()+dx[i]] = 1+name;
					
				}
			}
			
			return l;
		}
		
		Point searchI() {
		//	printMap();
			name ++;
			for (int i=1;i<=h;i++) {
				for (int j=1;j<=w;j++) {
					if (m[i][j] == 1 ) {
						m[i][j] = 1+name;
						return (new Point(j,i));
					}
				}
			}
			return (new Point(w+1,h+1));
		}
		
		void printMap() {
			for (int i=0;i<w+2;i++) {
				for (int j=0;j<h+2;j++)
					System.out.print(m[j][i] + " " );
				System.out.println();
			}
		}
		
		int getI() {
			return name-1;
		}
		
	}
	class Point {
		int x;
		int y;
		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
		int getX() {
			return x;
		}
		int getY() {
			return y;
		}
	}
	
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;



int main(){
    string s;
    cin >> s;
    int N = (int)s.length();

    vector<char> remain;
    int res = 0;
    for(int i = 0; i < N; i++){
        if(remain.empty()){
            remain.push_back(s[i]);
        }
        else{
            auto itr = remain.end();
            itr--;
            if(*itr != s[i]){
                res += 2;
                remain.pop_back();
            }
            else{
                remain.push_back(s[i]);
            }
        }
    }

    cout << res << endl;



    return 0;
}


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

long long cake[3][1005]={0};
long long sum[1005];
vector<long long> x;
long long dp[4][1001][1001]={0};

long long n,m;

int main(){
  long long i,j,k,l,ans=0,sumc=0,count=0,a,b,c;
  cin >> n >> m;
  for(i=1;i<=n;i++){
    cin >> cake[0][i] >> cake[1][i] >> cake[2][i];    
  }
  for(a=0;a<2;a++){
    for(i=1;i<=n;i++)cake[0][i]*=-1;
    for(b=1;b<=2;b++){
      for(i=1;i<=n;i++)cake[1][i]*=-1;
      for(c=1;c<=2;c++){
	for(i=1;i<=n;i++)cake[2][i]*=-1;
	for(i=1;i<=n;i++)sum[i]=cake[0][i]+cake[1][i]+cake[2][i];
	for(i=1;i<=n;i++)x.push_back(cake[0][i]+cake[1][i]+cake[2][i]);
	sort(x.begin(),x.end());
	sumc=0;

	for(i=0;i<m;i++)sumc+=x[n-i-1];
	if(ans<sumc)ans = sumc;
	for(i=0;i<n;i++)x.pop_back();
      }
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int n,used[51][51],day[51][32];

int solve(){
  vector <int> l;
  for(int i=1;i<=30;i++){
    l.clear();
    for(int j=0;j<n;j++)if(day[j][i]==1)l.push_back(j);
    int a[51] = {};  
    for(int j=0;j<l.size();j++)
      for(int k=0;k<n;k++) a[k] = (a[k] | used[l[j]][k]);
    
    for(int j=0;j<l.size();j++){
      for(int k=0;k<n;k++) used[l[j]][k] = a[k];
      for(int k=j+1;k<l.size();k++) used[l[j]][l[k]]=used[l[k]][l[j]]=1;
      int cnt=0;
      while(cnt<n && used[l[j]][cnt]==1)cnt++;
      if(cnt==n)return i;
    }
  }
  return -1;
}

int main(){
  while(1){
    cin >> n;
    if(n==0)break;
    memset(used,0,sizeof(used));
    memset(day,0,sizeof(day));
    for(int i=0;i<n;i++){
      used[i][i]=1;
      int a,b;
      cin>>a;
      while(a--)cin>>b,day[i][b]=1;
    }
    cout << solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long

void solve() {
	string s1, s2;
	cin >> s1 >> s2;
	int m = s1.size();
	int n = s2.size();
	int dp[m + 1][n + 1];
	int i, j;
	for (i = 0; i <= m; i++) {
		for (j = 0; j <= n; j++) {
			if (i == 0 || j == 0)dp[i][j] = 0;
			else if (s1[i - 1] == s2[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	// cout << dp[m][n] << endl;

	string str = "";
	i = m;
	j = n;

	while (i > 0 && j > 0) {
		if (s1[i - 1] == s2[j - 1]) {
			str += s1[i - 1];
			i--;
			j--;
		}
		else {
			if (dp[i - 1][j] > dp[i][j - 1])i--;
			else j--;
		}
	}

	reverse(str.begin(), str.end());
	cout << str << endl;
	return;
}

int32_t main() {

	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	while (t--)solve();
	return 0;
}

Measured memory_bytes: 73916