akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)






string str = "abcdefghijklmnopqrstuvwxyz";
int main() {

    long long n ;
    cin >> n;
    string temp = "";
    while( n ){
        ll k = n / 26 ;
        ll z = n % 26;

        if( z == 0 ){
            k--;
            temp+='z';
        }
        else{
            temp+= str[z]-1;
        }

        n = k;
    }
    // cout << temp << endl;
    reverse(temp.begin(),temp.end());
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 3628
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_1-A

#include <algorithm>
#include <iostream>

int max_profit(int const rs[], const unsigned int n) {
  int r0 = rs[0];
  int r1 = rs[1];
  int cur_p = r1 - r0;
  int max_p = cur_p;
  int min_r =  std::min(r0, r1);

  for (unsigned int i = 2; i < n; ++i) {
    const int r = rs[i];
    cur_p = r - min_r;
    max_p = std::max(max_p, cur_p);
    min_r = std::min(min_r, r);
  }

  return max_p;
}

int main(void) {
  unsigned int n;
  std::cin >> n;
  int rs[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> rs[i];
  }

  const int max_p = max_profit(rs, n);
  std::cout << max_p << std::endl;

  return 0;
}
// end

Measured memory_bytes: 1944
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int n,a,b;
    cin>>n>>a>>b;
    Vi h(n);
    REP(i,0,n) cin>>h[i];

    int low=0,high=1000000000;
    while(high-low>1){
        int x=(low+high)/2;
        int c=0;
        REP(i,0,n){
            int hp=h[i]-b*x;
            if(hp>0) c+=RUP(hp,a-b);
        }
        if(c<=x) high=x;
        else low=x;
//        cout<<low<<" "<<high<<endl;
    }
    int ans=high;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll F[N][10];
    for(int yi = 0; yi < N; yi++){
        for(int xi = 0; xi < 10; xi++){
            cin >> F[yi][xi];
        }
    }
    ll P[N][11];
    for(int yi = 0; yi < N; yi++){
        for(int xi = 0; xi < 11; xi++){
            cin >> P[yi][xi];
        }
    }
    ll M = -1000000007;
    for(unsigned int i = 1; i < (1 << 10); i++){
        int count[N];
        for(int tmp = 0; tmp < N; tmp++){
            count[tmp] = 0;
        }
        for(int j = 0; j < 10; j++){
            if(i & (1 << j)){
                //開店
                for(int k = 0; k < N; k++){
                    if(F[k][j] == 1){
                        count[k]++;
                    }
                }
            }
        }
        ll sTmp = 0;
        for(int tmp = 0; tmp < N; tmp++){
            sTmp += P[tmp][count[tmp]];
        }
        M = max(M,sTmp);
    }
    cout << M << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
int minTA[maxn] , minPA[maxn];
int minTB[maxn] , minPB[maxn];
int lowbit (int x) {return x & -x;}
void modify (int x , int c , int n , int minn[]){
    while (x <= n){
        minn[x] = min (minn[x] , c);
        x += lowbit(x);
    }
}
int ask (int x , int n , int minn[]){
    int ans = 1e9;
    while (x){
        ans = min (ans , minn[x]);
        x -= lowbit(x);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    ll n , q; cin >> n >> q;
    // 初始化
    for (int i = 0 ; i < maxn ; i++){
        minTA[i] = minTB[i] = minPA[i] = minPB[i] = 1e9;
    }
    ll ans = (n - 2) * (n - 2);
    for (int g = 1 ; g <= q ; g++){
        int op , x; cin >> op >> x;
        if (op == 1){
            int res = ask(x , n , minTA);
            if (res == 1e9) res = g - 1;
            int res2 =  minPB[res];
            if (res2 == 1e9) ans -= n - 2;
            else ans -= res2 - 2;
            modify( x , g , n , minTA );
            minPA[g] = x;
        }else {
            int res = ask(x , n , minTB);
            if (res == 1e9) res = g - 1;
            int res2 =  minPA[res];
            if (res2 == 1e9) ans -= n - 2;
            else ans -= res2 - 2;
            modify( x , g , n , minTB );
            minPB[g] = x;
        }
        minPB[g] = min (minPB[g] , minPB[g - 1]);
        minPA[g] = min (minPA[g] , minPA[g - 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6776
#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 n;
	cin >> n;
	
	vector< pair<ll, ll> > p(n);
	for(int i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;
		
		p[i] = {a, b};
	}
	
	ll cnt = 0LL;
	ll prev = 0LL;
	for(int i = n - 1; i >= 0; i--) {
		p[i].first += prev;
		
		if( p[i].first % p[i].second != 0 ) {
			cnt = p[i].second - (p[i].first % p[i].second);
		}
		
		prev += cnt;
		cnt = 0;
	}
	
	cout << prev << endl;
	
	return 0;
}


Measured memory_bytes: 1792
//142 A - Odds of Oddness 2019/09/28
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    float odd=0.0;
    for(int i=1;i<=n;++i){
        if(i%2==1) ++odd; 
    }
    printf("%.6f",(float)(odd/n));
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;

ll X[50];
ll Y[50];
bool visited[50];

int main() {
    ll N;
    cin >> N;
    for (ll i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }

    ll res = 100;
    if (N == 1) {
        cout << 1 << "\n";
        return 0;
    }

    for (ll i = 0; i < N; i++) {
        for (ll j = i+1; j < N; j++) {
            ll p = X[i] - X[j];
            ll q = Y[i] - Y[j];
            ll tmp = 0;
            for (ll k = 0; k < N; k++) {
                visited[k] = false;
            }
            for (ll k = 0 ; k < N; k++) {
                if (!visited[k]) {
                    queue<ll> que;
                    que.push(k);
                    while (!que.empty()) {
                        ll t = que.front(); que.pop();
                        for (ll l = 0; l < N; l++) {
                            if (!visited[l] && ((X[l]-X[t]==p && Y[l]-Y[t]==q)
                                                ||(X[t]-X[l]==p && Y[t]-Y[l]==q))) {
                                visited[l] = true;
                                que.push(l);
                            }
                        }
                        visited[t] = true;
                    }
                    tmp++;
                }
            }
            if (tmp < res) res = tmp;
        }
    }
    cout << res << "\n";

}

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

using namespace std;

#define MAX 110
#define INF 1e9
typedef pair<int,int> pii;
typedef pair<pii,int> State;

struct Edge{
  int to,cost;
  Edge() {}
  Edge(int to,int cost) : to(to),cost(cost) {}
};

int V,E;
vector<Edge> G[MAX];

int dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(pii(0,0),0));
  int dp[MAX][2];
  fill(dp[0],dp[0]+MAX*2,INF);
  dp[0][0] = 0;

  while(!Q.empty()){
    State p = Q.top(); Q.pop();
    int v = p.first.second;

    if(dp[v][p.second] < p.first.first) continue;

    for(int i = 0 ; i < (int)G[v].size() ; i++){
      if(dp[v][p.second] + G[v][i].cost < dp[G[v][i].to][p.second]){
        dp[G[v][i].to][p.second] = dp[v][p.second] + G[v][i].cost;
        Q.push(State(pii(dp[G[v][i].to][p.second],G[v][i].to),p.second));
      }
      if(p.second) continue;
      int d = G[v][i].to;
      for(int j = 0 ; j < (int)G[d].size() ; j++){
        if(dp[v][0] < dp[G[d][j].to][1]){
          dp[G[d][j].to][1] = dp[v][0];
          Q.push(State(pii(dp[G[d][j].to][1],G[d][j].to),1));
        }
      }
    }
  }
  return min(dp[V-1][0],dp[V-1][1]);
}

int main(){
  int a,b,c;
  while(cin >> V >> E, V){
    for(int i = 0 ; i < V ; i++){
      G[i].clear();
    }
    for(int i = 0 ; i < E ; i++){
      cin >> a >> b >> c;
      a--, b--;
      G[a].push_back(Edge(b,c));
      G[b].push_back(Edge(a,c));
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define INF ULLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ull N; cin >> N;
  vector<ull> div_arr = div(N);
  ull ans = INF;
  for(ull a:div_arr) {
    ull b = N/a;
    chmin(ans, a+b-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int n;
int a[100000];

int main(){

	int i;

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

	int search_num = a[0];
	int count = 0;
	while(count < n){
		count++;
		if(search_num == 2)
			break;
		search_num = a[search_num-1];
	}

	if(count >= n){
		printf("-1\n");
	} else {
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 512
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        count += 1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        count += 1
    else:
        pass
print (count)


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

#define ff first
#define ss second
#define pb push_back

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

const int N = 100005;
ll n, m, v, p;
ll a[N], b[N];

bool f(ll mid){
	ll tt = m * v;
	memcpy(b, a, sizeof(a));
	ll lim = a[mid] + m;
	b[mid] = lim;
	tt -= m;
	for(int i = n-1; i >= 0; i--){
		if(tt == 0) break;
		if(i != mid){
			if(b[i] > lim){
				b[i] += min(m, tt);
				tt -= min(m, tt);
			}
			else if(b[i] < lim){
				ll d = min(m, lim - b[i]);
				b[i] += min(d, tt);
				tt -= min(d, tt);
			}
		}
	}
	if(tt){
		for(int i = 0; i < n; i++) if(i != mid){
			ll d = b[i] - a[i];
			b[i] += min(tt, m-d);
			tt -= min(tt, m-d);
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cnt += b[i] > lim;
	}
	return cnt < p;
}

int main() {
	scanf("%lld %lld %lld %lld", &n, &m, &v, &p);
	for(int i = 0; i < n; i++){
		scanf("%lld", a+i);
	}
	sort(a, a + n);
	reverse(a, a + n);
	ll lo = 0, hi = n-1;
	ll ans = 0;
	while(lo <= hi){
		ll mid = (lo + hi) / 2;
		if(f(mid)){
			ans = mid+1;
			lo = mid + 1;
		}
		else{
			hi = mid - 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  x-= z;
  int res = x / (y + z);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
}


Measured memory_bytes: 35636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int tmp, ans;
  tmp = max(a+b, a-b);
  ans = max(tmp, a*b);
  cout << ans << endl;
}


Measured memory_bytes: 768
using System;
using System.Linq;

namespace AtCoderBeginnercontest161
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = ReadIntArray();

			Console.WriteLine($"{inputs[2]} {inputs[0]} {inputs[1]}");
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


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

int main()
{
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int i;
  int rankall = 0;
  int rankfor = 0;
  for(i = 0; i < n; i++)
  {
    if(s.at(i) == 'a')
    {
      if(rankall < a+b)
      { 
        rankall++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else if(s.at(i) == 'b')
    {
      if(rankall < a+b && rankfor < b)
      {
        rankall++;
        rankfor++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
}

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

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

  // X * 1.08 = N
  int X = N / 1.08;
  int X1 = X + 1;

  if ((int)(X * 1.08) == N) {
    cout << X << endl;
  } else if ((int)(X1 * 1.08) == N) {
    cout << X1 << endl;
  } else {
    cout << ":(" << endl;
  }
}

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

int main(){
	set<long long int> divisor;
	long long int N;
	cin >> N;
	divisor.insert(N);
	for(int i = 2;i<=sqrt(N);i++){
		if(N%i == 0){
			long long int k = N;
			while(k%i == 0){
				k = k/i;
			}
			if(k%i == 1 && divisor.find(i) == divisor.end()) divisor.insert(i); 
			long long int j = N/i;
			k = N;
			while(k%j == 0){
				k = k/j;
			}
			if(k%j == 1 && divisor.find(j) == divisor.end()) divisor.insert(j); 
		} 
	}
	N = N - 1;
	for(int i = 1;i<=sqrt(N);i++){
		if(N%i == 0){
			long long int x = N/i;
			if(divisor.find(x) == divisor.end() && x!=1 && i != x) divisor.insert(x);
			if(divisor.find(i) == divisor.end() && i!=1) divisor.insert(i);
		} 
	}
	cout << divisor.size() << endl;
	return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {
  int x;
  cin >> x;

  int h = CalcSumOfDigit(x);

  if(x%h == 0)cout << "Yes" << endl;
  else cout <<"No"<<endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
from sys import stdin
n=int(input())
D1=[]
D2=[]
for _ in range(n):
    x, y= map(int, stdin.readline().split())
    r1=x+y
    r2=abs((10**9-x)+y)
    D1.append(r1)
    D2.append(r2)

ans1=max(D1)-min(D1)
ans2=max(D2)-min(D2)
print(max(ans1,ans2))

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

int main(){
    string s;
    cin >> s;
    int tmp,flg=0;
    for(int i=0;i<(1<<s.size()-1);i++){
        bitset<3> op(i);
        tmp = (int)s.at(0)-'0';
        string ope={};
        for(int j=0;j<3;j++){
            if(op.test(j)==0){
                tmp -= ((int)s.at(j+1)-'0');
                ope += '-';
            }
            else if(op.test(j)==1){
                tmp += ((int)s.at(j+1)-'0');
                ope += '+';
            }
        }
        if(tmp==7){
            for(int k=0;k<3;k++)
                cout << s.at(k) << ope.at(k);
            cout << s.at(3) << "=7" << endl;
            break;
        }
    }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

struct brac{
    int val,peek = 0;
};

int main() {

    int N;
    cin >> N;

    vector<string> s(N);

    Rep(i,N){
        cin >> s[i];
    }

    int X = 0;
    int M = 1e6+1;
    vector<vi> a(M);
    vector<vi> b(M);
    vi c;
    ll ab = 0;
    Rep(i,N){
        int v = 0;
        int pp = 0;
        int np = 0;
        for( char c : s[i] ){
            if( c == '(' ){
                v++;
            }else {
                v--;
                np = max( np, -v );
            }
        }
        int K = s[i].size();
        v = 0;
        RRep(j,K){
            char c = s[i][j];
            if( c == '(' ){
                v++;
                pp = max( pp, v );
            }else {
                v--;
            }
        }
        if( v == 0 ){
            c.emplace_back(max(np,pp));
        }else if( v > 0 ){
            a[np].emplace_back(v);
            X += v;
        }else {
            b[pp].emplace_back(-v);
        }
        ab += v;
    }

    if( ab != 0 ){
        YesNo(false);
        return 0;
    }


    int cnt = 0;
    priority_queue<int> q;
    for( int v : a[0] ) q.push(v);
    while(q.size()){
        int v = q.top(); q.pop();
        Repe(i,cnt+1+v,cnt+1){
            for( int v : a[i] ) q.push(v);
        }
        cnt += v;
    }
    if( cnt != X ) {
        YesNo(false);
        return 0;
    }

    cnt = 0;
    for( int v : b[0] ) q.push(v);
    while(q.size()){
        int v = q.top(); q.pop();
        Repe(i,cnt+1+v,cnt+1){
            for( int v : b[i] ) q.push(v);
        }
        cnt += v;
    }
    if( cnt != X ) {
        YesNo(false);
        return 0;
    }

    bool ans = true;
    for( int v : c ){
        ans = ans && v<=X;
    }

    YesNo(ans);

    return 0;
}



Measured memory_bytes: 88372
// https://cp-wiki.vercel.app/en/tutorial/atcoder/ABC178/#problem-f-contrast

#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), cb(n + 1);
  vector<bool> taken(n);
  vector<vector<int>> ca(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ca[a[i]].emplace_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    cb[b[i]]++;
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 1; i <= n; ++i) {
    int lo = min((int)ca[i].size(), cb[i]);
    if (lo)
      pq.emplace(lo, i);
  }
  while (pq.size() >= 2) {
    auto [cx, x] = pq.top();
    pq.pop();
    auto [cy, y] = pq.top();
    pq.pop();
    if (cx == 1 && pq.size() == 1) {
      auto [cz, z] = pq.top();
      pq.pop();
      int px = ca[x].back();
      int py = ca[y].back();
      int pz = ca[z].back();
      taken[px] = taken[py] = taken[pz] = true;
      b[px] = y;
      b[py] = z;
      b[pz] = x;
      ca[x].pop_back();
      ca[y].pop_back();
      ca[z].pop_back();
      cb[x]--;
      cb[y]--;
      cb[z]--;
    } else {
      int px = ca[x].back();
      int py = ca[y].back();
      taken[px] = taken[py] = true;
      b[px] = y;
      b[py] = x;
      ca[x].pop_back();
      ca[y].pop_back();
      cb[x]--;
      cb[y]--;
      if (cx > 1)
        pq.emplace(cx - 1, x);
      if (cy > 1)
        pq.emplace(cy - 1, y);
    }
  }
  int idx = 0;
  if (!pq.empty()) {
    auto [cx, x] = pq.top();
    pq.pop();
    while (cb[x]) {
      while (idx < n && (taken[idx] || a[idx] == x))
        idx++;
      if (idx >= n)
        break;
      b[idx] = x;
      cb[x]--;
      taken[idx] = true;
    }
    if (cb[x]) {
      cout << "No" << flush;
      return 0;
    }
  }
  vector<int> rest;
  for (int i = 1; i <= n; ++i)
    if (cb[i]) {
      for (int j = 0; j < cb[i]; ++j)
        rest.emplace_back(i);
    }
  idx = 0;
  for (int i : rest) {
    while (taken[idx])
      idx++;
    b[idx] = i;
    taken[idx] = true;
  }
  cout << "Yes" << endl;
  for (int i : b)
    cout << i << " ";
  cout << flush;
}

Measured memory_bytes: 18500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
	cin>>n;
	if(n<=599)
	cout<<8;
	else if(n<=799)
	cout<<7;
	else if(n<=999)
	cout<<6;
	else if(n<=1199)
	cout<<5;
	else if(n<=1399)
	cout<<4;
	else if(n<=1599)
	cout<<3;
	else if(n<=1799)
	cout<<2;
	else if(n<=1999)
	cout<<1;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll x, y;
    cin >> x >> y;
    
    for (int i = 0; i <= x; ++i)
    {
        ll a = i;
        ll b = x - i;
        if (((x - i) * 4ll + i * 2ll) == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

struct BIT {
    ll N;
    vector<ll> bit;
    BIT(ll N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }

    void add(int x, ll val){
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }

    ll sum(int x){
        ll ret = 0;
        if(x == 0) return ret;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        return (ret);
    }
    // [l,r]
    ll sum(int l,int r){
        return sum(r) - sum(l-1);
    }
};


template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> P(N); for(auto& in:P) cin >> in;

    ll minP = LINF;
    for(int i = 0; i < N;i++){
        minP = min(minP,P[i]);
        if(P[i] <= minP) res++;
    }
    
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	map<int, int> b;
	for (int i = 0; i < n; i++) {
		b[a[i]]++;
	}
	int sum = 0;
	for (auto p : b) {
		int x = p.first, y = p.second;
		if (y < x)sum += y;
		else sum += y - x;
	}
	cout<< sum << endl;

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h> 
#define rep(i,N)  for(int i=0; i<N; i++)
#define ol(a) cout << a << endl;
#define PI 3.14159265359
using namespace std;

int main(){
  int64_t n,m;  cin >> n >> m;
  //string s; cin >> s;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  
  sort(p.begin(), p.end());
  //reverse(p.begin(), p.end());
  int ans = 0;
  rep(i,m){
    ans += p[i];
  }
  ol(ans)
    
    
      
}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N;
	cin >> N;
	vector<ll> ryuka;
	ryuka.push_back(2);
	ryuka.push_back(1);
	rep(i, 2, N + 1){
		ryuka.push_back(ryuka[i - 2] + ryuka[i - 1]);
	}
	cout << ryuka[N] << endl;
 	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve (i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1180&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */
int a; int L;
string getstr(const int V,int dig){
    ostringstream oss;
    oss << setw(dig) << setfill('0') << V;
    return oss.str();
}
vector<ll> solve(){
    vector<ll> res;
    map<string,int> mp;
    int idx = 0;
    while(true){
        string a_str = getstr(a,L);
        if(mp.count(a_str)){
            res = vector<ll>{mp[a_str],a,idx - mp[a_str]};
            break;
        }
        mp[a_str] = idx++;
        string s1 = a_str,s2 = a_str;
        sort(s1.rbegin(),s1.rend());
        sort(s2.begin(),s2.end());
        a = atoi(s1.c_str()) - atoi(s2.c_str());
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> a >> L,L){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	map<string,int> a;
	string s;
	for(int i = 0; i < n; i++) {
		cin>>s;
		a[s]++;
	}
	int m = 0;
	for(auto i = a.begin(); i != a.end(); i++) {
		if(i->sc > m){
			m = i->sc;
		}
	}
	for(auto i = a.begin(); i != a.end(); i++) {
		if(i->sc ==  m){
			cout << i->fs << endl;
		}
	}
	return 0;
}

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

inline int Pow(int x,int P,int MOD){
	int ans=1;
	for (;P;P>>=1,x=1LL*x*x%MOD)
		if (P&1)
			ans=1LL*ans*x%MOD;
	return ans;
}

const int MOD=1e9+7;
const int INV2=(MOD+1)/2;

inline int add(int a,int b){return (a+=b)>=MOD?(a-MOD):a;}
inline int minus(int a,int b){return (a-=b)<0?(a+MOD):a;}

const int maxn=2e5+10;

int Fac[maxn];
int Facinv[maxn];
inline int C(int n,int m){
	if (n==m||m==0)return 1;
	if (n<m||n<0||m<0)return 0;
	return 1LL*Fac[n]*Facinv[n-m]%MOD*Facinv[m]%MOD;
}

const int ZERO=2005;
const int maxv=4e3+10;

int n,ans;
int a[maxn];
int b[maxn];
int buc[maxv][maxv];

inline int& F(int i,int j){
	return buc[i+ZERO][j+ZERO];
}

int main (){
#ifdef LOCAL
	freopen("input","r",stdin);
#endif
	for (int i=Fac[0]=1;i<=1e4;i++)Fac[i]=1LL*Fac[i-1]*i%MOD;
	Facinv[10000]=Pow(Fac[10000],MOD-2,MOD),Facinv[0]=1;
	for (int i=1e4-1;i>=1;i--)Facinv[i]=1LL*Facinv[i+1]*(i+1)%MOD;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		++F(-a[i],-b[i]);
	}
	for (int i=-2e3;i<=2e3;i++)
		for (int j=-2e3;j<=2e3;j++){
			F(i,j)=add(F(i,j),F(i-1,j));
			F(i,j)=add(F(i,j),F(i,j-1));
		}
	for (int i=1;i<=n;i++){
		ans=add(ans,F(a[i],b[i]));
		ans=minus(ans,C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]));
	}
	printf("%lld\n",1LL*ans*INV2%MOD);
	return 0;
}



Measured memory_bytes: 65664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define pq priority_queue
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e5 + 5;

int n, m, a, b, ans;
int dp[N];
vt<int> v[N];

int f(int x) {
    if(!v[x].size()) return 0;
    int &sol = dp[x];
    if(sol != -1) return sol;
    sol = -INF;
    for(int u : v[x]) {
        sol = max(sol, 1 + f(u));
    }
    return sol;
}

void solve() {
    cin >> n >> m;
    while(m--) {
        cin >> a >> b;
        v[a].pb(b);
    }
    memset(dp, -1, sizeof(dp));
    ans = -INF;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, f(i));
    }
    cout << ans << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 11500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl D(13);
    D[0] = 1;
    rep(i, N) {
        ll c;
        cin >> c;
        D[c]++;
    };

    rep(i, 13) if(D[i]>2 or(i%12==0 and D[i]>1)){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    rep(bit, 1<<13){
        vl A = {0};
        repe(i, 1, 13){
            if (D[i] == 1) A.eb((bit & 1 << i ? i : 24 - i));
            else if(D[i]==2){
                A.eb(i), A.eb(24 - i);
            }
        }

        ll tmp = INF;
        repa(a, A)repa(b, A){
            if (a == b) continue;
            chmin(tmp, min(abs(a - b), 24 - abs(a - b)));
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

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

int main(){
  int w,h,n;
  cin >>w >>h >>n;
  vector<vector<int>> s(h,vector<int> (w,1));
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >>x[i] >>y[i] >>a[i];
  for(int k=0;k<n;k++){
    if(a[k]==1){
      for(int i=0;i<h;i++){
        for(int j=0;j<x[k];j++)
          s[i][j]=0;
      }
    }
    else if(a[k]==2){
      for(int i=0;i<h;i++){
        for(int j=x[k];j<w;j++)
          s[i][j]=0;
      }
    }
    else if(a[k]==3){
      for(int i=0;i<y[k];i++){
        for(int j=0;j<w;j++)
          s[i][j]=0;
      }
    }
    else{
      for(int i=y[k];i<h;i++){
        for(int j=0;j<w;j++)
          s[i][j]=0;
      }
    }
  }
  int sum=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      sum+=s[i][j];
  }
  cout <<sum <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b =sc.nextInt();
		int ans=0;

		for(int i=1; i <=n ; i++) {
			int digitSum=0;
			int now = i;
			while (now>0) {
				digitSum += now%10;
				now /= 10;
			}
			if (digitSum>=a&&digitSum<=b) {
				ans += i;
			}
		}
		System.out.println(ans);
//------------------------------------------------------------
	}
}

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

string mp[30];
int dx[]={0, 0, 1, -1};
int dy[]={1, -1, 0, 0};
int dist[22][22];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int h,w;cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];

  int ans=0;
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      if(mp[y][x]=='#')continue;
      for(int i=0;i<22;i++)for(int j=0;j<22;j++)dist[i][j]=1000;
      queue<int> q;q.push(y);q.push(x);
      dist[y][x]=0;
      int mx=0;
      while(!q.empty()){
        int cy = q.front();q.pop();int cx = q.front();q.pop();
        for(int i=0;i<4;i++){
          int nx = cx + dx[i]; int ny = cy + dy[i];
          if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]=='.'&&dist[ny][nx]>(dist[cy][cx]+1)){
            dist[ny][nx]=dist[cy][cx]+1;
            q.push(ny);q.push(nx);
            mx = max(mx, dist[ny][nx]);
          }
        }
      }
      ans=max(ans,mx);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
function Main(input){
  input = input.split('\n');
  const n = parseInt(input[0], 10);

  const atama = ['M', 'A', 'R', 'C', 'H'];
  let count = [0,0,0,0,0];

  for(const str of input){
    const k = str.substr(0,1);
    for(let i=0; i<5; i++){
      if(k == atama[i]){
        count[i]++;
      }
    }
  }

  let ans = 0;
  const p = [0,0,0,0,0,0,1,1,1,2];
  const q = [1,1,1,2,2,3,2,2,3,3];
  const r = [2,3,4,3,4,4,3,4,4,4];

  for(let i=0; i<10; i++){
    ans += count[p[i]] * count[r[i]] * count[q[i]];
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17100
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
  int N, M;
  deque<int> W;
  vector<unsigned long long> U;
  cin >> N >> M;
  U.resize(N+1);

  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    W.push_back(a);
  }

  U[0] = 1;
  if (W.front() != 1) {
    U[1] = 1;
  } else {
    U[1] = 0;
    W.pop_front();
  }

  for (int i = 2; i <= N; ++i) {
    if (!W.empty() && W.front() == i) {
      U[i] = 0;
      W.pop_front();
    } else {
      U[i] = (U[i-1] + U[i-2]) % 1000000007;
    }
  }

  cout << U.back() << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<int> s;
    while(n>0){
        n--;
        ll tmp=n%26;
        n/=26;
        s.emplace_back(tmp);
    }
    for(int i = 0; i < s.size(); i++) {
        int j=s.size()-i-1;
        cout << char(s[j]+'a');
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=3e3+5;
ll buff[maxn][maxn];
ll dp[maxn][maxn][4];
int main() {
    int n,m,k;cin>>n>>m>>k;
    for(int i=1;i<=k;i++) {
    	ll y,x,w;cin>>y>>x>>w;
    	buff[y][x]=w;
    }
    dp[1][1][1]=buff[1][1];
    for(int i=2;i<=m;i++) {
    	for(int j=0;j<=3;j++) dp[1][i][j]=dp[1][i-1][j];
    	if(buff[1][i]) for(int j=1;j<=3;j++) dp[1][i][j]=max(dp[1][i][j],dp[1][i-1][j-1]+buff[1][i]);
    }
    for(int i=1;i<=n;i++) {
    	for(int j=1;j<=m;j++) {
			for(int k=0;k<=3;k++) dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]); //同一行
			for(int k=0;k<=3;k++) dp[i][j][0]=max(dp[i-1][j][k],dp[i][j][0]); //下一行
    		if(buff[i][j]) {
    			for(int k=0;k<=3;k++) dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+buff[i][j]);
    			for(int k=1;k<=3;k++) dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+buff[i][j]);
    		}
    	}
    }
    ll ans=0;
    // cout<<dp[2][2][2]<<endl;
    for(int k=0;k<=3;k++) ans=max(ans,dp[n][m][k]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 355632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v(n, 1), endv(n, m);
    int ans = 0;
    while (true) {
        int sum = 0;
        for (int i = 0; i < q; i++) {
            if (v[b[i]] - v[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(ans, sum);
        if (v == endv) break;
        for (int i = n - 1; i >= 0; i--) {
            if (v[i] == m) {
                v[i] = 1;
            } else {
                v[i]++;
                for (int j = i + 1; j < n; j++) {
                    v[j] = v[i];
                }
                break;
            }
        }
        if (v == endv) break;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;


const int MorningPrice = 200;
const int AfternoonPrice = 300;

int main() {
	int a, b;
	string name;

	for (int i = 0; i < 9; i++) {
		cin >> name >> a >> b;
		cout << name << " " << a + b << " " << MorningPrice*a + AfternoonPrice*b << endl;
	}

	return 0;
}


Measured memory_bytes: 3172
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const A = input[1].map(Number);
  const MAX = 10 ** 6;

  const divisorCounts: Array<number | undefined> = [];

  A.forEach((a) => {
    if (divisorCounts[a] !== undefined) {
      divisorCounts[a] = 2;

      return;
    }

    for (let i = a; i <= MAX; i += a) {
      divisorCounts[i] = (divisorCounts[i] || 0) + 1;
    }
  });

  let answer = 0;
  A.forEach((a) => {
    if (divisorCounts[a] === 1) {
      answer += 1;
    }
  });

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 80136
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin>>s;
		int a =0,b =0;
		for(char x : s){
			a+=(x=='A');
			b+=(x=='B');
		}
		cout <<(a>0 && b>0 ? "Yes" :"No");

	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int k,sum,di;
    int c;

    while(cin >> k, k){
        sum = 0;
        rep(i,k*(k-1) / 2){
            cin >> c;
            sum += c;
        }
        cout << sum / (k - 1) << endl;
    }
}

Measured memory_bytes: 1160
use std::collections::BinaryHeap;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut a: BinaryHeap<u64> = (0..n).map(|_| read()).collect();

    for _ in 0..m {
        let x = a.pop().unwrap();
        a.push(x / 2);
    }
    let ans: u64 = a.iter().sum();

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4476