akhauriyash/Code-Regression huggingface dataset:
//
// Created by kuroneko on 2019-07-06.
//

using namespace std;

#include <iostream>
#include <vector>
#include <cmath>
#include <string>

typedef long long ll;
int INF = 1000000007;

int main() {
    int N; cin >> N;
    vector<pair<pair<string, int>, int>> v(N);

    for (int i = 0; i < N; i++) {
        string s;
        int p;
        cin >> s >> p;
        v[i] = make_pair(make_pair(s, -p), i+1);
    }

    sort(v.begin(), v.end());
    for (int i = 0; i < N; i++) {
        cout << v[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int main(){
  ll n ; cin>> n ;
  string s ; cin>>s ;
  vector<set<int>> st(26) ;
  rep(i,n){
      st[s[i]-'a'].insert(i) ;
  }
  ll q ; cin>> q ;
  while(q--){
    int a ;cin>> a ;
    if(a==1){
     int b ; char c ;
     cin>>b >>c ; b-- ;
     st[s[b]-'a'].erase(b) ;
     s[b]=c ;
     st[s[b]-'a'].insert(b) ;
    }

    else{
      int b, c ; cin >>b>>c ;
      b-- ;c-- ;
      int ans=0 ;
      rep(i,26){
          auto x= st[i].lower_bound(b) ;
          if(x!=st[i].end() &&  *x <= c) ans++ ;
      }
      cout<<ans<<endl ;
    }  
  }
   return 0 ; 
}



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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n, k, q; cin >> n >> k >> q;

    int p[100010] = {0};

    for (int i = 0; i < q; ++i) {
        int a; cin >> a;
        a--;

        p[a]++;
    }

    for (int i = 0; i < n; ++i) {
        if (k - (q - p[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll tmp[M],dp[M];

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

	ll n,w,i,j,u,v;

	cin >> n >> w;

	for(i=1;i<=100000;++i)
		dp[i] = w+1;

	for(i=1;i<=n;++i)
	{
		cin >> v >> u;
		for(j=u;j<=100000;++j)
			tmp[j] = min(dp[j],dp[j-u]+v);
		for(j=u;j<=100000;++j)
			dp[j] = tmp[j];
	}

	for(j=100000;j>=0;j--)
	{
		if(dp[j]<=w)
		{
			cout << j << endl;
			return 0;
		}
	}

	return 0;
}

	


Measured memory_bytes: 5120
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string input;
	int S, h, m, s;

	cin >> input;
	S = stoi(input);

	h = S / (60 * 60);
	S -= h * (60 * 60);
	m = S / 60;
	S -= m * 60;
	s = S;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3208
n = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(n-2): 
    if (p[i] > p[i+1] and p[i+1] > p[i+2]) or (p[i] < p[i+1] and p[i+1] < p[i+2]):
        count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll a, b; cin >> a >> b;
  ll n = b-a;
  cout << n*(n+1)/2 - b << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;
  cin >> A>>B>>C>>K;
  
  if(C > B) swap(B,C);
  if(B > A) swap(A,B);
  
  cout << A * pow(2,K) + B + C << endl;
  
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n:Int = readLine()!!.toInt()
    val dic = mutableMapOf<String,Int>()
    while(n>0)
    {
        val list: List<String> = readLine()!!.split(" ").map { it.toString() }
        when(list[0])
        {
            "insert" -> {
                if (!dic.containsKey(list[1]))
                {
                    dic[list[1]] = n
                }
            }
            "find" -> {
                if (!dic.containsKey(list[1]))
                {
                    println("no")
                }
                else
                {
                    println("yes")
                }
            }
        }
        n--
    }
}


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

class Dice{
private:
	int top,bottom,right,left,front,back;
	
	void North();
	void South();
	void East();
	void West();
	void Right();
	void Left();
	
public:
	Dice(){
		top = 1;
		bottom = 6;
		front = 5;
		back = 2;
		right = 3;
		left = 4;
	}
	
	void Turn(string com){
		if(com == "North")North();
		else if(com == "South")South();
		else if(com == "East")East();
		else if(com == "West")West();
		else if(com == "Right")Right();
		else if(com == "Left")Left();
	}
	
	int GetTop(){
		return top;
	}
	
};

void Dice::North(){
	int temp = top;
	top = back;
	back = bottom;
	bottom = front;
	front = temp;
}

void Dice::South(){
	int temp = top;
	top = front;
	front = bottom;
	bottom = back;
	back = temp;
}

void Dice::East(){
	int temp = top;
	top = left;
	left = bottom;
	bottom = right;
	right = temp;
}

void Dice::West(){
	int temp = top;
	top = right;
	right = bottom;
	bottom = left;
	left = temp;
}

void Dice::Right(){
	int temp = back;
	back = right;
	right = front;
	front = left;
	left = temp;
}

void Dice::Left(){
	int temp = back;
	back = left;
	left = front;
	front = right;
	right = temp;
}

int main() {
	
	int n,sum;
	string command;
	
	while(cin>>n,n){
		Dice dice;
		sum = 0;
		for(int i=0;i<n;++i){
			sum += dice.GetTop();
			cin>>command;
			dice.Turn(command);
		}
		sum += dice.GetTop();
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
s = input()
k = int(input())

def solve(s):
	tmp = ""
	streak = 1
	cnt = 0
	for i in range(len(s)):
		if s[i] == tmp:
			streak += 1
		else:
			cnt += streak // 2
			tmp = s[i]
			streak = 1
	cnt += streak // 2
	return cnt
	

if len(list(set(list(map(str,s))))) == 1:
	ans = len(s)*k//2
elif s[0] == s[-1]:
	key_c = s[0]
	pre_ind = 0
	epi_ind = 0

	for i in range(len(s)):
		if s[i] != key_c:
			pre_ind = i-1
			break
	for i in range(len(s)):
		if s[-(i+1)] != key_c:
			epi_ind = len(s)-i
			break

	cnt_mid = solve(s[pre_ind+1:epi_ind])
	cnt_left = (pre_ind+1)//2
	cnt_right = (len(s)-epi_ind)//2
	cnt_conection = (pre_ind+1+len(s)-epi_ind)//2

	ans = cnt_left + cnt_mid*k + cnt_conection*(k-1) + cnt_right
	

elif s[0] != s[-1]:
	cnt = solve(s)
	ans = cnt * k

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(c==a+b) printf("Yes\n");
  else if(b==a+c) printf("Yes\n");
  else if(a==b+c) printf("Yes\n");
  else printf("No\n");
  return(0);
}


Measured memory_bytes: 128
import math
a, b, x = map(float, input().split())


if x <= (a**2 * b) / 2:
    print(math.degrees(math.atan(a * b**2 / (2 * x))))
else:
    print(math.degrees(math.atan(2 * (a**2 * b - x) / a**3)))


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;
int a, b, n, i, j;
string s, k;

int main(){
	cin>>s;
	if(s[s.size()-1]=='s') cout<<s+"es";
	else cout<<s+"s";
	
	
	return 0;
}



Measured memory_bytes: 3608
import java.util.*;
import java.io.*;

public class Main{

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
            int sum =0;
            for(int i=0 ; i<N ; i++){
                arr[i] = in.nextInt();
                sum =sum +arr[i]-1;
            }
            
           System.out.println(sum);
        
    }
}

Measured memory_bytes: 26064
#include <iostream>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC133();
}

void ABC133(void){
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a<b)cout<<n*a;
    else cout<<b;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

class mint {
  private:
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % mod + mod) % mod) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += mod - right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % mod;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(mod-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n; cin >> n;
  map<int,int> m;

  rep(i, n) {
    int a; cin >> a;
    ++m[a];
  }

  if (n % 2) {
    if (m[0] != 1) cout << 0 << endl;
    else {
      for (int i = 2; i < n; i += 2) {
        if (m[i] != 2) {
          cout << 0 << endl;
          return 0;
        }
      }
      cout << mint(2).pow(n/2).value() << endl;
    }
  } else {
    for (int i = 1; i < n; i += 2) {
      if (m[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
    cout << mint(2).pow(n/2).value() << endl;
  }
}

Measured memory_bytes: 6580
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	grid := make([]string, h)

	yy := make([]bool, h)
	xx := make([]bool, w)
	for i := 0; i < h; i++ {
		yy[i] = false
		grid[i] = getNextString(scanner)
	}
	for i := 0; i < w; i++ {
		xx[i] = false
	}

	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if grid[y][x] == '#' {
				yy[y] = true
				xx[x] = true
			}
		}
	}

	for y := 0; y < h; y++ {
		if yy[y] == false {
			continue
		}
		for x := 0; x < w; x++ {
			if xx[x] == false {
				continue
			}
			fmt.Fprintf(writer, "%c", grid[y][x])
		}
		fmt.Fprintln(writer, "")
	}
	writer.Flush()
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	#define NUM_IN	10
	#define	NUM_OUT	3
	
	int i, j, tmp, height[NUM_IN];
	
	//input
	for( i = 0; i < NUM_IN; i++ )
	{
		scanf( "%d\n", &height[i] );
	}
	
	//sort
	for( i = 0; i < NUM_IN-1; i++ )
	{
		for( j = i+1; j < NUM_IN; j++ )
		{
			if( height[i] < height[j] )
			{
				tmp = height[i];
				height[i] = height[j];
				height[j] = tmp;
			}
		}
	}
	//output
	for( i = 0; i < NUM_OUT; i++ )
	{
		printf( "%d\n", height[i] );
	}
	
	return 0;
}

Measured memory_bytes: 604
def print_ans(input_line):
    """Test Case
    >>> print_ans("12 4")
    4
    """
    A, B = list(map(int,input_line.split()))
    print(str(max(0,A - B * 2)))

if __name__ == '__main__':
    input_line = input()
    print_ans(input_line)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int a, b;
	cin >> a >> b;
	put((a + b - 1) / b);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <cstdlib>

using namespace std;

int arith_op(int lhs, int rhs, char op) {
    switch (op) {
        case '+':
            return lhs+rhs;
        case '-':
            return lhs-rhs;
        case '*':
            return lhs*rhs;
    }
    return 0;
}

int main() {
    stack<int> s;
    for (char buf[1<<4]; scanf("%s", buf)!=EOF;) {
        if (buf[0]>='0' && buf[0]<='9') {
            s.push(atoi(buf));
        } else {
            int rhs=s.top(); s.pop();
            int lhs=s.top(); s.pop();
            s.push(arith_op(lhs, rhs, buf[0]));
        }
    }

    printf("%d\n", s.top());
    return 0;
}

Measured memory_bytes: 2712
#include<stdio.h>
#include<math.h>

typedef struct{
    double x, y;
}Point;

void koch(int n, Point a, Point b){
    if(n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8lf %.8lf\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8lf %.8lf\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8lf %.8lf\n", t.x, t.y);
    koch(n-1, t, b);
}

int main(){
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x=0.0;
    a.y=0.0;
    b.x=100.0;
    b.y=0.0;

    printf("%.8lf %.8lf\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8lf %.8lf\n", b.x, b.y);

    return 0;
}



Measured memory_bytes: 2112
#include <algorithm>
#include <set>
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

const double EPS = 1e-10;

int n, k;
int memo[1500];
vector<pair<double,double> > v;

double dpA[1500][1500];
double dpB[1500][1500];

int main(){  
  scanf("%d%d",&n,&k);

  v.reserve(n);

  const double PI = acos(0.0) * 2;

  REP(i,n){
    int x, y, r;
    scanf("%d%d%d",&x,&y,&r);

    if(y + r <= 0) continue;

    double th  = atan2(y, x);
    double th2 = asin(r/sqrt(x*x+y*y));

    if(y >= 0){
      v.push_back(make_pair(max(th - th2, 0.0), min(th + th2, PI)));
    }else{
      if(x >= 0){
	if(th + th2 > 0.0)
	  v.push_back(make_pair(0.0, th + th2));
      }else{
	th += 2 * PI;
	if(th - th2 < PI)
	  v.push_back(make_pair(th - th2, PI));
      }
    }
  }

  sort(v.begin(), v.end());

 next:
  REP(i,v.size()){
    for(int j = i + 1; j < v.size(); j++){
      if(v[i].second > v[j].second){
	v.erase(v.begin() + j);
	goto next;
      }
    }
  }

  n = v.size();

  REP(i,n){
    memo[i] = -1;
    for(int j = i - 1; j >= 0; j--){
      if(v[i].first < v[j].second + EPS){
	memo[i] = j;
      }else{
	break;
      }
    }
  }

  /*
  REP(i,v.size()){
    printf("%d: %f => %f (%d)\n", i, v[i].f, v[i].s, memo[i]);
  }
  */

  REP(i,n) dpA[i][0] = v[i].s - v[i].f;
  dpB[0][0] = v[0].s - v[0].f;
  REP(i,n - 1) dpB[i + 1][0] = max(dpB[i][0], v[i + 1].s - v[i + 1].f);

  REP(i,n){
    int p = memo[i];
    for(int j = 1; j < k; j++){
      if(j > i){
	dpA[i][j] = dpA[i][j-1];
	dpB[i][j] = dpB[i][j-1];
      }else{
	double A, B;
	if(p == -1){
	  A = 0.0;
	  B = dpB[i - 1][j - 1] + v[i].s - v[i].f;
	}else{
	  A = dpA[p][j - 1] + v[i].s - v[p].s;
	  if(p > 0) B = dpB[p - 1][j - 1] + v[i].s - v[i].f;
	  else      B = v[i].s - v[i].f;
	}

	dpA[i][j] = max(A, B);
	dpB[i][j] = max(dpB[i-1][j], dpA[i][j]);
      }
    }
  }

  // puts("dpA:"); REP(i,n) { REP(j,k) printf("%.2f ", dpA[i][j]); puts(""); }
  // puts("dpB:"); REP(i,n) { REP(j,k) printf("%.2f ", dpB[i][j]); puts(""); }

  printf("%.8f\n", (dpB[n - 1][k - 1] / PI));

  return 0;
}

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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;


int n;
string s, t;
int m[26];
int main() {
    cin >> s >> t;
    n = s.length();
    for (int i = 0; i < 26; ++i) {
        m[i] = i;
    }
    for (int i = 0; i < n; ++i) {
        char o = s[i] - 'a';
        char real = m[o];
        char tar = t[i] - 'a';
        if (real != tar) {
            for (int j = 0; j < 26; ++j) {
                if (m[j] == real) {
                    m[j] = tar;
                } else if (m[j] == tar) {
                    m[j] = real;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        char real = m[s[i] - 'a'];
        if (real != t[i] - 'a') {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
 
#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
 
int N, M, K;
int Asum[200200];
int Bsum[200200];
 
signed main() {
    cin >> N >> M >> K;
    rep(i, N) {
        int a;
        cin >> a;
        Asum[i + 1] = Asum[i] + a;
    }
    rep(i, M) {
        int b;
        cin >> b;
        Bsum[i + 1] = Bsum[i] + b;
    }
    int ans = 0;
    for (int a = 0; a <= N; ++a) {
        if (Asum[a] > K)break;
        int b = upper_bound(Bsum, Bsum + M + 1, K - Asum[a]) - Bsum - 1;
        ans = max(ans, a + b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6672
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	int h;
	cin>>a>>b>>c;
	
	if(a>b){
		h=a;
		a=b;
		b=h;
	}
	if(b>c){
		h=b;
		b=c;
		c=h;
	}
	if(a>c){
		h=a;
		a=c;
		c=h;
		
	}
	if(a>b){
		h=a;
		a=b;
		b=h;
	}
	
	
	
	cout<<a<<' '<<b<<' '<<c<<endl;
	
}


Measured memory_bytes: 3040
N=int(input())
A=[0]
for i in range(1,N+1):
    A.append(int(input()))

ans=0
i=1
while i<=N:
    # print(i)
    # print(A[1:])
    if A[i]>=2:
        ans+=A[i]//2
        A[i]%=2
    # print(A[1:])
    if i<N and A[i]==1 and A[i+1]>=1:
        ans+=1
        A[i]-=1
        A[i+1]-=1
    # print(A[1:])
    # print(ans)
    i+=1

print(ans)


Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
ll n,s;
vector<ll> p,w;
vector<vector<ll> > dp;
ll call(ll s,ll i){
    if(i==(n+1))
    return 0;
    if(s<=0)
    return 0;
    if(dp[s][i]!=-1)
    return dp[s][i];
    ll ans=0;
    ans=call(s,i+1);
    if(s>=w[i])
    ans=max(ans,call(s-w[i],i+1)+p[i]);
    dp[s][i]=ans;
    return ans;
}
int main(){
    fast;
    cin>>n>>s;
    p.resize(n,0);
    w.resize(n,0);
    for(ll i=0;i<n;i++){
        cin>>w[i]>>p[i];
    }
    dp.resize(s+1,vector<ll>(n+1,-1));
    cout<<call(s,0);
}

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

using namespace std;

typedef double Real;
constexpr Real EPS = 1e-8;

//???????????£
int sign(Real d) {
    if (d>EPS) { return 1; }
    if (d<-EPS) { return -1; }
    return 0;
}

/*
 * ???????§?????????????
 */
struct Point {
    Real x,y;

    //Point p(2,3)????¨±???
    explicit Point(Real x_=0, Real y_=0): x(x_), y(y_) {} //explicit?????£??\Point p = x;????¨±????????????????????????

    Point operator+(const Point &p) const {
        return Point(x+p.x,y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x,y-p.y);
    }
    Point operator*(Real s) const {
        return Point(x*s,y*s);
    }
    Point operator/(Real s) const {
        return Point(x/s,y/s);
    }
    bool operator<(const Point &p) const {
        return sign(x - p.x) == -1 || (sign(x - p.x)==0 && sign(y - p.y)==-1);
    }
    bool operator==(const Point &p) const { return sign(x-p.x) == 0 && sign(y - p.y)==0; }

};

//Point??????????????°????????¬??????
istream &operator>>(istream &is, Point &p) {
    return is >> p.x >> p.y;
}
ostream &operator<<(ostream &os, const Point &p) {
    //return os << '(' << p.x << ", " << p.y << ')';
    return os << p.x << " " << p.y;
}

struct Line : public array<Point, 2> { //??????
    Line(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Segment : public array<Point, 2> { //??´???
    Segment(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};


/*
 * Calc
 */
//???????¨??????????90??????
Point rotate90(const Point &p) { return Point(-p.y,p.x); }

//???????¨???????????????±???
Point rotate(const Point &p, Real theta) {
    const Real s = sin(theta), c = cos(theta);
    return Point(c*p.x - s*p.y, s*p.x + c*p.y);
}

Real angle(const Point &p) { return atan2(p.y, p.x); } //[X???]??¨[???????????????P??????]????§????
Real norm(const Point &p) { return p.x * p.x + p.y * p.y; } //??????0????????????P?????§????????¢?????????
Real abs(const Point &p) { return sqrt(norm(p)); } //??????0????????????P?????§????????¢

Real dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; } //??????(?????????????????£?????????)
Real cross(const Point &a, const Point &b) { return a.x * b.y - a.y * b.x; } //??????

/*
 * ?°???±??????
 * http://mathtrain.jp/projection
 */
inline Point project(Line &l, Point &p) {
    const Point a = p - l[0];
    const Point b = l[1] - l[0];
    return l[0] + b * (dot(a,b) / norm(b));
}

int main() {
    cout.setf(ios::fixed);
    cout.precision(10); //?°???°???10?????¨???
    int x0, x1, y0, y1;
    int q;
    int x,y;

    cin >> x0 >> y0 >> x1 >> y1;
    Point p0(x0,y0), p1(x1,y1);
    Line l(p0, p1);
    cin >> q;
    for(int i=0; i<q; i++) {
        cin >> x >> y;
        Point p(x,y);
        Point v = project(l, p);
        cout << v << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3284
from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in P:
  z = bisect.bisect(D[p], y)
  print ("%06d%06d"%(p, z))


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

int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> val(n+1);
  vector<int> wt(n+1);
  int total_val = 0;
  for(int i=1; i<=n; i++){
  	cin >> wt[i] >> val[i];
    total_val += val[i];
  }
  vector<vector<ll>> dp(total_val+1, vector<ll>(n+1, 1e11));
  for(int i=0; i<=n; i++) dp[0][i] = 0;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=total_val; j++){
    	if(j>=val[i]){
          dp[j][i] = min(dp[j-val[i]][i-1] + wt[i], dp[j][i-1]);
        }
      else{
        dp[j][i] = dp[j][i-1];
      }
    }
  }
  ll res = -1;
  for(int i=1; i<=total_val; i++){
    if(dp[i][n]<=w){
    	res = i;
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 85240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, std::vector<long long> H){
  int tallIndex =  0;
  int cnt = 0;
  int maxCnt = 0;
  FOR(x, 1, N) {
    if (H.at(x) <= H.at(x-1)) {
      cnt += 1;
    } else {
      // dv("cnt", cnt);
      maxCnt = max(maxCnt, cnt);
      // dv("maxcnt", maxCnt);
      tallIndex = x;
      cnt = 0;
    }
  }

  maxCnt = max(maxCnt, cnt);
  cout <<  maxCnt << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, std::move(H));
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	int b;
	int c;
	
	scanf("%d", &n);
	
	while (n > 0){
		scanf("%d %d %d", &a, &b, &c);
		if (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		n--;
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9+1;
int main(){
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
  return 0;
} 

Measured memory_bytes: 256
//https://atcoder.jp/contests/arc031/tasks/arc031_2 
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <deque>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	string ans = "No";
	int boolFlag = 0;
	int boolTimes = 0;

	vector<vector<int>> data(n, vector<int>(2));
	rep(i, n) {
		rep(j, 2) {
			cin >> data.at(i).at(j);
		}
	}
	rep(i, n) {
		if (data.at(i).at(0) == data.at(i).at(1)) {
			boolFlag = 1;
		}
		else {
			boolFlag = 0;
		}
		if (boolFlag == 1) {
			++boolTimes;
		}
		else {
			boolTimes = 0;
		}
		if (boolTimes == 3) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long ans = 0;
	int i, j;
	char X[200000];
	int check = 0;
	int count = 0;
	int N;
	
	scanf("%s", X);
	N = strlen(X);
	for(i=0;i<N-1;i++) {
		if(X[i] == 'S') {
			check++;
		} else {
			check--;
		}
		if(check < 0) {
			check = 0;
			count++;
		}
	}
	
	printf("%d\n", count*2);
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define INF 2100000000
const ll mod = 998244353;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<pii> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].x >> v[i].y;
		v[i].y += v[i].x;
	}
	sort(v.begin(), v.end());
	v.push_back(pii(INF, INF + 1));
	vector<ll> dp(n + 1);
	dp[n] = 1;
	vector<int> st = {n};
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1];
		while (st.size() && v[i].y > v[st.back()].x) st.pop_back();
		dp[i] = (dp[i] + dp[st.back()]) % mod;
		st.push_back(i);
	}
	cout << dp[0] << "\n";
	return 0;
}

Measured memory_bytes: 4864
N, A, B = map(int, input().split())


def digit_sum(q):
    if q <= 9:
        return q
    return digit_sum(q // 10) + int(q % 10)


result = 0
for q in range(N + 1):
    if A <= digit_sum(q) <= B:
        result += q
print(result)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,K; cin >> N >> K;
    vei l(N);
    rep(i,N) cin >> l[i];
    sort(rall(l));
    int sum = 0;
    rep(i,K) sum += l[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }

        long[] cumSum = new long[N + 1];
        for (int i = 1; i < N + 1; i++) {
            cumSum[i] = cumSum[i - 1] + A[i - 1];
        }

        long ret = Long.MAX_VALUE;

        int leftp = 0;
        int rightp = 2;

        for (int center = 1; center <= N - 3; center++) {
            long leftSum;
            long rightSum;
            long leftmin;
            leftSum = cumSum[leftp + 1] - cumSum[0];
            rightSum = cumSum[center + 1] - cumSum[leftp + 1];
            leftmin = Math.abs(leftSum - rightSum);

            while (true) {
                leftSum = cumSum[leftp + 2] - cumSum[0];
                rightSum = cumSum[center + 1] - cumSum[leftp + 2];
                if (Math.abs(leftSum - rightSum) > leftmin) break;
                leftmin = Math.abs(leftSum - rightSum);
                leftp++;
            }

            long rightmin;
            leftSum = cumSum[rightp + 1] - cumSum[center + 1];
            rightSum = cumSum[N] - cumSum[rightp + 1];
            rightmin = Math.abs(leftSum - rightSum);

            while (rightp + 2 <= N - 1) {
                leftSum = cumSum[rightp + 2] - cumSum[center + 1];
                rightSum = cumSum[N] - cumSum[rightp + 2];
                if (Math.abs(leftSum - rightSum) > rightmin) break;
                rightmin = Math.abs(leftSum - rightSum);
                rightp++;
            }

            long[] data = new long[4];
            data[0] = cumSum[leftp + 1] - cumSum[0];
            data[1] = cumSum[center + 1] - cumSum[leftp + 1];
            data[2] = cumSum[rightp + 1] - cumSum[center + 1];
            data[3] = cumSum[N] - cumSum[rightp + 1];
            Arrays.sort(data);

            ret = Math.min(ret, data[3] - data[0]);
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 94244
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

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

using namespace std;

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

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

	ll H, W;
	cin >> H >> W;
	string OUT;
	ll count = 0;

	vvl A(H, vl(W));
	rep(i, H) {
		rep(k, W) {
			cin >> A[i][k];
		}
	}

	rep(y, H) {
		rep(x, W-1) {
			if (A[y][x] % 2 == 1) {
				OUT.append(to_string(y + 1) + " " + to_string(x + 1) + " " + to_string(y + 1) + " " + to_string(x + 2) + "\n");
				count++;
				A[y][x]--;
				A[y][x+1]++;
			}
		}
	}

	rep(y, H-1) {
		if (A[y][W - 1] % 2 == 1) {
			OUT.append(to_string(y + 1) + " " + to_string(W) + " " + to_string(y + 2) + " " + to_string(W) + "\n");
			count++;
			A[y][W-1]--;
			A[y+1][W-1]++;
		}
	}

	cout << count << endl;
	cout << OUT;

	return 0;
}



Measured memory_bytes: 6020
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  string s;
  cin>>s;
  string t = s;
  reverse(rng(t));
  if (s == t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;

void solve() {
    string s;
    cin >> s;
    if (s[1] == 'B') cout << "ARC" ;
    else cout << "ABC" ;
    cout << endl;
    return;
}

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


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll i,j,k,n;
    string s;
    cin>>n;
    if(n>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;


    return 0;
}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll = long long;
using namespace std;

int main() {
  ll n;
  cin >> n;

  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    fs.emplace_back(i, x);
  }
  if (n != 1) {
    fs.emplace_back(n, 1);
  }
  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

typedef pair<int, int> pii;

#define f first
#define s second

int h, w, n;

pii nxt(pii a) {
    if (a.f % 2 == 0) {
        if (a.s < w - 1)
            a.s++;
        else
            a.f++;
    }
    else {
        if (a.s > 0)
            a.s--;
        else
            a.f++;
    }
    return a;
}

int main() {

    cin >> h >> w >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<vector<int> > b(h);
    for (int i = 0; i < h; i++)
        b[i].resize(w);
    pii cur(0, 0);
    for (int i = 0; i < n; i++) {
        while (a[i] > 0) {
            b[cur.f][cur.s] = i + 1;
            a[i]--;
            cur = nxt(cur);
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            printf("%d ", b[i][j]);
        printf("\n");
    }

	return 0;
}


Measured memory_bytes: 384
from itertools import accumulate
def acc(X): return list(accumulate(X))

N, M = map(int, input().split())
A = [int(a)-1 for a in input().split()]

X = [0] * M # 1,1,1,...
Y = [0] * M # 1,2,3,...

def tri(l, r, a = 1):
    if l < M:
        Y[l] += a
    if r + 1 < M:
        Y[r+1] -= a
        X[r+1] -= (r-l+1) * a

def box(l, r, a = 1):
    if l < M:
        X[l] += a
    if r + 1< M:
        X[r+1] -= a
    
def calc(a, b):
    if a <= b - 2:
        tri(a+2, b)
    elif a > b and a <= b + M - 2:
        tri(a+2, M-1)
        tri(0, b)
        box(0, b, -a+M-2)
        
    # print(a, b, X, Y, rev())

def rev():
    ret = acc(Y)
    ret = [X[i] + ret[i] for i in range(M)]
    return acc(ret)
    
ans = 0
for i in range(1, N):
    ans += (A[i] - A[i-1]) % M
    calc(A[i-1], A[i])

X = rev()
# print(X)
ans -= max(X)
print(ans)

Measured memory_bytes: 17944
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, T;
    cin >> N >> T;
    int c[N],t[N];
    for( int i=0; i<N; i++){
        cin >> c[i] >> t[i];
    }
    
    int mint;
    mint = 2e3;
    int ans;
    ans = -1;
    for( int i=0; i<N; i++){
        if( t[i] <= T && c[i] <= mint){
            mint = c[i];
            ans = mint;
        }
    }
    if( ans == -1 ){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}



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

string ans;
int w,h,gx,gy;
int map[110][110];
int dx_[4] = {0,1,0,-1};
int dy_[4] = {1,0,-1,0};
int dx[2][8] = {
	{0,1,2,3,0,1,2,3},
	{0,1,0,1,0,1,0,1}
};
int dy[2][8] = {
	{0,0,0,0,1,1,1,1},
	{0,0,1,1,2,2,3,3},
};
void solve(int x,int y,int color){
	if( ans == "OK" || color == 0 /*|| map[y][x] != color*/ ) return;
	//if( x<0 || x>w || y<0 || y>h ) return;

	for(int i=0 ; i<4 ; ++i ){
		int mx = x + dx_[i];
		int my = y + dy_[i];
		if( mx<0 || mx>w || my<0 || my>h ) continue;
		//cout << "x:" << x << " y:" << y << endl;
		
		if( map[my][mx] == color ){
			if( mx == gx && my == gy ){
				ans = "OK";
			}else{
				map[my][mx] = 0;
				solve( mx , my , color );
			}
		}
	}
}

void debug(){
	char c[6] = {' ','#','$','*','+','@'};
	cout << "w:" << w << " h:" << h << " map : " << endl;
	for(int y=0 ; y<h ; ++y ){
		for(int x=0 ; x<w ; ++x ){
			cout << c[ map[y][x] ];
		}
		cout << endl;
	}
}

int main(){
	int sx,sy,n;
	
	while( cin >> w >> h , w|h ){
		ans = "NG";
		for(int y=0 ; y<110 ; ++y )
			for(int x=0 ; x<110 ; ++x )
				map[y][x] = 0;

		cin >> sx >> sy >> gx >> gy >> n ;
		for(int i=0 ; i<n ; ++i ){
			int c,d,x,y;
			cin >> c >> d >> x >> y;
			for(int j=0 ; j<8 ; j++){
				int mx = x + dx[d][j];
				int my = y + dy[d][j];
				map[my][mx] = c;
			}
		}
		//debug();
		//map[sy][sx] = 0;
		solve( sx , sy , map[sy][sx] );
		//cout << "sx:" << sx << " sy:" << sy << endl;
		cout << ans << endl;
	}
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}

int solve(int a,int b){
    if(a==b)return 0;
    return 1+solve(min(a,b),max(a,b)-min(a,b));
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n,cnt=0,c=0;cin>>n;
    string s;cin>>s;
    f(i,0,n){if(s[i]=='W')cnt++;}
    f(i,0,n-cnt){
        if(s[i]=='W')c++;
    }cs(min(c,n-cnt));

    

  }


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int a[n+1];
  for(int i=0;i<=n;i++){
    a[i]=0;
  }
  for(int i=2;i<=n;i++){
    int x;
    cin >> x;
    a[x]++;
  }
  for(int i=1;i<=n;i++){
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
    char c;
    scanf("%c",&c);
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        printf("vowel\n");
    else
        printf("consonant\n");
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 100005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007
int p[MAXX];
void sieve(){
	for(int i = 1; i < MAXX; i ++){
		p[i] = i;
	}
	for(int i = 2; i * i < MAXX; i ++){
		for(int j = i * i; j < MAXX;j += i){
			if(p[j] == j){
				p[j] = i;
			}
		}
	}
}

int main()
{
	FAST;
	sieve();
	int n;
	cin >> n;
	n--;
	while(n ++){
		if(p[n] == n){
			cout << n;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll x;
  cin >> x;
  ll v = 100;
  int i = 0;
  while (v < x) {
    v *= 1.01;
    i++;
  }
  cout << i << endl;
}


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

//int main(void){
//  int K,S;
//  cin >> K >> S;
//  int sum;
//  int count = 0;
//  for(int i = 0; i <= K; i++) {
//    for(int j = 0; j <= K; j++) {
//      for(int l =0; l <= K; l++){
//        sum = i + j + l ;
//        if(sum == S) {
//          count++;
//        }
//      }
//    }
//  }
//  cout << count << endl;
//  return 0;
//}

int main(void){
  int K,S;
  cin >> K >> S;
  int count = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 0; j <= K; j++) {
     int  l = S - i - j;
     if(0 <= l && l <=K) {
       count++;
     }
    }
  }
  cout << count << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsighned long int
 
int main(){
    int n,m;
    cin >> n >> m;
 
    int ans = 0;
 
    while(n > 0){
        n -= m;
        ans++;
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 256