akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    vector<int> vec(n);
    for(int i=0;i<n;++i){
        cin >> vec.at(i);
    }
    long long a=vec.at(0),b=vec.at(0),c=0;
    for(int i=0;i<n;++i){
        if(a<vec.at(i)){
            a = vec.at(i);
        }
        if(b>vec.at(i)){
            b = vec.at(i);
        }
        c += vec.at(i);
    }

    cout <<b<<" "<<a<<" "<<c<<endl;
}


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

using namespace std;

typedef long long ll;

class Number {
public:
	int num2;
};
class DSLK {
public:
	Number *x;
	int num;
	DSLK *next;
};

void Solves();
int main() {
	Solves();

	/*
	fstream file;

	file.open("spoj.inp", ios::out | ios::binary);

	int n = 2;
	DSLK *ds = new DSLK();
	DSLK *temp = ds;
	for (int i = 0; i < n; i++) {
		temp->x = new Number();
		temp->num = i;
		temp->x->num2 = i * 10;
		if (i < n - 1) {
			temp->next = new DSLK();
		}
		temp = temp->next;
	}
	file.write((char*)&ds, sizeof(DSLK));
	cout << sizeof(DSLK);
	file.close();

	file.open("spoj.inp", ios::in | ios::binary);

	DSLK *doc = new DSLK();
	file.read((char*)&doc, sizeof(DSLK));
	temp = doc;
	while (temp != NULL) {
		cout << temp->num << endl;
		temp = temp->next;
	}

	file.close();

	DSLK *prev=NULL;
	DSLK *nodeDel;
	temp = ds;
	for (int i = 0; i < n; i++) {
		if (temp->next->num == n- 1) {
			prev = temp;
			temp = temp->next->next;
			break;
		}
		prev = temp;
		temp = temp->next;
	}
	nodeDel = prev->next;
	prev->next = temp;
	delete nodeDel;

	temp = ds;

	
/*	temp = ds;
	ds = temp->next;
	delete temp;
	
	temp = ds;

	while (temp != NULL) {
		cout << temp->num << " ";
		temp = temp->next;
	}
	*/
	return 0;
}

