akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdint>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int64_t N; std::cin >> N;
  int64_t ans = N-1;
  for(int64_t i = 2; i*i <= N; ++i) if(N%i==0) {
    int64_t j = N/i;
    ans = std::min(ans, i+j-2);
  }
  fin(ans);
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int a[111111];
int b[111111],c[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n)cin>>a[i];
	int cap=0;
	rep(i,n){
		if(a[i]==0){
			cap=INF;
		}else if(a[i]>0){
			b[i]=min(cap,a[i]);
		}else{
			minch(cap,-a[i]);
		}
		if(cap>0)cap--;
	}
	cap=0;
	for(int i=n-1;i>=0;i--){
		if(a[i]==0){
			cap=INF;
		}else if(a[i]>0){
			c[i]=min(cap,a[i]);
		}else{
			minch(cap,-a[i]);
		}
		if(cap>0)cap--;
	}
	ll res=0;
	rep(i,n){
		res+=max(b[i],c[i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4348
#include<stdio.h>
#define N 1000
#define WHITE 0
#define BLACK 2
#define GRAY 1
typedef struct Node{
  int num;
  int A[N];
}node;

void push(int);
int pop();
void DFS();
void Visit(int);

int n,time,top=0,D[N],F[N],S[N],color[N];
node L[N];

int main(){

  int i,k,j,a;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&k);
    L[a].num=0;
    for(j=1;j<=k;j++){
      scanf("%d",&L[a].A[j]);
    }
  }
  
  DFS();

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,D[i+1],F[i+1]);
  }


  return 0;
}


void DFS(){

  int i;

  for(i=1;i<=n;i++)color[i]=WHITE;

  time=0;

  for(i=1;i<=n;i++){
    if(color[i]==WHITE) Visit(i);
  }

}

void Visit(int r){

  int u,v,num=0; 

  push(r);
  color[r]=GRAY;
  D[r]=++time;

  while(top!=0){
    u=S[top];
    v=L[u].A[++L[u].num];

    if(v > 0){
      if(color[v]==WHITE){
	push(v);
	color[v]=GRAY;
	D[v]=++time;
      }
    }
    else{
      pop();
      color[u]=BLACK;
      F[u]=++time;
    }
  }

}

void push(int u){

  top++;
  S[top]=u;

}

int pop(){

  top--;
  return S[top+1];

}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll f(ll a, ll b){
	if(a>b) swap(a, b);
	if(b%a==0) return (2*(b/a)-1)*a;
	else return 2*a*(b/a)+f(b%a, a);
}

