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

public class Main {
	public static void main(String[]args) {
        function();
	}

	public static void function() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n >= m) {
        	System.out.println(0);
        	System.exit(0);
        }
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < m; i++) {
        	int tmp = sc.nextInt();
        	list.add(tmp);
        }
		Collections.sort(list);

		List<Integer> dist = new ArrayList<>();
		for(int i = 1; i < list.size(); i++) {
			dist.add( list.get(i) - list.get(i-1) );
		}

		solve(n, dist);
	}

	static void solve(int n, List<Integer> dist) {
		Collections.sort(dist);

		for(int i = 1; i < n; i++) {
			dist.remove( dist.size()-1 );
		}
		System.out.println(sum(dist));
	}

	static int sum(List<Integer> list) {
		int sum = 0;
		for(int i = 0; i < list.size(); i++) {
			sum += list.get(i);
		}
		return sum;
	}
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> a(N);
    REP(i,N){
        cin >> a.at(i);
    }
    ll ans = INF;
    for (ll i = -101; i <= 101; i++)
    {
        ll tmp = 0;
        REP(j, N)
        {
            tmp += (i - a.at(j)) * (i - a.at(j));
        }
        ans = min(tmp, ans);
    }
    cout << ans << endl;
}


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

template<class T>bool chmin(T &a, const T &b) {return (b<a)?(a=b,1):0;}
template<class T>bool chmax(T &a, const T &b) {return (a<b)?(a=b,1):0;}

using R=long double; // __float128
const R EPS = 1E-8; // [-100:100]->EPS=1e-9 [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}

using P=complex<R>;
using L=struct{P s,t;};

inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {
	if (sgn(det(o,a,b)) > 0) return LEFT;
	if (sgn(det(o,a,b)) < 0) return RIGHT;
	if (sgn(dot(o,a,b)) < 0) return BACK;
	if (sgn(norm(a-o)-norm(b-o)) < 0) return FRONT;
	return ON;
}

// above prepared template

bool iss(L a,L b,int end=0){
	int s1=ccw(a.s,a.t,b.s)|ccw(a.s,a.t,b.t);
	int s2=ccw(b.s,b.t,a.s)|ccw(b.s,b.t,a.t);
	if(end) return (s1&s2)==(LEFT|RIGHT);
	return (s1|s2)&ON || (s1&s2)==(LEFT|RIGHT);
}

R dsp(L s,P p){
	if(sgn(dot(s.s,s.t,p))<=0) return abs(p-s.s);
	if(sgn(dot(s.t,s.s,p))<=0) return abs(p-s.t);
	return abs(det(s.s,s.t,p))/abs(s.t-s.s);
}

R dss(L a,L b){return iss(a,b)?0:min({dsp(a,b.s),dsp(a,b.t),dsp(b,a.s),dsp(b,a.t)});}


using edge=struct {int to;R cost;};
using G=vector<vector<edge>>;
const R inf=1e60;

vector<R> dijkstra(const G &graph,int s){
	const int n=graph.size();
	vector<R> dist(n,inf);
	using state=tuple<R,int>;
	priority_queue<state,vector<state>,greater<state>> q;
	dist[s]=0.0,q.push(state(0.0,s));
	
	while(!q.empty()){
		R c; int v;
		tie(c,v)=q.top();q.pop();
		for(auto &e:graph[v]){
			R nc=c+e.cost; int nv=e.to;
			if(chmin(dist[nv],nc)) q.push(state(nc,nv));
		}
	}

	return dist;
}

