akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cnt(13, 0);
    cnt[0] = 1;
    rep(i,n){
        int d;
        cin >> d;
        cnt[d]++;
    }
    vector<int> circle;
    bool right = true;
    rep(i,13){
        if(cnt[i] >= 3){
            cout << 0 << endl;
            return 0;
        }
        if(cnt[i] == 2){
            if(i == 0 || i == 12){
                cout << 0 << endl;
                return 0;
            }
            circle.push_back(i);
            circle.push_back(24-i);
        }
        if(cnt[i] == 1){
            if(right) circle.push_back(i);
            else circle.push_back(24-i);
            right = !right;
        }
    }
    circle.push_back(24);
    sort(circle.begin(), circle.end());
    int ans = 24;
    rep(i,circle.size()-1){
        chmin(ans, circle[i+1] - circle[i]);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,p,k,i,j,mx,f[302][302],c[302][302],g[302][302];
int main(){
	scanf("%lld%lld%lld",&n,&mx,&p);
	for(i=0;i<=n;i++)c[i][0]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
	f[0][0]=g[0][0]=1;
	for(j=1;j<=mx;j++)f[0][j]=1,g[0][j]=j+1;
	for(i=1;i<=n;i++){
		for(j=1;j<=mx;j++){
			for(k=1;k<=i;k++){
				f[i][j]=(f[i][j]+g[k-1][j-1]*f[i-k][j]%p*c[i-1][k-1])%p;
			}
			g[i][j]=(g[i][j-1]+f[i][j])%p;
			//printf("%lld %lld %lld\n",i,j,f[i][j]);
		}
	}
	printf("%lld",f[n][mx]);
}

Measured memory_bytes: 5952
class DiceError < StandardError
end

n = gets.to_i
dices = []
n.times {dices << gets.split.map(&:to_i)}

dices2 = dices.map(&:sort).uniq
group = Array.new(dices2.size)
dices2.each_with_index do |d2, i|
  group[i] = dices.select {|d| d.sort == d2}
end

throw = {E: [3, 2, 6, 1, 5, 4], N: [5, 1, 3, 4, 6, 2],
         R: [1, 4, 2, 5, 3, 6]}
th = {}
throw.each_key {|k| th[k] = throw[k].map(&:pred)}

rotate = ->(dir, dice) {
  next_dice = Array.new(6, 0)
  dice.each_with_index do |d, i|
    next_dice[th[dir][i]] = d
  end
  next_dice
}

adapt_same_side = ->(dice, d0) {
  stack = [:N, :N, :N, :N, :E, :N, :N, :N, :N]
  stack.each do |dir|
    if dice[0] == d0[0]
      return dice
    else
      dice = rotate.(dir, dice)
    end
  end
  raise DiceError
}

is_same_dices = ->(dice1, dice2) {
  result = false
  4.times do
    if dice2 == dice1
      result = true
      break
    end
    dice2 = rotate.(:R, dice2)
  end
  result
}

handle_group = ->(dices) {
  n = dices.size
  new_dices = [dices[0]]
  dices[1, n - 1].each {|d| new_dices << adapt_same_side.(d, dices[0])}
  new_dices.combination(2) do |dice1, dice2|
    return false if is_same_dices.(dice1, dice2)
  end
  true
}

result = "Yes"
group.each do |dices|
  result = "No" unless handle_group.(dices)
end
puts result



Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(A>0&&C>0){
    C=C-B;
    if(C<=0){
      break;
    }
    A=A-D;
    if(A<=0){
      break;
    }
  }
  if(A<=0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}
    
    
  


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };

signed main() {
	string s; cin >> s;
	int k; cin >> k;
	rep(i, s.size()) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
		else {
			k--;
			if (k == 0) {
				cout << s[i] << endl;
				return 0;
			}
		}
	}
	cout << 1 << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<int> st;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }
  if ((int)st.size() == N) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}


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

using namespace std;

using ll = long long;

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

    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int L[N];
    for (auto &l: L) {
        cin >> l;
    }

    int min_sum = A + B + C;
    for (int i = 0; i < pow(4, N); ++i) {
        int sum = 0;
        int a = 0;
        int b = 0;
        int c = 0;
        int num = i;
        for (auto l: L) {
            switch (num % 4) {
                case 1:
                    a += l;
                    sum += 10;
                    break;
                case 2:
                    b += l;
                    sum += 10;
                    break;
                case 3:
                    c += l;
                    sum += 10;
                    break;
            }
            num /= 4;
        }
        sum += abs(A - a) + abs(B - b) + abs(C - c) - 30;
        if (a > 0 && b > 0 && c > 0) {
            min_sum = min(min_sum, sum);
        }
    }
    
    cout << min_sum << '\n';

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $M);