int main(){
	ll n, x;
	cin >> n >> x;
	cout << n+f(x, n-x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	set<char>q;
	for(int i=0;i<3;i++)cin>>a,q.insert(a);
	if(q.size()==2)cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod=1e9+7;


ll Q,H,S,D,N;
int main(){
	cin>>Q>>H>>S>>D>>N;
	if(Q*4<S){
		S=Q*4;
	}
	if(H*2<S){
		S=H*2;
	}
	if(S*2<=D){
		p(N*S);
	}else{
		ll ans=0;
		if(N%2==1){
			ans+=S;
			N-=1;
		}
		ans+=N/2*D;
		p(ans);
	}

	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy" << endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	string s;
	cin >> s;
	int a = s[0]-'0';
	int b = s[1]-'0';
	int c = s[2]-'0';
	int d = s[3]-'0';
	if(a+b+c+d == 7)	cout << a <<"+" << b <<"+" << c <<"+"<< d <<"=7\n"; 
	else if(a+b+c-d == 7)	cout << a <<"+" << b <<"+" << c <<"-"<< d <<"=7\n"; 
	else if(a+b-c+d == 7)	cout << a <<"+" << b <<"-" << c <<"+"<< d <<"=7\n"; 
	else if(a+b-c-d == 7)	cout << a <<"+" << b <<"-" << c <<"-"<< d <<"=7\n"; 
	else if(a-b+c+d == 7)	cout << a <<"-" << b <<"+" << c <<"+"<< d <<"=7\n"; 
	else if(a-b+c-d == 7)	cout << a <<"-" << b <<"+" << c <<"-"<< d <<"=7\n"; 
	else if(a-b-c+d == 7)	cout << a <<"-" << b <<"-" << c <<"+"<< d <<"=7\n"; 
	else if(a-b-c-d == 7)	cout << a <<"-" << b <<"-" << c <<"-"<< d <<"=7\n"; 
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (long i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

long N;
map<string, long> m;

ll ans;

int main() {
  cin >> N;
  ans = 0;
  rep(i, N) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s] = m[s] + 1;
    if (m[s] > 1) {
      ans += (m[s] - 1);
    }
  }

  cout << ans << endl;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int[] leftGcd = new int[n];
        leftGcd[0] = a[0];
        for (int i = 1; i < n; i++)
        {
            leftGcd[i] = Gcd(a[i], leftGcd[i - 1]);
        }

        int[] rightGcd = new int[n];
        rightGcd[0] = a[n - 1];
        for (int i = 1; i < n; i++)
        {
            rightGcd[i] = Gcd(a[n - 1 - i], rightGcd[i - 1]);
        }

        int answer = 0;
        for (int i = 1; i < n - 1; i++)
        {
            int tmpAnswer = Gcd(leftGcd[i - 1], rightGcd[n - i - 2]);
            answer = Math.Max(answer, tmpAnswer);
        }
        answer = Math.Max(answer, leftGcd[n - 2]);
        answer = Math.Max(answer, rightGcd[n - 2]);

        Console.WriteLine(answer);
    }

    // 最大公約数
    private static int Gcd(int a, int b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            int r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 31068
n,m = map(int,input().split())
A = [0 for i in range(n)]
b = []
C = [0 for i in range(n)]
for i in range(n):
    A[i] = list(map(int,input().split()))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    for j in range(m):
        C[i] += A[i][j] * b[j]
for i in range(n):
    print(C[i])



Measured memory_bytes: 6024
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A[] = new int[N];
    for(int i=0;i<N;i++){
      A[i] = Integer.parseInt(sc.next());
    }
    int target = 1;
    boolean b = false;
    for(int i=0;i<N;i++){
      if(A[i] != target){
        if(A[i] > N){
          System.out.println(-1 );
        }
      }else{
        target++;
        b = true;
      }
    }
    if(b==true){
      System.out.print(N-target+1);
    }else{
      System.out.print(-1);
    }
    return;
  }
}



Measured memory_bytes: 51564
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  ll ans=0;
  ll x=n/500;
  ans+=x*1000;
  n%=500;
  pr(ans+(ll)(n/5)*5);
}

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


Measured memory_bytes: 256
n = gets.to_i
p_n = gets.chomp.split(" ").map(&:to_i)

min = p_n[0]

res = 0

n.times do |i|
  if p_n[i] <= min
    res += 1
  end

  if p_n[i] < min
    min = p_n[i]
  end
end

puts(res)

Measured memory_bytes: 16516
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef long double ld;
//const int MAX=;
//const long double INF=;


int main(){
	int N;
	cin>>N;
	set< P > st;
	rep(i,N){
		int a;
		cin>>a;
		st.insert(make_pair(a,i));
	}
	int ind=0;
	int dif=0;
	for(auto it=st.begin(); it!=st.end(); it++){
		P p=*it;
		if(p.second % 2 != ind%2)dif++;
		ind++;
	}
	cout<<dif/2<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    YORN (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]);
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

constexpr double pi = acos(-1.0);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  h += m / 60;
  cout << hypot(b * cos(h / 6 * pi) - a * cos(m / 30 * pi), b * sin(h / 6 * pi) - a * sin(m / 30 * pi)) << '\n';
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int C = 2 * (int)1e8;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int sz;
int A[N + N];

struct Point {
    int x, y;
    Point(){}
    Point(int _x, int _y){
        x = _x; y = _y;
    }
}pt[N + N], st, en;

vector < pii > foun;

