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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	ll n, a, b;
	cin >> n >> a >> b;

	if(n < a + b - 1 || n > a * b) {
		puts("-1");
		return 0;
	}

	int ans[n];
	int cnt = n / a, val = 1;
	int lenb = ceil2(n, a);
	for(int i = 0; i < a; ++i) {

		int idx = i + cnt * a;
		if(idx >= n) {
			--cnt;
			idx = idx - a;
		}
		while(idx >= 0) {
			// cout << idx << endl;
			ans[idx] = val++;
			idx -= a;
		}
	}

	if(lenb < b) {
		// cout << lenb << endl;
		int need = b - lenb + 1;
		int idx = n - 1, currb = idx / a;
		vi tmp;
		while(need > 0) {
			if((idx / a) != currb) {
				++need;
				currb = idx / a;
			}
			// cerr << idx << endl;
			tmp.push_back(ans[idx--]);
			--need;
		}
		sort(tmp.rbegin(), tmp.rend());
		int j = 0;
		// cout << idx << endl;
		for(int i = idx + 1; i < n; ++i, ++j) { ans[i] = tmp[j]; }
	}

	for(int i = 0; i < n; ++i) { cout << ans[i] << " "; }

	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b, x;
    cin >> a >> b >> x;

    if(a+b<x) cout << "NO";
    else{
        int diff = x-a;
        if(diff<0) cout << "NO";
        else cout << "YES";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x (long long n, long long m) {
  long long N;
  if((n - m) >= 0) N = n - m;
  else N = 1000000007 + n - m;
  return N;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  long long s = 0;
  for(int i = 0; i < n; i++) {
    s += a.at(i);
    s = s % 1000000007;
  }
  long long ans = 0;
  for(int i = 0; i < (n - 1); i++) {
    s = x(s, a.at(i));
    long long p = s * a.at(i);
    ans += p;
    ans = ans % 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4792
package main
 
import (
	"fmt"
)
 
func main() {
 
	var a, b, c int
 
	fmt.Scan(&a, &b, &c)
 
	if a < c && b > c || a > c && b < c {
		fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
}

Measured memory_bytes: 512
import java.io.PrintWriter
import java.util.*
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val B = nextIntList().toMutableList()
    val A = ArrayDeque<Int>()
    var i = N - 1
    while (B.isNotEmpty() && i >= 0) {
        if (B[i] == i + 1) {
            A.push(i + 1)
            B.removeAt(i)
            i = B.size - 1
        } else {
            i--
        }
    }
    println(if (B.isEmpty()) A.joinToString("\n") else -1)
}


Measured memory_bytes: 36520
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    int arr[n+1];
    int cnt = 0;
    FOR(i,1,n+1) cin >> arr[i];
    FOR(i,1,n+1)
    {
        if (arr[i] != i)
            ++cnt;
    }
    if (cnt <= 2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

int n;
vi v, c;

int backtrack (int pos, int x, int y) {
  if (pos == n) return x - y;
  return max(backtrack(pos + 1, x + v[pos], y + c[pos]), backtrack(pos + 1, x, y));
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  v.resize(n);
  c.resize(n);
  for (int& elem: v) cin >> elem;
  for (int& elem: c) cin >> elem;
  cout << backtrack(0, 0, 0) << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
}

const long long MAX_N = 100010;
long long ca[MAX_N], cc[MAX_N], cq[MAX_N];

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        ca[i + 1] = ca[i] + (s[i] == 'A');
        cc[i + 1] = cc[i] + (s[i] == 'C');
        cq[i + 1] = cq[i] + (s[i] == '?');
    }
    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'B' || s[i] == '?'){
            long long a = ca[i];
            long long c = cc[n] - cc[i];
            long long leftq = cq[i];
            long long rightq = cq[n] - cq[i + 1];
            long long allq = cq[n] - (s[i] == '?');
            ans += a * c % mod * mod_pow(3, allq);
            ans += leftq * c % mod * mod_pow(3, allq - 1);
            ans += a * rightq % mod * mod_pow(3, allq - 1);
            ans += leftq * rightq % mod * mod_pow(3, allq - 2);
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  string S;cin >> S;
  ll count = 0;
  ll ans = 0;
  if(S.length()<3){
    cout << 0 << endl;
    return 0;
  }
  int i;REP(i,S.length()-2){
    if(S[i]=='A'){
      if(S[i+1]=='A')count++;
      else if(S[i+1]=='B'&&S[i+2]=='C'){
        ans += count + 1ll;
        S[i] = 'B';
        S[i+1] = 'C';
        S[i+2] = 'A';
        i++;
      }else count = 0;
    }else count = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define RALL(a) (a).rbegin(),(a).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;


string reverseLcs(string & a, string & b, vvi & dp, size_t i, size_t j)
{
    if (i == 0 || j == 0) {
        return "";
    }

    if (a.at(i - 1) == b.at(j - 1)) {
        return reverseLcs(a, b, dp, i - 1, j - 1) + a.at(i - 1);
    } else {
        if (dp[i - 1][j] == dp[i][j]) {
            return reverseLcs(a, b, dp, i - 1, j);
        } else {
            return reverseLcs(a, b, dp, i, j - 1);
        }
    }
}

string lcs(string & a, string & b)
{
    vvi dp(a.size() + 1, vi(b.size() + 1));

    FOR(i, 1, dp.size()) {
        FOR(j, 1, dp[0].size()) {
            if (a.at(i - 1) == b.at(j - 1)) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j],
                               dp[i][j - 1]);
            }
        }
    }

    return reverseLcs(a, b, dp, a.length(), b.length());
}

int main()
{
    string str;
    while (cin >> str) {
        string rstr(RALL(str));
        cout << lcs(str, rstr) << endl;
    }

    return 0;
}

Measured memory_bytes: 17268
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

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

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll a[N]={0};ll b[N]={0};
ll n,m,k;
bool check(ll num)
{
	rep(i,0,n+1)
	{
		ll curr=a[i];
		ll more=num-i;

		if(more<=m and more>=0)
		{	curr+=b[more];
			if(curr<=k)
				return 1;
		}
	}
	return 0;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	cin>>n>>m>>k;
	rep(i,1,n+1)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	rep(i,1,m+1)
	{
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll low=0,high=n+m;
	ll ans;
	while(low<=high)
	{
		ll mid=(low+high)/2;
		if(check(mid))
		{
			ans=mid;
			low=mid+1;
		}
		else
			high=mid-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6708
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean ebishu = true;
        for(int i = 0 ; i < n && ebishu ; i++){
            a[i] = sc.nextInt();
            if(a[i] % 2 == 0){
                if(a[i] % 3 == 0 || a[i] % 5 == 0){}else{
                    ebishu = false;
                }
            }
        }
        if(ebishu){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
    }
}
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww

Measured memory_bytes: 35944
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x: usize};

    if x == 2 || x == 3 {
        println!("{}", x)
    } else {
        for i in x..10000000000 {
            let mut k = true;
            let mut j = 3;
            while j <= (i as f64).sqrt() as usize + 2 {
                if i % j == 0 || i % 2 == 0 {
                    k = false;
                    break;
                }
                j += 2;
            }
            if k {
                println!("{}", i);
                break;
            }
        }
    }
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    vector<int>As(N);
    for (int i=0; i<N; i++)cin >> As[i];
    for (int i=0; i<N; i++)As[i]--;
    
    int cnt, curr;
    cnt = curr = 0;

    while (true){
        if(curr == 1)break;
        if (As[curr] == curr or cnt > pow(10,8)){
            cnt = -1;
            break;
        }
        curr = As[curr];
        cnt++;
    
    }
    cout << cnt << endl;
}

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

int main(){
  int a,b,c,d;

  cin >> a >> b >> c >> d;

  if(abs(a - c) <= d){
    cout << "Yes" << endl;
  }
  else if(abs(a - b) <= d && abs(b - c) <= d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    string s;
    cin>>s;
    int n = s.size(), ans = 0;
    f(i, 0, n)
    {
    	char c = s[i];
    	int cnt = 0;
    	if(c == 'S') continue;
    	while(c == s[i]) cnt++, i++;
    	i--;
    	ans = max(ans, cnt);
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

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

int main(){
    int T_a, T_h;
    int A_a, A_h;
    scanf("%d %d %d %d", &T_h, &T_a, &A_h, &A_a);

    while(true){
        A_h -= T_a;
        if(A_h <= 0){
            printf("Yes");
            break;
        }

        T_h -= A_a;
        if(T_h <= 0){
            printf("No");
            break;
        }
    }
}

Measured memory_bytes: 3828
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int64_t i=2; i<=n; ++i) {
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(int64_t j = i*i; j <= n; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    //素数判定
    bool isPrime(int x) {return f[x] == x;}
    //素数判定(1つ用)(宣言はsqrt(x)のサイズで)
    bool isPrime1(int64_t x) {
        bool m = true;
        for(int z:primes) {
            if(!(x%z)) {
                m = false;
                break;
            }
        }
        return m;
    }
    //素数列挙
    vector<int > factorList(int x) {
        assert(x <= n);
        vector<int> res;
        while(x != 1) {
            res.emplace_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    //素因数分解　pair(素数, 素因数の数)
    vector<pair<int, int> > factor(int x) {
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int, int> > res(1, pair<int, int>(fl[0], 0));
        for(int p : fl) {
            if(res.back().first == p) {
                ++res.back().second;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)
    vector<int64_t> factorList1(int64_t x) {
        vector<int64_t> vec;
        for(int z:primes) {
            while(!(x%z)) {
                vec.emplace_back(z);
                x /= z;
            }
        }
        if(x != 1) vec.emplace_back(x);
        return vec;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)　pair(素数, 素因数の数)
    vector<pair<int64_t, int> > factor1(int64_t x) {
        vector<int64_t> vec = factorList1(x);
        vector<pair<int64_t, int> > vecc;
        for(vector<int64_t>::iterator itr = vec.begin(); itr != vec.end(); ++itr) {
            if(itr != vec.begin() && *itr == *(itr-1)) {
                (vecc.end()-1)->second++;
            } else {
                vecc.emplace_back(pair<int64_t, int>(*itr, 1));
            }
        }
        return vecc;
    }
};

int main() {
    ll n;
    cin >> n;
    Sieve pp((int)sqrt(n));
    vector<pair<int64_t, int> > vecc = pp.factor1(n);
    int ans = 0;
    vi v(60);
    v[0] = 1;
    rep(i, 59) {
        v[i+1] = v[i] + i+2;
    }
    rep(i, vecc.size()) {
        auto itr = upper_bound(all(v), vecc[i].second);

        ans += itr-v.begin();
    }
    cout << ans << endl;

}

Measured memory_bytes: 7832
#include <iostream>

using namespace std;

int GCD(int M, int N) {

	while (N != 0) {
		int r = M % N;
		M = N;
		N = r;
	}
	return M;
}

int main() {
	
	int W, H, C;

	while(cin >> W >> H >> C) {

		int G = GCD(W, H);
		cout << (W / G) * (H / G) * C << "\n";

	}

	return 0;

}







Measured memory_bytes: 3124
#!/user/bin/python
# coding: UTF-8

N = int(raw_input())

L = [2, 1, 3, 4,
7,
11,
18,
29,
47,
76,
123,
199,
322,
521,
843,
1364,
2207,
3571,
5778,
9349,
15127,
24476,
39603,
64079,
103682,
167761,
271443,
439204,
710647,
1149851,
1860498,
3010349,
4870847,
7881196,
12752043,
20633239,
33385282,
54018521,
87403803,
141422324,
228826127,
370248451,
599074578,
969323029,
1568397607,
2537720636,
4106118243,
6643838879,
10749957122,
17393796001,
28143753123,
45537549124,
73681302247,
119218851371,
192900153618,
312119004989,
505019158607,
817138163596,
1322157322203,
2139295485799,
3461452808002,
5600748293801,
9062201101803,
14662949395604,
23725150497407,
38388099893011,
62113250390418,
100501350283429,
162614600673847,
263115950957276,
425730551631123,
688846502588399,
1114577054219522,
1803423556807921,
2918000611027443,
4721424167835364,
7639424778862807,
12360848946698171,
20000273725560978,
32361122672259149,
52361396397820127,
84722519070079276,
137083915467899403,
221806434537978679,
358890350005878082,
580696784543856761,
939587134549734843]

print L[N]


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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N;

int main()
{
    cin >> N;
    rep(i, 50001)
    {
        int m = i * 1.08;
        if (m == N)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator 


void solve() {
    int n;cin>>n;
    cout<< pow(2, int(log2(n))) <<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s;
	string temp;
	temp = "";
	for (int i = 0; i < 3; i++) {
		cin >> s;
		temp += s.substr(i, 1);
	}
	cout <<temp<< endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ans = 1e9;

  cin >> N;
  vector<int> W(N);

  for (int i = 0; i < N; ++i) {
    cin >> W[i];
  }

  for (int i = 1 ; i < N; ++i){
    int l = 0, r = 0;
    for (int j = 0; j < i; ++j) l += W[j];
    for (int j = i; j < N; ++j) r += W[j];
    ans = min(ans,abs(l-r));
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll h;
    cin>>h;
    ll sum=0;
    ll time=pow(10,5);
    ll last=0;
    for(ll i=0;i<time;i++){
        if(h==1){
            last=0;
            break;
        }else if(pow(2,i)<=h and h<pow(2,i+1)){
            last=i;
            break;
        }
    }

    for(ll i=0;i<last;++i){
        sum+=pow(2,i+1);
    }
    cout<<sum+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int n,q,a,b,x,y;
vector<vector<int>> d(200010);
vector<int> t(200010,0),v(200010);
int c=0;
void dfs(int p){
  c+=t[p];
  v[p]=c;
  for(auto au:d[p]){
    dfs(au);
  }
  c-=t[p];
}
int main(){
  cin>>n>>q;
  for(int i=0;i<n-1;i++){
    cin>>a>>b;
    d[a].push_back(b);
  }
  for(int i=0;i<q;i++){
    cin>>x>>y;
    t[x]+=y;
  }
  dfs(1);
  for(int i=1;i<=n;i++){
    cout<<v[i]<<" ";
  }
}

Measured memory_bytes: 21120
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn adder (i: usize, j: usize) -> isize{
    let mut pow: usize = 1;
    for k in 1..i {
        pow *= 10;
    }
    (pow * j) as isize
}

fn main(){
    input!{
        x: chars 
    }
    let mut check: bool = true;
    for (i, val) in x.iter().enumerate(){
        if x[i] != x[x.len()-(i+1)] || x[i] != x[if i == (x.len()-1)/2 {i} else if i < (x.len()-1)/2 {((x.len()-1)/2)-(i+1)} else {(x.len()-1) - (i - (x.len()+1)/2)}] {
            check = false;
        }
    }
    print!("{}", if check {"Yes".to_string()} else {"No".to_string()} );
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <memory.h>

int main(void) {
	int i, j, n, t;
	int A[20][20];
	while(scanf("%d\n", &n)==1) {
		if(n == 0) break;
		
		memset((char*)A, 0x00, sizeof(A));
		
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				scanf("%d", &t);
				A[i][j] = t;
				A[i][n] += t;
				A[n][j] += t;
				A[n][n] += t;
			}
		}
		
		for(i=0;i<n+1;i++) {
			for(j=0;j<n+1;j++) {
				printf("%5d", A[i][j]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

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

static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for (int i = 0; i < n; i ++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while (!q.empty()) {
    u = q.front(); q.pop();
    for (int v = 0; v < n; v ++) {
      if (M[u][v] == 0) continue;
      if (d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for (int i = 0; i < n; i ++) {
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;
  cin >> n;

  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < n; j ++) M[i][j] = 0;
  }

  for (int i = 0; i < n; i ++) {
    cin >> u >> k;
    u --;
    for (int j = 0; j < k; j ++) {
      cin >> v;
      v --;
      M[u][v] = 1;
    }
  }

  bfs(0);
}



Measured memory_bytes: 3140
#include <stdio.h>
int main(void){
   int h, m, s, S;
   
   scanf("%d",&S);
   
   s = S % 60;
   m = S / 60 % 60;
   h = S / (60*60);
   
   printf("%d:%d:%d\n", h, m, s);
   
   return 0;
}


Measured memory_bytes: 2104
N, M = [int(i) for i in input().split()]
data_ls = list()
for i in range(N):
    data_ls.append([int(i) for i in input().split()])
data_ls = sorted(data_ls, key=lambda x:x[0])
_sum = 0
_sum_price = 0
for (a,b) in data_ls:
    if b > M - _sum:
        _sum_price += a * (M - _sum)
        break
    else:
        _sum_price += a * b
        _sum += b
print(_sum_price)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#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> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MAXN = 100010;
const int MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000000;

int n;
int a[MAXN];

int main()
{
	/*
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", &a[i]);
	}
	*/
	
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (a-c)*(b-d) << endl;
	
	return 0;
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); i++)
#define f1(i, n) for (i = 1; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

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> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
template< typename T>
T modpow(T number, T power, T mod_value);
//*/

//int row, column;
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
//int dx[4] = {1,  0, -1, 0};
//int dy[4] = {0, -1,  0, 1};
//ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll a, b, k, i;

        cin >> a >> b >> k;

        for (i = a; i <= b; i++)
        {
            if (i < a+k || i >= b-k+1)
                cout << i << endl;
        }
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    }
    return 0;
}


template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
template< typename T>
T modpow(T number, T power, T mod_value)
{
    if (power == 0)
        return 1%mod_value;
    ll u = modpow(number,power/2,mod_value);
    u = (u*u)%mod_value;
    if (power%2 == 1)
        u = (u*number)%mod_value;
    return u;
}

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

int main(int argc, char const *argv[])
{
    int la=65, sa=97;
    int d = sa - la;
    char input;
    string s;
    getline(cin, s, '\n');
    for(int i = 0; i < s.length(); i ++){
        input = s[i];
        if (isalpha(input)){
            input = ((input - la + d)%(2 * d)) + la;
        }
        cout << input;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3156
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL T[100000],A[100000];

LL ans = 1;

void solve(){
    //i番目の山の高さが
    //1~HまでのH種類ありうるときheight_cand_T[i] = Hとする
    //絶対にHのみしかあり得ない時はheight_cand_T[i] = -Hとする
    vector<LL> height_cand_T(N);
    height_cand_T[0] = -T[0];
    for(int i=1;i<N;i++){
        if(T[i]==T[i-1]) height_cand_T[i] = T[i];
        else height_cand_T[i] = -T[i];
    }

    //同様にheight_cand_Aを定義
    vector<LL> height_cand_A(N);
    height_cand_A[N-1] = -A[N-1];
    for(int i=N-2;i>=0;i--){
        if(A[i]==A[i+1]) height_cand_A[i] = A[i];
        else height_cand_A[i] = -A[i];
    }

    for(int i=0;i<N;i++){
        if(height_cand_T[i]<0){
            LL fixed_height = -height_cand_T[i];
            if(height_cand_A[i]<0){
                if(height_cand_T[i]!=height_cand_A[i]){
                    ans = 0;
                    return;
                }
            }else{
                if(fixed_height>height_cand_A[i]){
                    ans = 0;
                    return;
                }
            }
        }else{
            if(height_cand_A[i]<0){
                LL fixed_height = -height_cand_A[i];
                if(fixed_height>height_cand_T[i]){
                    ans = 0;
                    return;
                }
            }else{
                ans = (ans*min(height_cand_A[i],height_cand_T[i]))%mod;
            }
        }
    }
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> T[i];
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,m;cin>>n>>m;
  ll a[n];rep(i,0,n)cin>>a[i];
  ll sum=0;
  rep(i,0,n)sum+=a[i];

  sort(a,a+n,greater<ll>());

  if(a[m-1]>=(lb)sum/(4*m))out("Yes");
  else out("No");




  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define loop(i,a,b) for(int i=a;i<b;i++)
#define scnarr(arr, n) for (int i = 0; i < n; ++i) cin >> arr[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>

//Constants
const int MOD = 1000000007; /* 1e9 + 7*/
const int MAXN = 1000005; /*1e6 +5 */


int spf[1000009]; // stores the smallest prime factor of a number

void sieve()
{
spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;
    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

/* Iterative Function to calculate (x^y)%p in O(log y) */
int power(int x,  int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

void solve()
{
  int k;cin>>k;
  if(k%2==0 || k%10==5)
    cout<<-1<<endl;
  else
  { int cp=k,cnt=0;
      while(cp!=0)
      {
          cp=cp/10;cnt++;
      }
      int req=0;
      for(int i=1;i<=cnt;i++)
      req=req*10+7;
    //   if(req<k)
    //   req=req*10+7;
      int f=1;
      int quo=0;
      while(f==1)
      {
          if(req%k!=0)
          {
              req=req-((req/k)*k);
              req=req*10+7;
              quo++;
          }
          else
          f=0;
      }
      int ans=quo+cnt;
    //   if((k/10) %10==8 && (k%10==3 || k%10==1))
    //   ans++;
      cout<<ans<<endl;
      
  }
}

int32_t main()
{
   // faster;
    //sieve();
    // int t;cin>>t;
    // while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

vector<ll> g[MAX];
ll N;
ll c[MAX];
ll p[MAX];
ll used[MAX];

void bfs() {
  queue<ll> q;
  q.push(0);
  ll id=0;
  p[0]=c[id];
  id++;
  used[0]=1;
  
  ll i, u, v;
  while(q.size()) {
    u=q.front(); q.pop();
    
    for(i=0; i<g[u].size(); i++) {
      v=g[u][i];
      
      if(used[v]) continue;
      p[v]=c[id];
      id++;
      q.push(v);
      used[v]=1;
    }
    
  }
  
}

int main(void) {
  cin >> N;
  ll i;
  
  for(i=0; i<N-1; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].pb(b);
    g[b].pb(a);
    
  }
  
  for(i=0; i<N; i++) {
    cin >> c[i];
  }
  sort(c, c+N);
  reverse(c, c+N);
  
  ll ans=0;
  for(i=1; i<N; i++) {
    ans+=c[i];
  }
  
  pt(ans);
  
  bfs();
  for(i=0; i<N; i++) {
    cout << p[i] << " ";
  }
  cout << endl;
}
  
  


Measured memory_bytes: 3712
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
alist = list(map(int, input().split()))
l = lcm_list(alist)
ans = 0
for a in alist:
    ans += (l - 1) % a
print(ans)


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

int main(){
  int N;
  cin >> N;
  int sum;
  sum=0;
  int tmp = N;

  while(tmp > 0){
  sum += tmp%10;
  tmp/=10;
  }

  if(N%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#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)

class item
{
public:
	int w, v;
	bool operator < (item& rhs){
		if(rhs.v == v)
			return rhs.w > w;
		return rhs.v < v;
	}
};

int N, W;
int knapsack()
{
	vector<item> items(N);

	 LL minwt = LLONG_MAX;
	 REP(i, 0, N){
	 	cin >> items[i].w >> items[i].v;
		minwt = min(minwt, (LL)items[i].w);
	 }
	 VI A, B, C, D;
	 REP(i, 0, N)
	 {
		 int wt = items[i].w, val = items[i].v;
		 if(wt - minwt == 0)
		 	A.push_back(val);
		 else if(wt - minwt == 1)
		 	B.push_back(val);
		 else if(wt - minwt == 2)
		 	C.push_back(val);
		else
			D.push_back(val);
	 }	

	 sort(ALL(A), greater<int>());
	 sort(ALL(B), greater<int>());
	 sort(ALL(C), greater<int>());
	 sort(ALL(D), greater<int>());

	 partial_sum(ALL(A), A.begin());
	 partial_sum(ALL(B), B.begin());
	 partial_sum(ALL(C), C.begin());
	 partial_sum(ALL(D), D.begin());

	 int ans = 0;
	 for(int i = 0; i <= sz(A); ++i)
	 	for(int j = 0; j <= sz(B); ++j)
		 	for(int k = 0; k <= sz(C); ++k)
			 	for(int h = 0; h <= sz(D); ++h)
				{
					LL sumwt = i * minwt + j * (minwt + 1) + k * (minwt + 2) + h * (minwt + 3);
					if(sumwt > W)
						continue;

					int sum = 0;
					if(i > 0) sum += A[i - 1];
					if(j > 0) sum += B[j - 1];
					if(k > 0) sum += C[k - 1];
					if(h > 0) sum += D[h - 1];

					ans = max(ans, sum);
				}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> N >> W;

	cout << knapsack() << endl;	 

	return 0;
}

Measured memory_bytes: 256
//1_2_B ???????????????3.4
#include<stdio.h>
#include<iostream>
#include<algorithm>

//spap??¢??°
void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
	return ;
}

//??????????????¢??°
int printArray(int data[],int num){
	int i;
	for(i=0;i<num;i++){
		if(i!=0)printf(" ");
		printf("%d",data[i]);
	}
	printf("\n");
	return 0;
}

int main(){
	int i,j,k,A[100]={0},count=0;
	int n,min,minI;
	
	scanf("%d",&n);
	//??\???
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	//?????????
	for(j=0;j<n-1;j++){
		minI=j;
		for(i=j;i<n;i++){
			if(A[i]<A[minI]){
				minI=i;
			}
		}
		swap(&A[j],&A[minI]);	//??????
		if(A[j]!=A[minI])count++;
		//printArray(A,n);
	}
	
	printArray(A,n);
	std::cout<<count<<"\n";
	
	return 0;
}

Measured memory_bytes: 3300
#include<cstdio>
using namespace std;
int n,E[300005],W[300005],mn=300005;
char s[300005];
int main()
{
	scanf("%d %c",&n,&s[0]);
	if(s[0]=='E')E[0]=1;
	if(s[0]=='W')W[0]=1;
	for(int i=1;i<n;i++)
	{
		scanf("%c",&s[i]);
		if(s[i]=='E')
		{
			E[i]=E[i-1]+1;
			W[i]=W[i-1];
		}
		if(s[i]=='W')
		{
			W[i]=W[i-1]+1;
			E[i]=E[i-1];
		}
//		printf("%d: %d %d\n",i,W[i],E[i]);
	}
	for(int i=0,tmp;i<n;i++)
	{
		tmp=W[i-1]+E[n-1]-E[i];
		if(tmp<mn)mn=tmp;
	}
	printf("%d",mn);
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
 
#define ft first
#define sd second
 
using namespace std;
 
 
typedef unsigned long long ll;
 
const int MAXN = 100 * 1000 + 12, MXR3 = 2155 + 5;
 
 
 
map<ll, int> mp, tof;
int ans;
 
bool inp[MAXN];
vector<int> p;
 
void gh() {
	inp[0] = inp[1] = true;
	for (int i = 2; i < MAXN; i++)
		if (!inp[i]) {
		    tof[(ll)i * i] = i;
		    if (i < MXR3)
		    	p.push_back(i);
			for (ll j = (ll)i * i; j < MAXN; j += i)
				inp[j] = true;
		}
}
ll kam(ll x) {
	ll ret = 1;
	for (int i = 0; (i < (int)p.size()) && ((ll)p[i] * p[i] * p[i] <= x); i++) {
		ll j = p[i];
		if (x % j == 0) {
			ll m = j * j * j;
			while (x % m == 0)
				x /= m;
			while (x % j == 0)
				ret *= j, x /= j;
		}
	}
	return ret * x;
}
ll ziad(ll x) {
	ll ret = 1;
	for (int i = 0; i < (int)p.size() && (ll)p[i] * p[i] * p[i] <= x; i++) {
		ll j = p[i];
		if (x % j == 0) {
			ll m = j * j * j;
			while (x % m == 0)
				x /= m;
			while (x % j == 0)
				m /= j, x/= j;
			ret *= ((m == j * j * j)? 1: m);
		}
	}
	if (tof[x])
	    return ret * tof[x];
	return ret * x * x;
}
 
 
int main() {
	gh();
	{
		int n;
		ll a;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> a;
			mp[kam(a)]++;
			mp[ziad(a)] += 0;
		}
	}
	for (auto i : mp) {
	    ll x = ziad(i.ft);
	    if (i.ft == 1 && i.sd)
	        ans++;
	    else if (i.ft < x)
	        ans += max(i.sd, mp[x]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()

int main(){
    string s;
    deque<char> dq;
    int q;
    cin >> s >> q;
    rep(i, s.size()) dq.push_back(s[i]);
    bool fore = true;
    rep(i, q) {
        int a, b;
        char c;
        cin >> a;
        if (a==2) {
            cin >> b >> c;
            if (b==1) {
                if (fore) dq.push_front(c);
                else dq.push_back(c);
            } else {
                if (fore) dq.push_back(c);
                else dq.push_front(c);
            }
        } else {
            fore = !fore;
        }
    }
    if (!fore) reverse(all(dq));
    for (auto a: dq) cout << a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
n,k,*l=map(int,open(0).read().split());s=sum(l);L=[]
for i in range(1,int(s**0.5)+1):
  if s%i==0:L+=[i,s//i]
for d in sorted(L)[::-1]:
  a=sorted([m%d for m in l])
  if sum(a[:n-sum(a)//d])<=k:print(d);exit()

Measured memory_bytes: 3060