akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    cout << (2000 - X - 1) / 200 + 1 << endl;
    return 0;
}

Measured memory_bytes: 3644
// https://atcoder.jp/contests/aising2020/tasks/aising2020_a

use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! { l: usize, r: usize, d: usize, }
    let mut ans = 0;
    for x in l..=r {
        if x % d == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll N;
    cin >> N;
    ll K=0;
    vector<ll> a(N,0);
    for(ll i=0;i<N;i++){
        cin>>a[i]
    ;}
    sort(a.begin(), a.end());
    while(a[N-1]>=N){
        ll t=(a[N-1]-N+1)/N;
        a[N-1]-=t*N;
        if(a[N-1]>=N){a[N-1]-=N;t++;};
        K+=t;
        for(ll i=0;i<N-1;i++){
            a[i]+=t;;}
        sort(a.begin(), a.end());
    }
    cout<<K<<endl;
    return 0;
}


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

int main() {
    int p, q, r;
    while (cin >> p >> q >> r) {
        set<int> possible;
        for (int i = 1; i <= 10; i++) possible.insert(i);
        possible.erase(p);
        possible.erase(q);
        possible.erase(r);
        int under = 20 - p - q;
        int count = 0;
        for (set<int>::iterator i = possible.begin(); i != possible.end(); i++) {
            if (*i <= under) count++;
        }
        if (count / 7.0 > 0.50) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }
    return 0;
}

Measured memory_bytes: 0
N, Y = [int(i) for i in input().split()]
flag = False
for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z
        if total == Y:
            flag = True
            print('{} {} {}'.format(x,y,z))
            break
    if flag:
        break
if not flag:
    print('-1 -1 -1')

Measured memory_bytes: 3064
import sys

h, n = list(map(int, input().split()))
INF = 10 ** 18
dp = [INF] * (20201)
dp[0] = 0
for line in sys.stdin:
    a, b = map(int, line.split())
    for i in range(10000):
        if dp[i] == INF:
            continue
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))


Measured memory_bytes: 41948
# coding: utf-8
import numpy as np
from functools import lru_cache
import time,math

def main(): 
    if True:
        N,K = list(map(int, input().split()))
    else:
        N = 10**5
        K = 10**5
        N = 3
        K = 10


    sum = 0
    for n in range(N):
        #print((2**math.ceil(math.log2(K/(n+1))))*N)
        if n+1 >= K:
            sum += 1/N
        else:
            sum += 1/((2**math.ceil(math.log2(K/(n+1))))*N)


    print(sum)
if __name__ =='__main__':
    main()

Measured memory_bytes: 12504
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

#[derive(Clone, Copy)]
pub struct Point {
    pub x: isize,
    pub y: isize,
}

fn cross3(p0: Point, p1: Point, p2: Point) -> isize {
    (p2.x - p0.x) * (p1.y - p0.y) - (p1.x - p0.x) * (p2.y - p0.y)
}

fn graham_scan(points: &[Point]) -> Vec<usize> {
    let n = points.len();
    if n == 1 {
        return vec![0];
    }

    let mut indices = (0..n).collect::<Vec<_>>();
    indices.sort_by_key(|&i| (points[i].x, points[i].y));

    let mut upper = vec![];
    for &k in &indices {
        while upper.len() >= 2
            && cross3(
                points[upper[upper.len() - 2]],
                points[upper[upper.len() - 1]],
                points[k],
            ) <= 0
        {
            upper.pop();
        }
        upper.push(k);
    }

    let mut lower = vec![];
    for &k in &indices {
        while lower.len() >= 2
            && cross3(
                points[lower[lower.len() - 2]],
                points[lower[lower.len() - 1]],
                points[k],
            ) >= 0
        {
            lower.pop();
        }
        lower.push(k);
    }

    lower.reverse();
    upper.pop();
    lower.pop();
    for &k in &lower {
        upper.push(k);
    }
    upper
}

fn dist(i: usize, j: usize, xy: &Vec<(isize, isize)>) -> isize {
    let (x1, y1) = xy[i];
    let (x2, y2) = xy[j];
    (x1 - x2).abs() + (y1 - y2).abs()
}

