akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int[] arr = new int[]{a, b, c};
            Arrays.sort(arr);
            String ans = "No";
            if (arr[2] == arr[0] + arr[1]) {
                ans = "Yes";
            }
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23252
text = gets.chomp

offset = 0
loop do
  a = text.index("apple", offset)
  b = text.index("peach", offset)

  if a && b
    if a < b
      offset = a + 1
      text[a,5] = "peach"
    else
      offset = b + 1
      text[b,5] = "apple"
    end
  elsif a
    text[a,5] = "peach"
    offset = a + 1
  elsif b
    text[b,5] = "apple"
    offset = b + 1
  else
    break
  end
end

puts text

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

int main(){
  long long int n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0) cout<<(b-a)/2<<endl;
  else{
    if(a>n-b)cout<<n-b+1+(b-a-1)/2<<endl;
    else cout<<a+(b-a-1)/2<<endl;

  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,i; cin >> n >> i;
    cout << n-i+1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i,a,t[256] = {0},h[256] = {0},x,th,hh,turn;
	int c;
	while(scanf("%d",&n) , n != 0){
		th = n;hh = n;
		for(i = 0;i <= 255;i++){t[i] = 0;h[i] = 0;}
		for(i = 1;i <= 2*n;i++){
			h[i] = 1;
		}
		for(i = 1;i <= n;i++){
			scanf("%d",&a);
			t[a] = 1;h[a] = 0;
		}
		turn = 0;
		x = 1;
		c = 0;
		while(1){
			for(i = x;i <= 256;i++){
				c++;
				if(turn == 0){
					if(t[i] == 1){t[i] = 0;x = i+1;turn = 1;th--;break;}
				}
				else{
					if(h[i] == 1){h[i] = 0;x = i+1;turn = 0;hh--;break;}
				}
				if(i >= 2 * n){
					x = 1;
					if(turn == 1){turn = 0;}
					else{turn = 1;}
					break;
				}
			}
			if(!(th && hh)){break;}
		}
		printf("%d\n%d\n",hh,th);
	}
	return 0;
}

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

void solve(long long N, long long X){
	long long A[N+1], P[N+1];
	A[0] = 1;
	P[0] = 1;
	for (int i = 1; i < N+1; i++) {
		A[i] = A[i-1]*2+3;
		P[i] = P[i-1]*2+1;
	}
	long long d = X;
	long long level = N;
	stack<long long> st1, st2;
	st1.push(A[level]);
	st2.push(P[level]);
	long long res = 0;
	while (d > 0) {
		if (d - st1.top() < 0) {
			level--;
			st1.pop();
			st2.pop();
			st1.push(1);
			st1.push(A[level]);
			st1.push(1);
			st1.push(A[level]);
			st1.push(1);
			st2.push(0);
			st2.push(P[level]);
			st2.push(1);
			st2.push(P[level]);
			st2.push(0);
		} else {
			d -= st1.top();
			res += st2.top();
			st1.pop();
			st2.pop();
		}
	}
	printf("%lld\n",res);
}

