akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

uint64_t recurse(const vector<vector<char>> &grid, int i, int j,
                 vector<vector<uint64_t>> &maxPaths) {
  if (i >= grid.size())
    return 0;
  if (j >= grid.front().size())
    return 0;
  // If it's a wall, we have no options.
  if (grid[i][j] == '#')
    return 0;
  if (maxPaths[i][j] != -1)
    return maxPaths[i][j];
  assert(grid[i][j] == '.');
  maxPaths[i][j] =
      (recurse(grid, i + 1, j, maxPaths) + recurse(grid, i, j + 1, maxPaths)) %
      1000000007;
  return maxPaths[i][j];
}

int solve(const vector<vector<char>> &grid) {
  vector<vector<uint64_t>> maxPaths;
  maxPaths.resize(grid.size());
  for (auto &m : maxPaths)
    m.resize(grid.front().size(), -1);
  // maxPaths[i][j] = maxPaths[i + 1][j] + maxPaths[i][j + 1].
  maxPaths.back().back() = 1;
  recurse(grid, 0, 0, maxPaths);
  return maxPaths.front().front();
}

int main() {
  vector<vector<char>> grid;
  int x, y;
  cin >> x >> y;
  grid.resize(x);
  for (auto &g : grid)
    g.resize(y);
  for (int i = 0; i < grid.size(); ++i) {
    for (int j = 0; j < grid[i].size(); ++j) {
      char currentTile;
      cin >> currentTile;
      grid[i][j] = currentTile;
    }
  }
  cout << solve(grid) << endl;
  return 0;
}


Measured memory_bytes: 9216
# 160
K,N=map(int,input().split())
A=[int(i) for i in input().split()]

ans =[]

for i in range(N-1):
    ans.append(A[i+1]-A[i])
ans.append(abs(A[0] + (K - A[-1])))
print(sum(ans) - max(ans))

Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ll N=0;cin>>N;ll k=0;cin>>k;
ll a[N];
for(ll i=0;i<N;++i){
	a[i]=0;
	cin>>a[i];
}
ll dp[N];
for(ll i=0;i<N;++i)
	dp[i]=INT_MAX;
dp[0]=0;
dp[1]=abs(a[0]-a[1]);
for(ll i=2;i<N;++i){
	for(ll j=1;j<=k;++j){
		dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
}
cout<<dp[N-1]<<endl;
return 0;
}

Measured memory_bytes: 1792
N = int(input())
robots = []
for _ in range(N):
    X, L = map(int, input().split())
    robots.append((X+L, X-L))
robots.sort()
ans = 0
last_end = -10 ** 10
for end, start in robots:
    if last_end <= start:
        last_end = end
        ans += 1
print(ans)


Measured memory_bytes: 16988
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=200005;
typedef long long ll;

struct node
{
    ll index,value;
}a[maxn];
ll C[maxn],n,k;

//离散化排序；
int cmp1(node a,node b)
{
    if(a.value!=b.value)
        return a.value<b.value;
    return a.index<b.index;
}

int cmp2(node a,node b)
{
    if(a.index!=b.index)
        return a.index<b.index;
    return a.value<b.value;
}

ll lowbit(ll x)
{
    return x&(-x);
}

void add(ll x,ll d)
{
    while(x<maxn)
    {
        C[x]+=d;
        x+=lowbit(x);
    }
}

ll sum(ll x)
{
    ll ret=0;
    while(x>0)
    {
        ret+=C[x];
        x-=lowbit(x);
    }
    return ret;
}

int main()
{
    ll ans=0;
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i].value);
        a[i].index=i;
        a[i].value-=k;
    }
    for(int i=2;i<=n;i++)
        a[i].value=a[i-1].value+a[i].value;
    for(int i=1;i<=n;i++)
        if(a[i].value>=0)
            ans+=1;
//printf("%d\n",ans);
    sort(a+1,a+1+n,cmp1);
    for(int i=1;i<=n;i++)
        a[i].value=i;
    sort(a+1,a+1+n,cmp2);
//for(int i=1;i<=n;i++)
//    printf("%d ",a[i].value);

//    printf("\n");
    for(int i=1;i<=n;i++)
    {
        ll x=a[i].value;
        ans+=sum(x);
        add(x,1);
    }
    printf("%lld\n",ans);

    return 0;
}