fn main() {
    input! {
        n: usize,
        xy: [(isize, isize); n],
    }

    let points = xy
        .iter()
        .map(|&(x, y)| Point { x, y })
        .collect::<Vec<Point>>();
    let ch = graham_scan(&points);

    let mut p = vec![];
    for &i in &ch {
        debug!(xy[i]);
        p.push(i);
    }
    for &i in &ch {
        p.push(i);
    }
    debug!(p);

    let mut result = 0;
    let mut l = 0;
    for k in 0..ch.len() {
        if l < k {
            l = k;
        }
        let mut d0 = dist(p[k], p[l], &xy);
        let d = loop {
            if l + 1 >= p.len() {
                break d0;
            }
            let d = dist(p[k], p[l + 1], &xy);
            // debug!(k, l + 1);
            // debug!(xy[p[k]], xy[p[l + 1]]);
            // debug!(p[k], p[l + 1], d, d0);
            if d <= d0 {
                if l > k {
                    l -= 1;
                }
                break d0;
            }
            l += 1;
            d0 = d;
        };
        // debug!(d);
        result = max(result, d);
    }
    println!("{}", result);
}


Measured memory_bytes: 14508
import itertools

s = 'ACGT'
s = [a+b+c for a,b,c in itertools.product(s,s,s)]
n = {s_:1 for s_ in s}
n['AGC'] = 0
n['GAC'] = 0
n['ACG'] = 0

N = int(input())
if N == 3:
    count = n
else:
    for i in range(N-3):
        count = {s_:0 for s_ in s}
        for _ in s:
            for a in 'ACGT':
                x = _+a
                if 'GAC' in x or 'ACG' in x or ('A' == x[0] and 'GC' == x[2:]) or ('AG' == x[:2] and 'C' == x[3]):
                    pass
                else:
                    count[x[1:]] += n[_]
        count['AGC'] = 0
        count['GAC'] = 0
        count['ACG'] = 0
        n = count
print(sum([value for value in count.values()])%(10**9+7))

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

#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"
#define endd "\n"; return 0;
#define all(v) v.begin(), v.end()

using namespace std;

const int MAXN = 1e5;
const int INF = 1e10;
const int MOD = 1e9 + 7;

main() {
    ios_base::sync_with_stdio(0);
    int n, t;
    cin >> n >> t;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    int tek = 0;
    int kon = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] <= kon){
            ans += t;
            ans -= kon - a[i];
            kon = a[i] + t;
        }
        else{
            ans += t;
            kon = a[i] + t;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include<stdio.h>
/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int x,int y){
		int r = 1;
		while(1){
			if(y&1)r=mul(r,x);
			if(y>>=1)x=mul(x,x);else
				break;
		}
		return r;
	}
	//mod must be a prime.
	int inv(int x){
		return pw(x, mod-2);
	}
	int div(int x,int y){
		return mul(x, inv(y));
	}
};
/*####*/

modular_arithmetic md;

int dp[55][3][3];
int n;char s1[55],s2[55];
int main(){
	scanf("%d%s%s",&n,s1,s2);
	if(s1[0] == s2[0]){
		for(int i=0; i<3; i++)
			dp[0][i][i] = 1;
	}else{
		for(int i=0; i<3; i++)for(int j=0; j<3; j++)if(i!=j)
			dp[0][i][j] = 1;
	}
	for(int i=0; i<n-1; i++)
	for(int c1=0; c1<3; c1++)
	for(int c2=0; c2<3; c2++)
	for(int c3=0; c3<3; c3++)
	for(int c4=0; c4<3; c4++){
		if(
		(s1[i+1] == s1[i]) == (c3 == c1) &&
		(s2[i+1] == s2[i]) == (c4 == c2) &&
		(s1[i+1] == s2[i+1])==(c3 == c4))
		dp[i+1][c3][c4] = md.add(dp[i+1][c3][c4], dp[i][c1][c2]);
	}
	int res = 0;
	for(int c1=0; c1<3; c1++)
	for(int c2=0; c2<3; c2++)
		res = md.add(res, dp[n-1][c1][c2]);
	printf("%d\n",res);
	return 0;
}

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

struct low_link {
public :
	vector<int> articulation;
	vector<pair<int, int>> bridge;
private :
	int n;
	vector<vector<int>> g;
	vector<int> order, low;
	vector<bool> seen;

