akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

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

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}
//sort pair by first vals in descending
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.first > b.first); 
} 

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

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


    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-10000001;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

        for(int i=0;i<l;i++){
            sum+=v[i];
            if(v[i]<0) {
                te.push_back(v[i]);
            }
        }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
            if(min(a,b)!=0) {
                for (int tt = 0; tt < min(a, b); tt++) {
                    if (te[tt] < 0) {

                        sum -= te[tt];

                        if (ans < sum) {
                            ans = sum;
                        }

                    } else { break; }
                    //cout<<l<<" "<<r<<" "<<sum<<endl;

                }
            }else {
                if (ans < sum) {
                    ans = sum;
                }
            }




        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    using Pi = pair < int , int >;
     
    int main()
    {
            int min_cost[3][100005];
            int N, M;
            int S, T;
            vector < int > G[100005];
            
            cin >> N >> M;
            
            while ( M-- ) {
                    int a, b;
                    cin >> a >> b;
                    G[a-1].push_back(b-1);
            }
            
            cin >> S >> T; --S, --T;
     
            queue < Pi > que;
     
            fill_n(*min_cost, 3 * 100005, -1);
            min_cost[0][S] = 0;
            que.emplace(S, 0);
     
            while ( !que.empty() ) {
                    Pi dat = que.front(); que.pop();
                    int u = dat.first, c = dat.second;
                    for ( int &v : G[u] ) {
                            int nc = (c + 1) % 3, cost = (c + 1) / 3;
                            if ( min_cost[nc][v] == -1 ) {
                                    min_cost[nc][v] = min_cost[c][u] + cost;
                                    que.emplace(v, nc);
                            }
                    }
            }
     
            cout << min_cost[0][T] << endl;
     
            return ( 0 );
    }

Measured memory_bytes: 6912
s = input()
num_s = list(map(int,s))
odd = num_s[0::2]
even = num_s[1::2]

total_count = len(s)
odd_count = len(odd)
even_count = len(even)

odd_sum = sum(odd)
even_sum = sum(even)

rev = 0
rev += abs(odd_count-odd_sum)
rev += even_sum
rev = rev if (total_count // 2 >= rev) else total_count - rev

print(rev)

Measured memory_bytes: 4724
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N,M = map(int,input().split())
S = input()
T = input()
k = gcd(N,M)
n = N//k
m = M//k
flg = False
for i in range(k):
    if S[n*i] != T[m*i]:
        flg = True
if flg:
    print(-1)
else:
    print(N*m)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int B[N + 1];
  REPS(i, 1, N) cin >> B[i];
  B[0] = INF;
  B[N] = INF;

  ll ans = 0;
  REP(i, N) { ans += min(B[i], B[i + 1]); }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;

#define mySwap(a, b) {int temp = a; a = b; b = temp;}

typedef long long ll;
const int MAXN = 1e5+10;

int preGcd[MAXN], postGcd[MAXN], num[MAXN];

int gcd(int a, int b) {
	int temp;
	while (b != 0) {
		temp = a%b;
		a = b;
		b = temp;
	}
	return a;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		scanf("%d", &num[i]);
	}
	preGcd[1] = num[1];
	postGcd[n] = num[n];
	for (int i=2; i<=n; i++) {
		preGcd[i] = gcd(num[i], preGcd[i-1]);
	}
	for (int i=n-1; i>=1; i--) {
		postGcd[i] = gcd(num[i], postGcd[i+1]);
	}
	
	//int ans = max(preGcd[n], postGcd[1]);
	int ans = max(preGcd[n-1], postGcd[2]);
	for (int i=2; i<n; i++)
		ans = max(ans, gcd(preGcd[i-1], postGcd[i+1]));
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	int x, n;
	cin >> x >> n;
	set<int>p;
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		p.insert(y);
	}
	ll gap = 10000;
	ll ans = 10000;
	for (int i = -200; i < 200; i++) {
		if (p.count(i))continue;
		if (gap > abs(x - i)) {
			gap = abs(x - i);
			ans = i;
		}
	}
	cout << ans << endl;
}

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