int main(void){
	int w,m;
	cout.precision(20);
	while(cin >> w >> m,w){
		vector<L> pol[210];

		rep(i,m){
			int n,x[55],y[55];
			cin >> n;
			rep(j,n) cin >> x[j] >> y[j];
			rep(j,n) pol[i].push_back({P(x[j],y[j]),P(x[(j+1)%n],y[(j+1)%n])});
		}

		const int s=m,t=m+1,n=m+2;
		pol[s].push_back({P(0,-1e5),P(0,1e5)});
		pol[t].push_back({P(w,-1e5),P(w,1e5)});
		G graph(n);

		rep(j,n)rep(i,j){
			R d=inf;
			for(auto &il:pol[i])
				for(auto &jl:pol[j]) 
					chmin(d,dss(il,jl));
			graph[i].push_back({j,d});
			graph[j].push_back({i,d});
		}
	
		auto dist=dijkstra(graph,s);
		cout << fixed << dist[t] << endl;
 	}
	return 0;
}

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

using namespace std;

int main() {
  int x,a,b; cin >> x >> a >> b;
  if ( abs(x-a) < abs (x-b) ) cout << "A" << endl;
  else if ( abs(x-a) > abs (x-b) ) cout << "B" << endl;
  return 0;
}


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

public class Main{

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int n = s.length();

        String temp = "";
        int min = 1000;
        int num =0;
        for(int i=0 ; i<n-2; i++){
            temp = s.substring(i , i+3);
            // System.out.println(temp);
            num = Integer.parseInt(temp);
            num = Math.abs(753-num);
            min = (min<num) ? min : num;
        }
        System.out.println(min);

    }
}

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

Measured memory_bytes: 1712
N,M = tuple(map(int,input().split()))
from collections import defaultdict
graph = defaultdict(list)
edges = []
for i in range(M):
  a,b = tuple(map(int,input().split()))
  graph[a].append(b)
  graph[b].append(a)
  edges += [(a,b)]
  
# pathを運んで，その中で
res = 0

def search_path(from_node,to_node):
  queue = [(from_node,set())]
  while queue:
    now, prevs = queue.pop()
    for next_node in graph[now]:
      if {now,next_node} != {from_node,to_node} :
        if next_node == to_node:
          # print(now,next_node,from_node,to_node,prevs)
          return 0
        if next_node not in prevs|{from_node,to_node}:
          queue.append((next_node, prevs|{now}))
  else:
    return 1

print(sum([search_path(from_node,to_node)	for from_node,to_node in edges]))

Measured memory_bytes: 41580
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	p := nextPrime(x)
	fmt.Println(p)
}

