akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
using namespace std;

int main(int argc, char *argv[]){
    int n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    cin >> n;
    string s;
    for(int i=0;i<n;i++){
        cin >>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;  
        else if(s=="TLE") tle++;  
        else if(s=="RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3628
def is_month(value):
    return 1 <= value and value <= 12

S = input()
A = is_month(int(S[:2]))
B = is_month(int(S[2:]))


if A:
    if B:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if B:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    ll a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int ans = 0;
    if(a == 0) ans = 1;
    else if(b == 0) ans = 2;
    else if(c == 0) ans = 3;
    else if(d == 0) ans = 4;
    else if(e == 0) ans = 5;


    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int n;

int co_graph[MAX_N];

vector<pair<int, int>> ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  if (n % 2 == 0) {
    for (int i = 1; i <= n / 2; ++i) {
      co_graph[i] = n - (i - 1);
      co_graph[n - (i - 1)] = i;
    }

  } else {
    for (int i = 1; i <= (n - 1) / 2; ++i) {
      co_graph[i] = n - i;
      co_graph[n - i] = i;
    }
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (i == j) continue;
      if (co_graph[i] == j) continue;

      ans.push_back(make_pair(i, j));
    }
  }

  printf("%d\n", ans.size());

  for (auto &e: ans) {
    printf("%d %d\n", e.first, e.second);
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    ll n,t;
    cin >> n >> t;
    ll sum = 0;
    vector<ll> time(n,0);
    rep(i,n){
        cin >> time.at(i);
        if(i == 0){
            sum += t;
        }else{
            //前が途切れた
            if(t < (time.at(i) - time.at(i-1))){
                sum += t;
            }else{
                sum += t;
                sum -= t -( time.at(i) - time.at(i-1));
            }
        }
    }
    cout << sum << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1792
import heapq

X, Y, Z, K = [int(v) for v in input().split()]
A = sorted([int(v) for v in input().split()], reverse=True)
B = sorted([int(v) for v in input().split()], reverse=True)
C = sorted([int(v) for v in input().split()], reverse=True)

added = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
added.add((0, 0, 0))
for i in range(K):
    cost, ai, bi, ci = heapq.heappop(h)
    print(-cost)

    if ai + 1 < X:
        na = (ai + 1, bi, ci)
        if not na in added:
            heapq.heappush(h, (-(A[ai + 1] + B[bi] + C[ci]),) + na)
            added.add(na)
    if bi + 1 < Y:
        nb = (ai, bi + 1, ci)
        if not nb in added:
            heapq.heappush(h, (-(A[ai] + B[bi + 1] + C[ci]),) + nb)
            added.add(nb)
    if ci + 1 < Z:
        nc = (ai, bi, ci + 1)
        if not nc in added:
            heapq.heappush(h, (-(A[ai] + B[bi] + C[ci + 1]),) + nc)
            added.add(nc)

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int flag=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
    {
      flag=1;
      break;
    }
  }
  if(flag==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
class Dijkstra{
public:
    struct edge{ll to,cost;};
    typedef pair<ll,ll> P;//firstは最短距離、secondは頂点の番号

    int V;//超点数
    vector<vector<edge> > G;//グラフ,G[i]はiから出る辺の集合,G[i][j]はiから出る辺のj番目の辺
    vector<ll> d; //最短距離

    //0origin
    Dijkstra(int N){
        V = N;
        G = vector<vector<edge> >(N);
        d = vector<ll>(N);
    };

    void dijkstra(int s){
        priority_queue<P,vector<P>,greater<P> > que;
        fill(d.begin(),d.end(),INFl);
        d[s] = 0;
        que.push(P(0,s));

        while(!que.empty()){
            P p = que.top();que.pop();
            ll v = p.second;
            if(d[v] < p.first) continue;
            for(int i = 0; i < G[v].size(); i++){
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost && !(d[e.to] == INFl && d[v] == INFl)) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }

    }
    /* 頂点fromに頂点toに達するコストcostの辺を貼る */
    void addEdge(int from,int to,int cost){
        edge e;
        e.to = to;
        e.cost = cost;
        G[from].push_back(e);
    }
};


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

    int N,M;
    cin >> N >> M;
    int s,t;
    cin >> s >> t;
    Dijkstra dij(N + 1);

    rep(i,0,M){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        dij.addEdge(a,b,d);
        dij.addEdge(b,c,d);
        dij.addEdge(a,c,d);

        dij.addEdge(b,a,d);
        dij.addEdge(c,b,d);
        dij.addEdge(c,a,d);
    }
    dij.dijkstra(s);
    cout << dij.d[t] << endl;
//    rep(i,0,N + 1){
//        cout << dij.d[i] << endl;
//    }


    return 0;
}



Measured memory_bytes: 23644
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,m;
long long x[100006];
long long k;
long long ans;
long long del[100006];
int main()
{
	cin>>n>>m;
	k=m-n;
	rep(i,m)
	{
		cin>>x[i];
	}
	sort(x,x+m);
	if(n>=m)
	{
		cout<<0<<endl;
		return 0;
	}
	rep(i,m-1)del[i]=x[i+1]-x[i];
	sort(del,del+m-1);
	rep(i,k)
	{
		ans+=del[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  string S,T;
  cin >> S >> T;
  int a = S.size();
  int b = 0;
  for(int i=0; i<a; i++){
    if(S[i] != T[i]) b++;
  }
  cout << b << endl;
  return 0;
} 

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

int main(){
  int x, y; cin >> x >> y;
  int a, b;
  bool can = false;
  if(y%2==0){
    a = 2*x-y/2;
    b = -x + y/2;
    if(0<=a && a<=x && 0<=b && b<=x) can = true;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3588
def main():
    N, K, Q = map(int, input().split())
    A = [int(input())-1 for _ in range(Q)]

    lives = [0 for _ in range(N)]

    for i in range(Q):
        lives[A[i]] += 1

    for i in range(N):
        if K - Q + lives[i] > 0:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 8604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll=pair<ll,ll>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) //a/bの除算の切り上げ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = acos(-1);
 
//a^b=b^a
//a^(b^c)=(a^b)^c
//a^a=0
//a+b=a^b + 2(a&b)
//(4a)^(4a+1)^(4a+2)^(4a+3)=0
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_),siz(sz_, 1LL){
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
   }
   void init(ll sz_){
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x){ // 根の検索
      while (par[x]!=x){
           x=par[x]=par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y){
       x=root(x);
       y=root(y);
       if (x==y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x]<siz[y]) swap(x, y);
       siz[x]+=siz[y];
       par[y]=x;
       return true;
  }
 
  bool same(ll x, ll y){ // 連結判定
       return root(x)==root(y);
  }
 
  ll size(ll x){ // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n){
   x=x%mod;
   if(n==0) return 1;
 
   else if(n%2==1){
       return (x*modpow(x, n-1))%mod;
   }
   else return modpow((x*x)%mod, n/2)%mod;
}
 
ll com(ll n, ll k){
   ll x=1;
   for(int i=n-k+1; i<=n; i++){
      x=x*i%mod;
   }
 
   ll y=1;
   for(int i=1; i<=k; i++){
       y=y*i%mod;
   }
   y=modpow(y,mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  }
 
   if(n%2==0 || n%3==0) return false;
 
   for(unsigned i = 5; i*i<=n; i+=6) {
       if(n%i==0) return false;
       if(n%(i+2)==0) return false;
   }
 
   return true;
}
 
int digsum(int n){
   int res=0;
   while(n > 0) {
       res+=n%10; //ここをres++;に変えたら桁数を求める関数になる,res+=n%10;なら格桁の和
       n/=10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i=1; i*i<=n; i++){
       if(n%i==0){
           ret.push_back(i);
           if(i*i!=n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n;
    cin >> n;
    vector<ll> cnt(n);
    for(ll i=1; i<=n; i++){
        for(ll j=i; j<=n; j+=i){
            cnt[j]++;
        }
    }
    ll ans=0;
    for(ll i=1; i<=n; i++){
        ans+=(i*cnt[i]);
    }

    cout << ans << endl;
}

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

ans_jpy = 0
ans_btc = 0
for i in range(N):
    x, u = map(str, input().split())
    if u == "JPY":
        ans_jpy += int(x)
    else:
        ans_btc += float(x)
    
print(ans_jpy + ans_btc*380000)


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

using namespace std;

const int MAX_N = 1e5 + 10;

int N, M;
vector<int> edge[MAX_N];
bool vis[MAX_N];

void No() {
    printf("No\n");
    exit(0);
}

void Yes() {
    printf("Yes\n");
    exit(0);
}

void dfs(int x, int pa, int s, int t, bool &succ) {
    if (vis[x]) return;
    vis[x] = true;
    bool met_pa = false;
    for (int i : edge[x]) {
        if (i == t) continue;
        if (i == pa) {
            if (!met_pa) {
                met_pa = true;
                continue;
            }
        }
        if (i == s) {
            succ = true;
            continue;
        }
        dfs(i, x, s, t, succ);
    }
}

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= M; i++) {
        int a, b; scanf("%d%d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for (int i = 1; i <= N; i++) {
        if (edge[i].size() & 1)
            No();
    }
    vector<int> key;
    for (int i = 1; i <= N; i++) {
        if (edge[i].size() >= 6) {
            Yes();
        }
        if (edge[i].size() >= 4) {
            key.push_back(i);
        }
    }
    if (key.size() > 2) {
        Yes();
    }
    if (key.size() < 2) {
        No();
    }
    int x = key[0], y = key[1];
    bool succ = false;
    dfs(x, 0, x, y, succ);
    if (succ) {
        Yes();
    } else {
        No();
    }
}


Measured memory_bytes: 7808
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskD {    
    int n, e, t;
    int[] x;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      e = in.nextInt();
      t = in.nextInt();
      x = new int[n + 1];
      for (int i = 1; i <= n; ++i)
        x[i] = in.nextInt();
      long[][] state = new long[3][n + 1];
      int ptr = 0;
      for (int i = 1; i <= n; ++i) {
        while (2 * (x[i] - x[ptr + 1]) > t)
          ++ptr;
        state[1][i] = ptr;
      }
      long min = Long.MAX_VALUE / 2;
      for (int i = 1; i <= n; ++i) {
        for (int j = (int) state[1][i - 1]; j < (int) state[1][i]; ++j)
          min = Math.min(min, state[0][j] - 2 * x[j + 1]);
        state[0][i] = Math.min(min + 2 * x[i], state[0][(int) state[1][i]] + t);
      }
      long ans = state[0][n] + e;
      out.println(ans);
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      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 String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 30132
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int a,b,c;
    cin>>a>>b>>c;

    if((a-b)>=c){
        c=0;
    }
    else{
        c-=(a-b);
    }
    
    cout<<c<<endl;
    return 0;
}


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    ll n; cin >> n;
    vll a; read(a, n, 0);

    vi u(20, 0);

    int i = 0, j = 0;
    ll ans = 0;
    ll num2 = 0;

    while (j < n) {
        ll k = 0;
        for (ll y = 1; y < ((ll)1<<20); y *= 2) {
            if (a[j]&y) {
                u[k]++;
                if (u[k] == 2)
                    num2++;
            }
            k++;
        }
        while (num2 > 0) {
            ll s = 0;
            for (ll y = 1; y < ((ll)1<<20); y*= 2) {
                if (a[i]&y) {
                    u[s]--;
                    if (u[s] == 1)
                        num2--;
                }
                s++;
            }
            i++;
        }
        ans += j - i + 1;
        j++;
    }
    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    rep(i, SZ(s)){
        if(i%2==0 && s[i] == 'L') pr(0);
        if(i%2==1 && s[i] == 'R') pr(0);
    }
    pr(1);
    return 0;
}

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

const int maxn = 1e5 + 10;
int n, l, r, q[maxn], vis[maxn];

vector <int> e[maxn];

int main() 
{
    cin>>n;
    for (int i = 1, u, v; i < n; i++) 
    {
        scanf("%d %d", &u, &v);
        e[u].push_back(v), e[v].push_back(u);
    }
    l = 1, r = 0;
    vis[1] = 1;
    vis[n] = 2;
    q[++r] = 1;
    q[++r] = n;
    for (; l <= r; ) 
    {
        int u = q[l++];
        for (int v : e[u]) 
        {
            if (!vis[v]) 
            {
                vis[v] = vis[u];
                q[++r] = v;
            }
        }
    }
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= n; i++) 
    {
        if (vis[i] == 1) 
        {
            sum1++;
        } 
        else 
        {
            sum2++;
        }
    }
    puts(sum1 > sum2 ? "Fennec" : "Snuke");
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
void solve(){
	ll n;
	cin>>n;
	ll res=1e18, ans=1;
	rep(i,0,n){
		ll x;
		cin>>x;
		if(x==0){
			res=1;
			ans=0;
			break;
		}
		res/=x;
		ans*=x;
	}
	if(res==0)ans=-1;
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

typedef long long ll;
typedef pair<ll,int> P;
ll const INF = INT64_MAX;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct edge {
    ll w;int u;int v;
    bool operator<(const edge& a) const {
        return w > a.w;
    }
};

struct SegmentTree {
private:
    int n;
    vector<P> node;
public:
    SegmentTree(vector<P> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,P(INF,-1));
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[2*i+1],node[2*i+2]);
    }
    void update(int x,P val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }

    P getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return P(INF,-1);
        if (a <= l && r <= b) return node[k];
        P vl = getmin(a,b,2*k+1,l,(l+r)/2);
        P vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

struct UnionFind {
private:
    vector<int> par,depth;
public:
    UnionFind (int n) {
        par.resize(n);
        depth = vector<int>(n,0);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (depth[x] < depth[y]) par[x] = y;
        else {
            par[y] = x;
            if (depth[x] == depth[y]) depth[x]++;
        }
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }
};


int main() {
    int n;
    ll d,ans = 0;
    cin >> n >> d;
    vector<ll> a(n);
    multimap<ll,int> b;
    priority_queue<edge> edgelist;
    SegmentTree segL(vector<P>(n,P(INF,-1))),segR(vector<P>(n,P(INF,-1)));
    UnionFind kruskal(n);
    
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) b.insert(P(a[i],i));

    for (auto it = b.begin();it != b.end();++it) {
        ll s = it->first;
        int i = it->second;
        P mnL = segL.getmin(0,i),mnR = segR.getmin(i,n);
        if (mnL.first < INF) {
            int j = mnL.second;
            edgelist.push(edge{a[i]+a[j]+(ll)(i-j)*d,i,j});
        }
        if (mnR.first < INF) {
            int j = mnR.second;
            edgelist.push(edge{a[i]+a[j]+(ll)(j-i)*d,i,j});
        }
        segL.update(i,P(a[i]+(ll)(n-i)*d,i));
        segR.update(i,P(a[i]+(ll)i*d,i));
    }

    while (!edgelist.empty()) {
        edge e = edgelist.top();edgelist.pop();
        if (kruskal.same(e.u,e.v)) continue;
        ans += e.w;
        kruskal.unite(e.u,e.v);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vll l(n+1), r(n+1);
  REP(i, n) {
    cin >> l[i] >> r[i];
  }
  sort(ALL(l));
  reverse(ALL(l));
  sort(ALL(r));

  ll ma = 0;
  ll now = 0;
  REP(i, n+1) {
    now += 2 * (l[i] - r[i]);
    chmax(ma, now);
  }
  cout << ma << endl;

}
























Measured memory_bytes: 1792
#include <iostream>

int main(int argc, char const* argv[])
{
	for (size_t i = 1; i < 10; i++)
		for (size_t j = 1; j < 10; j++)
			std::cout << i << "x" << j << "=" << i * j << std::endl;


	return 0;
}

Measured memory_bytes: 1112
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dictionary := make(map[string][]int)

	for {
		var word string
		var page int
		fmt.Scanf("%s %d", &word, &page)

		if word == "" || page == 0 {
			break
		}

		pages := dictionary[word]
		pages = append(pages, page)
		dictionary[word] = pages
	}

	words := make([]string, 0)
	for i := range dictionary {
		words = append(words, i)
	}

	sort.Strings(words)

	for _, v := range words {
		sort.Ints(dictionary[v])
		fmt.Println(v)
		for i, page := range dictionary[v] {
			if i == len(dictionary[v])-1 {
				fmt.Printf("%d\n", page)
			} else {
				fmt.Printf("%d ", page)
			}
		}
	}
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N;
    cin >> N;
    map<ll, ll> m;
    REP(i, N)
    {
        cin >> A[i];
        m[A[i]]++;
    }

    int sum = 0;
    REP(i, N)
    {
        if (m[A[i]] == A[i])
            continue;
        m[A[i]]--;
        sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 2e3 + 9;

in ans[maxn],jafoi[maxn],cur,jaja[maxn][maxn];
vector<in> g[maxn];

void bfs(in x){
    jafoi[x]=1;
    queue<in> q;
    q.push(x);
    while(!q.empty()){
        in agr = q.front(); q.pop();
        rep(i,0,sz(g[agr])){
            in u = g[agr][i];
            if(!jafoi[u]){
                q.push(u);
                jafoi[u]=jafoi[agr]+1;
                if(!jaja[u][x]){
                    ans[jafoi[u]-1]++;
                    jaja[u][x] = jaja[x][u] = 1;
                }
            }
        }
    }
}

int main(){
    IOS;
    in n,x,y;
    cin >> n >> x >> y;
    rep(i,1,n){
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    g[x].pb(y);
    g[y].pb(x);
    rep(i,1,n+1){
        memset(jafoi,0,sizeof(jafoi));
        bfs(i);
    }
    rep(i,1,n){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 31872
n, t = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=lambda x:x[0])

dp = [0]*(t+1)

for a, b in ab:
    tmp = dp[:]
    for i in range(t):
        if dp[i]+b > tmp[min(i+a, t)]:
            tmp[min(i+a, t)] = dp[i]+b
    dp = tmp
print(dp[-1])

Measured memory_bytes: 47064
N = int(input())
A = list(map(int,input().split()))
Color = [0]*9

for i in range(N):
  for j in range(9):
    if(j == 0):
      if(1<=A[i]<400): Color[j] = 1 
    elif(1<=j<=7):
       if(400*j<=A[i]<400*(j+1)):Color[j] = 1
    else:
       if(3200<=A[i]): Color[j] += 1
   

if(N == Color[-1]):
  ans_min = 1
  ans_max = N
else:
  ans_min = sum(Color) - Color[-1]
  ans_max = sum(Color) 
print(ans_min,ans_max)

Measured memory_bytes: 3064
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, Y;
    scan(N, Y);

    auto ans = solve(N, Y / 1000);
    writefln("%d %d %d", ans[0], ans[1], ans[2]);
}

long[3] solve(long N, long Y)
{
    if (Y == 0 && N == 0)
        return [0, 0, 0];
    if (0 == N)
        return [-1, -1, -1];
    if (Y < N || N * 10 < Y)
        return [-1, -1, -1];

    auto a = memoize!solve(N - 1, Y - 10);
    if (a[0] != -1)
    {
        a[0]++;
        return a;
    }
    auto b = memoize!solve(N - 1, Y - 5);
    if (b[0] != -1)
    {
        b[1]++;
        return b;
    }
    auto c = memoize!solve(N - 1, Y - 1);
    if (c[0] != -1)
    {
        c[2]++;
        return c;
    }
    return [-1, -1, -1];
}


Measured memory_bytes: 9084
#include<iostream>

using namespace std;

struct Card{
  char suit,value;
};


void bubble (struct Card A[] ,int N){
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=i;j--){
      if(A[j].value<A[j-1].value){
      Card t=A[j];
      A[j]=A[j-1];
      A[j-1]=t;
      }
    }
  }
}



void sele(struct Card A[] ,int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j].value<A[minj].value)
        minj=j;
    }
    Card t=A[i];
    A[i]=A[minj];
    A[minj]=t;
  }
}


void print(struct Card A[],int N){
  for(int i=0;i<N;i++){
    if(i>0)
        cout<<" ";
    cout<<A[i].suit<<A[i].value;
  }
  cout<<endl;
}

bool is(struct Card C1[],struct Card C2[],int N){
  for(int i=0;i<N;i++){
    if(C1[i].suit!=C2[i].suit)
       return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N;
  char ch;

  cin>>N;
  for(int i=0;i<N;i++){
    cin>>C1[i].suit>>C1[i].value;
  }

  for(int i=0;i<N;i++)
    C2[i]=C1[i];

  bubble(C1,N);
  sele(C2,N);

  print(C1,N);
  cout<<"Stable"<<endl;

 print(C2,N);
  if(is(C1,C2,N)){
     cout<<"Stable"<<endl;
   }
  else{
     cout<<"Not stable"<<endl;
   }
  return 0;
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        long ans = 0L;
        if (n >= 44) {//1以外ありえない
            System.out.println(1);
            return;
        } else if (n >= 26) {//2か1以外ありえない
            long a = pow(2, n);
            if (a <= p && p % a == 0) {
                System.out.println(2);
            } else {
                System.out.println(1);
            }
            return;
        } else if (n == 1) {
            System.out.println(p);
            return;
        }
        for (long i = 1; ; i++) {
            long a = pow(i, n);
            if (a <= p) {
                if (p % a == 0) {
                    ans = i;
                }
            } else {
                System.out.println(ans);
                return;
            }
        }
    }

    public static long pow(long base, long n) {
        if (base == 1L) return 1L;
        long retV = 1L;
        for (long i = 0; i < n; i++) {
            retV *= base;
        }
        return retV;
    }
}

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

#define MAX_N 11
#define MAX_Q 51

struct que {
    int a, b, c, d;
};

int N, M, q, A[MAX_N], ans = 0;
que Q[MAX_Q];

int compute(int A[],que Q[]){
    int ans = 0;
    for (int i = 1; i <= q; i++){
        if(A[Q[i].b] - A[Q[i].a] == Q[i].c) ans += Q[i].d;
    }
    return ans;
}

int solve(int A[]) {
    if (A[1] == M) {
        ans = max(ans, compute(A, Q));
        return ans;
    }
    int i = 1;
    while(A[i] != M && i <= N) i++;
    if (i == N + 1) {
        A[N]++;
        ans = max(ans, compute(A, Q));
        return solve(A);
    }
    A[i - 1]++;
    for (int j = i; j <= N; j++){
        A[j] = A[i - 1];
    }
    ans = max(ans, compute(A, Q));
    return solve(A);
}

int main(){
    cin >> N >> M >> q;
    for (int i = 1; i <= q; i++){
        cin >> Q[i].a >> Q[i].b >> Q[i].c >> Q[i].d;
    }
    for(int i = 1; i <= N; i++){
        A[i] = 1;
    }
    cout << solve(A) << endl;
    return 0;
}

Measured memory_bytes: 3600
n=gets.to_i
N=n*(n+1)/2
a=gets.split.map(&:to_i)
sum=a.inject(:+)
if sum%N!=0
    puts "NO"
    exit
end
d=[]
n.times do |i|
    d[i]=a[(i+1)%n]-a[i]-sum/N
end

if d.all?{|x| x<=0 && x%n==0}
    puts "YES"
else
    puts "NO"
end


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

using namespace std;

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

#define int ll

main(){
	int a,b;

	cin >> a >> b;
	int ans = 0;
	if(a==1) ans+= 300000;
	if(b==1) ans+= 300000;
	if(a==2) ans+= 200000;
	if(b==2) ans+= 200000;
	if(a==3) ans+= 100000;
	if(b==3) ans+= 100000;
	if(a==1&&b==1) ans += 400000;
  
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if(abs(a-b)<=d && abs(b-c)<=d){
		cout << "Yes" << endl;
		return 0;
	}else if(abs(a-c)<=d){
		cout << "Yes" << endl;
		return 0;

	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  
  bool a = A>0 && A<10;
  bool b = B>0 && B<10;
  
  if(a && b) cout << A*B << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

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

    if (k >= n) {
        print(0);
        return 0;
    }

    vector<ll> hp(n);
    rep2(i, n) cin(hp[i]);

    sort(hp.begin(), hp.end(), greater<ll>());

    ll result = 0;
    rep3(i, k, n) {
        result += hp[i];
    }

    print(result);
    return 0;
}

Measured memory_bytes: 1792
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

int r , b , g ;
void solve(){
	int n ;
	string s ;
	cin >> n>> s ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == 'R') r++ ;
		else if(s[i] == 'B') b++ ;
		else g++ ;
	}
	int ans = r*b*g ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 1 ; j <= n ; j++){
			if(i-j<0 || i+j>=n) continue ;
			int left = max(0LL,i-j) ;
			int right = min(n-1,i+j) ;
			if(s[left]!= s[i] && s[i]!= s[right] && s[right]!= s[left]) ans-- ;
		}
	}
	cout << ans ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 3656
