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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int n;
int a[N];
pii b[N];

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	forn(i, n) {
		scanf("%d", &a[i]);
		b[i] = mp(a[i], i);
	}
	sort(b, b + n);
	int ans = 0;
	forn(i, n) {
		if (!(i & 1) && (b[i].sc & 1)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1536
while True:
	h,m,s = map(int, raw_input().split())
	if h + m + s == -3: break
	ans = 120 * 60 - s - m * 60 - h * 3600

	s = ans % 60
	ans -= s
	h = ans / 3600
	ans -= h * 3600
	m = ans / 60

	h2 = 0
	m2 = 0
	s2 = s * 3
	if s2 > 60:
		m2 += s2 / 60
		s2 = s2 % 60
	m2 += m * 3
	if m2 > 60:
		h2 += m2 / 60
		m2 = m2 % 60
	h2 += h * 3

	print ":".join(map(str,['%02d' % h,'%02d' % m,'%02d' % s]))
	print ":".join(map(str,['%02d' % h2,'%02d' % m2,'%02d' % s2]))

Measured memory_bytes: 4240
#include<iostream>

using namespace std;

int main() {
	char* S = new char[6];
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll n;cin>>n;
  vl p(n+1);
  rep(i,n)cin>>p[i+1];
  vl q(n+1);
  for(ll i=1;i<=n;i++)q[p[i]]=i;
  vl a(n+1),b(n+1);
  a[1]=1;
  b[1]=1000000000LL;
  for(ll i=2;i<=n;i++){
    a[i]=a[i-1]+1;
    b[i]=b[i-1]-1;
    ll d=q[i]-q[i-1];
    if(d>0)a[i]+=d;
    else b[i]+=d;
  }
  for(ll i=1;i<=n;i++){
    cout<<a[i];
    if(i!=n)cout<<" ";
    else cout<<endl;
  }
  for(ll i=1;i<=n;i++){
    cout<<b[i];
    if(i!=n)cout<<" ";
    else cout<<endl;
  }
}

Measured memory_bytes: 1280
import math
from collections import Counter
def ip():return int(input())
def imp():return map(int,input().split())
def impstr():return map(str,input().split())
def limp():return list(map(int,input().split()))
def limpstr():return list(map(str,input().split()))

n=ip()
l=limp()
if 1 in l:
    if l.count(1)==1:print(1)
    else:print(0)
    exit()
else:
    mark=[0]*(10**6+5)
    for x in l:
        if mark[x]>=1:   #X已经出现了一次
            mark[x]=2
            continue
        mark[x]=1
        i=2
        while x*i<10**6+1:
            mark[x*i]=2
            i+=1
    ans=0
    for x in l:
        if mark[x]==1:ans+=1
    print(ans)



Measured memory_bytes: 126240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long T, vector<long long> A){
	ll cnt = 1, min = A[0], re = 0;
	repn(i, N-1) {
		if (A[i] < min) min = A[i];
		if (A[i] - min == re) {
			cnt++;
		}
		if (A[i] - min > re) {
			re = A[i] - min;
			cnt = 1;
		}
	}
	cout << cnt << endl;
}

int main(){	
	long long T;
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	scanf("%lld",&T);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, T, A);
	return 0;
}



Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInt()
	b := nextInt()
	if n*a < b {
		fmt.Println(n * a)
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,r;
  cin>>n>>r;
  cout<<r+(100*max((int)0,10-n))<<endl;
  

  return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO()
main = do
    s<-getLine
    let a:b:[]=(map (\x -> read x ::Int) . words) s
    let ans 
            | a==b = "a == b"
            | a<b = "a < b"
            | a>b = "a > b"
    putStrLn ans


Measured memory_bytes: 3676
import math

P = []
# 素数一覧リスト
Max = 1000000

def Era(P, Max) :
    D = list(range(2, Max))
    limit = math.sqrt(Max)
    while True :
        p = D[0]

        if limit <= p :
            P += D
            return P

        P.append(p)
        D = [d for d in D if d % p != 0]
        # D に含まれる値かつ p で割り切れない値をリスト化

Era(P, Max)

while True :
    try :
        n = int(input())

        if n == 1 :
            print(0)
        elif n == 2 :
            print(1)
        elif n >= max(P) :
            print(len(P))
        else :
            for i in range(n + 1) :
                if P[i] == n :
                    print(i + 1)
                    break
                elif P[i] > n :
                    print(i)
                    break

    except :
        break


Measured memory_bytes: 49560
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long mod = 1000000007;
const long long MOD = 998244353;

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

	ll n;
	cin >> n;

	deque<int> que;
	if (n == 0) {
		cout << 0 << "\n";
	}
	else {
		while (n) {
			if (n % (-2)) {
				que.push_front(1);
				--n;
			}
			else {
				que.push_front(0);
			}

			n /= (-2);
		}
	}

	while (!que.empty()) {
		cout << que.front();
		que.pop_front();
	}
	cout << "\n";

	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val a = scanner.nextLong()
	val b = scanner.nextLong()
	var gcd = euc(a, b)

	if (gcd==1L) fin(1)

	var cnt = 1
	val ps = mutableListOf(2L, 3L, 5L)
	for (p in ps) {
		if (gcd%p==0L) {
			cnt++
			while (gcd%p==0L) gcd /= p
		}
		if (gcd==1L) fin(cnt)
	}
	for (v in 7L..1000000L) {
		if (v*v>gcd) {	//gcdは素数
			fin (cnt+1)
		}
		val vMod = v%6
		if (vMod==1L || vMod==5L) {
			for (p in ps) {
				if (v%p==0L) break
				if (p*p>v) {	//vは素数
					ps.add(v)
					if (gcd%v==0L) {
						cnt++
						while(gcd%v==0L) gcd /= v
					}
					if (gcd==1L) fin(cnt)
					break
				}
			}
		}
	}
	println(cnt)
}