func nextPrime(x int) int {
	for ; ; x++ {
		isPrime := true
		for n := x / 2; n > 1; n-- {
			if x%n == 0 {
				isPrime = false
				break
			}
		}
		if isPrime {
			return x
		}
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

#define ll long long
#define ull unsigned long long
#define ui unsigned int

using namespace std;

int main()
{
	int a;
	char input[100];
	scanf("%d %s", &a, input);
	int ans = 0;
	for (int i = 0; i < a - 2; ++i)
	{
		if (input[i] == 'A' && input[i + 1] == 'B' && input[i + 2] == 'C') ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	
	int x;
	cin >> x;
	if(x < 100){
		cout << 0 << endl;
		return 0;
	}
	int a, b;
	a = x % 100;
	b = x / 100;
	if(a > b * 5) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
H, W, N = map( int, input().split())
X = [ tuple( map( int, input().split())) for _ in range(N)]
X.sort()
d = 0
ans = H
for i in range(N):
    if X[i][1]+d == X[i][0]:
        d += 1
    if X[i][1] + d < X[i][0]:
        ans = X[i][0]-1
        break
print(ans)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int h = 100,w = 100;
    ll a,b; cin >> a >> b;
    vvc c(h,vc(w,'.'));
    rep(i,50)rep(j,w)c[i][j] = '#';

    //aが白'.'の連結部分,a-1個分だけ(最大499個)
    rep(i,a-1){
        int row = (i / 50) * 3;
        int col = (i % 50)*2 + (row % 2);
        c[row][col] = '.';
    }

    //b-1個分黒くする
    rep(i,b-1){
        int row = 99 - (i / 50) * 3;
        int col = (i % 50)*2 + (row % 2);
        c[row][col] = '#';
    }

    //出力
    cout << h << " " << w << endl;
    rep(i,h){
        rep(j,w){
            cout << c[i][j];
        }   
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int ans[10001],m[10001],f[10001],n,i,j,k,c;
	while(cin >> n) {
		if (n==0) break;
		c=0;
		for (i=0;i<10001;i++) ans[i]=f[i]=0;
	    for (i=1;i<=(n-1)/2;i++) { k=(i*i) % n; if (f[k]==0) { f[k]=1; m[c++]=k; }} 
	for (i=0;i<c-1;i++) for (j=i+1;j<c;j++) {
          k=m[j]-m[i];
          k=k<0 ? k+n : k;
          k=k>(n-1)/2 ? n-k : k;
          ans[k]++;
          }
     for (i=1;i<=(n-1)/2;i++) cout << ans[i]*2 << endl;
	}
return 0;
 }

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int n, m;
int a[302][302];
int sp[302];
int ans = 1e9;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j]; 
			--a[i][j];
		}
	}
	for (int iter = 0; iter < m; ++iter) {
		for (int i = 0; i < m; ++i) sp[i] = 0;
		for (int i = 0; i < n; ++i) {
			int t;
			for (int j = 0; j < m; ++j) {
				t = a[i][j];
				if (t != -1) break;
			}
			++sp[t];
		}
		int t = 0;
		for (int i = 0; i < m; ++i) {
			if (sp[t] <= sp[i]) t = i;
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				if (a[i][j] == t) {
					a[i][j] = -1;
					break;
				}
			}
		}
		ans = min(ans, sp[t]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (ans * 2 > ans + k) {
            ans += k;
        }else{
            ans *= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
  { [m,f,r] <- getInts
  ; if all (-1 ==) [m,f,r] then done
    else putStrLn
      ( if m == (-1) || f == (-1) then "F"
        else if m+f >= 80 then "A"
             else if m+f >= 65 then "B"
                  else if m+f >= 50 then "C"
                       else if m+f >= 30 then if r >= 50 then "C" else "D"
                            else "F"
      ) >> main
  }

done :: IO ()
done = return ()

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4048
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

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

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll m = 0;
  if (A + B - N > 0)
    m = A + B - N;
  cout << min(A, B) << " " << m << endl;
  return 0;
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,k,a[100001],d[200001];

void nhap()
{
    scanf("%d %d",&n,&k);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        d[i]=INT_MAX;
    }
}

void process()
{
    d[1]=0;
    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<=k;++j)
        {
            d[i+j]=min(d[i+j],d[i]+abs(a[i]-a[i+j]));
        }
    }
    cout<<d[n];
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 1024
h,w= map(int,input().split())
# 二重配列
arr = [list(input()) for i in range(h)]

y = len(arr[0])
x = len(arr)

arr2 = [[0 for i in range(y)] for j in range(x)]

for i in range(0,x):
    if arr[i].count('#')!=0:
        for j in range(0,y):
            arr2[i][j]+=1

for j in range(0,y):
    f =[False]
    for i in range(0,x):
        if arr[i][j]=='#':
            f[0]=True
            break
    if f[0]==True:
        for i in range(0,x):
            arr2[i][j]+=1

for i in range(0,x):
    j = 0
    while((arr2[i].count(1)!=0)or(arr2[i].count(0)!=0)):
        if arr2[i][j]<2:
            del(arr[i][j])
            del(arr2[i][j])
            j -=1
        j += 1

for i in range(0,x):
    if len(arr[i])==0:
        continue
    print("".join(arr[i]))


Measured memory_bytes: 3316
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

void solve(long long Q, std::vector<long long> l, std::vector<long long> r){
    LL list[191919];
    list[0]=0;
    for(LL i=1; i <191919; i++){
        if(i%2==0){list[i]=0;}
        else if(IsPrime(i) && IsPrime((i+1)/2)){
            list[i]=1;
        }
        // debug(list[i]);
    }
    LL sum=0;
    FOR(i, 1,191919){
        list[i]+=list[i-1];
    }
    
    REP(i,Q){
        cout<<list[r[i]]-list[l[i]-1]<<endl;
    }
    return;
}

int main(){
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> l(Q);
    std::vector<long long> r(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&l[i]);
        scanf("%lld",&r[i]);
    }
    solve(Q, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

int main(void){
  int d, n, sum;
  int i, j;
  cin >> d >> n;
  if(100 > n){
    cout << pow(100, d) * n << endl;
  }
  else if(d < 2){
    cout << pow(100, d) * n + pow(100, d) << endl;
  }
  else{
    cout << "1010000" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC179C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var count = 0;
            for (var A = 1; A <= N; A++)
            {
                for (var B = 1; B <= (N / A); B++)
                {
                    var c = N - A * B;
                    if (c > 0)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
struct triple{ll   x=0;ll   y=0;ll   z=0;void mt(ll   a,ll   b, ll   c){x=a;y=b;z=c;} void holify(){x=69;y=420;z=911;}};
#define pb push_back
#define x first 
#define y second
#define vec vector
#define pf(vec,val) vec.insert(vec.begin(),val)
#define mp make_pair
#define pii pair<ll  ,ll  >
#define maxll  69696991169
#define minll  -69696942069
#define sz(vec) (ll )vec.size()
#define speedup ios_base::sync_with_stdio(0); cin.tie(NUll ); cout.tie(NUll );
#define loop(mep) for(auto it = mep.begin();it!=mep.end();++it)
//#define usaco_crap(str)ifstream cin((string)str + (string)".in"); ofstream cout ((string)str+(string)".out");
#define range(n) =0;i<(n);i++
#define prll  (vec) for(auto it=vec.begin();it!=vec.end();++it)cerr<<*it<<" ";cerr<<endl;
// mt make triple // triple.mt(a,b,c) //
int  main(){
	ll  n; cin>>n;
	ll  arr[n];
	map<ll  , ll >check;
	for(ll  i = 0 ; i < n ; i++){
		cin>>arr[i];
		check[arr[i]]++;
	}
	ll res = 0;
	for(auto it = check.begin() ; it != check.end() ; it++){
		res += (it->y * (it->y-1))/2;
	}
	for(ll  i = 0 ; i < n ; i++){
		cout<<res - ((check[arr[i]] * (check[arr[i]]-1))/2) + (((((check[arr[i]]-1) * (check[arr[i]]-2))/2)))<<endl;
	}
}


Measured memory_bytes: 12928
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int main(){
	int N;
	cin>>N;
    vector <int>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    }
	
	int four_sum=0;
	int even=0;
	for(int i=0 ; i<N ; i++){
		if(a[i]%4==0)four_sum+=1;
		else if(a[i]%2==0)even++;
		if(even==2){
			four_sum+=1;
			even=0;
		}
	}
	
	if(four_sum*2+1>=a.size())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 640
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do 
    [s,t]  <- getStringList
    [a,b] <- getIntegerList
    [dis] <- getStringList
    if s==dis then pr [a-1,b] else pr [a,b-1]
    return ()
  
    --a2 <- if s==dis then ((-1)<$>a) else a          
    --b2 <- if t==dis then ((-1)<$>b) else  b
    --print $ ((show a2) ++ " " ++ (show b2))

-- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine
getStringList    = words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















Measured memory_bytes: 508
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	if ((a + b) % 2 == 1) {
		cout << (a + b) / 2 + 1 << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}










	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
  int n;
  ll d;
  cin >> n >> d;
  ll x, y;
  int cnt = 0;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    if(d*d>=(x*x+y*y))  cnt++;
  }
  cout<< cnt;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define N (1<<17)

using namespace std;

int n, k, h[N], d[N];

int main(){

	cin >> n >> k;

	for(int i=0; i<n; i++) cin >> h[i];

	for(int i=1; i<n; i++){
		d[i] = 1e9;
		for(int j=1; j<=i && j<=k; j++) d[i] = min(d[i], d[i-j]+abs(h[i]-h[i-j]));
	}

	cout << d[n-1] << endl;

}


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

using namespace std;

int h[100001];
int val(int n)
{
//	if(n<=0)
//	return 0;
//	
//   if(n>2)
//   {
//   	return min(    val(n-2) +abs( h[n-1]-h[n-3]  ) ,val(n-1)+   abs( h[n-1]-h[n-2]  )          );
//   }
//	
//  else if(n==2)
//  return val(n-1)+   abs( h[n-1]-h[n-2]  );
//  
//  else
//  return 0;
	int dp[100001];
	
	dp[0]=0;
	dp[1]=0;
	dp[2]=abs(   h[1]-h[0]);
	
	int i,j,k;
	for(i=3;i<=n;i++)
	{
		dp[i]=min( dp[i-2]+abs(h[i-1]-h[i-3]) ,dp[i-1]+ abs(h[i-1]-h[i-2])   );
		
	//	cout<<dp[i]<<" ";
	}
	return dp[n];
	
	
}
int main()
{
	int t;
	t=1;
	while(t--)
	{
	 int n,i,j;
	 
	 cin>>n;
	 
	 for(i=0;i<n;i++)
	 cin>>h[i];
	
   cout<<val(n);
	
	}



}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CAverageLength {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n];
            int[] y = new int[n];

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            double avg = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    avg += Math.hypot(x[i] - x[j], y[i] - y[j]);
                }
            }
            avg /= Util.nc2(n);

            double answer = avg * (n - 1);

            out.println(Util.formatDouble(answer));
        }

    }

    static class Util {
        public static String formatDouble(double x) {
            return String.format("%.15f", x);
        }

        public static long nc2(long n) {
            return n * (n - 1) / 2;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22484
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int p[] =new int[n];


		int cnt=0;
		for(int i=0; i<n; i++) {
			p[i]=sc.nextInt();
			if(i>0 && p[i-1]>p[i]) {
				cnt++;
			}
		}
		if(cnt==0) {
			System.out.println("YES");
			sc.close();
			return;
		}
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				int tmp = p[j];
				p[j] = p[i];
				p[i] = tmp;
				cnt=0;
				for(int k=0; k<n; k++) {
					if(k>0 && p[k-1]>p[k]) {
						cnt++;
					}
				}
				if(cnt==0) {
					System.out.println("YES");
					sc.close();
					return;
				}
				tmp = p[j];
				p[j] = p[i];
				p[i] = tmp;
			}
		}
		System.out.println("NO");
		sc.close();
	}
}