void Solves() {
	ll n, m,a,b;
	cin >> n >> m;
	ll **mtk = new ll*[n+1];
	ll *mark = new ll[n + 1];
	for (int i = 1; i <= n; i++) {
		mtk[i] = new ll[n + 1];
	}
	for (int i = 1; i <= n; i++) {
		mark[i] = 0;
		for (int j = 1; j <= n; j++) {
			mtk[i][j] = 0;
		}
	}

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		mark[a]++;
		mark[b]++;
		//mtk[a][b]++;
		//mtk[b][a]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << mark[i] << endl;
	}
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int k, x;
	cin >> k >> x;
	if (500*k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static int D[1 << 20];
    int n;
    static vi s[1 << 20];
    static int p[1 << 20];
    fi>>n;
    for (int i = 2;i <= n;++i)
    {
        fi>>p[i];
        s[p[i]].pb(i);
    }
    function < void(int) > dfs = [&](int node)
    {
        vi ss;
        for (auto it : s[node])
            dfs(it),ss.pb(D[it]);
        sort(ss.begin(),ss.end());
        int sz = ss.size();
        for (int i = 0;i < sz;++i)
            D[node] = max(D[node],ss[i] + sz - i);
    };
    dfs(1);
    fo << D[1] << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 38144
#include <stdio.h>

int n, m, a;

int main() {
    while (1) {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) break;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((i + j) % 2 == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2048
main = do
  [_, t'] <- map (read :: String -> Int).words <$> getLine
  cts <- map (map read.words).lines <$> getContents
  let limited = filter (\ct -> last ct <= t') cts
  if limited == [] then putStrLn "TLE"
  else print $ minimum (map (\(c:_) -> c) limited)

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimaxze("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX_H 100
#define MAX_M 100
using namespace std;

int H, W;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
char field[MAX_H][MAX_M + 1];
const char t = 'T';
int ans = 0;

void dfs(int x, int y, char a)
{
	field[x][y] = t;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < H && ny < W && nx >= 0 && ny >= 0 && field[nx][ny] == a)
			dfs(nx, ny, a);
	}
}

void solve()
{
	while (true)
	{
		ans = 0;
		cin >> H >> W;
		if (!H && !W)
			break;
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				cin >> field[i][j];
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (field[i][j] != t)
				{
					dfs(i, j, field[i][j]);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 1632
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N,M = map(int,input().split())
    X = list(map(int,input().split()))
    Y = list(map(int,input().split()))

    height = sum((Y[i + 1] - Y[i])*(i + 1)*(M - i - 1)%MOD for i in range(M - 1))%MOD
    ans = sum(height*(X[i + 1] - X[i])*(i + 1)*(N - i - 1)%MOD for i in range(N - 1))%MOD
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18624
#include<iostream>
using namespace std;
#define rep(i,n) for(i = 0;i < n;i++)
int main(){
	int n,i,j,k,l;
	int count[200] = {0},cor = 0;
	while(cin >> n){
		rep(i,10){
			rep(j,10){
				rep(k,10){
					rep(l,10){
						if(n == i+j+k+l)
							count[cor]++;
					}
				}
			}
		}
		cor++;
	}
	rep(i,cor){
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#coding:utf-8
n,k  = map(int,input().split())
ls_a  = list(map(int,input().split()))
target = int(k*(k+1)/2)
ls_target = []
i = 1
while(1):
    for j in range(i):
        temp = ls_a[j:(len(ls_a)-i+j+1)]
        ls_target.append(sum(temp))
    if i==n:
        break
    i+=1

def check(num):
    for i in range(50):
        if (num < 2**i):
            return i-1, 2**(i-1)
mx = ls_target[0]
digit, mx_bin = check(mx)
ans = 0
for d in range(digit+1):
#    print (mx_bin)
#    print (ls_target)
    new_idx = []
    cnt = 0
    for idx,ls in enumerate(ls_target):
        if ls & mx_bin > 0:
            cnt += 1
            new_idx.append(idx)
    if cnt >= k:
        ls_target = [ls_target[i] for i in new_idx]
        ans += mx_bin
    mx_bin = int(mx_bin/2)
print (ans)

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

typedef long long ll;

void solve() {
    int N, T, A;
    cin >> N >> T;
    int min_A = 1000000001, max_diff = 0, ans = 0;
    rep(i,N) {
        cin >> A;
        min_A = min(min_A, A);
        if (A - min_A == max_diff) ans++;
        if (A - min_A > max_diff) {
            max_diff = A - min_A;
            ans = 1;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    v = sorted(tuple(map(int, input().split())))
    val = v[0]
    for i in v[1:]:
        val = (val + i) / 2
    print(val)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef unsigned int uint;
typedef unsigned long int lu;
typedef unsigned long long llu;
typedef long int ld;
typedef long long lld;
typedef vector<int> vint;
typedef vector<unsigned int> vuint;
typedef vector<unsigned long int> vlu;
typedef vector<unsigned long long> vllu;
typedef vector<long int> vld;
typedef vector<long long> vlld;

lld lcm(int n1,int n2)
{
    lld max = (n1 > n2) ? n1 : n2;
    do
    {
        if (max % n1 == 0 && max % n2 == 0)
        {
            return max;
            break;
        }
        else
            ++max;
    } while (true);
    return -1;
}

int main() {
    int x;
    cin>>x;
    cout<<lcm(360,x)/x<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b; cin >> a >> b;
    
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

from collections import Counter

n, m = map(int, raw_input().split())
q = [flatten for i in range(0, m) for flatten in raw_input().split()]

counter = Counter(q)
for word, cnt in counter.most_common():
    if cnt % 2 != 0:
        print "NO"
        exit()

print "YES"


Measured memory_bytes: 29348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String t[];
        int count = 0;
        boolean flag=true;
        try {
            String w = br.readLine();
            while(flag){
                t = br.readLine().split(" ");
                for (String string : t) {
                    if(string.equals("END_OF_TEXT")){
                        flag = false;
                        break;
                    }
                    if(string.equalsIgnoreCase(w)){
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
}

Measured memory_bytes: 24184
#include<stdio.h>

int c = 0;

void merge(int a[], int left, int mid, int right)
{
	int i;
	int n1 = mid - left;
	int n2 = right - mid;
	int l[n1], r[n2];
	for( i = 0; i < n1; i++ ){
		l[i] = a[left+i];
	}
	for( i = 0; i < n2; i++ ){
		r[i] = a[mid+i];
	}
	
	l[n1] = 100000000000;
	r[n2] = 100000000000;
	
	int j = 0, k;
	i = 0;
	
	for( k = left; k < right; k++ ){
		c++;
		if( l[i] <= r[j] ){
			a[k] = l[i++];
		}else{
			a[k] = r[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(void){
	int n, i;
	scanf( "%d", &n );
	int a[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &a[i] );
	}
	
	mergeSort(a, 0, n);
	
	for( i = 0; i < n-1; i++ ){
		printf( "%d ", a[i] );
	}
	printf( "%d\n", a[n-1] );
	
	printf( "%d\n", c );
	
	return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	sort(a.begin(), a.end());
	cout << accumulate(a.begin(), a.begin() + k, 0) << '\n';
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	
	std::vector<i64> ans;
	for(int i = 0; i < n; i++) ans.push_back(a[i] * 2);
	
	i64 tmp = 0;
	for(int i = 0; i < n; i++) {
		if(i & 1) tmp -= ans[i];
		else tmp += ans[i];
	}
	
	tmp /= 2;
	std::vector<i64> vec(1, tmp);
	for(int i = 0; i < n - 1; i++) {
		tmp = ans[i] - tmp;
		vec.push_back(tmp);
	}
		
	for(auto v: vec) printf("%lld ", v);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3828
S = input()

# 次の日曜日が何日後か求めよ
if S == "SUN":
    print(7)

if S == "SAT":
    print(1)

if S == "MON":
    print(6)

if S == "TUE":
    print(5)

if S == "WED":
    print(4)

if S == "THU":
    print(3)

if S == "FRI":
    print(2)

Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,m; cin >> n >> m;
    int a[50],b[50],c[50],d[50];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,m){
        cin >> c[i] >> d[i];
    }
    int ans = 0;
    rep(i,n){
        int mindist = INF;
        rep(j,m){
            int dist = abs(c[j]-a[i])+abs(d[j]-b[i]);
            if(mindist>dist){
                mindist = dist;
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

primes = [1] * 500000
primes[0] = 0

for i in range(3, 1000, 2):
    if primes[i // 2]:
        primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)

Measured memory_bytes: 16832
#import<iostream>
long N,M,c,n=1,i=1,m=1e9+7,h,r,d;main(){for(std::cin>>N>>M;M/++i/i;n=n*r%m){for(;M%i<1;++c)M/=i;for(r=d=1;c;r=r*(N+c)%m)d=d*c--%m;for(h=2*m-4;h/=2;d=d*d%m)r=h%2?r*d%m:r;}std::cout<<n*(M>1?N:1)%m;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

template <class T>
T gcd(T n, T m) {
    while (m != 0) {
        n %= m;
        std::swap(n, m);
    }
    return n;
}

using lint = long long;

int main() {
    lint a, b;
    std::cin >> a >> b;
    std::cout << a / gcd(a, b) * b << std::endl;
    return 0;
}


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

int main (void)
{
    boost::multiprecision::cpp_int a, b, ans;
    cin >> a >> b;
    ans = a - b;
    cout << ans << endl;
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;
bool  f(string a){
  for(int i=0,j=a.size()-1;i<j;i++,j--)
          if(a[i]!=a[j])
                return false;
 return true;

}
void solve(){
   string s;
   cin>>s;
 if(f(s))
      cout<<"Yes";
  else cout<<"No";
}

int main(){
   std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      solve(); 
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int q[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	{
		cout<<s1[i]<<s2[i];
	}

}


Measured memory_bytes: 3628
//実装21分
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
#define int long long
using namespace std;
typedef pair<int, int> P;

struct BIT {
	int n;
	int a[300000];
	void init(int n) { this->n = n; int i; rep(i, n + 1) a[i] = 0; }
	void add(int p, int x) {
		for (int i = p; i <= n; i += i & -i) {
			a[i] += x;
		}
	}
	int sum(int p) {
		int ret = 0;
		for (int i = p; i > 0; i -= i & -i) {
			ret += a[i];
		}
		return ret;
	}
};

int mod = 998244353;
int n;
int p2[200001];
P pa[200000];
int x[200000], y[200000];
BIT seg;

signed main() {
	int i;
	
	cin >> n;
	
	p2[0] = 1;
	rep(i, n) p2[i + 1] = (p2[i] * 2) % mod;
	
	rep(i, n) {
		cin >> pa[i].first >> pa[i].second;
		x[i] = pa[i].first;
		y[i] = pa[i].second;
	}
	sort(x, x + n);
	sort(y, y + n);
	
	rep(i, n) {
		pa[i].first = lower_bound(x, x + n, pa[i].first) - x;
		pa[i].second = lower_bound(y, y + n, pa[i].second) - y;
	}
	sort(pa, pa + n);
	
	seg.init(n);
	
	rep(i, n) {
		x[i] = pa[i].first;
		y[i] = pa[i].second + 1;
	}
	
	static int ru[200000];
	static int rd[200000];
	
	rrep(i, n) {
		int s = seg.sum(y[i]);
		ru[i] = (n - 1 - i) - s;
		rd[i] = s;
		seg.add(y[i], 1);
	}
	
	seg.init(n);
	
	int ans = 0;
	rep(i, n) {
		int s = seg.sum(y[i]);
		int lu = i - s;
		int ld = s;
		seg.add(y[i], 1);
		
		//cout << "x = " << x[i] << ", y = " << y[i] << ", lu = " << lu << ", ld = " << ld << ", ru = " << ru[i] << ", rd = " << rd[i] << endl;
		int res1 = (p2[lu] + mod - 1) * (p2[rd[i]] + mod - 1) % mod;
		int res2 = (p2[ld] + mod - 1) * (p2[ru[i]] + mod - 1) % mod;
		int res3 = res1 * res2 % mod;
		res1 = res1 * p2[ld + ru[i]] % mod;
		res2 = res2 * p2[lu + rd[i]] % mod;
		int res = (res1 + res2 - res3 + mod) % mod;
		ans += res;
		ans %= mod;
	}
	ans += n * p2[n - 1];
	ans %= mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<bool> ans(n, false); // ボールを入れるならtrue
    // 半分より上で余りが1なら絶対入れる必要あり
    map<ll, int> cnt;
    for (int i = n / 2; i < n; i++)
    {
        if (a[i])
        {
            ans[i] = true;
            auto yakusu = divisor(i + 1);
            for (auto a : yakusu)
            {
                cnt[a]++;
            }
        }
    }
    for (int i = n / 2 - 1; i >= 0; i--)
    {
        if (a[i] != cnt[i + 1] % 2)
        {
            ans[i] = true;
            auto yakusu = divisor(i + 1);
            for (auto a : yakusu)
            {
                cnt[a]++;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] != cnt[i + 1] % 2)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << count(ALL(ans), true) << endl;
    for (int i = 0; i < n; i++)
    {
        if (ans[i])
        {
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 14464
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=1;
int k,n;
int h,w;
signed main(){
	cin>>h>>w>>n>>k;
	char s='1',t='0';
	int f=1;
	rep(i,h){
		if(i>=k && f){swap(s,t);f=0;}
		rep(j,w){
			if(j<n)cout<<s;
			else cout<<t;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
using namespace std;
bool turn_f = false;
int  n, a, b;

int move(int my,int enemy,int* board){
  if(board[my+1] < 0 || my+1 == enemy){
    if(board[my-1] < 0 || my-1 == enemy){
      return 0;
    }else{
      board[my-1] = 1;
      board[my] = 0;
      if(turn_f){
        a--;
      }else{
        b--;
      }
      return 1;
    }
  }else if(board[my-1] < 0 || my-1 == enemy){
    if(board[my+1] < 0 || my+1 == enemy){
      return 0;
    }else{
      board[my+1] = 1;
      board[my] = 0;
      my++;
      if(turn_f){
        a++;
      }else{
        b++;
      }
      return 1;
    }
  }
  else{
    if(my > enemy){
      board[my-1] = 1;
      board[my] = 0;
      if(turn_f){
        a--;
      }else{
        b--;
      }
    }else{
      board[my+1] = 1;
      board[my] = 0;
      if(turn_f){
        a++;
      }else{
        b++;
      }
    }
    return 1;
  }
}

int main()
{
  cin >> n >> a >> b;
  int board[102];
  for(int i=0;i<102;i++){
    board[i] = -1;
  }
  for(int i=1;i<=n;i++){
    board[i] = 0;
  }
  board[a] = 1;
  board[b] = 1;
  for(;;){
    //cout << a << b << "\n";
    turn_f = !turn_f;
    if(turn_f){//先行
      if(move(a,b,board) == 0){
        cout << "Borys" << "\n";
        return 0;
      }
    }else{
      if(move(b,a,board) == 0){
        cout << "Alice" << "\n";
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

#エラトステネスの篩と素因数分解

from collections import Counter

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a
M = 10**6 + 8
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C


N = int(readline())
A = list(map(int, readline().split()))

D = Counter()

for a in A:
    c = pd(a)
    for k in c.keys():
        D[k] += 1


res = A[0]
for a in A:
    res = gcd(res, a)
ans = None
if all(a == 1 for a in A) or max(D.values()) == 1:
    ans = 'pairwise coprime'
elif res == 1:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'

print(ans)


Measured memory_bytes: 193624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    int n;
    cin >> n;
    vector<int> t(n+10),x(n+10),y(n+10);
    t[0] = x[0] = y[0] = 0;
    for(int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
    for(int i = 1; i <= n; i++){
        int mx = abs(x[i]-x[i-1]),my = abs(y[i]-y[i-1]),mt = t[i]-t[i-1];
        if(mx + my > t[i] || (mx + my) % 2 != abs(t[i]-t[i-1]) % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	int ans = 700;
	for(int i = 0; i < 3; i++)
	{
		if(s[i] == 'o')
		{
			ans += 100;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

class union_find {
	int M;
	std::vector<int> parent, sz;

public :
	const int N;

	union_find(const int& n) : N(n), M(n) {parent.resize(N, -1); sz.resize(N, 1);}

	int root(const int& i) {
		if (parent[i] == -1) return i;
		return parent[i] = root(parent[i]);
	}

	inline bool is_united(const int& i, const int& j) {return (root(i) == root(j));}

	bool unite(int i, int j) {
		if (is_united(i, j)) return false;
		if (size(i) < size(j)) std::swap(i, j);
		i = root(i); j = root(j);
		parent[j] = i;
		sz[i] += sz[j];
		M--;
		return true;
	}

	inline const int& size(const int& i) {return sz[root(i)];}
	inline const int& count_trees()const{return M;}
};

int main() {
	int n, m;
	std::cin >> n >> m;
	union_find uf(n);
	while (m--) {
		int a, b;
		std::cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) ans = std::max(ans, uf.size(i));
	std::cout << ans << '\n';

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull N,K,H;	cin>>N>>K;
  	if(K>=N)	cout<<"0"<<endl;
  	else{
	vector<ll>	vec;
	FOR(i,0,N){
		cin>>H;
		vec.push_back(H);
	}
	sort(range(vec));
	FOR(i,0,K)	vec.pop_back();
    ull ans=0;
    for (auto itr = vec.begin(); itr != vec.end(); ++itr) ans+=*itr;
    cout<<ans<<endl;
    }

    return 0;
}




Measured memory_bytes: 2420
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		var x = Console.ReadLine().Split().Select(y => int.Parse(y)).ToArray();
		int a = x[0];
		int b = x[1];
		int c = x[2];
		int k = x[3];
		
		if(k<=a){
			Console.WriteLine(k);
		}else if(k<=a+b){
			Console.WriteLine(a);
		}else{
			Console.WriteLine(2*a+b-k);
		}
		
	}
}

Measured memory_bytes: 28156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        // 各桁取り出し(範囲は5桁)
        int s = i % 10; // 下から1桁目
        int t = (i/10000) % 10; // 5桁目
        int u = (i/10) % 10; // 2桁目
        int v = (i/1000) % 10; // 4桁目
        if (s == t && u == v) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define int ll
typedef bitset<200001> Mybit;
signed main(){
    ios::sync_with_stdio(false);
    int n;
    string x;
    cin >> n >> x;
    Mybit xbit(x);
    int x_popcnt = xbit.count();
    vector<int> mod_plus(n+1), mod_minus(n+1);//2^iをx_popcnt+1, x_popcnt-1で割ったあまり
    mod_plus[0] = 1;
    mod_minus[0] = 1;

    for(int i = 1; i < n; i++) {
        mod_plus[i] = mod_plus[i-1] *2;
        mod_plus[i] %= x_popcnt+1;
        if(x_popcnt == 1) continue;
        mod_minus[i] = mod_minus[i-1] *2;
        mod_minus[i] %= x_popcnt-1;
    }
    
    int xmodp = 0, xmodm = 0;
    rep(i,n) {
        if(xbit[i] == 1) {
            xmodp += mod_plus[i];
            xmodp %= x_popcnt+1;
            if(x_popcnt == 1) continue;
            xmodm += mod_minus[i];
            xmodm %= x_popcnt-1;
        }
    }

    for(int i = n-1; i >= 0; i--) {
        int ans = 1;
        int mod;
        //一回だけ自力で
        if(xbit[i] == 0) {
            mod = xmodp;
            mod += mod_plus[i];
            mod %= x_popcnt+1;
        } else {
            mod = xmodm;
            mod += x_popcnt-1;
            if(x_popcnt == 1) {
                cout << 0 << endl;
                continue;
            }
            mod -= mod_minus[i];
            mod %= x_popcnt-1;
        }
        while(mod > 0) {
            mod%=__builtin_popcount(mod);
            ans++;
        }
        cout << ans << endl;
    }
}


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

int main()
{
	int count[30] = {0};
	char c;
	
	while((cin >> c))
	{
		if(c > 'z' || c < 'a')
		{
			count[c - 'A']++;
			continue;
		}
		count[c - 'a']++;
	}
	
	for(int i = 0; i < 26; i++)
	{
		cout << (char)('a' + i) << " : " << count[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int card[3][3];
bool works[3][3];
int main() {
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            cin >> card[i][j];
        }
    }
    int N;
    cin >> N;
    for (int i=0; i<N; i++){
        int a;
        scanf("%d", &a);
        for (int k=0; k<3; k++){
            for (int j=0; j<3; j++){
                if (card[k][j] == a) works[k][j] = true;
            }
        }
    }
    for (int i=0; i<3; i++){
        bool bingo = true;
        for (int j=0; j<3; j++){
            if (works[i][j] == false) bingo = false;
        }
        if (bingo){
            cout << "Yes\n";
            return 0;
        }
    }
    for (int i=0; i<3; i++){
        bool bingo = true;
        for (int j=0; j<3; j++){
            if (works[j][i] == false) bingo = false;
        }
        if (bingo){
            cout << "Yes\n";
            return 0;
        }
    }
    if (works[0][0] && works[1][1] && works[2][2]){
        cout << "Yes\n";
        return 0;
    }
    if (works[0][2] && works[1][1] && works[2][0]){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main()
{
  string input_str, display_str = "";
  cin >> input_str;
  for (int i = 0; i < input_str.length(); i++)
  {
    if (input_str.compare(i, 1, "B") == 0 && display_str.length() > 0)
    {
      display_str.erase(display_str.length() - 1);
    }
    else if (input_str.compare(i, 1, "0") == 0 || input_str.compare(i, 1, "1") == 0)
    {
      display_str += input_str[i];
    }
  }
  cout << display_str;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

bool isnp[200010];

int main(){
	for(int i = 2; i < 1000; ++i){
		if(!isnp[i]){
			for(int j = i * i; j <= 200000; j += i){
				isnp[j] = true;
			}
		}
	}
	
	vector<int> pr;
	for(int i = 2; i <= 200000; ++i){
		if(!isnp[i]){ pr.push_back(i); }
	}

	int n, p;
	while(scanf("%d%d", &n, &p), n != -1){
		vector<int> tbl;
		int k = upper_bound(pr.begin(), pr.end(), n) - pr.begin();
		for(int i = k; i <= k + p; ++i)
		for(int j = i; j <= k + p; ++j){
			tbl.push_back(pr[i] + pr[j]);
		}
		sort(tbl.begin(), tbl.end());
		printf("%d\n", tbl[p - 1]);
	}
}

Measured memory_bytes: 1372
s = input()
l = len(s)
one = 0
two = 0
for i in range(l):
  if i % 2 == 0:
    if s[i] == '0':
      one += 1
    else:
      two += 1
  else:
    if s[i] == '1':
      one += 1
    else:
      two += 1

print(min(one , two))

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

int main(void){
	int a, b;
  cin >> a >> b;
  
  if(a == 1) a += 13;
  if(b == 1) b += 13;
  
  if(a > b){
  cout << "Alice" << endl;
  }
  else if(a < b){
  cout << "Bob" << endl;
  }
  else{
  cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $N, $M);
$map = [];
while($M--){
    fscanf(STDIN, "%d%d", $s, $c);
    $s = $N - $s + 1;
    if(isset($map[$s]) && $map[$s] != $c){
        echo "-1";
        exit;
    }else{
        $map[$s] = $c;
    }
}
$ans = 0;
for($i=1;$i<=$N;$i++){
    if(isset($map[$i])){
        if($i == $N && $i > 1 && $map[$i] == 0 ){
            echo "-1";
            exit;
        }
        $ans = $map[$i] * pow(10, $i-1) + $ans;
    }else{
        if($i == $N && $i > 1){
            $ans = 1 * pow(10, $i - 1) + $ans;
        }else {
            $ans = 0 * pow(10, $i - 1) + $ans;
        }
    }
}
echo $ans;

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

string s1, s2;

int main() {
	cin >> s1; 
	for (int i = s1.size() - 1; i >= 0; --i) 
		s2 += s1[i]; 
	for (int i = 0; i < s2.size(); ++i) {
		if (s2[i] == 'b') s2[i] = 'd'; 
		else if (s2[i] == 'd') s2[i] = 'b'; 
		else if (s2[i] == 'p') s2[i] = 'q'; 
		else if (s2[i] == 'q') s2[i] = 'p'; 
	}
	if (s1 == s2) puts("Yes");
	else puts("No"); 
	return 0; 
}

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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string a;
        cin >> a;
        sort(all(a));
        mp[a]++;
    }
    ll ans = 0;
    for(auto p : mp){
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int n,num[300005];
LL ss,mx[300005],mn[300005],ans;
priority_queue<int>pq;
int main()
{
    ans=-MMX;
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)
    {
        scanf("%d",&num[i]);
    }
    for(int i=1;i<=n;i++)
    {
        pq.push(-num[i]);
        ss+=num[i];
        mx[i]=ss;
    }
    for(int i=n+1;i<=3*n;i++)
    {
        if(-pq.top()<num[i])
        {
            ss+=pq.top();
            pq.pop();
            ss+=num[i];
            pq.push(-num[i]);
        }
        mx[i]=ss;
    }
    while(!pq.empty())pq.pop();
    ss=0;
    for(int i=n*3;i>n*2;i--)
    {
        pq.push(num[i]);
        ss-=num[i];
        mn[i]=ss;
    }
    for(int i=(n*2);i>0;i--)
    {
        if(pq.top()>num[i])
        {
            ss+=pq.top();
            pq.pop();
            ss-=num[i];
            pq.push(num[i]);
        }
        mn[i]=ss;
    }
    for(int i=n;i<=n*2;i++)
    {
        //printf("%d %lld %lld\n",i,mx[i],mn[i+1]);
        ans=max(ans,mx[i]+mn[i+1]);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h[2],m[2];
	REP(i,2) cin>>h[i]>>m[i];
	
	int k;
	cin>>k;
	
	if(h[0]>h[1]) h[1]+=24;
	REP(i,2) m[i]+=60*h[i];
	
	cout<<m[1]-m[0]-k<<endl;
}

Measured memory_bytes: 3624
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=n/i;
		if(n%i==0)
			ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

bool table[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    if(a<=c && c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 5'009;

int n;
int m;
int x[N];
int y[N];
int cnt[N];
bool was[N];
int q[N];

void bfs(int from) {
  for (int i = 0; i < n; ++i) {
    was[i] = false;
  }
  was[from] = true;
  q[0] = from;
  for (int qh = 0, qt = 1; qh < qt; ++qh) {
    int z = q[qh];
    for (int i = 0; i < m; ++i) {
      if (x[i] == z) {
        if (!was[y[i]]) {
          was[y[i]] = true;
          q[qt++] = y[i];
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (was[i]) {
      ++cnt[i];
    }
  }
}

int c[N];
int d[N];

int main() {
  int v;
  scanf("%d%d%d", &n, &m, &v);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", x + i, y + i, c + i);
    --x[i];
    --y[i];
    c[i] = v - c[i];
  }
  for (int i = 0; i < n; ++i) {
    cnt[i] = 0;
  }
  bfs(0);
  for (int i = 0; i < m; ++i) {
    swap(x[i], y[i]);
  }
  bfs(n - 1);
  for (int i = 0; i < m; ++i) {
    swap(x[i], y[i]);
  }
  const int inf = 1'000'000'000;
  for (int i = 0; i < n; ++i) {
    d[i] = inf;
  }
  d[0] = 0;
  for (int it = 0; it < n - 1; ++it) {
    for (int i = 0; i < m; ++i) {
      if (cnt[x[i]] != 2 || cnt[y[i]] != 2) {
        continue;
      }
      if (d[x[i]] + c[i] < d[y[i]]) {
        d[y[i]] = d[x[i]] + c[i];
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    if (cnt[x[i]] != 2 || cnt[y[i]] != 2) {
      continue;
    }
    if (d[x[i]] + c[i] < d[y[i]]) {
      puts("-1");
      return 0;
    }
  }
  printf("%d\n", max(0, -d[n - 1]));
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    map<char,ll> mp;
    ll n; cin >> n;
    rep(i,n){
        string s; cin >> s;
        if(s[0]=='M'||s[0]=='A'||s[0]=='R'||s[0]=='C'||s[0]=='H'){
            mp[s[0]]++;
        }
    }
    ll ans = 0;
    for(auto i : mp){
        for(auto j : mp){
            for(auto k : mp){
                if(i.first!=j.first && j.first!=k.first && i.first!=k.first){
                    ans += i.second*j.second*k.second;
                }
            }
        }
    }
    cout << ans/6 << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

ll RepeatSquaring(ll n, ll p, ll M){
    if(p == 0) return 1;
    if(p % 2 == 0){
        ll t = RepeatSquaring(n, p/2, MOD);
        return t*t % M;
    }else{
        return n * RepeatSquaring(n, p-1, MOD) % MOD;
    }
}

ll Factorial(ll n, ll M){
    ll res = 1;
    for(ll i = 1; i <= n; i++){
        res *= i;
        res %= M;
    }
    return res;
}

ll modn(ll n, ll a, ll M){
    ll res = 1;
    ll mul = n;
    rep(i, a){
        res *= mul;
        res %= M;
        mul--;
    }
    return res;
}

ll modpow(ll a, ll n, ll p) {
    ll result = 1;
    while (n > 0) {
        if (n & 1) result = result * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return result;
};

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll all = modpow(2, n, MOD) - 1;
    if(all < 0) all += MOD;
    
    ll coma, comb, a1, b1;
    a1 = modn(a, a, MOD);
    b1 = modn(b, b, MOD);
    coma = RepeatSquaring(a1, MOD-2, MOD) * modn(n, a, MOD);
    coma %= MOD;
    comb = RepeatSquaring(b1, MOD-2, MOD) * modn(n, b, MOD);
    comb %= MOD;
    
    all -= coma;
    if(all < 0) all += MOD;
    all %= MOD;
    
    all -= comb;
    if(all < 0) all += MOD;
    all %= MOD;
    cout << all << endl;
}




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

namespace AtCoder.C
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long N { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            N = CR.GetLong();
            A = CR.GetLongs();

            var result = new long[N];
            foreach (var a in A)
            {
                result[a - 1]++;
            }

            var sb = new StringBuilder();
            foreach (var r in result)
            {
                sb.AppendLine(r.ToString());
            }

            return sb.ToString().Trim();
        }
    }
}


Measured memory_bytes: 47736
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

using P = pair<int, int>;
const int INF = 1 << 30;
int N, M;
int A[200010];
int L[200010], R[200010];
int mn[200010];
int dp[200010];

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

    cin >> N >> M;
    REP(i, N) cin >> A[i];
    vector<P> ps;
    REP(i, M) {
        cin >> L[i] >> R[i];
        --L[i]; --R[i];
        ps.emplace_back(R[i], L[i]);
    }
    REP(i, N + 1) mn[i] = INF;
    REP(i, M) mn[ps[i].first] = min(mn[ps[i].first], ps[i].second);
    for (int i = N - 2; i >= 0; --i) if (mn[i + 1] <= i) mn[i] = min(mn[i], mn[i + 1]);
    REP(i, N) {
        if (mn[i] == INF) dp[i + 1] = dp[i] + A[i];
        else dp[i + 1] = max(dp[i], dp[mn[i]] + A[i]);
    }
    cout << dp[N] << endl;
}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

int main() {
  ll h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}


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

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

  char A;
  A=N;

  N=toupper(N);
  if(A==N){
    cout << "A" <<endl;

  }
  else{
    cout << "a" << endl;
  }

}


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

typedef long long ll;

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

  int q;  cin >> q;
  for(int i=0; i<q; i++){
    int k; cin >> k;
    cout << binary_search(a.begin(),a.end(),k) << endl;
  }

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1e9+7;


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

  int n;
  cin >> n;
  vll a(n);
  vvi b(n,vi(60));
  vvi sum(n+1,vi(60));
  rep(i,n){
    cin >> a[i];
    rep(j,60){
      sum[i+1][j] = sum[i][j];
      b[i][j] = a[i]%2;
      sum[i+1][j] += b[i][j];
      a[i] /= 2;
    }
  }

  ll ret = 0;
  rep(i,n){
    ll p = 1;
    rep(j,60){
      if(b[i][j] == 0){
        ret += p * (sum[n][j] - sum[i+1][j]) % mod;
        ret %= mod;
      }else{
        ret += p * (n - i - 1 - (sum[n][j] - sum[i+1][j])) % mod;
        ret %= mod;
      }
      p = p*2 % mod;
    }
  }
  cout << ret << endl;
}


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


int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}


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

using namespace std;

int main()
{
    int result = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
        if (s[i] != t[i])
            result++;
    cout << result;
    return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 105;
int a[MAXN],n,mx,mxcnt,cnt[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		if(a[i]>mx)mx=a[i],mxcnt=1;
		else if(a[i]==mx)++mxcnt;
	}
	if(mxcnt<2)puts("Impossible");
	else{
		int mn=(mx+1)/2;
		for(int i=1;i<=n;++i)
			if(a[i]<mn){puts("Impossible");return 0;}
			else ++cnt[a[i]];
		if(!(mx&1)){if(cnt[mn]!=1){puts("Impossible");return 0;}}
		else if(cnt[mn]!=2){puts("Impossible");return 0;}
		for(int i=mn+1;i<=mx;++i)
			if(cnt[i]<2){puts("Impossible");return 0;}
		puts("Possible");
	}
	return 0;
}


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

int main(void)
{
	int r, d, x2000;
	vector<int> x(11);

	cin >> r >> d >> x[0];

	for (int i = 1; i <= 10; i++)
	{
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, a[10001], i;
	int min, max;
	long long sum = 0;
	scanf("%d", &n);
	for (i = 0; i<n; i++) {
		scanf("%d", &a[i]);
	}
	min = a[0];
	max = a[0];
	for (i = 0; i<n; i++) {
		if (min>a[i])min = a[i];
		if (max<a[i])max = a[i];
		sum += a[i];
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 2744
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;long D[1<<20],Z[1<<20],A[1<<18],x,z;long f(a,k,l,r,b){D[k]+=z=Z[k];Z[2*k]+=z;Z[2*k+1]+=z;Z[k]=0;return a<=l&r<i+2?D[k]+(Z[k]=x):l<=i&a<r?D[k]=fmax(f(a,2*k,l,b),f(a,2*k+1,b=l+r>>1,r)):D[k];}main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 19200