int main(){
    st.x = in(); st.y = in();
    en.x = in(); en.y = in();
    int n = in();
    for(int i = 1; i <= n; i++){
        pt[i].x = in(); pt[i].y = in();
    }
    double ans = abs(st.x - en.x) + abs(st.y - en.y); ans *= 100.0;
    if(st.x > en.x){
        st.x = C - st.x;
        en.x = C - en.x;
        for(int i = 1; i <= n; i++){
            pt[i].x = C - pt[i].x;
        }
    }
    if(st.y > en.y){
        st.y = C - st.y;
        en.y = C - en.y;
        for(int i = 1; i <= n; i++){
            pt[i].y = C - pt[i].y;
        }
    }
    for(int i = 1; i <= n; i++){
        if(pt[i].x >= st.x && pt[i].x <= en.x){
            if(pt[i].y >= st.y && pt[i].y <= en.y){
                foun.pb(mp(pt[i].x, pt[i].y));
            }
        }
    }
    sort(foun.begin(), foun.end());
    for(int i = 0; i < foun.size(); i++){
        int p = lower_bound(A, A + sz, foun[i].se) - A;
        if(p == sz) sz++;
        A[p] = foun[i].se;
    }
    if(sz > 0) {
        ans = ans - sz * 20.0;
        ans = ans + pi * 5.0 * sz;
        if(sz == min(en.x - st.x + 1, en.y - st.y + 1)) ans += 5.0 * pi;
    }
    printf("%.10lf\n", ans);
}


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

using namespace std;