Measured memory_bytes: 35448
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

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

    string S;
    cin >> S;

    string ans = "AC";

    if(S[0] != 'A') ans = "WA";
    if(!((S[1] >= 'a') && (S[1] <= 'z'))) ans = "WA";
    int C = -1;
    FOR(i, 2, S.length() - 1) {
        if(S[i] == 'C' && C == -1) {
            C = i;
        } else if(S[i] == 'C' && C != -1) {
            ans = "WA";
        }
    }
    if(C == -1) ans = "WA";

    FOR(i, 2, S.length()) {
        if(i != C && (!((S[i] >= 'a') && (S[i] <= 'z')))) ans = "WA";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
p = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    x,y = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)

group = [0]*(N+1)
ans = 0

for i,num in enumerate(p,1):
    exploration_space = [i]
    for exploration_point in exploration_space:
        if group[exploration_point]:
            continue
        group[exploration_point] = i
        exploration_space.extend(graph[exploration_point])
    ans += (group[num] == group[i])

print(ans)

Measured memory_bytes: 30324
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;

struct node{
	vector<int> out;
	int in=0;
	int id;
	bool vis = 0;
};
node A[401];
int w, x, y, z;
int h, n;
bool fail = 0;
void visit(int x){
	if (A[x].vis) return;
	A[x].vis = 1;
	for (auto y: A[x].out) visit(y);
}
int main() {
	cin>>n>>h;
	f(i, 401) A[i].id = i;
	f(i, n){
		cin>>w>>x>>y>>z;
		int a, b;
		if (y==0) a=200+w; else a = y;
		if (z==0) b=x; else b=200+z; 
		A[a].out.push_back(b);
		A[b].in++;
	}
	f(i, 200){
		if (A[i].out.size()>A[i].in) fail = 1;
		f(j, A[i].in-int(A[i].out.size())) A[i].out.push_back(200);
	}
	F(i, 200){
		if (A[i+200].out.size()<A[i+200].in) fail = 1;
		f(j, int(A[i+200].out.size())-A[i+200].in) A[200].out.push_back(i+200);
	}
	
	visit(200);
	f(i, 401) if (A[i].out.size()>0 && !A[i].vis) fail = 1;
	cout<<(fail? "NO" : "YES")<<endl;
	
	/*Printing edges, debug
	f(i, 401){
		for (auto x:A[i].out){
			cout<<i<<" "<<A[x].id<<endl;
		}
	}*/
}