int main(){
	long long X;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&X);
	solve(N, X);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, 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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int k;
    cin >> k;
    int x = 0;
    rep(i, 1000001) {
        x = x * 10 + 7;
        x %= k;
        if (x % k == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    long long int n = 0;
    cin >> n;
    int tp = n /500;
    int fp = (n % 500)/5;

    long long ans = (tp * 1000) + (fp * 5);
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

ll cross(point a, point b) { return imag(conj(a) * b); }

int qua(point x)
{
	if (x.real() > 0 && x.imag() >= 0) return 0;
	if (x.real() <= 0 && x.imag() > 0) return 1;
	if (x.real() < 0 && x.imag() <= 0) return 2;
	return 3;
}

int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<point> v;
	for (int i = 0, x, y; i < n; ++i)
	{
		cin >> x >> y;
		point p = { x, y };
		if (x != 0 || y != 0) v.push_back(p);
	}

	ll ans = 0;
	sort(v.begin(), v.end(), [](const point &x, const point &y)
	{
		int qx = qua(x);
		int qy = qua(y);
		if (qx != qy) return qx < qy;
		return cross(x, y) > 0;
	});

	n = v.size();
	for (int i = 0; i < n; ++i)
	{
		point p = { 0, 0 };
		for (int j = i, k = n; k--; j = (j+1) % n)
		{
			p += v[j];
			ans = max(ans, norm(p));
		}
	}
	cout << setprecision(20) << fixed << sqrtl(ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin>>s;
  int slen;
  slen = s.size();
  vector<int> conti(slen+1,0);
  for(int i = 0; i < slen; i++) {
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') conti[i+1] = conti[i] + 1;
  }
  int smax;
  smax = 0;
  for (int i = 0;  i < slen + 1; i++) smax = max(smax,conti[i]);
  cout<<smax<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int ar[26]={0},d;
	int i,n;
	char c[1000];
	scanf("%s",c);
	for(i=0;c[i]!='\0';i++){
		d=c[i]-97;
		ar[d]++;
	}
	for(i=0;i<26;i++){
		if(ar[i]%2==1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	ll ans = (i-i%2)+(j-j%2)+(l-l%2);
	ll cnt = i%2 + j%2 + l%2;
	bool flag = ( i > 0 && j > 0 && l > 0 );
	if( flag && cnt == 2 ){
		ans += 1;
	} else if( flag && cnt == 3 ){
		ans += 3;
	}
	cout << ans+o << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-01 20:42:18
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  if (n & 1) {
    cout << n / 2 + 1 << endl;
  } else {
    cout << n / 2 << endl;
  }

  return 0;
}

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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {

        public void Calc()
        {
            var n = int.Parse(Console.ReadLine());
            var votes = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();

                if (votes.ContainsKey(s))
                {
                    votes[s] += 1;
                }
                else
                {
                    votes.Add(s, 1);
                }
            }

            var max = votes.Max(p => p.Value);
            var elected = votes.Where(p => p.Value == max).Select(p => p.Key).ToArray();
            Array.Sort(elected, StringComparer.Ordinal);
            foreach (var a in elected)
            {
                Console.WriteLine(a);
            }

            //var N = int.Parse(Console.ReadLine());
            //var Ss = new Dictionary<String, int>();
            //for (int i = 0; i < N; i++)
            //{
            //    var s = Console.ReadLine();
            //    if (Ss.ContainsKey(s))
            //    {
            //        Ss[s]++;
            //    }
            //    else
            //    {
            //        Ss.Add(s, 1);
            //    }
            //}

            //var max = Ss.Max(x => x.Value);

            //var ans = Ss.Where(x => x.Value == max).Select(x => x.Key).ToArray().OrderBy(x=>x);

            //foreach (var a in ans)
            //{
            //    Console.WriteLine(a);
            //}
        }
    }
}

Measured memory_bytes: 42844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a==5 && b==5 && c!=5)
        cout<<"YES"<<endl;
    else if (a==5 && b!=5 && c==5)
        cout<<"YES"<<endl;
    else if (a!=5 && b==5 && c==5)
        cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3552
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
using namespace std;

int a,b,c,d,e;

void solve(){
	cin >> a >> b >> c >> d >> e;
    if(a == 0)
        cout << 1 << endl;
    if(b == 0)
        cout << 2 << endl;
    if(c == 0)
        cout << 3 << endl;
    if(d == 0)
        cout << 4 << endl;
    if(e == 0)
        cout << 5 << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    cin >> N >> M;
    vector<ll> edges(N - 1);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a] += 1;
        if(b < edges.size()) edges[b] -= 1;
    }
    bool flag = true;
    iter(i, edges) {
        if(i % 2) flag = false;
    }
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 4056
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;



void Show(vector<bool>& Ps) {
	for (int i = 0; i < Ps.size(); i++) {
		if (Ps[i]) {
			cout << "T" << endl;
		} else {
			cout << "F" << endl;
		}
	}
}

void Show(vector<vector<int>>& Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			cout << Ns[i][j] << " ";
		}
		cout << endl;
	}
}


int main() {
	int N;
	cin >> N;
	cout << N / 3 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)