int main(void) {
	ll n, q;
	cin >> n >> q;
	vector<ll>a(n);
	for (ll i = 0;i < n;i++)cin >> a[i];
	for (ll i = 0;i < q;i++) {
		ll x;cin >> x;
		ll res = 0, sum = 0, r = 0;
		for (ll l = 0;l < n;l++) {
			while ((r < n)&&(sum + a[r] <= x)) {
				sum += a[r];
				r++;
			}
			res += r - l;
			if (l == r)r++;
			else sum -= a[l];
		}
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int A[5];
  int ans = 0;
  int m   = 10;
  for (int i = 0; i < 5; i++) {
	  cin >> A[i];
	  ans += (A[i] - 1) / 10 * 10 + 10;
	  m    = min(m, A[i] % 10 == 0 ? 10 : A[i] % 10);
	}
  cout << ans - (10 - m) << endl;
  return 0;
}


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

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



Measured memory_bytes: 3084
#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.at(i);
  }
  
  int b=0;
  int ans=-1;
  
  for(int i=0;i<N;i++){
    if(a.at(b)==2){
      ans=i+1;
      break;
    }
    
    else{
      b=a.at(b)-1;
    }
  }
  
  cout<<ans<<endl;
  
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

vector<vector<ll>> v;

void dfs(vector<ll> t) {
    if (t.size() == 5) {
        v.push_back(t);
        return;
    }
    REP(i, 5) {
        bool exist = false;
        REP(j, t.size()) {
            if (t[j] == i)
                exist = true;
        }
        if (exist)
            continue;
        t.push_back(i);
        dfs(t);
        t.pop_back();
    }
}

ll A[10];

int main() {
    REP(i, 5) {
        cin >> A[i];
    }

    ll min = INF;
    vector<ll> vv;
    dfs(vv);
    REP(i, v.size()) {
        ll t = 0;
        REP(j, 4) {
            t += A[v[i][j]];
            t += (10 - (t % 10)) % 10;
        }
        t += A[v[i][4]];
        min = std::min(min, t);
    }
    cout << min << endl;
    return 0;
}

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


#----------
n,x = list(map(int, input().rstrip().split()))
a_list = list(map(int, input().rstrip().split()))
#----------
a_list.sort()
x_remain=x

result = -1
for i in range(n):
    x_remain -= a_list[i]
    
    if x_remain == 0:
        result = i+1
        break
    if x_remain < 0:
        result = i
        break

if result == -1 :
    result = n-1

print(result)