Measured memory_bytes: 1408
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
const double pi=3.14159265358979323846;
void solve()
{
    double n;
    cin>>n;
    double an=2.0*pi*n;
    cout<<fixed<<setprecision(10)<<an;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //srand(time(0));
    //cin>>t;
    for(int _i=1;_i<=t;_i++){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3804
/*
 * atcoder/abc112/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
vector<ll> X, Y, H;

ll height(ll n, ll cx, ll cy) {
  return H[n] + abs(cx - X[n]) + abs(cy - Y[n]);
}

void solve() {
  cin >> N;
  ll x, y, h;
  loop(n,0,N) {
    cin >> x >> y >> h;
    if (h > 0) {
      X.push_back(x); Y.push_back(y); H.push_back(h);
    }
  }
  N = H.size();
  if (N == 1) {
    cout << X[0] << " " << Y[0] << " " << H[0] << endl;
    return;
  }

  loop(cx,0,101) {
    loop(cy,0,101) {
      bool isCenter = true;
      ll h = height(0, cx, cy);
      loop(n,1,N) {
        isCenter &= h == height(n, cx, cy);
      }
      if (isCenter and h > 0) {
        cout << cx << " " << cy << " " << h << endl;
        return;
      }
    }
  }
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 256
import math
def dist(x,y):
    dis=math.sqrt((x**2)+(y**2))
    return dis
n,d=map(int,input().split())
count=0
for _ in range(n):
    x,y=map(int,input().split())
    if dist(x,y)<=d:
        count+=1
print(count)


Measured memory_bytes: 9184
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int plen, cnum, width, cspace;
        cin >> plen >> cnum >> width >> cspace;
        if(plen == 0)
            return 0;
        cin.ignore();

        string s;
        int w = width * cnum + cspace * (cnum-1);
        for(;;){
            vector<string> ret(plen, string(w, '.'));
            bool ng = true;
            for(int x=0; x<w; x+=width+cspace){
                for(int y=0; y<plen; ++y){
                    if(s == "")
                        getline(cin, s);
                    if(s == "?")
                        break;
                    ng = false;
                    string s1;
                    if(s.size() <= width){
                        s1 = s;
                        s = "";
                    }else{
                        s1 = s.substr(0, width);
                        s = s.substr(width);
                    }

                    ret[y].replace(x, s1.size(), s1);
                }
            }

            if(!ng){
                for(int y=0; y<plen; ++y)
                    cout << ret[y] << endl;
                cout << '#' << endl;
            }
            if(s == "?"){
                cout << '?' << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,K,md;
int dp[310][310];
int C[310][310];
void Add(int &x,int y){
	(x+=y)%=md;
}
int main(){
	scanf("%d%d%d",&n,&K,&md);
	C[0][0]=C[1][0]=C[1][1]=1;
	for(int i=2;i<=n+1;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%md;
	}
	for(int i=0;i<=K;i++)
		dp[1][i]=1;
	int sum;
	for(int i=2;i<=n+1;i++){
		for(int j=1;j<i;j++){
			sum=0;
			for(int k=K;k>=0;k--){
				Add(dp[i][k],sum*(long long)(i-j==1?1:C[i-2][j-1])%md*dp[i-j][k]%md);
				Add(sum,dp[j][k]);
			}
		}
	}
	printf("%d\n",dp[n+1][0]);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main(){
    int c[4][3][10] = {0};
    int t;
    cin >> t;
    int z;
    int y;
    int x;
    int a;
    int i;
    for ( i = 0; i<t; i++ ) {
        cin >> z >> y >> x >> a;
        c[z-1][y-1][x-1]+=a;
    }
    for ( z = 0; z<4; z++ ) {
        for ( y = 0; y<3; y++ ) {
            for ( x = 0; x<10; x++ ) {
                cout << " " << c[z][y][x];
            }
            cout << endl;
        }
        if ( z<3 ) {
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
import math

A,B=map(int,input().split())

def func(n):
    num=1
    for i in range(2,int(math.sqrt(n) + 1e-9) +3):
        if n%i==0 and n!=i:
            num=0
            break
        else:
            continue
    return num

p=min(A,B)
q=max(A,B)

ans=0
check=[]
for i in range(1, int(math.sqrt(p)+ 1e-9)+3):
    if p%i==0:
        if i not in check:
            check.append(i)
        if p//i not in check:
            check.append(p//i)

for i in check:
    if q%i==0:
        ans+=func(i)

print(ans)

Measured memory_bytes: 3280
# N:人数, K:初期ポイント, Q:クイズ数
N, K, Q = map(int,input().split())

s = K-Q

points = [s] * N

for _ in range(Q):
    ans = int(input())
    points[ans-1] += 1

for p in points:
    print('Yes' if p>0 else 'No')

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

void solve() 
{
    double x;cin>>x;
    cout<<ceil((sqrt(8*x+1)-1)/2)<<endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll cnt[5] = {0};
    ll ans = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M'){
            cnt[0]++;
        }else if(s[0] == 'A'){
            cnt[1]++;
        }else if(s[0] == 'R'){
            cnt[2]++;
        }else if(s[0] == 'C'){
            cnt[3]++;
        }else if (s[0] == 'H'){
            cnt[4]++;
        }
    }
    for(int i = 0; i < 5; i++){
        for(int j = i+1 ;j < 5; j++){
            for(int k = j+1; k < 5; k++){
                ans += (cnt[i] * cnt[j] * cnt[k]);
            }
        }
    }
    cout << ans ;
}


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

int main(){
    int n;
    cin >> n;
    vector <pair<string, pair<int, int>>> s;
    pair<string, pair<int, int>> q;
    string w;
    int e;
    int r;
    for (int i = 0; i < n; i++){
        cin >> w >> e;
        q.first = w;
        q.second.first = 100 - e;
        q.second.second = i + 1;
        s.push_back(q);
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++){
        cout << s[i].second.second << endl;
    }
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		int ab = Integer.parseInt(a + b);
		int sqrt = (int)Math.floor(Math.sqrt(ab));
		System.out.println((sqrt * sqrt == ab)?"Yes":"No");
		
	}
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Reverse(a []int, b, e int) {
	for i := b; i < (e+b)/2; i++ {
		j:= e-i+b-1
		a[i], a[j] = a[j], a[i]
	}
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := NextInt(sc)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = NextInt(sc)
	}

	q, _ := NextInt(sc)
	for i := 0; i < q; i++ {
		b, _ := NextInt(sc)
		e, _ := NextInt(sc)
		Reverse(a, b, e)
	}

	fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
}



Measured memory_bytes: 1264
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Measured memory_bytes: 4596
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    
    let a = input[0].split(" ")[0];
    let b = input[0].split(" ")[1];
    
    console.log(a * b);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int K;
    std::cin >> K;
    int sum = 0;
    for (int a = 1; a <= K; a++)
    {
        for (int b = 1; b <= K; b++)
        {
            for (int c = 1; c <= K; c++)
            {
                sum += std::__gcd(std::__gcd(a, b), c);
            }
        }
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)(b);++i)
#define long long long
using pi = pair<int, long>;
const long inf = LLONG_MAX / 3;

void solve()
{
  int N,M,L;
  cin>>N>>M>>L;
  vector<vector<long>> D(N, vector<long>(N, inf));
  vector<vector<long>> dist(N, vector<long>(N, inf));
  rep(i,N) {
    dist[i][i] = 0;
  }
  rep(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    a--; b--;
    if(L<c)continue;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  rep(k,N)rep(i,N)rep(j,N){
    long sum = dist[i][k] + dist[k][j];
    if(sum > L)continue;
    dist[i][j] = min(dist[i][j], sum); 
  }
  rep(i,N)rep(j,N){
    if(dist[i][j]!=inf){
      D[i][j]=1;
    }
  }
  
  rep(k,N)rep(i,N)rep(j,N){
    D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
  }
  // i~j に進む時の(最小の給油回数,移動距離)
  
  
  int Q; cin>>Q;
  rep(i,Q){
    int s,t; cin>>s>>t;
    s--; t--;
    cout << (D[s][t]!=inf ? (D[s][t]-1) : -1) << "\n";
  }
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);
  solve();
  return 0; 
}


Measured memory_bytes: 2048
#! /usr/bin/env python3
def main():
    H, W = map(int, input().split())
    CH, CW = map(int, input().split())
    DH, DW = map(int, input().split())
    G = []
    for i in range(H):
        G += [[[0,1][x=='#']for x in input()]]

    dx = [0, 1, 0, -1]
    dy = [-1, 0, 1, 0]


    dy2 = []
    dx2 = []
    for y in range(-2,3):
        for x in range(-2,3):
            if abs(y)+abs(x) > 1:
                dy2 += [y]
                dx2 += [x]
    dl = len(dx2)

    q = [(CH-1, CW-1)]
    a = [(CH-1, CW-1)]
    f = True
    c = 0
    ans = -1
    while f:
        f = False
        while q:
            t = []
            for y, x in q:
                G[y][x] = 2
                for d in range(4):
                    px = x + dx[d]
                    py = y + dy[d]
                    if 0<=px<W and 0<=py<H and G[py][px] == 0:
                        G[py][px] = 2
                        t += [(py, px)]
                        a += [(py, px)]
            q = t
        b = []
        s = set()
        for y, x in a:
            for d in range(dl):
                px = x + dx2[d]
                py = y + dy2[d]
                if 0<=px<W and 0<=py<H and G[py][px] == 0 and (py,px) not in s:
                    s.add((py,px))
                    b += [(py, px)]
                    q += [(py, px)]
        # for i in G:
        #     print(i)
        # print()
        if G[DH-1][DW-1] == 2:
            ans = c
            break
        c += 1
        a = b
        if b : f = True
        
    print(ans)

main()

Measured memory_bytes: 105196
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  ll k,n;
  cin >> k >> n;
  vector<ll>A(n),v(n);
  rep(i,n)cin >> v[i];
  rep(i,n - 1)A[i] = v[i + 1] - v[i];
  A[n - 1] = abs(0 - v[0]) + (k - v[n - 1]);
  sort(all(A));
  reverse(all(A));
  ll ans = 0;
  REP(i,1,n)ans += A[i];
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


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

const int maxn = 1e5 + 5;
int a[maxn];
char s[maxn];

int main() {

    scanf("%s", s);
    int R = 0, L = 0, len1, len2;
    while(s[R]) {

        while(s[R] == 'R') R++;
        len1 = R - L; L = R+1;
        while(s[L] == 'L') L++;
        len2 = L - R;

        a[R] = a[R-1] = (len1+len2)/2;
        if((len1+len2)%2)
            if(len1 > len2 && len1%2 || len1 < len2 && !(len2%2)) a[R-1]++;
            else a[R]++;

        R = L;
    }
    for(int i = 0; s[i]; i++)
        printf("%d ", a[i]);
    return 0;
}

Measured memory_bytes: 896