	int dfs (int v, int p, int ord) {
		seen[v] = true;
		order[v] = ord++;
		low[v] = order[v];
		int child = 0;
		bool isart = false;
		for (int u : g[v]) if (u != p) {
			if (seen[u]) {
				low[v] = min(low[v], order[u]);
				continue;
			}
			child++;
			ord = dfs(u, v, ord);
			low[v] = min(low[v], low[u]);
			if (p != -1) isart |= (order[v] <= low[u]);
			if (order[v] < low[u]) bridge.push_back(minmax(v, u));
		}
		isart |= (p == -1 and child >= 2);
		if (isart) articulation.push_back(v);
		return ord;
	}

public :
	low_link (int n) : n(n), g(n), order(n), low(n), seen(n) { }

	void add_edge (int v, int u) {
		g[v].push_back(u);
		g[u].push_back(v);
	}

	void build (int r = 0) {
		bridge.clear();
		articulation.clear();
		fill(seen.begin(), seen.end(), false);
		for (int s = 0; s < g.size(); s++) {
			if (not seen[s]) dfs(s, -1, 0);
		}
	}

};


int main() {
	int n, m;
	cin >> n >> m;
	low_link g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.add_edge(a, b);
	}
	
	g.build();
	
	cout << g.bridge.size() << endl;
	
	return 0;
}

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

int main() {
	int n, A[100];
cin>>n;
for(int i =0; i<n; i++) cin>>A[i];
for(int i=n-1; i>=0; i--){
if(i!=n-1)cout<<" ";
cout<<A[i];
}
cout<<endl;
// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		cout << 0 << endl;
		return 0;
	}
	if (N == 2) {
		cout << 2 << endl;
		cout << 0 << endl;
		cout << 11 << endl;
		return 0;
	}
	cout << N-1 << endl;
	for (int i = 2; i <= N-1; ++ i) {
		cout << "0" << string(i-2, '1') << "0" << endl;
	}
	cout << string(N, '1') << endl;
}



Measured memory_bytes: 3160
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
}

Measured memory_bytes: 53740
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2);
  else return x * r(x, (y-1)/2) * r(x, (y-1)/2);
}

int main() {
  ll n, p;
  cin >> n >> p;
  vector<int> a(n);
  ll a0 = 0;
  ll a1 = 0;
  for (int i = 0; i < n; i++) {
    ll A = 0;
    cin >> A;
    A %= 2;
    a[i] = A;
    if (A == 0) a0++;
    else a1++;
  }
  ll sum = 0;

  if (p == 0) {
    sum++;
    ll j = 2;
    while (j <= a1) {
      ll bo = 1;
      ll si = 1;
      ll m = min(a1-j, j);
      for (int k = 1; k <= m; k++) {
        bo *= k;
        si *= (a1 - k + 1);
      }
      si /= bo;
      sum += si;
      j += 2;
    }
  }
  
  else if (p == 1) {
    ll j = 1;
    while (j <= a1) {
      ll bo = 1;
      ll si = 1;
      ll m = min(a1-j, j);
      for (int k = 1; k <= m; k++) {
        bo *= k;
        si *= (a1 - k + 1);
      }
      si /= bo;
      sum += si;
      j += 2;
    }
  }
  
  ll A = r(2, a0);
  
  sum *= A;
  
  printf("%lld\n", sum);
}

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


int A[100005], n;

int binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if(A[mid] == key) return 1;
        else if(key > A[mid]) left = mid + 1;
        else right = mid;
    }
    return 0;
}

int main(){
    int q;
    cin >> n;
    for(int i = 0; i< n; i++) cin >> A[i];
    cin >> q;
    int t,sum = 0;
    for(int i = 0; i< q;i++) {
        cin >> t;
        if(binarySearch(t)) sum++;
    }
    cout << sum << endl;
    
  return 0;
}


