akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

long long int N,M,x,y,z,ans;
int main() {
    cin >> N >> M;
    //if(N == M == 1)
    long long int sum[8][N],a[]={1,1,1,1,-1,-1,-1,-1},b[]={1,1,-1,-1,1,1,-1,-1},c[]={1,-1,1,-1,1,-1,1,-1};
    REP(i,N){
        cin >> x >> y >> z;
        REP(j,8){
            sum[j][i] = x*a[j] + y*b[j] + z*c[j];
            
            //cout << sum[j][i]<<endl;
            

        }
    }

    REP(i,8){
        sort(sum[i],sum[i]+N);
    }
    REP(i,8){
        long long int temp = 0;
        for(int j = N - 1; j >= N - M;j--){
            temp += sum[i][j];
            //cout << temp << endl;
        }
        if(ans < temp){
            ans = temp;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N;
  cin>>N;
  vector<long double> A(N);
  vector<ll> B(N);
  vector<ll> Five(N, 0);
  vector<ll> Two(N, 0);
  vector<pair<ll, ll>> P(N);
  rep(i, N){
    cin>>A[i];
    //cout<<fixed<<A[i]<<endl;
    A[i]*=(long double)1000000000;
    A[i]+=0.1;
    B[i]=A[i];
    //cout<<fixed<<A[i]<<endl;
    //cout<<B[i]<<endl;
    ll BB=B[i];
    while(BB>0&&BB%2==0){
      BB/=2;
      Two[i]++;
    }
    while(BB>0&&BB%5==0){
      BB/=5;
      Five[i]++;
    }
    P[i]=make_pair(Two[i], Five[i]);
  }
  sort(ALL(P));
  vector<vector<ll>> FvN(N, vector<ll>(19, 0));
  per(i, N-1){
    if(i<N-1){
    	rep(j, 19){
          FvN[i][j]+=FvN[i+1][j];
        }
    }
    if(P[i].second<=18){
      FvN[i][P[i].second]++;
    }else{
      FvN[i][18]++;
    }
  }
  rep(i, N){
    //cout<<P[i].first<<" "<<P[i].second<<endl;
    rep(j, 19){
      //cout<<FvN[i][j]<<" ";
    }
    //cout<<endl;
  }
  ll Ans=0;
  ll Key=0;
  if(N>10000){
  per(i, N-1){
    //cout<<i<<endl;
    while(Key<N&&(P[i].first+P[Key].first<18)){
      	//cout<<i<<" "<<Key<<" "<<P[i].first+P[Key].first<<" "<<P[i].second+P[Key].second<<endl;
    	Key++;
      	
    }
    if(Key==N)continue;
    //cout<<"Key="<<Key<<endl;
    for(ll j=18-P[i].second; j<=18; j++){
      Ans+=FvN[Key][j];
    }
    if(i>=Key&&P[i].first>=9&&P[i].second>=9)Ans--;
    
  }
  }else{
  rep(i, N){//全探索
    rep(j, N){
      if(i==j)continue;
      if(P[i].first+P[j].first>=18&&P[i].second+P[j].second>=18)Ans++;
    }
  }
  }
  cout<<Ans/2<<endl;
  return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    map<char, int> mp;
    mp[s[0]]++;
    mp[s[1]]++;
    mp[s[2]]++;
    mp[s[3]]++;
    if ((int)mp.size() == 2) {
        if (mp[s[0]] == 2)
            cout << "Yes";
        else
            cout << "No";
    } else
        cout << "No";

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
T = str(input())

max_cnt = 0
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt += 1

        
    max_cnt = max(cnt, max_cnt)

print(len(T) - max_cnt)



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

class D{
    public:
    int f[6];
    D(){}
    void rollx(){
        roll(0,2,5,3);
    }
    void rolly(){
        roll(0,1,5,4);
    }
    void rollz(){
        roll(1,2,4,3);
    }
    void roll(int a,int b,int c,int d){
        int t=f[a];
        f[a]=f[b];
        f[b]=f[c];
        f[c]=f[d];
        f[d]=t;
    }
};

int right(D c,int a,int b){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(c.f[0]==a&&c.f[1]==b)return c.f[2];
            c.rollz();
        }
        if(i%2==0)c.rolly();
        else c.rollx();
    }
    return -1;
}

int main(){
    D c;
    int n,o,p;
    for(int j=0;j<6;j++)cin>>c.f[j];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>o>>p;
        cout<<right(c,o,p)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
class SegmentTree():
    def __init__(self, arr, func=min, ie=2**63):
        self.h = (len(arr) - 1).bit_length()
        self.n = 2**self.h
        self.ie = ie
        self.func = func
        self.tree = [ie for _ in range(2 * self.n)]
        for i in range(len(arr)):
            self.tree[self.n + i] = arr[i]
        for i in range(1, self.n)[::-1]:
            self.tree[i] = func(self.tree[2 * i], self.tree[2 * i + 1])

    def set(self, idx, x):
        idx += self.n
        self.tree[idx] = x
        while idx:
            idx >>= 1
            self.tree[idx] = self.func(self.tree[2 * idx], self.tree[2 * idx + 1])

    def query(self, lt, rt):
        lt += self.n
        rt += self.n
        vl = vr = self.ie
        while rt - lt > 0:
            if lt & 1:
                vl = self.func(vl, self.tree[lt])
                lt += 1
            if rt & 1:
                rt -= 1
                vr = self.func(self.tree[rt], vr)
            lt >>= 1
            rt >>= 1
        return self.func(vl, vr)

N, K = map(int, input().split())
A = list(map(int, input().split()))

res = N + 1
st = SegmentTree([0] * K)
rt = 0

for lt in range(N):
    while rt < N and st.tree[1] == 0:
        if A[rt] <= K:
            st.set(A[rt] - 1, st.query(A[rt] - 1, A[rt]) + 1)
        rt += 1
    if st.tree[1] != 0:
        res = min(res, rt - lt)
    if A[lt] <= K:
        st.set(A[lt] - 1, st.query(A[lt] - 1, A[lt]) - 1)

print(res if res <= N else 0)


Measured memory_bytes: 16404
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m;
    cin >> n >> m;
    ll x, y, z;
    vector<vector<ll>> arr;
    vector<vector<ll>> coff = {{1, 1, 1}, {1, 1, -1},
        {1, -1, 1}, {1, -1, -1}, {-1, 1, 1}, {-1, 1, -1},
        {-1, -1, 1}, {-1, -1, -1}};

    for(int i = 0; i < n; i++) {
        cin >> x >> y >> z;
        arr.push_back({x, y, z});
    }

    ll ans = INT_MIN*10000;
    for(int i = 0; i < 8; i++) {
        multiset<ll> pq;
        for(int j = 0; j < n; j++) {
            ll val = arr[j][0] *coff[i][0] +
                arr[j][1] * coff[i][1] + arr[j][2] * coff[i][2];
            pq.insert(val);
            if (pq.size() > m)
                pq.erase(pq.begin());
        }
        ll acc = 0;
        for(ll num: pq)
            acc += num;
        // cout << acc << endl;
        ans = max(ans, acc);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
N = int(input())
M_list = []
#社員のそれぞれの部下を記録するためのリストを用意する。
#インデックス０番目は一番偉い人で、もし各社員から上司を言われたら
#数字を一足していく。
for i in range(N):
  M_list.append(0)
#⁺リストでは各社員の上司を言っていく。例えば最初の社員が
#1というと、M_listの０の数字が１増える。
plus_list = input().split()

for i in range(N-1):
  M_list[int(plus_list[i])-1] += 1
  
for i in range(N):
  print(M_list[i])

Measured memory_bytes: 26024
package main

import(
    "fmt"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := b + (b-a)
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


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

int main(void)
{
    char str[10];
    int n;
    int i = 0;
    int sum = 0;

    scanf("%s", str);

    n = atoi(str);

    while('\0' != str[i]) {
        sum += (str[i] - '0');
        i++;
    }

    if (0 == (n % sum)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

int main(){
  int N, M; cin >> N >> M;
  int l=1, r = N;
  REP(i, M){
    int L, R; cin >> L >> R;
    if(l<=L) l = L;
    if(R<=r) r = R;
  }
  cout << (r<l ? 0 : r - l + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	reverse(all(s));
	s += "0";
	vector<vector<ll>> dp(s.size() + 1, vector<ll>(2, 1e18));
	dp[0][0] = 0;
	dp[0][1] = 1;
	rep(i, s.size())
	{
		int d = s[i] - '0';
		rep(j, 2)rep(k, 2)
		{
			if (j == 0)
			{
				if (k == 0)dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + d);
				else dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + 10 - d);
			}
			else
			{
				if (k == 0)dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + d + 1);
				else dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + 9 - d);
			}
		}
	}
	cout << min(dp[s.size()][0], dp[s.size()][1]) << endl;
}


Measured memory_bytes: 55940
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

ll n,k;
vector<ll>nedan, kati;
ll maxkati=0;
bool aruka[31] = {};

void ikura(ll searchNum) {
	ll kariMaxKati=0;
	REP(i, kati.size()) {
		if ((searchNum | nedan[i]) == searchNum) {
			kariMaxKati += kati[i];
		}
	}
	maxkati = max(maxkati, kariMaxKati);
	return;
}

void tansa(int hukasa) {
	ll searchNum = 0;
	ll nowHukasa = 0;
	REPR(i, 30) {
		//上のほうから数える
		
		if ((k & (((ll)1)<<i)) !=0) {
			//もしそのビットがたっていたら、深さをあげる
			nowHukasa++;
			//もし深さがここまでなら
			if (nowHukasa == hukasa) {
				//調べる番号はこれ
				searchNum += (((ll)1) << i) - 1;
				//for文を抜ける
				break;
			}
			else {
				//そうでないなら、もっと後のも調べる
				searchNum += (((ll)1) << i);
			}
		}
	}


	//得られたsearchNumを使って、どれだけの価値をゲットできるか調べる
	//maxkatiを更新する
	ikura(searchNum);

	//もしこれいじょうの深さがないなら、探索は無意味
	if (hukasa != nowHukasa) {
		return;
	}

	//より深いばーじょんもしらべる
	tansa(hukasa + 1);
	
	return;
}

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> n >> k;
	ll tmp;

	REP(i, n) {
		cin >> tmp;
		nedan.push_back(tmp);
		cin >> tmp;
		kati.push_back(tmp);
	}

	//REP(i, (ll)30) {
	//	if (k > pow(2, i)) {
	//		aruka[i] = true;
	//	}
	//}

	

	//max-1
	//max + max手前-1
	//max+max手前
	tansa(1);

	cout << maxkati << endl;



	return 0;

}



Measured memory_bytes: 2036
'use strict'
const convertNum = num => Number(num)
const Main = input => {
  const values = input[1].split(' ').map(convertNum)
  const costs = input[2].split(' ').map(convertNum)
  let result = 0
  values.forEach((value, idx) => {
    if (value > costs[idx]) {
      result = result + (value - costs[idx])
    }
  })
  console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/))

Measured memory_bytes: 7372
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b;
	cin>>s;
	for(int i=0;i<=a+b;i++)
	{
		if(i==a)
		{
			if(s[i]!='-')
			{
				cout<<"No";
				return 0;
			}
		}
		else
		{
			if(s[i]<'0' || s[i]>'9')
			{
				cout<<"No";
				return 0;
			 } 
		}
	}
	cout<<"Yes";
	return 0;
}

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

