akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

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

int main() {
	fast();
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << nl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n[2];
	while(cin>>n[0]>>n[1],n[0],n[1]){
		int num[2][101],sum[2]={};
		for(int i=0;i<2;i++){
			for(int j=0;j<n[i];j++){
				cin>>num[i][j];
				sum[i]+=num[i][j];
			}
		}
		int ans[2]={101,101};
		for(int i=0;i<n[0];i++){
			int now[2]={sum[0]-num[0][i],sum[1]+num[0][i]};
			for(int j=0;j<n[1];j++){
				if(now[0]+num[1][j]==now[1]-num[1][j]&&num[0][i]+num[1][j]<ans[0]+ans[1]){
					ans[0]=num[0][i];
					ans[1]=num[1][j];
				}
			}
		}
		if(ans[0]==101)cout<<-1<<endl;
		else cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( a >= 13 ) cout << b << endl;
	else if( a >= 6 && a <= 12 ) cout << b / 2 << endl;
	else cout << 0 << endl;
	
	return 0;
}


Measured memory_bytes: 256
S=gets.chomp
N=S.size
ans=0
0.upto(N-1) do |i|
    (i).upto(N-1) do |j|
    	if S[i..j].split("").all?{|e|e=="A" || e=="C" || e=="G" || e=="T"}
            jd=j-i+1
            ans=ans<jd ? jd : ans
        end
    end
end
puts ans

Measured memory_bytes: 1788
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define xam INT_MIN
#define nim INT_MAX
#define mp make_pair

using namespace std;
///check n=1;
///check corner case;
int main()
{
    ll n,i;
    cin>>n;
    set<ll> dj;
    for(i=0;i<n;i++){
        ll x;
        cin>>x;
        dj.insert(x);
    }
    if(dj.size()==n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

return 0;
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    struct P {
        int f, a, t, x, y;
    };
    istream& operator>>(istream& is, P& p) {
        return is >> p.f >> p.a >> p.t >> p.x >> p.y;
    }

    ll d2(int x, int y, int ax, int ay) {
        return (x - ax) * (x - ax) + (y - ay) * (y - ay);
    }

    int N;
    void solve() {
        cin >> N;
        P prev; cin >> prev;
        ll dist2[2] = {0};
        ll time[2] = {0};
        for (int q = 1; q < N; q++) {
            P cur; cin >> cur;
            int t = cur.t;
            if (prev.t == cur.t && prev.a != cur.a) {
                ll d = d2(cur.x, cur.y, prev.x, prev.y);
                if (d > dist2[t] || (d == dist2[t] && time[t] > cur.f - prev.f)) {
                    dist2[t] = d;
                    time[t] = cur.f - prev.f;
                }
            }
            prev = cur;
        }
        cout << fixed << setprecision(12);
        for (int t = 0; t < 2; t++) {
            if (dist2[t] == 0) {
                cout << -1 << " " << -1 << endl;
            } else {
                cout << sqrtl(real(dist2[t])) << " " << real(time[t]) / 60.0 << endl;
            }
        }
    }
}

int main() {
    solve();
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    ll N, M;
    cin >> N >> M;
    UnionFindSize uf(N);
    REP(i, M){
    	ll X, Y, Z;
    	cin >> X >> Y >> Z;
    	X--;Y--;
    	uf.merge(X, Y);
    }
    set<ll> st;
    REP(i, N){
    	st.insert(uf.root(i));
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

ll lcm(ll a, ll b){
	return a*b/__gcd(a, b); 
}
int32_t main(){
	ios::sync_with_stdio(0);
	int n; ll m;
	cin >> n >> m;
	vector<ll> vs(n);
	for(auto &x:vs) cin >> x;
	ll lm = vs[0];
	for(auto x:vs) lm = lcm(lm, x);
	ll ans = 0 ;
	for(auto x:vs){
		if(((lm/2)-x/2)%x!=0){
			cout << 0 << endl;
			return 0;
		}
	}
	ans = (m-(lm/2)+lm)/lm;
	cout << ans << endl;
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> x(N, 0);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) x[0] += A[i];
    for(int i = 1; i < N; i += 2) x[0] -= 2 * A[i];
    x[0] /= 2;
    for(int i = 1; i < N; i++) x[i] = A[i - 1] - x[i - 1];
    for(int i = 0; i < N; i++){
        cout << 2 * x[i];
        if(i < N - 1) cout << " ";
        else cout << endl;
    }
    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


class UnionFind{
    public:
        UnionFind(int N) : parent(N), rank(N){
            for(int i = 0; i < N; i++){
                parent[i] = i;
                rank[i] = 1;
            }
        }

        int find(int n){
            if(parent[n] == n){
                return n;
            }
            return parent[n] = find(parent[n]);
        }

        void merge(int m, int n){
            int root_x = find(m);
            int root_y = find(n);
            if(root_x == root_y){
                return;
            }
            if(rank[root_x] < rank[root_y]){
                parent[root_x] = root_y;
            }else if(rank[root_x] > rank[root_y]){
                parent[root_y] = root_x;
            }else{
                parent[root_y] = root_x;
                rank[root_x]++;
            }
        }

        bool equivalent(int x, int y){
            return find(x) == find(y);
        }

    private:
        vector<int> parent;
        vector<int> rank;

};

int N, M, K;
int A[100000], B[100000], G[100000];
vector<int> fri[100000];
vector<int> block[100000];

signed main(){
    cin >> N >> M >> K;
    REP(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        fri[A[i]].push_back(B[i]);
        fri[B[i]].push_back(A[i]);
    }
    int c, d;
    REP(i, K){
        cin >> c >> d;
        c--; d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    UnionFind uf(N);
    REP(i, M){
        uf.merge(A[i], B[i]);
    }
    REP(i, N) G[i] = 0;
    REP(i, N){
        G[uf.find(i)]++;
    }
    int fnd = 0;
    REP(i, N){
        fnd = G[uf.find(i)] - 1;
        for(int j : fri[i]){
            if(uf.equivalent(i, j)) fnd--;
        }
        for(int j : block[i]){
            if(uf.equivalent(i, j)) fnd--;
        }
        cout << fnd;
        if(i < N - 1) cout << " ";
        else cout << endl;
    }
    return 0;


}

Measured memory_bytes: 13816
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> v(n);
    map<int, pair<int, int>> ans;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        pair<int, int> p;
        p.first = y;
        p.second = i;
        v[x - 1].push_back(p);
    }
    for(int i = 0; i < n; i++){
        sort(v[i].begin(), v[i].end());
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < v[i].size(); j++){
            pair<int, int> a;
            a.first = i + 1;
            a.second = j + 1;
            ans[v[i][j].second] = a;
        }
    }
    
    for(int i = 0; i < m; i++){
        int x = ans[i].first;
        int y = ans[i].second;
        cout << setfill('0') << right << setw(6) << x;
        cout << setfill('0') << right << setw(6) << y << "\n";
    }
    
}


Measured memory_bytes: 13184
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

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

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

fun solve() {
    val n = readInteger()
    val aArray = IntArray(n) {
        readInteger() - 1
    }

    val searched = BooleanArray(n)
    var cur = 0
    var ans = 0
    while (true) {
        searched[cur] = true
        cur = aArray[cur]
        ans++

        if (searched[cur]) {
            out.println(-1)
            return
        }

        if (cur == 1) {
            out.println(ans)
            return
        }
    }
}


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


Measured memory_bytes: 43008
r,g,b,n=map(int,input().split())
ct=0
for i1 in range((n//r)+1):
  for i2 in range((n//g)+1):
    if (n-r*i1-g*i2)%b==0 and n-r*i1-g*i2>=0:
      ct+=1
print(ct)

Measured memory_bytes: 40940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1024);
		int number = Integer.parseInt(br.readLine());
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18364
local mfl = math.floor
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local curbits = {}
for i = 1, 20 do curbits[i] = 0 end

local function add(idx)
  local v = a[idx]
  for i = 1, 20 do
    curbits[i] = curbits[i] + v % 2
    v = mfl(v / 2)
  end
end

local function rm(idx)
  local v = a[idx]
  for i = 1, 20 do
    curbits[i] = curbits[i] - v % 2
    v = mfl(v / 2)
  end
end

local function check()
  for i = 1, 20 do if 1 < curbits[i] then return false end end
  return true
end

local left, right = 1, 1
local ret = 0
while right <= n do
  add(right)
  if check() then
    ret = ret + right + 1 - left
  else
    while left < right do
      rm(left)
      left = left + 1
      if check() then
        ret = ret + right + 1 - left
        break
      end
    end
  end
  right = right + 1
end
print(ret)


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

ll N,K;
const ll mm = 998244353;
int main() {

    cin >> N >> K;
    
    vector<pair<ll,ll>> tile(K);
    for(ll i=0;i<K;i++)cin >> tile[i].first >> tile[i].second;
    vector<ll> Msum(N+1,0);
    Msum[1]=1;
    for(ll i=2;i<=N;i++){
        
        for(ll j=0;j<K;j++){
            
            ll s1=i-tile[j].first;
            ll s2=i-tile[j].second;
            if(s1<=0 && s2<=0)continue;
            if(s2<=0&&s1>0)s2=1;
            Msum[i]+=Msum[s1]-Msum[s2-1];
            if(Msum[i]<0)Msum[i]+=mm;
            Msum[i]%=mm;
        }
        Msum[i]+=Msum[i-1];
        Msum[i]%=mm;
    }
    
    cout << (Msum[N]-Msum[N-1] + mm)%mm << endl;
    
}



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

using namespace std;

int main()
{
    string ans[10] = {"pon", "pon", "hon", "bon","hon","hon","pon","hon","pon","hon"};
    int n;
    cin >> n;
    n %= 10;
    cout << ans[n] << endl;
    return 0;
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N;
    cin >> N;
    ll a = 1;
    while ( a*(a+1)/2 < N ) a++;
    ll b = a*(a+1)/2 - N;
    for ( int i = 1; i <= a; i++ ) {
        if ( i != b ) {
            cout << i << "\n";
        }
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int r[200000];
  int i, n, max, min;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d", &r[i]);
  }
  
  max = -1000000000;
  min = r[0];
  
  for (i = 1; i < n; i++) {
    if(max < r[i] - min) {
      max = r[i] - min;
    }
    if(min > r[i]) {
      min = r[i];
    }
  }
  printf("%d\n", max);
  
  return 0;
}

Measured memory_bytes: 1376
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    int a,b,c;

    cin >> a >> b >> c;

    if(a < b)swap(a,b);
    if(a < c)swap(a,c);

    cout << b + c;

    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{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int d = 0;
		int sum = 0;

		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		for(d = a; d <= b; d++){
			if(c % d == 0){
				sum++;
			}
		}
		System.out.println(sum);
	}
}



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

ll Pow(ll x, ll n){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod, n/2);
  else return x * Pow(x,n-1) % mod;
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> p(k+1,0);
  for(ll i = k; i >= 1; i--) {
    p[i] += Pow(k/i,n);
    for(int j = 2*i; j <= k; j += i) {
      (p[i] -= p[j]) %= mod;
    }
  }
  ll ans = 0;
  for(ll i = 1; i <= k; i++) (ans += i * p[i]) %= mod;
  cout << (ans + mod) % mod << endl; 
  return 0;
}


Measured memory_bytes: 4048
#include <cstring>

#include <iostream>
#include <algorithm>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

const int INF = (int)1e9;

int coin[20];
int memo[20][50001];
int solve(int k, int m) {
  if(m == 0) return 0;
  if(k == -1) return INF;
  int &res = memo[k][m];
  if(res != -1) return res;
  res = INF;
  if(coin[k] <= m) res = min(res, 1 + solve(k, m - coin[k]));
  res = min(res, solve(k - 1, m));

  // cerr << "k = " << k << ", m = " << m << ", res = " << res << endl;

  return res;
}
int main() {
  int N, M; cin >> N >> M;
  for(int i = 0; i < M; ++i) cin >> coin[i];
  memset(memo, -1, sizeof(memo));
  cout << solve(M - 1, N) << endl;
}

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

double minkowski(vector<int> &x, vector<int> &y, int p) {
  double ans = 0;
  if (p == 1) {
    for (int i = 0; i < x.size(); i++) {
      ans += fabs(x.at(i) - y.at(i));
    }
    return ans;
  } else if (p == 2) {
    for (int i = 0; i < x.size(); i++) {
      ans += fabs(x.at(i) - y.at(i)) * fabs(x.at(i) - y.at(i));
    }
    ans = sqrt(ans);
  } else if (p == 3) {
    for (int i = 0; i < x.size(); i++) {
      ans += fabs(x.at(i) - y.at(i)) * fabs(x.at(i) - y.at(i)) *
             fabs(x.at(i) - y.at(i));
    }
    ans = cbrt(ans);
  } else if (p == 4) {
    for (int i = 0; i < x.size(); i++) {
      ans = max(ans, fabs(x.at(i) - y.at(i)));
    }
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> y.at(i);
  }
  cout << fixed << setprecision(8) << minkowski(x, y, 1) << endl;
  cout << fixed << setprecision(8) << minkowski(x, y, 2) << endl;
  cout << fixed << setprecision(8) << minkowski(x, y, 3) << endl;
  cout << fixed << setprecision(8) << minkowski(x, y, 4) << endl;
}


Measured memory_bytes: 3460
N = int(input())
W = [input() for i in range(N)]
#print(W)
cnt = 0
if len(set(W)) != N:
    print("No")
    exit()

else:
    for i in range(N - 1):
        if  W[i][len(W[i]) - 1] == W[i + 1][0]:
            cnt += 1
            
if cnt == N - 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
int a[3]={-1,0,1};
signed main(){
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  map<int,int> mp;
  rep(i,n){
    rep(j,3)mp[v[i]+a[j]]++;
  }
  int ans=-1;
  for(auto x:mp){
    ans=max(ans,x.second);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<char, char> P;


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

    vector<int> cards(n);
    rep(i, n)cin >> cards[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(50 * n + 1, -1)); // dp[i枚で][にする方法は] = 通り
    dp[0][0] = 1;

    auto set = [&](int i, int j, ll v) {
        assert(i <= n);
        if (j > 50 * n) return;
        if (dp[i][j] == -1) {
            dp[i][j] = v;
        } else {
            dp[i][j] += v;
        }
    };

    rep(i, n) {
        for (int j = n - 1; j >= 0; j--) {
            rep(k, 50 * n + 1) {
                if (dp[j][k] == -1) continue;
                set(j + 1, k + cards[i], dp[j][k]);
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (dp[i][a * i] == -1)continue;
        ans += dp[i][a * i];
    }
    cout << ans << endl;

}



Measured memory_bytes: 1280
#pragma GCC optimize(3)
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
long long a[10000010];
int main(){
	//fixed<<setprecision(3)
	long long n;
	cin>>n;
	long long cnt=0;
	for(long long i=1;i<=n;i++){
		for(long long j=i;j<=n;j+=i){
			a[j]++;
		}
		cnt+=i*a[i];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 81720
a = input()
b = input()

a = ["".join(sorted(a)),"".join(sorted(a,reverse=True))]
b = ["".join(sorted(b)),"".join(sorted(b,reverse=True))]

ans = "No"
for aa in a:
    for bb in b:
        if aa < bb:
            ans = "Yes"
            break
print(ans)

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

using namespace std;

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

const int INF = 1e9 + 1;

int main()
{
  int N;
  scanf("%d", &N);
  vector< double > t(N);
  vector< double > v(N);
  REP(i, N) {
    scanf("%lf", &t[i]);
  }
  REP(i, N) {
    scanf("%lf", &v[i]);
  }

  // 全体のT秒を求める
  int T = 0;
  REP(i, N) {
    T += t[i];
  }
  
  vector< double > maxV(2 * T + 1, (double)INF);

  // maxのスピードをv[i]で初期化
  int nowT = 0;
  REP(i, N) {
    REP(ti, t[i]) {
      int t1 = nowT + ti * 2;
      int t2 = nowT + ti * 2 + 1;
      maxV[t1] = min(maxV[t1], v[i]);
      maxV[t2] = min(maxV[t2], v[i]);
    }
    nowT += t[i] * 2;
    maxV[nowT] = min(maxV[nowT], v[i]);
  }

  // 0秒とT秒は0(静止)
  maxV[0] = maxV[T * 2] = 0.0;
  
  // 前から比較
  REP(ti, 2 * T + 1) {
    maxV[ti + 1] = min(maxV[ti + 1], maxV[ti] + 0.5);
  } 
  
  // 後ろから比較
  RREP(ti, 2 * T + 1) {
    maxV[ti] = min(maxV[ti], maxV[ti + 1] + 0.5);
  }
  
  double ans = 0.0;
  REP(i, 2 * T + 1) {
    // (上底 + 下底) * 高さ / 2
    ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2.0;
  }

  printf("%.4f\n", ans);

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  if(a>b)ans+=b;
  else ans+=a;
  if(c>d)ans+=d;
  else ans+=c;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K, sum=0;
  cin >> A >> B >> C >> K;
  for(A; A>0; A--){
    sum++;
    K--;
    if(K<=0){
    	break;
    }
  }
  
  if(K>0){
    for(B; B>0; B--){
      K--;
      if(K<=0){
          break;
      }
    }
  }
  
  if(K>0){
    for(C; C>0; C--){
      sum--;
      K--;
      if(K<=0){
          break;
      }
    }
  }
  
  
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3636
import java.util.*;

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 q = Integer.parseInt(sc.next());
        int[] m = new int[q];
        for (int i = 0; i < q; i++) {
            m[i] = Integer.parseInt(sc.next());
        }

        int[] num = new int[1 << n];

        for (int i = 0; i < (1 << n); i++) {
            int s = 0;
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    s += a[j];
                }
            }
            num[i] = s;
        }
        Arrays.sort(num);

        for (int i = 0; i < q; i++) {
            boolean fl = false;
            for (int j = 0; j < (1 << n); j++) {
                if (m[i] == num[j]) {
                    fl = true;
                } else if (m[i] < num[j]) {
                    break;
                }
            }
            System.out.println(fl ? "yes" : "no");
        }

        sc.close();
    }
}


Measured memory_bytes: 34684
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const int qq = 5e5 + 10;
int num[qq];

int main(){
	int n;	scanf("%d", &n);
	int c = 0;
	for(int i = 0; i < n; ++i){
		scanf("%d", num + i);
		if(num[i] % 2 == 1)
			c++;
	}
	if(c % 2 == 0)	puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
#include<cmath>
#include<string>
#include<stdio.h>
int main()
{
  int a,b,c,d,i,sum;
	while(scanf("%d",&a)!=EOF)
	{
		sum=1;
		cin>>b;
		for(i=0;i<a;i++)
		{
			c=2*sum;
			d=sum+b;
			if(c>d)
				sum=d;
			else
				sum=c;
			continue;
		}
		cout<<sum;
	}
}


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

const int MAXN = 200005;
char str[MAXN];
int T[26];

int main()
{
	scanf("%s", str);
	for (char *p = str; *p != '\0'; p++)
		T[*p-'a']++;
	int n = strlen(str);
	long long ans = (long long)n*(n-1)/2+1;
	for (int i = 0; i < 26; i++)
		ans -= (long long)T[i]*(T[i]-1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [0] * m
ans = []
a.sort()
for i in range(m):
    bc[i] = list(map(int, input().split()))
bc.sort(key=lambda x: x[1], reverse=True)


j = 0
for i in range(n):
    if j < m:
        if bc[j][0] == 0:
            j += 1
    if j >= m:
        ans.append(a[i])
    elif a[i] >= bc[j][1]:
        ans.append(a[i])
    else:
        ans.append(bc[j][1])
        bc[j][0] -= 1

print(sum(ans))


Measured memory_bytes: 34532
#include<stdio.h>

int main(void){
  char str[21];
  char copy[21];
  int i = 0;
  int j = 0;

  scanf("%s",str);
  
  while( str[i] != '\0'){
    i++;
  }

  while(i>=0){
    copy[j] = str[i];
    j++;
    i--;
  }

  for(i=0;i<j-1;i++){
    printf("%c",copy[i+1]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 520
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int D = Integer.parseInt(in.next());
            int[] c = new int[26];
            for (int i = 0; i < 26; i++) {
                c[i] = Integer.parseInt(in.next());
            }
            int[][] s = new int[D][26];
            for (int i = 0; i < D; i++) {
                for (int j = 0; j < 26; j++) {
                    s[i][j] = Integer.parseInt(in.next());
                }
            }
            int[] t = new int[D];
            for (int i = 0; i < D; i++) {
                t[i] = Integer.parseInt(in.next());
            }
            long satisfaction = 0;
            long[] last = new long[26];
            for (int i = 0; i < D; i++) {
                int j = t[i] - 1;
                last[j] = (long) i + 1;
                for (int k = 0; k < 26; k++) {
                    satisfaction -= (i + 1 - last[k]) * c[k];
                }
                satisfaction += (long) s[i][j];
                out.println(satisfaction);
            }

//        out.println(Math.max(0, 1000000 + satisfaction));

        }

    }
}



Measured memory_bytes: 42120
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int A,B,C,X,Y,ab,a,b,mp=INF;
  cin >> A >> B >> C >> X >> Y;
  for(int i=0;i<=2*max(X,Y)+1;i+=2){
    ab = i;
    a = max(X - (i/2),0);
    b = max(Y - (i/2),0);
    mp = min(mp,ab*C+a*A+b*B);
  }
  cout << mp << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
/*
https://atcoder.jp/contests/abc124/tasks/abc124_a
*/
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (abs(a - b) <= a && a > b) {
    printf("%d\n", a + (a - 1));
  } else if (abs(a - b) <= b && b > a) {
    printf("%d\n", b + (b - 1));
  } else {
    printf("%d\n", a + b);
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5,mod=1e9+7;
typedef ll fuko[yuzu|10];
fuko cnt,jic={1},inv;

ll kasumi(ll a,ll b=mod-2){
ll s=1;
for (;b;b>>=1,a=a*a%mod) if (b&1) s=s*a%mod;
return s;
}

ll zuhe(int n,int m){
return jic[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
int j,n=read(),m=read(),i;
for (i=1;i<=yuzu;++i) jic[i]=jic[i-1]*i%mod;
inv[yuzu]=kasumi(jic[yuzu]);
for (i=yuzu-1;~i;--i) inv[i]=inv[i+1]*(i+1)%mod;
for (i=2;i*i<=m;++i) 
  if (m%i==0) for (++*cnt;m%i==0;cnt[*cnt]++) m/=i;
if (m>1) cnt[++*cnt]++;
ll ans=1;
for (i=1;i<=*cnt;++i) ans=ans*zuhe(cnt[i]+n-1,cnt[i])%mod;
write(ans);
}

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

int main(void) {
  string S;
  cin >> S;
  
  for(int i = 0; i < S.size(); i++) {
    if(i%2==0) {
      if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
      }
      else {
        cout << "No"; return 0; 
      }
    }
    else {
      if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
      }
      else {
        cout << "No"; return 0; 
      }
    }
  }
  cout << "Yes";
  
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,m ; cin >> n >> m;
  vector<int> l(m),r(m);
  rep(i,m) {
    cin >> l[i] >> r[i];
  }

  using pi = pair<int,int>;
  vector<pi> vec;
  rep(i,m) {
    vec.push_back({l[i], 1});
    vec.push_back({r[i] + 1, -1});    
  }
  sort(vec.begin(), vec.end());
  int len = vec.size();
  
  int idx = 0;
  int cnt = 0;
  int res = 0;
  rep1(i,n) {
    while(idx < len && vec[idx].F == i) {
      cnt += vec[idx].S;
      idx++;
    }
    if(cnt == m) res++;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 6132
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>
#include<set>

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

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    set<string> st;
    string part;
    string last = "";
    int ans = 0;
    for (char c : s) {
        part += c;
        if (last == part) continue;
        ans++;
        last = part;
        part = "";
    }
    cout << ans << endl;
}


Measured memory_bytes: 1336
sx , sy ,tx ,ty = map(int,input().split())
for _ in range(ty - sy):
    print("U",end = "")
for _ in range(tx - sx):
    print("R",end = "")
for _ in range(ty - sy):
    print("D",end = "")
for _ in range(tx - sx):
    print("L",end = "")

print("L" , end = "")
for _ in range(ty - sy + 1):
    print("U",end = "")
for _ in range(tx - sx + 1):
    print("R",end = "")
print("D" , end = "")
print("R" , end = "")
for _ in range(ty - sy + 1):
    print("D",end = "")
for _ in range(tx - sx + 1):
    print("L",end = "")
print("U")

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n;
    cin >> n;
    vector< int> in(n);
    for (int &i : in) cin >> i;

    int cnt = 0;
    for (int i = 0, j = 1; i < n; i++) {
        if (in[i] == j) j++;
        else cnt++;
    }

    if (cnt == n) cout << -1;
    else cout << cnt << endl;
}

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


def main():
    S = input().strip()

    if S[0] != "A":
        S = "A" + S
    i = S.find("B")
    if i > -1 and S[i-1] != "A":
        S = S[:i] + "A" + S[i:]
    i = S.find("R")
    if i > -1 and S[i-1] != "A":
        S = S[:i] + "A" + S[i:]
    if S[-1] != "A":
        S = S + "A"

    if S == "AKIHABARA":
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

vin l;


bool check(int a,int x){
  //l[i]<l[j]+l[x]ならtrue
  return a<l[x];
}

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           l.resize(n);
           rep(i,0,n)cin>>l[i];
           sort(all(l));
           reverse(all(l));
           ll ans=0;
           rep(i,0,n-1){//1本目
            rep(j,i+1,n){//2本目
              int a=l[i]-l[j];
              int ok=j;
              int ng=n;
              while(ng-ok>1){
                int mid=(ok+ng)/2;
                if(check(a,mid))ok=mid;
                else ng=mid;
              }
              ans+=ok-j;
            }
           }
           cout<<ans<<endl;
}

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

int cmp(const void *a, const void *b)
{
	int *x = (int *)a;
	int *y = (int *)b;

	return (*y - *x);
}

int main(void)
{
	int hills[10];
	int i;

	for (i = 0; i < 10; i++){
		scanf("%d", hills + i);
	}

	qsort(hills, 10, sizeof(int), cmp);
	for (i = 0; i < 3; i++){
		printf("%d\n", hills[i]);
	}

	return (0);
}

Measured memory_bytes: 604
import java.util.Arrays;
import java.util.Scanner;

class Main {
    
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n, m, i, j;
    	
    	n = sc.nextInt();
    	m = sc.nextInt();
        
    	int[][] a = new int[n][m];
    	int[] b = new int[m];
    	int[] c = new int[n];
    	Arrays.fill(c, 0);
        
    	for(i = 0; i < n; i++) {
    		for(j = 0; j < m; j++) {
    			a[i][j] = sc.nextInt();
    		}
    	}
    	
    	for(i = 0; i < m; i++) {
    		b[i] = sc.nextInt();
    	}
    	
    	
    	for(i = 0; i < n; i++) {
    		for(j = 0; j < m; j++) {
    			c[i] += a[i][j] * b[j];
    		}
    		System.out.println(c[i]);
    	}
    	
    	
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n;
   cin >> n;
   int a[5] = {0};
   string march = "MARCH";
   rep (i, n) {
      string s;
      cin >> s;
      auto p = march.find(s[0]);
      if (p == string::npos) continue;
      a[p]++;
   }

   ll sum = 0;
   rep (i, 5) {
      repp (j, i+1, 5) {
         repp (k, j+1, 5) {
            sum += 1LL * a[i] * a[j] * a[k];
         }
      }
   }
   cout << sum <<endl;

   return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
like = [0]*m
for i in range(n):
    *k, = map(int,input().split())
    k = k[1:]
    for j in k:
        like[j-1]+=1
ans=0
for i in like:
    if i==n:
        ans+=1
print(ans)

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

int main() {
  int N;
  int total=0;
  cin >> N;
  
  for (int i=0;i<N;i++) {
    int s,e;
    cin >> s >> e;
    total += e - s + 1;
  }
  
  cout << total << endl;
}


Measured memory_bytes: 384
/*
https://atcoder.jp/contests/dp/tasks/dp_g
*/
#include<bits/stdc++.h>
#include<vector>
using namespace std;

vector<int> graph[100005];
int dp[100005];

int solve(int src){
    if(dp[src] != -1){
        return dp[src];
    }
    int leaf = 1;
    int best_child = 0;

    for(auto child:graph[src]){
        leaf = 0;
        best_child = max(best_child,solve(child));
    }
    if(leaf == 1){
        return dp[src] = 0;
    }
    else{
        return dp[src] = 1+best_child;
    }
}

int main(){

    int n,m;  cin>>n>>m;
    int x,y;

   // graph.clear();
    memset(dp,-1,sizeof(dp));

    for(int i=0;i<m;i++){
        cin>>x>>y;
        graph[x].push_back(y);
    }

    int ans = 0;

    for(int i=1;i<=n;i++){
        ans = max(ans,solve(i));
    }

    cout<<ans<<"\n";

return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,m,k,ans=0;
    cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> b(m);
    rep(i,n){
        cin >> a[i];
        if(i) a[i]+=a[i-1];
    } 
    rep(i,m){
        cin >> b[i];
        if(i) b[i]+=b[i-1];
    } 
    
    for(ll i=0;i<n;i++){
        if(k-a[i]<0){
            break;
        }
        ll now=upper_bound(b.begin(),b.end(),k-a[i])-b.begin();
        now+=i+1;
        ans=max(ans,now);
    }
    
    ll now2=upper_bound(b.begin(),b.end(),k)-b.begin();
    ans=max(ans,now2);
    
    cout << ans << endl;
    
    return 0;
}











Measured memory_bytes: 6424
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
S = input()
Q = int(input())
Que = [input().split() for _ in range(Q)]

d = deque([s for s in S])

oneisleft = True
for q in Que:
    if q[0] == '1':
        oneisleft = not(oneisleft)
    else:
        fi, ci = q[1], q[2]
        if oneisleft:
            if fi == '1':
                d.appendleft(ci)
            else:
                d.append(ci)
        else:
            if fi == '1':
                d.append(ci)
            else:
                d.appendleft(ci)
if oneisleft:
    res = ''.join(list(d))
else:
    res = ''.join(reversed(list(d)))
print(res)


Measured memory_bytes: 46220
#include <iostream>

using namespace std;

int main() {
    char s[1000];
    for (char &i : s) i = 'X';
    scanf("%s", &s);
    int w;
    cin >> w;
    for (int i = 0; i < 1000; i += w ) {
        // if (s[i] == 'X') break;
        if (s[i] == 'X' || s[i] == '\000') break;
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

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

  int k = 0;
  int ans = -1;
  while(1) {
    bool ok = false;
    REP(i, a+1) {
      if((k+i-c) % 60 == 0) {
        ok = true;
        ans = k+i;
        break;
      }
    }
    if(ok) break;
    k += a+b;
    if(k%60 == 0) break;
  }
  cout << ans << endl;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll K,X;

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

  cin>>K>>X;

  repl(i,X-K+1,X+K){
    cout<<i<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256