akhauriyash/Code-Regression huggingface dataset:
const MOD: usize = 1e9 as usize + 7;
fn dp(pos: usize, module: usize, schars: &[char], memo: &mut Vec<Vec<Option<usize>>>) -> usize {
    if pos >= schars.len() {
        let res = if module == 5 { 1 } else { 0 };
        return res;
    }
    if let Some(value) = memo[pos][module] {
        return value;
    }
    let mut result = 0;
    if schars[pos] == '?' {
        for x in 0..10 {
            let next_module = (module * 10 + x) % 13;
            result += dp(pos + 1, next_module, schars, memo);
            result %= MOD;
        }
    } else {
        let next_module = (module * 10 + schars[pos].to_digit(10).unwrap() as usize) % 13;
        result += dp(pos + 1, next_module, schars, memo);
        result %= MOD;
    }
    memo[pos][module] = Some(result);
    return result;
}

fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let schars = sc.chars();
    let mut memo = vec![vec![None; 13]; schars.len() + 1];
    let result = dp(0, 0, &schars, &mut memo);
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 43388
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;


int main() {

int N;
int M;
cin >>N>>M;//N以上の最大の約数を求めたい

int ans=M;

//sqrt(N)以上の約数を調べる．

for(int i=1;i*i<=M; i++){
if(M%i==0 && M/i>=N){ans=M/i;}
}

//sqrt(N)以下の約数を調べる．

for(int i=1;i*i<=M; i++){
if(M%i==0 && i>=N && i<ans){ans=i;}
}

cout <<M/ans;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
int main(){
  int K;
  cin >> K;
  long long ans = 0;
  for(int i = 1; i <= K; ++i){
    for(int j = 1; j <= K; ++j){
      for(int k = 1; k <=K; ++k){
        ans += __gcd(i,__gcd(j,k));
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  long long a[100001];
  long long b[100000];
  cin >> n;
  for(int i = 0; i < n+1; ++i)
    cin >> a[i];
  for(int i = 0; i < n; ++i)
    cin >> b[i];
  
  long long sum = 0;
  for(int i = 0; i < n; ++i) {
    long long r = max(b[i] - a[i], 0LL);
    sum += min(r, a[i+1]);
    a[i+1] = max(a[i+1] - r, 0LL);
    sum += min(b[i], a[i]);
  }
  
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int n;
    cin >> n;
    int d[n+1];
    REPP(i,1,n+1) d[i] = -1;
    int hoge,num;
    vector<vector<int> > bfs(n+1);
    for(int i = 1; i < n+1;i++){
        cin >> hoge >> num;
        for(int l = 0; l < num;l++){
            int tmp;
            cin >> tmp;
            bfs[i].push_back(tmp);
        }
    }

    // 初期セットアップ(index=1)
    queue<pair<int, int> > queue;
    for(int i = 0; i < bfs[1].size();i++){
        queue.push(make_pair(1,bfs[1][i]));
    }
    d[1] = 0;

    while(!queue.empty()){
        if(d[queue.front().second] == -1){
            d[queue.front().second] = d[queue.front().first]+1;
            for(int i = 0; i < bfs[queue.front().second].size();i++){
                queue.push(make_pair(queue.front().second,bfs[queue.front().second][i]));
            }
        }
        queue.pop();
    }

    for(int i = 1; i < n+1;i++){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3152
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	static int n;
	static int w;
	static int[] weights;
	static int[] values;
	static HashMap<String, Long> memo;
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		w = in.nextInt();
		weights = new int[n];
		values = new int[n];
		
		for (int i = 0; i < n; i++) {
			weights[i] = in.nextInt();
			values[i] = in.nextInt();
		}
		memo = new HashMap<String, Long>();
		
		System.out.println(solve2(0, 0));
	}
	
	public static long solve2(int index, long weight) {
		String s = index + "," + weight;
		if (w < weight) {
			return Integer.MIN_VALUE;
		} else if (index == n) {
			return 0;
		} else if (memo.containsKey(s)) {
			return memo.get(s);
		}
		long temp = Math.max(
				solve2(index + 1, weight), 
				values[index] + solve2(index + 1, weight + weights[index])
		);
		
		memo.put(s, temp);
		return temp;
	}
	
public static long solve(int index, long weight, long value) {
	String s = index + "," + weight;
	if (w < weight) {
		return Integer.MIN_VALUE;
	} else if (memo.containsKey(s)) {
		return value + memo.get(s);
	} else if (index == n) {
		return value;
	} 
	
	long temp = Math.max(
			solve(index + 1, weight, value),
			solve(index + 1, weight + weights[index], value + values[index])
	);
	memo.put(s, temp);
	
	return temp;
}
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n;
    ll cnt_4 = 0;
    ll cnt_2 = 0;
    NREP() {
        cin >> tmp;
        if (tmp % 4 == 0) cnt_4++;
        else if (tmp % 2 == 0) cnt_2++;
    }

    Yn (cnt_4 >= (n - (cnt_2 / 2) * 2) / 2)
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


template <class T>
T digitSum(T num) {
    ll sum = 0;
    while (num != 0) {
        sum += num%10;
        num /= 10;
    }
    return sum;
}

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

    // input
    int A, B;
    cin >> A >> B;
    
    // calculation
    int sum = 0;
    string str, front, back;
    for (int i = A; i <= B; ++i) {
        str = to_string(i);
        front = str.substr(0, 2);
        back = str.substr(3, 2);
        reverse(back.begin(), back.end());
        if (front == back) {
            sum++;
        }
    }
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	
	int c = a / b;
	
	if(a % b == 0) {
		printf("%d", c);
	} else {
		printf("%d", c + 1);
	}
	
	return 0;
}

Measured memory_bytes: 3136
# # -*- coding: utf-8 -*-

#
N, M = map(int, input().split(' '))
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

#
import collections
buf = collections.deque()
parents = [-1 for _ in range(N)]

parents[0] = 0
buf.append(0)

while buf:
    src = buf.popleft()
    for dst in graph[src]:
        if parents[dst] == -1:
            parents[dst] = src
            buf.append(dst)

if all([p != -1 for p in parents]):
    print('Yes')
    for p in parents[1:]:
        print(p+1)
else:
    print('No')



Measured memory_bytes: 100056
/*
* author: pavveu
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

struct SegmentTree {
    int N;
    vi lo, hi;
    vll delta, maximum;

    SegmentTree(int n) : N(4*n + 1), lo(N, -1), hi(N, -1), delta(N, 0), maximum(N, 1) {
        init(0, n - 1);
    }

    void init(int a, int b, int i = 1) {
        lo[i] = a; hi[i] = b; 

        if ( a == b ) return;

        int m = (a+b)/2;
        init(a, m, 2*i);
        init(m + 1, b, 2*i + 1);
    }

    void propagate(int i) {
        delta[2*i] += delta[i];
        delta[2*i + 1] += delta[i]; 
        delta[i] = 0;
    }

    void update(int i) {
        maximum[i] = std::max(maximum[2*i] + delta[2*i], maximum[2*i + 1] + delta[2*i + 1]);
    }

    void updateRange(int a, int b, ll val, int i = 1) {
        if ( b < lo[i] || hi[i] < a ) return; 
        else if ( a <= lo[i] && hi[i] <= b ) {
            delta[i] += val;
            return;
        }

        propagate(i);
        updateRange(a, b, val, 2*i);
        updateRange(a, b, val, 2*i + 1);
        update(i);
    }

    ll query(int a, int b, int i = 1) {
        if ( b < lo[i] || hi[i] < a ) return numeric_limits<ll>::min();
        else if ( a <= lo[i] && hi[i] <= b ) {
            return delta[i] + maximum[i];
        }

        propagate(i);
        ll leftMax = query(a, b, 2*i);
        ll rightMax = query(a, b, 2*i + 1);
        update(i);

        return max(leftMax, rightMax);
    }
};


void go() {
	int n, k;
	cin >> n >> k;

	int N = 300'100;
	SegmentTree st(N);
	int best = 1;

	for (int i = 0; i < n; i++ ) {
		int x; cin >> x;

		int mini = x - k; 
		int maxi = x + k;

		mini = max(0, mini);
		maxi = min(N - 1, maxi);

		int ans  = st.query(mini, maxi);
		best = max(best, ans + 1);


		int last = st.query(x, x); 
		st.updateRange(x, x, -last);
		st.updateRange(x, x, ans + 1);
	}
	

	cout <<best - 1 << endl;
}

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

	go();

	return 0;
}


Measured memory_bytes: 31440
#include <stdio.h>
 
int main(void) {
 
  int N, K, x;
  
  scanf("%d %d", &N, &K);
  x = N - K;
  
  if(K==1){
  printf("%d\n", 0);
  }
  else{
  printf("%d\n", x);
  }
 
  return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

w, h, x, y = ril()
s = w * h / 2
if w == 2 * x and h == 2 * y:
    print(s, 1)
else:
    print(s, 0)

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

int main(){
  
  int n;
  cin >> n;
  cout <<setprecision(10);
  if(n%2 == 0) cout << 0.5000000000 <<endl;
  else {
    cout << (n/2+1.0)/n <<endl;
  } 

  
  
  
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ans++;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long ll;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

void solve_case() {
  int n, r;cin >> n >> r;
  int ans = 0;
  while(n >= 1){
    ans++;
    n /= r;
  }
  cout << ans;

}

/**************/


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int tt = 1;
  // cin >> tt;
  while (tt--) {
    solve_case();
  } 
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;

  int odds[] = {3, 5, 7, 9, 11, 13};
  int size = 6;
  int count = 0;

  for (int i = 0; i < size; i++) {
    for (int j = i + 1; j < size; j++) {
      for (int k = j + 1; k < size; k++) {
        int prod = odds[i] * odds[j] * odds[k];
        if (prod <= n) {
          count++;
        }
      }
    }
  }
  std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	string t;
	for (auto i : s) {
		if (i != 'x') {
			t += i;
		}
	}
	if (t.empty()) {
		cout << "0\n";
		return 0;
	}
	string u = t;
	reverse(u.begin(), u.end());
	if (t != u) {
		cout << "-1\n";
		return 0;
	}
	vector<int>box;
	int bag = 0;
	for (auto i : s) {
		if (i == 'x') {
			bag++;
		}
		else {
			box.push_back(bag);
			bag = 0;
		}
	}
	box.push_back(bag);

	N = box.size();

	for (int i = 0; i < N / 2; i++) {
		M += abs(box[i] - box[N - i - 1]);
	}
	cout << M << endl;
	return 0;
}

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

using namespace std;
#define ml 200005
#define ll long long
int n;
ll a[ml];
int main()
{
    ll tal=0;
    scanf("%d",&n);
    int f=0;
    scanf("%lld",&a[1]);
    {
        if(a[1]!=0)
         {
             f=1;
         }
    }
    for(int i=2;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]-a[i-1]>=2)
        {
            f=1;
        }
        else if(a[i]-a[i-1]==1)
        {
            tal++;
        }
        else
        {
            tal+=a[i];
        }

    }
    if(f==1)
        printf("-1");
    else
    printf("%lld",tal);

    //cout << "Hello world!" << endl;
    return 0;
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int64_t> P, Q, R;
    for (int i = 0; i < A; ++i) {
        int64_t p;
        cin >> p;
        P.push_back(p);
    }
    for (int i = 0; i < B; ++i) {
        int64_t q;
        cin >> q;
        Q.push_back(q);
    }
    for (int i = 0; i < C; ++i) {
        int64_t r;
        cin >> r;
        R.push_back(r);
    }

    sort(P.begin(), P.end(), std::greater<int64_t>());
    sort(Q.begin(), Q.end(), std::greater<int64_t>());
    sort(R.begin(), R.end(), std::greater<int64_t>());
    vector<int64_t> pacc, qacc, racc;
    int64_t mx = 0;

    pacc.push_back(0);
    for (int i = 0; i < A; ++i) {
        pacc.push_back(pacc.back() + P[i]);
    }
    qacc.push_back(0);
    for (int i = 0; i < B; ++i) {
        qacc.push_back(qacc.back() + Q[i]);
    }
    racc.push_back(0);
    for (int i = 0; i < C; ++i) {
        racc.push_back(racc.back() + R[i]);
    }

    const function<int64_t(int, int)> f = [&](int x, int y) {
        return pacc[X - x] + qacc[Y - y] + racc[x + y];
    };

    for (int x = 0; x <= min(C, X); ++x) {
        int ymin = 0, ymax = min(C - x, Y);
        while (true) {
            int c1 = (ymin * 2 + ymax) / 3, c2 = (ymin + ymax * 2) / 3;
            if (c1 == ymin || c2 == ymax) { break; }
            if (f(x, c1) >= f(x, c2)) { ymax = c2; }
            else { ymin = c1; }
        }
        for (int c = ymin; c <= ymax; ++c) {
            mx = max(f(x, c), mx);
        }
    }
    cout << mx << endl;
} 

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

int main(){
  int N;
  cin >> N;
  bool a=false;
  for(int i=0;i<N;i++){
    char A;
    cin >> A;
    if(A=='Y'){
      a=true;
      break;
    }
  }
  
  if(a){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 10;
int n, tot, f[N], a[N], res[N];
int cnt, h[N], to[N << 1], nxt[N << 1];
void add (int u, int v) {
    to[++cnt] = v, nxt[cnt] =h[u], h[u] = cnt;
}
void dfs (int u, int la) {
    int k = 0, pos, num;
    if (a[u] > f[tot]) k = 1, f[++tot] = a[u], res[u] = tot;
    else {
        pos = lower_bound (f + 1, f + tot + 1, a[u]) - f;
        num = f[pos], f[pos] = a[u], res[u] = tot;
    }
    for (int i = h[u]; i; i = nxt[i])
        if (to[i] != la) dfs (to[i], u);
    k ? --tot : f[pos] = num;
}
signed main() {
    read (n);
    for (int i = 1; i <= n; ++i) read (a[i]);
    for (int i = 1, u, v; i < n; ++i)
        read (u), read (v), add (u, v), add (v, u);
    dfs (1, 0);
    for (int i = 1; i <= n; ++i)
        printf ("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 23396
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  ll N = s.size();
  ll cnt = 0;
  rep(i, N){
    if(s[i] == 'p'){
      cnt++;
    }
  }

  cout << (N / 2) - cnt << endl;
  
  return 0;
}

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

int main(){
	int n, a;
	cin >> n >> a;
	cout << n*n - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int l=0;l<=c;l++){
                if(i*500+j*100+50*l==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 45

int fibont(int ,int *);

int main(){
  int n=0;
  int i=0;
  int db[MAX];
  for(i=0;i<MAX;i++) db[i]=-1;
  
  scanf("%d",&n);
  printf("%d\n",fibont(n,db));

  return 0;
}

int fibont(int k,int *db){
  if(k==0 || k==1){
    db[k]=1;
    return db[k];
  }
  if(db[k]!=-1) return db[k];

  return db[k]=fibont(k-1,db)+fibont(k-2,db);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=2000010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll n,ll k){
  k%=mod-1; if(k<0)k+=mod-1;
  ll ret=1; while(k){ if(k&1)ret=ret*n%mod; n=n*n%mod; k>>=1; }
  return ret;
}
ll modinv(ll a){ return modpow(a, mod-2); }

int main(){
  mod_build(mx);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  mint ans = comb(c+1+d+1,c+1) - comb(c+1+b,c+1) - comb(a+d+1,d+1) + comb(a+b,a);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,x,m,i;
  cin >> n >> x >> m;
  map<ll,ll> mp;
  ll ans=0;
  for(i=0;i<n;i++){
    if(mp[x]==0){
      mp[x]=1;
      ans+=x;
    }
    else{
      break;
    }
    x=x*x%m;
  }
  ll y=n-i;
  ll first=x,res=0,sum=0;
  vector<ll> jo;
  jo.push_back(0);
  while(1){
    if(i==n){
      break;
    }
    sum+=x;
    jo.push_back(sum);
    i++,res++;
    x=x*x%m;
    if(first==x){
      break;
    }
  }
  if(i==n){
    cout << ans+sum << endl;
    return 0;
  }
  cout << ans+sum*(y/res)+jo[y%res] << endl;
}

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


int main(){
  string s;
  cin >> s;
  int a,b,c,d;
  //cin >> a >> b >> c >> d;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  d=s[3]-'0';
  if(a+b+c+d==7){
    printf("%d+%d+%d+%d=7\n",a,b,c,d);
  }else if(a+b+c-d==7){
    printf("%d+%d+%d-%d=7\n",a,b,c,d);
  }else if(a+b-c+d==7){
    printf("%d+%d-%d+%d=7\n",a,b,c,d);
  }else if(a-b+c+d==7){
    printf("%d-%d+%d+%d=7\n",a,b,c,d);
  }else if(a+b-c-d==7){
    printf("%d+%d-%d-%d=7\n",a,b,c,d);
  }else if(a-b-c+d==7){
    printf("%d-%d-%d+%d=7\n",a,b,c,d);
  }else if(a-b+c-d==7){
    printf("%d-%d+%d-%d=7\n",a,b,c,d);
  }else{
    printf("%d-%d-%d-%d=7\n",a,b,c,d);
  }
  return 0;
}


Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc128/tasks/abc128_d"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int N,K;
    cin>>N>>K;

    vector<int>V(N);
    int i;
    for(i=0;i!=N;i++)
        cin>>V[i];

    int R,P,M;
    M = 0;
    for(R=0;R<=min(N,K);R++)
    {
        P = min(K-R,R);
        int l,r;
        for(l=0;l<=R;l++)
        {
            r = R-l;

            int m = 0;
            vector<int>Q;
            for(i=0;i<l;i++)
            {
                 Q.push_back(V[i]);
                 m += V[i];
            }
            for(i=N-1;i>=N-r;i--)
            {
                Q.push_back(V[i]);
                m += V[i];
            }

            sort(Q.begin(),Q.end());
            for(i=0;i<P && Q[i]<0;i++)
                m -= Q[i];

            M = max(m,M);
        }
    }

    cout<<M;

    return 0;
}


Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int[] high = new int[10];
            for (int n = 0;n<=9 ; n++)
            {
                high[n] = int.Parse(Console.ReadLine());
                high[n] = -1 * high[n];
            }
            Array.Sort(high);
            for (int n = 0; n <= 2; n++)
            {
                high[n] = high[n] * (-1);
                Console.WriteLine(high[n]);
            }
        }
    }

Measured memory_bytes: 5740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        static bool[] primes = Enumerable.Repeat<bool>(true,10001).ToArray(); 
        
        public static void Main(String[] args) {
            string line;
            initPrimes();
            while ((line = Console.ReadLine())!=null) {
                int n = int.Parse(line);
                int count = 0;
                for (int i = 1; i <= n; i++) {
                    if (primes[i] == true && primes[n + 1 - i] == true) { count++; }
                }
                Console.WriteLine(count);
            }
        }
        private static void initPrimes() {
            primes[1]=false; primes[0] = false;
            for (int i = 2; i <= 10000 / 2; i++) {
                if (primes[i] == false) { continue; }
                if (primes[i] == true) {
                    for (int j = 2; j * i <= 10000; j++) {
                        primes[i * j] = false;
                    }
                }
            }

        }
    }
}

Measured memory_bytes: 5944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long x = sc.nextLong();
		
		sc.close();
		
		long ans = n;
		long w = x;
		long h = n-x;
		while(true) {
			if(w < h) {
				long m = h/w;
				ans += 2*w*m;
				if(h%w == 0) {
					ans -= w;
					break;
				}
				h -= m*w;
			} else {
				long m = w/h;
				ans += 2*h*m;
				if(w%h == 0) {
					ans -= h;
					break;
				}
				w -= m*h;
			}
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 9936
N = int(input())
X = list(map(int, input().split()))

x_sorted = sorted([[i, X[i]] for i in range(N)], key=lambda x: x[1])
mid = (x_sorted[N//2-1][1] + x_sorted[N//2][1]) / 2
for i in range(N):
    if X[i] >= mid:
        print(x_sorted[N//2-1][1])
    else:
        print(x_sorted[N//2][1])

Measured memory_bytes: 121812
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  double res = 0;
  for (int i = 1; i <= min(N, K - 1); ++i) {
    res += pow(0.5, ceil(log2(ceil((double)K / i))));
  }
  printf("%.10f\n", (res + max(0, N - K + 1)) / N);
}

Measured memory_bytes: 3448
#include<stdio.h>

  int main(void)
  {
    int H,A;
    
    scanf("%d",&H);
    scanf("%d",&A);
    int r;
    for(r = 0;H>0;r++)
    {
      H=H-A;
    }
    
    printf("%d",r);
    return 0;
  }

Measured memory_bytes: 128
import math
N = int(input())
S = [list(map(str, input())) for _ in range(N)]
S.sort()
for s in S:
    s.sort()

ans = 0

dic = {}

SS = []

for s in S:
    SS.append("".join(s))

for i in range(N):
    if SS[i] in dic:
        dic[SS[i]] += 1
    else:
        dic[SS[i]] = 1

for key in dic:
    if dic[key] > 1:
        ans += dic[key] * (dic[key] - 1) // 2

print(ans)

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

#define ff first
#define ss second
#define pb push_back

const int MAXN = 2e5 + 21;

long long n, m;
long long top, x;
long long q[MAXN], c[MAXN], ans[MAXN];

inline void solve(long long len, int id) {
    int tmp;    
    if (!len) 
        return;
    if (len <= q[1]) {
        ans[0] += c[id]; 
        ans[len] -= c[id];
    }
    else {
        tmp = upper_bound(q + 1, q + m + 1, len) - q - 1;
        c[tmp] += len / q[tmp] * c[id];
        solve(len % q[tmp], id);
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    q[top = 1] = n;
    
    for (int i = 0; i < m; i++) {
        cin >> x;
        while (top && q[top] >= x) 
            top--;

        q[++top] = x;
    }

    c[top] = 1;
    m = top;

    for (int i = m - 1; i > 0; i--) {
        c[i] += q[i + 1] / q[i] * c[i + 1]; 
        solve(q[i + 1] % q[i], i + 1);
    }

    ans[q[1]] -= c[1];
    ans[0] += c[1];

    cout << ans[0] << '\n';
    for (int i = 1; i < n; i++) {
        ans[i] += ans[i - 1];
        cout << ans[i] << '\n';
    }
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

void func_d(string S) {
	int R = 0, L = 0;
	vector<long> Rp;
	vector<long> Rn;

	vector<long> Lp;
	vector<long> Ln;
	
	vector<long> num(S.size());

	//RRRRR(RL)の探索
	for (int i = 0; i < S.size() - 1; i++) {
		
		if (S[i] == 'R' && S[i + 1] == 'L') {
			Rp.push_back(i);
			Rn.push_back(R);
			R = 0;
		}
		else if (S[i] == 'R') {
			R++;
		}
	}
	//(RL)LLLLLの探索
	for (int i = S.size()-1; i>0; i--) {
		
		if (S[i-1] == 'R' && S[i] == 'L') {
			Lp.push_back(i);
			Ln.push_back(L);
			L = 0;
		}
		else if (S[i] == 'L') {
			L++;
		}
	}
	int size = Rp.size()-1;

	for (int i = 0; i <= size; i++) {
		long tempR = 0;
		long tempL = 0;


		if (Rn[i] % 2 == 0) {
			tempR += Rn[i] / 2;
			tempL += Rn[i] / 2;
		}
		else {
			if (Rn[i] != 1) {
				tempR += Rn[i] / 2;
				tempL += (Rn[i] / 2) + 1;
			}
			else {
				tempL += 1;
			}
		}

		if (Ln[size - i] % 2 == 0) {
			tempR += Ln[size - i] / 2;
			tempL += Ln[size - i] / 2;
		}
		else {
			if (Ln[size - i] != 1) {
				tempR += (Ln[size - i] / 2)+1;
				tempL += (Ln[size - i] / 2);
			}
			else {
				tempR += 1;
			}
		}

		num[Rp[i]] = tempR + 1;
		num[Lp[size - i]] = tempL + 1;
	}
	for (int i = 0; i < S.size()-1; i++) {
		cout << num[i] << " ";
	}
	cout<< num[S.size() - 1] <<endl;
	
}

int main()
{
	string S;
	cin >> S;
	func_d(S);
}

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

int main() {
  int N, K, tmp = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    int a = tmp, b = tmp;
    
    a += K;
    b *= 2;
    
    if(a < b){
      tmp = a;
    }else{
      tmp = b;
    } 
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BBalance {
public:
        int A[111];
        int S[111];
void solve(std::istream& cin, std::ostream& cout) {
    int N;
    cin >> N;
    _for(i,N)cin >> A[i];
    S[0] = 0;
    _for(i,N)S[i+1] = S[i] + A[i];
    int mi = 1e9;
    _for(i,N+1)mi = min(mi, abs(2*S[i] - S[N]));
    cout << mi << endl;
}
};


#undef int
int main() {
	BBalance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#coding: UTF-8

def SLE(a,b):
    if a > b:
        return "a > b"
    elif a < b:
        return "a < b"
    else:
        return "a == b"

if __name__=="__main__":
    a = input().split(" ")
    ans = SLE(int(a[0]),int(a[1]))
    print(ans)

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

int main(void){
    double a, b, x;
    scanf("%lf %lf %lf", &a, &b, &x);

    if(x == a*a*b){
        printf("%lf", (double)0);
        return 0;
    }

    double ans;
    double l;
    if(a*a/2*b <= x){
        l = 2/(a*a)*(x-a*a*b/2);
        ans = 90- atan(a/(b-l))/M_PI*180;
    }else{
        l = 2*x/(a*b);
        ans = 90- atan(l/b)/M_PI*180;
    }

    printf("%lf", ans);

    return 0;

}

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

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

Graph G;
vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if(e.first == p) continue;
        if(e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    int n, u, v, w;
    cin >> n;
    G.assign(n, vector<Edge>());
    for(int i = 0; i < n-1; ++i) {
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(n, 0);
    dfs(0, -1, 1);
    for(auto v : res) cout << v << '\n';
 
    return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main(void){
string b;
getline(cin,b);
if(b=="A"){cout<<"T"<<endl;}
  else if(b=="T"){cout<<"A"<<endl;}
  else if(b=="C"){cout<<"G"<<endl;}
 else if(b=="G"){cout<<"C"<<endl;}
  return 0;


}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	vector<bool> w(f + 1, false), s(f + 1, false);
	w[0] = s[0] = true;
	for(int i = 0; i < f + 1; i++) {
		if(w[i]) {
			if(i + a * 100 <= f) {
				w[i + a * 100] = true;
			}
			if(i + b * 100 <= f) {
				w[i + b * 100] = true;
			}
		}
		if(s[i]){
			if(i + c <= f) {
				s[i + c] = true;
			}
			if(i + d <= f) {
				s[i + d] = true;
			}
		}
	}
	double conc = 0;
	int ans1 = 0, ans2 = 0;
	for(int i = 0; i <= f; i++) {
		for(int j = 0; j <= f; j++) {
			if(w[i] && s[j]) {
				double total = (double)i + (double)j;
				if((double)j / total >= conc && i + j <= f && double(j) / double(i) <= e / (1.0 * 100)) {
					conc = (double)j / total;
					ans1 = (int)total;
					ans2 = j;
				}
			}
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>

int a[100005];
int button[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

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

	i=1;

	int ans=0;

	while(1){

		if(i==2){break;}

		if(button[i]==1){
			printf("-1\n");
			return 0;
		}

		button[i]=1;
		i=a[i];
		ans++;
	
	}

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

	return 0;
}

Measured memory_bytes: 896
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

void printVector(vector<int> vec);

int main() {
	unsigned long int H;
	cin >> H;
	unsigned long int attacks = pow(2, floor(log2(H))+ 1) - 1;
	cout << attacks << endl;
}

void printVector(vector<int> vec) {
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 384
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
ll max_lim(ll n)
{
	ll sum=0;
	vector<ll>v(64);
	for(int i=1;i<=64;i++)
	{
		sum+=i;
v[i-1]=sum;
	}
	auto it=upper_bound(all(v),n);
	it--;
	int index=it-v.begin()+1;
	return index;	
}
void solve()
{
fastio
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=2;i*i<=n;i++)
	{
		ll pow=0;
		if(n%i==0)
		{
			while(n%i==0)
			{
				n/=i;
                pow++;
			}
          ans+=max_lim(pow);
		}
	}
	if(n!=1)
	{
		ans++;
	}
	cout<<ans;
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3696
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut x: usize = itr.next().unwrap().parse().unwrap();

    let ans = x / 500;
    x -= ans * 500;
    println!("{}", ans * 1000 + x / 5 * 5);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n, i, ans=0;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  sort(a, a+n);
  int res0=1, res1=1, res2=1;
  for(i=1; i<=n; i++){
    if(a[i]==a[i-1]){
      res0++;
      res1++;
      res2++;
    }
    else if(a[i]==a[i-1]+1){
      if(res0>ans) ans=res0;
      res0=res1+1;
      res1=res2+1;
      res2=1;
    }
    else if(a[i]==a[i-1]+2){
      if(res0>ans) ans=res0;
      res0=res2+1;
      res1=1;
      res2=1;
    }
    else{
      if(res0>ans) ans=res0;
      res0=res1=res2=1;
    }
  }
    if(res0>ans) ans=res0;
    cout << ans;
    return 0;
  }


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

int n, s, t;
vector<pii> ten;

int dp[3001][3001];

int func(int p, int ct) {
	if (p == n)
		return 0;
	if (~dp[p][ct])
		return dp[p][ct];
	int res = 0;

	res = max(res, func(p + 1, ct));
	if(ct < s)
		res = max(res, func(p + 1, s));
	if (((ct >= s) || (s >= (ct + ten[p].second))) && t >= (ct + ten[p].second)) {
		res = max(res, func(p + 1, ct + ten[p].second) + ten[p].first);
	}
	else
		res = res;

	dp[p][ct] = res;
	return res;
}

signed main() {
	scnaf("%d %d %d", &n, &t, &s);
	Fill(dp, -1);
	ten.resize(n);
	REP(i, n) {
		scnaf("%d %d", &ten[i].first, &ten[i].second);
	}

	printf("%d\n", func(0, 0));

	return 0;
}

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

#define MAXN 100005

typedef long long lint;

using namespace std;

const lint M = 100000;
const lint N = 2200;
int n, total, ans;
int prime[MAXN], v[MAXN];
map<lint, int> record, same;
lint a[MAXN];

lint read() {
    char c = getchar();
    lint x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

void sieve() {
    for (int i = 2; i <= N; ++i) {
        if (!v[i])
            prime[++total] = i;
        for (int j = 1; j <= total && i * prime[j] <= N; ++j) {
            v[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
        }
    }
}

lint power(lint a, int b) {
    lint res = 1;
    while (b) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void divide(lint x) {
    lint rev = 1, cur = 1;
    for (int i = 1; i <= total; ++i)
        if (x % prime[i] == 0) {
            int sum = 0;
            while (x % prime[i] == 0) {
                x /= prime[i];
                ++sum;
            }
            sum %= 3;
            if (sum != 0) {
                rev = rev * power(prime[i], 3 - sum);
                cur = cur * power(prime[i], sum);
            }
        }
//    if (cur == 10034)
//        cout << 10034 * 10034 << endl;
    if (x != 1) {
        if (x >= M) {
            if ((lint)sqrt(x) * (lint)sqrt(x) != x) {
                ++ans;
                return ;
            }
            rev = rev * sqrt(x);
            cur = cur * x;
        }
        else {
            rev = rev * x * x;
            cur = cur * x;
        }
    }
    if (rev == cur) {
        ans += !record[cur];
        record[cur] = true;
        return ;
    }
    ans -= max(record[rev], record[cur]);
    ++record[cur];
    ans += max(record[rev], record[cur]);
}

int main() {
//    freopen("01.txt", "r", stdin);
    sieve();
    n = (int)read();
    for (int i = 1; i <= n; ++i)
        divide(a[i] = read());
    printf("%d\n", ans);
}



Measured memory_bytes: 11264
# atcoder DPまとめ
# C-Vacation

def get_inputs():
    n = int(input())
    hap = []
    for _ in range(n):
        hap.append([int(x) for x in input().split()])
    
    return n, hap


if __name__ == "__main__":
    n, hap = get_inputs()
    
    dp = [[0, 0, 0] for _ in range(n + 1)]
    
    for i in range(1, n + 1):
        # i-1日にA:0の遊びをしたときの最大の幸福度を求める
        dp[i][0] = hap[i - 1][0] + max(dp[i - 1][1], dp[i - 1][2])
        # 同様にB:1の遊びをした時の最大の幸福度
        dp[i][1] = hap[i - 1][1] + max(dp[i - 1][0], dp[i - 1][2])
        # 同様にc:2の遊びをした時の最大の幸福度
        dp[i][2] = hap[i - 1][2] + max(dp[i - 1][0], dp[i - 1][1])
    
    print(max(dp[n]))

Measured memory_bytes: 44148
class UnionFind:

    def __init__(self, n):
        self.table = [-1] * (n + 1)
        self.size = [1] * (n + 1)

    def merge(self, r1, r2):
        self.table[r1] = r2
        self.size[r2] += self.size[r1]
        self.size[r1] = 0

    def find_root(self, k):
        path = []
        curr = k
        while self.table[curr] != -1:
            path.append(curr)
            curr = self.table[curr]
        for i in path:
            self.table[i] = curr
        return curr


def solve(string):
    n, m, *ab = map(int, string.split())
    ab = ab[::-1]
    ans = [n * (n - 1) // 2]
    uf = UnionFind(n)
    for _b, _a in zip(ab[::2], ab[1::2]):
        ra = uf.find_root(_a)
        rb = uf.find_root(_b)
        if ra == rb:
            ans.append(ans[-1])
            continue
        ans.append(ans[-1] - uf.size[ra] * uf.size[rb])
        uf.merge(ra, rb)
    return "\n".join([str(a) for a in ans[:-1][::-1]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Measured memory_bytes: 26672