// 残りの確率
$rest = 1;

// 答え
$ans = 0;

// 試行回数
$att = 0;

$time = 1900 * $M + 100 * ($N - $M);

while ($rest > .0000000001) {
    $att++;

    $end = $rest / pow(2, $M);
    // echo "{$end} {$time}\n";

    $ans += $end * $time * $att;
    
    $rest -= $end;
}

echo round($ans) . PHP_EOL;


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

using namespace std;

using ll = long long;

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

    double N, K;
    cin >> N >> K;

    double prob = 0;
    for (int i = 1; i <= N; ++i) {
        double mul = 1;
        double point = i;
        while (point * mul < K) {
            mul *= 2;
        }
        prob += (1.0 / N) / mul;
    }

    printf("%.12f", prob);
    // cout << prob << '\n';

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 28/Mar/20 05:40:46 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int k, n;
	cin >> k >> n;
	int arr[n];
	fr (i, 0, n) cin >> arr[i];

	sort (arr, arr + n);
	int mx = 0;
	fr (i, 1, n) {
		mx = max (mx, abs (arr[i] - arr[i - 1]));
	}
	mx = max (mx, abs (k - abs (arr[n - 1] - arr[0])));
	pr (k - mx);
	return 0;
}

Measured memory_bytes: 1792
import sys
H, W = map(int, raw_input().split())
a = [raw_input() for _ in range(H)]
for i in range(H + 2):
    for j in range(W + 2):
        if i == 0 or j == 0 or i == H + 1 or j == W + 1:
            sys.stdout.write('#')
        else:
            sys.stdout.write(str(a[i - 1][j - 1]))
    print("")


Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define	ll	long long
#define	pb	push_back
#define	sz(v)	(int)v.size()
#define	nl	"\n"
using namespace std;

void solve()
{
	int n;
	cin>>n;
	string s= "";
	for(int i = 0; i<n; i++)
		s += "ACL";
	cout<<s<<nl;

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

//	int t;
//	cin>>t;
//	while(t--)
	    solve();

	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  map<int,int> a;
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  
  vector<pair<int,int>> a2;
  
  for(auto b:a){
    int c,d;
    tie(c,d) = b;
    a2.push_back(make_pair(c,d));
  }
  sort(a2.begin(),a2.end(),greater<pair<int,int>>());
  
//  for(auto b:a2){
//    printf("%d %d\n",b.first,b.second);
//  }
  
  ll h=0LL;
  ll w=0LL;
  for(auto b:a2){
    if(h != 0 && w != 0) break;
    if(b.second < 2) continue;
    if(b.second >= 4 && h == 0){
      h = b.first;
      w = b.first;
      break;
    }
    if(h == 0){
      h = b.first;
    }else{
      w = b.first;
    }
  }
  cout << h*w;
  return 0;
}

Measured memory_bytes: 6136
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

from pprint import pprint

def main():
    N=ii()
    if N==1:
        print(0)
        return
    elif N==2:
        print(2)
        return
    ans = 0
    def get(n):
        l = [1]
        for _ in range(N):
            l.append(l[-1] * n % N1097)
        return l
    l8 = get(8)
    l9 = get(9)
    l10 = get(10)

    for i in range(N-1):
        fr = N - i - 1
        a = l8[i] * ((l10[fr] - l9[fr]) % N1097)
        a = (a*2) % N1097
        ans += a
        ans %= N1097
    print(ans)





main()



