akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  ll sum = 0;
  rep(i, N) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  if (K >= N)
    cout << '0' << endl;
  else {
    rep(i, N-K) {
      sum += H[i];
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 1792
n = int(input())
li = []

sumac = 0
sumwa = 0
sumtle = 0
sumre = 0

for i in range(n):
    case = input()
    if (case == "AC"):
        sumac += 1
    elif (case == "WA"):
        sumwa += 1
    elif (case == "TLE"):
        sumtle += 1
    else:
        sumre += 1

print("AC x " + str(sumac))
print("WA x " + str(sumwa))
print("TLE x " + str(sumtle))
print("RE x "+str(sumre))


Measured memory_bytes: 9204
#include <iostream>

using namespace std;

int main() {
  char c;
  cin >> c;
  switch (c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    cout << "vowel" << endl;
    break;
  default:
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={-1,0,1,-1,1,-1,0,1},DY[]={-1,-1,-1,0,0,1,1,1};

int w, h;
VII cs;

void dfs(int y, int x){
	int ans = 0;
	cs[y][x] = 0;
	rep(i, 8){
		int ny = y + DY[i], nx = x + DX[i];
		if(range(ny, 0, h - 1) && range(nx, 0, w - 1) && cs[ny][nx]){
			dfs(ny, nx);
		}
	}
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		cs.clear();
		int ans = 0;
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		rep(i, h){
			VI c;
			rep(j, w){
				int a;
				cin >> a;
				c.pb(a);
			}
			cs.pb(c);
		}
		rep(i, cs.size()){
			rep(j, cs[i].size()){
				if(!cs[i][j]) continue;
				dfs(i, j);
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1312
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf (1ll<<60)
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
int vis[256];
char s[10];
int main()
{
	int i,n=read();
	for(i=1;i<=n;i++){
		scanf("%s",s);
		vis[(int)s[0]]=1;
	}
	int ans=0;
	for(i=0;i<256;i++)
		if(vis[i])++ans;
	if(ans==4)printf("Four\n");
	else printf("Three\n");
	return 0;
}

Measured memory_bytes: 128
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
a,b,c,d=get_ints()
ans=[]
x=a*c
y=a*d
z=b*c
w=b*d
ans.extend(list([x,y,z,w]))
print(max(ans))


Measured memory_bytes: 62012
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<accumulate(a.begin(),a.begin()+k,0)<<endl;
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  vector<bool> color(8,false);
  int crown = 0;
  rep(i, N) {
    int tmp = a[i]/400;
    if(tmp >= 8) {
      crown++;
      continue;
    }
    color[tmp] = true;
  }
  int num = 0;
  rep(i, 8) {
    if(color[i])
      num++;
  }
  cout << max(num, 1) << " " << num+crown << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  double x=0.0,y=0.0;
  while(cin>>a>>b>>e>>c>>d>>f){
    x=(d*e-b*f)/(a*d-b*c);
    y=(a*f-c*e)/(a*d-b*c);
    if(x<=0&&x>-0.001){
      x=0;
    }
    if(y<=0&&y>-0.001){
      y=0;
    }
    
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1236
h, n = map(int, input().split())
c = [0]*n
m = [0]*n

mc = 0
for i in range(n):
    c[i], m[i] = map(int, input().split())
    if mc < c[i]:
        mc = c[i]
    
dp = [10**10]*(h+mc)
dp[0] = 0

for i in range(1, h + mc):
    dp[i] = min(dp[i-a] + b for a, b in zip(c, m))
        
print(min(dp[h:]))

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 105 , K = 1e5+5; 
int a[N],n; 
int dp[K][2] ; 

int main(){
	int k ;
	cin >> n >> k; 
	memset(dp,-1,sizeof dp); 
	for(int i =0 ; i < n ;i++)cin >> a[i] ; 
		for(int j = 0 ; j< *min_element(a,a+n) ; j++ ){
			dp[j][0]=1; 
			dp[j][1]=0;
		}
	

	for(int j= 0 ; j <= k ; j++ ){
		for(int i = 0 ; i < n ; i++ ){
			if(j+a[i] <= k ){

				if(dp[j+a[i]][0]==-1)dp[j+a[i]][0]=dp[j][1]; 
				if(dp[j+a[i]][0]==1 && dp[j][1]==0 )dp[j+a[i]][0]=0; 

				if(dp[j+a[i]][1]==-1)dp[j+a[i]][1]=dp[j][0]; 
				if(dp[j+a[i]][1]==0 && dp[j][0]==1 )dp[j+a[i]][1]=1; 
				
			}
		} 
	}
	cout << (dp[k][0]==0?"First":"Second") << endl; 
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;

int main()
{
	cin >> n;
	int l, r;
	int num = 0;
	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		num += r - l + 1;
	}
	cout << num << endl;
	return 0;
}

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

using namespace std;

int n, u, v;
int dist[2][100000];
vector<vector<int> > g;

void dfs(int v, int prev, int d, int f) {
	dist[f][v] = d;
	for (auto e : g[v])
		if (e != prev) dfs(e, v, d + 1, f);
}

int main() {
	cin >> n >> u >> v;
	--u, --v;
	g.resize(n);
	for (int i = 1; i < n; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(u, -1, 0, 0);
	dfs(v, -1, 0, 1);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (dist[0][i] < dist[1][i]) {
			ans = max(ans, dist[1][i] - 1);
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 11648
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,a,b,c,d=get_i
S=get_nsp
def fulfil?(s,g)
  (s).upto(g) do|i|
      if S[i]=="#" and S[i]==S[i+1]
          return false
      end
  end
  return true
end
unless fulfil?(a-1,c-1) and fulfil?(b-1,d-1)
    puts "No"
    exit
end
if c<d
    puts "Yes"
else
    flag=false
    (b-1).upto(min(d-1,N-2)) do|i|
        if S[i]=="." and S[i]==S[i-1] and S[i]==S[i+1]
            flag=true
            break
        end
    end 
    puts yn_judge(flag)
end

Measured memory_bytes: 16764
I=int
i=input
n=I(i())
a=eval('[i().split()for _ in"_"*I(i())],'*n)
print(max(all(I(y)==i>>I(x)-1&1for j,t in enumerate(a)if i>>j&1for x,y in t)*bin(i).count('1')for i in range(1<<n)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;string s;
  cin>>a>>b>>s;
  string ans="Yes";
  if(s[a]!='-')ans="No";
  if(s.substr(0,a).find('-')!=string::npos)ans="No";
  if(s.substr(a+1,b).find('-')!=string::npos)ans="No";
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
def main():
    _, _, m_num = map(int, input().split())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    min_price = min(a) + min(b)

    m = []
    for _ in range(m_num):
        x, y, c = map(int, input().split())
        price = a[x - 1] + b[y - 1] - c
        min_price = min(min_price, price)
    
    print(min_price)

main()

Measured memory_bytes: 18488
import java.util.*

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val nodes = Array(n) { mutableListOf<Pair<Int, Int>>() }
    val pColors = Array(n) { 0 }
    val ans = Array(n-1) { 0 }

    repeat(n-1) { idx ->
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        nodes[a-1].add(Pair(b-1, idx))
        nodes[b-1].add(Pair(a-1, idx))
    }

    val queue = ArrayDeque<Int>()
    val seen = Array(n){false}
    queue.add(0)

    while(queue.isNotEmpty()) {
        val idx = queue.poll()
        val node = nodes[idx]
        val pColor = pColors[idx]

        seen[idx] = true
        var newColor = 1

        node.forEach {
            if (seen[it.first]) return@forEach

            if (newColor == pColor) newColor++
            pColors[it.first] = newColor
            ans[it.second] = newColor
            queue.add(it.first)

            newColor++
        }
    }

    println(ans.toSet().size)
    println(ans.joinToString(separator = "\n"))
}

Measured memory_bytes: 102848
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

    int sum = 0;
    for(int i = 1; i < A.size(); i++) sum += abs(A[i] - A[i-1]);

    for(int i = 1; i <= N; i++){
        SS[i] = abs(A[i+1] - A[i-1]) - abs(A[i+1] - A[i]) - abs(A[i] - A[i-1]);
    }

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


    return 0;
}

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

int main() {
    for (;;) {
        int H, W;
        cin >> H >> W;
        int _H, _W;
        _H = H - 1;
        _W = W - 1;

        if (H == 0 && W == 0) {
            break;
        } else {
            for (int i = 0; i < W; ++i) {
                cout << "#";
            }
            cout << endl;

            for (int i = 1; i < _H; ++i) {
                cout << "#";
                for (int j = 1; j < _W; ++j) {
                    cout << ".";
                }
                cout << "#";
                cout << endl;
            }

            for (int i = 0; i < W; ++i) {
                cout << "#";
            }
            cout << endl;
            cout << endl;
        }
    }
}

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
from collections import Counter
import string

n = int(input())
m = []
for _ in range(n):
    m.append(Counter(input().rstrip("\r\n")))
ans = ""
for c in string.ascii_lowercase:
    is_ans = True
    count = 0
    for mi in m:
        if mi.get(c) == None:
            is_ans=False
            break
        count = mi.get(c) if count == 0 else min(count,mi.get(c))
    if is_ans:ans+=c*count
print(ans)

Measured memory_bytes: 39664
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int a[maxn],n;

int main()
{
	n=read(); rep(i,1,n) a[i]=read(); sort(a+1,a+n+1);
	if(a[1]+1<a[n]) return puts("No"),0;
	if(a[1]==a[n])
	{
		if(a[1]==n-1||(n/a[1])>=2) puts("Yes");
		else puts("No");
	}
	else
	{
		int f=0,n1,n2;
		rep(i,1,n) if(a[i]!=a[1]) {f=i-1; break;}
		n1=f; n2=n-f;
		if(n2>=(a[n]-n1)*2&&a[n]>=(n1+1)) puts("Yes"); else puts("No");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll powmod(ll a, ll x) {
    // calculates a^x mod MOD in logarithmic time.
    ll res = 1;
    while (x > 0) {
        if (x % 2 != 0) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        x /= 2;
    }
    return res;
}

ll inversemod(ll a) {
    // calculates the modular multiplicative of a mod m.
    //(assuming MOD is prime).
    return powmod(a, MOD - 2);
}

ll ncr(ll n, ll k) {
    // calculates C(n,k) mod MOD (assuming MOD is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i = 0; i < k; i++) {
        numerator = (numerator * (n - i)) % MOD;
    }

    ll denominator = 1; // k!
    for (int i = 1; i <= k; i++) {
        denominator = (denominator * i) % MOD;
    }

    // numerator / denominator mod MOD.
    return (numerator * inversemod(denominator)) % MOD;
}

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

  ll n;
  cin >> n;

  ll ans = 0;
  ans += powmod(10, n);
  ans -= powmod(9, n);
  if (ans < 0)
    ans += MOD;
  ans -= powmod(9, n);
  if (ans < 0)
    ans += MOD;
  ans += powmod(8, n);
  ans %= MOD;
  cout << ans << endl;

  return 0;
}


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

int main(){
  char c;
  cin >> c;
  if (c == 'A'){
    cout << "T" << endl;
  }
  else if (c == 'T'){
    cout << "A" << endl;
  }
  else if (c == 'G'){
    cout << "C" << endl;
  }
  else if (c == 'C'){
    cout << "G" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n,k;
  scanf("%d%d",&n,&k);

  int p[n];
  for(int i = 0; i < n; ++i){
    scanf("%d",&p[i]);
  }

  qsort(p,n,sizeof(int),sort);

  int ans = 0;
  for(int i = 0; i < k; ++i){
    ans += p[i];
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1744
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    n = len(s)
    ans = 0
    r = 0
    for l in range(n):
        while r < n and s[r] in "ACGT":
            r += 1
        k = r-l
        if ans < k:
            ans = k
        if r <= l:
            r = l+1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[25];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum = 0;
    int max = -1000000;
	for (int j = 0; j < n; j++) {
		if(a[j]>=max){
		    max = a[j];
		    sum++;
		}
		
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N,u,v = map(int,input().split())
edge = [list(map(int,input().split())) for _ in range(N-1)]

graph = [[] for _ in range(N)]

for e in edge:
    graph[e[0]-1].append(e[1]-1)
    graph[e[1]-1].append(e[0]-1)

level = [-1 for _ in range(N)]
level[v-1] = 0

queue = deque([v-1])

while queue:
    node = queue.popleft()
    for adj in graph[node]:
        if level[adj]==-1:
            level[adj] = level[node] + 1
            queue.append(adj)

t = level[u-1]

stack = [u-1]
maxlevel = t
visited = [0 for _ in range(N)]
visited[u-1] = 0
a = 0

while stack:
    node = stack.pop()
    for adj in graph[node]:
        if not visited[adj] and t-level[adj]<=(t-1)//2:
            stack.append(adj)
            maxlevel = max(maxlevel,level[adj])
            visited[adj] = 1

d = maxlevel-t

print(d+t-1)

Measured memory_bytes: 82904
#include <iostream>

using namespace std;
int a[200010],b[70][200010];
int main(){
    long long i,j,n,k;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> a[i]; a[i]--;
    }
    for(i=0;i<n;i++){
        b[0][i] = a[i];
    }
    for(j=1;j<70;j++){
        for(i=0;i<n;i++){
            b[j][i] = b[j - 1][b[j - 1][i]];
        }
    }
    long long d = (1LL<<60);
    int now = 0,cnt = 60;
    while(k){
        if(d<=k){
            now = b[cnt][now];
            k -= d;
        }
        d /= 2; cnt--;
    }
    cout << now + 1<< endl;
}

Measured memory_bytes: 59036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int A,B,X; cin >> A >> B >> X;
    if(A <= X && X <= A+B) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math

n, m, l = map(int, raw_input().split())

A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]

for i in range(n):
    A[i] = map(int, raw_input().split())

for i in range(m):
    B[i] = map(int, raw_input().split())

for i in range(n):
    for j in range(l):
        sm = 0
        for k in range(m):
            sm += A[i][k] * B[k][j]

        sys.stdout.write(str(sm))
        if j < l-1:
            sys.stdout.write(" ")
    print

Measured memory_bytes: 6864
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}
// [9, 81, 729, 6561, 59049, 531441]
// [6, 36, 216, 1296, 7776, 46656, 279936]
fn main() {
  solve2();
}

fn solve2() {
  let n: usize = read();

  let mut dp: Vec<u64> = vec![std::u64::MAX; n+1];
  dp[0] = 0;

  for i in 1..n+1 {
    let mut power = 1;
    while power <= i {
      dp[i] = min(dp[i], dp[i - power] + 1);
      power *= 6;
    }

    power = 1;
    while power <= i {
      dp[i] = min(dp[i], dp[i - power] + 1);
      power *= 9;
    }
  }
  println!("{}", dp[n]);
}

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

char dp[100010];
int n;
string str;

bool check()
{
	for(int i = 2;i <= n+1;i++)
	{
		if(dp[i-2] == 'S')
		{
			if(dp[i-1] == 'S')
			{
				if(str[i-1] == 'o')dp[i] = 'S';
				else dp[i] = 'W';
			}
			else
			{
				if(str[i-1] == 'o')dp[i] = 'W';
				else dp[i] = 'S';
			}
		}
		else
		{
			if(dp[i-1] == 'S')
			{
				if(str[i-1] == 'o')dp[i] = 'W';
				else dp[i] = 'S';
			}
			else
			{
				if(str[i-1] == 'o')dp[i] = 'S';
				else dp[i] = 'W';
			}
		}
	}
	if(dp[0]==dp[n]&&dp[1]==dp[n+1])
	{
		return true;
	}
	else
	{
		return false;
	}
}

int main()
{
	cin >> n;
	cin >> str;
	str += str[0];
	str += str[1];

	dp[0] = 'S';dp[1] = 'S';
	if(check()){rep(i,n)cout << dp[i];cout << endl;return 0;}
	dp[0] = 'S';dp[1] = 'W';
	if(check()){rep(i,n)cout << dp[i];cout << endl;return 0;}
	dp[0] = 'W';dp[1] = 'S';
	if(check()){rep(i,n)cout << dp[i];cout << endl;return 0;}
	dp[0] = 'W';dp[1] = 'W';
	if(check()){rep(i,n)cout << dp[i];cout << endl;return 0;}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    long long n,k,s=0,i;
    cin >> n>>k;
    for (i=k;i<=n+1;++i){
          s+= i*(n-i+1)+1;
          s=s%1000000007;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3656
import math
n,s=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
  X[i]=abs(X[i]-s)
X.sort()
ans=10**100
for x in X:
  tmp=math.gcd(X[0],x)
  if tmp<ans:
    ans=tmp
print(ans)

Measured memory_bytes: 20352
n=int(input())
ans=0
for i in range(2,1000010):
	power=0
	j=1
	if(n%i==0):
		while(n%i==0):
			power+=1
			n=(n//i)
		while(power>=j):
			power-=j
			j+=1
			ans+=1
if(n>1):
	ans+=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int main(){
  int N;
  cin >> N;
  vector<ll> T(N);
  rep(i,N) cin >> T[i];
  ll ans = T[0];
  for(int i=1;i<N;i++){
    ans = lcm(ans,T[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/


void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
        int n;
        cin>>n;
        unordered_map<string,int> st;
        forn(i,0,n){
            string s;
            cin>>s;
            st[s]++;
        }
        vector<pair<int,string>> vec;
        for(auto it:st){
            vec.pb(mp(it.S,it.F));
        }
        sort(vec.begin(),vec.end());
        n=vec.size();
        vector<string> res;
        res.pb(vec[n-1].S);
        int mx=vec[n-1].F;
        
        for(int i=n-2;i>=0;i--){
            if(vec[i].F!=mx)
            break;
            res.pb(vec[i].S);
        }
        sort(res.begin(),res.end());
        n=res.size();
        forn(i,0,n)
        cout<<res[i]<<"\n";
  }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 29504
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long calc(long h, long w) {
    if (h == 1 || w == 1) return 1;

    long a = (w + 1) / 2;
    long b = w / 2;

    long ans = (a + b) * (h / 2);
    if (h % 2 == 1) ans += a;
    return ans;
}

void main() {
    long h, w; scan(h, w);
    writeln(calc(h, w));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
#include <string>
#include "math.h"

using namespace std;
int main(int argc, char const *argv[]) {
  vector<string> s;
  int index[3];
  string a;
  for (size_t i = 0; i < 3; i++) {
    cin >> a;
    s.push_back(a);
    index[i] = 0;
  }
  int j = 0;
  string t;
  while(index[j] < s[j].size()) {
    t = s[j][index[j]];
    index[j]++;
    if (t == "a") {
      j = 0;
    } else if (t == "b") {
      j = 1;
    } else {
      j = 2;
    }
  }
  transform(t.begin(), t.end(), t.begin(), ::toupper);
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 760
fun main(args: Array<String>) {
    while(true){
        val (n,x) = readLine()!!.split(" ").map { it.toInt() }
        if(n == 0 && x == 0) break
        var count = 0
        loop@for(i in 1..n){
            for(j in (i+1)..n){
                val k = x - i - j
                if(k <= j) continue@loop
                if(k <=n)
                    count++
            }
        }
        println(count)
    }
}



Measured memory_bytes: 31992
#include <stdio.h>

int main() {

    int a, b;

    scanf("%d %d", &a, &b);

    if (a == b)
        printf("a == b\n");
    else if (a > b)
        printf("a > b\n");
    else
        printf("a < b\n");
    
    return 0;

}

Measured memory_bytes: 580
#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 pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

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);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, m;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  cout << (((n + m * 18)*100) << m) << endl;
  return 0;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


h,w = gi
n = gif
m = darray h,w,0
a = gi
i = 0
j = 0
rep n do |l|
  rep a[l] do
   m[i][j] = l+1
      if((i % 2 == 0 && j == w-1) || (i % 2 == 1 && j == 0))
        i+=1
      elsif(i % 2 == 0)
        j+=1
      elsif(i % 2 == 1)
        j-=1
      end
    end
end

m.each do |mm|
puts mm.join " "
end


Measured memory_bytes: 3196
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	
	ll H, W;
	cin >> H >> W;
	vector<vector<char>> s(H + 2, vector<char>(W + 2, ' '));
	fori(i, 1, H + 1) {
		fori(j, 1, W + 1) {
			cin >> s[i][j];
		}
	}

	ll ans = true;
	fori(i, 1, H + 1) {
		fori(j, 1, W + 1) {
			if (s[i][j] == '#' && s[i + 1][j] != '#' && s[i - 1][j] != '#' && s[i][j + 1] != '#' && s[i][j - 1] != '#')
				ans = false;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}

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

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

int main(){
	int n, m, xi, yi, a;
	char c, f[256];
	f['N'] = 0;
	f['S'] = 1;
	f['E'] = 2;
	f['W'] = 3;
	
	while( cin >> n , n ){
		char field[21][21] = {0};
		int x = 10;
		int y = 10;
		
		for(int i=0 ; i < n ; i++ ){
			cin >> xi >> yi;
			field[yi][xi] = 1;
		}
		cin >> m;
		for(int i=0 ; i < m ; i++ ){
			cin >> c >> a;
			for( ; a-- ; ){
				x += dx[ f[c] ];
				y += dy[ f[c] ];
				if( field[y][x] == 1 ){
					n--;
					field[y][x] = 0;
				}
			}
		}
		cout << ( ( n == 0 )? "Yes" : "No" ) << endl;
	}
}

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

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

    if (n.find("7") != string::npos)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
a= list(map(int,input().strip().split()))
cnt5 = 0
cnt7 = 0
for i in range(3):
    if a[i] == 5:
        cnt5 += 1
    if a[i] == 7:
        cnt7 += 1

if cnt5==2 and cnt7 ==1:
    print("YES")
else:
    print("NO")
    


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

namespace ABC106A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B,x;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            x = (A - 1) * (B - 1);
            Console.WriteLine(x);
            Console.ReadLine();
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  int k = 1;
  while (k * (k + 1) < 2 * n) ++k;
  if (k * (k + 1) != 2 * n) {
    cout << "No\n";
    return 0;
  }
  ++k;
  vector<vector<int>> res(k);
  int cur = 1;
  for (int i = 0; i < k; ++i) {
    for (int j = i + 1; j < k; ++j) {
      res[i].push_back(cur);
      res[j].push_back(cur);
      ++cur;
    }
  }
  cout << "Yes\n";
  cout << k << '\n';
  for (int i = 0; i < k; ++i) {
    cout << res[i].size();
    for (auto x : res[i]) cout << ' ' << x;
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 2304
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn; // 標準入力から NSString を得る
+(void)printf:(NSString*)format, ...; // 標準出力へ出力
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    NSUInteger length = [result length];
    if (length >= 1 && [result characterAtIndex:length-1] == '\n') { // 入力末尾に改行文字があれば削除
        [result deleteCharactersInRange:NSMakeRange(length-1,1)];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat:format arguments:arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
    va_end(arguments);
}
@end
  
int main() {
    @autoreleasepool {
        NSString *S = [StdIO stringFromStdIn];
        NSInteger length = [S length];
        NSArray *words = @[@"dream", @"erase", @"eraser", @"dreamer"];
        NSInteger currentIndex = length;
        while (currentIndex > 0) {
            BOOL found = false;
            for (NSString *word in words) {
                NSInteger size = [word length];
                NSInteger nextIndex = currentIndex - size;
                if (nextIndex >= 0) {
                    NSString *suffix = [S substringWithRange:NSMakeRange(nextIndex, size)];
                    if ([suffix isEqualToString: word]) {
                        if (nextIndex == 0) { // ちょうど先頭にたどり着いたら終了
                            [StdIO printf:@"YES"];
                            return 0;
                        } else {
                            found = YES;
                            currentIndex = nextIndex;
                            break;
                        }
                    }
                }
            }
            if (!found) {
                [StdIO printf:@"NO"];
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5092
fun main(args: Array<String>) {
    val arr = readLine()!!.split(" ").map { s->s.toInt() }
    val g = gcd(arr[0],arr[1])
    var c =0
    for (i in 1..g){
        if(g%i==0){
            c+=1
            if(c==arr[2]){
                print( g/i)
            }
        }
    }
}

fun gcd(a:Int,b:Int):Int{
    return if (a>b) gcd(b,a) else if(a>0)gcd(b%a,a) else b
}

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

using namespace std;

const int MSIZE  = 100100;

long long dp[MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, 0, sizeof dp);
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        int we, v;
        cin >> we >> v;
        for (int j = w - 1; j >= 0; j--) {
            if (j + we > w) continue;
            dp[j + we] = max(dp[j + we], dp[j] + v);
        }
    }
    cout << *max_element(dp, dp + MSIZE);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main (){
  
  string x, y, z;
  cin >> x >> y >> z;
  if (x[x.size()-1] == y[0] && y[y.size()-1] == z[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using namespace std;

#define pb push_back
#define mem(a) memset(a,0,sizeof(a))

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

const int mn=4005;

int n;
int a[mn];

//BIT
int t[mn+100];
void add(int i,int x){while(i<=n*2)t[i]+=x,i+=i&-i;}
int sum(int i){int s=0;while(i)s+=t[i],i-=i&-i;return s;}

int d[mn>>1][mn>>1];
int pos[2][mn];//0 white

int main() {
	cin>>n;
	for(int i=1;i<=2*n;i++){
		char u;int v;
		cin>>u>>v;
		if (u=='B'){
			v+=n;
			pos[1][v-n]=i;
		}
		else pos[0][v]=i;
		a[i]=v;
	}
	//DP
	memset(d,4, sizeof(d));
	d[0][0]=0;
	for(int i=0;i<=n;i++){//white
		fill_n(t,4100,0);
		int temp=0;
		for(int k=1;k<=i;k++) temp+=pos[0][k]-sum(pos[0][k])-1,add(pos[0][k],1);
		d[i][0]=temp;
		for(int j=1;j<=n;j++){//black
			if (!i&&!j) continue;
			d[i][j]=min(d[i][j],d[i][j-1]+pos[1][j]-sum(pos[1][j])-1);
			add(pos[1][j],1);
			if (i<n) d[i+1][j]=min(d[i+1][j],d[i][j]+pos[0][i+1]-sum(pos[0][i+1])-1);
		}
	}
	cout<<d[n][n]<<endl;
	return 0;
}

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

int main(){
	string T{"MARCH"};

	int N; cin>>N;

	vector<int> C(T.size());
	while(N--){
		string s; cin>>s;
		for(int t=0; t<T.size(); ++t)
			if(s[0]==T[t]) C[t]++;
	}

	ll ans = 0;
	for(int i=0; i<C.size(); ++i)
		for(int j=i+1; j<C.size(); ++j)
			for(int k=j+1; k<C.size(); ++k)
				ans += (ll)C[i] * C[j] * C[k];
	cout<< ans <<endl;
}

Measured memory_bytes: 384
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=t.in(),n=e*r,i=1;i<r;i++){var o=r-i,a=e/2,s=e/2;e%2==1&&(a=Math.floor(a),s=Math.ceil(s));var u=e*i,c=a*o,f=s*o,l=Math.max(u,c,f)-Math.min(u,c,f);n>l&&(n=l)}for(var h=1;h<e;h++){var d=e-h,p=r/2,v=r/2;r%2==1&&(p=Math.floor(p),v=Math.ceil(v));var m=r*h,M=p*d,x=v*d,b=Math.max(m,M,x)-Math.min(m,M,x);n>b&&(n=b)}if(r>2)for(var y=1;y<=r-2;y++){var g=r-y,j=g/2,O=g/2;g%2==1&&(j=Math.floor(j),O=Math.ceil(O));var S=(Math.max(y,j,O)-Math.min(y,j,O))*e;n>S&&(n=S)}if(e>2)for(var _=1;_<=e-2;_++){var q=e-_,P=q/2,z=q/2;q%2==1&&(P=Math.floor(P),z=Math.ceil(z));var w=(Math.max(_,P,z)-Math.min(_,P,z))*r;n>w&&(n=w)}console.log(n)}}]);

Measured memory_bytes: 12324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            String ans = S.replaceAll("hi", "");

            if (ans.length() == 0) out.println("Yes");
            else out.println("No");

        }

    }
}



Measured memory_bytes: 23636
//ABC112B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	string s, t;
	int count =0;
	cin >> s >> t;
	for(int i=0;i<3;i++){
		if(s.at(i) == t.at(i)){
			count++;
		}
	}
	cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  map<string, int> MA;
  while (cin >> S) MA[S]++;
  cout << "AC x " << MA["AC"] << "\n";
  cout << "WA x " << MA["WA"] << "\n";
  cout << "TLE x " << MA["TLE"] << "\n";
  cout << "RE x " << MA["RE"] << "\n";
}

Measured memory_bytes: 3628
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

#define INF INT_MAX/2

int min(int x, int y) {
	if(x < y)
		return x;
	return y;
}
int max(int x, int y) {
	if(x > y)
		return x;
	return y;
}

int main(void) {
	int h, n, i, j, a, b;
	scanf("%d%d", &h, &n);
	// dp[i][j]はi番目までの魔法を使って体力jのモンスターに勝つのに必要な魔力
	int **dp = malloc(sizeof(int *)*(n + 1));
	for(i = 0; i < n + 1; i++)
		*(dp + i) = malloc(sizeof(int)*(h + 1));
	for(i = 0; i < n + 1; i++)
		*(*(dp + i) + 0) = 0;
	for(j = 1; j < h + 1; j++)
		*(*(dp + 0) + j) = INF;
	for(i = 1; i < n + 1; i++) {
		scanf("%d%d", &a, &b);
		for(j = 1; j < h + 1; j++)
			dp[i][j] = min(dp[i][max(j - a, 0)] + b, dp[i - 1][j]);
	}
	printf("%d\n", dp[n][h]);
	for(i = 0; i < n + 1; i++)
		free(*(dp + i));
	free(dp);
	return 0;
}

Measured memory_bytes: 39296
#include <stdio.h>

int main(){
	int n, t[100000], tSum;
	int m, p, x, d;
	
	scanf("%d", &n);
	tSum = 0;
	for (int i=0; i<n; i++){
		scanf("%d", &t[i]);
		tSum += t[i];
	}
	scanf("%d", &m);
	for (int i=0; i<m; i++){
		scanf("%d%d", &p, &x);
		printf("%d\n", tSum - t[p-1] + x);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << y1 + x2 - y2 << " " << x2 + y2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1 << endl;
    return 0;
}


Measured memory_bytes: 256