import sys
N=input()
i = 1
for i in range(1,N+1):
    if (i % 3) == 0 :
        sys.stdout.write(" ")
        sys.stdout.write("%d" % i)
    else:
        if (i % 10 ) == 3 :
            sys.stdout.write(' ')
            sys.stdout.write("%d" % i)
        else:
            if (i/10)%10 == 3:
                #print (i/10)%10,"a"
                sys.stdout.write(' ')
                sys.stdout.write("%d" % i)
            else:
                if (i/100)%10 == 3:
                    sys.stdout.write(' ')
                    sys.stdout.write("%d" % i)
                else:
                    if (i/100)%10 == 3:
                        sys.stdout.write(' ')
                        sys.stdout.write("%d" % i)
                    else:
                        if(i/1000)%10 == 3:
                            sys.stdout.write(' ')
                            sys.stdout.write("%d" % i)
print ""

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

int main(){
  int n;
  cin >> n;
  int memo[100010];
  map<string, int> seibetu;
  seibetu["Male"] = 0;
  seibetu["Female"] = 1;
  string fin = "Vacant";

  int next;
  string cpu;
  cout << 0 << endl;
  cin >> cpu;
  if(cpu == fin) return 0;
  next = seibetu[cpu];
  for(int i = 0;i < n;i++){
    memo[i] = next;
    next = (next+1)%2;
  }

  int left = 0, right = n;
  int mid;
  while(1){
    mid = (left + right)/2;
    cout << mid << endl;
    cin >> cpu;
    if(cpu == fin) return 0;
    if(seibetu[cpu] == memo[mid]){
      left = mid;
    }else{
      right = mid;
    }
  }
}