s = []
visit = [-1]*n
cnt = 0
for i in range(n):
    if visit[i] == -1:
        s.append(i)
        cnt += 1
        visit[i] = cnt
        while s:
            v = s.pop()
            for u in g[v]:
                if visit[u] == -1:
                    visit[u] = visit[v]
                    s.append(u)
print(max(visit))

Measured memory_bytes: 64304
N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand.append(min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)))

print(min(cand))

Measured memory_bytes: 3188
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
double average = 0, variance = 0;
int n = sc.nextInt();
if(n==0) {break;}
int[] scores = new int[n];
for(int i=0;i<scores.length;i++){
scores[i]=sc.nextInt();
average += scores[i];
}
average = average / scores.length;
for (int j=0;j<scores.length;j++){
variance += scores[j] * scores[j] - average * average;
}

System.out.println(Math.sqrt(variance/scores.length));
}
}
}


Measured memory_bytes: 31376
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  const t = +readLine();
  console.log(Number(!t));
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  cout<<(a.back()==b[0] && b.back()==c[0] ? "YES" : "NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    vector< vector<int> > a(n,vector<int>(3));
    REP(i,n){
	REP(j,3) cin >> a[i][j];
    }
    vector<int> ans(n,0);
    REP(i,3){
	REP(j,n){
	    bool flg = true;
	    REP(k,n){
		if(k == j) continue;
		else if(a[j][i] == a[k][i]) {
		    flg = false;
		    break;
		}
	    }
	    if(flg) {
		ans[j] += a[j][i];
	    }
	}
    }
    REP(i,n) cout << ans[i] << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n;
  vector<intll> v={0,0,0,0,0};
  
  rep(i,n){
    string s ;
    cin >> s ;
    if(s.at(0) == 'M') v.at(0)++;
    if(s.at(0) == 'A') v.at(1)++;
    if(s.at(0) == 'R') v.at(2)++;
    if(s.at(0) == 'C') v.at(3)++;
    if(s.at(0) == 'H') v.at(4)++;
  }
  
  intll ans = 0;
  
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++){
        ans += (v.at(i)*v.at(j)*v.at(k));
      }
    }
  }
  
  cout << ans ;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  long double A,B;
  cin >> A >> B;
  long double ans = A * B;
  ll lans = ans;
  cout << lans << endl;
  return 0;
}

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

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  double c=(double)(a+b)/2;
  int d=(a+b)/2;
  int t=(c-d)*10;
  if(t>4)
    d+=1;
  printf("%d",d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    double z[10][10];
    cin>>n;
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
        cin>>z[i][j];
      }
    }
    vector<int> order(n);
    for(int i=0;i<n;i++) order[i]=i;
    double sum=0;
    do{
      for(int i=1;i<n;i++){
        double x=(z[order[i-1]][0]-z[order[i]][0])*(z[order[i-1]][0]-z[order[i]][0]);
        double y=(z[order[i-1]][1]-z[order[i]][1])*(z[order[i-1]][1]-z[order[i]][1]);
        double q=sqrt(x+y);
        //cout<<x<<" "<<y<<" "<<q<<endl;
        sum+=q;
      }
    }while(next_permutation(order.begin(),order.end()));
    int a=1;
    for(int i=1;i<=n;++i) a*=i;
    cout<<fixed<<setprecision(10)<<sum/a;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

MAX_X = max(x)
MIN_Y = min(y)
for num in range(X + 1, Y + 1):
    if num > MAX_X and num <= MIN_Y:
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
#include <iostream>

