akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const int Q=3e4;

int main(){
  int N;
  cin>>N;
  vector<int> P(N);
  rep(i,N) cin>>P[i];

  vector<int> A(N,0),B(N,0);
  rep(i,N){
    A[i]=Q;
    if(i>0) A[i]+=A[i-1];
  }
  for(int i=N-1;i>=0;i--){
    B[i]=Q;
    if(i<N-1) B[i]+=B[i+1];
  }

  for(int i=0;i<N;i++){
    A[P[i]-1]+=i;
  }

  rep(i,N) cout<<A[i]<<" ";
  cout<<endl;
  rep(i,N) cout<<B[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static final int MAX = 10;
	
	public static int ceiling = Integer.MAX_VALUE;
	
	public static int dfs(final int n, int deep, int cur_node, int dist, int[] min, boolean[] used, int[][] adj){
		if(deep == n - 1){
			return ceiling = Math.min(ceiling, dist);
		}
		
		int[] old_min = min.clone();
		int min_dist = ceiling;
		
		//System.out.println(deep);
		for(int next_node = 0; next_node < n; next_node++){
			if(used[next_node]){
				continue;
			}
			
			final int next_dist = Math.max(min[next_node], dist + adj[cur_node][next_node]);
			
			if(ceiling <= next_dist){
				continue;
			}
			
			used[next_node] = true;
			
			for(int other_node = 0; other_node < n; other_node++){
				if(used[other_node]){
					continue;
				}
				
				min[other_node] = Math.max(min[other_node], dist + adj[cur_node][other_node]);
			}
			
			min_dist = Math.min(min_dist, dfs(n, deep + 1, next_node, next_dist, min, used, adj));
			
			used[next_node] = false;
			System.arraycopy(old_min, 0, min, 0, n);			
		}
		
		return min_dist;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] adj = new int[MAX][MAX];
		boolean[] used = new boolean[MAX];
		int[] min = new int[MAX];
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					adj[i][j] = sc.nextInt();
				}
			}
			
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					adj[i][j] = adj[j][i] = Math.max(adj[i][j], adj[j][i]);
				}
			}
			
			
			ceiling = Integer.MAX_VALUE;
			for(int i = 0; i < n; i++){
				Arrays.fill(min, 0);
				Arrays.fill(used, false);
				used[i] = true;
				dfs(n, 0, i, 0, min, used, adj);
			}
			
			System.out.println(ceiling);
			
		}
	}

}