Measured memory_bytes: 1236
s = input()
mod = 1000000007
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
k = 1
for i in range(n):
    t = 0
    for j in range(10):
        if s[n-i-1]=="?":
            for l in range(13):
                dp[i+1][(l+t)%13]+=dp[i][l]
                dp[i+1][(l+t)%13]%=mod
        elif int(s[n-i-1])==j:
            for l in range(13):
                dp[i+1][(l+t)%13]+=dp[i][l]
                dp[i+1][(l+t)%13]%=mod
        t+=k
        t%=13
    k=t
print(dp[n][5])

Measured memory_bytes: 62056
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;
using ull = unsigned long long;
//constexpr ll N = 2e5;
//ll a[N];

//constexpr int max = 2147483647;


int main()
{
	ll x;
	cin >> x;
	ll d = 100;
	
	int i = 0;
	while (true)
	{
		d = d + 0.01 * d;
		i++;
		if (d >= x)
			break;
	
	}
		
	cout << i;
	
	
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll div=n,rem=0;
    string s;
    char c;

    while(1)
    {
        rem=(div-1)%26;
        div=(div-1)/26;
        char c;
        c=(char)(97+rem);
        s.push_back(c);
        if (div==0)
        {
            break;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    string s;
    bool tester=true;
    cin>>s;
    int n=s.size();
    rep(i,n){
        if(i%2==0 && s[i]=='L') tester=false;
        if(i%2==1 && s[i]=='R') tester=false;
    }
    cout<<(tester? "Yes": "No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,m,l;
  int a[101][101]={{0}};
  int b[101][101]={{0}};
  long c[101][101]={{0}};
  scanf("%d%d%d",&n,&m,&l);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      scanf("%d",&b[i][j]);
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int h=0;h<m;h++){
        c[i][j]+=a[i][h]*b[h][j];
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j!=0){
        printf(" ");
      }
      printf("%ld",c[i][j]);
    }
    printf("\n");
  }
  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a<10 && b<10) {
        cout << a*b << endl;
    }
    else    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = r[0];
            var A = r[1];
            var B = r[2];
            int ret = 0;
            for (int i = 1; i <= N; i++)
            {
                var tmp = 0;
                var val = i.ToString();
                for (int j = 0; j < val.Length; j++)
                {
                    tmp += int.Parse(val[j].ToString());
                }

                if (tmp >= A && tmp <= B)
                {
                    ret += i;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
N,M=map(int,input().split())

import heapq
def dijkstra_heap(s):
  #始点sから各頂点への最短距離と直前の点
  dist=[float("inf")]*size_v
  prev=[-1]*size_v
  used=[False]*size_v
  #used=set()
  dist[s]=0
  used[s]=True
  #used.add(s)

  hq_edge=[]
  for v,w in graph[s]:
    heapq.heappush(hq_edge,(w,v,s))

  while hq_edge:
    min_w,min_v,u=heapq.heappop(hq_edge)
    #まだ使われてない頂点の中から最小の距離のものを探す
    if used[min_v]:
    #if min_v in used:
      continue

    dist[min_v]=min_w
    prev[min_v]=u
    used[min_v]=True
    #used.add(min_v)
    for v,w in graph[min_v]:
      if not used[v]: 
      #if not v in used:
        heapq.heappush(hq_edge,(min_w+w,v,min_v))

  return dist,prev

size_v=N+1
s=1

graph=[[] for _ in range(size_v)]
for i in range(2,N):
  graph[i].append((i-1,0))
for _ in range(M):
  L,R,C=map(int,input().split())
  graph[L].append((R,C))
  
dist,prev=dijkstra_heap(s)
#print(dist)
if dist[N]==float("inf"):
  print(-1)
else:
  print(dist[N])

Measured memory_bytes: 51000
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,i,c=0;
    cin>>n;
    vector<ll>v(n);
    for(i=0;i<n;i++)
        {
            cin>>v[i];
            if(i%2==0)
            {
                if(v[i]%2)
                    c++;
            }
        }
        cout<<c<<endl;

}



Measured memory_bytes: 3588