fun fin(cnt: Int) {
	println(cnt)
	exitProcess(0)
}

fun euc(a: Long, b: Long): Long {
	var a = a
	var b = b
	if (a < b) {    //a>=bほしょー
		val c = a
		a = b
		b = c
	}
	while (a%b != 0L) {
		val c = a % b
		a = b
		b = c
	}
	return b
}

Measured memory_bytes: 38144
#include <iostream>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

#define MAX_E 500001
#define MAX_V 100001
#define INF INT_MAX

struct edge {
    int to;
    int cost;
};
vector<edge> G[MAX_V];

/*
 * ?¬¬????????°:????????????????¬¬????????°??§??¨???????????????????????§???cost
 * ?¬¬????????°:??°????????????
 */
typedef pair<int, int> P;

//???????????????????????????????????????????°?cost???????´??????????
int cost[MAX_V];

void Dijkstra(int start) {
    
    //????????????????????\??????cost???????????????????????????
    priority_queue<P, vector<P>, greater<P> > que;
    
    //?????????
    fill(cost, cost + MAX_V, INF);
    cost[start] = 0;
    que.push(P(0, start));
    
    while(!que.empty()) {
        P p = que.top(); que.pop();
        
        //v?????°????????????
        int v = p.second;
        
        /*
         * ?????¨?????§????±???????????????????v?????§???????°??????¨???start??????v?????§???????????????????????????
         * ???????????¶?????????????????´??????v?????¢????¨??????????????¢???????????????§??????
         */
        if (cost[v] < p.first) continue;
        
        /*
         * v??????????????????????????????e.to???????????????
         * ?????¨?????§????±???????????????????????°?????????´??°????????§????????°??´??°????????????
         * ??´??°????????§????????°???e.to???????????????????????????????????¨??????cost?????´??°???????????????
         * ??????????????\???????????????e.to???????´???????
         */
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (cost[e.to] > cost[v] + e.cost) {
                cost[e.to] = cost[v] + e.cost;
                que.push(P(cost[e.to], e.to));
            }
        }
    }
}