int main()
{
  int n, a, b;
  std::cin >> n >> a >> b;
  std::string s="Borys";
  for(int i=1; i <100; i++)
  {
    ++a;
    if(a==b) break;
    --b;
    if(b==a) {
      s="Alice";
    }
  }
  std::cout << s << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std; 
#define MAXN 9999
vector<long long>luc(87,0);

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

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

int main() {
	deque<int> arr; 
	int t;
	int oper, choice, num;
	cin >> t;
	for(int i = 0; i < t; i++) {
		cin >> oper;
		if(oper == 0) {
			cin >> choice >> num;
			if(choice == 0) arr.push_front(num);
			else arr.push_back(num);
		}
		else if(oper == 1) {
			cin >> num;
			cout << arr[num] << endl; 
		}
		else {
			cin >> choice;
			if(choice == 0) arr.pop_front();
			else arr.pop_back();
		}
	} 
	return 0;
}


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,i,k,j;
  cin>>a>>b>>c;
  if(a==5&&b==5&&c==7||
     a==5&&b==7&&c==5||
     a==7&&b==5&&c==5)
       {

        cout<<"YES";
  }
  else
    {
    cout<<"NO";}


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int a,b;

int main(){
	cin >> a >> b;
	
	for(int i = b-a+1; i < b+a; i++){
		cout << i;
		if(i != b+a) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int[] h=new int[5];
		string ans="YES";
		for(int i = 0;i<3;i++) {
			int[] s=sc.Ia;
			h[s[0]]++;
			h[s[1]]++;
		}
		for(int i = 1;i<=4;i++) {
			if(h[i]>2){ans="NO";}
			
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

	if (x == 2)
	{
		printf("2");
		return 0;
	}

	vector<int> v = { 2 };

	for (int i = 3; ; i++)
	{
		bool flg = false;
		for (auto n : v)
		{
			if (i % n == 0)
			{
				flg = true;
				break;
			}
		}

		if (!flg)
		{
			v.push_back(i);
			if (i >= x)
				break;
		}
	}

	printf("%d", v[v.size() - 1]);

	return 0;
}

Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
  var n int
  var ac, wa, tle, re int
	fmt.Scanf("%d", &n)

	sc.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
    s := nextString()
    switch s {
      case "AC":
        ac++
      case "WA":
        wa++
      case "TLE":
        tle++
      case "RE":
        re++
    }
	}

	fmt.Printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}



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

using namespace std;

int main() {
  int n,m,a[100],b[100],c[100];
  cin >> n >> m;
  for(int i = 0; i < m; i++)
    cin >> a[i] >> b[i];
  
  for(int i = 1; i <= n; i++)
    c[i] = 0;

  for(int i = 1; i <= n; i++) {
    for(int j = 0; j < m; j++)
      if(i == a[j] || i == b[j]) c[i]++;
  
    cout << c[i] << endl;
  }
}

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

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

const int MAX_H = 30;
const int MAX_W = 30;
int iswall[2 * MAX_H][MAX_W];
const int INF = 1e9;

int solve(int w, int h) {
	// printf("k\n");
	int memo[MAX_H][MAX_W];
	const static int dy[] = {1, 0, -1, 0};
	const static int dx[] = {0, 1, 0, -1};
	for (int i = 0; i < MAX_H; ++i) for (int j = 0; j < MAX_W; ++j) memo[i][j] = INF;

	queue<pair<int, int> > que;
	memo[0][0] = 1;
	que.push(make_pair(0, 0));
	while(!que.empty()) {
		pair<int, int> tmp = que.front(); que.pop();
		int y = tmp.first, x = tmp.second;
		// printf("y %d x %d\n", y, x);
		for (int i = 0; i < 4; ++i) {
			int ny = y + dy[i], nx = x + dx[i];
			if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue; // ?????????
			if(memo[ny][nx] != INF) continue; // ?????§?????°???????????????
			// printf("ny %d nx %d\n", ny, nx);
			if(i % 2 == 0) { //????§????
				if(iswall[2 * min(y, ny) + 1][x]) continue;
			} else { //?¨??§????
				if(iswall[2 * y][min(x, nx)]) continue;
			}
			que.push(make_pair(ny, nx));
			memo[ny][nx] = memo[y][x] + 1;
		}
	}
	return memo[h - 1][w - 1] == INF ? 0 : memo[h - 1][w - 1];
}

int main(void) {
	while(1) {
		int w, h; scanf("%d %d", &w, &h);
		if(w == 0 && h == 0) break;

		for (int i = 0; i < 2 * h - 1; ++i) {
			for (int j = 0; j < w - (i % 2 ? 0 : 1); ++j) {
				scanf("%d", &iswall[i][j]);
			}
		}

		printf("%d\n", solve(w, h));
	}
	return 0;
}

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

w_row = ['.' for i in range(w)]
del_row_list = []
del_col_list = []

for i in range(h):
    if field[i] == w_row:
        del_row_list.append(i)

for j in range(w):
    count = 0
    for i in range(h):
        if field[i][j] == '.':
            count += 1
    if count == h:
        del_col_list.append(j)

for i in range(h):
    if i in del_row_list:
        continue
    for j in range(w):
        if j in del_col_list:
            continue
        print(field[i][j], end='')
    print('')


Measured memory_bytes: 9216
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


vbool made(1e8);

bool k;

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	int N, M;
	cin >> N >> M;

	vpint RL(M);
	for (int i = 0; i < M; i++)
	{
		int r, l;
		cin >> l >> r;
		RL[i].first = r-1;
		RL[i].second = l;
	}

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

	int last = RL[0].first;
	int ans = 1;

	for (int i = 1; i < M; i++)
	{
		if (RL[i].second <= last)
		{
			continue;
		}
		else
		{
			last = RL[i].first;
			ans++;
		}
	}

	cout << ans << endl;


}



