akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < n; ++i)

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<bool> used(m * 2);
  vector<ll> one_cycle;

  int start = 0;
  ll now = x;
  rep(i, 0, n) {
    used[now] = true;
    one_cycle.push_back(now);
    now = now * now % m;
    if (used[now]) {
      rep(j, 0, one_cycle.size()) if (one_cycle[j] == now) {
        start = j;
        break;
      }
      break;
    }
  }

  ll s1 = 0, s2 = 0, loop = one_cycle.size() - start;
  rep(i, 0, start) s1 += one_cycle[i];
  rep(i, start, one_cycle.size()) s2 += one_cycle[i];
  ll ans = s1 + (n - start) / loop * s2;
  rep(i, 0, (n - start) % loop) {
    ans += now;
    now = now * now % m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3912
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
gcd=math.gcd

def is_primes(n):
    primes = [1]*n
    primes[0] =0
    primes[1] =0
    for i in range(2,int(n**0.5)+2):
        if primes[i] ==1:
            for j in range(2*i,n,i):
                primes[j] = 0
    return primes
def factorize(n,primes):
    fct = [(1,1)]
    for b in primes:#primes ::sorted
        if b**2 > n:
            break
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
    if n > 1:
        fct.append((n,1))
    return fct

n =ni()
A = lma()
mx= 10**6+10
prms = is_primes(mx)
prms2=[i for i in range(mx) if prms[i]]
#print(prms2)
d=collections.Counter()
for a in A:
    fct = factorize(a,prms2)
    #print(fct)
    for fc,cnt in fct:
        if fc==1:continue
        d[fc]+=1

f1=True # pp or sp
f2=True # sp or not p
for num,cnt in d.items():
    if cnt==n:
        f2=False #numが全体で共通の約数になる not coprime
        break
    else:
        if cnt==1:## 素
            pass
        else:
            f1=False

if f2==False:
    print("not coprime")
elif f1:
    print("pairwise coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 201784
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int X, Y; cin >> X >> Y;
    REP(i, 0, X + 1) {
        if (2 * i + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const ll    MOD = (ll)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


template<typename T>
inline vector<T> cin_vector(const size_t n) {
     vector<T> vec;
    vec.reserve(n);
    REP(i, n) {
        T element; cin >> element;
        vec.push_back(element);
    }
    return vec;
}

template<typename T>
inline vector< vector<T> > cin_matrix(const size_t m, const size_t n) {
    vector< vector<T> > matrix;
    matrix.reserve(m);
    REP(i, m) {
        vector<T> vec = cin_vector<T>(n);
        matrix.push_back(vec);
    }
    return matrix;
}

template<typename T>
inline void cout_vector(const vector<T>& vec) {
    REP(i, SZ(vec)-1) {
       cout << vec[i] << ' ';
    }
    cout << vec[SZ(vec)-1] << endl;
}

template<typename T>
inline void cout_matrix(vector< vector<T> > matrix) {
    for(const vector<T>& vec : matrix) {
         cout_vector<T>(vec);
    }
}

ll mod_pow(ll b, ll e) {
    ll ret = 1;
    while (e != 0) {
        if (e % 2 == 1) ret = (ret * b) % MOD;
        b = (b * b) % MOD;
        e /= 2;
    }
    return ret;
}

vector<ll> mod_invtable(ll max) {
    vector<ll> ret({1});
    ll fact = 1;
    FOR(n, 1, max + 1) {
        fact = (fact * n) % MOD;
        ll inv = mod_pow(fact, MOD - 2);
        ret.push_back(inv);
    }
    return ret;
}

ll mod_combi(ll n, ll r, const vector<ll>& invtable) {
    ll ret = 1;
    FOR(i, n-r+1, n+1) {
        ret = (ret*i) % MOD;
    }
    ret = (ret * invtable[r]) % MOD;

    return ret;
}

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

    vector<ll> invtable = mod_invtable(max({a, b}));
    cout << (
        (
            mod_pow(2LL, n) - 1LL +
            (MOD - mod_combi(n, a, invtable))
            + (MOD - mod_combi(n, b, invtable))
        ) % MOD
       ) << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>          // printf(), scanf()

int
gcd(int a, int b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

int
main(int argc, char** argv)
{
	int a, b;

	while (scanf("%d %d", &a, &b) != EOF)
	{
		int g = gcd(a, b);
		int l = (a / g) * b;
		printf("%d %d\n", g, l);
	}

	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h, w; cin >> h >> w;
    vector<string> field;
    string s = "";
    for(int i = 0; i < w + 2; i++) s += '#';
    field.push_back(s);
    for(int i = 0; i < h; i++){
        string t; cin >> t;
        t = '#' + t + '#';
        field.push_back(t);
    }
    field.push_back(s);
    for(int i = 0; i < field.size(); i++) cout << field[i] << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

num = gets.chomp.split(" ").map(&:to_i)

candidate1 = num.sort[(num.length / 2) - 1]
candidate2 = num.sort[num.length / 2]
centoral = (candidate1.to_f + candidate2.to_f) / 2.0

n.times do |i|
    if num[i] < centoral
        puts candidate2
    else
        puts candidate1
    end
end


Measured memory_bytes: 25572
#include<cstdio>
#include<algorithm>
using namespace std;
int ans=0,n;
void dfs(int now,bool a,bool b,bool c){
	if(now>n||now<0) return;
	ans+=(a&&b&&c),dfs(now*10+3,1,b,c),dfs(now*10+5,a,1,c),dfs(now*10+7,a,b,1);
}
int main(){
	scanf("%d",&n),dfs(3,1,0,0),dfs(5,0,1,0),dfs(7,0,0,1),printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
package main

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

var (
	N int
)

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	upperbound := 10000000
	answer := 1234567890123456
	for i := 1; i < upperbound; i++ {
		if N%i == 0 {
			answer = MinInt(i-1+(N/i)-1, answer)
		}
	}
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
# coding: utf-8
#便利そうなので置いとく
import fractions 
import functools 
#再帰関数を使うときは、再帰上限を上げておこうね！
import sys
sys.setrecursionlimit(200000000)
# my functions here!
def pin(type=int):
    return map(type,input().split())
"""
------------------------------------------------------------------
|OBJECTIVE:                                                      |
|Educatinal DP contest("https://atcoder.jp/contests/dp")を解こう!|
------------------------------------------------------------------
"""
#solution:
INF = float("inf")
"""
|#遷移式を考える
|   つまり、漸化式みたいに i回目までの結果を保存して、i+1回目の評価を行う
"""
def Flog_1(N,H):
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    dp[1]=abs(H[1]-H[0])#ほら、"2段前"がないから…
    for i in range(2,N):
        hop1=dp[i-1]+abs(H[i-1]-H[i]) 
        hop2=dp[i-2]+abs(H[i-2]-H[i]) 
        #print(hop1,hop2)
        dp[i]=hop1 if hop1<hop2 else hop2
    return dp
def Flog_1_Another(N,H):#"配る"DP
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in [1,2]:
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp
"""
|# Flog1との違い:飛ぶ段数に（1個か2個という）制限がない
|    
"""    
def Flog_2(N,K,H):#pypy回答でなんとかおｋ
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0,default position
    for i in range(1,N):#k段前から飛んでくることを考えよ
        temp = INF
        for k in range(1,K+1):
            if i-k < 0:break
            else:
                #print("*",i-k)
                temp = min(temp,(dp[i-k]+abs(H[i-k]-H[i])))
                
        dp[i]=temp
        #print("*",dp)
    return dp

def Flog_2_Another(N,K,H):#"配る"DP
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in range(1,K+1):
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp
#input
N,K=pin()
H =list(pin())

#output
print(Flog_2_Another(N,K,H)[-1])

Measured memory_bytes: 84188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A;
    int B;
    int C;
    cin >> A;
    cin >> B;
    cin >> C;
    if (A * C<=B){
        cout << C << endl;
    }else{
        cout << B/A << endl;
    }
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int h[n];
    rep(i, n) cin >> h[i];
    vector<bool> tf(n, true);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (h[a-1] < h[b-1]) {
            tf[a-1] = false;
            continue;
        }
        
        if (h[a-1] > h[b-1]) {
            tf[b-1] = false;
            continue;
        }

        else {
            tf[a-1] = false;
            tf[b-1] = false;
        }
    }

    int ans = 0;
    rep (i, n) {
        if (tf[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4004
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
//Atcoder Educational DP
//J-Sushi
/*
    I ♥ CLARICE STARLING

    EXPLAINATION BELOW->
    Dp + Probability

    First : what really matters is the number of dishes with 0, 1, 2 and 3 sushis and not the order of the dishes.
    So answer for 2,1,0,2,1 is same as answer for 0,1,1,2,2.
    Number of dishes with 0 sushis is easily determined by N - one - two - three, where one is the number of dishes with 1 sushi and N is the total number of dishes in the input.
    Let F(x, y, z) be the expected moves needed for x dishes with 1 sushi, y with 2 and z with 3.
    Now in the next move we can pick a dish with 1 sushi with a probability of x/N or p1. we can pick a dish with 2 sushi with a probability of y/N or p2. we can pick a dish with 3 sushi with a probability of z/N or p3. 
    we can pick a dish with 0 sushi with a probability of (N - (x + y + z))/N or p0.
    Now try to understand this :
    F(x,y,z) = 1 + p0F(x,y,z) + p1F(x-1,y,z) + p2F(x+1,y-1,z) + p3F(x,y+1,z-1)
   
*/
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF=(ll)1e18+5;
void solve()
{
    ll n,i,j,k,t;cin>>n;
    ll one,two,three;one=two=three=0;
    fo(i,0,n)
    {
        cin>>t;
        if(t==1)one++;
        else if(t==2)two++;
        else three++;
    }
    double dp[n+1][n+1][n+1];//n*n*n since max possible 1's or 2's or 3's can be equal to n
    dp[0][0][0]=0;
    
    foe(k,0,n)
    {
        foe(j,0,n)
        {
            foe(i,0,n)
            {
                ll total=0;
                if(i==0&&j==0&&k==0)continue;
                if(i+j+k>n)continue;
                total=i+j+k;
                dp[i][j][k]=n;
                if(i>0)dp[i][j][k]+=i*dp[i-1][j][k];
                if(j>0)dp[i][j][k]+=j*dp[i+1][j-1][k];
                if(k>0)dp[i][j][k]+=k*dp[i][j+1][k-1];
                dp[i][j][k]/=total;
            }
        }
    }
    cout<<setprecision(16)<<dp[one][two][three]<<"\n";
    
}
int main()
{
   fastio
   solve();
  return 0;
}



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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll N; cin >> N;
	ll sum = 0;
	ll T = N;
	while (T) {
		sum += T % 10;
		T /= 10;
	}

	cout << ((N % sum == 0) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;const ll inf = 1e16;
int n,k,a[N],b[N],l[N],r[N],len,s[N];
ll v[N<<2];int m;
void init(int n){
	for(m=1;m<=n+1;m<<=1);
	rep(i,1,n)v[m+i]=-s[i];
	per(i,m-1,1)v[i]=min(v[i<<1],v[i<<1|1]);
}
ll query(int l, int r){
	if(l>r)return inf;l=m+l-1;r=m+r+1;ll res=inf;
	while((l>>1)!=(r>>1)){
		if(!(l&1))umin(res,v[l+1]);
		if(r&1)umin(res,v[r-1]);l>>=1;r>>=1;
	}
	return res;
}
void modify(int p,ll x){
	umin(v[m+p],x);for(int i=m+p>>1;i;i>>=1)v[i]=min(v[i<<1],v[i<<1|1]);
}
void zhi(int p,ll x){
	v[m+p]=x;for(int i=m+p>>1;i;i>>=1)v[i]=min(v[i<<1],v[i<<1|1]);
}
int main() {
	read(n);read(k);ll ans=0;
	rep(i,1,n){
		read(a[i]);read(b[i]);ans+=2LL*a[i];
		if(b[i]==1&&a[i]*2>k){puts("-1");return 0;}
		a[i]=(a[i]+a[i-1])%k;l[i]=0;r[i]=k-1;
		if(b[i]==1){
			int x=((-2LL*a[i-1])%k+k)%k,y=((-2LL*a[i]+k)%k+k)%k;
			l[i]=x;r[i]=y;//if(r[len]<l[len])r[len]+=k;
		}
	}
	//l[1..n]
	rep(i,1,n)s[++len]=l[i],s[++len]=r[i];
//	rep(i,1,len)printf("[%d,%d]\n",l[i],r[i]);
//	rep(i,1,len)s[i]=l[i];
	sort(s+1,s+len+1);len=unique(s+1,s+len+1)-s-1;//s[1..len]
	rep(i,1,n){
		l[i]=lower_bound(s+1,s+len+1,l[i])-s;
		r[i]=lower_bound(s+1,s+len+1,r[i])-s;
	}
	init(len);set<int>Set;
	rep(i,1,len)Set.insert(i);
	rep(i,1,n){
		if(l[i]<=r[i]){
			ll now=min(query(1,l[i]-1),query(r[i]+1,len)+k);
			modify(l[i],now);
			while(!Set.empty()&&*Set.begin()<l[i])zhi(*Set.begin(),inf),Set.erase(*Set.begin());
			while(!Set.empty()&&*Set.rbegin()>r[i])zhi(*Set.rbegin(),inf),Set.erase(*Set.rbegin());
		}
		else{
			modify(l[i],query(r[i]+1,l[i]-1));
			set<int>::iterator it=Set.upper_bound(r[i]);
			while(it!=Set.end()&&(*it)<l[i])zhi(*it,inf),it=Set.erase(it);
		}
		Set.insert(l[i]);
	}
	ll res=1e18;rep(i,1,len)umin(res,query(i,i)+s[i]);
	cout<<res+ans;
	return 0;
}


Measured memory_bytes: 11392
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

ll c[5] = {};
ll res = 0;
const char march[] = "MARCH";
string s;
int main() {
	in(int, N);
	while(N--){
		cin >> s;
		loop(i, 5)
			if(march[i] == s[0])
				++c[i];
	}
	loop(n, 5)
		std::cerr << "c[" << n << "] = " << c[n] << std::endl;
	loop(i, 1<<5){
		int cc = 0;
		loop(n, 5)
			cc += !!(i & (1<<n));
		if(i==21) std::cerr << "cc = " << cc << std::endl;
		if(cc == 3){
			ll tmp = 1;
			loop(n, 5)
				if(i & (1<<n)){
					tmp *= c[n];
					if(i==21)
						std::cerr << "c[" << n << "] = " << c[n] << ", " << endl;
				}
			res += tmp;
		}
	}
	out(res);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	string s;
	cin >> s;

	int n = s.size();
	s += 'R';
	vector<int> num(n + 1, 0);

	int cnt = 1;
	rep (i, n) {
		if (s[i] == s[i + 1]) {
			cnt++;
			continue;
		}
		if (s[i] == 'R') {
			num[i] = cnt;
		}
		else num[i - cnt + 1] = cnt;
		cnt = 1;
	}

	rep (i, n) {
		if (num[i]) {
			if ((num[i] + num[i + 1]) % 2 == 0) {
				num[i] = num[i + 1] = (num[i] + num[i + 1]) / 2;
			}
			else {
				if (num[i] % 2 == 1) {
					num[i] = (num[i] + num[i + 1]) / 2 + 1;
					num[i + 1] = num[i] - 1;
				}
				else {
					num[i] = (num[i] + num[i + 1]) / 2;
					num[i + 1] = num[i] + 1;
				}
			}
			i++;
		}

	}

	rep (i, n) cout << num[i] << endl;
	return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str[100];
	string str1[100];

	int n;
	cin >> n;
	for(int i=0 ; i<n ; i++)
		cin >> str[i];

	int m;
	cin >> m;
	for(int j=0 ; j<m ; j++)
		cin >> str1[j];

	int ans = 0;
	for(int i=0 ; i<n ; i++)
	{
		if(str[i] != "-1")
		{
			int count1 = 1;
			for(int j=i+1 ; j<n ; j++)
			{
				if(str[j] == str[i])
				{
					count1++;
					str[j] = "-1";
				}
			}
			//cout << count1 << "\n";

			int count = 0;
			for(int j=0 ; j<m ; j++)
			{
				if(str[i] == str1[j])
					count++;
			}
            //cout << count << "\n\n";
			ans = max(ans , count1-count);
		}
	}
	cout << ans;
	return 0;
}

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

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<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int x, n;
	cin >> x >> n;
	V<int> p(n);
	rep(i, n) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int pos = -1;
	rep(i, n) {
		if (p[i] == x) {
			pos = i;
			break;
		}
	}
	if (pos < 0) {
		cout << x << endl;
		return 0;
	}
	//cout << pos << endl;
	int ans_p = x, ans_m=x;
	for (int i = pos + 1; i < n; ++i) {
		if (p[i] - p[i-1] > 1) {
			ans_p = p[i - 1] + 1;
			//cout << ans_p << endl;
			break;
		}
	}
	if (ans_p == x) {
		ans_p = p[n - 1] + 1;
	}
	for (int i = pos - 1; i > 0; --i) {
		if (p[i + 1] - p[i] > 1) {
			ans_m = p[i+1] - 1;
			//cout << ans_m << endl;
			break;
		}
	}
	if (ans_m == x) {
		ans_m = p[0] - 1;
	}
	if (abs(x - ans_p) >= abs(ans_m - x )) {
		cout << ans_m << endl;
	}
	else {
		cout << ans_p << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    ll x,y;
    cin>>x>>y;
    
    ll ans=LINF;
    rep(i,0,2){
        rep(j,0,2){
            ll X=x;
            ll Y=y;
            ll now=0;
            
            if(i==0){
                X=-X;
                now++;
            }
            if(j==0) {
                Y=-Y;
                now++;
            }
            now+=Y-X;
            if(Y-X>=0) ans=min(ans,now);
        }
    }
    
    cout<<ans<<endl;
}


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

int main() {
  int n;
  	cin>>n;
  int sum=0;
  int resum=0;
  
  vector<int>vec(n);
  
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int j=0;j<n;j++){
    if(j%2==0){
      sum+=vec.at(j);
    }
    else{
      resum+=vec.at(j);
    }
    
  }
  cout<<sum-resum<<endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    int l, r;
    int n = s.size();
    l = 0, r = s.size() - 1;
    while(l < r) {
        if(s[l] != s[r]) {
            cout << "No" << endl;
            return 0;

        }
        ++l; --r;

    }

    l = 0;
    r = (n - 1) / 2 - 1;
    while(l < r) {
        if(s[l] != s[r]) {
            cout << "No" << endl;
            return 0;

        }
        ++l; --r;

    }

    l = (n + 3) / 2 - 1;
    r = s.size() - 1;
    while(l < r) {
        if(s[l] != s[r]) {
            cout << "No" << endl;
            return 0;

        }
        ++l;
        --r;

    }
    cout << "Yes" << endl;
    return 0;
}



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

int  main(){
  int  q;
  cin>>q;
  int p,n;
  char c;
  int left=0,right=0;
  int left_digit=0,right_digit=0;
  for(int i=0;i<q;i++){
    cin>>p>>c>>n;
    if(c=='('){
      left+=n;
      if(left>100000){
        left_digit++; left-=100000;
      }
    } else{
      right+=n;
      if(right>100000){
        right_digit++; right-=100000;
      }
    }
    if(left_digit==right_digit&&left==right){
      cout<<"Yes"<<endl; left=0; right=0;
    } else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,w[N],b[N],x;
int f[N][N],cw[N][N],cb[N][N];
int main()
{
	memset(cw,0,sizeof(cw));
	memset(cb,0,sizeof(cb));
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++){
		char op[2];scanf("%s%d",op,&x);
		if(op[0]=='W')w[x]=i;else b[x]=i;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++)if(w[i]<w[j])cw[i][0]++;
		for(int j=1;j<=n;j++){
			cw[i][j]=cw[i][j-1];
			if(w[i]<b[j])cw[i][j]++;	
		}
	}	
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++)if(b[i]<b[j])cb[0][i]++;
		for(int j=1;j<=n;j++){
			cb[j][i]=cb[j-1][i];
			if(b[i]<w[j])cb[j][i]++;
		}
	}
	int c1=0,c2=0;
	for(int i=1;i<=n;i++){
		c1+=cw[i][0],c2+=cb[0][i];
		f[i][0]=c1,f[0][i]=c2;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=min(f[i-1][j]+cw[i][j],f[i][j-1]+cb[i][j]);	
	cout<<f[n][n]<<'\n';
	return 0;
}

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

int n;
vector<int> a, b, c;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    b.push_back(x);
  }
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    c.push_back(x);
  }

  int prev, sum = 0;
  for (int i = 0; i < n; i++) {
    int now = a[i];
    int bonus = (now - 1 == prev) ? c[prev -1] : 0;
    sum += b[now - 1] + bonus;
    prev = now;
  }

  cout << sum << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int maxn=2e5+10;
LL a[maxn];
int main()
{
    LL h;
    LL cnt=1,ans=0;
    cin>>h;
    while(h){
        ans+=cnt;
        cnt*=2;
        h/=2;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int x,y;
    scanf("%d%d",&x,&y);
    if(x<y){
        swap(a,b);
        swap(x,y);
    }
    //x>=y
    int ans=2147483647;
    int tmp=2*c*x;
    if(tmp<ans)ans=tmp;
    tmp=2*c*y+(x-y)*a;
    if(tmp<ans)ans=tmp;
    tmp=b*y+a*x;
    if(tmp<ans)ans=tmp;
    printf("%d\n",ans);
    
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll inf = 1e18L;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	ll res = 1;
	bool hasZero = false;
	bool over = false;
	cin >> n;
	rep(i,0,n) {
		ll val;
		cin >> val;
		if (val == 0) {
			hasZero = true;
			break;
		}
		if (over) {
			continue;
		}
		if (res > 2L*inf / val) {
			over = true;
		} else {
			res = res * val;
		}
		if (res > inf) {
			over = true;
		}
	}
	if (hasZero) {
		cout << 0 << endl;
	} else if (over) {
		cout << -1 << endl;
	} else {
		cout << res << endl;
	}
}

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

int main(int argc, char const *argv[]) {
    int n, d;
    cin >> n >> d;

    int ans = 0;
    for (size_t i = 0; i < n; i++) {
        long long x, y;

        cin >> x >> y;
        double dist = sqrt(x*x + y*y);
        if (dist <= d) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010];
long long ans=0;
bool w=false;
struct node{
	int pos,val;
	bool operator <(const node &b)const{
		return val<b.val;
	}
};
priority_queue<node>q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		node tmp={i,b[i]};
		q.push(tmp);
	}
	while(q.size()){
		node now=q.top();q.pop();
		int l=(now.pos-2+n)%n+1,r=now.pos%n+1;
      	if(b[now.pos]==a[now.pos]) continue;
		if(b[now.pos]-b[l]-b[r]<a[now.pos]){
			puts("-1");
			return 0;
		}
		int d=b[now.pos]-a[now.pos];
		ans+=d/(b[l]+b[r]);
		b[now.pos]=d%(b[l]+b[r])+a[now.pos];
		if(b[now.pos]==a[now.pos]) continue;
		node tmp={now.pos,b[now.pos]};
		q.push(tmp);
	}
	printf("%lld\n",ans); 
}


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

	static int n;
	static int[] A;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		int[] M = new int[q];
		for (int i = 0; i < q; i++) {
			M[i] = scan.nextInt();
			if (solve(0, M[i])) {
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}
		
		scan.close();
	}
	
	// ??\?????????M???????????????????´????????????????????????°??¢??°
	public static boolean solve(int i, int m){
		if (m == 0) {
			return true;
		}
		if (i >= n) {
			return false;
		}
		return solve(i + 1, m) || solve(i + 1, m - A[i]);
		
	}
}

Measured memory_bytes: 26784
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main
{

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

		int n = Integer.parseInt(sc.next());

		List<Integer> list = new ArrayList<>();

		int count = 0;

		for (int i = 0; i < n; i++) {
			int height = Integer.parseInt(sc.next());

			if (list.stream().allMatch(h -> height >= h)) {
				count++;
			}

			list.add(height);
		}

		System.out.println(count);
		sc.close();
	}
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

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

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;

void dfs(int n, int depth, vector<int> route, vector<vector<int>> &candidate) {
    if (n == depth) {
        candidate.push_back(route);
        return;
    }
    rep(i, 4) {
        vector<int> route2 = route;
        route2.push_back(i);
        dfs(n, depth + 1, route2, candidate);
    }
}


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

    vector<ll> bamboos(n);
    rep(i, n) cin >> bamboos[i];

    vector<vector<int>> candidate;
    vector<int> route;
    dfs(n, 0, route, candidate);


    ll ans = INF;
    for (auto &l : candidate) {
        ll a_sum = 0, b_sum = 0, c_sum = 0;
        int a_count = 0, b_count = 0, c_count = 0;

        rep(i, n) {
            int bamboo = l[i];
            ll size = bamboos[i];
            if (bamboo == 0) {
                continue;
            }
            if (bamboo == 1) {
                a_sum += size;
                a_count++;
            }
            if (bamboo == 2) {
                b_sum += size;
                b_count++;
            }
            if (bamboo == 3) {
                c_sum += size;
                c_count++;
            }
        }
        if (a_sum == 0 || b_sum == 0 || c_sum == 0) continue;

        if (a_count > a) continue;
        if (b_count > b) continue;
        if (c_count > c) continue;

        ll sum = 0;
        sum += ((a_count - 1) * 10);
        sum += ((b_count - 1) * 10);
        sum += ((c_count - 1) * 10);

        sum += abs(a - a_sum);
        sum += abs(b - b_sum);
        sum += abs(c - c_sum);
        cmin(ans, sum);
    }

    cout << ans << endl;

}


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


#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int INF = 1e9+7;
using ipair = pair<int, int>;
using ll = long long;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int main(){
    // Input
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    //
    vector<vector<ll>> dp(101, vector<ll>(2, -1));

    dp[45][0] = 0;
    for(int d=44; d>=0; --d){
        ll mask = 1LL<<d;
        ll num = 0;
        rep(i, N) if(A[i]&mask) ++num;

        if(dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, N-num));
        if(dp[d+1][0] >= 0){
            if (K>>d & 1){
                chmax(dp[d][1], dp[d+1][0] + mask * num);
                chmax(dp[d][0], dp[d+1][0] + mask * (N-num));
            }else{
                chmax(dp[d][0], dp[d+1][0] + mask * num);
            }
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;





    return 0;
}

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

int main(){
 int k,min,max;
 cin>>k>>min>>max;
 for(int i=min;i<=max;i++){
 if(i%k==0){
   cout<<"OK"<<endl;
   return 0;
 }
 }
  cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define INF 1e9;
#define MOD 1e9 + 7;
int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = long.Parse(ReadLine());
        long count = 1;
        int i = 1;
        for(; ; i++)
        {
            count *= 26;
            if(count < n)
            {
                count++;
                continue;
            }
            n -= count / 26;
            break;
        }
        string s = "";
        while(n > 0)
        {
            s = ((char)(n % 26L + 'a')).ToString() + s;
            n /= 26L;
        }
        while(s.Length < i)
        {
            s = "a" + s;
        }
        WriteLine(s);
    }
}


Measured memory_bytes: 17684
#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);

	string s;
	cin >> s;

	ll ans = 0;
	ll counter = 0;
	rep(i, s.length()) {
		if (s[i] == 'W') {
			ans += (ll)i - counter;
			++counter;
		}
	}

	cout << ans << "\n";

	return 0; 
}


Measured memory_bytes: 720
#include <iostream>

int main()
{
	int a, b;
	std::cin >> a >> b;
	if (a < b) {
		std::cout << "a < b" << std::endl;
	}
	else if (a > b) {
		std::cout << "a > b" << std::endl;
	}
	else
	{
		std::cout << "a == b" << std::endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import string
az = list(string.ascii_lowercase)
li = [0 for a in range(len(az))]

while True:
    try:
        a = raw_input()
        for b in list(a):
            if b.lower() in az:
                tmp = az.index(b.lower())
                li[tmp] = li[tmp] + 1
    except:
        break

for c in range(len(az)):
    print az[c] + ' : ' + str(li[c])

Measured memory_bytes: 4376
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    int flag=1;
    for(int i=0; i<a; i++){
        int tmp=s[i]-'0';
        if(tmp<0 || tmp>10) flag=0;
    }
    if(s[a]!='-') flag=0;
    for(int i=a+1; i<=a+b; i++){
        int tmp=s[i]-'0';
        if(tmp<0 || tmp>10) flag=0;
    }
    if(flag==0){
        cout << "No";
    }else{
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

#define MOD 1000000007

int main() {
	long long n, ans = 1;
	cin >> n;
	
	for (int i = 1; i <= n; ++i) {
		ans *= i;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
    }

    long long sum = 1000000000;
    for(int i = 1; i <= 100; i++){
        long long cost = 0;
        for(int j = 0; j < N; j++){
            cost += (X.at(j) - i) * (X.at(j)-i);
        }
        sum = min(sum, cost);
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


int main(void){
    int a,b;
    cin >> a >> b;
    int x;
    if(b <= 9){
        x = a * 10 + b;
    }else if(b <= 99){
        x = a * 100 + b;
    }else{
        x = a * 1000 + b;
    }
    if((int)sqrt(x) * (int)sqrt(x) == x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();

bool isp[401010];
int now[1010101], cnt[1010101];

int l, r;

vector<int> build(){
  vector<int> p;
  for(int i=0; i*i<=r; i++){
    isp[i] = 1;
  }
  isp[0] = 0;
  isp[1] = 0;
  for(int i=2; i*i<=r; i++){
    if(!isp[i]) continue;
    for(LL j=i*i; j*j<=r; j+=i){
      isp[j] = 0;
    }
  }
  for(int i=0; i*i<=r; i++){
    if(isp[i]) p.push_back(i);
  }
  return p;
}

int main(){
  cin >> l >> r;
  vector<int> prime = build();
  for(int i=l; i<=r; i++) now[i-l] = i;
  for(int &p: prime){
    for(int i=(l+p-1)/p * p; i <= r; i+=p){
      while(now[i-l] % p == 0){
        now[i-l] /= p;
        cnt[i-l]++;
      }
    }
  }
  int ans = 0;
  for(int i=l; i<=r; i++){
    if(now[i-l] > 1) cnt[i-l]++;
    if(isp[cnt[i-l]] && cnt[i-l] > 0) ans++;
  }
  cout << ans << endl;
  
	return 0;
}



Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
ll A[200010];
ll X[200010];
ll Y[200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    X[i + 1] = X[i] ^ A[i];
    Y[i + 1] = Y[i] + A[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    int ok = i, ng = N + 1;
    while (ng - ok > 1) {
      int m = (ok + ng) / 2;
      ll x = X[m] ^ X[i];
      ll y = Y[m] - Y[i];
      if (x == y) ok = m;
      else ng = m;
    }
    ans += ok - i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N,K;
long long int x[51],y[51],x2[51],y2[51];
long long int ans;
int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i];
    x2[i]=x[i];
    y2[i]=y[i];
  }
  sort(x,x+N);
  sort(y,y+N);
  ans=1LL*(x[N-1]-x[0])*(y[N-1]-y[0]);
  for(int xi=0;xi<N;xi++){
    for(int xj=xi+1;xj<N;xj++){
      for(int yi=0;yi<N;yi++){
	for(int yj=yi+1;yj<N;yj++){
	  
	  long long int lx=x[xi],rx=x[xj];
	  long long int by=y[yi],uy=y[yj];
	  int c=0;
	  for(int p=0;p<N;p++){
	    if(lx<=x2[p] && x2[p]<=rx && by<=y2[p] && y2[p]<=uy)c++;
	  }
	
	  if(c>=K)ans=min(ans,1LL*(rx-lx)*(uy-by));
	  
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
   int i, a, b, s=0;

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

   for(i=a;i<=b;i++){
      if(((((i/10000)%10)==(i%10)))&&(((i/1000)%10)==((i/10)%10)))
        s++;
   }

   printf("%d\n", s);

   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, a, piyo[8] = {},hoge=0,max=0,min=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if(a<3200) piyo[a / 400]++;
		else hoge++;
	}
	for (int j = 0; j < 8; j++) if (piyo[j] > 0) min++;
	max = min + hoge;
	if (min == 0 && hoge > 0) min++;
	cout << min <<" "<<max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 9;
int n;
ll anser = 0;
ll c;
ll pre[100005];
ll pre2[100005];
ll dis[100005];
ll dis2[100005];
ll v[100005];
ll shun[100005];
ll ni[100005];
int main()
{
        cin >> n >> c;
        for (int i = 1; i <= n; i++)
        {
                cin >> dis[i] >> v[i];
                pre[i] = pre[i - 1] + v[i];
        }
        for (int i = n; i >= 1; i--)
        {
                dis2[n - i + 1] = c - dis[i];
                pre2[n - i + 1] = pre2[n - i] + v[i];
        }
        for (int i = 1; i <= n; i++)
        {
                shun[i] = max(shun[i - 1], pre[i] - dis[i]);
                anser = max(anser, shun[i]);
        }
        for (int i = 1; i <= n; i++)
        {
                ni[i] = max(ni[i - 1], pre2[i] - dis2[i]);
                anser = max(anser, ni[i]);
        }
        //cout << anser << endl;
        for (int i = 1; i <= n; i++)
        {
                anser = max(anser, pre[i] - 2 * dis[i] + ni[n - i]);
                anser = max(anser, pre2[i] - 2 * dis2[i] + shun[n - i]);
        }
        cout << anser << endl;
        return 0;
}


Measured memory_bytes: 5760