akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

	int N = scan.nextInt();
	int count = 0;

	Boolean three;
	Boolean five;
	Boolean seven;
	Boolean flag;
	for(int i = 1; i <= N; i++){
	    three = false;
	    five = false;
	    seven = false;
	    flag = true;

	    int digit = String.valueOf(i).length();
	    int num = i;
	    double diff = 1;
	    for(int j = 0; j < digit; j++){
		int rem = (int)num % 10;
		if(rem == 3){
		    three = true;
		}else if(rem == 5){
		    five = true;
		}else if(rem == 7){
		    seven = true;
		}else{
		    flag = false;
		    if(rem == 0 || rem == 1 || rem == 2){
			diff = 3*Math.pow(10, j) - (i % Math.pow(10, j+1));
		    }else if(rem == 4){
			diff = 5*Math.pow(10, j) - (i % Math.pow(10, j+1));
		    }else if(rem == 6){
			diff = 7*Math.pow(10, j) - (i % Math.pow(10, j+1));
		    }else{
			diff = 13*Math.pow(10, j) - (i % Math.pow(10, j+1));
		    }
		    break;
		}
		num /= 10;
	    }

	    if(three == true && five == true &&
	       seven == true && flag == true)
		count++;

	    i += (diff-1);
	}

	System.out.println(count);
    }
}


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

#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

typedef long long ll;

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str)
{
    int num;
    std::istringstream iss(str); //put string in input stream
    iss >> num; return num; //read from stream as integer
}
ll  OO = 10e9;