Measured memory_bytes: 13312
#include <bits/stdc++.h>
#include <unordered_map>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, M;
ll res, DP[100000][60];
unordered_map<int, int>mp;

ll pw(ll x, ll y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a *= x;
			a %= mod;
		}
		x *= x;
		x %= mod;
		y >>= 1;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

ll comb(ll x, ll y) {
	ll a = 1, b = 1;
	for (int i = 1; i <= y; ++i) {
		a *= (x - i + 1);
		b *= i;
		a %= mod;
		b %= mod;
	}
	return a * modinv(b) % mod;
}

int main() {
	cin >> N >> M;
	res = 1;
	for (int i = 2; i <= M; ++i) {
		while (M%i == 0) {
			++mp[i];
			M /= i;
		}
	}
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		res *= comb(N - 1 + it->second, it->second);
		res %= mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long x=1,a[210000];
int n;
int main(void)
{
    cin>>n;
    int b=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==0)b=1;
    }
    if(b==1)
    {
        cout<<"0"<<endl;
        return 0;
    }
        for(int i=1;i<=n;i++)
        {
            if(a[i]<=1000000000000000000/x)x=x*a[i];
            else
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3952
#include <algorithm> // sortのため //
#include <iostream>
using namespace std;

int t, n, k, g, A[100000+10], B[100000+10], Ans;

int main(){
  cin >> t;
  for(int i=0; i<t; i++){
    cin >> n >> k;
    for(int j=0; j<n; j++){
      cin >> A[j]; // 家の位置を配列におく //
    }
    for(int k=0; k<n-1; k++){
      B[k] = A[k+1] - A[k]; // 家間の距離の大きい順を知りたいので座標の差をはいれつする //
    }
    sort(B, B+n-1);
    reverse(B, B+n-1); // 家間の距離を大きい順に配列し直す //
    Ans = A[n-1] - A[0];
    g=0;
    while(g<k-1 && Ans>0){ // 最大の距離からBの大きい順に引こうと思うが引いた合計が0になったらそのループをやめることにする //
      Ans -= B[g];
      g++;
    }
    cout << Ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3928
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
};

struct Node gNode[MAX];
int gDepth[MAX];

void print(int node){
  int i,left;
  printf("node %d: ",node);
  printf("parent = %d, ",gNode[node].parent);
  printf("depth = %d, ",gDepth[node]);
    
  if(gNode[node].parent == NIL){
    printf("root, ");
  }
  else if(gNode[node].left == NIL){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");
    
    for(i=0,left=gNode[node].left;left!=NIL;i++,left=gNode[left].right){
      if(i) {
	printf(", ");
      }
        printf("%d",left);
    }
    printf("]\n");
}

void rec(int node ,int parent){
    gDepth[node]=parent;
    if(gNode[node].right!=NIL){
        rec(gNode[node].right,parent);
    }
    if(gNode[node].left!=NIL){
        rec(gNode[node].left,parent+1);
    }
}

int main(){
  int nodeNum,nodeIndex,node,left,root,n,i,j;
    scanf("%d",&n);
    for(i = 0;i < n;++i){
        gNode[i].parent = gNode[i].left = gNode[i].right = NIL;
    }
    for(i = 0;i < n;++i){
      scanf("%d%d",&nodeIndex,&nodeNum);
        for(j=0;j<nodeNum;++j){
	  scanf("%d",&node);
            if(j == 0){
                gNode[nodeIndex].left = node;
            }
            else{
                gNode[left].right = node;
            }
            left = node;
            gNode[node].parent = nodeIndex;
        }
    }    
    for(i = 0;i < n;++i){
        if(gNode[i].parent == NIL){
            root = i;
        }
    }
    rec(root,0);
    for(i = 0;i < n;++i){
        print(i);
    }
    return 0;
}


Measured memory_bytes: 6464
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  int now=0;
  rep(i,n){
    now=a[now];
    if (now==1) {cout<<(i+1)<<endl; return 0;}

  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, (int) s.length() - 8) << endl;
  return 0;
}

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

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

int main() {
    int start,end;
    int N;
    int buf,num=0;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> start >> end;
        buf = end - start + 1;
        num += buf;
    }
    cout << num << endl;
}

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

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > miti(n, vector<int>(0));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        miti[a - 1].emplace_back(b - 1);
        miti[b - 1].emplace_back(a - 1);
    }

    queue<int> room;
    room.push(0);
    vector<int> sirusi(n, -1);
    vector<int> flag(n, -1);

    while (!room.empty()) {
        int r = room.front(); room.pop();
        for (int i : miti[r]) {
            if (flag[i] != -1) continue;

            flag[i] = 0;
            sirusi[i] = r;
            room.push(i);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if (i == 0) continue;
        cout << sirusi[i] + 1 << endl;
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

int main()
{
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	for (int i = K+1; i <= N; ++i)
	{
		ans += (i-K) * (N / i) + max(ll(0),(N%i)-(K-1));
		if (K == 0) ans--;
		//cout << (i-K) * (N / i) + max(ll(0),(N%i)-(K-1)) << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		int n = sc.nextInt();
		Deque dq = new Deque();

		for (int i=0; i<n; i++) {
			int mode = sc.nextInt();
			if (mode == 0) {
				if (sc.nextInt() == 0) {
					dq.addFirst(sc.nextInt());
				}
				else {
					dq.addLast(sc.nextInt());
				}
			}
			else if (mode == 1) {
				System.out.println(dq.ar[dq.head + sc.nextInt()]);
			}
			else if (mode == 2) {
				if (sc.nextInt() == 0) {
					dq.removeFirst();
				}
				else {
					dq.removeLast();
				}
			}
		}

	}
}



class Deque {
	int ar[];
	int head = 500000, tail = 499999;
	Deque() {
		ar = new int[1000000];
	}

	void addFirst(int n) {head--; ar[head] = n;}
	void addLast(int n) {tail++; ar[tail] = n;}
	void removeFirst() {head++;}
	void removeLast() {tail--;}
}


Measured memory_bytes: 298532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    int N;
    cin >> N;
    vint A(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> A[i];
        A[i] -= (i + 1);
        sum += A[i];
    }
    sort(all(A));
    ll b = A[N / 2], c = A[N / 2 + 1];
    ll sum1 = 0, sum2 = 0;
    rep(i, N)
    {
        sum1 += abs(A[i] - b);
        sum2 += abs(A[i] - c);
    }
    cout << min({sum1, sum2});
    return 0;
}

Measured memory_bytes: 1024
a, b, c, d = map(int, input().split())

import fractions
#import math
from functools import reduce
def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
  #return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

l = lcm_base(c, d)

i = b//c-(a-1)//c
j = b//d-(a-1)//d
k = b//l-(a-1)//l
#print(i, j, k)
ans = b-a+1-(i+j-k)
print(ans)


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ld res = 0;
    FOR(i,0,n){
      ld in;
      string s;
      cin>>in>>s;
      if(s == "BTC") in *= 380000;
      res += in;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
s = input()
sr = s[::-1]
words = [w[::-1] for w in ('dream','dreamer','erase','eraser')]

f = 0
while f == 0:  
  f = 1
  for w in words:
    if sr[0:len(w)] == w:
      sr = sr[len(w):]
      f = 0
  
if sr =='':
  print('YES')
else:
  print('NO')
  

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

int main(){
	string a;
	bool answer = false;
	cin >> a;
	for(int i = 0;i<(int)a.size();i++){
		if(a[i]=='7') {
			answer = true;
			break;
		}
	}
	answer ? printf("Yes\n") : printf("No\n");
	return 0;
}


Measured memory_bytes: 3628
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans1 = 0
    S1 = [0] * N
    S1[0] = A[0]
    if A[0] == 0:
        S1[0] = -1
        ans1 += 1
    for i in range(1, N):
        S1[i] = S1[i-1] + A[i]
        if S1[i]*S1[i-1] < 0:
            continue
        if S1[i-1] > 0:
            S1[i] = -1
            ans1 += abs((-1) - (S1[i-1]+A[i]))
        else:
            S1[i] = 1
            ans1 += abs(1 - (S1[i-1]+A[i]))
    S2 = [0] * N
    ans2 = 0
    if A[0] > 0:
        S2[0] = -1
        ans2 += abs((-1) - A[0])
    else:
        S2[0] = 1
        ans2 += abs(1 - A[0])
    for i in range(1, N):
        S2[i] = S2[i-1] + A[i]
        if S2[i]*S2[i-1] < 0:
            continue
        if S2[i-1] > 0:
            S2[i] = -1
            ans2 += abs((-1) - (S2[i-1]+A[i]))
        else:
            S2[i] = 1
            ans2 += abs(1 - (S2[i-1]+A[i]))

    print(min(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b;
  cin >> a >> b;
  vector<pair<int64_t,int64_t>> res;
  int64_t n=gcd(a,b);
  for(int64_t i=2;i*i<=n;i++){
    if(n%i!=0)continue;
    int64_t s=0;
    while(n%i==0){
      s++;
      n/=i;
    }
    res.push_back({a,s});
  }
  if(n!=1)res.push_back({n,1});
  cout << res.size()+1 << endl;
}
      
  

Measured memory_bytes: 3640
S = input()
n = len(S)
counter2n0=0
counter2n1=0
counter1n0=0
counter1n1=0
for i in range(n):
    if i%2 ==0:
        if S[i] == '0':
            counter2n0 +=1
        else:
            counter2n1 +=1
    if i%2 == 1:
        if S[i] == '0':
            counter1n0 +=1
        else:
            counter1n1 +=1
print(min(counter2n0+counter1n1,counter2n1+counter1n0))


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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int k = Integer.parseInt(s[1]);
    int[] arr = new int[n];
    //int sum = 0;
    String[] str = br.readLine().split(" ");
    for(int i=0;i<n;i++){
      arr[i] = Integer.parseInt(str[i]);
      //sum += arr[i];
    }
    boolean[] dp = new boolean[k+1];
    Arrays.fill(dp,false);
    for(int i=0;i<=k;i++){
      for(int j=0;j<n;j++){
        if(i-arr[j]<0)
          break;
        else if(dp[i-arr[j]]==false){
          dp[i] = true;
          break;
        }
      }
    }
         if(dp[k]==true)
    System.out.println("First");
  else
    System.out.println("Second");
    
    
 
  }
}


Measured memory_bytes: 33652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a[3005];
ll dp[3005][3005];
ll f(int i,int j)
{
  if(dp[i][j] != 0) return dp[i][j];
  if(i>j) return 0;
  dp[i][j] =  max(a[i] - f(i+1,j),a[j]-f(i,j-1));
  return dp[i][j];
}

int main() {
  int n;
  cin>>n;
  for(int i=0;i<3005;i++)
  {
    for(int j=0;j<3005;j++)
    {
      dp[i][j] = 0;
    }
  }
  for(int i=1;i<=n;i++) cin>>a[i];
  cout<<f(1,n)<<endl;
  return 0;
}

Measured memory_bytes: 74344