int nums[100000]={0};
int main()
{
    int i=0,N,Q,l,r,sum=0;
    string S;

    cin>>N>>Q>>S;
    for(i=1;i<N;i++)
    {
        if(S[i-1]=='A' &&S[i]=='C')
        {
            sum++;

        }
        nums[i] = sum;
    }

    for(i=0;i<Q;i++)
    {
        cin>>l>>r;
        cout<<nums[r-1]-nums[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

    int x;
    cin >> x;

    if(x < 1200){
    	cout << "ABC";
    }else{
    	cout << "ARC";
    }


	return 0;

}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,s.size()/2) {
    if (s[i] != s[s.size()-i-1]) cnt += 1;
  }
  cout << cnt << 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, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

def main():
	a = [LIST() for _ in range(3)]
	n = INT()
	b = [INT() for _ in range(n)]

	for i in range(3):
		for j in range(3):
			if a[i][j] in b:
				a[i][j] = 0

	line = [[a[0][0], a[0][1], a[0][2]],
			[a[1][0], a[1][1], a[1][2]],
			[a[2][0], a[2][1], a[2][2]],
			[a[0][0], a[1][0], a[2][0]],
			[a[0][1], a[1][1], a[2][1]],			
			[a[0][2], a[1][2], a[2][2]],
			[a[0][0], a[1][1], a[2][2]],
			[a[0][2], a[1][1], a[2][0]]]

	if [0, 0, 0] in line:
		print("Yes")
	else:
		print("No")

if __name__=='__main__':
    main()


Measured memory_bytes: 5720
a,b = map(int,input().split())
num=b
s=0
minA = 500
store= []
ans = []
final = []
c=-1
for i in range(a):
    store.append(num);
    s+=num
    num+=1
for v in store:
    cur = s-v
    final.append([abs(s-cur),cur])
final.sort()
print(final[0][1])

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

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

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

vector<pair<long long,long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for(ll p=2; p*p <= N; p++) {
	if(N % p != 0) continue;
	int ex = 0;          //exponetial part
	while(N%p == 0) {
	  ex++;
	  N/=p;
	}
	res.push_back({p,ex});
  }
  if(N!=1) {
	res.push_back({N,1});
  }
  return res;
}
int main(){
  ll N;
  cin >> N;
  vector<pair<ll,ll>> a;
  a = prime_factorization(N);
  
  ll ans = 0;
  for(auto it : a) {
	ll num = it.second;
	ll cnt = 1;
	ll tmp = 0;
	while(num >= cnt) {
	  num -= cnt;
	  cnt++;
	  tmp++;
	}
	ans += tmp;
  }

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



Measured memory_bytes: 3232
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
ll sc(char x,char y){
  if(x==y) return -1;
  else{
    if(x>y){
      swap(x,y);
    }
    if(x=='B'&&y=='G') return 0;
    else if(x=='B'&&y=='R') return 1;
    else return 2;
  }
}
signed main(){
  init_io();
  ll n,ans=0;
  string s;
  cin >> n >> s;
  vector<vector<ll>> sum(n+1,vector<ll>(3,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      sum[i+1][j] += sum[i][j];
    }
    if(s[i]=='R') sum[i+1][0]++;
    if(s[i]=='G') sum[i+1][1]++;
    if(s[i]=='B') sum[i+1][2]++;
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ll v = sc(s[i],s[j]);
      if(v!=-1){
        ans += sum[n][v] - sum[j][v];
      }
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j+i*2<n;j++){
      set<char> st;
      st.insert(s[j]);
      st.insert(s[j+i]);
      st.insert(s[j+2*i]);
      if(st.size()==3){
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    long long h,w,ans;
    cin>>h>>w;
    if(h==1||w==1)ans=1;
    else ans=(h*w+1)/2;
    cout<<ans;
	return 0;
}


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

int main() {
    double n, m, d;
    cin >> n >> m >> d;

    if (d == 0) {
        printf("%.9f\n", (m - 1) / n);
    } else {
        printf("%.9f\n", (m - 1) * 2 * (n - d) / (n * n));
    }
    return 0;
}

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

int main(){
  int mon, tue, wed, thu, fri, sat, sun;
  sun = 7;
  mon = 6;
  tue = mon-1;
  wed = mon-2;
  thu = mon-3;
  fri = mon-4;
  sat = mon-5;
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << sun << endl;
  }
  else if(s=="MON"){
    cout << mon << endl;
  }
  else if(s=="TUE"){
    cout << tue << endl;
  }
  else if(s=="WED"){
    cout << wed << endl;
  }
  else if(s=="THU"){
    cout << thu << endl;
  }
  else if(s=="FRI"){
    cout << fri << endl;
  }
  else{
    cout << sat << endl;
  }
}

Measured memory_bytes: 256
/*" بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ -In the name of Allah."
   Never stop chasing!-MD.SOURAV.

   ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
   ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
   ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
   [███████████████████].░░░░░░░░░░░░░░
   ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
*/

#include <bits/stdc++.h>


#define endl           "\n"
#define MAX            32000
#define F              first
#define S              second
#define sz(x)          x.size()
#define li             long int
#define gcd(a,b)       _gcd(a,b)
#define pb             push_back
#define mp             make_pair
#define asrt(a,n)      sort(a,a+n)
#define MOD 	       1000000007
#define ll             long long int
#define lcd(a,b)       (a*b)/gcd(a,b)
#define mp(x,y)        make_pair(x,y)
#define no             cout<<"NO"<<endl
#define yes            cout<<"YES"<<endl
#define f(i, a, n)     for(int i=a;i<n;i++)
#define test           int t;cin>>t;while(t--)
#define srt(v)         sort(v.begin() , v.end())
#define basrt(a,n)     sort(a,a+n, greater<int>())
#define debug(x)         cout << #x<< ": "<< x<< endl;
#define sumof(x)       accumulate(x.begin(),x.end(),0);
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }



using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll> msll;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve()
{
    int n;
    cin>>n;
    if(n==0)
    {
        cout << "1";
    }
    else 
    {
        cout << "0";
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll test_case;
    test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
const ll MOD=998244353;

int main(){
  int N,S;
  cin >> N >> S;
  vector<vector<ll>> dp(N+1,vector<ll>(S+1,0));
  dp[0][0]=1;
  for(int i=1;i<N+1;i++){
    ll A; cin >> A;
    for(int j=0;j<S+1;j++){
      dp[i][j]+=2*dp[i-1][j]%MOD;
      dp[i][j]%=MOD;
      if(j+A<=S){
        dp[i][j+A]+=dp[i-1][j];
      }
      dp[i][j]%=MOD;
    }
  }

  cout << dp[N][S] << endl;

  return 0;
}


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

int main(void)
{
    rep(i, 5)
    {
        int x;
        cin >> x;
        if(x==0)
        {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
<?php
  $ary = explode(" ", trim(fgets(STDIN)));
  if (intval($ary[0]) == intval($ary[1])) {
    print "a == b";
  } elseif (intval($ary[0]) > intval($ary[1])) {
    print "a > b";
  } else {
    print "a < b";
  }
?>

Measured memory_bytes: 6540
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int to[44][101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    REP(i,N){
        if(S[i] == 'R') to[0][i] = i + 1;
        else to[0][i] = i - 1;
    }

    REP(i,40){
        REP(j,N) to[i+1][j] = to[i][to[i][j]];
    }

    vector<int> ans(N);
    REP(i,N) ans[to[40][i]]++;

    REP(i,N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 17488
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll  x,t;cin>>x>>t;
    cout<<max(0,x-t)<<endl;
    
    return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		
		
		System.out.println(Z+" "+X+" "+Y);

		
	}
}




Measured memory_bytes: 21716
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let s=read::<String>().chars().collect::<Vec<char>>();
    let mut c=0;
    for i in 0..a+b+1{
        c+=((i==a)as i32+(s[i as usize]!='-')as i32!=1)as i32;
    }
    println!("{}",if c>0{"No"}else{"Yes"});
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef EBUCHKA
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}


int main() {
	kekek();
	int ans;
	int n;
	cin >> n;
	cin >> ans;
	for (int i = 0; i < n - 1; i++) {
		int t;
		cin >> t;
		ans = __gcd(ans, t);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt() - 1;
            }
            boolean[] seen = new boolean[n];
            int cur = 0;
            int ans = 0;
            while (true) {
                if (seen[cur]) {
                    out.println(-1);
                    return;
                }
                if (cur == 1) {
                    out.println(ans);
                    return;
                }
                seen[cur] = true;
                cur = arr[cur];
                ans += 1;
            }
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34836
#include <iostream>
#include <cstdio>


int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int ans = (n - 1) / (k - 1);
	if (ans * k - ans + 1 < n) ++ans;
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    vector<int> coins = {1};
    int p = 1;
    while (p*6 <= n) {
        p *= 6;
        coins.pb(p);
    }
    p = 1;
    while (p*9 <= n) {
        p *= 9;
        coins.pb(p);
    }
    int dp[n+1];
    fore(i,0,n+1) {
        dp[i] = i;
        for (auto &c : coins) {
            if (i-c >= 0) dp[i] = min(dp[i], dp[i-c]+1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
@memo = Array.new(11){Array.new(331){ Array.new(1024) }}

def calc(num,n,s)
  return 0 if n<=0 || s<0 || s>330 || n>10
  return @memo[n][s][num] if @memo[n][s][num]
  ans = 0
  d,m = num.divmod(2)
  cnt = 0
  while d>0 || cnt<10
    if m==0
      t = s-cnt*n
      if t==0 && n==1
        ans = 1
        break
      end
      ans += calc(num+2**cnt,n-1,t)
    end
    cnt += 1
    d,m = d.divmod(2)
  end
  @memo[n][s][num] = ans
  return ans
end

while l=gets
  n,s = l.split.map(&:to_i)
  puts calc(0, n, s)
end

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N, M, j=0;
  LL ans=0;
  cin >> N >> M;
  vector<PII> dri;
  REP(i,N) {
    int A, B;
    cin >> A >> B;
    PII p;
    p = MP(A,B);
    dri.PB(p);
  }
  SORT(dri);
  REP(i,M){
    if(dri.at(j).SE == 0) {
      j++;
      i--;
    }
    else{
      ans += dri.at(j).FI;
      dri.at(j).SE--;
    }
  }
  cout << ans << endl;
  return 0;
}
    

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

int main(){
    int n;    cin >> n;
    int k;    cin >> k;
    
    int dp[n];
    dp[0] = 1;

    for (int i=0; i < n; i++){
        if (dp[i]*2 < dp[i]+k){
            dp[i+1] = dp[i] * 2;
        }else {
            dp[i+1] = dp[i] + k;
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 256
n=int(input())
ab=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])[::-1]
ans=ab[0][0]
for i in range(1,n):
    ans+=ab[i][0]-ab[i-1][0]
ans+=ab[-1][1]
print(ans)

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

vector<pair<int,int>> vec(100000);
int main(){
    long long n,k,a,b;
    pair<int,int> p;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        p.first = a;
        p.second = b;
        vec.push_back(p);
    }
    sort(vec.begin(), vec.end());
    long long ans = 0, num = -1;
    do{
        ++num;
        ans += vec[num].second;
    }while(ans < k);
    cout << vec[num].first << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x[] = new int[11];
		x[0] = sc.nextInt();
		for (int i = 1; i < 11; i++) {
			x[i] = x[i - 1] * r - d;
			System.out.println(x[i]);
		}
	}
}

Measured memory_bytes: 20820
#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

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

  ll a,b,k;
  std::cin>>a>>b>>k;

  if(k>=a+b)std::cout<<"0 0"<<"\n";
  else if(a<=k)std::cout<<0<<" "<<a+b-k<<"\n";
  else std::cout<<a-k<<" "<<b<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() 
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	ll n, h; 
	cin >> n >> h;
	ll A[100001], B[100001];
	for (int i = 0; i < n; ++i) 
	{
		cin >> A[i] >> B[i];
	}

	sort(A, A + n, greater<int>());
	sort(B, B + n, greater<int>());
	bool done = false;
	ll ans = 0;
	for (int j = 0; j < n; ++j) 
	{
		if (B[j] >= A[0])ans++, h -= B[j];
		else break;
		if (h <= 0) 
		{
			done = true;
			break;
		}
	}
	if (!done)ans += (h / A[0]) + (h%A[0] != 0);
	cout << ans;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


def main():
    N = int(input())
    H = list(map(int, input().split()))

    cost = [0] * N
    cost[0] = 0
    cost[1] = abs(H[0] - H[1])
    for i in range(2, N):
        cost[i] = min(
            cost[i-1] + abs(H[i] - H[i-1]),
            cost[i-2] + abs(H[i] - H[i-2])
            )
        # print(i+1, cost[i])
    print(cost[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13980
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;


int main() {

	cin.tie(0);
	
	int N, cost = 0;
	cin >> N;

	vector<float> a(N);
	FOR(i, 0, N) cin >> a[i];

	float ave = 0;
	for (auto &elem : a) ave += elem / a.size();
	
	FOR(i, 0, N) cost += pow((a[i] - roundf(ave)), 2);

	cout << cost;

	return 0;
}

Measured memory_bytes: 384
def 解():
    iN = int(input())
    sS = input().rstrip()

    aE= [0]*iN #東向かされる人
    for i in range(1,iN):
        if sS[i-1] == "W":
            aE[i] = aE[i-1]+1
        else:
            aE[i] = aE[i-1]
    iMinCost = aE[iN-1]
    iW = 0 #西向かされる人
    for i in range(iN-2,-1,-1):
        if sS[i+1]=="E":
            iW += 1
        iMinCost = min(iMinCost,iW+aE[i])
    print(iMinCost)

解()


Measured memory_bytes: 15264
import java.util.Scanner;

public class Main {
	private static Main instance = new Main();
	
	private Scanner scanner = new Scanner(System.in);
	
	public static void main(String[] args) {
		instance.solve();
	}
	
	private void solve() {
		String n = scanner.nextLine();
		int numOfGames = n.length();
		int idealP = numOfGames / 2;
		int numOfP = n.replace("g", "").length();
		System.out.printf("%d", idealP - numOfP);
	}
}


Measured memory_bytes: 20684
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    //cin>>n>>m;
cin>>s1;
if(s1=="ABC")
{
    cout<<"ARC"<<endl;
}
else{cout<<"ABC"<<endl;}




}


Measured memory_bytes: 3604
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


N = int(input())
r = make_divisors(N)
res = []
for i in r:
    y = N // i
    res.append(max(len(str(y)), len(str(i))))
print(min(res))

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */

ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;

void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll x;
sieve();
cin>>x;
 cout<<v[lower_bound(v.begin(),v.end(),x)-v.begin()]<<endl;
return 0;
}



Measured memory_bytes: 39280
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([p_d, m_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)

Measured memory_bytes: 20104
a,b,m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = []
for i in range(m):
    x,y,c = map(int, input().split())
    ans += [A[x-1] + B[y-1] - c]
ans += [min(A) + min(B)]

print(min(ans))

Measured memory_bytes: 24840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,q,a,b,cnt[100005]={};
	string s;
	cin>>n>>q;
	cin>>s;
	for(int i=1;i<n;i++)
	{
		if(s.substr(i-1,2)=="AC")cnt[i]++;
		cnt[i]+=cnt[i-1];
	}
	for(int i=0;i<q;i++)
	{
		cin>>a>>b;
		cout<<cnt[b-1]-cnt[a-1]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    double a,b,x,z=acos(-1);
    scanf("%lf%lf%lf",&a,&b,&x);
    if(a*a*b>=x*2)
        printf("%.9f\n",90-180*((atan((2*x)/(a*b*b)))/z));
    else
    {
        x=a*a*b-x;
        printf("%.9f\n",90-180*((atan((a*a*a)/(2*x)))/z));
    }
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    string converted;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'B' && s[i + 1] == 'C') {
            converted += 'D';
            i++;
        } else
            converted += s[i];
    }

    ll A = 0, ans = 0;
    for(int i = 0; i < converted.size(); i++) {
        if(converted[i] == 'A') {
            A++;
        } else if(converted[i] == 'D') {
            ans += A;
        } else
            A = 0;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < n; i++)
using namespace std;

int main(void) {
  int N, A[1000];
  cin >> N;
  REP(i, 0, N) cin >> A[i];
  sort(A, A + N);
  cout << (A[N - 1] - A[0]) << endl;
  return 0;
}


Measured memory_bytes: 256