Measured memory_bytes: 167740
#include<iostream>
using namespace std;
#include<complex>
#include<vector>
void dft(vector<complex<double> >&A,int sign)
{
	int N=A.size()>>1;
	if(N==0)return;
	vector<complex<double> >F(N),G(N);
	for(int i=0;i<N;i++)
	{
		F[i]=A[i<<1];
		G[i]=A[i<<1|1];
	}
	dft(F,sign);
	dft(G,sign);
	complex<double>z(cos(M_PI/N),sin(M_PI/N)*sign),p=1;
	for(int i=0;i<N;i++)
	{
		A[i]=F[i]+p*G[i];
		A[i+N]=F[i]-p*G[i];
		p*=z;
	}
}
vector<long long>multiply(const vector<int>&A,const vector<int>&B)
{
	if(A.empty()||B.empty())
	{
		return(vector<long long>){};
	}
	int N=1;
	vector<long long>ret(A.size()+B.size()-1);
	while(N<ret.size())N<<=1;
	vector<complex<double> >F(N),G(N);
	for(int i=0;i<A.size();i++)F[i]=A[i];
	for(int i=0;i<B.size();i++)G[i]=B[i];
	dft(F,1);
	dft(G,1);
	for(int i=0;i<N;i++)F[i]*=G[i];
	dft(F,-1);
	for(int i=0;i<ret.size();i++)ret[i]=llround((F[i]/=N).real());
	return ret;
}
const long P=200003;
const long root=2;
int N;
long f[P],invf[P];
main()
{
	cin>>N;
	f[0]=1;
	for(int i=1;i<P-1;i++)f[i]=f[i-1]*root%P;
	for(int i=0;i<P-1;i++)invf[f[i]]=i;
	vector<int>A(P-1);
	long ans=0;
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;
		if(a==0)continue;
		A[invf[a]]++;
		ans-=(long)a*a%P;
	}
	vector<long long>B=multiply(A,A);
	for(int i=0;i<2*P-3;i++)
	{
		ans+=f[i%(P-1)]*B[i];
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 43644
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
string S;
LL K;
int main(){
	cin>>S>>K;
	REP(i,S.size()){
		if(i==K-1){
			cout<<S[i]<<endl;
			return 0;
		}
		if(S[i]!='1'){
			cout<<S[i]<<endl;
			return 0;
		}
	}
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<sstream>
#include<map>
#include<queue>
#include<complex>
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)


#define int long long
D dot(P a, P b) {
	return (conj(a) * b).X;
}
D cross(P a, P b) {
	return (conj(a) * b).Y;
}
int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (cross(b, c) > EPS)return 1;
	if (cross(b, c) < -EPS)return -1;
	if (dot(b, c) < -EPS)return 2;
	if (norm(b) < norm(c))return -2;
	return 0;
}

bool issecSS(P a1, P a2, P b1, P b2) {
	return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
		ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}
VP crosspointCC(P a, D ar, P b, D br) {
	VP ps;
	P ab = b - a;
	D d = abs(ab);
	D crL = (norm(ab) + ar*ar - br*br) / (2 * d);
	if (EQ(d, 0) || ar < abs(crL)) return ps;

	P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
	P cp = a + crL / d * ab;
	ps.push_back(cp + abN);
	if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
	return ps;
}
int N;
signed main() {
	while (true) {
		cin >> N;
		if (N == 0)break;
		vector<int> x(N);
		vector<int> y(N);
		vector<int> r(N);
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i] >> r[i];
		}
		vector<VP> vp(N + 1);
		vp[0] = VP(1, P(x[0], y[0]));
		for (int i = 1; i <= N - 1; i++) {
			vp[i] = crosspointCC(P(x[i - 1], y[i - 1]), r[i - 1], P(x[i], y[i]), r[i]);
			if ((int)vp[i].size() == 1)vp.push_back(vp[0]);
			//cerr << i << " " << vp[i].size() << endl;
		}
		vp[N] = VP(1, P(x[N - 1], y[N - 1]));
		vector<vector<double> > dst(N + 1, vector<double>(2, 1e9));
		dst[0][0] = 0;
		bool f = true;
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j < i; j++) {
				for (int a = 0; a < vp[i].size(); a++) {
					for (int b = 0; b < vp[j].size(); b++) {
						f = true;
						for (int k = j + 1; k < i; k++) {
							if (!issecSS(vp[j][b], vp[i][a], vp[k][0], vp[k][1])) {
								
								f = false;
								break;
							}
						}
						
						if (f) {
							dst[i][a] = min(dst[i][a], dst[j][b] + abs(vp[j][b] - vp[i][a]));
						}
					}
				}
			}
		}
		cout << fixed << setprecision(15) << dst[N][0] << endl;
	}
}


Measured memory_bytes: 3260
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

/** direction */
enum class GridDirection(val dx: Int, val dy: Int) {
    UP(0, -1),
    DOWN(0, 1),
    LEFT(-1, 0),
    RIGHT(1, 0),
}