/*
10 7
4 6 8 13 11 3 2 6 12 14
*/


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int l,r,cnt=10000,i,j;
    cin>>l>>r;
    if(r-l>=2019)
        cout<<0;
    else
    {
        l%=2019;
        r%=2019;
        if(r<=l)
            cout<<0;
        else
        {
            for(i=l;i<r;i++)
                for(j=i+1;j<=r;j++)
                    cnt=min(cnt,(i*j)%2019);
            cout<<cnt;
        }

    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    ll f = a[0];
    ll ans = 0;
    for(ll i=1;i<n;++i){
        if(f > a[i]){
            ans += f - a[i];
            a[i] = f;
        }
        f = a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6424
n=int(input())
arr=list(map(float,input().split()))
dp=[0.0]*(n+1)
dp[0]=1.0
for i in range(n):
    p=arr[i]
    for j in range(i+1,-1,-1):
        if j==0:
            dp[j]=(1-p)*(dp[j])
        else:
            dp[j]=((p)*dp[j-1])+((1-p)*dp[j])
ans=0
for heads in range(n+1):
    tails=n-heads
    if heads>tails:
        ans+=dp[heads]
print(ans)

Measured memory_bytes: 41324
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int v[1010]={0};
int w[1010]={0};
int dp[1010][10010]={{0}};
int n,W;
int main(){
	cin>>n>>W;
	for(int i =0;i <n;i++){
		cin>>v[i]>>w[i];
	}
	for(int i =0;i < n;i++){
		for(int j =0;j <=W;j++){
			if(j-w[i]>=0){
				dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
			}else{
				dp[i+1][j]=dp[i][j];
			}
		}
	}
	cout <<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 5220
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
vvi v;
ll ans;
int n,k;
void rec(int ind,int cur,int parent){
    for(int i = 0; i < v[ind].size(); i++){
        if(v[ind][i]==parent) continue;
        ans=(ans*(ll)max(k-cur,0))%INF;
        cur++;
        rec(v[ind][i],2,ind);
    }
}

void solve(){
    cin>>n>>k;
    ans=k;
    v = vvi(n+1,vi());
    for(int i = 1; i < n; i++){
        int a,b; cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    rec(1,1,-1);
    cout<<ans;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int dp[100005];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w;
    cin>>n>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<=100000;i++)dp[i]=LLONG_MAX/3;
    dp[0]=0;
    for(int i=0;i<n;i++){
		for(int j=100000-b[i];j>=0;j--){
			dp[j+b[i]]=min(dp[j+b[i]],dp[j]+a[i]);
        }
    }
    int ans=0;
    for(int i=0;i<=100000;i++){
    	if(dp[i]<=w)ans=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4368
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

struct Tournament {
  static const int off = 1 << 13;

  struct Node {
    llint p, v;
    void add(llint x) { p += x; v += x; }
  };

  Node tree[off << 1];

  Tournament() {
    memset(tree, 0, sizeof tree);
  }
  
  void prop(int i) {
    tree[2 * i].add(tree[i].p);
    tree[2 * i + 1].add(tree[i].p);
    tree[i].p = 0;
  }

  void merge(int i) {
    tree[i].v = max(tree[2 * i].v, tree[2 * i + 1].v);
  }

  void build(int i = 1) {
    if (i >= off) return;
    build(2 * i);
    build(2 * i + 1);
    merge(i);
  }

  void add(int l, int r, llint v, int lo = 0, int hi = off, int i = 1) {
    if (lo >= r || hi <= l) return;
    if (lo >= l && hi <= r) {
      tree[i].add(v);
      return;
    }

    prop(i);
    add(l, r, v, lo, (lo + hi) / 2, 2 * i);
    add(l, r, v, (lo + hi) / 2, hi, 2 * i + 1);
    merge(i);
  }

  llint getmax() { return tree[1].v; }
} t;

int main(void) 
{
  int N, M;
  scanf("%d%d", &N, &M);
  
  vector<llint> A(N, 0);
  vector<vector<llint>> B(N, vector<llint>(M));
  REP(i, N - 1) scanf("%lld", &A[i]);
  REP(i, N) REP(j, M) scanf("%lld", &B[i][j]);

  llint sol = 0;
  REP(i, M) sol += B[0][i];
  t.tree[Tournament::off].v = sol;
  t.build();

  vector<stack<int>> S(M);
  REP(i, M) S[i].push(-1), S[i].push(0);

  FOR(i, 1, N) {
    t.add(0, i, -A[i - 1]);
    REP(j, M) {
      vector<int> out;
      while (S[j].top() != -1 && B[S[j].top()][j] <= B[i][j]) {
	out.push_back(S[j].top());
	S[j].pop();
      }
      out.push_back(S[j].top());
      S[j].push(i);
      reverse(out.begin(), out.end());

      REP(k, (int)out.size() - 1) 
	t.add(out[k] + 1, out[k + 1] + 1, -B[out[k + 1]][j]);

      t.add(out[0] + 1, i + 1, B[i][j]);
    }
    sol = max(sol, t.getmax());
  }

  printf("%lld\n", sol);
  
  return 0;
}


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

int main(){
  int K, N;
  int b;
  cin >> K >> N;
  vector <int> a(N);
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  b = (K - a.at(N-1)) + a.at(0);
  
  for (int i=0; i<N-1; i++){
    b = max(a.at(i+1)-a.at(i), b);
  }
  cout << K - b << endl;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, h, w; cin >> n >> h >> w;
  cout << (n-h+1) * (n-w+1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int ans = 7;
  cin >> S;
  if (S == "SUN")
    ans -= 0;
  else if (S == "MON")
    ans -= 1;
  else if (S == "TUE")
    ans -= 2;
  else if (S == "WED")
    ans -= 3;
  else if (S == "THU")
    ans -= 4;
  else if (S == "FRI")
    ans -= 5;
  else
    ans -= 6;
  cout << ans << endl;
}

Measured memory_bytes: 256
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
void solve(){
    ll n,q,x,y,z;
    cin>>n>>q;
    dsu d(n+1);
    rep(i,0,q-1){
        cin>>x>>y>>z;
        if(x==0){
            d.merge(y,z);
        }
        else{
            cout<<d.same(y,z)<<endl;
        }
    }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 3852
N = int(input())
first = input()
seen = {first}
for _ in range(N-1):
    w = input()
    if w[0] != first[-1]:
        print("No")
        break
    if w in seen:
        print("No")
        break
    seen.add(w)
    first = w
else:
    print("Yes")

Measured memory_bytes: 9112
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b  = map(str, input().split())
a = int(a)
b = b.replace('.', '')
b = int(b)
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print(a * b // 100)


Measured memory_bytes: 9472
#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;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

//最後のところの処理がいい加減になっていた、こういう詰めの甘い実装がダメなんだよカス
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,q;cin>>n>>q;

    vector<vector<ll>> xst(n);
    REP(i,n){
        ll s,t,x;cin>>s>>t>>x;
        xst[i]={x,s,t};
    }
    sort(ALL(xst));

    vector<ll> d(q);
    REP(i,q)cin>>d[i];

    vector<deque<ll>> ans_sectl(q);
    vector<deque<ll>> ans_sectr(q);
    REP(i,n){
        ll s,t,x;x=xst[i][0];s=xst[i][1];t=xst[i][2];
        ll L=(lower_bound(ALL(d),s-x)-d.begin());
        ll R=(upper_bound(ALL(d),t-x-1)-d.begin())-1;
        //lower,upper気を付ける
        //2RE
        if(L<=R){ans_sectl[L].PB(i);ans_sectr[R].PB(i);}
        //cout << L << " " << R << endl;
    }

    //複数存在する場合もあるので、map
    map<ll,ll> ans;
    REP(i,q){
        ll sl=SIZE(ans_sectl[i]);
        ll sr=SIZE(ans_sectr[i]);
        REP(_,sl){
            ans[*(ans_sectl[i].begin())]+=1;
            ans_sectl[i].pop_front();
        }
        //削除しておく
        while(!ans.empty()){
            if(ans.begin()->S==0){
                ans.erase(ans.begin());
            }else{
                break;
            }
        }
        if(ans.empty()){
            cout<<-1<<"\n";
        }else{
            cout<<xst[ans.begin()->F][0]<<"\n";
        }
        REP(_,sr){
            ans[*(ans_sectr[i].begin())]-=1;
            ans_sectr[i].pop_front();
        }
    }
}

Measured memory_bytes: 296704
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K, N = map(int, readline().split())
A = list(map(int, readline().split()))
A_ = [a + K for a in A]

ans = 10**9 + 7
min1, max1 = min(A), max(A)

for i in range(N):
    if A[i - 1] - A[i] > 0:
        CW = A[i - 1] - A[i]
    else:
        CW = A[i] + K - A[i - 1]

    if i != N - 1:
        if A[i] - A[i + 1] > 0:
            CCW = A[i] - A[i + 1]
        else:
            CCW = A[i] + K - A[i + 1]
    else:
        CCW = A[i] - A[0]

    ans = min(ans, min(CW, CCW))

print(ans)


Measured memory_bytes: 21084
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  vll d(0);
  for(int i=100;i>=1;i--){
    if(a%i==0&&b%i==0){
      d.pb(i);
  }
  }
  COUT(d[k-1]);
}


Measured memory_bytes: 256
for i in range(5):
    a=int(input())
    b=(1000-a)//500
    c=(1000-a-500*b)//100
    d=(1000-a-500*b-100*c)//50
    e=(1000-a-500*b-100*c-50*d)//10
    f=(1000-a-500*b-100*c-50*d-10*e)//5
    g=1000-a-500*b-100*c-50*d-10*e-5*f
    if a==0:break
    print(b+c+d+e+f+g)
    



Measured memory_bytes: 5584
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int maxc = (n + 1) / 2;
  if (k <= maxc) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
int k[32];
int a[32][32];
int cnt[32];

int main(){
   int n,m;
   cin>>n>>m;
   int ans=0;
   for(int i=0;i<n;i++){
      cin>>k[i];
      for(int j=0;j<k[i];j++){
         cin>>a[i][j];
         cnt[a[i][j]]++;
      }
   }
   for(int i=0;i<m+2;i++){
      if(cnt[i]==n){
         ans++;
      }
   }

   cout<<ans<<endl;

}

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

using namespace std;

char a[15];

int main(void)
{
	scanf("%s",a);
	int l = strlen(a);
	int mn=753;
	for(int i=0;i<l-2;i++){
		int n = 100*(a[i]-'0')+10*(a[i+1]-'0')+a[i+2]-'0';
		if(abs(n-753)<mn) mn = abs(n-753);
	}
	printf("%d",mn);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import collections


n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]

ce = collections.Counter(leven)
co = collections.Counter(lodd)
ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != co[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])


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

int main(){
    int a[102];
    int b[102];

    rep(i,102){
        b[i]=10*i;
        a[i]=(12*i+13*i+1)/2;
    }
    int an,bn;
    cin >> an >> bn;

    if(a[an]>=b[bn]&&a[an]<b[bn+1]){
        cout << a[an] << endl;
    }else if(b[bn]>=a[an]&&b[bn]<a[an+1]){
        cout << b[bn] << endl;
    }else{
        cout<<-1 <<endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,max_num=0,next_num=0;
    std::deque<int> array;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a;
        array.emplace_back(a);
        if (max_num<a) {
            max_num=a;
        } else if (next_num<a) {
            next_num=a;
        }
    }
    for (int j=0;j<n;j++) {
        if (array[j]<max_num) {
            cout<<max_num<<endl;
        } else {
            cout<<next_num<<endl;
        }
    }
}


Measured memory_bytes: 2432
k = gets.chomp.to_i

$num = [0,1]

def add(d)
	if $num[d+1]==nil
		if $num[d]==9
			$num << 1
			$num[d] = 0
		else
			$num[d] += 1
		end
	elsif $num[d]==9 || $num[d]==($num[d+1]+1)
		add(d+1)
		if $num[d+1]==0 then
			$num[d] = 0
		else
			$num[d] = $num[d+1]-1
		end
	else
		$num[d] += 1
	end
end

if k<=10 then
	print(k)
else
	(k-10).times do 
		add(0)
	end
	ans = 0
	0.upto($num.length-1) do |i| 
		ans += $num[i]*10**i
	end
	print(ans)
end


Measured memory_bytes: 1788
#include<cstdio>

#define REP(i,n)   for(int i=0;i<(n);++i)
int b[100000];

int main(){
    int n,min=1e9+7,d=0,cnt=0;
    scanf("%d%*d",&n);
    REP(i,n) scanf("%d",b+i);
    REP(i,n){
        int a=b[i];
        if(min>a) min = a;
        else if(d==a-min) ++cnt;
        else if(d<a-min){
            d = a - min;
            cnt = 1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main()
{
	int k,i;
	char s[100];
	char *str;
	scanf("%d", &k);
	scanf("%s", &s);
	str = s;
	if (strlen(s) <= k) {
		while (*str != '\0') {
			printf("%c", *str);
			str++;
		}
	}
	else {
		for (i = 0; i < k; i++) {
			printf("%c", *str);
			str++;
		}
		printf("...");
	}

	return 0;
}

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

int main() {
    int X, Y; cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (2 * i + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	string s; cin >> s;
	int n = s.length();
	if (n < 4)cout << "No" << endl;
	else {
		string u = s.substr(0, 4);
		if (u == "YAKI")cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var r, b int
	for _, c := range s {
		if c == '0' {
			b++
		} else {
			r++
		}
	}
	min := r
	if min > b {
		min = b
	}
	fmt.Println(min * 2)
}


Measured memory_bytes: 2488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k;
    cin>>s>>k;
    string tmp;
    vector<string> fin;
    for(int i=0;i<s.size();i++){
        for(int j=1;j<=k;j++){
            tmp=s.substr(i,j);
            fin.push_back(tmp);
        }
    }

    sort(fin.begin(),fin.end());
    fin.erase(unique(fin.begin(),fin.end()),fin.end());
        
    cout<<fin[k-1]<<endl;
    return 0;
}


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

int main(){
    int n, num;
    char card;
    bool cards[4][13]; // 0: Spade, 1: Heard, 2: Club, 3: Diamond
    char p[4] = {'S', 'H', 'C', 'D'};
    std::fill(cards[0], cards[4], false);
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> card >> num;
        switch(card){
            case 'S':
                cards[0][num-1] = true;
                break;
            case 'H':
                cards[1][num-1] = true;
                break;
            case 'C':
                cards[2][num-1] = true;
                break;
            case 'D':
                cards[3][num-1] = true;
                break;
        }
    }

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(!cards[i][j])
                cout << p[i] << " " << j+1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int A,B,C,D,k;
bool pd(int x){
	if(x==0) return 1;
	if(x%(k+1)==0) x--;
	int cntB=x/(k+1),cntA=x-cntB;
	if((A-cntA+1)*(long long)k>=B-cntB)
		return 1;
	return 0;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&A,&B,&C,&D);
		if(A>B) k=(A-1)/(B+1)+1;
		else k=(B-1)/(A+1)+1;
		int l=0,r=A+B,mid,ans=0;
		while(l<=r){
			mid=(l+r)>>1;
			if(pd(mid))ans=mid,l=mid+1;
			else r=mid-1;
		}
		l=ans;
		//printf("k:%d l:%d\n",k,l);
		for(int i=C;i<=D;i++){
			if(i<=l){
				if(i%(k+1)==0) printf("B");
				else printf("A");
			}
			else{
				if((A+B+1-i)%(k+1)==0) printf("A");
				else printf("B");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		String[] s = new String[N];
		int[] t = new int[N];
		for(int i = 0; i < N; i++) {
			s[i] = stdIn.next();
			t[i] = stdIn.nextInt();
		}
		String X = stdIn.next();
		int ind = 0;
		int sum = 0;
		for(int i = 0; i < N; i++) {
			if(s[i].equals(X)) {
				ind = i;
				break;
			}
		}
		for(int i = ind+1; i < N; i++) {
			sum += t[i];
		}
		
		
		System.out.println(sum);

	}

}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int n){
    for(int i=0; i<n; i++){
        for(int j=n-1; j>=i; j--){
            if(A[j].value < A[j-1].value){
                //swap(A[j].value, A[j-1].value);
                Card t = A[j];
                A[j]=A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int n){
    for(int i=0; i<n; i++){
        int minj = i;
        for(int j=i; j<n; j++)
            if(A[j].value < A[minj].value) minj = j;
        //swap(A[i].value, A[minj].value);
        Card t = A[i]; A[i]=A[minj]; A[minj]=t;
    }
}

void print(struct Card A[], int n){
    for(int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int n){
    for(int i=0; i<n; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int n;
    char ch;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for(int i=0; i<n; i++) C2[i] = C1[i];
    
    bubble(C1, n);
    selection (C2, n);
    
    print(C1, n);
    cout << "Stable" << endl;
    print(C2, n);
    if(isStable(C1, C2, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

signed main()
{
	long double A;
	long double B;
	cin >> A >> B;
	cout << (int)(A * B) << endl;


}




Measured memory_bytes: 3732
N,Q=map(int,input().split())
S=input()
t = [0]*(N+1)
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        t[i+1] = 1

import numpy
res = numpy.cumsum(t)

for _ in range(Q):
    l=list(map(int,input().split()))
    print(res[l[1]-1]-res[l[0]-1])

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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.

  i32 n;
  cin >> n;
  vi32 h(n);
  REP(i, 0, n) {
    cin >> h[i];
  }

  i32 hMax = 0;
  i32 ret = 0;
  REP(i, 0, n) {
    if (h[i] >= hMax) ret++;
    hMax = max(hMax, h[i]);
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let s = get_chars();
    let ans = std::cmp::min(
        vec_sum(&s.iter().enumerate().map(|(i, &c)| if i%2==0&&c=='1'||i%2==1&&c=='0' {0} else {1}).collect()),
        vec_sum(&s.iter().enumerate().map(|(i, &c)| if i%2==0&&c=='1'||i%2==1&&c=='0' {1} else {0}).collect())
        );
    println!("{}", ans);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


Measured memory_bytes: 6396
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

divs = factorization(N)

n = len(divs)
ans = 0

for i in range(n):
    div,num = divs[i]
    cnt = 0
    now = 1
    while 1:
        if num >= now:
            num -= now
            now += 1
            cnt += 1
        else:
            break
    ans += cnt
if N == 1:
    print(0)
    exit()
print(ans)
    




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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M,R;
vector<int> A;
ll edgeL [201] [201],edgeS [201] [201];
ll dp [1001] [201];
const ll INF = 1e18;

int main()
{
	while(cin >> N >> M && N){
		fill(edgeL [0],edgeL [201],INF);
		fill(edgeS [0],edgeS [201],INF);
		FOR(i,1,N + 1){
			edgeL [i] [i] = 0;
			edgeS [i] [i] = 0;
		}
		FOR(i,0,M){
			int u,v,w;
			char c;
			cin >> u >> v >> w >> c;
			if(c == 'L'){
				chmin(edgeL [u] [v],(ll) w);
				chmin(edgeL [v] [u],(ll) w);
			}
			else{
				chmin(edgeS [u] [v],(ll) w);
				chmin(edgeS [v] [u],(ll) w);
			}
		}
		cin >> R;
		A.assign(R,0);
		FOR(i,0,R){
			scanf("%d",&A [i]);
		}

		FOR(k,1,N + 1) FOR(i,1,N + 1) FOR(j,1,N + 1){
			chmin(edgeL [i] [j],edgeL [i] [k] + edgeL [k] [j]);
			edgeL [j] [i] = edgeL [i] [j];
			chmin(edgeS [i] [j],edgeS [i] [k] + edgeS [k] [j]);
			edgeS [j] [i] = edgeS [i] [j];
		}

		fill(dp [0],dp [1001],INF);
		dp [0] [A.front()] = 0;
		FOR(i,0,R - 1) FOR(j,1,N + 1) if(dp [i] [j] < INF){
			chmin(dp [i + 1] [j],dp [i] [j] + edgeL [A [i]] [A [i + 1]]);
			FOR(nxt,1,N + 1){
				chmin(dp [i + 1] [nxt],dp [i] [j] + edgeL [A [i]] [j] + edgeS [j] [nxt] + edgeL [nxt] [A [i + 1]]);
			}
		}
		printf("%lld\n",*min_element(dp [R - 1],dp [R]));
	}

	return 0;
}

Measured memory_bytes: 5336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int bfs(int &h, int &w, vector<string> &grid, int &i, int &j) {
  vector<vector<int>> visit(h, vector<int>(w, 0));
  queue<vector<int>> task;
  task.push({i, j});
  visit.at(i).at(j) = 1;
  int cnt = 0;
  while (task.size() > 0) {
    int sz = task.size();
    for (int i = 0; i < sz; i++) {
      int x = task.front().at(0), y = task.front().at(1);
      if (x + 1 < h && visit.at(x + 1).at(y) == 0
          && grid.at(x + 1).at(y) == '.') {
        task.push({x + 1, y});
        visit.at(x + 1).at(y) = 1;
      }
      if (x - 1 >= 0 && visit.at(x - 1).at(y) == 0
          && grid.at(x - 1).at(y) == '.') {
        task.push({x - 1, y});
        visit.at(x - 1).at(y) = 1;
      }
      if (y + 1 < w && visit.at(x).at(y + 1) == 0
          && grid.at(x).at(y + 1) == '.') {
        task.push({x, y + 1});
        visit.at(x).at(y + 1) = 1;
      }
      if (y - 1 >= 0 && visit.at(x).at(y - 1) == 0
          && grid.at(x).at(y - 1) == '.') {
        task.push({x, y - 1});
        visit.at(x).at(y - 1) = 1;
      }
      task.pop();
    }
    cnt++;
  }
  return cnt;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  priority_queue<int> ans;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') continue;
      ans.push(bfs(h, w, grid, i, j));
    }
  }
  cout << ans.top() - 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  int count = 0;
  for (int i = 0, m = N, P; i < N; i++) {
    scanf("%d", &P);
    if (P <= m) {
      m = P;
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        char[] s = scanner.next().toCharArray();
        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < s.length; i = i + 2) {
            ans.append(s[i]);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
int main() {
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    unordered_map<int,ll> m;
    for(int i=0;i<n;i++){
    	m[s[i]]++;
    }
    ll dp[n+1];
    dp[0]=1;
    for(int i=1;i<=n;i++){
    	dp[i]=(dp[i-1]*2)%mod;
    }
    ll pre=0;
    ll f=1;
    ll ans=(dp[n]-1)%mod;
    for(auto x : m){
    	ll a=x.second; ll b=n-a-pre;
    	pre+=a;
    	ll d=(dp[a]-a-1)%mod;
    	ll g=dp[b];
    	ans=(ans-(((d*g)%mod)*f)%mod + mod)%mod;
    	f=(f*(a+1))%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 1232
N, K = map(int, input().split())
W = []
for _ in range(N):
  W.append(int(input()))
    
def carriable(p):
  if p < max(W):
    return False
  
  k_count = 0
  current_weight = 0
  for w in W:
    if current_weight + w <= p:
      current_weight += w
    else:
      if k_count + 1 < K:
        k_count += 1
        current_weight = w
      else:
        return False
      
  return True

def solve():
  min_p = 0
  max_p = sum(W)
  current_p = (max_p + min_p) // 2
  
  while True:    
    if min_p == current_p:
      return max_p
    
    if carriable(current_p):
      max_p = current_p
    else:
      min_p = current_p
    current_p = (max_p + min_p) // 2
    
print(solve())


Measured memory_bytes: 9560
S = gets.chomp
N = S.length

cand1 = 0   #cost start from 0
cand2 = 0   #cost start from 1
for i in 1..N do
  if i % 2 == 0 then
    if S[i-1] == "0" then
      cand2 += 1
    else
      cand1 += 1
    end
  else
    if S[i-1] == "1" then
      cand2 += 1
    else
      cand1 += 1
    end
  end
end
    
if cand1 < cand2 then
  puts cand1
else
  puts cand2
end

Measured memory_bytes: 14408
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=[0]*N
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp[t-1]+=1
		else:
			A+=1
			W+=tmp[t-1]
			L[t-1]=1
print(A,W)

Measured memory_bytes: 4596
n = int(input())
c = str(input())

r_m = c.count('R')
w_m = 0
out = max(r_m, w_m)
for i in range(n):
    if c[i] == 'W':
        w_m += 1
    else:
        r_m -= 1
    out = min(out, max(w_m, r_m))
print(out)


Measured memory_bytes: 9432
class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        # k+1ではなくkでは？
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
from collections import defaultdict
import sys;input=sys.stdin.readline
N, = map(int, input().split())

A = [0] + list(map(int, input().split()))
G = [[] for _ in range(N+1)]
for v in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

iA = [(i, a) for i, a in enumerate(A)]
iA.sort(key=lambda x:x[1])
d = dict()
AA = [0]*(N+1)
a2f = [0]*(N+1)
rj = 0
for j, (i, a) in enumerate(iA):
    AA[i] = j
    if a not in d:
        rj = j
    a2f[i] = rj
    d[a] = 1
#print(AA, a2f)

R = [0]*(N+1)
R[1] = 1
ss = SegTree([0]*(N+1), N+1, -1, max)
stack = [1]
visited = set([1])
path = []
while stack:
    v = stack.pop()
    if v > 0:
        path.append(v)
        qq = ss.query(0, a2f[v])
        ss.update(AA[v], qq+1)
#        print(v, qq)
        R[v] = ss.query(0, N+1)
        for u in G[v]:
            if u in visited:
                continue
            visited.add(u)
            stack += [-v, u]
    else:
        c = path.pop()
        ss.update(AA[c], 0)
for i in range(1, N+1):
    print(R[i])


Measured memory_bytes: 178464