int main() {
        cin.sync_with_stdio(0);
      
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        while (true) {
                c -= b;
                if (c <= 0) {
                        cout << "Yes";
                        return 0;
                }
                a -= d;
                if (a <= 0) {
                        cout << "No";
                        return 0;
                }
        }

        return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int n;
  cin >> n;
  map<int,int> m;
  vector<ll> d;
  rep(i,n){
    int a;
    cin >> a;
    m[a]++;
    if(m[a]==2)d.push_back(a);
    if(m[a]==4)d.push_back(a);
  }
  ll ans = 0;
  if(d.size()>=2){
    sort(d.rbegin(),d.rend());
    ans = d[0]*d[1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
int main(){
	
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll>> v;
	ll x,y;
	mov(i,0,n){
		cin>>x>>y;
		v.push_back({x,y});
	}
	sort(v.begin(),v.end());
	ll sum = 0;
	mov(i,0,n){
		if(m >= v[i].second) {sum += v[i].first*(v[i].second); m -= v[i].second; continue;}
		if(m < v[i].second) {sum += m*v[i].first; m = 0; break;}
	}
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 2420
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dxl[] = {0, 0, 1, -1}, dxr[] = {0, 0, 1, -1};
int dyl[] = {1, -1, 0, 0}, dyr[] = {-1, 1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int rec[51][51][51][51];
int solve_testcase() {
    memset(rec, 0, sizeof(rec));
    int W, H; cin >> W >> H;
    if(W == 0 and H == 0) return 1;
    
    vector<string> bl(H), br(H);
    int lx = -1, ly = -1, rx = -1, ry = -1;
    int glx = -1, gly = -1, grx = -1, gry = -1;
    for(int i=0; i<H; i++) {
        cin >> bl[i] >> br[i];
        for(int j=0; j<W; j++) {
            if(bl[i][j] == 'L') lx = i, ly = j;
            if(br[i][j] == 'R') rx = i, ry = j;
            if(bl[i][j] == '%') glx = i, gly = j;
            if(br[i][j] == '%') grx = i, gry = j;
        }
    }

    queue< tuple<int, int, int, int> > que;
    rec[lx][ly][rx][ry] = true;
    que.emplace(lx, ly, rx, ry);
    while(que.size()) {
        int px, py, qx, qy; tie(px, py, qx, qy) = que.front(); que.pop();
        if(glx == px and gly == py) continue;
        if(grx == qx and gry == qy) continue;
        for(int k=0; k<4; k++) {
            int npx = px + dxl[k], npy = py + dyl[k];
            int nqx = qx + dxr[k], nqy = qy + dyr[k];

            if(npx < 0 or npx >= H or npy < 0 or npy >= W) npx = px, npy = py;
            if(nqx < 0 or nqx >= H or nqy < 0 or nqy >= W) nqx = qx, nqy = qy;
            if(bl[npx][npy] == '#') npx = px, npy = py;
            if(br[nqx][nqy] == '#') nqx = qx, nqy = qy;

            if(!rec[npx][npy][nqx][nqy]) {
                rec[npx][npy][nqx][nqy] = true;
                que.emplace(npx, npy, nqx, nqy);
            }
        }
    }

    cout << (rec[glx][gly][grx][gry] ? "Yes" : "No") << endl;
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 30352
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll X;cin>>X;
    ll ans=(X/500)*1000;
    X=X%500;
    ans+=(X/5)*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[][] t = new int[3][N+1];
        t[0][0] = 0;
        t[1][0] = 0;
        t[2][0] = 0;

        for(int i = 1; i <= N; i++){
            t[0][i] = sc.nextInt();
            t[1][i] = sc.nextInt();
            t[2][i] = sc.nextInt();
        }
        sc.close();

        for(int i = 1; i <= N; i++){
            if(t[0][i] - t[0][i-1] < Math.abs(t[1][i] - t[1][i-1]) +
                                    Math.abs(t[2][i] - t[2][i-1])){
                System.out.println("No");
                return;
            } else if((t[0][i] - t[0][i-1]) % 2 != (Math.abs(t[1][i] - t[1][i-1]) +
                                                    Math.abs(t[2][i] - t[2][i-1])) % 2){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 91400
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbers();
            var array = nums.OrderBy(x => x).Select(x => x.ToString()).ToArray();
            Console.WriteLine(string.Join(" ", array));
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbers()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 10380
A = ['HIT','HOMERUN','OUT']
n = int(input())
for i in range(n):
    r = []
    o = 3
    s = 0
    while o > 0:
        a = input()
        if a == A[0]:
            r = [1]+r
            if len(r) >= 4:
                S,r[3:] = r[3:],[]
                for i in S:
                    s += i
        elif a == A[1]:
            for i in r:
                s += i
            s += 1
            r = []
        else:
            o -= 1
    print (s)



Measured memory_bytes: 5596
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll two[65];
vector<int> seq;
int now;

int main()
{
	int tmp = 1;
	ll N;
	scanf("%lld", &N);
	for(int i=0; i<60; i++) two[i] = 1LL<<i;
	int top = 0;
	while(two[top+1]-1 <= N) top++;
	N -= (two[top]-1);
	for(int i=1; i<=top; i++) seq.push_back(i);
	for(int i=1; i<=top; i++) seq.push_back(i);
	now = top;
	for(int i=40; i>=1; i--)
	{
		while(N >= two[i-1])
		{
			now ++;
			seq.push_back(now);
			seq.insert(seq.begin()+i-1, now);
			N -= two[i-1];
		}
	}
	printf("%d\n", seq.size());
	for(auto it=seq.begin(); it!=seq.end(); it++) printf("%d ", *it);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

class Main {

  public static int popAsInt(Stack<String> stack) {
    return Integer.parseInt(stack.pop());
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String opsStr = s.nextLine();
    String[] ops = opsStr.split(" ");
    Stack<String> stack = new Stack<String>();
    for (String op : ops) {
      switch(op) {
        case "+":
          stack.push(Integer.toString(popAsInt(stack) + popAsInt(stack)));
          break;
        case "-":
          int second = popAsInt(stack);
          int first = popAsInt(stack);
          stack.push(Integer.toString(first - second));
          break;
        case "*":
          stack.push(Integer.toString(popAsInt(stack) * popAsInt(stack)));
          break;
        default:
          stack.push(op);
          break;
      }
    }
    System.out.println(stack.pop());
  }

}



Measured memory_bytes: 26164
import sys
import math
import itertools

def main():
  n,k = map(int, input().split())
  a = list(map(int,sys.stdin.readline().split()))

  now = 0
  times = 0
  visit =[[0],[-1 for _ in range(n)]]
  visit[1][0] = 0
  roop = 0
  roop_start = 0

  for _ in range(k):
    times += 1
    now = a[now] - 1

    if visit[1][now] != -1:
      roop_start = visit[1][now] #ループが始めった待ちの最初に訪れた時に何回ループしていたかをroop_startに代入
      roop = times - roop_start #何個の町でループしてるかをroopに代入
      break
    else:
      visit[0].append(now)
      visit[1][now] = len(visit[0]) - 1

  if roop > 0:
    k = (k - roop_start) % roop

  # print(roop_start)
  # print(roop)
  # print(k)
  # print(visit[0])
  print(visit[0][roop_start + k] + 1)

  # now = 0
  # for _ in range(roop_start):
  #   now = a[now] - 1

  # for _ in range(k):
  #   now = a[now] -1

  # print(now+1)


if __name__ == '__main__':
  main()

Measured memory_bytes: 104380
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return kai(n - 1)*n;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int n, m, a[100005], b[100005], cnt[100005],ans;
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(b, b + m);
	for (int i = 0; i < m; i++) {
		if (i == 0)cnt[0] = b[i];
		else cnt[i] = cnt[i - 1] + b[i];
	}
	for (int i = 0; i < n; i++) {
		int j = lower_bound(b, b + n, a[i]) - b;
		j--;
		ans += cnt[j];
		ans += a[i] * (m - j - 1);
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 5476
n = gets.to_i
numbers = gets.split.map(&:to_i)
ans = 0

(numbers.length-2).times do |i|
  first = numbers[i]
  second = numbers[i+1]
  third = numbers[i+2]
  ans += 1 if (first < second && second < third) || (first > second && second > third)
end

p ans

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	vector<char> abc = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

	int n;
	cin >> n;

	vs s(n);

	for (int i = 0; i < n; i++) {
		cin >> s[i];
		SORT(s[i]);
	}

	for (int i = 0; i < 26; i++) {
		int outCnt = 114514;
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < s[j].size(); k++) {
				if (abc[i] == s[j][k]) {
					cnt++;
				}
			}
			outCnt = min(outCnt, cnt);
			cnt = 0;
		}

		while (outCnt) {
			cout << abc[i];
			outCnt--;
		}
	}

	cout << endl;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int F[50];
	F[0]=F[1]=1;
	for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
	
	cout<<F[n]<<endl;
	
	return 0;
}



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

int main(){
  int x[1000], i = 0;
  char s[1000];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-1] = x[i-1] + x[i];
      i--;
    }
    else if ( s[0] == '-' ){
      x[i-1] = x[i-1] - x[i];
      i--;
    }
    else if ( s[0] == '*' ){
      x[i-1] = x[i-1] * x[i];
      i--;    
    }
    else {
      i++;
      x[i] = atoi(s);
    }
  }
  printf("%d\n", x[i]);
  return 0;
}

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

using namespace std;

using ll = long long;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll n = B - A + 1;
    n -= B / C - (A - 1) / C;
    n -= B / D - (A - 1) / D;
    ll lcd = C * D / gcd(C, D);
    n += B / lcd - (A - 1) / lcd;
    cout << n << endl;
    return 0;
}

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

int main() 
{
    string word;
    int m, h;
    while(true)
    {
        cin >> word;
        if (word == "-")
            break;
        
        cin >> m;
        for (int i = 0; i < m; i++) 
        {
            cin >> h;
            word += word.substr(0, h);
            word.erase(0, h);
        }
        cout << word << endl;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,ans;
vector<ll> s,t,u;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){cin>>a;s.push_back(a);}
    for(int i=0;i<n;i++){cin>>a;t.push_back(a);}
    for(int i=0;i<n;i++){cin>>a;u.push_back(a);}
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    sort(u.begin(),u.end());
    for(ll x:t){
        ans+=(lower_bound(s.begin(),s.end(),x)-s.begin())*(n-(upper_bound(u.begin(),u.end(),x)-u.begin()));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
using namespace std;
int n , maxn1 , maxn2 , p , x;
int main()
{
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i = i + 1)
	{
		scanf("%d",&x);
		if(x % 2)
		{
			p = 1;
		}
	}
	if(p)
		printf("first");
	else
		printf("second");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N 11116
#define mod 1000000007

int n,m,f[N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();m=read();f[1]=1;
	for (int i=2;i<=n;i++)
		for (int j=1;j<=i;j++)
			f[j]=(f[j-1]+f[j])%mod;
	for (int i=m+1;i<n;i++)
		f[m]=f[m]*2%mod;
	printf("%d\n",f[m]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b)*h/ 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main

{	
	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
		
		int N = fs.nextInt();
		System.out.println((N>=30)?"Yes":"No");
	}


}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	int [] arrayIn(int n) throws IOException
	{
		int  arr[] = new int[n];
		arr[0] = 0;
		for(int i=1; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	

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

using namespace std;

int main() {
  int d, t, s;
  scanf("%d%d%d", &d, &t, &s);
  if (d <= t*s) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 3680
n = int(input())
tmp = 0
ans = 0

for i in range(1,n+1):
    if i % 2 == 0:
        pass
    else:
        for j in range(1,i+1):
            if i % j == 0:
                tmp += 1

        if tmp == 8:
            ans += 1

        tmp = 0

print(ans)


Measured memory_bytes: 2940
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]

l1=[]
for i in a:
    if '#' in i:
        l1.append(i)
l2=[]
for i in zip(*l1):
    if '#' in i:
        l2.append(i)
l3=zip(*l2)
for i in l3:
    print(''.join(i))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll p[200010];
ll a[200010];
ll k[200010];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
        cin >> p[i];
        k[p[i]]=i;
        a[i]=1;
    }

    set<ll> s;
    rep(i,n){
        decltype(s)::iterator it = s.find(p[i]-1);
        if (it != s.end()) { // 見つかった
            a[i]=a[k[p[i]-1]]+1;
        }
        s.insert(p[i]);
    }

    /*
    rep(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
    */

    ll m=0;
    rep(i,n){
        m=max(a[i],m);
    }
    cout << n-m << endl;


}

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


Measured memory_bytes: 14336
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int R;
	cin >> R;
	cout << (double)R * 2 * 3.14159265358979;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a , const void *b){
	return *(int *) a - *(int *)b;
}
int main(void){
	int n,x;
	int sum = 0; 
	scanf("%d %d",&n,&x);
	int m[n];
	for(int i ; i < n; i++) {
		scanf("%d",&m[i]);
		sum += m[i];
	}
	qsort(m,n,sizeof(int),asc);
	printf("%d\n",n + (int)((x-sum)/m[0]));
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from collections import Counter
def main():
    N = int(input())
    S = [input() for i in range(N)]
    c = Counter(S)
    ans = []
    tmp = []
    tmp = c.most_common()
    cmax = c.most_common()[0][1]
    ans = [k for k , j in c.items() if j == cmax]
    ans.sort()
    print('\n'.join(ans))
if __name__ == '__main__':
    main()

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

using namespace std;

const int INF = 1e9;
int N;
int X[100];

int point(int p) {
    int ret = 0;
    for(int i = 0;i < N;i++) {
        ret += (X[i] - p) * (X[i] - p);
    }
    return ret;
}

int main() {
    int ans = INF;
    cin >> N;
    for(int i = 0;i < N;i++) {
        cin >> X[i];
    }
    for(int i = 1;i <= 100;i++) {
        ans = min(ans, point(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
static const LL INF = 1LL<<61LL;
typedef pair<int,int> PII;

int n,m;
int s[1010];
LL ans;
vector<LL> V;
int main(){
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        V.clear();
        FOR(i,1,n)cin>>s[i];
        rep(i,n+1)rep(j,i+1){
            if(s[i]+s[j]<=m)V.push_back(s[i]+s[j]);
        }
        sort(V.begin(),V.end());
        int s=0; LL e=V.size()-1;
        while(s<=e){
            if(V[s]+V[e]>m){
                while(1){
                    if(V[s]+V[e]<=m)break;
                    e--;
                }
            }
            ans=max(ans,V[s]+V[e]);
            s++;
        }
        cout<<ans<<endl;
        ans=0;
    }
}

Measured memory_bytes: 7312
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MN 205
#define INF 100000000
#define init(a) memset(a,0x0f,sizeof(a))
#define min(a,b) (a<b?a:b)
int N,M,R,de[1005],S[MN][MN],L[MN][MN],i,j,k,x,y,s;
int dp[1005][205];

int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		init(S);init(L);init(dp);
		for(i=0;i<N;i++)L[i][i]=S[i][i]=0;
		for(i=0;i<M;i++)
		{
			char t;
			scanf("%d%d%d %c",&x,&y,&s,&t);
			x--;y--;
			if(t=='L')L[x][y]=L[y][x]=s;
			else S[x][y]=S[y][x]=s;
		}
		for(scanf("%d",&R),i=0;i<R;de[i++]--)scanf("%d",&de[i]);
		for(k=0;k<N;k++)
			for(i=0;i<N;i++)
				for(j=0;j<N;j++)
				{
					S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
					L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
				}
		dp[0][de[0]]=0;
		for(k=0;k<R-1;k++)
			for(i=0;i<N;i++)
				for(j=0;j<N;j++)
				{
					dp[k+1][i] = min(dp[k+1][i],dp[k][j]+L[de[k]][j]+S[j][i]+L[i][de[k+1]]);
					if(i == j) dp[k+1][i] = min(dp[k+1][i], dp[k][j] + L[de[k]][de[k+1]]);
				}
		for(i=0,s=INF;i<N;i++)s=min(s,dp[R-1][i]);
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1744
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, l, i, sum = 0;
	int min;
	scanf("%d %d", &n, &l);

	//味の合計値と、おいしさの絶対値が最小になるときの値を求める
	min = abs(l);
	for (i = 1; i <= n; i++) {
		sum += l + i - 1;//味の合計

		if (min >= abs(l + i - 1)) {//おいしさの絶対値が最小になるときの値を求める
			min = abs(l + i - 1);
		}
	}
	
	if (sum < 0) {
		printf("%d\n", sum + min);
	}
	else {
		printf("%d\n", sum - min);
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

void initBIT(int *b){
  const int n=b[0];
  for(int i=1;i<=n;i++) b[i]=0;
}

void add(int *bit,int x,int v){
  const int n=bit[0];
  for(int i=x;i<=n;i+=i&-i) bit[i]+=v;
}

int sum(int *bit,int x){
  int res=0;
  for(int i=x;i>0;i-=i&-i) res+=bit[i];
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *b=(int *)calloc(n+1,sizeof(int));
  int *w=(int *)calloc(n+1,sizeof(int));
  int i,j;
  for(i=0;i<2*n;i++){
    char s[10];
    int k;
    scanf("%s%d",s,&k);
    if(s[0]=='B'){
      b[k]=i+1;
    } else {
      w[k]=i+1;
    }
  }
  int *dp=(int *)calloc(2*(n+1),sizeof(int));
  int *bit=(int *)calloc(2*n+1,sizeof(int));
  bit[0]=2*n;
  dp[0]=0;
  for(i=1;i<=n;i++){
    add(bit,w[i],1);
    dp[i]=dp[i-1]+(i-sum(bit,w[i]));
  }
  int now=0;
  for(i=1;i<=n;i++){
    initBIT(bit);
    int inv=0;
    for(j=1;j<=i;j++){
      add(bit,b[j],1);
      inv+=j-sum(bit,b[j]);
    }
    int next=now^(n+1);
    dp[next]=inv;
    for(j=1;j<=n;j++){
      add(bit,w[j],1);
      int p=dp[next+j-1]+(i+j-sum(bit,w[j]));
      int q=dp[now+j]+(i+j-sum(bit,b[i]));
      dp[next+j]=p<q?p:q;
    }
    now=next;
  }
  printf("%d\n",dp[now+n]);
  return;
}

int main(void){
  run();
  return 0;
}


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

int main() {
    int n[4];
    cin >> n[0] >> n[1] >> n[2] >> n[3];
    sort(n, n + 4);
    if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.min(a + b, Math.min(b + c, a + c)));
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	long long c[26];
	rep(i,26) c[i]=0;
	rep(i,n) {
		string s;cin>>s;
		c[s[0]-'A']++;
	}
	string s[10]={"MAR","MAC","MAH","MRC","MRH","MCH","ARC","ARH","ACH","RCH"};
	long long ans=0;
	rep(i,10) {
		long long tmp=1;
		rep(j,3) tmp*=c[s[i][j]-'A'];
		ans+=tmp;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
max_count = 0
for i in 1..(n-1) do
  x = s.slice(0, i)
  y = s.slice(i, n-i)
  xx = x.split("").sort.uniq
  yy = y.split("").sort.uniq
  count = 0
  for j in 0...i do
    if yy.include?(xx[j])
      count += 1
    end
  end
  max_count = count if max_count < count
end
puts max_count


Measured memory_bytes: 1916
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,len[105];
char w[105][15];
int main()
{
	register int i,j,k;
	scanf("%d",&n);
	for (i=1;i<=n;++i)
	{
		scanf("\n%s",w[i]);
		len[i]=strlen(w[i]);
	}
	for (i=1;i<n;++i)
	for (k=i+1;k<=n;++k)
	{
		int flag=0;
		if (len[i]==len[k])
		{
			for (j=0;j<len[i];++j)
			{
				if (w[i][j]!=w[k][j])
				{
					flag=1;
					break;
				}
			}
			if (!flag)
				return !printf("No");			
		}
	}
	for (i=2;i<=n;++i)
		if (w[i][0]!=w[i-1][len[i-1]-1])
			return !printf("No");
	return !printf("Yes");
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
count = 0

for i in range(n-1):
  if p[i] == i+1:
    count += 1
    p[i],p[i+1] = p[i+1],p[i]
    
if p[n-1] == n:
  count += 1

print(count)

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

int main(){
    double n,t,a;
    cin>>n>>t>>a;
    vector<double> h(n);
    rep(i,n)cin>>h[i];
    //t:気温
    //a:aに近い平均気温が欲しい
    //h:標高
    double ans=20021003;
    int num=0;
    rep(i,n){
        double save=t-h[i]*0.006;
        double ab = a - save;
        ab = abs(ab);
        if(ans>ab){
        ans = ab;
        num = i+1;
        }
    }
    cout<<num<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

minus = 0
for i in range(N):
    if A[i] < 0:
        minus += 1

absed = sorted([abs(a) for a in A])
if minus % 2 == 0:
    print(sum(absed))
else:
    print(sum(absed) - absed[0]*2)


Measured memory_bytes: 66208
#include <stdio.h>

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

    if (n == 1) {
        printf("%d\n", k);
        return 0;
    }
    if (k == 2) {
        printf("%d\n", k);
        return 0;
    }

    unsigned long long r = k;
    for (int i = 2; i <= n; i++) {
        r *= (k-1);
    }

    printf("%lld\n", r);

    return 0;
}

Measured memory_bytes: 128
day = input()
 
if day == "SUN":
  print(7)
elif day == "MON":
  print(6)
elif day == "TUE":
  print(5)
elif day == "WED":
  print(4)
elif day == "THU":
  print(3)
elif day == "FRI":
  print(2)
elif day == "SAT":
  print(1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int main() {

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

	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			if ((a[j] - a[i]) % (n - 1) == 0)
			{
				cout << a[i] << " " << a[j] << endl;
				return 0;
			}
		}
	}



}


Measured memory_bytes: 3156
#include<stdio.h>

int main(){
		long long a,b,c,ans=0;
		scanf("%lld%lld%lld",&a,&b,&c);
		while(a%2==0&&b%2==0&&c%2==0){
				if(a==b&&b==c){
						puts("-1");
						return 0;
				}
				ans++;
				long long tmp=a;
				long long tmp1=b;
				long long tmp2=c;
				a=tmp1/2+tmp2/2;
				b=tmp/2+tmp2/2;
				c=tmp/2+tmp1/2;
		}
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=1000009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int spf[M+7];
void sieve()
{
    spf[1]=1;
    f(i,1,M)spf[i]=i;
    for(int i=4;i<=M;i=i+2)
    {
        spf[i]=2;
    }
    for(int i=3;i*i<=M;i=i+2)
    {
        if(spf[i]==i)
        {
           for(int j=i*i;j<=M;j=j+i)
           {
               if(spf[j]==j)
               {
                   spf[j]=i;
               }
           }
        }
    }
}
void prime_factorization(int val,vector<int>&prime,vector<int>&power)
{
    while(val!=1)
    {
        int p=spf[val],cnt=0;
        prime.pb(p);
        while(val%p==0)val=val/p,cnt++;
        power.pb(cnt);
    }
}
map<int,int>yo;
 main()

{
    fast
    int n;
    sieve();
    cin>>n;
    int a[n+5];
    f(i,1,n)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        vector<int>prime,power;
        prime_factorization(a[i],prime,power);
        int sz=prime.size();
        for(int j=0;j<sz;j++)
        {
           int p=prime[j];
           int cnt=power[j];
           if(yo.count(p)==0)yo[p]=cnt;
           else yo[p]=max(yo[p],cnt);
        }
    }
    int lcm=1;
    for(auto x:yo)
    {
         int val=1;
         int cnt=x.si;
         //cout<<x.fi<<" # "<<x.si<<endl;
         while(cnt--)val=gun(val,x.fi);
         lcm=gun(lcm,val);
    }
    int ses=0;
    f(i,1,n)
    {
        int x=gun(lcm,bigmod(a[i],mod-2));
        ses=ad(ses,x);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 8832
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let x: f64 = line.parse().unwrap();
  let l = x / 3.0;
  let v = l * l * l;
  println!("{}", v);
}

Measured memory_bytes: 4352