Measured memory_bytes: 3060
function Main(input){
var N = input.split("\n")[0];
N = parseInt(N,10);
var H = input.split("\n")[1].split(" ");
var count = 0;
var memo = 0;
for(i=0;i<=(N-1);i++){
  var a = parseInt(H[i],10) >= parseInt(H[i+1],10);
  if(a == true){
    count += 1;
  }else{
    var b = count >= memo;
    if(b==true){
      memo = count;
      count = 0;
    }else{
      count = 0;
    }
  }
}
console.log(memo);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 17804
a,b,c,n=map(int,input().split( ))

s=0
for i in range(n//a+1):
    for j in range((n-a*i)//b+1):
        ck=(n-a*i-b*j)
        if ck%c==0 and ck//c>=0:
            s+=1
        # print(i,j,ck,s)

print(s)



Measured memory_bytes: 40684
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, K;
ll A[200000];
map<ll, ll> ind;
map<ll, queue<ll>> hoge;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,N) cin >> A[i];
    rep(i,N) A[i] = (A[i]-1+K)%K;
    for (int i = 1; i < N; i++) A[i] = (A[i] + A[i-1]) % K;
    ll ans = 0;
    ll cnt = 0;
    ind[0] = cnt++;
    hoge[0].push(-1);
    rep(i,N) {
        int pos = 0;
        if (ind.count(A[i])) {
            pos = ind[A[i]];
        } else {
            pos = ind[A[i]] = cnt++;
        }
        while (hoge[pos].size() && i-hoge[pos].front() >= K) hoge[pos].pop();
        ans += hoge[pos].size();
        hoge[pos].push(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 158080
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i, n, m) for (int i = n; i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout << #val << ": " << val << endl;
#define CASET             \
    int ___T, case_n = 1; \
    scanf("%d ", &___T);  \
    repp(i, 1, ___T)
 
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
        y = 0;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 1e6 + 5;
const double PI = acos(-1.0);
const ll mod = 998244353;
/*************************************************************************/

void solve() {
    int m;
    int d;
    sa(m);
    sa(d);
    int ans = 0;
    repp(i,1,m) {
        repp(j,1,d) {
            int k = j/10;
            int s = j%10;
            if(k>=2 && s>=2 && k*s==i) {
                ans++;
            }
        }
    }
    printf("%d\n", ans);
}

int main()
{

  
    
    // int t;
    // sa(t);
    // while(t--)
    solve();
    // int *x = new int[5]();
    return 0;
}


Measured memory_bytes: 256
/**
* Copyright(c)
* All rights reserved.
* Author : Mingzhe
* Description : sample
*/
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <memory.h>
#define MAXN 100005
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;

ll MOD = 1e9+7;
int x[MAXN];
int ans[MAXN];

int main(){
    int n,m;
    cin>>n>>m;
    int p;
    memset(x,0,sizeof(x));
    memset(ans,0,sizeof(ans));
    ans[0]=1;ans[1]=1;
    for(int i=0;i<m;i++){
        cin>>p;
        x[p] = 1;
        ans[p]=0;
    }
    for(int i=2;i<=n;i++){
        if(!x[i]){
            ans[i] = ((ans[i-1]%MOD)+(ans[i-2]%MOD))%MOD;
        }
    }
    cout<<ans[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
}

Measured memory_bytes: 28160
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

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

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

    int ans = 0;
    rep(i, n){
        int h;
        cin >> h;
        if(h >= k){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
 
map<string, int> dp;
int direction[4] = { 1, -1, 4, -4 };
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   void
// Qualifier: ?0漫游整个字串
//************************************
void bfs()
{
    queue<string> que;
    que.push("01234567");
    dp["01234567"] = 0;
    while (!que.empty())
    {
        string now = que.front(); que.pop();
        // p是'0'的位置
        int p = 0;
        for (int j = 0; j < 8; ++j)
        {
            if (now[j] == '0')
            {
                p = j;
                break;
            }
        }
 
        for (int i = 0; i < 4; ++i)
        {
            int n = p + direction[i];
            if (0 <= n && n < 8 && 
                !(p == 3 && i == 0) && // 右上角不能再往右了
                !(p == 4 && i == 1))   // 左下角不能再往左了
            {
                string next = now;
                swap(next[p], next[n]);
                if (dp.find(next) == dp.end())
                {
                    dp[next] = dp[now] + 1;
                    que.push(next);
                }
            }
        }
    }
}
 

int main(int argc, char *argv[])
{
 
    bfs();
    string line;
    while (getline(cin, line))
    {
        line.erase(remove(line.begin(), line.end(), ' '), line.end());
        cout << dp[line] << endl;
    }
 
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<vector<ll>> d(10, vector<ll>(10, 0));
    rep2(i, 1, N + 1) {
        string s = to_string(i);
        d[s[0] - '0'][i % 10]++;
    }
    ll ans = 0;
    rep2(i, 1, 10) {
        rep2(j, 1, 10) {
            ans += d[j][i] * d[i][j];
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int a, b;
	cin >> a >> b;
	string h;
	for (int i = 0; i < b+2; i++) {
		h += '#';
	}
	vector<string>w;
	w.push_back(h);
//	cout << h << endl;;
	for (int i = 0; i < a; i++) {
		string g;
		cin >> g;
		g = '#' + g + '#';
		w.push_back(g);
	//	cout << g << endl;;
	}
	for (int i = 0; i < w.size(); i++)
		cout << w[i] << endl;
	cout << h << endl;
	return 0;

}




Measured memory_bytes: 256
# coding: utf-8
# Your code here!

input_line = input().split()
inputInt = [int(i) for i in input_line]
#print(inputInt)
A = inputInt[0]
maisuu = inputInt[1]
timeLimit = inputInt[2] + 0.5

i = 0
while A*i < timeLimit:
    i += 1
i -= 1

print(maisuu*i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=2e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    int l,r;
    cin>>l>>r;
    for(i=0;i<=1e5;i++)
    {
        if(floor(i*0.08)==l&&floor(i*0.1)==r)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K, H, W;
ll MOD = 1000000007;
int ans = 1;
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second > secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

int main()
{
	int X;
	cin >> N >> X;
	vector<int> L(N);
	for (i = 0; i < N; i++) {
		cin >> L[i];
	}
	int sum = 0;
	for (i = 1; i <= N; i++) {
		sum += L[i - 1];
		if (sum <= X) {
			ans = i+1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
N = int(input())
g = [[-1 for _ in range(N)] for _ in range(N)]
for i in range(N):
    m = int(input())
    for j in range(m):
        x,y = map(int,input().split())
        g[i][x-1] = y

ans = 0
for i in range(1 << N):
    hornest = [0] * N
    for j in range(N):
        if (i >> j)&1:
            hornest[j] = 1
    is_ok = 1
    for j in range(N):
        if hornest[j] and is_ok:
            for k in range(N):
                if g[j][k] == -1:
                    continue
                if g[j][k] != hornest[k]:
                    is_ok = 0
    if is_ok:
        ans = max(ans,hornest.count(1))
        
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
	if(ch == 'A')
	{
		return 1;
	}
	else if(ch == 'C')
	{
		return 2;
	}
	else if(ch == 'T')
	{
		return 3;
	}
	else if(ch == 'G')
	{
		return 4;
	}
	else
	{
		return 0;
	}
}

long long int getKey(char str [])
{
	long long int sum = 0, p = 1, i;
	for(i = 0; i < strlen(str); i++)
	{
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(long long int key)
{
	return key % M;
}

int h2(long long int key)
{
	return 1 + (key % (M - 1));
}

int insert(char str[])
{
	long long int key, i , h;
	key = getKey(str);
	for(i = 0; ; i++)
	{
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0)
		{
			return 1;
		}
		else if(strlen(H[h]) == 0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int find(char str[])
{
	long long int key, h, i;
	key = getKey(str);
	for(i = 0; ; i++)
	{
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0)
		{
			return 1;
		}
		else if(strlen(H[h]) == 0)
		{
			return 0;
		}
	}
	return 0;
}

int main()
{
	int i, n;
	char str[L] , com[9];
	for(i = 0; i < M; i++)
	{
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s %s", com, str);
		if(com[0] == 'i')
		{
			insert(str);
		}
		else
		{
			if(find(str))
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16980
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int dp[101][100005]; // sum of first i elements of array is atmost j.
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,k;
		cin>>n>>k;
		int a[n+1];
		rep(i,1,n+1) cin>>a[i];
		rep(i,0,n+1){
			rep(j,0,100005) dp[i][j] = 0;
		}
		rep(i,0,100005) dp[1][i] = min(a[1]+1,i+1);
		rep(i,2,n+1){
			rep(j,0,100005){
				dp[i][j] = ((j>0)*dp[i][j-1]+dp[i-1][j] - (j>=a[i]+1)*dp[i-1][j-a[i]-1]+M)%M;
			}
		}
		// rep(i,1,n+1){
		// 	rep(j,0,k+1) cout<<dp[i][j]<<" ";
		// 	cout<<endl;
		// }
		if(k!=0) cout<<(M+dp[n][k]-dp[n][k-1])%M;
		else cout<<dp[n][k];
	}   
}     

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

unordered_map<int,int> A;
int N,M;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    int d; cin >> d;
    A[d]++;
  }
  cin >> M;
  bool dm = true;
  for(int i=0;i<M;i++){
    int x; cin >> x;
    A[x]--;
    if( A[x] < 0 ) dm = false;
  }
  cout << (dm?"YES":"NO") << endl;

}

Measured memory_bytes: 8520
a = [1] + [0] * 2018
s, p = 0, 1
for c in reversed(input()):
  s = (s + p * int(c)) % 2019
  p = p * 10 % 2019
  a[s] += 1
print(sum(x * (x - 1) // 2 for x in a))


Measured memory_bytes: 9316
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

void relax( int &a, int b ) { a = min(a, b); }

int main() {
	int n;
	while (scanf("%d", &n) == 1 && n ) {
	vector<int> p(n), f(n + 1, INT_MAX);
	forn(i, n) 
		scanf("%d", &p[i]), p[i]--;
	f[0] = 0;
	forn(i, n)
		if (f[i] != INT_MAX) {
			// printf("f[%d] = %d\n", i, f[i]);
			if (p[i] != i)
				relax(f[i + 1], f[i]);
			if (i + 1 < n && p[i + 1] != i && p[i] != i + 1)
				relax(f[i + 2], f[i] + 1);
			if (i + 2 < n && p[i] != i + 2 && p[i + 1] != i && p[i + 2] != i + 1)
				relax(f[i + 3], f[i] + 2);
			if (i + 2 < n && p[i] != i + 1 && p[i + 1] != i + 2 && p[i + 2] != i)
				relax(f[i + 3], f[i] + 2);
		}
	printf("%d\n", f[n]);
	// break;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n, mi[N], sum[N];
char s[N];
int solve(int x) {
	int tot = 0, now = 0, mx = 0;
	REP(i,1,n) {
		if (s[i]=='?') {
			if (mi[i]-tot-2>=x) --now,tot+=2;
			else ++now;
		}
		else if (s[i]=='0') --now;
		else ++now;
		mx = max(mx, now);
	}
	return mx;
}
int main() {
	scanf("%s", s+1);
	n = strlen(s+1);
	REP(i,1,n) sum[i] = sum[i-1]+(s[i]=='0'?-1:1);
	mi[n] = sum[n];
	PER(i,0,n-1) mi[i] = min(mi[i+1], sum[i]);
	printf("%d\n", min(solve(mi[0])-mi[0],solve(mi[0]-1)-mi[0]+1));
}


Measured memory_bytes: 12632
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
int a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    int ans=0;
    int w=0;
    for(int i=0;i<n;i++) {
        if(s[i]=='W') w++;
    }
    int r=n-w;
    int flag=0;
    for(int i=n-1;i>=0;i--){
        if(flag==0){
            if(s[i]=='R'){
                flag=1;
            }

        }
        if(flag){
            if(s[i]=='W') ans++;
        }
    }
    int ans1=0;
    int pre=0;
    for(int i=0;i<n;i++){
        if(s[i]=='W') pre++;
        else a[i]=pre;
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R'){
            if(ans1>=a[i]) break;
            ans1++;
        }
    }
    ans=min(ans,ans1);
    cout<<ans<<endl;
}


Measured memory_bytes: 4748
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1<<30)

class Edge{
	public:
		int t, w;
		Edge(){}
		Edge(int t, int w): t(t), w(w) {}
}; 

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
	for(int i = 0; i < n; i++) d[i] = INFTY;
	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	int u;
	while(!Q.empty() ){
		u = Q.front(); Q.pop();
		for(int i = 0; i < G[u].size(); i++){
			Edge e = G[u][i];
			if(d[e.t] == INFTY){
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

void solve(){
	//从任选的结点s出发，选择距离s最远的结点tgt
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for(int i = 0; i < n; i++){
		if(d[i] == INFTY) continue;
		if(maxv < d[i]){
			maxv = d[i];
			tgt = i;
		} 
	} 
	
	//从tgt出发，求结点tgt到最远节点的距离maxv
	bfs(tgt);
	maxv = 0;
	for(int i = 0; i < n; i++){
		if(d[i] == INFTY) continue;
		maxv = max(maxv, d[i]);
	} 
	
	cout<<maxv<<endl;
}	 

int main(){
	int s, t, w;
	cin>>n;
	
	for(int i = 0; i < n-1; i++){
		cin>>s>>t>>w;
		
		G[s].push_back(Edge(t, w));
		G[t].push_back(Edge(s, w));
	}
	solve();
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010
//#define CHECK

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }

// 無限ループできる(Yes)なら true
bool solve(ll A, ll B, ll C, ll D) {
    if(A < B || D < B) { return false; }
    if(A % B > C) { return false; }
    if(B <= C) { return true; }
    if(B == D || D % B == 0) { return true; }
    if(B-1 == C) { return true; }

    // 初期位置
    ll X = A % B;
    // X から、  D を加算することで gcd(Y, B) の位置に訪れることになる
    ll Y = (D - B) % B;
    Y = gcd(Y, B);
    // C に一番接近するとき
    ll Z = X + ((C - X) / Y) * Y;
    if(Z + Y < B && Z + Y > C) {
        // NG ゾーンに入った
        return false;
    }

    // NG ゾーンに入ることなく無限ループできる
    return true;
}

// 愚直な解放で解く
// 無限ループできる(Yes)なら true
bool brute_force(ll A, ll B, ll C, ll D) {
    map<ll, bool> exist;
    ll cur = A;
    exist[A] = true;
    for(;;) {
        cur -= B;
        if(cur < 0) { return false; }
        if(cur <= C) { cur += D; }
        if(exist.count(cur) != 0) { break; }
        exist[cur] = true;
    }
    return true;
}

signed main()
{
#ifdef CHECK
    // ABCD の全組み合わせを与える
    const ll max_abcd = 30;
    for(ll a = 1; a <= max_abcd; ++a) {
        for(ll b = 1; b <= max_abcd; ++b) {
            for(ll c = 1; c <= max_abcd; ++c) {
                for(ll d = 1; d <= max_abcd; ++d) {
                    bool cand = solve(a, b, c, d);
                    bool ans = brute_force(a, b, c, d);
                    if(cand != ans) {
                        DBG("%3lld %3lld %3lld %3lld cand: %s ans: %s\n",
                                a, b, c, d, cand ? "Yes" : "No", ans ? "Yes" : "No");
                        assert(false);
                    }
                }
            }
        }
    }
#else
    ll T;
    cin >> T;
    REP(t, T) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        bool ans = solve(A, B, C, D);
        if(ans) { printf("Yes\n"); }
        else { printf("No\n"); }
    }
#endif
    return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    cout << (max(0, 4 - x) + max(0, 4 - y) + (x + y > 2 ? 0 : 4)) * 100000
         << endl;
    return 0;
}


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

int main() {
  long long int a;
  cin >>a ;
  
  long long int ans = 100;
  long long int res = 0;
  
  for(int i=0;i<=5000;i++){
    ans = ans + ans / 100;
    res++;
    if(ans >= a ){
      cout << res << endl;
    return 0;
    }
    
  }
  
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long a,b,c,d,n,x,y;
	cin>>a>>b>>c>>d>>n;
	n=n*4;
	if(2*a<b)
	b=2*a;
	if(2*b<c)
	c=2*b;
	if(c*2<d)
	d=c*2;
	if(n==1)
	cout<<a<<endl;
	if(n>=2&&n<4)
	cout<<n%2*a+n/2*b<<endl;
	if(n>=4&&n<8)
	{
		x=n%4;
		cout<<n/4*c+x/2*b+x%2*a<<endl;
	}
	if(n>=8)
	{
		x=n%8;
		y=x%4;
		cout<<n/8 *d+x/4*c+y/2*b+y%2*a<<endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#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> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

bool ismonth(string s)
{
    return s >= "01" && s <= "12";
}

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

    string S;
    cin >> S;

    string yy = S.substr(0, 2);
    string mm = S.substr(2, 2);

    bool y = ismonth(yy);
    bool m = ismonth(mm);

    if (y)
    {
        if (m)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else
        {
            cout << "MMYY" << endl;
        }
    }
    else
    {
        if (m)
        {
            cout << "YYMM" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3580
main(a,b,c,X,Y,A,f,i,j){for(;scanf("%d%d%d",&a,&b,&c),a|b|c;printf("%d %d\n",X,Y))
for(X=Y=-1,A=2147483647,f=i=0;!f;i++)
	for(j=0;j<=i;j++)
		if(a*j+b*(i-j)==c||a*j==b*(i-j)+c||a*j+c==b*(i-j))
			if(f=1,A>a*j+b*(i-j))A=a*j+b*(i-j),X=j,Y=i-j;
exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int B[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>a>>b>>m;

    int res = 0;

    for(int i=1;i<=a;i++)
    {
        cin>>A[i];
        mn = min(mn,A[i]);
    }

    res+=mn;
    mn = INF;

    for(int i=1;i<=b;i++){
        cin>>B[i];
        mn = min(mn,B[i]);
    }
    res+=mn;

    for(int i=1;i<=m;i++){
        cin>>x>>y>>k;
        res = min(res,A[x]+B[y]-k);
    }

    cout<<res<<"\n";

    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	double R;
	cin >> R;

	double pi = 3.14159265353238;

	double ans = 2.0 * pi * R;
	cout << fixed << setprecision(10) << ans << "\n";


	return 0;
}


Measured memory_bytes: 3724
M1, D1=map(int, input().split())
M2, D2=map(int, input().split())

if M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12:
    if D1==31:
        print('1')
    else:
        print('0')
elif M1==4 or M1==6 or M1==9 or M1==11:
    if D1==30:
        print('1')
    else:
        print('0')
elif M1==2:
    if D1==28:
        if D2-D1==1:
            print('0')
        else:
            print('1')
    elif D1==29:
        print('1')
    else:
        print('0')

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 2e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 1e9 + 7;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

int fa[kN], siz[kN]; ll fac[kN];
int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }
void Merge(int x, int y) {
	int f_x = Find(x), f_y = Find(y);
	if(f_x == f_y) return;
	siz[f_x] += siz[f_y]; fa[f_y] = f_x;
}

int cm[kN], w[kN], c[kN], ccnt = 0; std::vector <int> cb[kN];
int main() {
	w[0] = kInf;
	int n, X, Y; rd(n, X, Y);
	for(int i = 1; i <= n; ++i) {
		rd(c[i], w[i]); siz[i] = 1; fa[i] = i;
		cb[c[i]].push_back(i);
	}
	if(n == 1) { printf("1"); return 0; }
	ll ans = 1, divans = 1; fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % kMod;
	for(int i = 1; i <= n; ++i) {
		if(!cb[i].size()) continue;
		for(auto x : cb[i]) {
			if(w[x] < w[cm[i]])
				cm[i] = x;
		}
		for(auto x : cb[i]) if(w[x] + w[cm[i]] <= X) Merge(cm[i], x);
	}
	int m1 = 0, m2 = 0;
	for(int i = 1; i <= n; ++i) {
		if(w[cm[i]] < w[m1]) m2 = m1, m1 = cm[i];
		else if(w[cm[i]] < w[m2]) m2 = cm[i];
	}
	for(int i = 1; i <= n; ++i)
		if(w[m1] + w[i] <= Y && c[m1] != c[i]) Merge(m1, i);
	for(int i = 1; i <= n; ++i)
		if(w[m2] + w[i] <= Y && c[m2] != c[i]) Merge(m2, i);
	for(int i = 1; i <= n; ++i) if(fa[i] == i) ans = ans * fac[siz[i]] % kMod;
	for(int i = 1; i <= n; ++i) {
		if(!cb[i].size()) continue;
		int cnt = 0;
		for(auto x : cb[i]) if(Find(x) == Find(cm[i])) ++cnt;
		divans = divans * fac[cnt] % kMod;
	}
	printf("%lld\n", ans * QPow(divans, kMod - 2) % kMod);
	return 0;
}

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

int main() {
	int A, B, C, D, T[100] = { 0 }, count = 0;
	cin >> A >> B >> C >> D;
	for (int i = A; i < B; i++) {
		T[i]++;
	}
	for (int i = C; i < D; i++) {
		T[i]++;
	}
	for (int i = 0; i < 100; i++) {
		if (T[i] == 2) count++;
	}
	cout << count << endl;
}

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

typedef long long ll;

const int MOD = (int)1e9 + 7;
int N, M;
vector<int> A, B;

void input_init(void) {
	cin >> N >> M;
	A.resize(N);
	for (int j = 0; j < N; ++j)
		cin >> A[j];
	B.resize(M);
	for (int i = 0; i < M; ++i)
		cin >> B[i];
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	sort(B.begin(), B.end());
	B.erase(unique(B.begin(), B.end()), B.end());
}

int calcu(int n) {
	vector<int>::iterator it_a = lower_bound(A.begin(), A.end(), n);
	vector<int>::iterator it_b = lower_bound(B.begin(), B.end(), n);
	int idx_a = distance(A.begin(), it_a);
	int idx_b = distance(B.begin(), it_b);

	int ret = 0;
	if (*it_a == n && *it_b == n)				// A, B 共に有る
		ret = 1;
	else if (*it_a == n && *it_b != n)			// A のみに有る
		ret = M - idx_b;
	else if (*it_a != n && *it_b == n)			// B のみに有る
		ret = N - idx_a;
	else										// A, B 共に無い
		ret = (M - idx_b) * (N - idx_a) - (N * M - n);

	return ret;
}

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

	input_init();
	ll ans = (ll)0;
	if (A.size() == N && B.size() == M) {
		A.push_back(N * M + 1);
		B.push_back(N * M + 1);
		ans = (ll)1;
		for (int i = N * M; i >= 1; --i) {
			ans *= (ll)calcu(i);
			ans %= (ll)MOD;
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2e5+5;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}


void solve(){
	
	ll n;
	cin>>n;
	ll ans=0;
	map<ll,ll> mp;
	while(n%2==0){
		mp[2]++;
		n/=2;
	}
	for (ll i=3;i*i<=n;i+=2){
		if (n%i==0){
			while(n%i==0){
				mp[i]++;
				n/=i;
			}
		}
	}
	
	
	
	if (n>1){
		mp[n]++;
	}
	
	for (auto i:mp){
		ll l=1, r=i.S;
		ll mx=1;
		while(l<=r){
			ll mid=(l+r)/2;
			ll tmp=(mid*(mid+1))/2;
			if (tmp<=i.S){
				mx=max(mx, mid);
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		
		ans+=mx;
	}
	cout<<ans<<endl;
	
	return;
}

 
int main(){ 
    
    #ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	
	
	return 0;
	
}

Measured memory_bytes: 3608