Measured memory_bytes: 3460
#include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int a,b,c,d,count=0;
        for(a=0; a<10; a++){
            for(b=0; b<=9; b++){
                for(c=0; c<=9; c++){
                    for(d=0; d<=9; d++){
                        if(a+b+c+d==n)
                            count++;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();


        //分母
        double denom = 0;

        for (int i = 0; i < N; i++) {
            denom += 1d / (double)A[i];
        }

        //出力
        Console.WriteLine(1d / denom);


    }
}

Measured memory_bytes: 11348
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

def insertion_sort(n, a):
    for i in range(1, n):
        print_list(a)
        v = a[i]
        sorted_list_idx = i
        while sorted_list_idx > 0 and a[sorted_list_idx - 1] > v:
            a[sorted_list_idx] = a[sorted_list_idx - 1]
            sorted_list_idx -= 1
        a[sorted_list_idx] = v
    return a


n = int(input())
a = list(map(int, input().split(' ')))

a = insertion_sort(n, a)

print_list(a)


Measured memory_bytes: 5600
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <regex>

#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define RFOR(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define REP(i,x) for(int i=0;i<(x);i++)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
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();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_S = 100000;
string S;

bool solve() {
    regex re("^(dream|dreamer|erase|eraser)+$");
    return regex_match(S, re);
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> S;
    cout << (solve() ? "YES" : "NO") << "\n";
    return 0;
}


Measured memory_bytes: 39888
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Char;

class Program{
    public static void Main(){
        int A = 0;
        int C = 0;
        int kcount = 0;
        string S = ReadLine();
        if(S[0] == 'A'){
            A++;
        }
        for(int i = 2; i < S.Length-1; i++){
            if(S[i] == 'C'){
                    C++;
            }
        }
        for(int i = 0; i < S.Length; i++){
            if(!IsUpper(S[i])){
                kcount++;
            }
        }

        if(A == 1 && C == 1 && kcount == S.Length - 2){
            WriteLine("AC");
        }
        else{
            WriteLine("WA");
        }
    } 
}

Measured memory_bytes: 11092
program abc170c
      implicit none
      integer::x,n
      integer,allocatable,dimension(:)::p
      logical,allocatable,dimension(:)::check
      integer::i,step


         read *, x,n
         allocate( p(n),check(-100:200) )
         check=.false.
         read *, p(1:n)

         if ( n==0 ) then
            print *, x
            stop
         end if

         do i=1,n
            check(p(i))=.true.
         end do

         if ( check(x) .eqv. .false. ) then
            print *, x
            stop
         end if

         step=0
         do while ( check(x+step) .and. check(x-step) )
            step=step+1
            if ( check(x+step) .eqv. .false. ) then
               if ( check(x-step) .eqv. .false. ) then
                  print *, x-step
                  stop
               else
                  print *, x+step
                  stop
               end if
            else if ( check(x-step) .eqv. .false. ) then
               print *, x-step
               stop
            end if
         end do


   end program abc170c

Measured memory_bytes: 2804
#include<iostream>
#include<cstring>
using namespace std;
int vis[330],sum[330],n,m,g[330][330];
int ans(int &maxn)
{
    int i,j;
    int mx=0;
    memset(sum,0,sizeof(sum));
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            if (!vis[g[i][j]])
            {
                sum[g[i][j]]++;
                if (sum[g[i][j]]>mx)
                    maxn=g[i][j],mx=sum[g[i][j]];
                break;
            }
    return mx;
}
int main()
{
    int i,k,x,j;
    int maxn,mi=400;
    cin>>n>>m;
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            cin>>g[i][j];
    for (i=1;i<=m;i++)
    {
        mi=min(mi,ans(maxn));
        vis[maxn]=1;
    }
    cout<<mi<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
  #define ll  long long int
  #define N 100000
  #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
  #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
  #define po pop_back
  #define pb push_back
  #define lb lower_bound
  #define fi first
  #define se second
  #define debug(x) cout << #x << " = " << x << endl
  #define ub upper_bound
  #define ibs ios_base::sync_with_stdio(false)
  #define cti cin.tie(0)
  #define all(x) x.begin(),x.end()
  #define PI 3.14159265
  #define cot cout.tie(0)
  using namespace std;
   /**
    * @author :: Sawlani
    *
    */
    int main()
    {
        ll m,d;
        cin >> m >> d;

        ll ans=0;
        f(i,1,m)
        {
            f(j,20,d)
            {
                ll k=j%10;

                ll p=j/10;
                if((p>=2)&&(k>=2))
                    {
                    if((k*p)==i){
                     ans++;
                       }

            }

        }
        }
        cout <<  ans <<  endl;

     }


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

template<typename ctype, ctype INF>
class BellmanFord{
public:
  double EPS = 1e-8;
  using T = tuple<int, int, ctype>;
  int V;
  vector<vector<int> > G, rG;
  vector<T> edge;
  BellmanFord():V(-1){}
  BellmanFord(int V):V(V), G(V), rG(V){}

  void add_edge(int from, int to,ctype cost){
    assert(0 <= from && from < V);
    assert(0 <= to && to < V);
    edge.push_back(T(from, to, cost));
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void add_bidirectional_edge(int a,int b,ctype cost){
    add_edge(a, b, cost);
    add_edge(b, a, cost);
  }

  //s番目の頂点から各頂点への最短距離を求める。
  //グラフに負閉路があれば{}を返す。
  vector<ctype> calcDistance(int start){
    assert(0 <= start && start < V);
    vector<ctype> D(V, INF);   //最短距離
    D[start] = 0;

    int cnt = 0;
    bool update = true;
    while(update){
      if(++cnt > V) return {}; //負の閉路
      update = false;
      for(auto e:edge){
        int from, to;
        ctype cost;
        tie(from, to, cost) = e;
        ctype ncost = D[from] + cost;
        if(abs(D[from] - INF) < EPS || ncost - D[to] > -EPS) continue;
        //if(D[from] == INF || ncost >= D[to]) continue;
        D[to] = ncost;
        update = true;
      }
    }
    return D;
  }
  
  //startからgoalへの最短距離を求める。
  //startからgoalの経路上に負閉路があるか判定する。
  ctype calcDistance(int start, int goal){
    assert(0 <= start && start < V);
    assert(0 <= goal && goal < V);

    vector<int> visited(V, 0); //goalから到達可能なノード
    function<void(int pos)> calcVisited = [&](int pos){
      if(visited[pos]) return;
      visited[pos] = 1;
      for(int to:rG[pos]) calcVisited(to);
    };
    calcVisited(goal);

    vector<ctype> D(V, INF);   //最短距離
    D[start] = 0;
    int cnt = 0;
    bool update = true;
    while(update){
      if(++cnt > V) return -INF; //負の閉路
      update = false;
      for(auto e:edge){
        int from, to;
        ctype cost;
        tie(from, to, cost) = e;
        ctype ncost = D[from] + cost;
        if(abs(D[from] - INF) < EPS || ncost - D[to] > -EPS || visited[to] == 0) continue;
        //if(D[from] == INF || ncost >= D[to] || visited[to] == 0) continue;
        D[to] = ncost;
        update = true;
      }
    }
    return D[goal];
  }
};

int n, m, p;

signed main(){
  
  cin>>n>>m>>p;
  
  const int INF = 1e15;
  
  BellmanFord<int,INF> bell(n);
  
  for(int i=0;i<m;i++){
    
    int a, b, c;
    cin>>a>>b>>c;
    
    a--, b--;
    
    bell.add_edge( a, b, -( c - p ) );
    
  }
  
  int cost = bell.calcDistance( 0, n-1 );
  
  if( cost == -INF ) cout<<-1<<endl;
  else{
    cost *= -1;
    if( cost < 0 ) cost = 0;
    cout<<cost<<endl;
  }
  
  return 0;
}


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

using namespace std;
 
int main()
{
    string str; 
    while (getline(cin,str)) {
        for (int i = 0; i < (int)str.size(); i++) {
            string key = str.substr(i, 5), repl;
            if (key == "apple") {
                repl = "peach";
                for (int j = 0; j < 5; j++) {
                    str[i+j] = repl[j];
                }
            } else if (key == "peach") {
                repl = "apple";
                for (int j = 0; j < 5; j++) {
                    str[i+j] = repl[j];
                }
            }
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 2988
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n, a, b;
    cin >> n >> a >> b;
    ll remain = n % (a + b);
    ll res = min(remain, a);
    res += n / (a + b) * a;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
//In the name of God

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

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

const int N = 2e5+10 , mod = 1e9+7;

vector <pii> v[N];
vector <int> r;
int dp[N] , ans[N] , cnt[N] , c[N];

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   int lst = 1;
   cin >> c[1];
   for(int i = 2 ; i <= n + 1 ; i++){
      if(i <= n)
         cin >> c[i];
      if(c[i] == c[i - 1])
         continue;
      else
         v[c[i - 1]].push_back({lst , i - 1}) , lst = i , r.push_back(i - 1);
   }
   dp[c[1]] = 1;
   for(int i = 0 ; i < r.size() ; i++){
      int rpos = r[i];
      ans[i] = dp[c[rpos]];
      //cout << rpos << " " << ans[i] << endl;
      (dp[c[rpos + 1]] += ans[i]) %= mod;
   }
   cout << ans[r.size() - 1];
   return 0;
}


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

using namespace std;

int main(){
  	int n, q;
  	string s;
  	vector<int> rep(n,0);	
  
  	cin >> n >> q >> s;
  
    for(int i=0; i<n-1; i++){
    	if(s[i]=='A' && s[i+1]=='C'){
        	rep[i+1]=1;
        }
    }
  
  	for(int i=0; i<n-1; i++){
    	rep[i+1]+=rep[i];
    }
  
  	for(int i=0; i<q; i++){
    	int l1, r1;
      	cin >> l1 >> r1;
      	cout << rep[r1-1]-rep[l1-1] << endl;
    }
      
	return 0;
}


Measured memory_bytes: 25728
using System;
using static System.Console;

class Program {
	static void Main() {
		var N = int.Parse(ReadLine());
		var S = ReadLine();
		var ans = 0;

		for (var i = 1; i < N; i++) {
			var a = S.Substring(0, i);
			var b = S.Substring(i);
			ans = Math.Max(ans, Calc(a, b));
		}
		WriteLine(ans);
	}

	static int Calc(string x, string y) {
		var result = 0;
		for (var c = 'a'; c <= 'z'; c++) {
			if (x.Contains(c + "") && y.Contains(c + "")) {
				result++;
			}
		}
		return result;
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    std::priority_queue<std::pair<long long, int>> que;
    for (int i = 0; i < n; i++) {
        que.emplace(b[i], i);
    }
    long long ans = 0;
    while (!que.empty()) {
        int i = que.top().second;
        que.pop();
        int p = (i + n - 1) % n, q = (i + 1) % n;
        long long k = b[i] - std::max(b[p], b[q]);
        k = (k + b[p] + b[q] - 1) / (b[p] + b[q]);
        if ((b[i] - a[i]) % (b[p] + b[q]) == 0) {
            k = std::min(k, (b[i] - a[i]) / (b[p] + b[q]));
        }
        b[i] -= k*(b[p] + b[q]);
        ans += k;
        if (a[i] > b[i]) break;
        if (a[i] == b[i]) continue;
        que.emplace(b[i], i);
    }
    bool ok = true;
    for (int i = 0; i < n; i++) ok &= a[i] == b[i];
    std::cout << (ok ? ans : -1) << std::endl;
    return 0;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string at, s, co;
  	cin >> at >> s >> co;
  
	char A = at.at(0);  
  	char x = s.at(0);
  	char C = co.at(0);
  
  cout << A << x << C << endl;



}

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

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

    // binary_search使うのでvector(push_forwardするならlist??)
    vector<int> a;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        a.push_back(x);
    }

    // query数
    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int k;
        cin >> k;
        if(binary_search(a.begin(), a.end(),k)){
            cout << 1 << "\n";
        }
        else{
            cout << 0 << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
int nu[200005];

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=1;i<N;i++){
        cin >> A[i];
    }

    for(int i=1;i<N;i++){
        nu[A[i]]++;
    }
    for(int i=1;i<=N;i++){
        cout << nu[i]<< endl;
    }

    return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e9;

//入力
ll n,k;

int main(){
    cin >> n >> k;
    ll flag = (n-1)*(n-2)/2;
    if(k>flag){
        cout << -1 << endl;
        return 0;
    }
    cout << n-1+(flag-k) << endl;
    rep(i,n-1){
        cout << 1 <<  ' ' << i+2 << endl;
    }
    bool end = false;
    for(int i=2;i<n;i++){
        if(flag==k)end=true;
        if(end)break;
        for(int j=i+1;j<=n;j++){
            if(end)break;
            cout << i << ' ' << j << endl;
            flag--;
            if(flag==k)end=true;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll nowans,ans;
ll n,a[N];
ll Stack[N],top;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();for(register ll i=1;i<=n;i++)a[i]=read();
	for(register ll i=1;i<=n;i++)
	{
		while(top&&a[i]<a[Stack[top]]){nowans-=(Stack[top]-Stack[top-1])*a[Stack[top]];top--;}
		nowans+=a[i]*(i-Stack[top]);Stack[++top]=i;ans+=nowans;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int print(){
	
}

int main() {
  vector<char> code(4);
  for(int i; i<4; i++){
    cin >> code[i];
    if(i>0){
      if(code[i-1]==code[i]){
        cout << "Bad" << endl;
      	return 0;
      }
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);
	
	n = n * (n - 1) / 2;
	m = m * (m - 1) / 2;
	
	printf("%d", n + m);
	
	return 0;
}

Measured memory_bytes: 128
# 競プロの数学は高校数学みたいな泥臭いのが多い
# めんどくさがってA,Bの範囲を計算しなかったのが原因
# なんなら大雑把にみて -500~500でもいけてる
flag = 0
X = int(input())
for i in range(1000):
    for j in range(1000):
        a = i-500
        b = j-500
        if X == a**5-b**5:
            print(a, end=" ")
            print(b)
            flag =  1
            break
    if flag == 1:
        break

Measured memory_bytes: 9096
#include <cstdio>

const int N = 600000;
const int MAX = 2000000000;

int n, cnt;

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[N], R[N];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = MAX; R[n2] = MAX;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int* A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int A[N];
    scanf("%d", &n);
    cnt = 0;
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    mergeSort(A, 0, n);

    for(int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", cnt);
}



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

int main() {
    int n,k;
    cin>>n>>k;
    int res=0;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++){
        if(v[i]>=k) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

bool solve(vector<int> A, int p, int t) {
  if (p > A.size() || t < 0 || accumulate(A.begin()+p, A.end(), 0) < t) return false;
  else if (t == 0) return true;
  else return (solve(A, p + 1, t) || solve(A, p + 1, t - A[p]));
}

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

  vector<int> A;
  int n, q, x;

  cin >> n;
  REP(i, n) {
    cin >> x;
    A.push_back(x);
  }

  cin >> q;
  REP(i, q) {
    cin >> x;
    if (solve(A, 0, x)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,A,B;
  cin >> N >> A >> B;
  vector<int> a(N),b(N),c(N);
  rep(i,N)  cin >> a.at(i) >> b.at(i) >> c.at(i);

  vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(500,vector<int>(500,5000)));
  dp.at(0).at(0).at(0)=0;
  rep(i,N){
    rep(j,500){
      rep(k,500){
        chmin(dp.at(i+1).at(j).at(k),dp.at(i).at(j).at(k));
        if(j+a.at(i)<500 && k+b.at(i)<500){
          chmin(dp.at(i+1).at(j+a.at(i)).at(k+b.at(i)),dp.at(i).at(j).at(k) + c.at(i));
        }
      }
    }
  }
  int ans=5000;
  REP(i,1,500){
    if(i*A>=500 || i*B>=500)  break;
    chmin(ans,dp.at(N).at(i*A).at(i*B));
  }
  if(ans==5000) ans=-1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 45156
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

int main() {
    ll m=1000000000000000000;
    ll sum=1;
    ll flag=0;
    ll n,a;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a;
        if(a==0){
            cout<<"0";
            exit(0);
        }
        if(m<a){
            flag=1;
        }
        m/=a;
        sum*=a;
    }
    if(flag==1)cout<<"-1";
    else cout<<sum;
}



Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;
import java.util.jar.JarOutputStream;

public class Main {

    public static int lower_bound(long[] arr,long target){
        int low = 0;
        int high = arr.length - 1;
        while(low < high){
            int mid = (low + high) / 2;
            if(arr[mid] < target){
                low = mid + 1;
            }
            else{
                high = mid;
            }
        }
        return low;
    }

    public static void main(String[] args) throws IOException {

        Reader.init(System.in);
        int n= Reader.nextInt();
        int k= Reader.nextInt();
        int[] cost=Reader.nextIntArray(n);
        int[] dp=new int[n];
        dp[0]=0;
        if(dp.length>1){
            dp[1]=Math.abs(cost[1]-cost[0]);
        }
        for(int i=2;i<dp.length;i++){
            int min = Integer.MAX_VALUE;
            for(int j=1;j<=k;j++){
                if(i-j>=0){
                    min = Math.min(min,dp[i-j]+Math.abs(cost[i]-cost[i-j]));
                }
            }
            dp[i]=min;
        }
        System.out.println(dp[n-1]);

    }

}






class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String nextLine() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( nextLine() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong(nextLine());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( nextLine() );
    }

    static float nextFloat() throws IOException {
        return Float.parseFloat( nextLine() );
    }
    static int[] nextIntArray(int length) throws IOException {
        int[] arr = new int[length];
        //System.out.println(length);
        for (int i=0; i<length; i++) {
            arr[i] = Integer.parseInt( nextLine() );
            //System.out.println(arr[i]);
        }
        //System.out.println(arr);
        return arr;
    }
    static long[] nextLongArray(int length) throws IOException {
        long[] arr = new long[length];
        for (int i=0; i<length; i++) {
            arr[i] = Long.parseLong( nextLine() );
        }
        return arr;
    }

}



Measured memory_bytes: 44220
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio 
    int n ; 
    cin >> n ;
    string s ;
    cin >> s ;
    int R = 0 , G = 0, B = 0 ;
    for(char &c : s){
        if ( c == 'R' ) R++ ;
        else if ( c == 'B' ) B++ ;
        else G++ ;
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= n; j++){
            int before = i - j ; 
            int after = i + j ;
            if ( before < 0 || after >= n ) break ;
            set<int> ss ; 
            ss.insert(s[i]) ;
            ss.insert(s[before]) ;
            ss.insert(s[after]) ;
            if ( ss.size() == 3 ) ans++ ;
        }
    }
    debug() << imie(ans) ;
    int curR = 0 , curB = 0 , curG = 0 ;
    int total = 0 ;
    for(int i = 0; i < n; i++){
        if ( s[i] == 'R' ){
            int beforeB = curB ;
            int afterG = G - curG ;
            total += beforeB * afterG ;
            int beforeG = curG ;
            int afterB = B - curB ;
            total += beforeG * afterB ;
            curR++ ;
        }
        else if ( s[i] == 'B' ){
            int beforeR = curR ;
            int afterG = G - curG ;
            total += beforeR * afterG ;
            int beforeG = curG ;
            int afterR = R - curR ;
            total += beforeG * afterR ;
            curB++ ;
        }
        else{
            int beforeR = curR ;
            int afterB = B - curB ;
            total += beforeR * afterB ;
            int beforeB = curB ;
            int afterR = R - curR ;
            total += beforeB * afterR ;
            curG++ ;
        }
    }
    cout << total - ans << endl;
    return 0 ; 
}

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

void show(int a,int b){
cout<<a<<"x"<<b<<"="<<a*b<<endl;
}
int main(){
    
    for(int i = 1;i <= 9;i++){
      for(int j = 1;j<=9;j++){
        show(i,j);
}
}
    return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int p[N];
int main()
{
	for(int i=2;i<=200000;i++)
		if(!p[i])
			for(int j=i+i;j<=200000;j+=i)
				p[j]=1;
	int x;
	cin>>x;
	while(1)
	{
		if(!p[x])
		{
			cout<<x<<endl;
			return 0;
		}
		x++;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll down = 0, up = INF;
    while(up - down > 1){
        ll mid = (up + down) / 2;
        ll cnt = 0;
        REP(i, n){
            ll idx = lower_bound(a.begin(), a.end(), mid - a[i]) - a.begin();
            cnt += n - idx;
        }
        ((cnt >= m)? down : up) = mid;
    }
    vector<ll> aa = {0};
    REP(i, n){
        aa.push_back(a[i]);
    }
    REP(i, n){
        aa[i + 1] += aa[i];
    }
    ll ans = 0, cnt = 0;
    REP(i, n){
        ll idx = lower_bound(a.begin(), a.end(), down - a[i]) - a.begin();
        ans += aa[n] - aa[idx] + (n - idx) * a[i];
        cnt += n - idx;
    }
    cout << ans - (cnt - m) * down << endl;
}

Measured memory_bytes: 2168
X = list(map(str, input().split()))
A = []
for x in X:
    if x.isnumeric():
        A.append(int(x))
    else:
        a = A.pop()
        b = A.pop()
        if x == '+':
            A.append(a+b)
        elif x == '-':
            A.append(b-a)
        else:
            A.append(a*b)
print(A[0])



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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define vi              vector<int>
#define ii              pair<int,int>

using namespace std;

int main(){
    int n;
    cin>>n;
    set<string> st;
    while(n--){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
}


Measured memory_bytes: 19228
def a():
    S = input()

    if S[3] == S[2] and S[4] == S[5]:
        print("Yes")
    else:
        print("No")


def b():
    X = int(input())
    y_500 = (X // 500) * 1000
    y_5 = ((X - (y_500 / 2)) // 5) * 5
    print(int(y_500 + y_5))


def c():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    max_A_d = -1
    for i in range(len(A)):
        A_d = 0
        if i == 0:
            A_d = K - (A[-1] - A[0])
        else:
            A_d = (A[i] - A[i - 1])
        if max_A_d < A_d:
            max_A_d = A_d
    d = K - max_A_d
    print(d)


def d():
    print()


def e():
    print()


c()


Measured memory_bytes: 78284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, k, h[100001], count = 0;
	cin >> n >> k;
	rep(i, n){
		cin >> h[i];
		if(h[i] >= k) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]-1]+C[A[i]-2])
    else:
      happiness += B[A[i]-1]
  else:
    happiness += B[A[i]-1]
print(happiness)

Measured memory_bytes: 3064