akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
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;
}

signed main() {
    INIT;
    cin >> X;
    if (X < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	k := readInt()
	s := readString()

	if len(s) <= k {
		fmt.Println(s)
	} else {
		fmt.Println(s[:k] + "...")
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1756
import java.util.*;
import java.io.*;

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      int N = sc.nextInt();
      String pre = sc.next();
      HashSet<String> hs = new HashSet<String>();
      hs.add(pre);
      for (int i = 0; i < N-1; i++) {
        String now = sc.next();
        if (now.charAt(0) == pre.charAt(pre.length()-1) && !hs.contains(now)) {
          hs.add(now);
          pre = now;
        } else {
          System.out.println("No");
          return;
        }
      }
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	//ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n+1];
    ll dp[n+1];mset(dp);
    vi ans;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=n;i>=1;i--){
        ll cnt=0;
        for(int j=i;j<=n;j+=i){
            cnt+=dp[j];
        }
        if(cnt%2!=a[i]){dp[i]=1;ans.pb(i);}
    }
    cout<<ans.size()<<"\n";
    print(ans);
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define ll long long int

using namespace std;



int main()
{
    int n, m, z = 0, y = 0;
    cin >> n >> m;
    vector <int> a(n);
    for (int j = 0; j < m; j++){
        int i;
        string c;
        cin >> i >> c;
        if (c[0] == 'A' && a[i - 1] != 1){
            z++;
            y += -a[i - 1];
            a[i - 1] = 1;
        }
        if (c[0] == 'W' && a[i - 1] != 1){
            a[i - 1]--;
        }

    }
    cout << z << " " << y << endl;
    return 0;

}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main{
   public static void main(String[]args)throws IOException{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      int[] k = new int[10];

      for(int i=0; i < 10; i++)
      k[i] = Integer.parseInt(br.readLine());

      Arrays.sort(k); 


      for(int i=0; i<3; i++)
      System.out.println(k[9-i]);
   }
}

Measured memory_bytes: 24244
#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll test[1234][1234];
signed main() {
	vector<vector<ll>> abc(27, vector<ll>(2));
	ll D, c, s; cin >> D;
	for (int h = 1; h <= 26; h++) {
		cin >> abc[h][0]; abc[h][1] = h;
	}
	sort(abc.begin() + 1, abc.end());
	for (int i = 0; i < D; i++) {
		for (int h = 0; h < 26; h++) {
			cin >> test[i][h];
		}
	}
	for (int h = 0; h < 13; h++) {
		vector<vector<ll>> v(676, vector<ll>(3)); ll uio = 0;
		for (int i = 0; i < 26; i++) {//26*h+i
			for (int j = 0; j < 26; j++) {
				v[uio][0] = test[26 * h + i][j];
				v[uio][1] = i; v[uio][2] = j; uio++;
			}
		}
		sort(v.begin(), v.end()); reverse(v.begin(), v.end());
		vector<ll> ok1(26), ok2(26), ans(26);
		for (int h = 0; h < 676; h++) {
			if (ok1[v[h][1]] == 0 && ok2[v[h][2]] == 0) {
				ok1[v[h][1]]++; ok2[v[h][2]]++;
				ans[v[h][1]] = v[h][2];
			}
		}
		for (int h = 0; h < 26; h++) {
			cout << ans[h] + 1 << endl;
		}
	}
	cout << abc[26][1] << endl;
	for (int h = 1; h <= 26; h++) {
		cout << abc[h][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5200
N,M = map(int,input().split())
s = []
for i in range(M):
    s += [[int(x) for x in input().split()]]
p = [int(x) for x in input().split()]
ans = 0

for i in range(2**N):
    sw = [(i//2**x)%2 for x in range(N)]
    for j in range(M):
        a = True
        sums = 0
        for k in range(s[j][0]):
            if sw[s[j][k+1]-1] == 1:
                sums += 1
        if sums%2 != p[j]:
            a = False
            break
    if a:   ans += 1

print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

class union_find
{
	std::vector<boost::optional<index_t>> parent;
	std::vector<index_t> rank;
	std::set<index_t> tops;
	std::size_t sz;
public:
	union_find(std::size_t N) :parent(N), rank(N), tops(), sz(N)
	{
		for (auto i : boost::irange<index_t>(0, N))
		{
			tops.emplace(i);
		}
	}
	index_t find(index_t a)
	{
		if (!parent[a])
		{
			return a;
		}
		else
		{
			return *(parent[a] = find(*parent[a]));
		}
	}
	void merge(index_t a, index_t b)
	{
		auto x = find(a);
		auto y = find(b);
		if (x != y)
		{
			--sz;
			if (rank[x] < rank[y])
			{
				tops.erase(x);
				parent[x] = y;
			}
			else if (rank[y] < rank[x])
			{
				tops.erase(y);
				parent[y] = x;
			}
			else
			{
				tops.erase(y);
				parent[y] = x;
				++rank[x];
			}
		}
	}
	std::size_t size()const
	{
		return sz;
	}
	auto begin()const
	{
		return tops.begin();
	}
	auto end()const
	{
		return tops.end();
	}
};

void Main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
	union_find group(N - K + 1);
	int inc = 0;
	int prev = -1;
	boost::optional<int> first;
	for (auto i = 0; i < N; ++i)
	{
		if (prev < vec[i])
		{
			++inc;
			if (K <= inc)
			{
				if (!first)
				{
					first = i - (K - 1);
				}
				else
				{
					group.merge(*first, i - (K - 1));
				}
			}
		}
		else
		{
			inc = 1;
		}
		prev = vec[i];
	}
	std::set<int> set;
	for (auto i : boost::irange(0, K))
	{
		set.emplace(vec[i]);
	}
	for (auto i : boost::irange(K, N))
	{
		auto rem = vec[i - K];
		auto add = vec[i];
		set.emplace(add);
		if (rem == *set.begin() && add == *std::prev(set.end()))
		{
			group.merge(i - K, i - K + 1);
		}
		set.erase(rem);
	}
	std::cout << group.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 15104
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A,B;

    cin >>A >> B;

    Int ue = (A*A - B*B);
    Int shita = 2*(A-B);

    if(ue%shita==0){
        cout << ue/shita << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        List<Integer> list = new ArrayList<Integer>();

        for(int i = 1; i <= b; i++){
            int surplus = a*i % b;
            if(list.contains(surplus)){
                break;
            } else {
                list.add(surplus);
            }
        }

        if(list.contains(c)){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

//ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 11111

int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;

  if (a + b >= c && a <= c) {
	cout << "YES" << endl;
  }
  else {
	cout << "NO" << endl;
  }


  return 0;
}

Measured memory_bytes: 768
# Input the amount of money Takahashi paid
N = int(input())

# Check if the price before tax is X, for X = 1, 2, 3, ..., N
ans = -1
for i in range(1, N + 1):
	if int(i * 1.08) == N:
		ans = i

# Print answer
if ans != -1:
	print(ans)
else:
	print(":(")

Measured memory_bytes: 2940
#include<stdio.h>
  
int main(){
    int a, b ,c ,max,min,middle;
      
    scanf("%d %d %d", &a, &b, &c);
     
    max = a; 
    if (b >= max) {
      middle = a;
      max    = b;
    } else {
        middle = b;
    }
 
    if (c >= max){
      min    = middle;
      middle = max;
      max    = c;
    } else if (c >= middle) {
        min    = middle;
        middle = c;
    } else {
        min = c;
    }
 
    printf("%d %d %d\n", min, middle, max);
      
    return 0;
}

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

#define ll long long int
#define ri register int

using namespace std;

int dp[100003][3];

int main()
{
	ll n, w;
	cin >> n >> w;
	
	vector< pair<ll, ll> > v(n, { 0,0 });
	vector<ll> dp(w+1, 0);
	vector< set<ll> > taken(w + 1);

	for (int i = 0; i < n; i++)
	{
		cin >> v[i].first >> v[i].second;
		dp[v[i].first] = max(dp[v[i].first], v[i].second);

		if (dp[v[i].first] == v[i].second)
		{
			taken[v[i].first].clear();
			taken[v[i].first].insert(i);
		}
	}
/*
	for (int i = 1; i <= w; i++)
	{
		if (dp[i] < dp[i - 1])
		{
			dp[i] = dp[i - 1];
			taken[i] = taken[i - 1];
		}
	}*/

	for (int i = 1; i <= w; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if ((i - v[j].first) >= 0)
			{
				if (taken[i - v[j].first].find(j) == taken[i - v[j].first].end())
				{
					if (dp[i] < dp[i - v[j].first] + v[j].second)
					{
						dp[i] = max(dp[i], dp[i - v[j].first] + v[j].second);
						taken[i] = taken[i - v[j].first];
						taken[i].insert(j);
					}
				}
			}
		}
	}

	ll ans = 0;
	for (ri i = 0; i <= w; i++)
	{
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 299520
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[101];
  char p[101];
  char ss[202]; //s????????????????????????

  scanf("%s",s);
  scanf("%s",p);

  strcpy(ss,s); //ss???s???????????????
  strcat(ss,s); //ss???s?????£???

  if(strstr(ss,p)){ //ss??????p???????????????????´¢??????
    puts("Yes");
  }else{
    puts("No");
  }
  
  return(0);
}

Measured memory_bytes: 972
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int N, K;
	int disA, disB,ans=0;

	cin >> N >> K;

	vector<int> x(N);

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

	for (int i = 0; i < N; i++) {
		disA = abs(x[i] - 0) * 2;
		disB = abs(K - x[i]) * 2;
        ans += min(disA,disB);
	}

    cout << ans << endl;

	return 0;
}


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

int main(){
	int n,i,a=100000;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		a=a*1.05;
		if(a%1000!=0){
			a=((a/1000)*1000)+1000;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

#define MAX_N 100000
#define INF 1000000000

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<ll> A(M);
  vector<int> C(M, 0);
  rep(i, M) {
    int b;
    cin >> A[i] >> b;
    rep(j, b) {
      int c;
      cin >> c;
      C[i] |= 0x1 << (c - 1);
    }
  }
  int EndF = 0;
  rep(i, N) { EndF |= 0x1 << i; }

  vector<ll> DP(EndF + 1, INF);
  DP[0] = 0;
  rep(i, EndF) {
    rep(j, M) {
      int next = i | C[j];
      DP[next] = min(DP[i] + A[j], DP[next]);
    }
  }
  if (DP[EndF] == INF) DP[EndF] = -1;
  cout << DP[EndF] << endl;
  return 0;
}


Measured memory_bytes: 256
from decimal import *
def calc(l,theta):
    tmpcos = Decimal(math.cos(theta))
    tmpsin = Decimal(math.sin(theta))
#    print(l,(theta)/(2*Decimal(math.pi)),tmpcos,tmpsin)
    return l*tmpsin,l*tmpcos

import math
a,b,h,m = map(int,input().split())
thetaA = Decimal(((60*h+m)/720)*(2*math.pi))
x1,y1 = calc(a,thetaA)
thetaB =  Decimal(2*(math.pi)*(m/60))
x2,y2 = calc(b,thetaB)
ans = Decimal((x1-x2)**2 + (y1-y2)**2)
ans = Decimal(math.sqrt(ans))

print(ans)

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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

ll dp[200][200000];
ll a[200];

int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    dp[0][k] = 1;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= k; j++)
        {
            dp[i+1][max(j - a[i], 0ll)] += dp[i][j];
            dp[i+1][j + 1] -= dp[i][j];
        }
        ll gryzha = 0;
        for(int j = 0; j <= k; j++)
        {
            gryzha += dp[i + 1][j];
            gryzha = (gryzha + 1000000007) % 1000000007;
            dp[i + 1][j] = gryzha;
        }
    }
    cout<<dp[n][0];
}


Measured memory_bytes: 156416
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
string n;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin>>n;
    ll ans=0;
    for(int i=0;i<(int)n.size();i++){
    	ans+=n[i]-'0';
    	ans%=9;
    }
    if(!ans) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3756
N,M=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(M)]

l=1
r=N

for i in LR:
    #print(i)
    if i[0]>l:
        l=i[0]
    if i[1]<r:
        r=i[1]

if r>=l:
    print(r-l+1)
else:
    print(0)

Measured memory_bytes: 27344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans = 0;
const ll MOD = 998244353;
void Main(){
    ll n;cin>>n;
    ll s;cin>>s;
    vector<ll> a(n);
    For(i,0,n) cin>>a[i];
    vector<vector<ll>> dp(n+1,vector<ll> (s+1,0));
    For(i,0,n){
        if(s >= a[i]) dp[i+1][a[i]]+=i+1;
        For(j,1,s){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            if(j+a[i]<=s) dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%MOD;
        }
    }
    For(i,1,n+1) ans=(ans+dp[i][s]*(n+1-i)%MOD)%MOD;
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 70784
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int X;
	cin>>X;
	int maxi=0;
	for(int b=1;b<=X;b++)
		for(int p=2;p<=X+1;p++){
			int e=1;
			for(int i=0;i<p;i++){
				e*=b;
				if(e>1000)
					break;
			}
			if(e<=X)
				maxi=max(maxi,e);
		}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 256
--相手と同じ手を出せば必ず引き分けにはなる。
--p,gを出すトータルが同じとき、出すタイミングによって点数が変わるかどうかについては、
--これはかわらない。こちらの出す手の任意の二箇所を入れ替えても、点数の変動は相殺してゼロ。
--従って、p,gを出す回数を固定したら、それは履歴に関する出し手制約を満たしていればいつ出しても点数はかわらない。
--つまり勝てるときに勝っておいて、そのせいで後で負けても、トータルに支障はない。
--ということで貪欲法で行く。相手の出方を見ながら、こちらがより高い点を獲得できる手が出せるならそれを出す。


main::IO()
main = do
  enemy<-getLine
  print (solver enemy)

solver ::String -> Int
solver cs = let (_,_,score) = foldl decide_result (0,0,0) cs in score

decide_result:: (Int,Int,Int) -> Char -> (Int,Int,Int)
decide_result (p,g,score) hand
          |(hand=='g')&&(p <g) = (p+1,g,score+1)
          |(hand=='g')&&(p>=g) = (p,g+1,score)
          |(hand=='p')&&(p <g) = (p+1,g,score)
          |(hand=='p')&&(p>=g) = (p,g+1,score-1)


Measured memory_bytes: 6140
word = gets.chomp.split("")
wordr = word.reverse
num = word.length-1
first = 0
last = 0

(0..num).each do |i|
    if word[i] == "A"
        first = word.index(word[i])
        break
    end
end
(0..num).each do |i|
    if wordr[i] == "Z"
        last = wordr.index(wordr[i])
    break
    end
end

last = word.length - last
puts last - first

Measured memory_bytes: 18300
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    vector<set<int>> edges(n);
    rep(_, n - 1) {
        int x, y;
        cin >> x >> y;

        x--;
        y--;
        edges[x].insert(y);
        edges[y].insert(x);
    }

    set<P> s;
    rep(i, n) s.insert(P(edges[i].size(), i));
    bool b = [&]() -> bool {
        while (s.size()) {
            if (s.begin()->first == 0) {
                return true;
            }
            int x = s.begin()->second;
            int y = *edges[x].begin();

            for (int r : edges[y]) {
                s.erase(P(edges[r].size(), r));
                edges[r].erase(y);
                s.insert(P(edges[r].size(), r));
            }
            s.erase(P(edges[y].size(), y));
            s.erase(P(edges[x].size(), x));
        }
        return false;
    }();

    cout << (b ? "First" : "Second") << endl;

}


Measured memory_bytes: 20608
#include<cstdio>
#include<vector>
#include<algorithm>
#define FOR(i, a, b) for (i = a; i < b; ++i)
#define FOR_I(i, a, b) for (int i = a; i < b; ++i)

using namespace std;

int main()
{
  int n,d,x;
  scanf("%d\n%d %d", &n, &d, &x);
  int a[110];
  FOR_I(i, 0, n) {
    scanf("\n%d", a + i);
  }
  int t = 0;
  FOR_I(i, 0, n) {
    t += 1 + ((d - 1) / a[i]);
  }
  printf("%d\n", t + x);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  bool a = false;
  
  if (n % 2 == 0){
    for (int i = 0; i < n/2; i++){
      if (s.at(i) == s.at(i + n/2)){
        a = true;
      }
      else {
        a = false;
        break;
      }
    }
  }
  if (a == true){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL (long long)1e18
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    ll n;
    cin>>n;
    map<ll,int>m;
    for(int i=2;i<=sqrt(n);i++){
        while(n%i==0){
            n/=i;
            m[i]++;
        }
    }
    if(n!=1)m[n]++;
    int a[20];
    REP(i,20){
        a[i]=i*(i+1)/2;
    }
    int ans=0;
    for(auto p:m){
        for(int i=19;i>=0;i--){
            if(a[i]<=p.second){
                ans+=i;
                break;
            }
        }
    }
    OUT(ans);
    return 0;
}


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

int main(){
    int N;
    int A[100], B[100], C[100];
    long ans = 0;

    cin >> N;
    for(int i=1;i<=N;i++) cin >> A[i];
    for(int i=1;i<=N;i++){
        cin >> B[i];
        ans += B[i];
    }
    for(int i=1;i<=N-1;i++) cin >> C[i];

    int previous_A = -500;
    for(int i=1;i<=N;i++){
        if(previous_A + 1 == A[i]){
            ans += C[previous_A];
        }
        previous_A = A[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    cin >> s;
    int len = s.size();
    for(int i = 0; i < len; i++)
    if(s[i] == '7'){printf("Yes\n"); return 0;}
    printf("No\n");

    return 0;
}


Measured memory_bytes: 3676
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s1 = sc.next();
        String s2 = sc.next();
        String ans="";
        
        for(int i=0; i<n; i++){
            ans=ans+s1.charAt(i)+s2.charAt(i);
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 39376
//B.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
  int x[4],y[4];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  int dx,dy;
  dx = x[1] - x[0];
  dy = y[1] - y[0];
  x[2] = x[1] - dy;
  y[2] = y[1] + dx;
  x[3] = x[2] - dx;
  y[3] = y[2] - dy;
  printf("%d %d %d %d\n",x[2],y[2],x[3],y[3]);
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

#define loop(i, n) for (int i = 1; i < n; i++)
#define INF 1010001000

typedef pair<int, int> i_i;
typedef pair<double, int> d_i;

double calc(i_i &a, i_i &b);
void dijkstra(int st, int en, vector<vector<double> > &g);
void print(int st, int en, vector<int> &path);

int n;

int main()
{
    cin >> n;
    while (n) {
        n++;
        vector<vector<double> > g(n, vector<double>(n));
        vector<i_i > ob(n);
        loop(i, n) {
            int a;
            cin >> a;
            cin >> ob[a].first >> ob[a].second;
        }
        loop(i, n) {
            loop(j, n) {
                g[i][j] = calc(ob[i], ob[j]);
            }
        }
        int m;
        cin >> m;
        m++;
        loop(i, m) {
            int a, b;
            cin >> a >> b;
            dijkstra(a, b, g);
        }
        cin >> n;
    }
    return 0;
}

void dijkstra(int st, int en, vector<vector<double> > &g)
{
    priority_queue<d_i, vector<d_i>, greater<d_i> > pq;
    vector<double> d(n, INF);
    vector<int> prev(n, -1);
    d[st] = 0;
    pq.push(make_pair(0.0, st));

    while (!pq.empty()) {
        d_i tmp = pq.top();
        pq.pop();
        int v = tmp.second;
        if (d[v] < tmp.first) {
            continue;
        }
        for (int i = 1; i < n; i++) {
            if (d[i] > d[v] + g[v][i]) {
                d[i] = d[v] + g[v][i];
                prev[i] = v;
                pq.push(i_i(d[i], i));
            }
        }
    }
    if (d[en] != INF) {
        print(st, en, prev);
        cout << en << endl;
    } else {
        cout << "NA" << endl;
    }
}

void print(int st, int en, vector<int> &path)
{
    int wt = path[en];
    if (wt != st) {
        print(st, wt, path);
    }
    cout << wt << " ";
}
        

double calc(i_i &a, i_i &b) 
{
    int x1 = a.first, x2 = b.first, y1 = a.second, y2 = b.second;
    int tmp = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);
    double len = sqrt((double)tmp);
    return (50.0000<len)?INF:len;
}

Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

#define REP(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

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

    int H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));
    vector<int> wi(W);
    vector<int> hi(H);
    REP(y, 0, H)
    {
        string s;
        cin >> s;
        REP(x, 0, W)
        {
            a[y][x] = s[x];
            if (a[y][x] == '#')
            {
                wi[x]++;
                hi[y]++;
            }
        }
    }

    REP(y, 0, H)
    {
        if (hi[y] == 0) continue;
        REP(x, 0, W)
        {
            if (wi[x] == 0) continue;
            cout << a[y][x];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// ALDS 1_9_A
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

void print_btree(vector<int> btree){
	for(int i=1;i<btree.size();i++){
		cout<<"node "<<i<<": key = "<<btree[i]<<", ";

		if(i != 1)
			cout<<"parent key = "<<btree[i/2]<<", ";
		
		if(2*i < btree.size())
			cout<<"left key = "<<btree[i*2]<<", ";

		if(2*i+1 < btree.size())
			cout<<"right key = "<<btree[2*i+1]<<", ";

		cout<<endl;
	}
}

int main(){
	int H;
	vector<int> btree;

	cin>>H;
	btree.resize(H+1);

	for(int i=1;i<=H;i++)
		cin>>btree[i];

	print_btree(btree);

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();

	int ans1 = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			if (s[i] == '0') ans1++;
		}
		else {
			if (s[i] == '1') ans1++;
		}
	}

	cout << min(ans1, n - ans1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, N) for(ll i = 0; i < (ll)N; i++)
using ll = long long;
using namespace std;
#define MOD 1000000007
typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int n, m, ans = MOD, flag = 0;
    string s,t;
    cin >> s >> t;
    int r = (int)s.size() - (int)t.size() +1;
    rep(i,r){
        int tmp = 0;
        rep(j,t.size()){
            if(s[i+j] != t[j]) tmp++;
        }
        ans = min(ans, tmp);
    }

    cout << ans;
    printf("\n");
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
int main() {
  int64_t A,B,V,W,T;
  cin>>A>>V>>B>>W>>T;
  int64_t k=abs(A-B);
  int64_t m=V-W;
  if(m*T>=k) cout<<"YES";
  else cout<<"NO";

}



Measured memory_bytes: 3620
a,b,c,x,y = map(int,input().split())
ab = c*2 #A,B１枚ずつ入手
if ab <= a+b:
    bab = min(x,y)*ab
    if x > y:
        bother = (max(x,y)-min(x,y))*a
    else:
        bother = (max(x,y)-min(x,y))*b
    ans = min(bab+bother,ab*max(x,y))
else:
    bab = 0
    bother = a*x + b*y
    ans = bab + bother
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/(a,b);}
//priority_queue<int, vi, greater<int> > que;//æ˜‡é †

using namespace std;

const int mod=1e9+7;

signed main(){
  SPEED;
  int a;
  while(scanf("%d",&a)!=EOF){
    printf("3C%02d\n",(a-1)%39+1);
  }
  return 0;
}



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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  
  if(N == 2) cout << "Borys" << endl;
  else if((B-A)%2 == 0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}


Measured memory_bytes: 256
n = int(input())
number = list(map(int, input().split()))
a = sum(number)
g0 = a//n
g1 = a/n
if g1-g0 >= g0+1 - g1:
  g = g0+1
else:
  g = g0

ans = []
for i in range(n):
  l = (number[i] - g)**2
  ans.append(int(l))
print(sum(ans))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int r[51]={0};
	int i,j;
	int a,b;
	int n,m;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		r[a]++;
		r[b]++;
	}
	for(i=1;i<=n;i++){
		cout<<r[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    s_list = [list(map(int, input().split()))]
    i = 0
    while True:
        i += 1
        s = []
        for j in s_list[-1]:
            s.append(s_list[-1].count(j))
        if s == s_list[-1]:
            break
        s_list.append(s)
    print(i - 1)
    print(*s)



Measured memory_bytes: 5604
#include<iostream>
using namespace std;
int main()
{
    long long n,i;
    cin>>n;
    long long h[n];
    long long dp[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=h[0];
    dp[1]=abs(h[1]-h[0]);
    dp[2]=min(abs(h[2]-h[0]),abs(h[2]-h[1])+dp[1]);
    for(i=3;i<n;i++)
    {
        dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = list(input())
N = len(S)
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1

for i,s in enumerate(S):
    m = pow(10,(N-i-1),13)
    if s == '?':
        for d in range(10):
            for k in range(13):
                dp[i+1][(k+m*d)%13] += dp[i][k]
    else:
        d = int(s)
        for k in range(13):
            dp[i+1][(k+m*d)%13] += dp[i][k]

    for k in range(13):
        dp[i+1][k] %= mod


print(dp[-1][5]%mod)


Measured memory_bytes: 67060
def chain(s,p):
  s2=s[1::]+s[0]
  for i in s2:
    if i=='o':
      if p[-1]=='0': p=p+p[-2] 
      else:  p=p+str((int(p[-2])-1)*(-1))
    else:
      if p[-1]=='0': p=p+str((int(p[-2])-1)*(-1))
      else: p=p+p[-2]
  return p

N=int(input())
s=input()
p1='00'
p2='01'
p3='10'
p4='11'
p1=chain(s,p1)
p2=chain(s,p2)
p3=chain(s,p3)
p4=chain(s,p4)
l=[p1,p2,p3,p4]
flag=0
for i in l:
  if i[0]==i[-2] and i[1]==i[-1]:
    flag=1
    i=str(i[0:-2])
    i=i.replace('0','S')
    i=i.replace('1','W')
    print(i)
    break
if flag==0: print('-1')


Measured memory_bytes: 3828
#include <cstdio>
#include <vector>
#include <set>

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> a(n), deg(n);
  std::set<int> left;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    ++deg[--a[i]];
    left.insert(i);
  }

  int forbid = -1;
  
  auto check = [&](int x) {
    if (x == forbid) return false;
    int y = a[x];
    if (!left.count(y)) {
      if (left.size() == 3) {
        int u = -1, v = -1;
        for (auto &e: left) if (e != x) {
          if (u == -1) u = e;
          else v = e;
        }
        if (a[u] == v && a[v] == u) return false;
      }
      return true;
    } else {
      return deg[y] != left.size() - 1;
    }
  };

  std::vector<int> b(n, -1);
  for (int i = 0; i < n; ++i) {
    for (auto it = left.begin(); it != left.end(); ++it) {
      if (check(*it)) { b[i] = *it; break; }
    }
    if (b[i] == -1) break;
    forbid = a[b[i]];
    --deg[forbid];
    left.erase(b[i]);
  }
  if (b.back() == -1) puts("-1");
  else {
    for (auto &x: b) printf("%d ", x + 1);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  bool ans=true;
  for(int i=n-1;i;i--){
    if(h[i-1]==h[i]+1)h[i-1]--;
  }
  for(int i=1;i<n;i++){
    if(h[i]-h[i-1]<0)ans=false;
  }
  puts(ans?"Yes":"No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    ll ans = 1;
    cin >> a[0];
    vector<ll> t;
    REPP(i,n-1) {
        cin >> a[i];
        if(a[i]-a[i-1]!=0) t.push_back(a[i]-a[i-1]);
    }
    int m = t.size();
    REPP(i,m-1) {
        if(t[i]*t[i-1]<0) {
            ans ++;
            i ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2296
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

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

  if (!(a == 1 || b == 1))
    cout << 1 << endl;
  else if (!(a == 2 || b == 2))
    cout << 2 << endl;
  else
    cout << 3 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N;
    cin >> N;
    ll i;
    string s[MAX];
    ll cnt[5]={};
    
    for(i=0; i<N; i++) {
        cin >> s[i];
        
        if(s[i][0]=='M') cnt[0]++;
        if(s[i][0]=='A') cnt[1]++;
        if(s[i][0]=='R') cnt[2]++;
        if(s[i][0]=='C') cnt[3]++;
        if(s[i][0]=='H') cnt[4]++;
        
    }
    
    ll ans=0;
    ans+=cnt[0]*cnt[1]*(cnt[2]+cnt[3]+cnt[4]);
    ans+=cnt[0]*cnt[2]*(cnt[3]+cnt[4]);
    ans+=cnt[0]*cnt[3]*cnt[4];
    ans+=cnt[1]*cnt[2]*(cnt[3]+cnt[4]);
    ans+=cnt[1]*cnt[3]*cnt[4];
    ans+=cnt[2]*cnt[3]*cnt[4];
    pr(ans);
    
    
    
    
    
    
    
    
    
}






















Measured memory_bytes: 6144
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s = line.Trim().Split(' ');
            Console.WriteLine((int.Parse(s[0]) + int.Parse(s[1])).ToString().Length);
        }
    }
}

Measured memory_bytes: 9176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication50
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;string s = "";
               for(int b = 0; b < a.Length; b++)
                {
                    if (a[b] == '@') {
                        for(int d = 0; d < a[b + 1]-48; d++)
                        {
                            s += a[b + 2];
                        }
                        b += 2;
                    }
                    else s += a[b];
                }
                Console.WriteLine(s);
            }
        }
    }
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int h,n;
    cin>>h>>n;
    int a;
    rep(i,n){
        cin>>a;
        h-=a;
        if(h<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main(){
    int N,ans = 0;
    cin >> N;
    int V[N];
    int C[N];
    for(int  i = 0; i < N; i++){
        cin >> V[i]; 
    }
    for(int  i = 0; i < N; i++){
        cin >> C[i]; 
        if(V[i] - C[i] > 0){
            ans += V[i] - C[i];
        }
    }

    cout << ans << endl;
    return 0;

}

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

ll x[50], dp[51][51][2501];

int main() {
	ll n, a; scanf("%lld%lld", &n, &a);
	for (int i = 0; i < n; i++)scanf("%lld", &x[i]);
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= 2500; k++) {
				dp[i][j][k] += dp[i - 1][j][k];
				if (j >= 1 && k >= x[i - 1])
					dp[i][j][k] += dp[i - 1][j - 1][k - x[i - 1]];
			}
		}
	}
	ll sum = 0;
	for (int i = 1; i <= n; i++)sum += dp[n][i][a*i];
	printf("%lld\n", sum);
}

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll ans;
  if (a % 2 == 0) ans = 0;
  else if (b % 2 == 0) ans = 0;
  else if (c % 2 == 0) ans = 0;
  else ans = min(a * b, min(a * c, b * c));
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }

  long long ANS = - (1LL << 40);
  for (int i = 1; i < (1 << 10); i++) {
    long long ans = 0;
    for (int j = 0; j < N; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        if (F[j][k] && ((i >> k) & 1)) {
          cnt ++;
        }
      }
      ans += P[j][cnt];
    }
    ANS = max(ANS, ans);
  }
  cout << ANS << endl;
}


Measured memory_bytes: 3204
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


X = read_a_int()
now = X
ans = 1
while now % 360 != 0:
    now += X
    ans += 1
print(ans)


Measured memory_bytes: 67108
#include <cstdio>
#include <string>

// class List
// {
//     int* data_;
//     int begin_;
//     int end_;
// public:
//     List()
//     {
//         data_  = new int[2000000];
//         begin_ = 1999999;
//         end_   = 1999999;
//     }
//     void Insert(int X)
//     {
//         --begin_;
//         data_[begin_] = X;
//     }
//     void Delete(int X)
//     {
//         int Index = end_;
//         for(int i = begin_; i < end_; ++i){
//             if(X == data_[i]){
//                 Index = i;
//                 break;
//             }
//         }
//         if(Index == end_) return;
//         for(int i = Index; i < end_; ++i){
//             data_[i] = data_[i+1];
//         }
//         end_--;
//     }
//     void DeleteFirst()
//     {
//         begin_++;
//     }
//     void DeleteLast()
//     {
//         end_--;
//     }
//     void Show()const
//     {
//         printf("%d", data_[begin_]);
//         for(int i = begin_ + 1; i < end_; ++i){
//             printf(" %d", data_[i]);
//         }
//         printf("\n");
//     }
// };

int main()
{
    // List list;
    int* data_ = new int[2000001];
    int begin_ = 2000000;
    int end_   = 2000000;

    int n;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            // list.DeleteFirst();
            begin_++;
        }else
        if(com[6] == 'L'){
            // list.DeleteLast();
            end_--;
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                // list.Insert(v);
                --begin_;
                data_[begin_] = v;
            }else
            if(com[0] == 'd'){
                // list.Delete(v);
                int Index = end_;
                for(int i = begin_; i < end_; ++i){
                    if(v == data_[i]){
                        Index = i;
                        break;
                    }
                }
                if(Index == end_) continue;
                for(int i = Index; i < end_; ++i){
                    data_[i] = data_[i+1];
                }
                end_--;
            }
        }
    }
    // list.Show();
    printf("%d", data_[begin_]);
    for(int i = begin_ + 1; i < end_; ++i){
        printf(" %d", data_[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 6544