int main() {
    IOS()
    int n , cnt = 1;
    char c_prev,c;
    cin>>n;
    cin>>c_prev;
    REP(i,n-1)
    {
        cin>>c;
        if(c!=c_prev) ++cnt;
        c_prev= c;
    }

    cout<<cnt<<endl;
    return 0;
}



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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if(a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main()
{
  bool can = true;
  int N;
  cin >> N;
  vector<pair<int, int> > pairs(N);
  for (int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }

  sort(pairs.begin(), pairs.end(), compare_by_b);
  int nowTime = 0;

  for (int i = 0; i < N; i++) {
    nowTime += pairs[i].first;
    if (nowTime > pairs[i].second) {
      can = false;
      break;
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
	int n,x;
	while(1){
	scanf("%d %d\n",&n,&x);
	if(n==0 && x==0){
		break;
	}else{
		int count;
		count = 0;
		int i,j,k;
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x){
						count = count + 1;
					}
				}
			}
		}
		printf("%d\n",count);
	}
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <string>
#include <complex>
#include <cstdio>
using namespace std;

pair<int,int> a[15];

int main(){
	int n,m,K;
	cin >> n >> m >> K;
	long long sum = 0;
	for(int i = 0 ; i < n ; i++) cin >> a[i].first;
	for(int i = 0 ; i < n ; i++) cin >> a[i].second;
	long long w = 0;
	for(int k = 0 ; k < (1<<n) ; k++){
		if( __builtin_popcount(k) > K ) continue;
		vector<int> v;

		for(int i = 0 ; i < n ; i++){
			if( k >> i & 1 )
				for(int j = 0 ; j < a[i].second ; j++)
					v.push_back(a[i].first);
		}
		sort(v.rbegin(),v.rend());

		long long s = m - min<int>(v.size(),m);
		for(int i = 0 ; i < min<int>(v.size(),m) ; i++){
			//cout << v[i] << endl;
			s += v[i];
		}
		w = max(w,s);

	}
	cout << w << endl;
}

Measured memory_bytes: 3264
#include<stdio.h>
int main()
{
	char s[19];
	int i;
	scanf("%s", s);
	for (i = 0; i < 19; i++) {
		if (s[i] == ',') {
			printf(" ");
		}
		else {
			printf("%c", s[i]);
		}
	}
	printf("\n");
	return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> mass(h);
    for (int i = 0; i < h; i++){
        cin >> mass[i];
    }

    vector<bool> row(h,false);
    vector<bool> col(w,false);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (mass[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++){
        if (row[i]){
            for (int j = 0; j < w; j++){
                if (col[j]){
                    cout << mass[i][j];
                }
            }
            cout << endl;
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;

    FOR(i,1,9){
        if (n%i == 0 && n/i <= 9) { cout << "Yes"; return 0; }
    }
    cout << "No";
}



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

const long long int MAX = 1000001; 

struct Query 
{ 
	lld l, r, idx; 
}; 


bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 
 
void update(lld idx, lld val, lld bit[], lld n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 
 
lld query(lld idx, lld bit[], lld n) 
{ 
	lld sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(lld arr[], lld n, Query queries[], lld q) 
{ 

	lld bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 


	lld last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	lld ans[q]; 
	lld query_counter = 0; 
	for (lld i=0; i<n; i++) 
	{ 
	
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 


		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	for (lld i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

 
int main() 
{ 
    lld n,k; cin>>n>>k;
    lld a[n];
    for(lld i=0;i<n;i++)  cin>>a[i];
	Query queries[k]; 
	for(lld i=0;i<k;i++){
	    lld ll,rr; cin>>ll>>rr;
	queries[i].l = ll-1; 
	queries[i].r = rr-1; 
	queries[i].idx = i; 
	}
	sort(queries, queries+k, cmp); 
	answeringQueries(a, n, queries, k); 
	return 0; 
} 


Measured memory_bytes: 35000
import numpy as np
N, M = input().split()
hito = []
for i in range(int(N)):
    hito.append(input().split())

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

for i in range(int(N)):
    hito[i].pop(0)

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))



print(len(hikaku))


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

        T vl = _query(a, b, k*2+1, l, (l+r)/2);
        T vr = _query(a, b, k*2+2, (l+r)/2, r);

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

    void update(int k, T a) {
        k += _n-1;
        _data[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            _data[k] = _f(_data[k*2+1], _data[k*2+2]);
        }
    }

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

struct T {
  ll l, r, c;
  T() {}
  T(ll l, ll r, ll c): l(l), r(r), c(c) {}
};

const ll INF = 1e17;
ll N, M;
vector<T> g;

signed main() {
  cin >> N >> M;
  g.resize(M);
  rep(i, M) {
    cin >> g[i].l >> g[i].r >> g[i].c;
    g[i].l--;
    g[i].r--;
  }
  sort(begin(g), end(g), [](const auto &x, const auto &y) { return x.r < y.r; });

  // {value, index}
  SegTree<PLL> st(N, PLL(INF, 0), [](PLL x, PLL y) { return min(x, y); });
  st.update(0, PLL(0, 0));
  for (auto t : g) {
    ll l = t.l, r = t.r, c = t.c;
    PLL p = st.query(l, r + 1);
    PLL nval(p.first + c, r);
    if (st.get(r) <= nval)
      continue;
    st.update(r, nval);
    // cout << "update " << r << " " << nval.first << endl;
  }
  ll ans = st.get(N-1).first;
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6656
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

fn main() {
    let a = read!(usize);
    let s = read!(String);
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if ((s.at(0) != '7') && (s.at(1) != '7') && (s.at(2) != '7')) {
    coNo;
  }
  else {
    coYes;
  }
}




Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=1000005;
char s[N]; int n,pfx[N],smi[N];
inline int work(CI mi)
{
	RI i; int cur=0,mx=0; for (i=1;i<=n;++i)
	{
		if (s[i]=='?'&&smi[i]-cur-2>=mi) cur+=2;
		mx=max(mx,pfx[i]-cur);
	}
	return mx-mi;
}
int main()
{
	RI i; for (scanf("%s",s+1),n=strlen(s+1),i=1;i<=n;++i)
	pfx[i]=pfx[i-1]+(s[i]=='0'?-1:1); smi[n]=pfx[n];
	for (i=n-1;~i;--i) smi[i]=min(smi[i+1],pfx[i]);
	return printf("%d",min(work(smi[0]),work(smi[0]-1))),0;
}

Measured memory_bytes: 12628
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    double x1, y1, x2, y2;
    double base, height, hype;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    base = abs(x1 - x2);
    height = abs(y1 - y2);
    
    hype = sqrt(pow(base, 2) + pow(height, 2));
    
    printf("%lf\n", hype);
    
    return 0;
}


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

void swap(int &a,int &b){
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

int main(){
	int w;
	int n;
	char c;
	cin >> w;
	cin >> n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		cin >> a[i] >> c >> b[i];
	
	int num[w];
	int tmp;
	for(int i=0;i<w;i++)
		num[i] = i+1;
	
	for(int i=0;i<n;i++){
	swap(num[a[i]-1],num[b[i]-1]);
	}
	
	for(int i=0;i<w;i++)
		cout << num[i] <<endl;
}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll a = n, cut = 0;

    while (a) {
        a /= k;
        cut++;
    }

    if (k == 10) {
        int b = to_string(n).length();
        cout << b << endl;
        return 0;
    }

    cout << cut << endl;

    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> machi_a(M);
  vector<int> machi_b(M);
  vector<int> total(N);

  
  for(int i=0; i <M; i++){
    cin >> machi_a.at(i) >> machi_b.at(i);
    for(int j =0; j<N; j++){
      if(machi_a.at(i) == j+1){
        total.at(j)++;}
      if(machi_b.at(i) == j+1){
        total.at(j)++;}}
  }
  for(int i =0; i<N; i++){
    cout << total.at(i) << endl;}
    
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
michi = []
good = [1 for _ in range(n)]

for _ in range(m):
    a,b =map(int, input().split())
    if good[a-1]:
        if h_list[a-1] <= h_list[b-1]:
            good[a-1] = 0
    if good[b-1]:
        if h_list[a-1] >= h_list[b-1]:
            good[b-1] = 0

print(sum(good))




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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
	string s;
	cin >> s;
	if (sz(s) < 2) {
		puts("-1 -1");
		return 0;
	} else if (sz(s) == 2) {
		if (s[0] == s[1])puts("1 2");
		else puts("-1 -1");
		return 0;
	}

	rep(i, sz(s) - 2) {
		li cnt[26] = {0};
		cnt[s[i] - 'a']++;
		cnt[s[i + 1] - 'a']++;
		cnt[s[i + 2] - 'a']++;
		li tma = 0;
		rep(j, 26)tma = max(tma, cnt[j]);
		if (tma > 1) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	puts("-1 -1");


	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;
int main() {
    int A,B,K,X,count;
    cin >> A >> B >> K;
    X = 101;
    count = 0;
    while(count < K){
        X = X - 1;
        if(A % X == 0 && B % X == 0){
            count = count + 1;
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())




def mc(s):
    l = len(s)
    if l <= 1: return 0
    s1 = s[:l//2]
    s2 = s[l//2:]
    count = mc(s1) + mc(s2)
    count += sum(s1) * (len(s2) - sum(s2))
    return count


def main():
    s = list(input().strip())
    s = [(c == "B") for c in s]
    return mc(s)


if __name__ == "__main__":
    print(main())


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

using namespace std;

typedef long long ll;

int N,M; vector<vector<int>> to,revto;
vector<bool> visited;
vector<int> stock,alt;
vector<int> vec; 

vector<int> par;

void dfs(int u){ //今この位置にいる // ここからdescentして行く
  if(visited[u]){ return;}
  
  visited[u] = true;
  
  for(auto v : to[u]){
    if(visited[v]){ continue;}
    
    
    dfs(v);
  }
  
  stock.push_back(u);
  
 
  return ;
}

int main(){ 
  
  cin >> N >> M;
 
  visited = vector<bool>(N,false);
  
  to.resize(N); revto.resize(N);
  
  for(int i = 0; i < N+M-1; i++){
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); revto[b].push_back(a); //逆辺
  }
  
  for(int i = 0; i < N; i++){
    dfs(i);
  } // トポロジカルソート
  
  reverse(stock.begin(),stock.end());
 
  alt.resize(N);
  
  for(int i = 0; i < N; i++){
    alt[stock[i]] = i;
  }
  //OK
  
  
  vec.resize(N);
  
  for(int i = 0; i < N; i++){ //それぞれのノードについて、親を確定して行く
  
   int q = -1; int j;
    
    for(auto ne : revto[i]){
      int v = alt[ne]; //親の中で、最も数字がでかいものを選ぶ
      if( q < v){ q = v; j = ne;}
      
    }
    
    // pとqをつなぐ
      
   if( q == -1){ j = -1;}
    
    vec[i] = j;
  }
  
 
  for(auto ne : vec){
    cout << ne+1 << endl;
  }
  

  
  
  
 
  
  return 0;
}

Measured memory_bytes: 16252
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 51;
int n, a[N], b[N];
bool e[N][N], t[N][N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  FOR(i, 0, n) cin >> b[i];
  FOR(i, 0, N) e[i][i] = 1;
  ll ans = 0;
  FORR(i, N-1, 1){
    FOR(j, 0, N)FOR(k, 0, N) t[j][k] = e[j][k];
    FORR(j, i-1, 1)FOR(k, 0, N)FOR(l, 0, N) if(t[k][l]) t[k][l%j] = true;
    FOR(j, 0, n) if(!t[a[j]][b[j]]) goto bad;
    continue;
bad:
    FOR(k, 0, N)FOR(l, 0, N) if(e[k][l]) e[k][l%i] = true;
    ans += 1ll<<i;
  }
  FOR(i, 0, n) if(!e[a[i]][b[i]]){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
int main(){
	int v[101];
	scanf("%d", &v[0]);
	for(int i = 1; i <= v[0]; i++){
		scanf("%d", &v[i]);
	}
	for(int i = v[0]; i > 0; i--){
		printf("%d", v[i]);
		if(i != 1) putchar(' ');
	}
putchar('\n');
	return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <cmath>

using namespace std;

#define int long long

int32_t main() {
	double n;
	double k;
	cin >> n >> k;
	int x;
	for (int i = 0; i < n; i++)
		cin >> x;
	cout << int32_t(ceil((n - 1) / (k - 1))) << endl;
}


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

int main() {
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000007
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;



int main()
{

	io;
	
	//v=s/t

	double d, t, s; cin >> d >> t >> s;

	if (d / s <= t)cout << "Yes";
	else cout << "No";
	




}



Measured memory_bytes: 3704
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int a[105], b[105];
int n, m, x, y;

bool check(int z){
	for(int i = 1; i <= n; i++){
		if(a[i] >= z) return false;
	}
	for(int i = 1; i <= m; i++){
		if(b[i] < z) return false;
	}
	return true;
}

int main()
{
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	for(int i = 1; i <= m; i++) scanf("%d", b + i);
	for(int i = y; i > x; i--){
		if(check(i)) return 0 * puts("No War");
	}
	puts("War");
	return 0;
}

Measured memory_bytes: 256
class Node():
    def __init__(self, key):
        self.parent = None
        self.left = None
        self.right = None
        self.key = key

class Tree():
    def __init__(self):
        self.root = None
    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
        
    def preorder(self, node):
        print(" {}".format(node.key), end = "")
        if node.left:
            self.preorder(node.left)
        if node.right:
            self.preorder(node.right)
            
    def inorder(self, node):
        if node.left:
            self.inorder(node.left)
        print(" {}".format(node.key), end = "")
        if node.right:
            self.inorder(node.right)
            
    def find(self, key):
        node = self.root
        while node:
            if node.key == key:
                return 'yes'
            elif node.key > key:
                node = node.left
            else:
                node = node.right
        return 'no'
    
    def out(self):
        self.inorder(self.root)
        print('')
        self.preorder(self.root)
        print('')

tree = Tree()
N = int(input())
for _ in range(N):
    order = input().split()
    if order[0] == 'insert':
        tree.insert(int(order[1]))
    elif order[0] == 'find':
        print(tree.find(int(order[1])))
    else:
        tree.out()

Measured memory_bytes: 124528
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int MAX = 1e9 + 7;

int T[10];

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x>=10) write(x/10); 
	putchar(x%10+'0'); 
}

bool can(int x)
{
	while(x >= 10)
	{
		if(T[x%10]) return false;
		x /= 10;
	}
	if(T[x]) return false;
	return true;
}

int main(void)
{
	int n = read(), k = read();
	rep1(i, 1, k)
	{
		int t = read();
		T[t] = 1;
	}
	int ans = n;
	while(!can(ans)) ++ans;
	write(ans);
	
	return 0;
} 

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

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

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

    vector<int> rate = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    for (int i = 0; i < N; i++) {
        if (a[i] < 3200) {
            rate[a[i] / 400]++;
        }
        else {
            rate[8]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if (rate[i] > 0) {
            ans++;
        }
    }
    
    cout << max(1, ans) << " " << ans + rate[8] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double d = sc.nextDouble();
		double t = sc.nextDouble();
		double s = sc.nextDouble();
		if (d / s <= t) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 37216
#include<bits/stdc++.h>
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef pair<int,int> pii;
typedef vector<pii> vp;

const D EPS = 1e-8;
const D PI = acos(-1);

void normalize(vector<int> &v){
  map<int,int> cnt;
  int k = 0;
  for(int i=0;i<(int)v.size();i++){
    if(cnt.count(v[i]) == 0){
      cnt[v[i]] = k++;
    }
  }
 
  for(int i=0;i<(int)v.size();i++){
    v[i] = cnt[v[i]];
  }
}

inline D dot(P a, P b){
  return real(conj(a)*b);
}

inline D cross(P a, P b){
  return imag(conj(a)*b);
}

inline int ccw(P a, P b, P c){
  b -= a; c-= a;
  if(cross(b,c)>EPS) return 1;
  if(cross(b,c)<-EPS) return -1;
  return 0;
}

inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline P norm(P p){return p*P(0,1);}

map< pair<int, vector<int> >, int> memo;

int rec(int d, vector<int> use, vector<vp> &segs){
  pair< int, vector<int> > key(d,use);
  if(memo.count(key)) return memo[key];

  if(d == (int)segs.size()){
    /*
    for(int i=0;i<(int)use.size();i++){
      cout << use[i] << " ";
    }
    cout << endl;
    */

    set<int> c;
    for(int x : use) c.insert(x);

    if(c.size() == 1) return 0;
    else return 100;
  }

  int res = rec(d+1,use,segs);

  for(auto p : segs[d]){
    int a = use[p.first], b = use[p.second];
    for(int i=0;i<(int)use.size();i++){
      if(use[i] == a) use[i] = b;
    }
  }
  normalize(use);
  res = min(res, rec(d+1,use,segs) + 1);

  return memo[key] = res;
}

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

  vector<P> p(n);
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    p[i] = P(x,y);
  }

  vector< vp > segs;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      P mid = (p[i]+p[j])/2.0;
      P nv = norm(p[i] - p[j]);
      L seg = make_pair(mid, mid + nv);

      vp ans;
      for(int k=0;k<n;k++){
	for(int l=k+1;l<n;l++){
	  P mid_c = (p[k]+p[l])/2.0;
	  if( ccw(seg.first, seg.second, mid_c) == 0 ){
	    if( abs( dot(seg.second - seg.first, p[k] - p[l])) < EPS){
	      ans.push_back( make_pair(k,l) );
	    }
	  }
	}
      }
      /*
      cout << i << " " << j << ": " << endl;
      for(pii a : ans){
	cout << a.first << "," << a.second << " ";
      }
      cout << endl;
      */

      segs.push_back(ans);
    }
  }

  vector<int> use(n,0);
  for(int i=0;i<n;i++)use[i] = i;

  cout << rec(0,use,segs) << endl;
}

Measured memory_bytes: 7576
# https://atcoder.jp/contests/abc143/submissions/8043786

from heapq import heappush, heappop
import sys

input = sys.stdin.readline

n, m, max_tank = map(int, input().split())

g = tuple(set() for _ in range(n))
for _ in range(m):
    a, b, c = map(int, input().split())
    if c > max_tank:
        continue
    # 燃料不足で通過できない

    a -= 1
    b -= 1
    g[a].add((b, c))
    g[b].add((a, c))
    # 隣接リスト、(行き先、コスト)

inf = n + 10

e = [None] * n
for s in range(n):
    d = [inf] * n
    remains = [0] * n

    d[s] = 0
    remains[s] = max_tank

    h = [(0, -max_tank, s)]
    # (補給回数, タンク残量, 現在位置)

    while h:
        take, tank, v = heappop(h)
        tank *= -1
        if (d[v] < take) or (d[v] == take and remains[v] > tank):
            continue

        for u, c in g[v]:
            if c > tank:
                if (d[u] > take + 1) or (d[u] == take + 1 and remains[u] < max_tank - c):
                    d[u] = take + 1
                    remains[u] = max_tank - c
                    heappush(h, (take + 1, c - max_tank, u))  # -(max_tank - c)
            else:
                if (d[u] > take) or (d[u] == take and remains[u] < tank - c):
                    d[u] = take
                    remains[u] = tank - c
                    heappush(h, (take, c - tank, u))  # -(tank - c)
    e[s] = d

q = int(input())

ans = []
for _ in range(q):
    s, t = map(int, input().split())
    ans.append(e[s - 1][t - 1])

print(*map(lambda x: -1 if x == inf else x, ans), sep='\n')


Measured memory_bytes: 83804
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    ll n,e;
    cin >> n >> e;
    ll res=10000000000;
    if((e-n)>=2019)
        cout << 0;
    else
    {
         for(ll i=n;i<=e;i++)
         {
             for(ll j=i+1;j<=e;j++)
             {
                 res=min(((i%2019)*(j%2019))%2019,res);
             }
         }
         cout << res;
    }





    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=1;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i-j>=0){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}

map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
// dp[i] := 長さが i の増加部分列として最後尾の要素のとりうる最小値
template<class T> int LIS(vector<T> a,  bool is_strong = true) {
    const T INF = 1<<30; // to be set appropriately
    int n = (int)a.size();
    vector<T> dp(n, INF);
    for (int i = 0; i < n; ++i) {
        if (is_strong) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        else *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N;
string S;
// 変数定義end

void solve(){
	cin >> N >> S;
	if (N % 2 != 0){
		cout << "No" << endl;
	} else {
		if(S.substr(0, S.size()/2) == S.substr(S.size()/2, S.size()/2)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	//clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


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

int main(){
    long long int n;
    cin>>n;
    long long int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    long long int res=1;
    int check=0;
    for (int i = 0; i < n; i++)
    {
        if(arr[i]==0){
            check=1;
            break;
        }
    }
    if (check==1)
    {
        cout<<0;
        return 0;
    }
    
    for(int i=0;i<n;i++){
      
        if(arr[i]<=1000000000000000000/res){
            res=res*arr[i];
        }else
        {
            check=1;
            break;
        }
    }
    if (check==1)
    {
        cout<<-1;
    }else
    {
        cout<<res;
    }
    
    
   
    
    return 0;
}

Measured memory_bytes: 4368
n=int(raw_input())
s=[str(raw_input()) for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
	if s[i][0]=="M":
		m+=1
	elif s[i][0]=="A":
		a+=1
	elif s[i][0]=="R":
		r+=1
	elif s[i][0]=="C":
		c+=1
	elif s[i][0]=="H":
		h+=1

sl=[m,a,r,c,h]
tl=[[1,1,1,0,0],[1,1,0,1,0],[1,1,0,0,1],[1,0,1,1,0],[1,0,1,0,1],[1,0,0,1,1],[0,1,1,1,0],[0,1,1,0,1],[0,1,0,1,1],[0,0,1,1,1]]

ans=[]

for i in range(10):
	tmpl=[]
	ctr=0
	for k in range(5):
		if tl[i][k]*sl[k]!=0:
			ctr+=1
			tmpl.append(tl[i][k]*sl[k])
	if ctr==3:
		ans.append(tmpl[0]*tmpl[1]*tmpl[2])
print sum(ans)


Measured memory_bytes: 11376
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<int>> a(n,vector<int>(n,0));
    vector<vector<int>> s(n + 1,vector<int>(n + 1,0));
    vector<int> ans(q);
    REP(i,m){
        int r,l;
        cin >> l >> r;
        l--;r--;
        a[l][r]++;
    }
    FOR(i,1,n+1){
        FOR(j,1,n+1){
            s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i - 1][j - 1];
        }
    }
    REP(i,q){
        int p,q;
        cin >> p >> q;
        ans[i] = s[q][q] - s[q][p - 1] - s[p - 1][q] + s[p - 1][p - 1]; 
    }
    REP(i,q)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include<string>
#include<string.h>
using namespace std;

int main() {
  string a;
  cin >> a;
  
  if(a == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3628
X,Y = map(int,input().split())
count = 0
if X == 1:
    count += 300000
if X == 2:
    count += 200000
if X == 3:
    count += 100000
    
if Y == 1:
    count += 300000
if Y == 2:
    count += 200000
if Y == 3:
    count += 100000

if X == 1 and Y == 1:
    count += 400000
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n, a, b, c, d, e;
string s;
bool ok = true;
int main(){
    cin >> n >> a >> b >> c >> d >> s;
    e = max(c, d) - 1;
    for(int i = a; i < e; i++){
        if(s[i] == '#' && s[i+1] == '#') ok = false;
    }
    if(c > d){
        ok = false;
        for(int i = b-2; i < d-1; i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') ok = true;
        }
    }
    puts(ok ? "Yes" : "No");
}

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

using namespace std;
int main()
{
    short n;
    int ma = 0;
    int mi = 100000000;
    cin >> n;
    int a[n];

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    cout << a[n-1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 3e3+17;
int mp[MAXN*2][MAXN*2];
int cnt[MAXN*2][MAXN*2];
inline int dap(int rx,int ry,int lx,int ly)
{
	// debug(rx);
	// debug(ry);
	// debug(lx);
	// debug(ly);
	// debug(cnt[rx][ry]);
	// debug(cnt[lx][ry-1]);
	// debug(cnt[rx-1][ly]);
	// debug(cnt[lx-1][ly-1]);
	//debug(cnt[rx][ry]-cnt[rx][ly-1]-cnt[lx-1][ry]+cnt[lx-1][ly-1]);
	return cnt[rx][ry]-cnt[rx][ly-1]-cnt[lx-1][ry]+cnt[lx-1][ly-1];
}
int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n,k;
    cin>>n>>k;
    for (int i = 0; i < n; ++i)
    {
    	int x,y;
    	string cl;
    	cin>>x>>y>>cl;
    	x++,y++;
    	if(cl=="B")
    		x+=k;
    	int a = x%(2*k)==0?(2*k):x%(2*k);
    	int b = y%(2*k)==0?(2*k):y%(2*k);
    	mp[a][b]++;
    }
    for (int i = 1; i <= 2*k; ++i)
    {
    	for (int j = 1; j <= 2*k; ++j)
    	{
    		cnt[i][j] = mp[i][j]+cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1];
    	}
    }
    int ans = 0;
    for (int i = 1; i <= k; ++i)
    {
    	for (int j = 1; j <= k; ++j)
    	{
    		int mid =  dap(2*k+1-i,2*k+1-j,k+2-i,k+2-j);
    		int zx = dap(k+1-i,k+1-j,1,1);
    		int zs = dap(k+1-i,2*k,1,2*k+2-j);
    		int ys = dap(2*k,2*k,2*k+2-i,2*k+2-j);
    		int yx = dap(2*k,k+1-j,2*k+2-i,1);
    		int sum = mid+zx;
    		if(j!=1) sum += zs;
    		if(i!=1) sum += yx;
    		if((j!=1)&&(i!=1)) sum+=ys;
    		// debug(i);
    		// debug(j);
    		// debug(mid);
    		// debug(zx);
    		// debug(zs);
    		// debug(ys);
    		// debug(yx);
    		int fan = dap(2*k,2*k,1,1)-sum;
    		// debug(sum);
    		// debug(fan);
    		ans = max(ans,max(fan,sum));
    	}
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 97536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define reprev2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int arr[3];
bool v[3];

int main()
{
    rep(i, 3)
    {
        arr[i] = -1;
        v[i] = false;
    }

    int n, m, i, bb;
    cin >> n >> m;
    rep(a, m)
    {
        cin >> i >> bb;
        if (n > 1 && 1 == i && 0 == bb)
        {
            cout << "-1" << endl;
            return (0);
        }
        if (v[i] && arr[i] != bb)
        {
            cout << "-1" << endl;
            return (0);
        }
        arr[i] = bb;
        v[i] = true;
    }
    rep2(i, 1, n + 1)
    {
        if (v[i])
        {
            cout << arr[i];
        }
        else if (n == 1)
        {
            cout << 0;
        }
        else if (i == 1)
        {
            cout << 1;
        }
        else
        {
            cout << 0;
        }
    }
    cout << endl;
}


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans=0;
    vector<int> A(n);
    for(int i=0; i<n; i++) {
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    vector<int> d(1000005);
    vector<int> cnt(1000005);
    for(int i=0; i<n; i++) {
        cnt[A[i]]++;
    }
    if(A[0]==1) {
        if(cnt[1]==1)
            cout << "1\n";
        else
            cout << "0\n";
        return;
    }
    int m = *max_element(A.begin(), A.end());
    for(int i=0; i<n; i++) {
        for(int j=2*A[i]; j<=m; j+=A[i]) {
            d[j]++;
        }
    }

    for(int i=0; i<n; i++) {
        if(d[A[i]]==0 && cnt[A[i]]==1)
            ans++;
    }


    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 11880
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  while(cin>>h>>w,h+w!=0){
    for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
        cout<<(((i+j)%2==0)?"#":".");
      }
      cout<<endl;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 205;
const int mod = 998244353;
const double eps = 1e-9;
const double PI = acos(-1);

int n, x[MAXN], y[MAXN], cnt[MAXN], bin[MAXN];
double a[MAXN];

inline int Sgn(double x)
{
	return fabs(x) < eps ? 0 : x > 0 ? 1 : -1;
}

inline int F(int x)
{
	return (bin[x] - 1 - x - x * (x - 1) / 2 + mod) % mod;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), bin[0] = 1;
	for (int i = 1; i <= n; i ++)
		x[i] = Read(), y[i] = Read(), bin[i] = (bin[i - 1] << 1) % mod;
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1, k = 0; j <= n; j ++)
			if (j ^ i)
			{
				a[++ k] = atan2(y[j] - y[i], x[j] - x[i]);
				if (Sgn(a[k]) <= 0)
					a[k] += PI;
			}
		sort(a + 1, a + n);
		for (int l = 1, r = 1; l < n; cnt[r - l + 1] ++, l = r)
			while (r < n && !Sgn(a[r] - a[l]))
				r ++;
	}
	int ans = F(n);
	for (int i = 1; i <= n; i ++)
		ans = (ans - 1LL * cnt[i] / i * F(i) % mod + mod) % mod;
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 384