fun gridBfs(h: Int, w: Int, grid: Array<String>): Array<LongArray> {
    /** point of coordinate */
    data class Point(val x: Int, val y: Int)

    val countGrid = Array(h) { LongArray(w) }
    val checkedGrid = Array(h) { BooleanArray(w) }
    val queue = ArrayDeque<Point>()
    queue.addLast(Point(0, 0))
    checkedGrid[0][0] = true
    while (queue.isNotEmpty()) {
        val node = queue.removeFirst()
        for (d in GridDirection.values()) {
            val x = node.x + d.dx
            val y= node.y + d.dy
            if (!(y in 0 until h && x in 0 until w)) continue
            if (checkedGrid[y][x]) continue

            if (grid[y][x] == '#') continue

            countGrid[y][x] = countGrid[node.y][node.x] + 1
            checkedGrid[y][x] = true
            queue.addLast(Point(x, y))
        }
    }

    return countGrid
}

fun solve() {
    val (h, w) = readIntegerList()
    val map = Array(h) { br.readLine()!! }

    val countMap = gridBfs(h, w, map)

    val tmp = countMap[h - 1][w - 1]
    if (tmp == 0L) {
        out.println(-1)
        return
    }

    val whiteCount = map.fold(0L) { acc, s -> acc + s.count { it == '.' } } - 1
    out.println(whiteCount - tmp)
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main(){
  int N, M;
  cin>>N>>M;
  
  int ans=0;
  if(N>=2){
    ans += N*(N-1)/2;
  }
  
  if(M>=2){
    ans += M*(M-1)/2;
  }
  
  cout<<ans<<endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	VI zz(5), cv(130, -1);
	string mc = "MARCH";
	rep(i, 5) cv[mc[i]] = i;
	rep(i, n){
		string s; cin >>s;
		if(cv[s[0]] <0) continue;
		zz[cv[s[0]]]++;
	}
	for(auto x :zz) cerr<<x<<" "; dbg();
	ll ans = 0LL;
	rep(i, 1<<5){
		if(__builtin_popcount(i) !=3) continue;
		ll w = 1;
		rep(j, 5) if(i>>j &1) w  *= zz[j];
		ans += w;
	}
	cout << ans <<"\n";
	return 0;
}


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

int main(){
  long long A, B, C;
  cin >> A >> B >> C;
  long long ans=0;
  if(C>A+B+1) ans= B*2 + A + 1;
  else ans = B + C;
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
const int N = 100001;
int a[N];

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++) {
        a[i] = k;
        a[i] -= q;
    }
    while (q--) {
        int x;
        cin >> x;
        a[x]++;
    }
//    for (int i = 1; i <= n; i++) {
//        a[i] = max(0, a[i] - q);
//    }
//    for (int i = 1; i <= n; i++) {
//        cout << a[i] << ' ';
//    }
    for (int i = 1; i <= n; i++) {
        if (a[i] > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A>B) swap(A, B);
    if(C>A && B > C)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n; cin >> n;
    int a;   
    map<ll, ll> m;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> a;
        ll l = i - a;
        ll r = i + a;
        ans += m[l];
        m[r]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 26300
N,A,B = map(int, input().split())

H = [int(input()) for i in range(N)]

low = sum(H)//(len(H)*B+A-B) - 1
high = max(H)//B+1

d = A-B
ceildiv = lambda x,y: -(-x//y)

while low + 1 < high:
  mid = (low+high)//2
  offset = mid*B
  cnt = sum(max(ceildiv(h - offset, d),0) for h in H)
  if cnt > mid:
    low = mid
  else:
    high = mid

print(high)

Measured memory_bytes: 7072
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string s; cin >> s;
    ll pre = stoll(s.substr(0,2));
    ll lat = stoll(s.substr(2,2));
    
    
    bool prem = 1 <= pre && pre <= 12;
    bool latm = 1 <= lat && lat <= 12;
    
    if(prem && latm){
        cout << "AMBIGUOUS" << endl;
    }
    else if(prem){
        cout << "MMYY" << endl;
    }
    else if(latm){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * Author : Deep Raval
 * There are no two words in the English language more harmful than "good job".
 * 1729 0_0
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
    ll n,x, t;
    cin >> n >> x >> t;
    cout << ll(ceil(double(n) / x)) * t << endl;
	return ;
}
int main()
{
	FAST_IO
    int t = 1;
    //cin >> t;
    while(t--)
        test_case();
	return 0;
}

Measured memory_bytes: 3700
N,M = map(int,input().split())
xyz = [list(map(int,input().split())) for _ in range(N)]
#%%
ans = 0
state = [0,0,0]
for s in range(1<<3):
    for i in range(3):
        if s%2 == 1:
            state[i] = 1
        else:
            state[i] = 0
        s = s>>1
    
    #state[i]==1ならxyz[:,i]を負に反転して集計
    totalList = [0] * N
    
    for k in range(N):
        t = 0
        for i in range(3):
            if state[i]:
                t -= xyz[k][i]
            else:
                t += xyz[k][i]
        totalList[k] = t
        
    totalList.sort(reverse = True)
    cur = sum(totalList[:M])
    ans = max(ans,cur)
    cur = sum(totalList[N-M:])
    ans = max(ans,cur)

print(ans)
    
    

Measured memory_bytes: 43632
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back


typedef long long ll;
typedef double db;

using namespace std;

int v[30];

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    string s;
    cin >> s;

    for(int i=0; i<s.size(); i++)
    {
        v[s[i] - 'a']++;
    }
    int flag = 0;

    for(int i=0; i<30; i++)
    {
        if(v[i] % 2 ==1)
        {
            flag = 1;
            break;
        }
    }
    if(flag == 0)
        cout << "Yes" << nl;
    else
        cout << "No" << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3660
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0 ;i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        boolean[] b = new boolean[1000001];

        int res = 0;
        for(int i=0; i<n; i++) {
            int num = a[i];
            if(!b[num] && !(i<n-1 && num == a[i+1])) res++;
            if(!b[num]) {
                for(int j = num; j<=1000000; j+=num) {
                    b[j] = true;
                }
            }
        }
        System.out.println(res);

    }


}

Measured memory_bytes: 60984
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char s[200000];
	int n,sum,i;
	scanf("%s",s);
	n=strlen(s);
	sum=n;
	//printf("n=%d\n",n);
	for(i=0;i<n;i++){
		if(s[i]=='A'){
			sum-=i-1;
			break;
		}
	}
	//printf("sum=%d\n",sum);
	for(i=n;i>0;i--){
		if(s[i]=='Z'){
			n-=i;
			sum-=n;
			break;
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
	int n;
	double v[55];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (v[i] > v[j]) {
				int tmp = v[i];
				v[i] = v[j];
				v[j] = tmp;
			}
		}
	}
	
	while (n != 1) {
		v[0] = (v[0] + v[1]) / 2;
		
		for (int i = 2; i < n; i++) {
			v[i - 1] = v[i];
		}
		n--;
	}
	cout << v[0];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define x first
#define y second
#define PII pair < int , int >
#define PLL pair < ll , ll >
#define mod 1000000007
#define maxn 100100

using namespace std;

ll n, a[300100], dp[300100], dp2[300100], sum, mn = 1e17, m;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cout << ((n+m)%3==0 || n%3==0 || m%3==0 ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
boxnum, sousanum = map(int, input().split(" "))
sousa = []
for i in range(sousanum):
  sousa.append(list(map(int, input().split(" "))))

#aka[0][0] ...[ボール個数][赤フラグ]
ball = [[1, 0] for i in range(boxnum)]
ball[0][1] = 1
for i in range(sousanum):
  if ball[sousa[i][0] - 1][1] == 1:#赤色あり
    ball[sousa[i][1] - 1][1] = 1
    
  ball[sousa[i][0] - 1][0] -= 1
  ball[sousa[i][1] - 1][0] += 1
  
  if ball[sousa[i][0] - 1][0] == 0:#ボール尽きた
    ball[sousa[i][0] - 1][1] = 0
total = 0
for i in range(boxnum):
    total += ball[i][1]
print(total)

Measured memory_bytes: 34632
N = int(input())
t = [2,1]
h = [[1],[1]]
while t[1]<=N:
    if t[1]==N:
        print("Yes")
        print(t[0])
        [print("{0} {1}".format(len(h[i])," ".join([str(j) for j in h[i]]))) for i in range(len(h))]
        break
    else:
        [h[i].append(t[1]+1+i) for i in range(len(h))]
        h.append([t[1]+1+i for i in range(len(h))])
        t[1]+=t[0]
        t[0]+=1
else:
    print("No")
    exit()


Measured memory_bytes: 12216
n,m=list(map(int,input().split()))
s=[]
k=[]
for i in range(m):
    ss=list(map(int,input().split()))
    k.append(ss[0])
    s.append(ss[1:])
p=list(map(int,input().split()))


def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

ans=0

for bit in range(2**n):
    ok=True
    for mm in range(m):
        on=0
        for i in s[mm]:
            if bit & 2**(i-1)!=0:
                on+=1
        if on%2==p[mm]:
            pass
        else:
            ok=False

    if ok:ans+=1
print(ans)

Measured memory_bytes: 3064
import itertools
N, M, R = map(int, input().split())
r = tuple(map(lambda n: int(n)-1, input().split()))
inf = float("inf")
vertices = [[inf]*N for _ in [0]*N]
for _ in [0]*M:
    a, b, c = map(int, input().split())
    vertices[a-1][b-1] = c
    vertices[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        c2 = vertices[i][k]
        for j, (c1, c3) in enumerate(zip(vertices[i], vertices[k])):
            vertices[i][j] = c1 if c1 < c2+c3 else c2+c3

ans = inf

for p in itertools.permutations(r):
    subt = 0
    for i in range(R-1):
        subt += vertices[p[i]][p[i+1]]
    if subt < ans:
        ans = subt

print(ans)


Measured memory_bytes: 80748
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // M_PI, sin(), cos()

typedef struct point_tbl{
	double x;
	double y;
} point;

void koch(int n, point a, point b){
	point s, t, u;

	if (n == 0)
		return;

	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main(int argc, char** argv){
	point a, b;
	int n;

	scanf("%d", &n);
	a.x = 0, a.y = 0;
	b.x = 100, b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


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

int main(){
  ll n;
  cin >> n;
  ll cnt=0;
  vector <ll> m(n+1,0);
  for(ll i = 1;i<n+1;i++){
    ll j = 1;
    while(i*j<=n){
      m[i*j]++;
      j++;
    }
  }
  for(ll i = 1;i<n+1;i++)cnt+=i*m[i];
  cout << cnt << endl;
}


Measured memory_bytes: 81328
#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.000000001
#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 m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res);
    x=(x*x);
    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;
  }
}*/
vi gr[1000001];
int ans;

void dfs(int v,int cnt,int p){
    ans=max(ans,cnt);
    int x=gr[v].size();
    if(p==-1)
    x--;
    else
    x-=2;
    for(auto u:gr[v]){
        if(u!=p){
            dfs(u,cnt+x,v);
        }
    }
}

void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
       int n,m;
       cin>>n>>m;
       unordered_set<int> st;
       
       int w=0;
       unordered_map<int,int> mpi;
       forn(i,0,m){
           int x;
           cin>>x;
           string s;
           cin>>s;
           
           if(s=="WA"){
               if(st.find(x)==st.end()){
                  mpi[x]++;
               }
           }
           else{
               st.insert(x);
           }
       }
       for(auto it:mpi){
           if(st.find(it.first)!=st.end())
           w+=it.second;
       }
       cout<<st.size()<<" "<<w;
  }    
}    

    


/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

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

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


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: 27812
#include<iostream>
    using namespace std;
    int main()
    {
      int n; cin>>n;
      int *x = new int[n];
      int *y = new int[n];
      int ans = 0;
      for(int i=0;i<n;i++)cin>>x[i];
      for(int i=0;i<n;i++)
      {
        cin>>y[i];
        if(x[i]>y[i])ans+=x[i]-y[i];
      }
      cout<<ans<<endl;
      delete[] x;
      delete[] y;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner s = new Scanner(System.in);
	
	public static void main(String[] args) {
		String S = s.next();
		int min = Integer.MAX_VALUE;
		for(int i = 0;i < S.length()-2;i++) {
			min = Math.min(min, Math.abs(753 - Integer.parseInt(S.substring(i, i+3))));
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21588
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

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

    long long ans = 0;
    long long tmp = 0;
    long long f = 1;
    for(int i=0; i<n-1; ++i){
        tmp *= i + 1;
        tmp %= MOD;
        tmp += f;
        tmp %= MOD;
        f *= i + 1;
        f %= MOD;

        ans *= i + 1;
        ans %= MOD;
        ans += tmp * (x[i+1] - x[i]);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n;cin>>n;
    
    vi l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(), l.end());
    
    int sum = 0;
    rep(i,n-1)sum+=l[i];
    
    cout << (sum>l[n-1]?"Yes":"No") << endl;
    
    return 0;
}

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

int main(void){
    int N,K;
    string S;
    char key;
    cin>>N>>S>>K;
    key = S[K-1];
    for(int i = 0; i<N; i++){
        if(S[i] != key){
            S[i] = '*';
        }
    }
    cout<<S<<endl;
    return 0;
}

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

int main()
{
	int res = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();i++) {
		if (res == 0 && s[i] == 'C') {
			res++;
		}
		else if (res == 1 && s[i] == 'F') {
			res++;
		}
		else if (res == 2) {
			break;
		}
	}
	cout << (res == 2 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

char a[1000][1024];
int v[1000][1024];

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

    int h, w;
    cin >> h >> w;

    queue<pair<int, int>> q;

    for (int i = 0; i < h; i++) {
        cin >> a[i];
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') q.push({ i, j });
        }
    }

    int r = 0;
    while (!q.empty()) {
        pair<int, int> i = q.front(); q.pop();
        for (auto d : { pair<int, int>{ -1, 0 }, pair<int, int>{ 1, 0 }, pair<int, int>{ 0, 1 }, pair<int, int>{ 0, -1 } }) {
            pair<int, int> j = { i.first + d.first, i.second + d.second };
            if (j.first < 0 || j.first >= h || j.second < 0 || j.second >= w) continue;
            if (a[j.first][j.second] == '.' && v[j.first][j.second] == 0) {
                v[j.first][j.second] = v[i.first][i.second] + 1;
                r = max(r, v[j.first][j.second]);
                q.push(j);
            }
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 11408
#include<stdio.h>
int main(void)
{
  char str[3];
  int i;
  for(i=0;i<3;i++)
    scanf("%s",&str[i]);
  
  if(str[0]==str[1]&&str[1]==str[2])
    printf("No");
  else
    printf("Yes");
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<complex>
#include<math.h>
#include<algorithm>
using namespace std;
int n,i,j;
double x[100],y[100],a[101],Ans[100];
complex<double>z[100];
int main()
{
  cin >> n;
  for(i=0;i<n;i++){
    cin >> x[i] >> y[i];
    z[i]=complex<double>(x[i],y[i]);
  }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        a[j]=fmod(arg(z[j]-z[i])+2*M_PI,2*M_PI);
      }
      sort(a,a+n);
      a[n]=a[1]+2*M_PI;
      for(j=1;j<n;j++){
        if(a[j+1]-a[j]>=M_PI){Ans[i]=(a[j+1]-a[j]-M_PI)/2/M_PI;
                             }
      }
      cout << Ans[i] << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll x,y,a,b,c,xx[1000001],yy[1000001],zz[1000001],poz,dp[1000001],ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;i++)
        cin>>xx[i];
    for(int i=1;i<=b;i++)
        cin>>yy[i];
    for(int i=1;i<=c;i++)
        cin>>zz[i];
    sort(xx+1,xx+a+1);
    reverse(xx+1,xx+a+1);
    sort(yy+1,yy+b+1);
    reverse(yy+1,yy+b+1);
    sort(zz+1,zz+c+1);
    reverse(zz+1,zz+c+1);
    for(int i=1;i<=x;i++)
        dp[0]+=xx[i];
    for(int i=1;i<=y;i++)
        dp[0]+=yy[i];
    ans=dp[0];
    ll suma=x+y;
    for(int i=1;i<=min(suma,c);i++)
    {
        ll nr=dp[i-1]+zz[i];
        if(x!=0&&y!=0)
        {
            if(xx[x]<yy[y])
            {
                nr-=xx[x];
                x--;
            }
            else
            {
                nr-=yy[y];
                y--;
            }
        }
        else if(x==0)
        {
            nr-=yy[y];
            y--;
        }
        else if(y==0)
        {
            nr-=xx[x];
            x--;
        }
        dp[i]=nr;
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}


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


int main(void) {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < d;j++){
            cin >> x.at(i).at(j);
        }
    }
    int count = 0;
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            double disp = 0;
            for(int k = 0;k < d;k++){
                disp += (x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
            }
            disp = sqrt(disp);
            if(ceil(disp) == floor(disp))count ++;
        }
    }
    cout << count << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;

  if (L < R) {
    cout << "Right" << endl;
  }
  else if (L > R) {
      cout << "Left" << endl;
  }
  else if (L == R) {
      cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int LCS(char*,char*);

int main()
{
  int n,i,j;
  char C1[1001],C2[1001];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",C1);
    scanf("%s",C2);
   printf("%d\n",LCS(C1,C2));
  }
  return 0;
}

int LCS(char *A,char *B)
{
  int c[1001][1001],i,j,x,y;
  x=strlen(A)+1;
  y=strlen(B)+1;
  for(i=1;i<x;i++)c[0][i]=0;
  for(i=0;i<y;i++)c[i][0]=0;
  
  for(i=1;i<x;i++){
    for(j=1;j<y;j++){
      if(A[i-1]==B[j-1])c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[x-1][y-1];
}



Measured memory_bytes: 5688
from sys import stdin
n,k = [int(x) for x in stdin.readline().rstrip().split()]
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append([int(x) for x in stdin.readline().rstrip().split()])
b = [0]*n
for i in range(k):
    for j in range(d[i]):
        b[a[i][j]-1] = 1
ans =0
for i in range(n):
    if b[i] == 0:
        ans += 1
print(ans)

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

using namespace std;

int main() {
	cin.tie(0);
	cout.tie(0);
	string s;
	long long k;
	cin>>s;
	cin>>k;
	if (s.size() == 1) {
		cout<<(k/2)<<endl;
		return 0;
	}
	long long n = s.size();
	if (s[0] == s[n - 1]) {
		long long beg = 0;
		while (beg < n && s[beg] == s[0])
			beg++;
		long long end = n - 1;
		while (end > 0 && s[end] == s[n - 1])
			end--;
		if (beg == n) {
			cout<<(n*k/2)<<endl;
			return 0;
		}
		long long res = 0;
		for (long long i = beg + 1; i <= end; i++)
			if (s[i] == s[i - 1]) {
				res++;
				s[i] = 'A';
			}
		res*=k;
		res += (beg / 2) + (n - 1 - end) / 2;
		res += (k - 1) * ((beg + n - 1 - end) / 2);
		cout<<res<<endl;
	} else {
		long long res = 0;
		for (long long i = 1; i < n; i++)
			if (s[i] == s[i - 1]) {
				res++;
				s[i] = 'A';
			}
		cout<<res*k<<endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
def inpl(): return map(int, input().split())

N, M = inpl()
G = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = inpl()
    G[a].append(b)
    G[b].append(a)

searched = [False] * (N+1)

m = 1
searched[m] = True

ans = []
def dfs(c):
    global ans
    searched[c] = True
    for d in G[c]:
        if not searched[d]:
            ans.append(c)
            dfs(d)
            break 
    else:
        ans.append(c)
    
dfs(1)
ans = ans[:0:-1]
dfs(1)

print(len(ans))
print(*ans)

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

int main(int argc, char* argv[])
{
	string A;
	string B;
	string C;
	cin>>A;
	cin>>B;
	cin>>C;
	char *pA=(char*)A.c_str();
	char *pB=(char*)B.c_str();
	char *pC=(char*)C.c_str();
	char ch = *pA;
	pA++;
	int i=0;
	for(;;){
		if (ch=='\0'){
			switch(i){
				case 0:
					cout<<'A'<<endl;
					break;
				case 1:
					cout<<'B'<<endl;
					break;
				case 2:
					cout<<'C'<<endl;
					break;
			}
			return 0;
		}
		switch(ch){
			case 'a':
				ch = *pA;
				pA++;
				i=0;
				break;
			case 'b':
				ch = *pB;
				pB++;
				i=1;
				break;
			case 'c':
				ch = *pC;
				pC++;
				i=2;
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N,K,Q=[int(i) for i in input().split()]
A = []
for i in range(Q):
  A.append(int(input()))
P=[Q-K]*N
for i in range(Q):
  P[A[i]-1]-=1
for i in range(N):
  if P[i]<0:print("Yes")
  else :print("No")

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

int main(){
  int n,m;cin >> n >> m;
  bool ans = false;
  vector<int> a(m),b(m),c(n,0);
  for(int i=0;i<m;i++)cin >> a[i] >> b[i];
  for(int i=0;i<m;i++){
    if(a[i]==1)c[b[i]-1]++;
    if(b[i]==n)c[a[i]-1]++;
  }
  for(int i=0;i<c.size();i++){
    if(c[i]==2)ans = true;
  }
  if(ans)cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2560