Measured memory_bytes: 152600
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var r = int.Parse(ss[0]);
            var D = int.Parse(ss[1]);
            var x2000 = int.Parse(ss[2]);

            var x = x2000;
            for (int i = 0; i < 10; i++)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int main(void){
	char S[11];
	char T[11];
	int A, B;
	char U[11];

	scanf("%s",S);
	scanf("%s",T);
	scanf("%d %d",&A, &B);
	scanf("%s",U);	

	if(strcmp(S,U)){
		B--;
	}else{
		A--;
	}
	printf("%d %d\n",A,B );
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int distance_ac = abs(a - c);
  int distance_ab = abs(a - b);
  int distance_bc = abs(b - c);
  if (distance_ac <= d) {
    cout << "Yes" << endl;
  } else if (distance_ab <= d && distance_bc <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {

    int N,M;
    Scd2(N,M);
    printf ("%d\n", (N-1)*(N)/2 + (M-1)*(M)/2 );

    return 0;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, c, k;
  cin >> n >> c >> k;

  vector<ll> t(n);
  for (ll i = 0; i < n; ++i) {
    cin >> t[i];
  }
  sort(t.begin(), t.end());

  vector<Pll> bus = {mkp(c, t[0]+k)};
  for (ll i = 0; i < n; ++i) {
    auto b = &bus[bus.size()-1];
    if (t[i] <= b->second && b->second <= t[i]+k && b->first > 0) { 
      b->first--;
    } else {
      bus.push_back(mkp(c-1, t[i]+k));
    }
  }

  cout << bus.size() << endl;

  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int a,b;
  cin >> a >> b;
  if(a>0 && b>0) {cout <<"Positive" << endl;return 0;}
  if(a==0||b==0) {cout <<"Zero" << endl;return 0;}
  if(a<0 && b>0) {cout <<"Zero" << endl;return 0;}
  if((b-a)%2==0) {cout <<"Negative" << endl;return 0;}
  else cout << "Positive" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

class unionfind{
	private:
		int par[999999];
		int depth[999999];
	public:
		void init(int n){
			for(int i=0; i<n; i++){
				par[i]=i;
				depth[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(depth[x] < depth[y])par[x]=y;
			else{
				par[y]=x;
				if(depth[x] == depth[y])depth[x]++;
			}
		}
		bool same(int x,int y){
			return find(x) == find(y);
		}
};
int main(){
	int n, m; 
	cin >> n >> m;
	int p[n];
	for(int i = 0; i < n; i++)cin >> p[i];
	unionfind un;
	un.init(n);
	int x, y;
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		x--;
		y--;
		un.unite(x, y);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(un.same(p[i]-1, i))ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int64_t rt = sqrt(N);
	int64_t a = 0, b = 0;

	for (int64_t i = rt; rt > 0; i--) {
		if (N % i == 0) {
			a = i;
			b = N / i;
			break;
		}
	}

	cout << (a - 1) + (b - 1) << endl;
}

Measured memory_bytes: 3648
import math
a,b,h,m = map(int, input().split())

angle = abs(30 * h - 5.5 * m)

if angle >= 180:
    angle = 360 - angle

angle = math.radians(angle)

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(angle))

print('{:.020f}'.format(ans))

Measured memory_bytes: 9448
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


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

    ll copyN = N;
    char name[13];
    ll size = 0;
    ll p = 0;

    while(copyN >= 0){
        size++;
        copyN /= 26;
        copyN--;
    }
    p = size;
    name[p] = '\0';
    p--;
    rep(i, size){
        name[p] = N % 26 + 'a';
        N /= 26;
        N--;
        p--;
    }

    cout << name << endl;
    
    return 0;
}


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


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
#define pb push_back
#define inf 1e9+11
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

void pre(){
}

void solve(){
	ll n; cin >> n;
	ll m[n][3]; rep(i,n) rep(j,3) cin >> m[i][j];
	ll score[n][3];
	memset(score, 0x00, sizeof(score));
	rep(i,n){
		if(i == 0){
			score[i][0] = m[i][0];
			score[i][1] = m[i][1];
			score[i][2] = m[i][2];
		}
		else rep(j,3){
				score[i][j] = max(score[i-1][(j+1)%3] + m[i][j], score[i-1][(j+2)%3] + m[i][j]  ); 
			}
	}
	ll mv = 0;
	rep(i,3)
		mv = max(mv, score[n-1][i]);
	cout << mv << endl;
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	solve();	
	return 0;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    string A, B;
    cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    else {
        for (int i = 0; i < A.size(); i++) {
            if (A.at(i) > B.at(i)) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (A.at(i) < B.at(i)) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3982722#1
struct SegmentTree{
private:
	vector<ll> node;
	int n;
    ll I=0;//ここに代入

public:
	SegmentTree(){
		int sz=200010;
		n=1;
		//要素数を2のべき乗にする
		while(n<sz) n*=2;
		rep(i,2*n-1) node.push_back(I);//全ての要素をinfで初期化//これは定義される演算における単位元
	}

	//k番目の値をaに変更する
	void update(int k,ll a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=max(node[2*k+1],node[2*k+2]);//これは結合則が満たされる任意の演算でok
		}
	}

	//[a,b)の最小値を求める,find(a,b+1)でよぶ
	ll find(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(r<=a || b<=l) return I;
		if(a<=l && r<=b) return node[k];
		else{
			ll vl=find(a,b,2*k+1,l,(l+r)/2);
			ll vr=find(a,b,2*k+2,(l+r)/2,r);
			return max(vl,vr);
		}
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> h(n),a(n);
	int ma=0;
	rep(i,n){
		cin>>h[i];
		chmax(ma,h[i]);
	}
	rep(i,n){
		cin>>a[i];
	}
	vector<ll> dp(ma+1,0);
	SegmentTree seg;
	rep(i,n){
		dp[h[i]]=seg.find(0,h[i])+a[i];
		seg.update(h[i],dp[h[i]]);
	}
	cout<<*max_element(begin(dp),end(dp))<<endl;
}

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n,i;
  cin>>n;
  long int arr[n][3];
  long int dp[n][3];
  for(i=0;i<n;i++)
  {
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(i=1;i<n;i++)
  {
    dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;


int main()
{	
	//解答方針
	
	int n, k;
	cin >> n >> k;

	priority_queue<P, vector<P>, function<bool(P, P)>> ps([](P a, P b) {return a.second < b.second; });	
	rep(i, n)
	{
		int t, d;
		cin >> t >> d;
		ps.emplace(t, d);
	}

	priority_queue<P, vector<P>, function<bool(P, P)>> ks([](P a, P b) {return a.second > b.second; });
	map<int, int> counts;
	ll score = 0;

	//最初のk個をとる
	rep(i, k)
	{
		P p = ps.top(); ps.pop();
		score += p.second;
		counts[p.first]++;

		ks.push(p);
	}

	score += (ll)counts.size() * (ll)counts.size();

	//残りのn - k個を入れ替えながら、満足度の最大値を計算
	ll maxScore = score;
	while (!ps.empty())
	{
		P p = ps.top(); ps.pop();

		//すでにk個のなかに同じ種類の寿司がある場合は
		//寿司の種類が増えないので置き換えない
		if (counts.find(p.first) != counts.end()) continue;

		//k個の中でおいしさ最小の寿司を交換
		P kp;
		bool found = false;

		while (!ks.empty())
		{
			kp = ks.top(); ks.pop();
			if (counts[kp.first] > 1)
			{
				found = true;
				break;
			}
		}

		if (!found) break;

		//置き換え
		//(n + 1)^2 - n^2 = 2n + 1
		score += (ll)p.second - (ll)kp.second + 2 * (ll)counts.size() + 1;

		if (score > maxScore) maxScore = score;
		counts[kp.first]--;
		counts[p.first]++;
	}

	cout << maxScore << endl;

	return 0;
}

Measured memory_bytes: 4724
#include<iostream>

#define bound 1000000

int main()
{
  bool is_prime[bound] = {};
  for (int i = 2; i < bound; i++)
    is_prime[i] = true;
  for (int prime = 2; prime < bound; ++prime)
    {
      if (!is_prime[prime]) continue;
      for (int i = prime * 2; i < bound; i += prime)
	is_prime[i] = false;
    }

  int table[bound] = {};
  for (int i = 0; i < bound; ++i)
      table[i] = table[i - 1] + is_prime[i];

  int n;
  while(std::cin >> n)
      std::cout << table[n] << std::endl;

  return 0;
}



Measured memory_bytes: 7968
#include <iostream>

using namespace std;

unsigned long long int a, b;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}

unsigned long long int lcm(unsigned long long int a, unsigned long long int b)
{
	return a * b / gcd(a, b);
}

int main()
{
	unsigned long long int a, b;
	cin >> a >> b;

	//cout << "最大公約数:" << gcd(a, b) << endl;
	cout << lcm(a, b) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return (2*i)+1;
}

int main(){
  int H, i, A[MAX+1];

  scanf("%d",&H);

  for(i=1; i<=H; i++){
    scanf("%d",&A[i]);
  }

  for(i=1; i<=H; i++){
    printf("node %d: key = %d, ",i ,A[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i) <= H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i) <= H){
      printf("right key = %d, ",A[right(i)]);
    }

    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,su=0;
    map<char,long long int>m;
    map<string,int>g;
    string s;
    cin>>n;
    getchar();
    for(int i = 0;i < n;i++)
    {
        cin>>s;
        if((s[0]=='M' || s[0]=='A' || s[0]=='R' || s[0]=='C' || s[0]=='H') && g[s]!=-1)
        {
            m[s[0]]++;
            g[s]=-1;
        }
    }
    if(m['M']!=0&& m['A']!=0 && m['R']!=0)
    {
        su += (m['M']*m['A']*m['R']);
    }
    if(m['M']!=0 && m['C'] && m['H'])
    {
        su += (m['M']*m['C']*m['H']);
    }
    if(m['M']!=0 && m['A'] && m['H'])
    {
        su += (m['M']*m['A']*m['H']);
    }
    if(m['M']!=0 && m['R'] && m['H'])
    {
        su += (m['M']*m['H']*m['R']);
    }
    if(m['M']!=0 && m['R'] && m['C'])
    {
        su += (m['M']*m['R']*m['C']);
    }
    if(m['M']!=0 && m['C'] && m['A'])
    {
        su += (m['M']*m['C']*m['A']);
    }
    if(m['R']!=0 && m['A']!=0 && m['C']!=0)
    {
        su += (m['A']*m['R']*m['C']);
    }
    if(m['A']!=0 && m['R'] && m['H'])
    {
        su += (m['A']*m['R']*m['H']);
    }
    if(m['C']!=0 && m['A']!=0 && m['H']!=0)
    {
        su += (m['A']*m['C']*m['H']);
    }
    if(m['H']!= 0 && m['C']!=0 && m['R']!=0)
    {
        su += (m['R']*m['C']*m['H']);
    }





    {
        cout<<su<<endl;
    }


}



Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>
#include <bitset>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::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...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 2e3 + 10;

int main()
{
	const int offset = max_N * max_N;

	int N;
	cin >> N;

	bitset<max_N * max_N> poss;
	poss[0] = true;

	int all_sum = 0;
	for (int i = 1; i <= N; ++i) {
		int x;
		cin >> x;
		all_sum += x;

		poss |= (poss << x);
	}

	int S = all_sum / 2 + all_sum % 2;
	for (; S <= all_sum; ++S) {
		if (poss[S]) {
			cout << S << endl;
			break;
		}
	}
}


Measured memory_bytes: 1664
// 2009à\IB Í¢­Â éH
#include <iostream>

using namespace std;

int w, h;
int c[50][50];
// 8ßTÖÌÚ®ðè`
char dx[] = {-1,-1,-1,0,1,1,1,0};
char dy[] = {-1,0,1,1,1,0,-1,-1};

// ÄAÅ»ÝÌ¤©çBÅ«é¤ðÁµÁÄ¢­
void dfs(int x, int y){
	c[x][y] = 0;
	for(int i=0;i<8;i++){
		int nx = x+dx[i], ny = y+dy[i];
		// (nx,ny)ªtB[hàÉ é©ÆC»±ª¤©ð»è
		if(nx<0||h<=nx||ny<0||w<=ny||!c[nx][ny]) continue;
		dfs(nx,ny);
	}
}

int main(){
	while(cin >> w >> h, w){
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin >> c[i][j];
		int ans = 0;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				if(c[i][j]) ans++, dfs(i,j);
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main() {
  double r;
  cin >> r;
  cout << 3*r*r << endl;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> vec(n);
  pair<ll, ll> p = make_pair(-1, INF);
  rep(i, n) {
    cin >> vec[i];
  }
  cout << ceil((n - 1) / (k - 1.0)) << endl;
  return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int r,d,x;
signed main(){
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++){
		x=x*r-d;
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n, 0);
	rep(i, n) {
		cin >> a[i];
	}
	sort(ALL(a));
	ll ans = 0;
	for (int i = 0; i < n-2; i++) {
		ll A = a[i];
		for (int j = i + 1; j < n - 1; j++) {
			ll B = a[j];
			for (int k = j + 1; k < n; k++) {
				ll C = a[k];
				if (A!=B&&B!=C&&C < A + B) {
					//cout << A << " " << B << " " << C << endl;
					ans++;
				}

			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n,a;
    cin>>n>>a;
    n=n%500;
    if(n<=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
# Jasmine_ss's code modufied by centipede_human

parseline(str=readline()) = parse.(Int, split(str))
function Ki()
    N, Q = parseline()
    tree = [Int[] for n in 1:N]
    score = zeros(Int, N)
    for _ in 1:N-1
        a, b = parseline()
        push!(tree[a], b)
        push!(tree[b], a)
    end
    for _ in 1:Q
        p, x = parseline()
        score[p] += x
    end
    seen = zeros(Bool,N)
    que = [1]; seen[1] = true
    while !isempty(que)
        parent = popfirst!(que)
        for child in tree[parent]
            seen[child] && continue
            seen[child] = true
            score[child] += score[parent]
            push!(que, child)
        end
    end
    for s in score
        print(s, " ")
    end
end
Ki()


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

using namespace std;
typedef unsigned long long ll;

int main(){

  ll a,b,x;
  cin >> a >> b >> x;


  while (a%x != 0) {
    a += (x-a%x);
  }
  while (b%x != 0) {
    b -= b%x;
  }

  ll cnt = b/x - a/x;


  cout << cnt+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b;
    cin >> a >> b;
    ll ans = a / __gcd(a, b) * b;
    cout << ans;
    
}

Measured memory_bytes: 256
import collections
N = int(input())
A = filter(lambda x: x%2 == 0,map(int,input().split()))
C = collections.Counter(A)
ans = 0
for key in C.keys():
    tmp = key
    count = 0
    while tmp%2 == 0:
        tmp //= 2
        count += 1
    ans += C[key]*count
print(ans)

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

    vector<int> inv(N+1);
    for(int i=1; i<N; i++) inv[i+1] = inv[i] + (P[i-1] > P[i]);
    
    set< pair<int, int> > S;
    for(int i=0; i<K; i++) {
        S.emplace(P[i], i);
    }

    int ans = 0;
    for(int i=0; i<=N-K; i++) {
        if(inv[i+K] - inv[i+1] == 0) {
            ans++;
            break;
        }
    }

    vector<bool> checked(N);
    for(int i=0; i<=N-K; i++) {
        if(inv[i+K] - inv[i+1] == 0) checked[i] = true;
    }
    
    for(int i=0; i<=N-K; i++) {
        if(!checked[i]) {
            // fprintf(stderr, "i = %d\n", i + 1);
            if(i == N - K) ans++;
            else {
                // fprintf(stderr, "%d %d\n", S.begin()->second, i);
                // fprintf(stderr, "%d %d\n", S.rbegin()->first, P[i+K]);
                // fprintf(stderr, "-----\n");
                bool ng = true;
                ng &= (S.begin()->second == i);
                ng &= (S.rbegin()->first < P[i+K]);
                if(!ng) ans++;
            }
        }
        
        S.erase(make_pair(P[i], i));
        
        if(i < N-K) {
            S.emplace(P[i+K], i+K);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int INF = 1 << 30;
    int r = INF;
    for (int i = 0; i < n; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T && c < r) {
            r = c;
        }
    }

    if (r == INF) {
        cout << "TLE" << endl;
    } else {
        cout << r << endl;
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] d = new int[k];
        boolean[] canGet = new boolean[n];
        for(int i = 0;i < k;i++) {
            d[i] = sc.nextInt();
            for(int j = 0;j < d[i];j++) {
                canGet[sc.nextInt() - 1] = true;
            }
        }
        
        int count = 0;
        for(int i = 0;i < canGet.length;i++) {
            if(!canGet[i]) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 46476
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
map<ll,ll>m;
void fillmap()
{
    for (ll i = -1000; i <= 1000; i++)
    {
        m[i * i * i * i * i] = i;
    }
}
int main()
{
    Run();
    fillmap();
   int n; cin >> n;
    for (ll i = -1000; i <= 1000; i++)
    {
        ll a = pow(i, 5) - n;
        ll b = m[a];
        if (pow(i, 5) - pow(b, 5) == n)
        {
            cout << i << " " << b;
            return 0;
        }
        
    }
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	string s;
  cin >> s;
  
  int flag = 0;
  for (int i = 0;i < s.length(); i++)
  {
   	 if (flag == 0 && s[i] == 'C')
       flag++;
    else if (flag == 1 && s[i] == 'F')
      flag++;
  }
	if (flag == 2)
      cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll ksm(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e5+10;
int n;
ll a[N];
ll fact[N],infact[N];

int main(){
	scanf("%d",&n);
	map<ll,ll>m1,m2;
	rep(i,1,n){
		scanf("%lld",&a[i]);
		m1[i-a[i]]++;
		m2[i+a[i]]++;
	}
	ll ans=0;
	rep(i,1,n){
		
		ll &x=m2[i+a[i]];
		ll &y=m1[i+a[i]];
		ans+=y;
		if(x){
			x--;
		}
	}
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 39576
n = int(input())
t = 0
x = 0
y = 0

for _ in range(n):
    nt, nx, ny = map(int, input().split())

    dt = nt - t
    dx = nx - x
    dy = ny - y

    distance = abs(dx) + abs(dy)
    if distance > dt:
        print('No')
        exit()
    
    left_over = nt - distance
    if left_over % 2 != 0:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    ll dp[n + 5][k + 5] = {};
    memset(dp, 0x3f, sizeof(dp));
    f1(k) {
        dp[0][i] = 0;
    }
    dp[0][0] = 0;
    ll v[n + 5] = {};
    f1 (n) {
        cin >> v[i];
        fr (j, 0, k + 1) {
            fr(z, 1, min(j + 1,i) + 1) {
                dp[i][j] = min(dp[i][j], dp[i-z][j-z+1] + max(0LL,v[i] - v[i-z]));
            }
            //cout << i <<' '<<j<<' '<<dp[i][j] << endl;
        }
    }
    ll mi = 1e18;
    f(n+1) {
        if (i + k >= n) {
            mi = min(mi, dp[i][k-n+i]);
        }
    }
    cout << mi << '\n';
}


Measured memory_bytes: 1024
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    map<string, int> m;
    for(int i=0; i<n; i++) {
        string si; cin >> si;
        if(m.count(si)==0) m[si] = 0;
        m[si] += 1;
    }
    int max_v = 0;
    for(auto mi:m) {
        if(max_v<mi.second) max_v = mi.second;
    }
    // sort(m.begin(), m.end(), std::greater<map<string, int>>());
    for(auto mi:m) {
        if(max_v==mi.second) cout << mi.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25344
import java.util.*;
import java.awt.geom.*;
public class Main {
	int res;
	boolean [] data;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			data = new boolean[3];
			res = 0;
			int outcount = 0;
			while(outcount!= 3){
				String s = sc.next();
				if(s.charAt(0) == 'O') outcount++;
				else solve(s);
			}
			System.out.println(res);
		}
	}

	private void solve(String s) {
		if(s.charAt(1) == 'I'){
			//hit
			if(data[2]){
				res++;
			}
			data[2] = data[1];
			data[1] = data[0];
			data[0] = true;
		}
		else{
			//homeran
			for(int i = 0; i < 3; i++){
				if(data[i]){
					res++;
					data[i] = false;
				}
			}
			res++;
		}
	}

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

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC120A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().SplitTryParseToList<int>();

            var a = line[0] * line[2] <= line[1] ? line[2] : (int)Math.Floor((double)line[1] / (double)line[0]);

            WriteLine(a);
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 12500
N = int(input())

i = 0
answer = []
while True:
    if N == 0:
        break
    if N % ((-2)**(i + 1)) != 0:
        answer.append(1)
        N -= (-2)**i
        if N == 0:
            break
    else:
        answer.append(0)
    i += 1

print(''.join(map(str,reversed(answer))) if len(answer) != 0 else '0')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
#define mod 1e18+1
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l, m;
    cin >> n;
    ll gun = 1;
    ll maxi = -1;
    long double res = 0.00000;
    int flag = 0;
    vector<ll> data;
    for (i = 1; i <= n;i++){
        cin >> k;
        data.pb(k);
        if(k==0){
            flag = 1;
        }
    }
    if(flag==1){
        cout << "0\n";
        return 0;
    }
    for(auto x:data){
        res += (long double)(log10f((long double)x));
    }
    ///cout << res << "\n";
    long double temp = 18;
    if(res>temp)
        cout << "-1\n";
    else{
        for(auto x:data)
            gun *= x;
        ll bash = 1e18;
        if(gun>bash){
            cout << "-1\n";
        }
        else
            cout << gun << "\n";
    }
    return 0;
}

Measured memory_bytes: 4320
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
using namespace std;

#define ll                    long long int
#define ull                   unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>
const ll MOD = 998244353;

ll modpow(ll a, ll b, ll mod) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res%=mod; a = a * a; a%=mod; }return res; }
//ll p(ll a, ll b) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a;a = a * a; }return res; }

struct dsu {
    vector<ll> p,sum,minn,maxx,r;
    dsu(int n) {
        loop(i,0,n+1) {
            p.pb(i); sum.pb(i); minn.pb(i); maxx.pb(i); r.pb(0);
        }
    }
    int get(int a) {
        return (p[a] = (p[a]==a)?a:get(p[a]));
    }
    void uni(int a, int b) {
        a = get(a); b = get(b);
        if(a==b) return;
        if(r[a]==r[b]) r[a]++;
        if(r[a] < r[b]) swap(a,b);
        p[b] = a;
        sum[a] += sum[b];
        minn[a] = min(minn[a], minn[b]);
        maxx[a] = max(maxx[a],maxx[b]);
    }
};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */
    int n; cin >> n;
    ll ans = 0;
    loopl(i,1,n) {
        ans += n/i; if(!(n%i)) ans--; 
    }
    cout << ans << "\n";
    /* end code */
}

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

// Taken from Loveless AtCoder

bool goodPrice(int price, int a, int b){
	return(
		  price * 8/100 == a and price * 10/100 == b
		);
}

int main(){

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

	int m = max(a*100/8, b*100/10);

	for(int i=1; i< 2*m; i++){
		if(goodPrice(i, a, b)){
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    pair<int, int> p[n];
    rep(i, n) {
        cin >> a[i] >> b[i];
        p[i] = make_pair(b[i], a[i]);
    }
    sort(p, p+n);
    
    int t = 0;
    rep(i, n) {
        t += p[i].second;
        if(p[i].first < t) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes";

    cout << endl;
    return 0;   
}    

Measured memory_bytes: 3328
#include<stdio.h>

int main(void){
    int a,b;

    scanf("%d %d",&a, &b);

    if(a <= 9 && a >= 1 && b <= 9 && b >= 1){
        printf("%d", a*b);
    }else{
        printf("-1");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

int main(){
    int h, w;
    cin >> h >> w;
    char a[h][w];
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
        }
    }
    vector<bool> d(h, false);
    vector<bool> f(w, false);
    REP(i, h){
        int count = 0;
        REP(j, w){
            if(a[i][j] == '#'){
                break;
            }else{
                count++;
            }
            if(count == w){
                d[i] = true;
            }
        }
    }
    REP(i, w){
        int count = 0;
        REP(j, h){
            if(a[j][i] == '#'){
                break;
            }else{
                count++;
            }
            if(count == h){
                f[i] = true;
            }
        }
    }
    REP(i, h){
        REP(j , w){
            if(!d[i] && !f[j]){
                cout << a[i][j];
            }
        }
        if(!d[i]){
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256