int main( ){
    
    int i, V, E, r, u, v, c;
    edge tmp;
    cin >> V >> E >> r;

    for (i = 0; i < E; i++) {
        cin >> u >> v >> c;
        tmp.cost = c;
        tmp.to = v;
        G[u].push_back(tmp);
    }
    
    Dijkstra(r);
    
    for (i=0; i<V; i++) {
        if (cost[i] == INF) {
            cout << "INF" << endl;
        }else{
            cout << cost[i] << endl;
        }
    }
    
    return 0;
}

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

int main() {
        double m, n, a, s[1000];
        for(int j = 0; j < 100; j++) {
                cin >> n;
                if(n == 0) break;
                m = 0;
                a = 0;
                for(int i = 0; i < n; i++) {
                        cin >> s[i];
                        m += s[i];
                }
                m /= n;
                for(int i = 0; i < n; i++) {
                        a += pow(s[i] - m, 2);
                }
                a /= n;
                cout << sqrt(a) << endl;
        }
        return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, x; cin >> N >> x;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    ll ans = 0;
    if(a[0] > x){ ans += a[0]-x; a[0] = x; }
    for(int i=1; i<N; i++){
        if(a[i]+a[i-1] > x){
            ans += a[i]+a[i-1]-x;
            a[i] = x-a[i-1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

const long long INF = 1e18;

long long f(long long b, long long n) {
    return n < b ? n : f(b, n/b) + n % b;
}

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    long long n, s;
    std::cin >> n >> s;
    if (n < s) {
        std::cout << -1 << '\n';
    } else if (n == s) {
        std::cout << n + 1 << '\n';
    } else {
        for (long long i = 2; i * i <= n; ++i) {
            if (f(i, n) == s) {
                std::cout << i << '\n';
                return 0;
            }
        }
        long long ans = INF;
        for (long long i = 1; i * i <= n; ++i) {
            long long b = (n - s) / i + 1;
            if (b >= 2 && f(b, n) == s) {
                ans = b < ans ? b : ans;
            }
        }
        std::cout << (ans == INF ? -1 : ans) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long a, b;
    cin >> a >> b;
 
    long long ans;
    for (long long i = 1; i <= b; i++) {
        if ((i * a) % b == 0) {
            ans = i * a;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import queue
from collections import defaultdict
import copy

N,M=map(int,input().split())
A=list(map(int,input().split()))
ma=[2,5,5,4,5,6,3,7,6]
BA=[[0,0] for _ in range(M)] #(必要本数，-1*数字)
for i in range(M):
    BA[i][1]=-1*A[i]
    BA[i][0]=ma[A[i]-1]
    
BA.sort()

#同じ本数使うものを消去
can=[]
ii=0
while ii <len(BA):
    if BA[ii][0] in can:
        BA.pop(ii)
    else:
        can.append(BA[ii][0])
        ii+=1
M=len(BA)#Mの書き換え

diff=[0]*M#数字変更の際に追加で必要な本数
for i in range(M):
    diff[i]=BA[i][0]-BA[0][0]
    BA[i][1]=BA[i][1]*-1#(必要本数，数字)に直しておく

fi=BA[0]###
#BA.sort(key=lambda x: x[1]*-1)#数字の大きいもの順


    
p=[1]*(N+1)
for i in range(N):
    p[i+1]=p[i]*10

#数字のセットL(sort済み)から作れる最大の数値を出力
def set_to_num(L):
    ans=0
    for i in range(len(L)):
        ans+=L[i]*p[i]
    return ans

#2つの配列を合わせる
def make_set(temp,L):
    ori=copy.deepcopy(temp)
    for i in range(len(L)):
        ori[i]=L[i]
    ori.sort()
    return ori
    

#dd用hash
def make_h(L):
    h=0
    for i in range(len(L)):
        h+=p[i]*L[i]
    return h
    
    
ans=-1
Max_dig=N//fi[0]

for d in range(Max_dig):#減らす桁数
    dig=Max_dig-d
    rem=N-fi[0]*dig
    temp=[fi[1]]*dig
    dd = defaultdict(int)
    q=queue.Queue()
    q.put((rem,[]))#残り本数，入れ替える数字
    
    while not q.empty():
        rem2,L=q.get()
        if rem2==0:
            #print(temp,L)
            LLL=make_set(temp,L)
            #print(LLL)
            ans=max(ans,set_to_num(LLL))
        else:
            for i in range(1,M):#変更候補の数字を見ていく.0番は自身のためのぞく
                if rem2>=diff[i]:
                    LL=copy.deepcopy(L)
                    LL.append(BA[i][1])
                    if len(LL)<=len(temp):
                        LL.sort()
                        h=make_h(LL)
                        if dd[h]==0:
                            q.put((rem2-diff[i],LL))
                            dd[h]=1
    if ans!=-1:
        break
        
print(ans)    

Measured memory_bytes: 62680
a1, a2, a3 = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]

var1 = []
var2 = []
var3 = []

for bb in b:
    if bb in a1:
        var1.append(a1.index(bb))

    elif bb in a2:
        var2.append(a2.index(bb))
    elif bb in a3:
        var3.append(a3.index(bb))

#たて
if 0 in var1 and 0 in var2 and 0 in var3 or 1 in var1 and 1 in var2 and 1 in var3 or 2 in var1 and 2 in var2 and 2 in var3 :
    print("Yes")

#よこ
elif 0 in var1 and 1 in var1 and 2 in var1 or 0 in var2 and 1 in var2 and 2 in var2 or 0 in var3 and 1 in var3 and 2 in var3 :
    print("Yes")

#ななめ
elif 0 in var1 and 1 in var2 and 2 in var3 or 2 in var1 and 1 in var2 and 0 in var3:
    print("Yes")

else : 
    print("No")

Measured memory_bytes: 3064
import java.util.*;

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

    int n = sc.nextInt();
    int[] d = new int[n];
    int ans = 0;
    
    for(int i = 0; i < n; i++){
      d[i] = sc.nextInt();
    }

    for(int i = 0; i < n; i++){
      for(int j = 1; j < n - i; j++){
        ans += d[i] * d[i + j];
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21076
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())

a = np.array(input().split(), dtype='int')

sum_a = np.sum(a)

b = np.sort(a)[::-1]

if b[m-1] >= sum_a / 4 / m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct nod{int p,l,r;long long w;nod(int p=0,int l=0,int r=0,long long w=0):p(p),l(l),r(r),w(w){}}a[2000005];
bool operator<(nod a,nod b){return a.p<b.p;}
int n,m,L[5005],R[5005],cur=1,t;long long s[5005],c[5005],ans,dis[5005],b[5005][205];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=2;i<=n;i++) scanf("%lld",&dis[i]),dis[i]+=dis[i-1];
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lld",&b[i][j]);
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++) for(L[j]=j-1;L[j]>=1&&b[L[j]][i]<b[j][i];L[j]=L[L[j]]);
		for(int j=n;j>=1;j--) for(R[j]=j+1;R[j]<=n&&b[R[j]][i]<b[j][i];R[j]=R[R[j]]);
		for(int j=1;j<=n;j++) a[++t]=nod(L[j]+1,j,R[j]-1,b[j][i]),a[++t]=nod(j+1,j,R[j]-1,-b[j][i]);
	}
	sort(a+1,a+t+1);
	for(int i=1;i<=n;i++)
	{
		for(memset(c,0,sizeof(c));cur<=t&&a[cur].p==i;cur++) c[a[cur].l]+=a[cur].w,c[a[cur].r+1]-=a[cur].w;
		for(int j=1;j<=n;j++) c[j]+=c[j-1],s[j]+=c[j],ans=max(ans,j<i?ans:s[j]-dis[j]+dis[i]);
	}
	printf("%lld\n",ans);
}

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

d = {}

for i in range(N):
    d[A[i]] = 0

for i in range(N):
    d[A[i]] += 1

dd = sorted(d.items(),key= lambda x:x[1] )

c = len(d)
ret = 0
for i in range(N):
    if c <= K:
        break
    c -= 1
    ret += dd[i][1]
print(ret)


Measured memory_bytes: 38964
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=3e5+10,MOD=998244353;
int main (){
    int M,D,res=0;cin >> M >> D;
    for(int i=1;i<=M;i++){
        for(int j=10;j<=D;j++){
            int one = j%10;
            int ten = j/10;
            if(one * ten ==i && one>=2&&ten>=2){res++;}
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T;qq++)
    {
        ll n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        if(a>b)swap(a,b);
        n--;
        b+=n*c;
        for(ll i=0;i<=n;i++){
            if(a-b>=0&&a-b<=n*(d-c))return cout<<"YES"<<endl,0;
            a+=d,b-=c;
        }
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int R = scan.nextInt();

        if (H + R > 0) {

            System.out.println("1");

        } else if (H + R < 0) {

            System.out.println("-1");

        } else {
            System.out.println("0");

        }

    }

}



Measured memory_bytes: 26100
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
    ll R; cin >> R;
    cout<<setprecision(10)<< 2.0* M_PI*R<<endl;
    return 0;
}


Measured memory_bytes: 3812
n = int(input())
t, a = map(int,input().split())
beta = 0.006
H = list(map(int,input().split()))
import numpy as np 
H = np.array(H) 
use = t - beta * H - a 
use = use**2 
pre_answer = min(use)
use = list(use) 
ans = 1 + use.index(pre_answer) 
print(ans)

Measured memory_bytes: 30772
N,M,X = map(int, input().split())
A = list(map(int, input().split()))
S = [0]*N
for i in range(M):
    S[A[i]] = 1
sum_l = sum(S[0:X+1])
sum_r = sum(S[X+1:N])
print(min(sum_l,sum_r))

Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int ans[26];
        for(int i=0;i<26;i++){
                ans[i]=0;
        }
//      for(;;){
        char c;
        while(scanf("%c",&c)!=EOF){
//              scanf("%c",&c);
//              if(c==EOF) break;
                c=tolower(c);
                int chk=c-'a';
                if(chk>=0 && chk<27){
            ans[chk]+=1;
                }
        }
        for(int i=0;i<26;i++){
                printf("%c : %d\n",char(i+97),ans[i]);
        }
        return 0;
}

Measured memory_bytes: 1128
import java.util.Scanner;

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

		if(a.equals("a") || a.equals("e") || a.equals("i") || a.equals("o") || a.equals("u")) {
			System.out.println("vowel");
		}
		else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[222222];
map<int,ll> ma;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
	}
	
	int lo=0;int hi=n-1;
	vector<ii> vec;
	
	for(int i=0;i<n;i++)
	{
		vec.pb(mp(a[i],i));
	}
	
	ll tot = (ll(n)*ll(n+1))/2;
	int res=0;
	ll med = tot/2+1;
	sort(vec.begin(),vec.end());
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;
		int val=vec[mid].fi;
		ll ans = 0;
		vector<int> V;
		for(int i=0;i<n;i++)
		{
			if(a[i]<=val)
			{
				V.pb(1);
			}
			else V.pb(-1);
		}
		//# of subsegments with sum > 0
		pbds T; int timer=0; int sum=0;
		T.insert(mp(sum,timer++));
		for(int i=0;i<n;i++)
		{
			sum+=V[i];
			ans+=T.order_of_key(mp(sum,-1));
			T.insert(mp(sum,timer++));
		}
		//cerr<<val<<' '<<ans<<' '<<med<<'\n';
		if(ans>=med)
		{
			res=mid; hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<vec[res].fi<<'\n';
}


Measured memory_bytes: 8160
N = int(input())
x = []
s = input()
x = s.split()
y = len(x)
summ1 = 0
summ2 = 0
sr = 0
setx = set(x)
h = len(setx)
if N == 1:
    print("0")
else:
    if h == 0:
        print("0")
    else:
        for i in range(y):
            x[i] = int(x[i])
            sr = sr + x[i]
        PMA = (sr//N)+1
        PMM = sr//N
        for i in range(y):
            summ1 = summ1 + ((x[i]-PMA)*(x[i]-PMA))
        for i in range(y):
            summ2 = summ2 + ((x[i] - PMM) * (x[i] - PMM))
        if summ2 > summ1:
            print(summ1)
        else:
            print(summ2)


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

void swap(int *x, int *y)
{
	int tmp;
	if(*x > *y) {
		tmp = *y;
		*y = *x;
		*x = tmp;
	}
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	swap(&a, &b);
	swap(&a, &c);
	swap(&b, &c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3104
from collections import defaultdict

class TreeNode:
  def __init__(self, val):
    self.val = val
    self.left = None
    self.right = None
    self.parent = -1


preorder, inorder, postorder = [], [], []

def preorder_dfs(root):
  if root is None: return

  preorder.append(root.val)

  preorder_dfs(root.left)
  preorder_dfs(root.right)

def inorder_dfs(root):
  if root is None: return

  inorder_dfs(root.left)

  inorder.append(root.val)

  inorder_dfs(root.right)


def postorder_dfs(root):
  if root is None: return 
  
  postorder_dfs(root.left)
  postorder_dfs(root.right)

  postorder.append(root.val) 


num = int(input())
nodes = defaultdict(int)

for i in range(num):
  val, left, right = list(map(int, input().split()))

  if nodes[val] == 0:
    nodes[val] = TreeNode(val)
  n = nodes[val]
  
  if left != -1:
    # initalize treenode
    if nodes[left] == 0:
      nodes[left] = TreeNode(left)

    # appending to n.left
    n.left = nodes[left]
    n.left.parent = n.val

  if right != -1:
    if nodes[right] == 0:
      nodes[right] = TreeNode(right)

    n.right = nodes[right]
    n.right.parent = n.val

root = [node for node in nodes.values() if node.parent == -1][0]

preorder_dfs(root)
inorder_dfs(root)
postorder_dfs(root)

print("Preorder")
print(" " + " ".join([ str(i) for i in preorder]))
print("Inorder")
print(" " + " ".join([ str(i) for i in inorder]))
print("Postorder")
print(" " + " ".join([ str(i) for i in postorder]))


Measured memory_bytes: 6008
extern crate proconio;
use proconio::input;
fn main() {
    input!{
        n: usize,
        q: usize,
        query: [(u64, usize); q],
    }

    let arr = vec![n-2; 200000];
    let mut tree_x = DualSegmentTree::new(n-2, &arr, n-2, std::cmp::min, n-2, std::cmp::min);
    let mut tree_y = DualSegmentTree::new(n-2, &arr, n-2, std::cmp::min, n-2, std::cmp::min);

    let mut ans = ((n-2)*(n-2)) as u64;
    for i in 0..q {
        match query[i] {
            (1, t) => {
                let mx = tree_y.get(t-2) as u64; 
                ans -= mx;
                tree_x.range_query(0, mx as usize, t-2);
            },
            (2, t) => {
                let mx = tree_x.get(t-2) as u64;
                ans -= mx;
                tree_y.range_query(0, mx as usize, t-2);
            },
            (_, _) => panic!(),
        }
    }

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

struct DualSegmentTree<R, S, T, U>{
    elements: Vec<R>,
    size: usize,
    unite: T,
    operator: Vec<S>,
    unit: S,
    composite: U,
}

impl<R, S, T, U> DualSegmentTree<R, S, T, U> 
    where 
        R: Copy,
        S: Copy,
        U: Fn(S, S) -> S,
        T: Fn(R, S) -> R,
{
    pub fn new(unit_e: R, arr: &Vec<R>, n: usize, unite: T, unit_op: S, composite: U ) -> DualSegmentTree<R, S, T, U>{
        let mut size: usize = 1;
        while size < n  {
            size <<= 1;
        }
        let mut elements = vec![unit_e; size];
        for i in 0..n {
            elements[i] = arr[i];
        }
        let unit = unit_op;
        let operator = vec![unit; 2*size];
        DualSegmentTree{
            elements,
            size,
            unite,
            operator,
            unit: unit_op,
            composite,
        }
    }

    // [l, r)での関数をセットする.
    pub fn range_query(&mut self, l: usize, r: usize, op: S) {
        if l != r {
            self.sub_range(0, self.size, l, r, op);
        }
    }

    fn sub_range(&mut self, min: usize, max: usize, l: usize, r: usize, op: S){
        let mid = (min + max)/2;
        if l == min && r == max {
            self.operator[self.size/(r-l) + l/(r-l)] = (self.composite)(op, self.operator[self.size/(r-l) + l/(r-l)]);
        }else{
            if l < mid && mid < r{
                self.sub_range(min, mid, l, mid, op) ; self.sub_range(mid, max, mid, r, op) ;
            }else if mid <= l {
                self.sub_range(mid, max, l, r, op)
            }else if r <= mid {
                self.sub_range(min, mid, l, r, op)
            }else{
                panic!("invalid input: min: {}, max: {}, l: {}, r: {}", min, max, l, r );
            }
        }
    }

    pub fn get(&self, index: usize) -> R{
        (self.unite)(self.elements[index], self.sub_get(index + self.size))
    }

    fn sub_get(&self, index: usize) -> S {
        if index == 0 {
            self.unit
        }else{
            (self.composite)(self.operator[index], self.sub_get(index >> 1))
        }
    }

    // pub fn debug(&self) {
    //     println!("{:?}", self.operator);
    // }
}

Measured memory_bytes: 20712
#!/usr/bin/env python3

N = int(input())
# S = input()
# N, K = map(int, input().split())
P = list(map(int, input().split()))

def main():
    ans = 0
    for i, p in enumerate(P, 1):
        if i == p:
            ans += 1
            if i != N:
                P[i] = p
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14004
import sys
def input(): return sys.stdin.readline().rstrip()


def kaisuu(moto, shitai):
    return (moto-1) // shitai


def is_ok(arg, dlist, k):
    # 条件を満たすかどうか？問題ごとに定義
    num = map(lambda x: kaisuu(x, arg), dlist)
    return sum(num) <= k


def meguru_bisect(ng, ok, dlist, k):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, dlist, k):
            ok = mid
        else:
            ng = mid
    return ok


def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    print(meguru_bisect(0, 10**9+1, A, k))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i=0; i<n; i++){
        if(s == t) {
            out("Yes");
            return 0;
        }
        s = s.back() + s.substr(0, s.size()-1);
    }
        out("No");
        return 0;
    
}

Measured memory_bytes: 256
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
  	
	int a, b;
	cin >> a >> b;
	if((a + b) % 2)puts("IMPOSSIBLE");
	else cout << (a + b) / 2 << '\n';
    return 0;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key === arr[mid]) return 1;
    else if (key < arr[mid]) right = mid;
    else  left = mid + 1;
    //else return 1;
  }
  return 0;
}


(function() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34936
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, v[Nmax], s;

int main()
{
    cin >> n;
    for (int i=1;i<=3 * n;i++) cin >> v[i];
    sort(v+1,v+3*n+1);
    for (int i=3 * n - 1;i>n;i -= 2) s += v[i];
    cout << s;

    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int h, w; gi(h); gi(w);
	if(h==1 || w==1) print(1);
	else print(1ll*((h+1)/2)*((w+1)/2)+1ll*(h/2)*(w/2));
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="776755555555555555555555555555555555555554555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int maxtime(int x)
{
    return (x + 9) / 10 * 10;
}
int remtime(int x)
{
    return maxtime(x) - x;
}
int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
    sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
    cout << sum << endl;
    return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */

int rec(int i)
{
    if(i==1) return 1;
    else
        return i*rec(i-1);
}

signed main() 
{
    int n; cin >> n;
    string s;
    ll cnt=0;
    ll m=0,a=0,r=0,c=0,h=0;
    REP(i,n)
    {
        cin >> s;
        if(s[0]=='M') m++;
        else if(s[0]=='A') a++;
        else if(s[0]=='R') r++;
        else if(s[0]=='C') c++;
        else if(s[0]=='H') h++;
    }
    cnt+=m*a*r;
    cnt+=m*a*c;
    cnt+=m*a*h;
    cnt+=m*r*c;
    cnt+=m*r*h;
    cnt+=m*c*h;
    cnt+=a*r*c;
    cnt+=a*r*h;
    cnt+=a*c*h;
    cnt+=r*c*h;

    cout << cnt << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n){
        string s;
        cin >> s;
        if(s=="AC") a[0]++;
        else if(s=="WA") a[1]++;
        else if(s=="TLE") a[2]++;
        else if(s=="RE") a[3]++;
    }
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <random>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;

	FOR(i, 1, n) {
		int cnt = 0;

		for (char c = 'a'; c <= 'z'; c++) {
			bool x = false, y = false;

			REP(j, i)if (s[j] == c)x = true;
			FOR(j, i, n)if (s[j] == c)y = true;
			if (x&&y)cnt++;
		}

		ans = ans < cnt ? cnt : ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = input()

for i in n:
	if i == '1':
		print(9, end="")
	elif i == '9':
		print(1, end="")
	else:
		print(i, end="")


Measured memory_bytes: 5384
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = []
for i in range(M):
    PX.append(list(map(int,input().split())))
s = sum(T)
for i in range(M):
    print(s-T[PX[i][0]-1]+PX[i][1])


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

ll modpw(ll x, ll k) { 
	ll res = 1;
	while (k != 0) {
		if (k & 1) res = res*x % MOD;
		x = x*x % MOD;
		k = k >> 1;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	cout<<modpw(n,m)<<endl;
}




Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;

const int N = 3e5+1000;
#define ll long long
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define sread(x,y,z) scanf("%d%d%d",&x,&y,&z)
ll w[N];
ll cnt[64];
inline ll fast_mul(ll a, ll b, ll Mod)
{
    ll c = a*b-(ll)((long double)a*b/Mod+0.5)*Mod;
    return c<0 ? c+Mod : c;  //就是算的a*b%Mod;
}
int main()
{
    int n,m;
    read(n);
    for(int i = 1;i <= n;++i){
        scanf("%lld",&w[i]);
        for(int j = 0;j <= 62;++j){
            cnt[j] += (w[i]>>j)&1;
        }
    }
    ll sum = 0;
    ll mod = 1e9 + 7LL;
    for(int i = 0;i <= 62;++i){
        sum += fast_mul(fast_mul(cnt[i],n-cnt[i],mod),(1LL<<i),mod);
        sum %= mod;
    }
    cout<<sum<<endl;

}

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

int main()
{
    int h,a, ans;
    cin >> h >> a;
    ans = 0;
    while(h>0){
        h-=a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
nowp = 0
nowg = 0
ans = 0

for i in range(n):
    if s[i] == "g":
        if nowp < nowg:
            nowp += 1
            ans += 1
        elif nowp == nowg:
            nowg += 1
    elif s[i] == "p":
        if nowp < nowg:
            nowp += 1
        elif nowp == nowg:
            nowg += 1
            ans -= 1
print(ans)

Measured memory_bytes: 39792